Mercurial > pidgin
annotate plugins/gaiminc.c @ 7827:ee32e030c9be
[gaim-migrate @ 8479]
marv asserts that these character set conversions are more correct
than the previous yahoo conversions, which assumed that pretty much
everything was UTF-8. I believe him.
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Wed, 10 Dec 2003 16:48:23 +0000 |
parents | d7fd01f7bdcb |
children | d7b8eb1f0a18 |
rev | line source |
---|---|
7746 | 1 #include "internal.h" |
2 #include "plugin.h" | |
3 | |
4 #include "account.h" | |
5 #include "connection.h" | |
6 #include "conversation.h" | |
7 | |
8 /* include UI for show_about() */ | |
9 #include "gtkplugin.h" | |
10 #include "ui.h" | |
91 | 11 |
5255 | 12 #define GAIMINC_PLUGIN_ID "core-gaiminc" |
13 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
14 static void |
7746 | 15 echo_hi(GaimConnection *gc) |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
16 { |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
17 /* this doesn't do much, just lets you know who we are :) */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
18 show_about(NULL, NULL); |
91 | 19 } |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
91
diff
changeset
|
20 |
7746 | 21 static gboolean |
22 reverse(GaimAccount *account, char **who, char **message, int *flags) | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
23 { |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
24 /* this will drive you insane. whenever you receive a message, |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
25 * the text of the message (HTML and all) will be reversed. */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
26 int i, l; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
27 char tmp; |
99
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
28 |
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
29 /* this check is necessary in case bad plugins do bad things */ |
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
30 if (message == NULL || *message == NULL) |
7746 | 31 return FALSE; |
99
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
32 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
33 l = strlen(*message); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
34 |
7746 | 35 if (!strcmp(*who, gaim_account_get_username(account))) |
36 return FALSE; | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
37 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
38 for (i = 0; i < l/2; i++) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
39 tmp = (*message)[i]; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
40 (*message)[i] = (*message)[l - i - 1]; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
41 (*message)[l - i - 1] = tmp; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
42 } |
7746 | 43 return FALSE; |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
91
diff
changeset
|
44 } |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
45 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
46 static void |
7746 | 47 bud(GaimBuddy *who) |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
48 { |
7746 | 49 GaimAccount *acct = who->account; |
50 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_IM, acct, who->name); | |
51 | |
52 gaim_conv_im_send(GAIM_CONV_IM(conv), "Hello!"); | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
53 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
54 |
5255 | 55 /* |
56 * EXPORTED FUNCTIONS | |
57 */ | |
58 | |
59 static gboolean | |
60 plugin_load(GaimPlugin *plugin) | |
61 { | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
62 /* this is for doing something fun when we sign on */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
63 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
64 plugin, GAIM_CALLBACK(echo_hi), NULL); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
65 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
66 /* this is for doing something fun when we get a message */ |
7746 | 67 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
68 plugin, GAIM_CALLBACK(reverse), NULL); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
69 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
70 /* 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
|
71 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
72 plugin, GAIM_CALLBACK(bud), NULL); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
99
diff
changeset
|
73 |
5255 | 74 return TRUE; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
75 } |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
76 |
5255 | 77 static GaimPluginInfo info = |
78 { | |
79 2, /**< api_version */ | |
80 GAIM_PLUGIN_STANDARD, /**< type */ | |
81 NULL, /**< ui_requirement */ | |
82 0, /**< flags */ | |
83 NULL, /**< dependencies */ | |
84 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
85 | |
86 GAIMINC_PLUGIN_ID, /**< id */ | |
87 N_("Gaim Demonstration Plugin"), /**< name */ | |
88 VERSION, /**< version */ | |
89 /** summary */ | |
90 N_("An example plugin that does stuff - see the description."), | |
91 /** description */ | |
92 N_("This is a really cool plugin that does a lot of stuff:\n" | |
93 "- It tells you who wrote the program when you log in\n" | |
94 "- It reverses all incoming text\n" | |
95 "- It sends a message to people on your list immediately" | |
96 " when they sign on"), | |
97 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
98 GAIM_WEBSITE, /**< homepage */ |
5255 | 99 |
100 plugin_load, /**< load */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
101 NULL, /**< unload */ |
5255 | 102 NULL, /**< destroy */ |
103 | |
104 NULL, /**< ui_info */ | |
105 NULL /**< extra_info */ | |
106 }; | |
107 | |
108 static void | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5255
diff
changeset
|
109 init_plugin(GaimPlugin *plugin) |
5255 | 110 { |
3551 | 111 } |
112 | |
6063 | 113 GAIM_INIT_PLUGIN(gaiminc, init_plugin, info) |