Mercurial > pidgin.yaz
annotate src/log.c @ 5859:022786c7ab53
[gaim-migrate @ 6290]
CUI is gone, long live gaim-remote! The old CUI functionality, which was
for remote-controlling gaim, is now a Core Plugin, so any future UI
(including the current, normal gaim gtk UI) can be remote-controlled.
Applications will soon be able to link against the library and header files
and provide their own remote-control of gaim, but why bother? :) If you
use gaim-remote, make sure to load the new plugin. It won't auto-load.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 14 Jun 2003 06:06:40 +0000 |
parents | 5e685e42931e |
children | 059d95c67cda |
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 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
30 GaimConversation *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 | |
48 struct log_conversation *find_log_info(const char *name) | |
49 { | |
50 char *pname = g_malloc(BUF_LEN); | |
51 GList *lc = log_conversations; | |
52 struct log_conversation *l; | |
53 | |
54 | |
55 strcpy(pname, normalize(name)); | |
56 | |
57 while (lc) { | |
58 l = (struct log_conversation *)lc->data; | |
4793 | 59 if (!gaim_utf8_strcasecmp(pname, normalize(l->name))) { |
4184 | 60 g_free(pname); |
61 return l; | |
62 } | |
63 lc = lc->next; | |
64 } | |
65 g_free(pname); | |
66 return NULL; | |
67 } | |
68 | |
69 void update_log_convs() | |
70 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
71 GList *cnv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
72 GaimConversation *c; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
73 GaimGtkConversation *gtkconv; |
4359
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 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
76 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
77 c = (GaimConversation *)cnv->data; |
4184 | 78 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
79 if (!GAIM_IS_GTK_CONVERSATION(c)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
80 continue; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
81 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
82 gtkconv = GAIM_GTK_CONVERSATION(c); |
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 if (gtkconv->toolbar.log) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
85 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
86 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
5548 | 87 !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")); |
4184 | 88 else |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
89 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
5548 | 90 !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); |
4184 | 91 } |
92 } | |
93 } | |
94 | |
4635 | 95 static void do_save_convo(GObject *obj, GtkWidget *wid) |
4184 | 96 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
97 GaimConversation *c = g_object_get_data(obj, "gaim_conversation"); |
4184 | 98 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
99 FILE *f; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
100 |
4184 | 101 if (file_is_dir(filename, wid)) |
102 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
103 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
104 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
105 g_list_find(gaim_get_ims(), c)) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
106 (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_chats(), c)))) |
4184 | 108 filename = NULL; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
109 |
4184 | 110 gtk_widget_destroy(wid); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
111 |
4184 | 112 if (!filename) |
113 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
114 |
4184 | 115 f = fopen(filename, "w+"); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
116 |
4184 | 117 if (!f) |
118 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
119 |
4184 | 120 fprintf(f, "%s", c->history->str); |
121 fclose(f); | |
122 } | |
123 | |
124 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
125 void save_convo(GtkWidget *save, GaimConversation *c) |
4184 | 126 { |
127 char buf[BUF_LONG]; | |
128 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); | |
129 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); | |
130 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
4635 | 131 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
132 "gaim_conversation", c); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
133 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
4184 | 134 "clicked", G_CALLBACK(do_save_convo), window); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
135 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), |
4184 | 136 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); |
137 gtk_widget_show(window); | |
138 } | |
139 | |
140 static FILE *open_gaim_log_file(const char *name, int *flag) | |
141 { | |
142 char *buf; | |
143 char *buf2; | |
144 char log_all_file[256]; | |
145 struct stat st; | |
146 FILE *fd; | |
147 #ifndef _WIN32 | |
148 int res; | |
149 #endif | |
150 gchar *gaim_dir; | |
151 | |
152 buf = g_malloc(BUF_LONG); | |
153 buf2 = g_malloc(BUF_LONG); | |
154 gaim_dir = gaim_user_dir(); | |
155 | |
156 /* Dont log yourself */ | |
157 strncpy(log_all_file, gaim_dir, 256); | |
158 | |
159 #ifndef _WIN32 | |
160 stat(log_all_file, &st); | |
161 if (!S_ISDIR(st.st_mode)) | |
162 unlink(log_all_file); | |
163 | |
164 fd = fopen(log_all_file, "r"); | |
165 | |
166 if (!fd) { | |
167 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
168 if (res < 0) { | |
169 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
170 log_all_file); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
171 gaim_notify_error(NULL, NULL, buf, NULL); |
4184 | 172 g_free(buf); |
173 g_free(buf2); | |
174 return NULL; | |
175 } | |
176 } else | |
177 fclose(fd); | |
178 | |
179 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
180 | |
181 if (stat(log_all_file, &st) < 0) | |
182 *flag = 1; | |
183 if (!S_ISDIR(st.st_mode)) | |
184 unlink(log_all_file); | |
185 | |
186 fd = fopen(log_all_file, "r"); | |
187 if (!fd) { | |
188 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
189 if (res < 0) { | |
190 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
191 log_all_file); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
192 gaim_notify_error(NULL, NULL, buf, NULL); |
4184 | 193 g_free(buf); |
194 g_free(buf2); | |
195 return NULL; | |
196 } | |
197 } else | |
198 fclose(fd); | |
199 #else /* _WIN32 */ | |
200 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
201 | |
202 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
203 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
|
204 gaim_notify_error(NULL, NULL, buf, NULL); |
4184 | 205 g_free(buf); |
206 g_free(buf2); | |
207 return NULL; | |
208 } | |
209 #endif | |
210 | |
211 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
212 if (stat(log_all_file, &st) < 0) | |
213 *flag = 1; | |
214 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
215 gaim_debug(GAIM_DEBUG_INFO, "log", "Logging to: \"%s\"\n", log_all_file); |
4184 | 216 |
217 fd = fopen(log_all_file, "a"); | |
218 | |
219 g_free(buf); | |
220 g_free(buf2); | |
221 return fd; | |
222 } | |
223 | |
224 static FILE *open_system_log_file(char *name) | |
225 { | |
226 int x; | |
227 | |
228 if (name) | |
229 return open_log_file(name, 2); | |
230 else | |
231 return open_gaim_log_file("system", &x); | |
232 } | |
233 | |
234 FILE *open_log_file(const char *name, int is_chat) | |
235 { | |
236 struct stat st; | |
237 char realname[256]; | |
238 struct log_conversation *l; | |
239 FILE *fd; | |
240 int flag = 0; | |
241 | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
242 if (((is_chat == 2) && !gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
5548 | 243 || ((is_chat == 1) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")) |
244 || ((is_chat == 0) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims"))) { | |
4184 | 245 |
246 l = find_log_info(name); | |
247 if (!l) | |
248 return NULL; | |
249 | |
250 if (stat(l->filename, &st) < 0) | |
251 flag = 1; | |
252 | |
253 fd = fopen(l->filename, "a"); | |
254 | |
255 if (flag) { /* is a new file */ | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
256 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
4184 | 257 fprintf(fd, _("IM Sessions with %s\n"), name); |
258 } else { | |
259 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
260 fprintf(fd, _("IM Sessions with %s"), name); | |
5138 | 261 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
4184 | 262 } |
263 } | |
264 | |
265 return fd; | |
266 } | |
267 | |
268 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); | |
269 fd = open_gaim_log_file(realname, &flag); | |
270 | |
271 if (fd && flag) { /* is a new file */ | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
272 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
4184 | 273 fprintf(fd, _("IM Sessions with %s\n"), name); |
274 } else { | |
275 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
276 fprintf(fd, _("IM Sessions with %s"), name); | |
5138 | 277 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
4184 | 278 } |
279 } | |
280 | |
281 return fd; | |
282 } | |
283 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
284 void system_log(enum log_event what, GaimConnection *gc, |
4184 | 285 struct buddy *who, int why) |
286 { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
287 GaimAccount *account; |
4184 | 288 FILE *fd; |
289 char text[256], html[256]; | |
290 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
291 account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
292 |
5839 | 293 if ((why & OPT_LOG_MY_SIGNON && |
294 !gaim_prefs_get_bool("/gaim/gtk/logging/log_own_states")) || | |
295 (why & OPT_LOG_BUDDY_SIGNON && | |
296 !gaim_prefs_get_bool("/gaim/gtk/logging/log_signon_signoff")) || | |
297 (why & OPT_LOG_BUDDY_IDLE && | |
298 !gaim_prefs_get_bool("/gaim/gtk/logging/log_idle_state")) || | |
299 (why & OPT_LOG_BUDDY_AWAY && | |
300 !gaim_prefs_get_bool("/gaim/gtk/logging/log_away_state"))) { | |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
301 |
4184 | 302 return; |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
303 } |
4184 | 304 |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
305 if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) { |
4184 | 306 if (why & OPT_LOG_MY_SIGNON) |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
307 fd = open_system_log_file(gc ? (char *)gaim_account_get_username(account) : NULL); |
4184 | 308 else |
309 fd = open_system_log_file(who->name); | |
310 } else | |
311 fd = open_system_log_file(NULL); | |
312 | |
313 if (!fd) | |
314 return; | |
315 | |
316 if (why & OPT_LOG_MY_SIGNON) { | |
317 switch (what) { | |
318 case log_signon: | |
4195 | 319 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %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), "<B>%s</B>", text); |
322 break; | |
323 case log_signoff: | |
4195 | 324 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %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), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
327 break; | |
328 case log_away: | |
4195 | 329 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
|
330 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 331 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
332 break; | |
333 case log_back: | |
4195 | 334 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %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), "%s", text); |
337 break; | |
338 case log_idle: | |
4195 | 339 g_snprintf(text, sizeof(text), _("+++ %s (%s) became 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), "<FONT COLOR=GRAY>%s</FONT>", text); |
342 break; | |
343 case log_unidle: | |
4195 | 344 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
|
345 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
4184 | 346 g_snprintf(html, sizeof(html), "%s", text); |
347 break; | |
348 case log_quit: | |
4195 | 349 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
4184 | 350 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
351 break; | |
352 } | |
4687 | 353 } else if (gaim_get_buddy_alias_only(who)) { |
4184 | 354 switch (what) { |
355 case log_signon: | |
4195 | 356 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
|
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), "<B>%s</B>", text); |
359 break; | |
360 case log_signoff: | |
4195 | 361 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
|
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), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
364 break; | |
365 case log_away: | |
4195 | 366 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
|
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), "<FONT COLOR=OLIVE>%s</FONT>", text); |
369 break; | |
370 case log_back: | |
4195 | 371 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
|
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), "%s", text); |
374 break; | |
375 case log_idle: | |
4195 | 376 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
|
377 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 378 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
379 break; | |
380 case log_unidle: | |
381 g_snprintf(text, sizeof(text), | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
382 _("%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
|
383 gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 384 g_snprintf(html, sizeof(html), "%s", text); |
385 break; | |
386 default: | |
387 fclose(fd); | |
388 return; | |
389 break; | |
390 } | |
391 } else { | |
392 switch (what) { | |
393 case log_signon: | |
4195 | 394 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
|
395 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 396 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
397 break; | |
398 case log_signoff: | |
4195 | 399 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
|
400 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 401 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
402 break; | |
403 case log_away: | |
4195 | 404 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
|
405 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 406 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
407 break; | |
408 case log_back: | |
4195 | 409 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
|
410 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 411 g_snprintf(html, sizeof(html), "%s", text); |
412 break; | |
413 case log_idle: | |
4195 | 414 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
|
415 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
4184 | 416 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
417 break; | |
418 case log_unidle: | |
419 g_snprintf(text, sizeof(text), | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
420 _("%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
|
421 gc->prpl->info->name, who->name, full_date()); |
4184 | 422 g_snprintf(html, sizeof(html), "%s", text); |
423 break; | |
424 default: | |
425 fclose(fd); | |
426 return; | |
427 break; | |
428 } | |
429 } | |
430 | |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
431 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) |
4184 | 432 fprintf(fd, "---- %s ----\n", text); |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
433 else if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
434 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
435 else |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
436 fprintf(fd, "%s<BR>\n", html); |
4184 | 437 |
438 fclose(fd); | |
439 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 char *html_logize(const char *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 const char *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
444 char *buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 char *buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 int num_cr = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
447 int char_len = 0; |
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 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
450 char_len++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 num_cr++; |
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 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
457 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
458 for (temp_p = p, buffer_start = buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
459 *temp_p != '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 temp_p++) { |
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 if (*temp_p == '\n') { |
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++ = 'B'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
465 *buffer_p++ = 'R'; |
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 *buffer_p++ = '\n'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
468 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
469 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
470 *buffer_p++ = '&'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
471 *buffer_p++ = 'l'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
472 *buffer_p++ = 't'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
473 *buffer_p++ = ';'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
474 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
475 } else |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
476 *buffer_p++ = *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
477 } |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
478 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
479 *buffer_p = '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
480 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
481 return buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
482 } |