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