Mercurial > pidgin.yaz
annotate src/log.c @ 5896:a156d08e481e
[gaim-migrate @ 6328]
Groove is in the heart
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 15 Jun 2003 18:22:11 +0000 |
parents | 059d95c67cda |
children | 91ee71a394be |
rev | line source |
---|---|
4184 | 1 /* --------------------------------------------------- |
2 * Function to remove a log file entry | |
3 * --------------------------------------------------- | |
4 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
5 #include "internal.h" |
4195 | 6 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
7 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
8 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
9 #include "log.h" |
4184 | 10 #include "multi.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
11 #include "notify.h" |
5548 | 12 #include "prefs.h" |
4184 | 13 #include "prpl.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
14 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
15 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
16 #include "gtkconv.h" |
4184 | 17 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
18 #include "ui.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
19 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
20 GList *log_conversations = NULL; |
4192
17187504bfc2
[gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4184
diff
changeset
|
21 |
4184 | 22 void rm_log(struct log_conversation *a) |
23 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
24 GaimConversation *cnv = gaim_find_conversation(a->name); |
4184 | 25 |
5528 | 26 /* Added the following if statements for sanity check */ |
27 if (!a) | |
28 { | |
29 gaim_notify_error (NULL, NULL, _("Error in specifying buddy conversation."), NULL); | |
30 return; | |
31 } | |
32 cnv = gaim_find_conversation(a->name); | |
33 if (!cnv) | |
34 { | |
35 gaim_notify_error (NULL, NULL, _("Unable to find conversation log"), NULL); | |
36 return; | |
37 } | |
38 | |
4184 | 39 log_conversations = g_list_remove(log_conversations, a); |
40 } | |
41 | |
42 struct log_conversation *find_log_info(const char *name) | |
43 { | |
44 char *pname = g_malloc(BUF_LEN); | |
45 GList *lc = log_conversations; | |
46 struct log_conversation *l; | |
47 | |
48 | |
49 strcpy(pname, normalize(name)); | |
50 | |
51 while (lc) { | |
52 l = (struct log_conversation *)lc->data; | |
4793 | 53 if (!gaim_utf8_strcasecmp(pname, normalize(l->name))) { |
4184 | 54 g_free(pname); |
55 return l; | |
56 } | |
57 lc = lc->next; | |
58 } | |
59 g_free(pname); | |
60 return NULL; | |
61 } | |
62 | |
63 void update_log_convs() | |
64 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
65 GList *cnv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
66 GaimConversation *c; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
67 GaimGtkConversation *gtkconv; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
68 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
69 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
70 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
71 c = (GaimConversation *)cnv->data; |
4184 | 72 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
73 if (!GAIM_IS_GTK_CONVERSATION(c)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
74 continue; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
75 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
76 gtkconv = GAIM_GTK_CONVERSATION(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
77 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
78 if (gtkconv->toolbar.log) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
79 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
80 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
5548 | 81 !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")); |
4184 | 82 else |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
83 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
5548 | 84 !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); |
4184 | 85 } |
86 } | |
87 } | |
88 | |
4635 | 89 static void do_save_convo(GObject *obj, GtkWidget *wid) |
4184 | 90 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
91 GaimConversation *c = g_object_get_data(obj, "gaim_conversation"); |
4184 | 92 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
93 FILE *f; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
94 |
4184 | 95 if (file_is_dir(filename, wid)) |
96 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
97 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
98 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
99 g_list_find(gaim_get_ims(), c)) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
100 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
101 g_list_find(gaim_get_chats(), c)))) |
4184 | 102 filename = NULL; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
103 |
4184 | 104 gtk_widget_destroy(wid); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
105 |
4184 | 106 if (!filename) |
107 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
108 |
4184 | 109 f = fopen(filename, "w+"); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
110 |
4184 | 111 if (!f) |
112 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
113 |
4184 | 114 fprintf(f, "%s", c->history->str); |
115 fclose(f); | |
116 } | |
117 | |
118 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
119 void save_convo(GtkWidget *save, GaimConversation *c) |
4184 | 120 { |
121 char buf[BUF_LONG]; | |
122 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); | |
123 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); | |
124 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
4635 | 125 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
126 "gaim_conversation", c); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
127 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
4184 | 128 "clicked", G_CALLBACK(do_save_convo), window); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
129 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), |
4184 | 130 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); |
131 gtk_widget_show(window); | |
132 } | |
133 | |
134 static FILE *open_gaim_log_file(const char *name, int *flag) | |
135 { | |
136 char *buf; | |
137 char *buf2; | |
138 char log_all_file[256]; | |
139 struct stat st; | |
140 FILE *fd; | |
141 #ifndef _WIN32 | |
142 int res; | |
143 #endif | |
144 gchar *gaim_dir; | |
145 | |
146 buf = g_malloc(BUF_LONG); | |
147 buf2 = g_malloc(BUF_LONG); | |
148 gaim_dir = gaim_user_dir(); | |
149 | |
150 /* Dont log yourself */ | |
151 strncpy(log_all_file, gaim_dir, 256); | |
152 | |
153 #ifndef _WIN32 | |
154 stat(log_all_file, &st); | |
155 if (!S_ISDIR(st.st_mode)) | |
156 unlink(log_all_file); | |
157 | |
158 fd = fopen(log_all_file, "r"); | |
159 | |
160 if (!fd) { | |
161 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
162 if (res < 0) { | |
163 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
164 log_all_file); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
165 gaim_notify_error(NULL, NULL, buf, NULL); |
4184 | 166 g_free(buf); |
167 g_free(buf2); | |
168 return NULL; | |
169 } | |
170 } else | |
171 fclose(fd); | |
172 | |
173 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
174 | |
175 if (stat(log_all_file, &st) < 0) | |
176 *flag = 1; | |
177 if (!S_ISDIR(st.st_mode)) | |
178 unlink(log_all_file); | |
179 | |
180 fd = fopen(log_all_file, "r"); | |
181 if (!fd) { | |
182 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
183 if (res < 0) { | |
184 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
185 log_all_file); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
186 gaim_notify_error(NULL, NULL, buf, NULL); |
4184 | 187 g_free(buf); |
188 g_free(buf2); | |
189 return NULL; | |
190 } | |
191 } else | |
192 fclose(fd); | |
193 #else /* _WIN32 */ | |
194 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
195 | |
196 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
197 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
198 gaim_notify_error(NULL, NULL, buf, NULL); |
4184 | 199 g_free(buf); |
200 g_free(buf2); | |
201 return NULL; | |
202 } | |
203 #endif | |
204 | |
205 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
206 if (stat(log_all_file, &st) < 0) | |
207 *flag = 1; | |
208 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
209 gaim_debug(GAIM_DEBUG_INFO, "log", "Logging to: \"%s\"\n", log_all_file); |
4184 | 210 |
211 fd = fopen(log_all_file, "a"); | |
212 | |
213 g_free(buf); | |
214 g_free(buf2); | |
215 return fd; | |
216 } | |
217 | |
218 static FILE *open_system_log_file(char *name) | |
219 { | |
220 int x; | |
221 | |
222 if (name) | |
223 return open_log_file(name, 2); | |
224 else | |
225 return open_gaim_log_file("system", &x); | |
226 } | |
227 | |
228 FILE *open_log_file(const char *name, int is_chat) | |
229 { | |
230 struct stat st; | |
231 char realname[256]; | |
232 struct log_conversation *l; | |
233 FILE *fd; | |
234 int flag = 0; | |
235 | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
236 if (((is_chat == 2) && !gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
5548 | 237 || ((is_chat == 1) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")) |
238 || ((is_chat == 0) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims"))) { | |
4184 | 239 |
240 l = find_log_info(name); | |
241 if (!l) | |
242 return NULL; | |
243 | |
244 if (stat(l->filename, &st) < 0) | |
245 flag = 1; | |
246 | |
247 fd = fopen(l->filename, "a"); | |
248 | |
249 if (flag) { /* is a new file */ | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
250 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
4184 | 251 fprintf(fd, _("IM Sessions with %s\n"), name); |
252 } else { | |
253 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
254 fprintf(fd, _("IM Sessions with %s"), name); | |
5138 | 255 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
4184 | 256 } |
257 } | |
258 | |
259 return fd; | |
260 } | |
261 | |
262 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); | |
263 fd = open_gaim_log_file(realname, &flag); | |
264 | |
265 if (fd && flag) { /* is a new file */ | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
266 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
4184 | 267 fprintf(fd, _("IM Sessions with %s\n"), name); |
268 } else { | |
269 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
270 fprintf(fd, _("IM Sessions with %s"), name); | |
5138 | 271 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
4184 | 272 } |
273 } | |
274 | |
275 return fd; | |
276 } | |
277 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
278 void system_log(enum log_event what, GaimConnection *gc, |
4184 | 279 struct buddy *who, int why) |
280 { | |
5896 | 281 GaimAccount *account = NULL; |
4184 | 282 FILE *fd; |
283 char text[256], html[256]; | |
284 | |
5896 | 285 if (gc != NULL) |
286 account = gaim_connection_get_account(gc); | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
287 |
5839 | 288 if ((why & OPT_LOG_MY_SIGNON && |
289 !gaim_prefs_get_bool("/gaim/gtk/logging/log_own_states")) || | |
290 (why & OPT_LOG_BUDDY_SIGNON && | |
291 !gaim_prefs_get_bool("/gaim/gtk/logging/log_signon_signoff")) || | |
292 (why & OPT_LOG_BUDDY_IDLE && | |
293 !gaim_prefs_get_bool("/gaim/gtk/logging/log_idle_state")) || | |
294 (why & OPT_LOG_BUDDY_AWAY && | |
295 !gaim_prefs_get_bool("/gaim/gtk/logging/log_away_state"))) { | |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
296 |
4184 | 297 return; |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
298 } |
4184 | 299 |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
300 if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) { |
4184 | 301 if (why & OPT_LOG_MY_SIGNON) |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
302 fd = open_system_log_file(gc ? (char *)gaim_account_get_username(account) : NULL); |
4184 | 303 else |
304 fd = open_system_log_file(who->name); | |
305 } else | |
306 fd = open_system_log_file(NULL); | |
307 | |
308 if (!fd) | |
309 return; | |
310 | |
311 if (why & OPT_LOG_MY_SIGNON) { | |
312 switch (what) { | |
313 case log_signon: | |
4195 | 314 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
315 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 316 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
317 break; | |
318 case log_signoff: | |
4195 | 319 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
320 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 321 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
322 break; | |
323 case log_away: | |
4195 | 324 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
325 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 326 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
327 break; | |
328 case log_back: | |
4195 | 329 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
330 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 331 g_snprintf(html, sizeof(html), "%s", text); |
332 break; | |
333 case log_idle: | |
4195 | 334 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
335 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 336 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
337 break; | |
338 case log_unidle: | |
4195 | 339 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
340 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 341 g_snprintf(html, sizeof(html), "%s", text); |
342 break; | |
343 case log_quit: | |
4195 | 344 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
4184 | 345 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
346 break; | |
347 } | |
4687 | 348 } else if (gaim_get_buddy_alias_only(who)) { |
4184 | 349 switch (what) { |
350 case log_signon: | |
4195 | 351 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
352 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 353 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
354 break; | |
355 case log_signoff: | |
4195 | 356 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
357 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 358 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
359 break; | |
360 case log_away: | |
4195 | 361 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
362 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 363 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
364 break; | |
365 case log_back: | |
4195 | 366 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
367 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 368 g_snprintf(html, sizeof(html), "%s", text); |
369 break; | |
370 case log_idle: | |
4195 | 371 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
372 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 373 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
374 break; | |
375 case log_unidle: | |
376 g_snprintf(text, sizeof(text), | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
377 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gaim_account_get_username(account), |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
378 gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 379 g_snprintf(html, sizeof(html), "%s", text); |
380 break; | |
381 default: | |
382 fclose(fd); | |
383 return; | |
384 break; | |
385 } | |
386 } else { | |
387 switch (what) { | |
388 case log_signon: | |
4195 | 389 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
390 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 391 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
392 break; | |
393 case log_signoff: | |
4195 | 394 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
395 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 396 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
397 break; | |
398 case log_away: | |
4195 | 399 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
400 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 401 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
402 break; | |
403 case log_back: | |
4195 | 404 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
405 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 406 g_snprintf(html, sizeof(html), "%s", text); |
407 break; | |
408 case log_idle: | |
4195 | 409 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"), |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
410 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 411 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
412 break; | |
413 case log_unidle: | |
414 g_snprintf(text, sizeof(text), | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
415 _("%s (%s) reported that %s returned from idle @ %s"), gaim_account_get_username(account), |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
416 gc->prpl->info->name, who->name, full_date()); |
4184 | 417 g_snprintf(html, sizeof(html), "%s", text); |
418 break; | |
419 default: | |
420 fclose(fd); | |
421 return; | |
422 break; | |
423 } | |
424 } | |
425 | |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
426 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) |
4184 | 427 fprintf(fd, "---- %s ----\n", text); |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
428 else if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
429 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
430 else |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
431 fprintf(fd, "%s<BR>\n", html); |
4184 | 432 |
433 fclose(fd); | |
434 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
435 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
436 char *html_logize(const char *p) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
437 { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
438 const char *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
439 char *buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 char *buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 int num_cr = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 int char_len = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
443 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
444 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 char_len++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
447 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
448 num_cr++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
449 } |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
450 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 for (temp_p = p, buffer_start = buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
454 *temp_p != '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
457 if (*temp_p == '\n') { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
458 *buffer_p++ = '<'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
459 *buffer_p++ = 'B'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 *buffer_p++ = 'R'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 *buffer_p++ = '>'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
462 *buffer_p++ = '\n'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
463 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
464 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
465 *buffer_p++ = '&'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
466 *buffer_p++ = 'l'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
467 *buffer_p++ = 't'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
468 *buffer_p++ = ';'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
469 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
470 } else |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
471 *buffer_p++ = *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
472 } |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
473 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
474 *buffer_p = '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
475 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
476 return buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
477 } |