annotate src/log.c @ 4523:64d03b6a0864

[gaim-migrate @ 4801] added gtkft.c committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Wed, 05 Feb 2003 00:40:46 +0000
parents a8249a5250b6
children 42d53c416bb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /* ---------------------------------------------------
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * Function to remove a log file entry
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 * ---------------------------------------------------
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 */
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
5 #ifdef HAVE_CONFIG_H
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
6 #include <config.h>
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
7 #endif
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
8 #include <string.h>
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
9
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
10 #ifndef _WIN32
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
11 #include <unistd.h>
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
12 #endif
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
13
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 #include "gaim.h"
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 #include "core.h"
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 #include "multi.h"
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 #include "prpl.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
18 #include <string.h>
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 #include <sys/stat.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
20 #include <unistd.h>
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21
4192
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
22 #ifdef _WIN32
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
23 #include "win32dep.h"
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
24 #endif
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
25
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 void rm_log(struct log_conversation *a)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
28 struct gaim_conversation *cnv = gaim_find_conversation(a->name);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 log_conversations = g_list_remove(log_conversations, a);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 save_prefs();
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 if (cnv && !(im_options & OPT_IM_ONE_WINDOW))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
35 gaim_conversation_autoset_title(cnv);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 struct log_conversation *find_log_info(const char *name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 char *pname = g_malloc(BUF_LEN);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 GList *lc = log_conversations;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 struct log_conversation *l;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 strcpy(pname, normalize(name));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 while (lc) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 l = (struct log_conversation *)lc->data;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 if (!g_strcasecmp(pname, normalize(l->name))) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 g_free(pname);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 return l;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 lc = lc->next;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 g_free(pname);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 void update_log_convs()
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
61 GList *cnv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
62 struct gaim_conversation *c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
63 struct gaim_gtk_conversation *gtkconv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
64
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
65 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
66
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
67 c = (struct gaim_conversation *)cnv->data;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68
4398
a8249a5250b6 [gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
69 if (!GAIM_IS_GTK_CONVERSATION(c))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
70 continue;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
71
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
72 gtkconv = GAIM_GTK_CONVERSATION(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
73
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
74 if (gtkconv->toolbar.log) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
75 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
76 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 ((logging_options & OPT_LOG_CHATS)) ? FALSE : TRUE);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 else
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
79 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 ((logging_options & OPT_LOG_CONVOS)) ? FALSE : TRUE);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 static void do_save_convo(GtkObject *obj, GtkWidget *wid)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
87 struct gaim_conversation *c = gtk_object_get_user_data(obj);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 FILE *f;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
90
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 if (file_is_dir(filename, wid))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
93
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
94 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
95 g_list_find(gaim_get_ims(), c)) ||
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
96 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
97 g_list_find(gaim_get_chats(), c))))
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 filename = NULL;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
99
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 gtk_widget_destroy(wid);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
101
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 if (!filename)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
104
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 f = fopen(filename, "w+");
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
106
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 if (!f)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
109
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 fprintf(f, "%s", c->history->str);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 fclose(f);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
115 void save_convo(GtkWidget *save, struct gaim_conversation *c)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 char buf[BUF_LONG];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation"));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 gtk_object_set_user_data(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), c);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 "clicked", G_CALLBACK(do_save_convo), window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 gtk_widget_show(window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 static FILE *open_gaim_log_file(const char *name, int *flag)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 char *buf;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 char *buf2;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 char log_all_file[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 struct stat st;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 #ifndef _WIN32
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 int res;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 #endif
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 gchar *gaim_dir;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 buf = g_malloc(BUF_LONG);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 buf2 = g_malloc(BUF_LONG);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 gaim_dir = gaim_user_dir();
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 /* Dont log yourself */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 strncpy(log_all_file, gaim_dir, 256);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 #ifndef _WIN32
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 stat(log_all_file, &st);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 if (!S_ISDIR(st.st_mode))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 unlink(log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 fd = fopen(log_all_file, "r");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 if (!fd) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 if (res < 0) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 do_error_dialog(buf, NULL, GAIM_ERROR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 if (stat(log_all_file, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 *flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 if (!S_ISDIR(st.st_mode))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 unlink(log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 fd = fopen(log_all_file, "r");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 if (!fd) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 if (res < 0) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 do_error_dialog(buf, NULL, GAIM_ERROR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 #else /* _WIN32 */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 do_error_dialog(buf, NULL, GAIM_ERROR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 #endif
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 if (stat(log_all_file, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 *flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 debug_printf("Logging to: \"%s\"\n", log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 fd = fopen(log_all_file, "a");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 return fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 static FILE *open_system_log_file(char *name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 int x;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 if (name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 return open_log_file(name, 2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 return open_gaim_log_file("system", &x);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 FILE *open_log_file(const char *name, int is_chat)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 struct stat st;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 char realname[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 struct log_conversation *l;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 int flag = 0;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 l = find_log_info(name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 if (!l)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 if (stat(l->filename, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 fd = fopen(l->filename, "a");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 if (flag) { /* is a new file */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 fprintf(fd, _("IM Sessions with %s\n"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 fprintf(fd, "<HTML><HEAD><TITLE>");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 fprintf(fd, _("IM Sessions with %s"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 return fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 fd = open_gaim_log_file(realname, &flag);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 if (fd && flag) { /* is a new file */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 fprintf(fd, _("IM Sessions with %s\n"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 fprintf(fd, "<HTML><HEAD><TITLE>");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 fprintf(fd, _("IM Sessions with %s"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 return fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 void system_log(enum log_event what, struct gaim_connection *gc,
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 struct buddy *who, int why)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 char text[256], html[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 if ((logging_options & why) != why)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 if (logging_options & OPT_LOG_INDIVIDUAL) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 if (why & OPT_LOG_MY_SIGNON)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 fd = open_system_log_file(gc ? gc->username : NULL);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 fd = open_system_log_file(who->name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 fd = open_system_log_file(NULL);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 if (!fd)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 if (why & OPT_LOG_MY_SIGNON) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
296 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 case log_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
301 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
306 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
311 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
316 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 case log_unidle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
321 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 case log_quit:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
326 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 }
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
330 } else if (get_buddy_alias_only(who)) {
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
333 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"),
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
334 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 case log_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
338 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"),
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
339 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
343 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"),
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
344 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
348 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"),
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
349 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
353 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"),
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
354 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 case log_unidle:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 g_snprintf(text, sizeof(text),
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
359 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gc->username,
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4195
diff changeset
360 gc->prpl->name, get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 default:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
371 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 case log_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
376 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
381 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
386 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
391 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 case log_unidle:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 g_snprintf(text, sizeof(text),
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
397 _("%s (%s) reported that %s returned from idle @ %s"), gc->username,
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 default:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 fprintf(fd, "---- %s ----\n", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 if (logging_options & OPT_LOG_INDIVIDUAL)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 fprintf(fd, "%s<BR>\n", html);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 }
4359
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 char *html_logize(const char *p)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
421 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
422 const char *temp_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
423 char *buffer_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
424 char *buffer_start;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
425 int num_cr = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
426 int char_len = 0;
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 for (temp_p = p; *temp_p != '\0'; temp_p++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
429 char_len++;
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 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!')))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
432 num_cr++;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
433 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
434
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
435 buffer_p = g_malloc(char_len + (4 * num_cr) + 1);
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 for (temp_p = p, buffer_start = buffer_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
438 *temp_p != '\0';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
439 temp_p++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
440
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
441 if (*temp_p == '\n') {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
442 *buffer_p++ = '<';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
443 *buffer_p++ = 'B';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
444 *buffer_p++ = 'R';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
445 *buffer_p++ = '>';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
446 *buffer_p++ = '\n';
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 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
449 *buffer_p++ = '&';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
450 *buffer_p++ = 'l';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
451 *buffer_p++ = 't';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
452 *buffer_p++ = ';';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
453
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
454 } else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
455 *buffer_p++ = *temp_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
456 }
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 *buffer_p = '\0';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
459
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
460 return buffer_start;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
461 }