Mercurial > pidgin
annotate src/log.c @ 5564:187c740f2a4e
[gaim-migrate @ 5966]
Committing what I have so far.
Some new functions, and msn is almost done.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 30 May 2003 18:04:45 +0000 |
| parents | 9eb5b13fd412 |
| children | b07aa997ddd8 |
| 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 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
286 void system_log(enum log_event what, GaimConnection *gc, |
| 4184 | 287 struct buddy *who, int why) |
| 288 { | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
289 GaimAccount *account; |
| 4184 | 290 FILE *fd; |
| 291 char text[256], html[256]; | |
| 292 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
293 account = gaim_connection_get_account(gc); |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
294 |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
295 if (((why & OPT_LOG_MY_SIGNON) && |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
296 !gaim_prefs_get_bool("/gaim/gtk/logging/log_own_states"))) { |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
297 |
| 4184 | 298 return; |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
299 } |
| 4184 | 300 |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
301 if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) { |
| 4184 | 302 if (why & OPT_LOG_MY_SIGNON) |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
303 fd = open_system_log_file(gc ? (char *)gaim_account_get_username(account) : NULL); |
| 4184 | 304 else |
| 305 fd = open_system_log_file(who->name); | |
| 306 } else | |
| 307 fd = open_system_log_file(NULL); | |
| 308 | |
| 309 if (!fd) | |
| 310 return; | |
| 311 | |
| 312 if (why & OPT_LOG_MY_SIGNON) { | |
| 313 switch (what) { | |
| 314 case log_signon: | |
| 4195 | 315 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
316 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 317 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 318 break; | |
| 319 case log_signoff: | |
| 4195 | 320 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
321 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 322 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 323 break; | |
| 324 case log_away: | |
| 4195 | 325 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
|
326 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 327 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 328 break; | |
| 329 case log_back: | |
| 4195 | 330 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
331 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 332 g_snprintf(html, sizeof(html), "%s", text); |
| 333 break; | |
| 334 case log_idle: | |
| 4195 | 335 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
336 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 337 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 338 break; | |
| 339 case log_unidle: | |
| 4195 | 340 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
|
341 gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 342 g_snprintf(html, sizeof(html), "%s", text); |
| 343 break; | |
| 344 case log_quit: | |
| 4195 | 345 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
| 4184 | 346 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 347 break; | |
| 348 } | |
| 4687 | 349 } else if (gaim_get_buddy_alias_only(who)) { |
| 4184 | 350 switch (what) { |
| 351 case log_signon: | |
| 4195 | 352 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
|
353 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 354 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 355 break; | |
| 356 case log_signoff: | |
| 4195 | 357 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
|
358 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 359 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 360 break; | |
| 361 case log_away: | |
| 4195 | 362 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
|
363 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 364 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 365 break; | |
| 366 case log_back: | |
| 4195 | 367 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
|
368 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 369 g_snprintf(html, sizeof(html), "%s", text); |
| 370 break; | |
| 371 case log_idle: | |
| 4195 | 372 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
|
373 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 374 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 375 break; | |
| 376 case log_unidle: | |
| 377 g_snprintf(text, sizeof(text), | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
378 _("%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
|
379 gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 380 g_snprintf(html, sizeof(html), "%s", text); |
| 381 break; | |
| 382 default: | |
| 383 fclose(fd); | |
| 384 return; | |
| 385 break; | |
| 386 } | |
| 387 } else { | |
| 388 switch (what) { | |
| 389 case log_signon: | |
| 4195 | 390 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
|
391 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 392 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 393 break; | |
| 394 case log_signoff: | |
| 4195 | 395 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
|
396 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 397 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 398 break; | |
| 399 case log_away: | |
| 4195 | 400 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
|
401 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 402 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 403 break; | |
| 404 case log_back: | |
| 4195 | 405 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
|
406 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 407 g_snprintf(html, sizeof(html), "%s", text); |
| 408 break; | |
| 409 case log_idle: | |
| 4195 | 410 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
|
411 gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 412 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 413 break; | |
| 414 case log_unidle: | |
| 415 g_snprintf(text, sizeof(text), | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
416 _("%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
|
417 gc->prpl->info->name, who->name, full_date()); |
| 4184 | 418 g_snprintf(html, sizeof(html), "%s", text); |
| 419 break; | |
| 420 default: | |
| 421 fclose(fd); | |
| 422 return; | |
| 423 break; | |
| 424 } | |
| 425 } | |
| 426 | |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
427 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) |
| 4184 | 428 fprintf(fd, "---- %s ----\n", text); |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
429 else if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
430 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
431 else |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
432 fprintf(fd, "%s<BR>\n", html); |
| 4184 | 433 |
| 434 fclose(fd); | |
| 435 } | |
|
4359
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 char *html_logize(const char *p) |
|
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 const char *temp_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 char *buffer_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 char *buffer_start; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 int num_cr = 0; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
443 int char_len = 0; |
|
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 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 char_len++; |
|
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 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
449 num_cr++; |
|
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 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
|
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 for (temp_p = p, buffer_start = buffer_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 *temp_p != '\0'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 temp_p++) { |
|
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 if (*temp_p == '\n') { |
|
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++ = 'B'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 *buffer_p++ = 'R'; |
|
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++ = '\n'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
464 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
465 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
|
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++ = 'l'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
468 *buffer_p++ = 't'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
469 *buffer_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 } else |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
472 *buffer_p++ = *temp_p; |
|
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 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
475 *buffer_p = '\0'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
476 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
477 return buffer_start; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
478 } |
