comparison plugins/history.c @ 8898:de87e510ff9a

[gaim-migrate @ 9667] This makes the history plugin work in chats and not just conversations. To do this I had to change some functions in log.c to pass around the GaimLogType (GAIM_LOG_IM, GAIM_LOG_CHAT, or GAIM_LOG_SYSTEM). I hope that's not a problem... Here's how I see it: When creating a new GaimLog you need 3 things, the type, your account and the name of the other person/chat. It only makes sense that you would need those same 3 things to find a log. Or to calculate log size. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 07 May 2004 02:30:02 +0000
parents d7b8eb1f0a18
children d729311f6352
comparison
equal deleted inserted replaced
8897:8ffd1679df93 8898:de87e510ff9a
19 #define HISTORY_SIZE (4 * 1024) 19 #define HISTORY_SIZE (4 * 1024)
20 20
21 static void historize(GaimConversation *c) 21 static void historize(GaimConversation *c)
22 { 22 {
23 GaimGtkConversation *gtkconv; 23 GaimGtkConversation *gtkconv;
24 GaimConversationType convtype;
24 char *history = NULL; 25 char *history = NULL;
25 guint flags; 26 guint flags;
26 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; 27 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS;
27 GList *logs = gaim_log_get_logs(gaim_conversation_get_name(c), 28 GList *logs = NULL;
28 gaim_conversation_get_account(c)); 29
30 convtype = gaim_conversation_get_type(c);
31 if (convtype == GAIM_CONV_IM)
32 logs = gaim_log_get_logs(GAIM_LOG_IM,
33 gaim_conversation_get_name(c), gaim_conversation_get_account(c));
34 else if (convtype == GAIM_CONV_CHAT)
35 logs = gaim_log_get_logs(GAIM_LOG_CHAT,
36 gaim_conversation_get_name(c), gaim_conversation_get_account(c));
29 37
30 if (!logs) 38 if (!logs)
31 return; 39 return;
40
32 history = gaim_log_read((GaimLog*)logs->data, &flags); 41 history = gaim_log_read((GaimLog*)logs->data, &flags);
33 gtkconv = GAIM_GTK_CONVERSATION(c); 42 gtkconv = GAIM_GTK_CONVERSATION(c);
34 if (flags & GAIM_LOG_READ_NO_NEWLINE) 43 if (flags & GAIM_LOG_READ_NO_NEWLINE)
35 options |= GTK_IMHTML_NO_NEWLINE; 44 options |= GTK_IMHTML_NO_NEWLINE;
36 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options); 45 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options);
37 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options); 46 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options);
38 gtk_imhtml_scroll_to_end(GTK_IMHTML(gtkconv->imhtml)); 47 gtk_imhtml_scroll_to_end(GTK_IMHTML(gtkconv->imhtml));
39 g_free(history); 48 g_free(history);
49
40 while (logs) { 50 while (logs) {
41 GaimLog *log = logs->data; 51 GaimLog *log = logs->data;
42 GList *logs2; 52 GList *logs2;
43 gaim_log_free(log); 53 gaim_log_free(log);
44 logs2 = logs->next; 54 logs2 = logs->next;
45 g_list_free_1(logs); 55 g_list_free_1(logs);
46 logs = logs2; 56 logs = logs2;
47 } 57 }
48
49 } 58 }
50 59
51 static gboolean 60 static gboolean
52 plugin_load(GaimPlugin *plugin) 61 plugin_load(GaimPlugin *plugin)
53 { 62 {