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