annotate src/log.c @ 5528:c72213437829

[gaim-migrate @ 5928] Dario Sarango (darius_wolfson) writes: "Patch to fix bug #743397 I added some snity checks when removing a log file, to avoid gai segfaulting when removing an invalid/non-existing log file." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 26 May 2003 04:28:11 +0000
parents ad445074d239
children 80e4ba770f97
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"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
18 #include "notify.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
19 #include <string.h>
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 #include <sys/stat.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
21 #include <unistd.h>
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22
4192
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
23 #ifdef _WIN32
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
24 #include "win32dep.h"
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
25 #endif
17187504bfc2 [gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4184
diff changeset
26
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 void rm_log(struct log_conversation *a)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
29 struct gaim_conversation *cnv = gaim_find_conversation(a->name);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
5528
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
31 /* Added the following if statements for sanity check */
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
32 if (!a)
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
33 {
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
34 gaim_notify_error (NULL, NULL, _("Error in specifying buddy conversation."), NULL);
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
35 return;
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
36 }
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
37 cnv = gaim_find_conversation(a->name);
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
38 if (!cnv)
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
39 {
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
40 gaim_notify_error (NULL, NULL, _("Unable to find conversation log"), NULL);
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
41 return;
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
42 }
c72213437829 [gaim-migrate @ 5928]
Luke Schierer <lschiere@pidgin.im>
parents: 5436
diff changeset
43
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 log_conversations = g_list_remove(log_conversations, a);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 save_prefs();
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 if (cnv && !(im_options & OPT_IM_ONE_WINDOW))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
49 gaim_conversation_autoset_title(cnv);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 struct log_conversation *find_log_info(const char *name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 char *pname = g_malloc(BUF_LEN);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 GList *lc = log_conversations;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 struct log_conversation *l;
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 strcpy(pname, normalize(name));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 while (lc) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 l = (struct log_conversation *)lc->data;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
63 if (!gaim_utf8_strcasecmp(pname, normalize(l->name))) {
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 g_free(pname);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 return l;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 lc = lc->next;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 g_free(pname);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 void update_log_convs()
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
75 GList *cnv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
76 struct gaim_conversation *c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
77 struct gaim_gtk_conversation *gtkconv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
78
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
79 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
80
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
81 c = (struct gaim_conversation *)cnv->data;
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
4398
a8249a5250b6 [gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
83 if (!GAIM_IS_GTK_CONVERSATION(c))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
84 continue;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
85
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
86 gtkconv = GAIM_GTK_CONVERSATION(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
87
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
88 if (gtkconv->toolbar.log) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
89 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
90 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 ((logging_options & OPT_LOG_CHATS)) ? FALSE : TRUE);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 else
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
93 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 ((logging_options & OPT_LOG_CONVOS)) ? FALSE : TRUE);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
99 static void do_save_convo(GObject *obj, GtkWidget *wid)
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
101 struct gaim_conversation *c = g_object_get_data(obj, "gaim_conversation");
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 FILE *f;
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 if (file_is_dir(filename, wid))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
107
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
108 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
109 g_list_find(gaim_get_ims(), c)) ||
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
110 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
111 g_list_find(gaim_get_chats(), c))))
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 filename = NULL;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
113
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 gtk_widget_destroy(wid);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
115
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 if (!filename)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
118
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 f = fopen(filename, "w+");
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
120
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 if (!f)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
123
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 fprintf(f, "%s", c->history->str);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 fclose(f);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 }
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
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
129 void save_convo(GtkWidget *save, struct gaim_conversation *c)
4184
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[BUF_LONG];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation"));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 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
134 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4398
diff changeset
135 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
136 "gaim_conversation", c);
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
137 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 "clicked", G_CALLBACK(do_save_convo), window);
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5211
diff changeset
139 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button),
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 gtk_widget_show(window);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 static FILE *open_gaim_log_file(const char *name, int *flag)
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 char *buf;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 char *buf2;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 char log_all_file[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 struct stat st;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 #ifndef _WIN32
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 int res;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 #endif
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 gchar *gaim_dir;
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 buf = g_malloc(BUF_LONG);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 buf2 = g_malloc(BUF_LONG);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 gaim_dir = gaim_user_dir();
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 /* Dont log yourself */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 strncpy(log_all_file, gaim_dir, 256);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 #ifndef _WIN32
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 stat(log_all_file, &st);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 if (!S_ISDIR(st.st_mode))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 unlink(log_all_file);
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 fd = fopen(log_all_file, "r");
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 (!fd) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 if (res < 0) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 log_all_file);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
175 gaim_notify_error(NULL, NULL, buf, NULL);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 return NULL;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 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
184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 if (stat(log_all_file, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 *flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 if (!S_ISDIR(st.st_mode))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 unlink(log_all_file);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 fd = fopen(log_all_file, "r");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 if (!fd) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 if (res < 0) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 log_all_file);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
196 gaim_notify_error(NULL, NULL, buf, NULL);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 return NULL;
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 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 #else /* _WIN32 */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 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
205
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
208 gaim_notify_error(NULL, NULL, buf, NULL);
4184
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 NULL;
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 #endif
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 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
216 if (stat(log_all_file, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 *flag = 1;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
5211
0241d6b6702d [gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
219 gaim_debug(GAIM_DEBUG_INFO, "log", "Logging to: \"%s\"\n", log_all_file);
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 fd = fopen(log_all_file, "a");
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 g_free(buf);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 g_free(buf2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 return fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 static FILE *open_system_log_file(char *name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 int x;
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 (name)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 return open_log_file(name, 2);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 return open_gaim_log_file("system", &x);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 FILE *open_log_file(const char *name, int is_chat)
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 struct stat st;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 char realname[256];
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 struct log_conversation *l;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 int flag = 0;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS))
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 l = find_log_info(name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 if (!l)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 return NULL;
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 if (stat(l->filename, &st) < 0)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 flag = 1;
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 fd = fopen(l->filename, "a");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 if (flag) { /* is a new file */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 fprintf(fd, _("IM Sessions with %s\n"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 fprintf(fd, "<HTML><HEAD><TITLE>");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 fprintf(fd, _("IM Sessions with %s"), name);
5138
5425bbaa2630 [gaim-migrate @ 5502]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
265 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n");
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 }
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 return fd;
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
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name));
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 fd = open_gaim_log_file(realname, &flag);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 if (fd && flag) { /* is a new file */
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 fprintf(fd, _("IM Sessions with %s\n"), name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 fprintf(fd, "<HTML><HEAD><TITLE>");
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 fprintf(fd, _("IM Sessions with %s"), name);
5138
5425bbaa2630 [gaim-migrate @ 5502]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
281 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n");
4184
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 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 return fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 void system_log(enum log_event what, struct gaim_connection *gc,
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 struct buddy *who, int why)
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 FILE *fd;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 char text[256], html[256];
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 ((logging_options & why) != why)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 if (logging_options & OPT_LOG_INDIVIDUAL) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 if (why & OPT_LOG_MY_SIGNON)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 fd = open_system_log_file(gc ? gc->username : NULL);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 fd = open_system_log_file(who->name);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 } else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 fd = open_system_log_file(NULL);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 if (!fd)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 if (why & OPT_LOG_MY_SIGNON) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 case log_signon:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
311 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
312 gc->username, gc->prpl->info->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 g_snprintf(html, sizeof(html), "<B>%s</B>", 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_signoff:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
316 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
317 gc->username, gc->prpl->info->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 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
319 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
321 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
322 gc->username, gc->prpl->info->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", 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_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
326 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
327 gc->username, gc->prpl->info->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 g_snprintf(html, sizeof(html), "%s", 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 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
331 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
332 gc->username, gc->prpl->info->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 case log_unidle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
336 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
337 gc->username, gc->prpl->info->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 case log_quit:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
341 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 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
343 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
345 } else if (gaim_get_buddy_alias_only(who)) {
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 case log_signon:
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) signed on @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
349 gc->username, gc->prpl->info->name, gaim_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), "<B>%s</B>", 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_signoff:
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) signed off @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
354 gc->username, gc->prpl->info->name, gaim_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), "<I><FONT COLOR=GRAY>%s</FONT></I>", 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_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
358 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
359 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
363 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
364 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 g_snprintf(html, sizeof(html), "%s", text);
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 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
368 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
369 gc->username, gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 case log_unidle:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 g_snprintf(text, sizeof(text),
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
374 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gc->username,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
375 gc->prpl->info->name, gaim_get_buddy_alias(who), who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 default:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 switch (what) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 case log_signon:
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 signed on @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
387 gc->username, gc->prpl->info->name, who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 g_snprintf(html, sizeof(html), "<B>%s</B>", 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_signoff:
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 signed off @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
392 gc->username, gc->prpl->info->name, who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 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
394 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 case log_away:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
396 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
397 gc->username, gc->prpl->info->name, who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 case log_back:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
401 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
402 gc->username, gc->prpl->info->name, who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 g_snprintf(html, sizeof(html), "%s", text);
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 case log_idle:
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
406 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"),
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
407 gc->username, gc->prpl->info->name, who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 case log_unidle:
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 g_snprintf(text, sizeof(text),
4195
4a0837c49d85 [gaim-migrate @ 4426]
Luke Schierer <lschiere@pidgin.im>
parents: 4192
diff changeset
412 _("%s (%s) reported that %s returned from idle @ %s"), gc->username,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5138
diff changeset
413 gc->prpl->info->name, who->name, full_date());
4184
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 g_snprintf(html, sizeof(html), "%s", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 default:
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 return;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 break;
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 if (logging_options & OPT_LOG_STRIP_HTML) {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 fprintf(fd, "---- %s ----\n", text);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 } else {
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 if (logging_options & OPT_LOG_INDIVIDUAL)
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 else
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 fprintf(fd, "%s<BR>\n", html);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 }
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 fclose(fd);
af2eeb7f7cf8 [gaim-migrate @ 4415]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 }
4359
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 char *html_logize(const char *p)
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 const char *temp_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
438 char *buffer_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
439 char *buffer_start;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
440 int num_cr = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
441 int char_len = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
442
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
443 for (temp_p = p; *temp_p != '\0'; temp_p++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
444 char_len++;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
445
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
446 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!')))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
447 num_cr++;
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
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
450 buffer_p = g_malloc(char_len + (4 * num_cr) + 1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
451
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
452 for (temp_p = p, buffer_start = buffer_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
453 *temp_p != '\0';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
454 temp_p++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
455
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
456 if (*temp_p == '\n') {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
457 *buffer_p++ = '<';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
458 *buffer_p++ = 'B';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
459 *buffer_p++ = 'R';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
460 *buffer_p++ = '>';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
461 *buffer_p++ = '\n';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
462
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
463 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
464 *buffer_p++ = '&';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
465 *buffer_p++ = 'l';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
466 *buffer_p++ = 't';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
467 *buffer_p++ = ';';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
468
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
469 } else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
470 *buffer_p++ = *temp_p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
471 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
472
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
473 *buffer_p = '\0';
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
474
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
475 return buffer_start;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4227
diff changeset
476 }