annotate src/log.c @ 5057:317bdeedc729

[gaim-migrate @ 5408] Now you should be able to unset aliases again. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 07 Apr 2003 04:55:48 +0000
parents 677d3cb193a1
children 5425bbaa2630
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;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
49 if (!gaim_utf8_strcasecmp(pname, normalize(l->name))) {
4184
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
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
85 static void do_save_convo(GObject *obj, GtkWidget *wid)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
87 struct gaim_conversation *c = g_object_get_data(obj, "gaim_conversation");
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);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
121 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
122 "gaim_conversation", c);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 "clicked", G_CALLBACK(do_save_convo), window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 gtk_widget_show(window);
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 static FILE *open_gaim_log_file(const char *name, int *flag)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 char *buf;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 char *buf2;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 char log_all_file[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 struct stat st;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 #ifndef _WIN32
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 int res;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 #endif
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 gchar *gaim_dir;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 buf = g_malloc(BUF_LONG);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 buf2 = g_malloc(BUF_LONG);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 gaim_dir = gaim_user_dir();
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 /* Dont log yourself */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 strncpy(log_all_file, gaim_dir, 256);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 #ifndef _WIN32
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 stat(log_all_file, &st);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 if (!S_ISDIR(st.st_mode))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 unlink(log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 fd = fopen(log_all_file, "r");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 if (!fd) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 if (res < 0) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 do_error_dialog(buf, NULL, GAIM_ERROR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 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
170
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 if (stat(log_all_file, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 *flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 if (!S_ISDIR(st.st_mode))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 unlink(log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 fd = fopen(log_all_file, "r");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 if (!fd) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 if (res < 0) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 do_error_dialog(buf, NULL, GAIM_ERROR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 #else /* _WIN32 */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 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
191
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 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
194 do_error_dialog(buf, NULL, GAIM_ERROR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 #endif
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 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
202 if (stat(log_all_file, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 *flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 debug_printf("Logging to: \"%s\"\n", log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 fd = fopen(log_all_file, "a");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 return fd;
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 static FILE *open_system_log_file(char *name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 int x;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 if (name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 return open_log_file(name, 2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 return open_gaim_log_file("system", &x);
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 FILE *open_log_file(const char *name, int is_chat)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 struct stat st;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 char realname[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 struct log_conversation *l;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 int flag = 0;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 l = find_log_info(name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 if (!l)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 if (stat(l->filename, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 fd = fopen(l->filename, "a");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 if (flag) { /* is a new file */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 fprintf(fd, _("IM Sessions with %s\n"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 fprintf(fd, "<HTML><HEAD><TITLE>");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 fprintf(fd, _("IM Sessions with %s"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 return fd;
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 fd = open_gaim_log_file(realname, &flag);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 if (fd && flag) { /* is a new file */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 fprintf(fd, _("IM Sessions with %s\n"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 fprintf(fd, "<HTML><HEAD><TITLE>");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 fprintf(fd, _("IM Sessions with %s"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 return fd;
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 void system_log(enum log_event what, struct gaim_connection *gc,
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 struct buddy *who, int why)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 char text[256], html[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 if ((logging_options & why) != why)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 if (logging_options & OPT_LOG_INDIVIDUAL) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 if (why & OPT_LOG_MY_SIGNON)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 fd = open_system_log_file(gc ? gc->username : NULL);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 fd = open_system_log_file(who->name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 fd = open_system_log_file(NULL);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 if (!fd)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 if (why & OPT_LOG_MY_SIGNON) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
297 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 case log_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
302 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 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
305 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
307 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
312 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
317 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 case log_unidle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
322 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 gc->username, gc->prpl->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 case log_quit:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
327 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 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
329 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
331 } else if (gaim_get_buddy_alias_only(who)) {
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
334 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"),
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
335 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 case log_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
339 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"),
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
340 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 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
342 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
344 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"),
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
345 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
349 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"),
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
350 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
354 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"),
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
355 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 case log_unidle:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 g_snprintf(text, sizeof(text),
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
360 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gc->username,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
361 gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 default:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
372 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
373 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 g_snprintf(html, sizeof(html), "<B>%s</B>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 case log_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
377 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
378 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 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
380 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
382 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
383 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
387 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
388 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
392 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
393 gc->username, gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 case log_unidle:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 g_snprintf(text, sizeof(text),
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
398 _("%s (%s) reported that %s returned from idle @ %s"), gc->username,
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 gc->prpl->name, who->name, full_date());
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 default:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 break;
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 fprintf(fd, "---- %s ----\n", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 if (logging_options & OPT_LOG_INDIVIDUAL)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 fprintf(fd, "%s<BR>\n", html);
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
420
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
421 char *html_logize(const char *p)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
422 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
423 const char *temp_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
424 char *buffer_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
425 char *buffer_start;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
426 int num_cr = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
427 int char_len = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
428
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
429 for (temp_p = p; *temp_p != '\0'; temp_p++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
430 char_len++;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
431
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
432 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!')))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
433 num_cr++;
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
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
436 buffer_p = g_malloc(char_len + (4 * num_cr) + 1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
437
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
438 for (temp_p = p, buffer_start = buffer_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
439 *temp_p != '\0';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
440 temp_p++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
441
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
442 if (*temp_p == '\n') {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
443 *buffer_p++ = '<';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
444 *buffer_p++ = 'B';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
445 *buffer_p++ = 'R';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
446 *buffer_p++ = '>';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
447 *buffer_p++ = '\n';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
448
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
449 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
450 *buffer_p++ = '&';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
451 *buffer_p++ = 'l';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
452 *buffer_p++ = 't';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
453 *buffer_p++ = ';';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
454
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
455 } else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
456 *buffer_p++ = *temp_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
457 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
458
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
459 *buffer_p = '\0';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
460
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
461 return buffer_start;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
462 }