Mercurial > pidgin
annotate src/log.c @ 5554:7b36d02031a2
[gaim-migrate @ 5955]
More work done... Got some painful stuff to do now.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 30 May 2003 00:00:48 +0000 |
| parents | 80e4ba770f97 |
| children | b7319c094153 |
| 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 | |
| 292 if ((logging_options & why) != why) | |
| 293 return; | |
| 294 | |
| 295 if (logging_options & OPT_LOG_INDIVIDUAL) { | |
| 296 if (why & OPT_LOG_MY_SIGNON) | |
| 297 fd = open_system_log_file(gc ? gc->username : NULL); | |
| 298 else | |
| 299 fd = open_system_log_file(who->name); | |
| 300 } else | |
| 301 fd = open_system_log_file(NULL); | |
| 302 | |
| 303 if (!fd) | |
| 304 return; | |
| 305 | |
| 306 if (why & OPT_LOG_MY_SIGNON) { | |
| 307 switch (what) { | |
| 308 case log_signon: | |
| 4195 | 309 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
310 gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 311 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 312 break; | |
| 313 case log_signoff: | |
| 4195 | 314 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
315 gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 316 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 317 break; | |
| 318 case log_away: | |
| 4195 | 319 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
|
320 gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 321 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 322 break; | |
| 323 case log_back: | |
| 4195 | 324 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
325 gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 326 g_snprintf(html, sizeof(html), "%s", text); |
| 327 break; | |
| 328 case log_idle: | |
| 4195 | 329 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
330 gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 331 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 332 break; | |
| 333 case log_unidle: | |
| 4195 | 334 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
|
335 gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 336 g_snprintf(html, sizeof(html), "%s", text); |
| 337 break; | |
| 338 case log_quit: | |
| 4195 | 339 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
| 4184 | 340 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 341 break; | |
| 342 } | |
| 4687 | 343 } else if (gaim_get_buddy_alias_only(who)) { |
| 4184 | 344 switch (what) { |
| 345 case log_signon: | |
| 4195 | 346 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
|
347 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 348 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 349 break; | |
| 350 case log_signoff: | |
| 4195 | 351 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
|
352 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 353 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 354 break; | |
| 355 case log_away: | |
| 4195 | 356 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
|
357 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 358 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 359 break; | |
| 360 case log_back: | |
| 4195 | 361 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
|
362 gc->username, 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 case log_idle: | |
| 4195 | 366 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
|
367 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 368 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 369 break; | |
| 370 case log_unidle: | |
| 371 g_snprintf(text, sizeof(text), | |
| 4195 | 372 _("%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
|
373 gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 374 g_snprintf(html, sizeof(html), "%s", text); |
| 375 break; | |
| 376 default: | |
| 377 fclose(fd); | |
| 378 return; | |
| 379 break; | |
| 380 } | |
| 381 } else { | |
| 382 switch (what) { | |
| 383 case log_signon: | |
| 4195 | 384 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
|
385 gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 386 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 387 break; | |
| 388 case log_signoff: | |
| 4195 | 389 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
|
390 gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 391 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 392 break; | |
| 393 case log_away: | |
| 4195 | 394 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
|
395 gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 396 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 397 break; | |
| 398 case log_back: | |
| 4195 | 399 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
|
400 gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 401 g_snprintf(html, sizeof(html), "%s", text); |
| 402 break; | |
| 403 case log_idle: | |
| 4195 | 404 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
|
405 gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 406 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 407 break; | |
| 408 case log_unidle: | |
| 409 g_snprintf(text, sizeof(text), | |
| 4195 | 410 _("%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
|
411 gc->prpl->info->name, who->name, full_date()); |
| 4184 | 412 g_snprintf(html, sizeof(html), "%s", text); |
| 413 break; | |
| 414 default: | |
| 415 fclose(fd); | |
| 416 return; | |
| 417 break; | |
| 418 } | |
| 419 } | |
| 420 | |
| 5548 | 421 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
| 4184 | 422 fprintf(fd, "---- %s ----\n", text); |
| 423 } else { | |
| 424 if (logging_options & OPT_LOG_INDIVIDUAL) | |
| 425 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); | |
| 426 else | |
| 427 fprintf(fd, "%s<BR>\n", html); | |
| 428 } | |
| 429 | |
| 430 fclose(fd); | |
| 431 } | |
|
4359
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 char *html_logize(const char *p) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
434 { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
435 const char *temp_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
436 char *buffer_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
437 char *buffer_start; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
438 int num_cr = 0; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
439 int char_len = 0; |
|
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 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 char_len++; |
|
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 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 num_cr++; |
|
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 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
448 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
|
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 for (temp_p = p, buffer_start = buffer_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 *temp_p != '\0'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 temp_p++) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
454 if (*temp_p == '\n') { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 *buffer_p++ = '<'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 *buffer_p++ = 'B'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
457 *buffer_p++ = 'R'; |
|
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++ = '\n'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
462 *buffer_p++ = '&'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
463 *buffer_p++ = 'l'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
464 *buffer_p++ = 't'; |
|
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 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
467 } else |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
468 *buffer_p++ = *temp_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 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
471 *buffer_p = '\0'; |
|
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 return buffer_start; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
474 } |
