| |
1 #include "internal.h" |
| |
2 #include "plugin.h" |
| |
3 |
| |
4 #include "account.h" |
| |
5 #include "connection.h" |
| |
6 #include "conversation.h" |
| |
7 #include "version.h" |
| |
8 |
| |
9 /* include UI for gaim_gtkdialogs_about() */ |
| |
10 #include "gtkplugin.h" |
| |
11 #include "gtkdialogs.h" |
| |
12 |
| |
13 #define GAIMINC_PLUGIN_ID "core-gaiminc" |
| |
14 |
| |
15 static void |
| |
16 echo_hi(GaimConnection *gc) |
| |
17 { |
| |
18 /* this doesn't do much, just lets you know who we are :) */ |
| |
19 gaim_gtkdialogs_about(); |
| |
20 } |
| |
21 |
| |
22 static gboolean |
| |
23 reverse(GaimAccount *account, char **who, char **message, |
| |
24 GaimConversation *conv, int *flags) |
| |
25 { |
| |
26 /* this will drive you insane. whenever you receive a message, |
| |
27 * the text of the message (HTML and all) will be reversed. */ |
| |
28 int i, l; |
| |
29 char tmp; |
| |
30 |
| |
31 /* this check is necessary in case bad plugins do bad things */ |
| |
32 if (message == NULL || *message == NULL) |
| |
33 return FALSE; |
| |
34 |
| |
35 l = strlen(*message); |
| |
36 |
| |
37 if (!strcmp(*who, gaim_account_get_username(account))) |
| |
38 return FALSE; |
| |
39 |
| |
40 for (i = 0; i < l/2; i++) { |
| |
41 tmp = (*message)[i]; |
| |
42 (*message)[i] = (*message)[l - i - 1]; |
| |
43 (*message)[l - i - 1] = tmp; |
| |
44 } |
| |
45 return FALSE; |
| |
46 } |
| |
47 |
| |
48 static void |
| |
49 bud(GaimBuddy *who) |
| |
50 { |
| |
51 GaimAccount *acct = who->account; |
| |
52 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, who->name); |
| |
53 |
| |
54 gaim_conv_im_send(GAIM_CONV_IM(conv), "Hello!"); |
| |
55 } |
| |
56 |
| |
57 /* |
| |
58 * EXPORTED FUNCTIONS |
| |
59 */ |
| |
60 |
| |
61 static gboolean |
| |
62 plugin_load(GaimPlugin *plugin) |
| |
63 { |
| |
64 /* this is for doing something fun when we sign on */ |
| |
65 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
| |
66 plugin, GAIM_CALLBACK(echo_hi), NULL); |
| |
67 |
| |
68 /* this is for doing something fun when we get a message */ |
| |
69 gaim_signal_connect(gaim_conversations_get_handle(), "receiving-im-msg", |
| |
70 plugin, GAIM_CALLBACK(reverse), NULL); |
| |
71 |
| |
72 /* this is for doing something fun when a buddy comes online */ |
| |
73 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", |
| |
74 plugin, GAIM_CALLBACK(bud), NULL); |
| |
75 |
| |
76 return TRUE; |
| |
77 } |
| |
78 |
| |
79 static GaimPluginInfo info = |
| |
80 { |
| |
81 GAIM_PLUGIN_MAGIC, |
| |
82 GAIM_MAJOR_VERSION, |
| |
83 GAIM_MINOR_VERSION, |
| |
84 GAIM_PLUGIN_STANDARD, /**< type */ |
| |
85 NULL, /**< ui_requirement */ |
| |
86 0, /**< flags */ |
| |
87 NULL, /**< dependencies */ |
| |
88 GAIM_PRIORITY_DEFAULT, /**< priority */ |
| |
89 |
| |
90 GAIMINC_PLUGIN_ID, /**< id */ |
| |
91 N_("Gaim Demonstration Plugin"), /**< name */ |
| |
92 VERSION, /**< version */ |
| |
93 /** summary */ |
| |
94 N_("An example plugin that does stuff - see the description."), |
| |
95 /** description */ |
| |
96 N_("This is a really cool plugin that does a lot of stuff:\n" |
| |
97 "- It tells you who wrote the program when you log in\n" |
| |
98 "- It reverses all incoming text\n" |
| |
99 "- It sends a message to people on your list immediately" |
| |
100 " when they sign on"), |
| |
101 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ |
| |
102 GAIM_WEBSITE, /**< homepage */ |
| |
103 |
| |
104 plugin_load, /**< load */ |
| |
105 NULL, /**< unload */ |
| |
106 NULL, /**< destroy */ |
| |
107 |
| |
108 NULL, /**< ui_info */ |
| |
109 NULL, /**< extra_info */ |
| |
110 NULL, /**< prefs_info */ |
| |
111 NULL /**< actions */ |
| |
112 }; |
| |
113 |
| |
114 static void |
| |
115 init_plugin(GaimPlugin *plugin) |
| |
116 { |
| |
117 } |
| |
118 |
| |
119 GAIM_INIT_PLUGIN(gaiminc, init_plugin, info) |