Mercurial > pidgin.yaz
comparison pidgin/plugins/pidgininc.c @ 16140:787961f1007e
Rename pidgin/plugins/gaiminc.c to pidgin/plugins/pidgininc.c
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 15:47:32 +0000 |
parents | |
children | 3cc856ca2338 |
comparison
equal
deleted
inserted
replaced
16139:caab13aa0b5c | 16140:787961f1007e |
---|---|
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 pidgindialogs_about() */ | |
10 #include "gtkplugin.h" | |
11 #include "gtkdialogs.h" | |
12 | |
13 #define PURPLEINC_PLUGIN_ID "core-purpleinc" | |
14 | |
15 static void | |
16 echo_hi(PurpleConnection *gc) | |
17 { | |
18 /* this doesn't do much, just lets you know who we are :) */ | |
19 pidgindialogs_about(); | |
20 } | |
21 | |
22 static gboolean | |
23 reverse(PurpleAccount *account, char **who, char **message, | |
24 PurpleConversation *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, purple_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(PurpleBuddy *who) | |
50 { | |
51 PurpleAccount *acct = who->account; | |
52 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, who->name); | |
53 | |
54 purple_conv_im_send(PURPLE_CONV_IM(conv), "Hello!"); | |
55 } | |
56 | |
57 /* | |
58 * EXPORTED FUNCTIONS | |
59 */ | |
60 | |
61 static gboolean | |
62 plugin_load(PurplePlugin *plugin) | |
63 { | |
64 /* this is for doing something fun when we sign on */ | |
65 purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
66 plugin, PURPLE_CALLBACK(echo_hi), NULL); | |
67 | |
68 /* this is for doing something fun when we get a message */ | |
69 purple_signal_connect(purple_conversations_get_handle(), "receiving-im-msg", | |
70 plugin, PURPLE_CALLBACK(reverse), NULL); | |
71 | |
72 /* this is for doing something fun when a buddy comes online */ | |
73 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", | |
74 plugin, PURPLE_CALLBACK(bud), NULL); | |
75 | |
76 return TRUE; | |
77 } | |
78 | |
79 static PurplePluginInfo info = | |
80 { | |
81 PURPLE_PLUGIN_MAGIC, | |
82 PURPLE_MAJOR_VERSION, | |
83 PURPLE_MINOR_VERSION, | |
84 PURPLE_PLUGIN_STANDARD, /**< type */ | |
85 NULL, /**< ui_requirement */ | |
86 0, /**< flags */ | |
87 NULL, /**< dependencies */ | |
88 PURPLE_PRIORITY_DEFAULT, /**< priority */ | |
89 | |
90 PURPLEINC_PLUGIN_ID, /**< id */ | |
91 N_("Pidgin 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 PURPLE_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(PurplePlugin *plugin) | |
116 { | |
117 } | |
118 | |
119 PURPLE_INIT_PLUGIN(purpleinc, init_plugin, info) |