Mon, 18 Nov 2013 01:12:39 +0530
Merged soc.2013.gobjectification branch
|
35072
cb3673616d90
Added a note regarding internal.h for example plugins
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
1 | /* When writing a third-party plugin, do not include libpurple's internal.h |
|
cb3673616d90
Added a note regarding internal.h for example plugins
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
2 | * included below. This file is for internal libpurple use only. We're including |
|
cb3673616d90
Added a note regarding internal.h for example plugins
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
3 | * it here for our own convenience. */ |
| 7746 | 4 | #include "internal.h" |
| 5 | ||
|
35072
cb3673616d90
Added a note regarding internal.h for example plugins
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
6 | /* This file defines PURPLE_PLUGINS and includes all the libpurple headers */ |
|
cb3673616d90
Added a note regarding internal.h for example plugins
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
7 | #include <purple.h> |
| 7746 | 8 | |
|
25629
a1d84a478cb7
s/pidgindialogs_about/pidgin_dialogs_about/ to fix compiling also add some
Etan Reisner <deryni@pidgin.im>
parents:
20288
diff
changeset
|
9 | /* include UI for pidgin_dialogs_about() */ |
| 7746 | 10 | #include "gtkplugin.h" |
|
9709
2e73f176cc80
[gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents:
8999
diff
changeset
|
11 | #include "gtkdialogs.h" |
| 91 | 12 | |
| 15884 | 13 | #define PURPLEINC_PLUGIN_ID "core-purpleinc" |
| 5255 | 14 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
15 | static void |
| 15884 | 16 | echo_hi(PurpleConnection *gc) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
17 | { |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
18 | /* this doesn't do much, just lets you know who we are :) */ |
|
25629
a1d84a478cb7
s/pidgindialogs_about/pidgin_dialogs_about/ to fix compiling also add some
Etan Reisner <deryni@pidgin.im>
parents:
20288
diff
changeset
|
19 | pidgin_dialogs_about(); |
| 91 | 20 | } |
|
92
b2cc29da946e
[gaim-migrate @ 102]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
91
diff
changeset
|
21 | |
| 7746 | 22 | static gboolean |
| 15884 | 23 | reverse(PurpleAccount *account, char **who, char **message, |
| 24 | PurpleConversation *conv, int *flags) | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
25 | { |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
26 | /* this will drive you insane. whenever you receive a message, |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
27 | * the text of the message (HTML and all) will be reversed. */ |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
28 | int i, l; |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
29 | char tmp; |
|
99
eed3f8358586
[gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
96
diff
changeset
|
30 | |
|
eed3f8358586
[gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
96
diff
changeset
|
31 | /* this check is necessary in case bad plugins do bad things */ |
|
eed3f8358586
[gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
96
diff
changeset
|
32 | if (message == NULL || *message == NULL) |
| 7746 | 33 | return FALSE; |
|
99
eed3f8358586
[gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
96
diff
changeset
|
34 | |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
35 | l = strlen(*message); |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
36 | |
| 15884 | 37 | if (!strcmp(*who, purple_account_get_username(account))) |
| 7746 | 38 | return FALSE; |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
39 | |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
40 | for (i = 0; i < l/2; i++) { |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
41 | tmp = (*message)[i]; |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
42 | (*message)[i] = (*message)[l - i - 1]; |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
43 | (*message)[l - i - 1] = tmp; |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
44 | } |
| 7746 | 45 | return FALSE; |
|
92
b2cc29da946e
[gaim-migrate @ 102]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
91
diff
changeset
|
46 | } |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
47 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
48 | static void |
| 15884 | 49 | bud(PurpleBuddy *who) |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
50 | { |
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
51 | PurpleAccount *acct = purple_buddy_get_account(who); |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
52 | PurpleIMConversation *im = purple_im_conversation_new(acct, |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
53 | purple_buddy_get_name(who)); |
| 7746 | 54 | |
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
55 | purple_conversation_send(PURPLE_CONVERSATION(im), "Hello!"); |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
56 | } |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
57 | |
| 5255 | 58 | /* |
| 59 | * EXPORTED FUNCTIONS | |
| 60 | */ | |
| 61 | ||
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
62 | static PidginPluginInfo * |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
63 | plugin_query(GError **error) |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
64 | { |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
65 | const gchar * const authors[] = { |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
66 | "Eric Warmenhoven <eric@warmenhoven.org>", |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
67 | NULL |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
68 | }; |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
69 | |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
70 | return pidgin_plugin_info_new( |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
71 | "id", PURPLEINC_PLUGIN_ID, |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
72 | "name", N_("Pidgin Demonstration Plugin"), |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
73 | "version", DISPLAY_VERSION, |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
74 | "category", N_("Example"), |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
75 | "summary", N_("An example plugin that does stuff - see the description."), |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
76 | "description", N_("This is a really cool plugin that does a lot of stuff:\n" |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
77 | "- It tells you who wrote the program when you log in\n" |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
78 | "- It reverses all incoming text\n" |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
79 | "- It sends a message to people on your list immediately" |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
80 | " when they sign on"), |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
81 | "authors", authors, |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
82 | "website", PURPLE_WEBSITE, |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
83 | "abi-version", PURPLE_ABI_VERSION, |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
84 | NULL |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
85 | ); |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
86 | } |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
87 | |
| 5255 | 88 | static gboolean |
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
89 | plugin_load(PurplePlugin *plugin, GError **error) |
| 5255 | 90 | { |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
91 | /* this is for doing something fun when we sign on */ |
| 15884 | 92 | purple_signal_connect(purple_connections_get_handle(), "signed-on", |
| 93 | plugin, PURPLE_CALLBACK(echo_hi), NULL); | |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
94 | |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
95 | /* this is for doing something fun when we get a message */ |
| 15884 | 96 | purple_signal_connect(purple_conversations_get_handle(), "receiving-im-msg", |
| 97 | plugin, PURPLE_CALLBACK(reverse), NULL); | |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
98 | |
|
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
99 | /* this is for doing something fun when a buddy comes online */ |
| 15884 | 100 | purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", |
| 101 | plugin, PURPLE_CALLBACK(bud), NULL); | |
|
1047
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
99
diff
changeset
|
102 | |
| 5255 | 103 | return TRUE; |
|
94
0c6ba3d3fa90
[gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
92
diff
changeset
|
104 | } |
|
96
2b8586ab9456
[gaim-migrate @ 106]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
94
diff
changeset
|
105 | |
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
106 | static gboolean |
|
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
107 | plugin_unload(PurplePlugin *plugin, GError **error) |
| 5255 | 108 | { |
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
109 | return TRUE; |
| 3551 | 110 | } |
| 111 | ||
|
36770
d971efd6f8bd
Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
112 | PURPLE_PLUGIN_INIT(purpleinc, plugin_query, plugin_load, plugin_unload); |