pidgin/plugins/pidgininc.c

Tue, 15 Sep 2020 21:54:10 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 15 Sep 2020 21:54:10 -0500
changeset 40534
8dad2981fb86
parent 40360
e21f3bbcc2a5
permissions
-rw-r--r--

Separate the AccountChooser from its model and move options to filters

Create a store for accounts and a filter to only show connected accounts

Update everything to use the new PidginAccountStore and PidginAccountFilterConnected filter

Add a GtkTreeModelFilter for protocols by id

Testing Done:
Compiled and opened most of the dialogs to make sure they're still working the same. Was unable to test gevolution.

Reviewed at https://reviews.imfreedom.org/r/95/

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
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
4 #include "internal.h"
35072
cb3673616d90 Added a note regarding internal.h for example plugins
Ankit Vani <a@nevitus.org>
parents: 34627
diff changeset
5 #include <purple.h>
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
6
25629
a1d84a478cb7 s/pidgindialogs_about/pidgin_dialogs_about/ to fix compiling also add some
Etan Reisner <deryni@pidgin.im>
parents: 20288
diff changeset
7 /* include UI for pidgin_dialogs_about() */
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
8 #include "gtkplugin.h"
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 8999
diff changeset
9 #include "gtkdialogs.h"
91
5d2be994dcf4 [gaim-migrate @ 101]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
10
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
11 #define PURPLEINC_PLUGIN_ID "core-purpleinc"
5255
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
12
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
13 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
14 echo_hi(PurpleConnection *gc)
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
15 {
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
16 /* 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
17 pidgin_dialogs_about();
91
5d2be994dcf4 [gaim-migrate @ 101]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
18 }
92
b2cc29da946e [gaim-migrate @ 102]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 91
diff changeset
19
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
20 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
21 reverse(PurpleAccount *account, char **who, char **message,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
22 PurpleConversation *conv, int *flags)
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
23 {
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
24 /* this will drive you insane. whenever you receive a message,
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
25 * the text of the message (HTML and all) will be reversed. */
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
26 int i, l;
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
27 char tmp;
99
eed3f8358586 [gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 96
diff changeset
28
eed3f8358586 [gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 96
diff changeset
29 /* this check is necessary in case bad plugins do bad things */
eed3f8358586 [gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 96
diff changeset
30 if (message == NULL || *message == NULL)
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
31 return FALSE;
99
eed3f8358586 [gaim-migrate @ 109]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 96
diff changeset
32
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
33 l = strlen(*message);
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
34
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 25639
diff changeset
35 if (purple_strequal(*who, purple_account_get_username(account)))
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
36 return FALSE;
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
37
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
38 for (i = 0; i < l/2; i++) {
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
39 tmp = (*message)[i];
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
40 (*message)[i] = (*message)[l - i - 1];
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
41 (*message)[l - i - 1] = tmp;
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
42 }
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
43 return FALSE;
92
b2cc29da946e [gaim-migrate @ 102]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 91
diff changeset
44 }
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
45
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
46 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
47 bud(PurpleBuddy *who)
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
48 {
36770
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
49 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
50 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
51 purple_buddy_get_name(who));
7746
d7cdf0d60f5d [gaim-migrate @ 8391]
Paul Aurich <darkrain42@pidgin.im>
parents: 6982
diff changeset
52
36770
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
53 purple_conversation_send(PURPLE_CONVERSATION(im), "Hello!");
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
54 }
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
55
5255
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
56 /*
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
57 * EXPORTED FUNCTIONS
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
58 */
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
59
36770
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
60 static PidginPluginInfo *
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
61 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
62 {
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
63 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
64 "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
65 NULL
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
66 };
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
67
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
68 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
69 "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
70 "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
71 "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
72 "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
73 "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
74 "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
75 "- 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
76 "- 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
77 "- 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
78 " 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
79 "authors", authors,
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
80 "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
81 "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
82 NULL
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
83 );
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
84 }
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
85
5255
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
86 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
87 plugin_load(PurplePlugin *plugin, GError **error)
5255
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
88 {
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
89 /* this is for doing something fun when we sign on */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
90 purple_signal_connect(purple_connections_get_handle(), "signed-on",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
91 plugin, PURPLE_CALLBACK(echo_hi), NULL);
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
92
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
93 /* this is for doing something fun when we get a message */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
94 purple_signal_connect(purple_conversations_get_handle(), "receiving-im-msg",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
95 plugin, PURPLE_CALLBACK(reverse), NULL);
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
96
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
97 /* this is for doing something fun when a buddy comes online */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
98 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
99 plugin, PURPLE_CALLBACK(bud), NULL);
1047
783f8520d9a0 [gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 99
diff changeset
100
5255
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
101 return TRUE;
94
0c6ba3d3fa90 [gaim-migrate @ 104]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 92
diff changeset
102 }
96
2b8586ab9456 [gaim-migrate @ 106]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents: 94
diff changeset
103
36770
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
104 static gboolean
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
105 plugin_unload(PurplePlugin *plugin, GError **error)
5255
8aa84137a01f [gaim-migrate @ 5627]
Paul Aurich <darkrain42@pidgin.im>
parents: 5205
diff changeset
106 {
36770
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
107 return TRUE;
3551
acce66c34dbd [gaim-migrate @ 3626]
Sean Egan <seanegan@pidgin.im>
parents: 1047
diff changeset
108 }
acce66c34dbd [gaim-migrate @ 3626]
Sean Egan <seanegan@pidgin.im>
parents: 1047
diff changeset
109
36770
d971efd6f8bd Refactored mailchk, pidgininc, raw pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 36367
diff changeset
110 PURPLE_PLUGIN_INIT(purpleinc, plugin_query, plugin_load, plugin_unload);

mercurial