Mon, 10 Mar 2003 05:30:31 +0000
[gaim-migrate @ 4998]
This is a new buddy list.
Lots of things about it just Don't Work. I probably already know about those
things, and you'd just be wasting my time in submitting a bug report about it.
I decided that instead of getting it to all work perfectly before committing,
that I'd get it in cvs, and slowly fix it with regular commits. That way, it's
easier to keep track of things, and other developers can help. Plus, I'm getting
pissed off at the buddy list and want it to die. It's kinda boring, and doing nothing
but the buddy list for such a long time has just gotten me very bitter.
After 0.60 is released later this week, Gaim will resume being fun. This week is
going to be very stressful, though, I'm sure.
Things you ought to know about this buddy list:
- It crashes
- It leaks
- There's no way to edit the buddy list, or access offline buddies
- Most of the menus and buttons and whatnot just plain ol' don't work.
- Status icons are only implemented for AIM.
That's mostly just because I'm lazy. As such, you may want to be wary of updating this.
If you do decide to update this, you may want to learn "cvs update -D yesterday" as well :)
All the art there is just placeholder art.
You probably won't really have as many problems as it sounds like you will from reading this.
This message is extra-negative to stress that I don't want to be bothered with complaints about
something not working about it :). I'll repeat: If something doesn't work, I probably already
know about it.
If you want to actually help with something, I'd be delighted to have it. IM me.
-s.
| 4184 | 1 | /* --------------------------------------------------- |
| 2 | * Function to remove a log file entry | |
| 3 | * --------------------------------------------------- | |
| 4 | */ | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
5 | #ifdef HAVE_CONFIG_H |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
6 | #include <config.h> |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
7 | #endif |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
8 | #include <string.h> |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
9 | |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
10 | #ifndef _WIN32 |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
11 | #include <unistd.h> |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
12 | #endif |
|
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
13 | |
| 4184 | 14 | #include "gaim.h" |
| 15 | #include "core.h" | |
| 16 | #include "multi.h" | |
| 17 | #include "prpl.h" | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
18 | #include <string.h> |
| 4184 | 19 | #include <sys/stat.h> |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
20 | #include <unistd.h> |
| 4184 | 21 | |
|
4192
fd80a226a2d9
[gaim-migrate @ 4423]
Herman Bloggs <herman@bluedigits.com>
parents:
4184
diff
changeset
|
22 | #ifdef _WIN32 |
|
fd80a226a2d9
[gaim-migrate @ 4423]
Herman Bloggs <herman@bluedigits.com>
parents:
4184
diff
changeset
|
23 | #include "win32dep.h" |
|
fd80a226a2d9
[gaim-migrate @ 4423]
Herman Bloggs <herman@bluedigits.com>
parents:
4184
diff
changeset
|
24 | #endif |
|
fd80a226a2d9
[gaim-migrate @ 4423]
Herman Bloggs <herman@bluedigits.com>
parents:
4184
diff
changeset
|
25 | |
| 4184 | 26 | void rm_log(struct log_conversation *a) |
| 27 | { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
28 | struct gaim_conversation *cnv = gaim_find_conversation(a->name); |
| 4184 | 29 | |
| 30 | log_conversations = g_list_remove(log_conversations, a); | |
| 31 | ||
| 32 | save_prefs(); | |
| 33 | ||
| 34 | if (cnv && !(im_options & OPT_IM_ONE_WINDOW)) | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
35 | gaim_conversation_autoset_title(cnv); |
| 4184 | 36 | } |
| 37 | ||
| 38 | struct log_conversation *find_log_info(const char *name) | |
| 39 | { | |
| 40 | char *pname = g_malloc(BUF_LEN); | |
| 41 | GList *lc = log_conversations; | |
| 42 | struct log_conversation *l; | |
| 43 | ||
| 44 | ||
| 45 | strcpy(pname, normalize(name)); | |
| 46 | ||
| 47 | while (lc) { | |
| 48 | l = (struct log_conversation *)lc->data; | |
| 49 | if (!g_strcasecmp(pname, normalize(l->name))) { | |
| 50 | g_free(pname); | |
| 51 | return l; | |
| 52 | } | |
| 53 | lc = lc->next; | |
| 54 | } | |
| 55 | g_free(pname); | |
| 56 | return NULL; | |
| 57 | } | |
| 58 | ||
| 59 | void update_log_convs() | |
| 60 | { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
61 | GList *cnv; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
62 | struct gaim_conversation *c; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
63 | struct gaim_gtk_conversation *gtkconv; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
64 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
65 | for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
66 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
67 | c = (struct gaim_conversation *)cnv->data; |
| 4184 | 68 | |
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
69 | if (!GAIM_IS_GTK_CONVERSATION(c)) |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
70 | continue; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
71 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
72 | gtkconv = GAIM_GTK_CONVERSATION(c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
73 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
74 | if (gtkconv->toolbar.log) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
75 | if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
76 | gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
| 4184 | 77 | ((logging_options & OPT_LOG_CHATS)) ? FALSE : TRUE); |
| 78 | else | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
79 | gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
| 4184 | 80 | ((logging_options & OPT_LOG_CONVOS)) ? FALSE : TRUE); |
| 81 | } | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 4635 | 85 | static void do_save_convo(GObject *obj, GtkWidget *wid) |
| 4184 | 86 | { |
| 4635 | 87 | struct gaim_conversation *c = g_object_get_data(obj, "gaim_conversation"); |
| 4184 | 88 | const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
| 89 | FILE *f; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
90 | |
| 4184 | 91 | if (file_is_dir(filename, wid)) |
| 92 | return; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
93 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
94 | if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
95 | g_list_find(gaim_get_ims(), c)) || |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
96 | (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
97 | g_list_find(gaim_get_chats(), c)))) |
| 4184 | 98 | filename = NULL; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
99 | |
| 4184 | 100 | gtk_widget_destroy(wid); |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
101 | |
| 4184 | 102 | if (!filename) |
| 103 | return; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
104 | |
| 4184 | 105 | f = fopen(filename, "w+"); |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
106 | |
| 4184 | 107 | if (!f) |
| 108 | return; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
109 | |
| 4184 | 110 | fprintf(f, "%s", c->history->str); |
| 111 | fclose(f); | |
| 112 | } | |
| 113 | ||
| 114 | ||
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
115 | void save_convo(GtkWidget *save, struct gaim_conversation *c) |
| 4184 | 116 | { |
| 117 | char buf[BUF_LONG]; | |
| 118 | GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); | |
| 119 | g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); | |
| 120 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
| 4635 | 121 | g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 122 | "gaim_conversation", c); | |
| 4184 | 123 | g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 124 | "clicked", G_CALLBACK(do_save_convo), window); | |
| 125 | g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), | |
| 126 | "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); | |
| 127 | gtk_widget_show(window); | |
| 128 | } | |
| 129 | ||
| 130 | static FILE *open_gaim_log_file(const char *name, int *flag) | |
| 131 | { | |
| 132 | char *buf; | |
| 133 | char *buf2; | |
| 134 | char log_all_file[256]; | |
| 135 | struct stat st; | |
| 136 | FILE *fd; | |
| 137 | #ifndef _WIN32 | |
| 138 | int res; | |
| 139 | #endif | |
| 140 | gchar *gaim_dir; | |
| 141 | ||
| 142 | buf = g_malloc(BUF_LONG); | |
| 143 | buf2 = g_malloc(BUF_LONG); | |
| 144 | gaim_dir = gaim_user_dir(); | |
| 145 | ||
| 146 | /* Dont log yourself */ | |
| 147 | strncpy(log_all_file, gaim_dir, 256); | |
| 148 | ||
| 149 | #ifndef _WIN32 | |
| 150 | stat(log_all_file, &st); | |
| 151 | if (!S_ISDIR(st.st_mode)) | |
| 152 | unlink(log_all_file); | |
| 153 | ||
| 154 | fd = fopen(log_all_file, "r"); | |
| 155 | ||
| 156 | if (!fd) { | |
| 157 | res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 158 | if (res < 0) { | |
| 159 | g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
| 160 | log_all_file); | |
| 161 | do_error_dialog(buf, NULL, GAIM_ERROR); | |
| 162 | g_free(buf); | |
| 163 | g_free(buf2); | |
| 164 | return NULL; | |
| 165 | } | |
| 166 | } else | |
| 167 | fclose(fd); | |
| 168 | ||
| 169 | g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
| 170 | ||
| 171 | if (stat(log_all_file, &st) < 0) | |
| 172 | *flag = 1; | |
| 173 | if (!S_ISDIR(st.st_mode)) | |
| 174 | unlink(log_all_file); | |
| 175 | ||
| 176 | fd = fopen(log_all_file, "r"); | |
| 177 | if (!fd) { | |
| 178 | res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 179 | if (res < 0) { | |
| 180 | g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
| 181 | log_all_file); | |
| 182 | do_error_dialog(buf, NULL, GAIM_ERROR); | |
| 183 | g_free(buf); | |
| 184 | g_free(buf2); | |
| 185 | return NULL; | |
| 186 | } | |
| 187 | } else | |
| 188 | fclose(fd); | |
| 189 | #else /* _WIN32 */ | |
| 190 | g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
| 191 | ||
| 192 | if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
| 193 | g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file); | |
| 194 | do_error_dialog(buf, NULL, GAIM_ERROR); | |
| 195 | g_free(buf); | |
| 196 | g_free(buf2); | |
| 197 | return NULL; | |
| 198 | } | |
| 199 | #endif | |
| 200 | ||
| 201 | g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
| 202 | if (stat(log_all_file, &st) < 0) | |
| 203 | *flag = 1; | |
| 204 | ||
| 205 | debug_printf("Logging to: \"%s\"\n", log_all_file); | |
| 206 | ||
| 207 | fd = fopen(log_all_file, "a"); | |
| 208 | ||
| 209 | g_free(buf); | |
| 210 | g_free(buf2); | |
| 211 | return fd; | |
| 212 | } | |
| 213 | ||
| 214 | static FILE *open_system_log_file(char *name) | |
| 215 | { | |
| 216 | int x; | |
| 217 | ||
| 218 | if (name) | |
| 219 | return open_log_file(name, 2); | |
| 220 | else | |
| 221 | return open_gaim_log_file("system", &x); | |
| 222 | } | |
| 223 | ||
| 224 | FILE *open_log_file(const char *name, int is_chat) | |
| 225 | { | |
| 226 | struct stat st; | |
| 227 | char realname[256]; | |
| 228 | struct log_conversation *l; | |
| 229 | FILE *fd; | |
| 230 | int flag = 0; | |
| 231 | ||
| 232 | if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL)) | |
| 233 | || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS)) | |
| 234 | || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) { | |
| 235 | ||
| 236 | l = find_log_info(name); | |
| 237 | if (!l) | |
| 238 | return NULL; | |
| 239 | ||
| 240 | if (stat(l->filename, &st) < 0) | |
| 241 | flag = 1; | |
| 242 | ||
| 243 | fd = fopen(l->filename, "a"); | |
| 244 | ||
| 245 | if (flag) { /* is a new file */ | |
| 246 | if (logging_options & OPT_LOG_STRIP_HTML) { | |
| 247 | fprintf(fd, _("IM Sessions with %s\n"), name); | |
| 248 | } else { | |
| 249 | fprintf(fd, "<HTML><HEAD><TITLE>"); | |
| 250 | fprintf(fd, _("IM Sessions with %s"), name); | |
| 251 | fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
| 252 | } | |
| 253 | } | |
| 254 | ||
| 255 | return fd; | |
| 256 | } | |
| 257 | ||
| 258 | g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); | |
| 259 | fd = open_gaim_log_file(realname, &flag); | |
| 260 | ||
| 261 | if (fd && flag) { /* is a new file */ | |
| 262 | if (logging_options & OPT_LOG_STRIP_HTML) { | |
| 263 | fprintf(fd, _("IM Sessions with %s\n"), name); | |
| 264 | } else { | |
| 265 | fprintf(fd, "<HTML><HEAD><TITLE>"); | |
| 266 | fprintf(fd, _("IM Sessions with %s"), name); | |
| 267 | fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | return fd; | |
| 272 | } | |
| 273 | ||
| 274 | void system_log(enum log_event what, struct gaim_connection *gc, | |
| 275 | struct buddy *who, int why) | |
| 276 | { | |
| 277 | FILE *fd; | |
| 278 | char text[256], html[256]; | |
| 279 | ||
| 280 | if ((logging_options & why) != why) | |
| 281 | return; | |
| 282 | ||
| 283 | if (logging_options & OPT_LOG_INDIVIDUAL) { | |
| 284 | if (why & OPT_LOG_MY_SIGNON) | |
| 285 | fd = open_system_log_file(gc ? gc->username : NULL); | |
| 286 | else | |
| 287 | fd = open_system_log_file(who->name); | |
| 288 | } else | |
| 289 | fd = open_system_log_file(NULL); | |
| 290 | ||
| 291 | if (!fd) | |
| 292 | return; | |
| 293 | ||
| 294 | if (why & OPT_LOG_MY_SIGNON) { | |
| 295 | switch (what) { | |
| 296 | case log_signon: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
297 | g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
| 4184 | 298 | gc->username, gc->prpl->name, full_date()); |
| 299 | g_snprintf(html, sizeof(html), "<B>%s</B>", text); | |
| 300 | break; | |
| 301 | case log_signoff: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
302 | g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
| 4184 | 303 | gc->username, gc->prpl->name, full_date()); |
| 304 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); | |
| 305 | break; | |
| 306 | case log_away: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
307 | g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"), |
| 4184 | 308 | gc->username, gc->prpl->name, full_date()); |
| 309 | g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); | |
| 310 | break; | |
| 311 | case log_back: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
312 | g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
| 4184 | 313 | gc->username, gc->prpl->name, full_date()); |
| 314 | g_snprintf(html, sizeof(html), "%s", text); | |
| 315 | break; | |
| 316 | case log_idle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
317 | g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
| 4184 | 318 | gc->username, gc->prpl->name, full_date()); |
| 319 | g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); | |
| 320 | break; | |
| 321 | case log_unidle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
322 | g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"), |
| 4184 | 323 | gc->username, gc->prpl->name, full_date()); |
| 324 | g_snprintf(html, sizeof(html), "%s", text); | |
| 325 | break; | |
| 326 | case log_quit: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
327 | g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
| 4184 | 328 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 329 | break; | |
| 330 | } | |
| 4687 | 331 | } else if (gaim_get_buddy_alias_only(who)) { |
| 4184 | 332 | switch (what) { |
| 333 | case log_signon: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
334 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"), |
| 4687 | 335 | gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 336 | g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
| 337 | break; | |
| 338 | case log_signoff: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
339 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"), |
| 4687 | 340 | gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 341 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
| 342 | break; | |
| 343 | case log_away: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
344 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"), |
| 4687 | 345 | gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 346 | g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
| 347 | break; | |
| 348 | case log_back: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
349 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"), |
| 4687 | 350 | gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 351 | g_snprintf(html, sizeof(html), "%s", text); |
| 352 | break; | |
| 353 | case log_idle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
354 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"), |
| 4687 | 355 | gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 356 | g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
| 357 | break; | |
| 358 | case log_unidle: | |
| 359 | g_snprintf(text, sizeof(text), | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
360 | _("%s (%s) reported that %s (%s) returned from idle @ %s"), gc->username, |
| 4687 | 361 | gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
| 4184 | 362 | g_snprintf(html, sizeof(html), "%s", text); |
| 363 | break; | |
| 364 | default: | |
| 365 | fclose(fd); | |
| 366 | return; | |
| 367 | break; | |
| 368 | } | |
| 369 | } else { | |
| 370 | switch (what) { | |
| 371 | case log_signon: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
372 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"), |
| 4184 | 373 | gc->username, gc->prpl->name, who->name, full_date()); |
| 374 | g_snprintf(html, sizeof(html), "<B>%s</B>", text); | |
| 375 | break; | |
| 376 | case log_signoff: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
377 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"), |
| 4184 | 378 | gc->username, gc->prpl->name, who->name, full_date()); |
| 379 | g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); | |
| 380 | break; | |
| 381 | case log_away: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
382 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"), |
| 4184 | 383 | gc->username, gc->prpl->name, who->name, full_date()); |
| 384 | g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); | |
| 385 | break; | |
| 386 | case log_back: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
387 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"), |
| 4184 | 388 | gc->username, gc->prpl->name, who->name, full_date()); |
| 389 | g_snprintf(html, sizeof(html), "%s", text); | |
| 390 | break; | |
| 391 | case log_idle: | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
392 | g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"), |
| 4184 | 393 | gc->username, gc->prpl->name, who->name, full_date()); |
| 394 | g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); | |
| 395 | break; | |
| 396 | case log_unidle: | |
| 397 | g_snprintf(text, sizeof(text), | |
|
4195
37449660e3d5
[gaim-migrate @ 4426]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4192
diff
changeset
|
398 | _("%s (%s) reported that %s returned from idle @ %s"), gc->username, |
| 4184 | 399 | gc->prpl->name, who->name, full_date()); |
| 400 | g_snprintf(html, sizeof(html), "%s", text); | |
| 401 | break; | |
| 402 | default: | |
| 403 | fclose(fd); | |
| 404 | return; | |
| 405 | break; | |
| 406 | } | |
| 407 | } | |
| 408 | ||
| 409 | if (logging_options & OPT_LOG_STRIP_HTML) { | |
| 410 | fprintf(fd, "---- %s ----\n", text); | |
| 411 | } else { | |
| 412 | if (logging_options & OPT_LOG_INDIVIDUAL) | |
| 413 | fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); | |
| 414 | else | |
| 415 | fprintf(fd, "%s<BR>\n", html); | |
| 416 | } | |
| 417 | ||
| 418 | fclose(fd); | |
| 419 | } | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
420 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
421 | char *html_logize(const char *p) |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
422 | { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
423 | const char *temp_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
424 | char *buffer_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
425 | char *buffer_start; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
426 | int num_cr = 0; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
427 | int char_len = 0; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
428 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
429 | for (temp_p = p; *temp_p != '\0'; temp_p++) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
430 | char_len++; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
431 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
432 | if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
433 | num_cr++; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
434 | } |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
435 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
436 | buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
437 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
438 | for (temp_p = p, buffer_start = buffer_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
439 | *temp_p != '\0'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 | temp_p++) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 | if (*temp_p == '\n') { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
443 | *buffer_p++ = '<'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
444 | *buffer_p++ = 'B'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 | *buffer_p++ = 'R'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 | *buffer_p++ = '>'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
447 | *buffer_p++ = '\n'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
448 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
449 | } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
450 | *buffer_p++ = '&'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 | *buffer_p++ = 'l'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 | *buffer_p++ = 't'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 | *buffer_p++ = ';'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
454 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 | } else |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 | *buffer_p++ = *temp_p; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
457 | } |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
458 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
459 | *buffer_p = '\0'; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 | return buffer_start; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
462 | } |