Mercurial > pidgin
annotate src/log.c @ 7158:aee5fd893aba
[gaim-migrate @ 7725]
I tried to clean up some stuff. I'm not done, but I wanted to commit this
before I break something.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 05 Oct 2003 16:55:20 +0000 |
| parents | 6faeeecab0dc |
| children | 1930e3d00ecd |
| rev | line source |
|---|---|
| 4184 | 1 /* --------------------------------------------------- |
| 2 * Function to remove a log file entry | |
| 3 * --------------------------------------------------- | |
| 4 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
5 #include "internal.h" |
| 4195 | 6 |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
7 #include "conversation.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
8 #include "debug.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
9 #include "log.h" |
| 4184 | 10 #include "multi.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
11 #include "notify.h" |
| 5548 | 12 #include "prefs.h" |
| 4184 | 13 #include "prpl.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
14 #include "util.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
15 |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
16 /* XXX CORE/UI */ |
|
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
17 #include "gtkinternal.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
18 #include "gtkconv.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
19 #include "ui.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
20 |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
21 GList *log_conversations = NULL; |
|
4192
17187504bfc2
[gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4184
diff
changeset
|
22 |
| 4184 | 23 void rm_log(struct log_conversation *a) |
| 24 { | |
|
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
25 GaimConversation *cnv = gaim_find_conversation(a->name); |
| 4184 | 26 |
| 5528 | 27 /* Added the following if statements for sanity check */ |
| 28 if (!a) | |
| 29 { | |
| 30 gaim_notify_error (NULL, NULL, _("Error in specifying buddy conversation."), NULL); | |
| 31 return; | |
| 32 } | |
| 33 cnv = gaim_find_conversation(a->name); | |
| 34 if (!cnv) | |
| 35 { | |
| 36 gaim_notify_error (NULL, NULL, _("Unable to find conversation log"), NULL); | |
| 37 return; | |
| 38 } | |
| 39 | |
| 4184 | 40 log_conversations = g_list_remove(log_conversations, a); |
| 41 } | |
| 42 | |
| 43 struct log_conversation *find_log_info(const char *name) | |
| 44 { | |
| 45 char *pname = g_malloc(BUF_LEN); | |
| 46 GList *lc = log_conversations; | |
| 47 struct log_conversation *l; | |
| 48 | |
| 49 | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
50 strcpy(pname, gaim_normalize(name)); |
| 4184 | 51 |
| 52 while (lc) { | |
| 53 l = (struct log_conversation *)lc->data; | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
54 if (!gaim_utf8_strcasecmp(pname, gaim_normalize(l->name))) { |
| 4184 | 55 g_free(pname); |
| 56 return l; | |
| 57 } | |
| 58 lc = lc->next; | |
| 59 } | |
| 60 g_free(pname); | |
| 61 return NULL; | |
| 62 } | |
| 63 | |
| 64 void update_log_convs() | |
| 65 { | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
66 GList *cnv; |
|
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
67 GaimConversation *c; |
|
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
68 GaimGtkConversation *gtkconv; |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
69 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
70 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
71 |
|
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
72 c = (GaimConversation *)cnv->data; |
| 4184 | 73 |
|
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
74 if (!GAIM_IS_GTK_CONVERSATION(c)) |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
75 continue; |
|
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 gtkconv = GAIM_GTK_CONVERSATION(c); |
|
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 if (gtkconv->toolbar.log) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
80 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
81 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
| 5548 | 82 !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")); |
| 4184 | 83 else |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
84 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
| 5548 | 85 !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); |
| 4184 | 86 } |
| 87 } | |
| 88 } | |
| 89 | |
| 90 static FILE *open_gaim_log_file(const char *name, int *flag) | |
| 91 { | |
| 92 char *buf; | |
| 93 char *buf2; | |
| 94 char log_all_file[256]; | |
| 95 struct stat st; | |
| 96 FILE *fd; | |
| 97 #ifndef _WIN32 | |
| 98 int res; | |
| 99 #endif | |
| 100 gchar *gaim_dir; | |
| 101 | |
| 102 buf = g_malloc(BUF_LONG); | |
| 103 buf2 = g_malloc(BUF_LONG); | |
| 104 gaim_dir = gaim_user_dir(); | |
| 105 | |
| 106 /* Dont log yourself */ | |
| 107 strncpy(log_all_file, gaim_dir, 256); | |
| 108 | |
| 109 #ifndef _WIN32 | |
| 110 stat(log_all_file, &st); | |
| 111 if (!S_ISDIR(st.st_mode)) | |
| 112 unlink(log_all_file); | |
| 113 | |
| 114 fd = fopen(log_all_file, "r"); | |
| 115 | |
| 116 if (!fd) { | |
| 117 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 118 if (res < 0) { | |
| 119 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
| 120 log_all_file); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
121 gaim_notify_error(NULL, NULL, buf, NULL); |
| 4184 | 122 g_free(buf); |
| 123 g_free(buf2); | |
| 124 return NULL; | |
| 125 } | |
| 126 } else | |
| 127 fclose(fd); | |
| 128 | |
| 129 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
| 130 | |
| 131 if (stat(log_all_file, &st) < 0) | |
| 132 *flag = 1; | |
| 133 if (!S_ISDIR(st.st_mode)) | |
| 134 unlink(log_all_file); | |
| 135 | |
| 136 fd = fopen(log_all_file, "r"); | |
| 137 if (!fd) { | |
| 138 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 139 if (res < 0) { | |
| 140 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
| 141 log_all_file); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
142 gaim_notify_error(NULL, NULL, buf, NULL); |
| 4184 | 143 g_free(buf); |
| 144 g_free(buf2); | |
| 145 return NULL; | |
| 146 } | |
| 147 } else | |
| 148 fclose(fd); | |
| 149 #else /* _WIN32 */ | |
| 150 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
| 151 | |
| 152 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
| 153 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
|
154 gaim_notify_error(NULL, NULL, buf, NULL); |
| 4184 | 155 g_free(buf); |
| 156 g_free(buf2); | |
| 157 return NULL; | |
| 158 } | |
| 159 #endif | |
| 160 | |
| 161 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
| 162 if (stat(log_all_file, &st) < 0) | |
| 163 *flag = 1; | |
| 164 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
165 gaim_debug(GAIM_DEBUG_INFO, "log", "Logging to: \"%s\"\n", log_all_file); |
| 4184 | 166 |
| 167 fd = fopen(log_all_file, "a"); | |
| 168 | |
| 169 g_free(buf); | |
| 170 g_free(buf2); | |
| 171 return fd; | |
| 172 } | |
| 173 | |
| 6695 | 174 static FILE *open_system_log_file(const char *name) |
| 4184 | 175 { |
| 176 int x; | |
| 177 | |
| 178 if (name) | |
| 179 return open_log_file(name, 2); | |
| 180 else | |
| 181 return open_gaim_log_file("system", &x); | |
| 182 } | |
| 183 | |
| 184 FILE *open_log_file(const char *name, int is_chat) | |
| 185 { | |
| 186 struct stat st; | |
| 187 char realname[256]; | |
| 188 struct log_conversation *l; | |
| 189 FILE *fd; | |
| 190 int flag = 0; | |
| 191 | |
|
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
192 if (((is_chat == 2) && !gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
| 5548 | 193 || ((is_chat == 1) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")) |
| 194 || ((is_chat == 0) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims"))) { | |
| 4184 | 195 |
| 196 l = find_log_info(name); | |
| 197 if (!l) | |
| 198 return NULL; | |
| 199 | |
| 200 if (stat(l->filename, &st) < 0) | |
| 201 flag = 1; | |
| 202 | |
| 203 fd = fopen(l->filename, "a"); | |
| 204 | |
| 205 if (flag) { /* is a new file */ | |
|
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
206 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
| 4184 | 207 fprintf(fd, _("IM Sessions with %s\n"), name); |
| 208 } else { | |
| 209 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
| 210 fprintf(fd, _("IM Sessions with %s"), name); | |
| 5138 | 211 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
| 4184 | 212 } |
| 213 } | |
| 214 | |
| 215 return fd; | |
| 216 } | |
| 217 | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
218 g_snprintf(realname, sizeof(realname), "%s.log", gaim_normalize(name)); |
| 4184 | 219 fd = open_gaim_log_file(realname, &flag); |
| 220 | |
| 221 if (fd && flag) { /* is a new file */ | |
|
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
222 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
| 4184 | 223 fprintf(fd, _("IM Sessions with %s\n"), name); |
| 224 } else { | |
| 225 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
| 226 fprintf(fd, _("IM Sessions with %s"), name); | |
| 5138 | 227 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
| 4184 | 228 } |
| 229 } | |
| 230 | |
| 231 return fd; | |
| 232 } | |
| 233 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
234 void system_log(enum log_event what, GaimConnection *gc, |
| 6695 | 235 GaimBuddy *who, int why) |
| 4184 | 236 { |
| 5896 | 237 GaimAccount *account = NULL; |
| 4184 | 238 FILE *fd; |
| 239 char text[256], html[256]; | |
| 240 | |
| 5896 | 241 if (gc != NULL) |
| 242 account = gaim_connection_get_account(gc); | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
243 |
| 5839 | 244 if ((why & OPT_LOG_MY_SIGNON && |
| 245 !gaim_prefs_get_bool("/gaim/gtk/logging/log_own_states")) || | |
| 246 (why & OPT_LOG_BUDDY_SIGNON && | |
| 247 !gaim_prefs_get_bool("/gaim/gtk/logging/log_signon_signoff")) || | |
| 248 (why & OPT_LOG_BUDDY_IDLE && | |
| 249 !gaim_prefs_get_bool("/gaim/gtk/logging/log_idle_state")) || | |
| 250 (why & OPT_LOG_BUDDY_AWAY && | |
| 251 !gaim_prefs_get_bool("/gaim/gtk/logging/log_away_state"))) { | |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
252 |
| 4184 | 253 return; |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
254 } |
| 4184 | 255 |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
256 if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) { |
| 4184 | 257 if (why & OPT_LOG_MY_SIGNON) |
| 6695 | 258 fd = open_system_log_file(gc ? gaim_account_get_username(account) : NULL); |
| 4184 | 259 else |
| 260 fd = open_system_log_file(who->name); | |
| 261 } else | |
| 262 fd = open_system_log_file(NULL); | |
| 263 | |
| 264 if (!fd) | |
| 265 return; | |
| 266 | |
| 267 if (why & OPT_LOG_MY_SIGNON) { | |
| 268 switch (what) { | |
| 269 case log_signon: | |
| 4195 | 270 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
271 gaim_account_get_username(account), gc->prpl->info->name, gaim_date_full()); |
| 4184 | 272 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 273 break; | |
| 274 case log_signoff: | |
| 4195 | 275 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
276 gaim_account_get_username(account), gc->prpl->info->name, gaim_date_full()); |
| 4184 | 277 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 278 break; | |
| 279 case log_away: | |
| 4195 | 280 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
281 gaim_account_get_username(account), gc->prpl->info->name, gaim_date_full()); |
| 4184 | 282 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 283 break; | |
| 284 case log_back: | |
| 4195 | 285 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
286 gaim_account_get_username(account), gc->prpl->info->name, gaim_date_full()); |
| 4184 | 287 g_snprintf(html, sizeof(html), "%s", text); |
| 288 break; | |
| 289 case log_idle: | |
| 4195 | 290 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
291 gaim_account_get_username(account), gc->prpl->info->name, gaim_date_full()); |
| 4184 | 292 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 293 break; | |
| 294 case log_unidle: | |
| 4195 | 295 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
296 gaim_account_get_username(account), gc->prpl->info->name, gaim_date_full()); |
| 4184 | 297 g_snprintf(html, sizeof(html), "%s", text); |
| 298 break; | |
| 299 case log_quit: | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
300 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), gaim_date_full()); |
| 4184 | 301 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 302 break; | |
| 303 } | |
| 4687 | 304 } else if (gaim_get_buddy_alias_only(who)) { |
| 4184 | 305 switch (what) { |
| 306 case log_signon: | |
| 4195 | 307 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
308 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, gaim_date_full()); |
| 4184 | 309 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 310 break; | |
| 311 case log_signoff: | |
| 4195 | 312 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
313 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, gaim_date_full()); |
| 4184 | 314 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 315 break; | |
| 316 case log_away: | |
| 4195 | 317 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
318 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, gaim_date_full()); |
| 4184 | 319 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 320 break; | |
| 321 case log_back: | |
| 4195 | 322 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
323 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, gaim_date_full()); |
| 4184 | 324 g_snprintf(html, sizeof(html), "%s", text); |
| 325 break; | |
| 326 case log_idle: | |
| 4195 | 327 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
328 gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, gaim_date_full()); |
| 4184 | 329 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 330 break; | |
| 331 case log_unidle: | |
| 332 g_snprintf(text, sizeof(text), | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
333 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gaim_account_get_username(account), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
334 gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, gaim_date_full()); |
| 4184 | 335 g_snprintf(html, sizeof(html), "%s", text); |
| 336 break; | |
| 337 default: | |
| 338 fclose(fd); | |
| 339 return; | |
| 340 break; | |
| 341 } | |
| 342 } else { | |
| 343 switch (what) { | |
| 344 case log_signon: | |
| 4195 | 345 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
346 gaim_account_get_username(account), gc->prpl->info->name, who->name, gaim_date_full()); |
| 4184 | 347 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 348 break; | |
| 349 case log_signoff: | |
| 4195 | 350 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
351 gaim_account_get_username(account), gc->prpl->info->name, who->name, gaim_date_full()); |
| 4184 | 352 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 353 break; | |
| 354 case log_away: | |
| 4195 | 355 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
356 gaim_account_get_username(account), gc->prpl->info->name, who->name, gaim_date_full()); |
| 4184 | 357 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 358 break; | |
| 359 case log_back: | |
| 4195 | 360 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
361 gaim_account_get_username(account), gc->prpl->info->name, who->name, gaim_date_full()); |
| 4184 | 362 g_snprintf(html, sizeof(html), "%s", text); |
| 363 break; | |
| 364 case log_idle: | |
| 4195 | 365 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
366 gaim_account_get_username(account), gc->prpl->info->name, who->name, gaim_date_full()); |
| 4184 | 367 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 368 break; | |
| 369 case log_unidle: | |
| 370 g_snprintf(text, sizeof(text), | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
371 _("%s (%s) reported that %s returned from idle @ %s"), gaim_account_get_username(account), |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
372 gc->prpl->info->name, who->name, gaim_date_full()); |
| 4184 | 373 g_snprintf(html, sizeof(html), "%s", text); |
| 374 break; | |
| 375 default: | |
| 376 fclose(fd); | |
| 377 return; | |
| 378 break; | |
| 379 } | |
| 380 } | |
| 381 | |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
382 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) |
| 4184 | 383 fprintf(fd, "---- %s ----\n", text); |
|
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
384 else if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
385 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
386 else |
|
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
387 fprintf(fd, "%s<BR>\n", html); |
| 4184 | 388 |
| 389 fclose(fd); | |
| 390 } | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
391 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
392 char *html_logize(const char *p) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
393 { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
394 const char *temp_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
395 char *buffer_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
396 char *buffer_start; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
397 int num_cr = 0; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
398 int char_len = 0; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
399 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
400 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
401 char_len++; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
402 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
403 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
404 num_cr++; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
405 } |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
406 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
407 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
408 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
409 for (temp_p = p, buffer_start = buffer_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
410 *temp_p != '\0'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
411 temp_p++) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
412 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
413 if (*temp_p == '\n') { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
414 *buffer_p++ = '<'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
415 *buffer_p++ = 'B'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
416 *buffer_p++ = 'R'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
417 *buffer_p++ = '>'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
418 *buffer_p++ = '\n'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
419 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
420 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
421 *buffer_p++ = '&'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
422 *buffer_p++ = 'l'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
423 *buffer_p++ = 't'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
424 *buffer_p++ = ';'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
425 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
426 } else |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
427 *buffer_p++ = *temp_p; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
428 } |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
429 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
430 *buffer_p = '\0'; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
431 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
432 return buffer_start; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
433 } |
