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