Sat, 14 Jun 2003 23:21:02 +0000
[gaim-migrate @ 6304]
The legendary Header File Cleanup! Files now only include what they need.
This should reduce the number of files that must recompile when a header
file changes. It's a lot nicer. Trust me on it. I also added a couple new
header files. I hope I didn't break TOO much!
| 4184 | 1 | /* --------------------------------------------------- |
| 2 | * Function to remove a log file entry | |
| 3 | * --------------------------------------------------- | |
| 4 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
5 | #include "internal.h" |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
6 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
7 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
8 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
9 | #include "log.h" |
| 4184 | 10 | #include "multi.h" |
|
5872
754c63f29b77
[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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
14 | #include "util.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
15 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
16 | #include "gtkconv.h" |
| 4184 | 17 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
18 | #include "ui.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
19 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5839
diff
changeset
|
20 | GList *log_conversations = NULL; |
|
4192
fd80a226a2d9
[gaim-migrate @ 4423]
Herman Bloggs <herman@bluedigits.com>
parents:
4184
diff
changeset
|
21 | |
| 4184 | 22 | void rm_log(struct log_conversation *a) |
| 23 | { | |
|
5676
d3c2fdaf4821
[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
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
65 | GList *cnv; |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
66 | GaimConversation *c; |
|
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
67 | GaimGtkConversation *gtkconv; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
68 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
69 | for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
70 | |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
71 | c = (GaimConversation *)cnv->data; |
| 4184 | 72 | |
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
73 | if (!GAIM_IS_GTK_CONVERSATION(c)) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
74 | continue; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
75 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
76 | gtkconv = GAIM_GTK_CONVERSATION(c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
77 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
78 | if (gtkconv->toolbar.log) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
79 | if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) |
|
cf899ee07d1d
[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
cf899ee07d1d
[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 | ||
| 4635 | 89 | static void do_save_convo(GObject *obj, GtkWidget *wid) |
| 4184 | 90 | { |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
91 | GaimConversation *c = g_object_get_data(obj, "gaim_conversation"); |
| 4184 | 92 | const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
| 93 | FILE *f; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
94 | |
| 4184 | 95 | if (file_is_dir(filename, wid)) |
| 96 | return; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
97 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
98 | if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
99 | g_list_find(gaim_get_ims(), c)) || |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
100 | (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
101 | g_list_find(gaim_get_chats(), c)))) |
| 4184 | 102 | filename = NULL; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
103 | |
| 4184 | 104 | gtk_widget_destroy(wid); |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
105 | |
| 4184 | 106 | if (!filename) |
| 107 | return; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
108 | |
| 4184 | 109 | f = fopen(filename, "w+"); |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
110 | |
| 4184 | 111 | if (!f) |
| 112 | return; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
113 | |
| 4184 | 114 | fprintf(f, "%s", c->history->str); |
| 115 | fclose(f); | |
| 116 | } | |
| 117 | ||
| 118 | ||
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
119 | void save_convo(GtkWidget *save, GaimConversation *c) |
| 4184 | 120 | { |
| 121 | char buf[BUF_LONG]; | |
| 122 | GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); | |
| 123 | g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); | |
| 124 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
| 4635 | 125 | g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 126 | "gaim_conversation", c); | |
|
5314
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
127 | g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 4184 | 128 | "clicked", G_CALLBACK(do_save_convo), window); |
|
5314
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
129 | g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), |
| 4184 | 130 | "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); |
| 131 | gtk_widget_show(window); | |
| 132 | } | |
| 133 | ||
| 134 | static FILE *open_gaim_log_file(const char *name, int *flag) | |
| 135 | { | |
| 136 | char *buf; | |
| 137 | char *buf2; | |
| 138 | char log_all_file[256]; | |
| 139 | struct stat st; | |
| 140 | FILE *fd; | |
| 141 | #ifndef _WIN32 | |
| 142 | int res; | |
| 143 | #endif | |
| 144 | gchar *gaim_dir; | |
| 145 | ||
| 146 | buf = g_malloc(BUF_LONG); | |
| 147 | buf2 = g_malloc(BUF_LONG); | |
| 148 | gaim_dir = gaim_user_dir(); | |
| 149 | ||
| 150 | /* Dont log yourself */ | |
| 151 | strncpy(log_all_file, gaim_dir, 256); | |
| 152 | ||
| 153 | #ifndef _WIN32 | |
| 154 | stat(log_all_file, &st); | |
| 155 | if (!S_ISDIR(st.st_mode)) | |
| 156 | unlink(log_all_file); | |
| 157 | ||
| 158 | fd = fopen(log_all_file, "r"); | |
| 159 | ||
| 160 | if (!fd) { | |
| 161 | res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 162 | if (res < 0) { | |
| 163 | g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
| 164 | log_all_file); | |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
165 | gaim_notify_error(NULL, NULL, buf, NULL); |
| 4184 | 166 | g_free(buf); |
| 167 | g_free(buf2); | |
| 168 | return NULL; | |
| 169 | } | |
| 170 | } else | |
| 171 | fclose(fd); | |
| 172 | ||
| 173 | g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
| 174 | ||
| 175 | if (stat(log_all_file, &st) < 0) | |
| 176 | *flag = 1; | |
| 177 | if (!S_ISDIR(st.st_mode)) | |
| 178 | unlink(log_all_file); | |
| 179 | ||
| 180 | fd = fopen(log_all_file, "r"); | |
| 181 | if (!fd) { | |
| 182 | res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 183 | if (res < 0) { | |
| 184 | g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
| 185 | log_all_file); | |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
186 | gaim_notify_error(NULL, NULL, buf, NULL); |
| 4184 | 187 | g_free(buf); |
| 188 | g_free(buf2); | |
| 189 | return NULL; | |
| 190 | } | |
| 191 | } else | |
| 192 | fclose(fd); | |
| 193 | #else /* _WIN32 */ | |
| 194 | g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
| 195 | ||
| 196 | if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
| 197 | g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file); | |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
198 | gaim_notify_error(NULL, NULL, buf, NULL); |
| 4184 | 199 | g_free(buf); |
| 200 | g_free(buf2); | |
| 201 | return NULL; | |
| 202 | } | |
| 203 | #endif | |
| 204 | ||
| 205 | g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
| 206 | if (stat(log_all_file, &st) < 0) | |
| 207 | *flag = 1; | |
| 208 | ||
|
5211
94d9756c381f
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
209 | gaim_debug(GAIM_DEBUG_INFO, "log", "Logging to: \"%s\"\n", log_all_file); |
| 4184 | 210 | |
| 211 | fd = fopen(log_all_file, "a"); | |
| 212 | ||
| 213 | g_free(buf); | |
| 214 | g_free(buf2); | |
| 215 | return fd; | |
| 216 | } | |
| 217 | ||
| 218 | static FILE *open_system_log_file(char *name) | |
| 219 | { | |
| 220 | int x; | |
| 221 | ||
| 222 | if (name) | |
| 223 | return open_log_file(name, 2); | |
| 224 | else | |
| 225 | return open_gaim_log_file("system", &x); | |
| 226 | } | |
| 227 | ||
| 228 | FILE *open_log_file(const char *name, int is_chat) | |
| 229 | { | |
| 230 | struct stat st; | |
| 231 | char realname[256]; | |
| 232 | struct log_conversation *l; | |
| 233 | FILE *fd; | |
| 234 | int flag = 0; | |
| 235 | ||
|
5554
a197dfd0d8b3
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
236 | if (((is_chat == 2) && !gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
| 5548 | 237 | || ((is_chat == 1) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_chats")) |
| 238 | || ((is_chat == 0) && !gaim_prefs_get_bool("/gaim/gtk/logging/log_ims"))) { | |
| 4184 | 239 | |
| 240 | l = find_log_info(name); | |
| 241 | if (!l) | |
| 242 | return NULL; | |
| 243 | ||
| 244 | if (stat(l->filename, &st) < 0) | |
| 245 | flag = 1; | |
| 246 | ||
| 247 | fd = fopen(l->filename, "a"); | |
| 248 | ||
| 249 | if (flag) { /* is a new file */ | |
|
5554
a197dfd0d8b3
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
250 | if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
| 4184 | 251 | fprintf(fd, _("IM Sessions with %s\n"), name); |
| 252 | } else { | |
| 253 | fprintf(fd, "<HTML><HEAD><TITLE>"); | |
| 254 | fprintf(fd, _("IM Sessions with %s"), name); | |
| 5138 | 255 | fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
| 4184 | 256 | } |
| 257 | } | |
| 258 | ||
| 259 | return fd; | |
| 260 | } | |
| 261 | ||
| 262 | g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); | |
| 263 | fd = open_gaim_log_file(realname, &flag); | |
| 264 | ||
| 265 | if (fd && flag) { /* is a new file */ | |
|
5554
a197dfd0d8b3
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
266 | if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { |
| 4184 | 267 | fprintf(fd, _("IM Sessions with %s\n"), name); |
| 268 | } else { | |
| 269 | fprintf(fd, "<HTML><HEAD><TITLE>"); | |
| 270 | fprintf(fd, _("IM Sessions with %s"), name); | |
| 5138 | 271 | fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
| 4184 | 272 | } |
| 273 | } | |
| 274 | ||
| 275 | return fd; | |
| 276 | } | |
| 277 | ||
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
278 | void system_log(enum log_event what, GaimConnection *gc, |
| 4184 | 279 | struct buddy *who, int why) |
| 280 | { | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
281 | GaimAccount *account; |
| 4184 | 282 | FILE *fd; |
| 283 | char text[256], html[256]; | |
| 284 | ||
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
285 | account = gaim_connection_get_account(gc); |
|
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
286 | |
| 5839 | 287 | if ((why & OPT_LOG_MY_SIGNON && |
| 288 | !gaim_prefs_get_bool("/gaim/gtk/logging/log_own_states")) || | |
| 289 | (why & OPT_LOG_BUDDY_SIGNON && | |
| 290 | !gaim_prefs_get_bool("/gaim/gtk/logging/log_signon_signoff")) || | |
| 291 | (why & OPT_LOG_BUDDY_IDLE && | |
| 292 | !gaim_prefs_get_bool("/gaim/gtk/logging/log_idle_state")) || | |
| 293 | (why & OPT_LOG_BUDDY_AWAY && | |
| 294 | !gaim_prefs_get_bool("/gaim/gtk/logging/log_away_state"))) { | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
295 | |
| 4184 | 296 | return; |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
297 | } |
| 4184 | 298 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
299 | if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) { |
| 4184 | 300 | if (why & OPT_LOG_MY_SIGNON) |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
301 | fd = open_system_log_file(gc ? (char *)gaim_account_get_username(account) : NULL); |
| 4184 | 302 | else |
| 303 | fd = open_system_log_file(who->name); | |
| 304 | } else | |
| 305 | fd = open_system_log_file(NULL); | |
| 306 | ||
| 307 | if (!fd) | |
| 308 | return; | |
| 309 | ||
| 310 | if (why & OPT_LOG_MY_SIGNON) { | |
| 311 | switch (what) { | |
| 312 | case log_signon: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
313 | g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
314 | gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 315 | g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 316 | break; | |
| 317 | case log_signoff: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
318 | g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
319 | gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 320 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 321 | break; | |
| 322 | case log_away: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
323 | g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
324 | gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 325 | g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 326 | break; | |
| 327 | case log_back: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
328 | g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
329 | gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 330 | g_snprintf(html, sizeof(html), "%s", text); |
| 331 | break; | |
| 332 | case log_idle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
333 | g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
334 | gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 335 | g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 336 | break; | |
| 337 | case log_unidle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
338 | g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
339 | gaim_account_get_username(account), gc->prpl->info->name, full_date()); |
| 4184 | 340 | g_snprintf(html, sizeof(html), "%s", text); |
| 341 | break; | |
| 342 | case log_quit: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
343 | g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
| 4184 | 344 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 345 | break; | |
| 346 | } | |
| 4687 | 347 | } else if (gaim_get_buddy_alias_only(who)) { |
| 4184 | 348 | switch (what) { |
| 349 | case log_signon: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
350 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
351 | gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 352 | g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 353 | break; | |
| 354 | case log_signoff: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
355 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
356 | gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 357 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 358 | break; | |
| 359 | case log_away: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
360 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
361 | gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 362 | g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 363 | break; | |
| 364 | case log_back: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
365 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
366 | gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 367 | g_snprintf(html, sizeof(html), "%s", text); |
| 368 | break; | |
| 369 | case log_idle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
370 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
371 | gaim_account_get_username(account), gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 372 | g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 373 | break; | |
| 374 | case log_unidle: | |
| 375 | g_snprintf(text, sizeof(text), | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
376 | _("%s (%s) reported that %s (%s) returned from idle @ %s"), gaim_account_get_username(account), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
377 | gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 378 | g_snprintf(html, sizeof(html), "%s", text); |
| 379 | break; | |
| 380 | default: | |
| 381 | fclose(fd); | |
| 382 | return; | |
| 383 | break; | |
| 384 | } | |
| 385 | } else { | |
| 386 | switch (what) { | |
| 387 | case log_signon: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
388 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
389 | gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 390 | g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 391 | break; | |
| 392 | case log_signoff: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
393 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
394 | gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 395 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 396 | break; | |
| 397 | case log_away: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
398 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
399 | gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 400 | g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 401 | break; | |
| 402 | case log_back: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
403 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
404 | gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 405 | g_snprintf(html, sizeof(html), "%s", text); |
| 406 | break; | |
| 407 | case log_idle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
408 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"), |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
409 | gaim_account_get_username(account), gc->prpl->info->name, who->name, full_date()); |
| 4184 | 410 | g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 411 | break; | |
| 412 | case log_unidle: | |
| 413 | g_snprintf(text, sizeof(text), | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
414 | _("%s (%s) reported that %s returned from idle @ %s"), gaim_account_get_username(account), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
415 | gc->prpl->info->name, who->name, full_date()); |
| 4184 | 416 | g_snprintf(html, sizeof(html), "%s", text); |
| 417 | break; | |
| 418 | default: | |
| 419 | fclose(fd); | |
| 420 | return; | |
| 421 | break; | |
| 422 | } | |
| 423 | } | |
| 424 | ||
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
425 | if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) |
| 4184 | 426 | fprintf(fd, "---- %s ----\n", text); |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
427 | else if (gaim_prefs_get_bool("/gaim/gtk/logging/individual_logs")) |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
428 | fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
429 | else |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
430 | fprintf(fd, "%s<BR>\n", html); |
| 4184 | 431 | |
| 432 | fclose(fd); | |
| 433 | } | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
434 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
435 | char *html_logize(const char *p) |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
436 | { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
437 | const char *temp_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
438 | char *buffer_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
439 | char *buffer_start; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 | int num_cr = 0; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 | int char_len = 0; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
443 | for (temp_p = p; *temp_p != '\0'; temp_p++) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
444 | char_len++; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 | if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
447 | num_cr++; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
448 | } |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
449 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
450 | buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 | for (temp_p = p, buffer_start = buffer_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 | *temp_p != '\0'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
454 | temp_p++) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 | if (*temp_p == '\n') { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
457 | *buffer_p++ = '<'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
458 | *buffer_p++ = 'B'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
459 | *buffer_p++ = 'R'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 | *buffer_p++ = '>'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 | *buffer_p++ = '\n'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
462 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
463 | } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
464 | *buffer_p++ = '&'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
465 | *buffer_p++ = 'l'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
466 | *buffer_p++ = 't'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
467 | *buffer_p++ = ';'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
468 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
469 | } else |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
470 | *buffer_p++ = *temp_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
471 | } |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
472 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
473 | *buffer_p = '\0'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
474 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
475 | return buffer_start; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
476 | } |