annotate plugins/gaiminc.c @ 10849:c203cd637f95

[gaim-migrate @ 12521] sf patch #1185449, from Richard Laager "As the comment in gtkconv.c says, saving a duplicate copy of the entire conversation is completely bogus. Saving a copy of a conversation is a UI thing (if the UI is only showing the last five messages, for example, that's all the user would expect to be saved). Therefore, there's no problem having the UI save its own buffer. The GTK+ UI is already doing this with the imhtml object. This patch removes the history from GaimConversation and uses the buffer in the imhtml object when saving a conversation. It also adds <html>, <head>, <title>, and <body> tags to the file to make it a bit more valid. This patch is extremely likely to break plugins because it changes the size of the GaimConversation struct. As such, if this is committed, I recommend the developers recompile non-default plugins. This broke Gaim-Encryption for me, hence the warning." committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 19 Apr 2005 04:21:39 +0000
parents 60db14d54914
children 17142948653e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
1 #include "internal.h"
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
2 #include "plugin.h"
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
3
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
4 #include "account.h"
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
5 #include "connection.h"
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
6 #include "conversation.h"
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9753
diff changeset
7 #include "version.h"
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
8
9753
60705fd4f411 [gaim-migrate @ 10620]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
9 /* include UI for gaim_gtkdialogs_about() */
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
10 #include "gtkplugin.h"
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8999
diff changeset
11 #include "gtkdialogs.h"
91
308d0896d979 [gaim-migrate @ 101]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
13 #define GAIMINC_PLUGIN_ID "core-gaiminc"
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
14
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
15 static void
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
16 echo_hi(GaimConnection *gc)
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
17 {
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
18 /* this doesn't do much, just lets you know who we are :) */
9753
60705fd4f411 [gaim-migrate @ 10620]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
19 gaim_gtkdialogs_about(NULL, NULL);
91
308d0896d979 [gaim-migrate @ 101]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 }
92
f3c6cf79f651 [gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 91
diff changeset
21
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
22 static gboolean
10104
60db14d54914 [gaim-migrate @ 11131]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9954
diff changeset
23 reverse(GaimAccount *account, char **who, char **message,
60db14d54914 [gaim-migrate @ 11131]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9954
diff changeset
24 GaimConversation *conv, int *flags)
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
25 {
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
26 /* this will drive you insane. whenever you receive a message,
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
27 * the text of the message (HTML and all) will be reversed. */
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
28 int i, l;
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
29 char tmp;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 96
diff changeset
30
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 96
diff changeset
31 /* this check is necessary in case bad plugins do bad things */
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 96
diff changeset
32 if (message == NULL || *message == NULL)
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
33 return FALSE;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 96
diff changeset
34
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
35 l = strlen(*message);
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
36
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
37 if (!strcmp(*who, gaim_account_get_username(account)))
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
38 return FALSE;
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
39
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
40 for (i = 0; i < l/2; i++) {
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
41 tmp = (*message)[i];
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
42 (*message)[i] = (*message)[l - i - 1];
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
43 (*message)[l - i - 1] = tmp;
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
44 }
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
45 return FALSE;
92
f3c6cf79f651 [gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 91
diff changeset
46 }
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
47
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
48 static void
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
49 bud(GaimBuddy *who)
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
50 {
7746
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
51 GaimAccount *acct = who->account;
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
52 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_IM, acct, who->name);
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
53
d7fd01f7bdcb [gaim-migrate @ 8391]
Luke Schierer <lschiere@pidgin.im>
parents: 6982
diff changeset
54 gaim_conv_im_send(GAIM_CONV_IM(conv), "Hello!");
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
55 }
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
56
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
57 /*
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
58 * EXPORTED FUNCTIONS
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
59 */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
60
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
61 static gboolean
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
62 plugin_load(GaimPlugin *plugin)
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
63 {
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
64 /* this is for doing something fun when we sign on */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
65 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
66 plugin, GAIM_CALLBACK(echo_hi), NULL);
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
67
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
68 /* this is for doing something fun when we get a message */
8999
8f838ae3e710 [gaim-migrate @ 9774]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
69 gaim_signal_connect(gaim_conversations_get_handle(), "receiving-im-msg",
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
70 plugin, GAIM_CALLBACK(reverse), NULL);
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
71
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
72 /* this is for doing something fun when a buddy comes online */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
73 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
74 plugin, GAIM_CALLBACK(bud), NULL);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 99
diff changeset
75
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
76 return TRUE;
94
9f6ce50ffb78 [gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 92
diff changeset
77 }
96
247f540ea6e1 [gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 94
diff changeset
78
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
79 static GaimPluginInfo info =
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
80 {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9753
diff changeset
81 GAIM_PLUGIN_MAGIC,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9753
diff changeset
82 GAIM_MAJOR_VERSION,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9753
diff changeset
83 GAIM_MINOR_VERSION,
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
84 GAIM_PLUGIN_STANDARD, /**< type */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
85 NULL, /**< ui_requirement */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
86 0, /**< flags */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
87 NULL, /**< dependencies */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
88 GAIM_PRIORITY_DEFAULT, /**< priority */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
89
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
90 GAIMINC_PLUGIN_ID, /**< id */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
91 N_("Gaim Demonstration Plugin"), /**< name */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
92 VERSION, /**< version */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
93 /** summary */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
94 N_("An example plugin that does stuff - see the description."),
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
95 /** description */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
96 N_("This is a really cool plugin that does a lot of stuff:\n"
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
97 "- It tells you who wrote the program when you log in\n"
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
98 "- It reverses all incoming text\n"
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
99 "- It sends a message to people on your list immediately"
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
100 " when they sign on"),
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
101 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
102 GAIM_WEBSITE, /**< homepage */
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
103
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
104 plugin_load, /**< load */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
105 NULL, /**< unload */
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
106 NULL, /**< destroy */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
107
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
108 NULL, /**< ui_info */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
109 NULL /**< extra_info */
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
110 };
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
111
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
112 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5255
diff changeset
113 init_plugin(GaimPlugin *plugin)
5255
c0baa01cdeda [gaim-migrate @ 5627]
Luke Schierer <lschiere@pidgin.im>
parents: 5205
diff changeset
114 {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
115 }
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 1047
diff changeset
116
6063
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 5920
diff changeset
117 GAIM_INIT_PLUGIN(gaiminc, init_plugin, info)