Fri, 25 Apr 2003 06:47:33 +0000
[gaim-migrate @ 5573]
I had a damn good commit message, but it was eaten. Let's try it again.
Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short.
There are lots'a cool thingies here.
Okay now, this isn't as cool as the previous message, but:
1) There's now a single entry function for all plugin types. It returns a
detailed information structure on the plugin. This removes a lot of the
ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so
if you use it, well, you shouldn't have used it anyway, but now you
can't! bwahahaha. Use AIM/ICQ.
2) There are now 3 types of plugins: Standard, Loader, and Protocol
plugins.
Standard plugins are, well, standard, compiled plugins.
Loader plugins load other plugins. For example, the perl support is now
a loader plugin. It loads perl scripts. In the future, we'll have
Ruby and Python loader plugins.
Protocol plugins are, well, protocol plugins... yeah...
3) Plugins have unique IDs, so they can be referred to or automatically
updated from a plugin database in the future. Neat, huh?
4) Plugins will have dependency support in the future, and can be hidden,
so if you have, say, a logging core plugin, it won't have to show up,
but then you load the GTK+ logging plugin and it'll auto-load the core
plugin. Core/UI split plugins!
5) There will eventually be custom plugin signals and RPC of some sort, for
the core/ui split plugins.
So, okay, back up .gaimrc.
I'd like to thank my parents for their support, javabsp for helping convert
a bunch of protocol plugins, and Etan for helping convert a bunch of
standard plugins.
Have fun. If you have any problems, please let me know, but you probably
won't have anything major happen. You will have to convert your plugins,
though, and I'm not guaranteeing that all perl scripts will still work.
I'll end up changing the perl script API eventually, so I know they won't
down the road. Don't worry, though. It'll be mass cool.
faceprint wants me to just commit the damn code already. So, here we go!!!
..
..
I need a massage. From a young, cute girl. Are there any young, cute girls
in the audience? IM me plz k thx.
| 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; | |
| 4793 | 49 | if (!gaim_utf8_strcasecmp(pname, normalize(l->name))) { |
| 4184 | 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); | |
| 5138 | 251 | fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
| 4184 | 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); | |
| 5138 | 267 | fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n"); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
298 | gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
303 | gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
308 | gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
313 | gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
318 | gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
323 | gc->username, gc->prpl->info->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
335 | gc->username, gc->prpl->info->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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
340 | gc->username, gc->prpl->info->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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
345 | gc->username, gc->prpl->info->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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
350 | gc->username, gc->prpl->info->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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
355 | gc->username, gc->prpl->info->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, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
361 | gc->prpl->info->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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
373 | gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
378 | gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
383 | gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
388 | gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 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"), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
393 | gc->username, gc->prpl->info->name, who->name, full_date()); |
| 4184 | 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, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5138
diff
changeset
|
399 | gc->prpl->info->name, who->name, full_date()); |
| 4184 | 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 | } |