Mon, 28 Oct 2013 00:02:17 +0530
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
- Renamed "preferences-frame" to "pref-frame-cb"
- Renamed "preferences-request" to "pref-request-cb"
- Renamed "get-actions" to "actions-cb"
- Renamed "finch-preferences-frame" to "finch-pref-frame-cb"
- Renamed "pidgin-config-frame" to "pidgin-config-frame-cb"
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2 | |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34632
diff
changeset
|
3 | #include "buddylist.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
4 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5 | #include "debug.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
6 | #include "signals.h" |
| 9943 | 7 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
8 | |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
9 | #include "plugins.h" |
| 9583 | 10 | #include "pluginpref.h" |
| 11 | #include "prefs.h" | |
| 12 | ||
| 13 | #define STATENOTIFY_PLUGIN_ID "core-statenotify" | |
| 14 | ||
| 5267 | 15 | static void |
| 15884 | 16 | write_status(PurpleBuddy *buddy, const char *message) |
| 5267 | 17 | { |
|
24531
76e72697f7d6
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
22880
diff
changeset
|
18 | PurpleAccount *account = NULL; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
19 | PurpleIMConversation *im; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
20 | const char *who; |
| 5267 | 21 | char buf[256]; |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
22 | char *escaped; |
|
24531
76e72697f7d6
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
22880
diff
changeset
|
23 | const gchar *buddy_name = NULL; |
|
76e72697f7d6
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
22880
diff
changeset
|
24 | |
|
76e72697f7d6
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
22880
diff
changeset
|
25 | account = purple_buddy_get_account(buddy); |
|
76e72697f7d6
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
22880
diff
changeset
|
26 | buddy_name = purple_buddy_get_name(buddy); |
| 5267 | 27 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
28 | im = purple_conversations_find_im_with_account(buddy_name, account); |
| 5267 | 29 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
30 | if (im == NULL) |
| 5267 | 31 | return; |
| 32 | ||
| 24761 | 33 | /* Prevent duplicate notifications for buddies in multiple groups */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
34 | if (buddy != purple_blist_find_buddy(account, buddy_name)) |
|
24759
9f88e2d42845
Prevent the Buddy State Notification plugin from printing duplicate
Florian Quèze <florian@instantbird.org>
parents:
24531
diff
changeset
|
35 | return; |
|
9f88e2d42845
Prevent the Buddy State Notification plugin from printing duplicate
Florian Quèze <florian@instantbird.org>
parents:
24531
diff
changeset
|
36 | |
| 15884 | 37 | who = purple_buddy_get_alias(buddy); |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
38 | escaped = g_markup_escape_text(who, -1); |
| 5267 | 39 | |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
40 | g_snprintf(buf, sizeof(buf), message, escaped); |
|
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
41 | g_free(escaped); |
| 5267 | 42 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
43 | purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, buf, |
|
34628
014583658b51
Refactored libpurple/plugins to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34626
diff
changeset
|
44 | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ACTIVE_ONLY | PURPLE_MESSAGE_NO_LINKIFY, |
|
014583658b51
Refactored libpurple/plugins to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34626
diff
changeset
|
45 | time(NULL)); |
| 5267 | 46 | } |
| 47 | ||
| 48 | static void | |
| 15884 | 49 | buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status, |
| 50 | PurpleStatus *status, void *data) | |
| 5267 | 51 | { |
| 11935 | 52 | gboolean available, old_available; |
| 53 | ||
|
22880
e44c97dec833
Do not show an erroneous message when the 'now listening' song for a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
54 | if (!purple_status_is_exclusive(status) || |
|
e44c97dec833
Do not show an erroneous message when the 'now listening' song for a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
55 | !purple_status_is_exclusive(old_status)) |
|
e44c97dec833
Do not show an erroneous message when the 'now listening' song for a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
56 | return; |
|
e44c97dec833
Do not show an erroneous message when the 'now listening' song for a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
57 | |
| 15884 | 58 | available = purple_status_is_available(status); |
| 59 | old_available = purple_status_is_available(old_status); | |
| 11935 | 60 | |
| 16481 | 61 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_away")) { |
| 11935 | 62 | if (available && !old_available) |
| 63 | write_status(buddy, _("%s is no longer away.")); | |
| 64 | else if (!available && old_available) | |
| 65 | write_status(buddy, _("%s has gone away.")); | |
| 66 | } | |
| 5267 | 67 | } |
| 68 | ||
| 69 | static void | |
| 15884 | 70 | buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle, |
| 11935 | 71 | void *data) |
| 5267 | 72 | { |
| 16481 | 73 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { |
|
25833
9cdd935e0aba
In the state notify plugin, don't print out a status change if we get an update
Marcus Lundblad <malu@pidgin.im>
parents:
24761
diff
changeset
|
74 | if (idle && !old_idle) { |
| 11935 | 75 | write_status(buddy, _("%s has become idle.")); |
|
25833
9cdd935e0aba
In the state notify plugin, don't print out a status change if we get an update
Marcus Lundblad <malu@pidgin.im>
parents:
24761
diff
changeset
|
76 | } else if (!idle && old_idle) { |
| 11935 | 77 | write_status(buddy, _("%s is no longer idle.")); |
| 78 | } | |
| 79 | } | |
| 9583 | 80 | } |
| 81 | ||
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
82 | static void |
| 15884 | 83 | buddy_signon_cb(PurpleBuddy *buddy, void *data) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
84 | { |
| 16481 | 85 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
86 | write_status(buddy, _("%s has signed on.")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
87 | } |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
88 | |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
89 | static void |
| 15884 | 90 | buddy_signoff_cb(PurpleBuddy *buddy, void *data) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
91 | { |
| 16481 | 92 | if (purple_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
93 | write_status(buddy, _("%s has signed off.")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
94 | } |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
95 | |
| 15884 | 96 | static PurplePluginPrefFrame * |
| 97 | get_plugin_pref_frame(PurplePlugin *plugin) | |
| 9583 | 98 | { |
| 15884 | 99 | PurplePluginPrefFrame *frame; |
| 100 | PurplePluginPref *ppref; | |
| 9583 | 101 | |
| 15884 | 102 | frame = purple_plugin_pref_frame_new(); |
| 9583 | 103 | |
| 15884 | 104 | ppref = purple_plugin_pref_new_with_label(_("Notify When")); |
| 105 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9583 | 106 | |
| 16481 | 107 | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", _("Buddy Goes _Away")); |
| 15884 | 108 | purple_plugin_pref_frame_add(frame, ppref); |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
109 | |
| 16481 | 110 | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); |
| 15884 | 111 | purple_plugin_pref_frame_add(frame, ppref); |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
112 | |
| 16481 | 113 | ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_signon", _("Buddy _Signs On/Off")); |
| 15884 | 114 | purple_plugin_pref_frame_add(frame, ppref); |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
115 | |
| 9583 | 116 | return frame; |
| 5267 | 117 | } |
| 118 | ||
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
119 | static PurplePluginInfo * |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
120 | plugin_query(GError **error) |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
121 | { |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
122 | const gchar * const authors[] = { |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
123 | "Christian Hammond <chipx86@gnupdate.org>", |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
124 | NULL |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
125 | }; |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
126 | |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
127 | return purple_plugin_info_new( |
|
36934
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
128 | "id", STATENOTIFY_PLUGIN_ID, |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
129 | "name", N_("Buddy State Notification"), |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
130 | "version", DISPLAY_VERSION, |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
131 | "category", N_("Notification"), |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
132 | "summary", N_("Notifies in a conversation window when a " |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
133 | "buddy goes or returns from away or idle."), |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
134 | "description", N_("Notifies in a conversation window when a " |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
135 | "buddy goes or returns from away or idle."), |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
136 | "authors", authors, |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
137 | "website", PURPLE_WEBSITE, |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
138 | "abi-version", PURPLE_ABI_VERSION, |
|
e7268aeb3b89
Renamed plugin info callback properties to end with "-cb", and their respective symbols.
Ankit Vani <a@nevitus.org>
parents:
36929
diff
changeset
|
139 | "pref-frame-cb", get_plugin_pref_frame, |
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
140 | NULL |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
141 | ); |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
142 | } |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
143 | |
| 5267 | 144 | static gboolean |
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
145 | plugin_load(PurplePlugin *plugin, GError **error) |
| 5267 | 146 | { |
| 15884 | 147 | void *blist_handle = purple_blist_get_handle(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
148 | |
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
149 | purple_prefs_add_none("/plugins/core/statenotify"); |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
150 | purple_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
151 | purple_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
152 | purple_prefs_add_bool("/plugins/core/statenotify/notify_signon", TRUE); |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
153 | |
| 15884 | 154 | purple_signal_connect(blist_handle, "buddy-status-changed", plugin, |
| 155 | PURPLE_CALLBACK(buddy_status_changed_cb), NULL); | |
| 156 | purple_signal_connect(blist_handle, "buddy-idle-changed", plugin, | |
| 157 | PURPLE_CALLBACK(buddy_idle_changed_cb), NULL); | |
| 158 | purple_signal_connect(blist_handle, "buddy-signed-on", plugin, | |
| 159 | PURPLE_CALLBACK(buddy_signon_cb), NULL); | |
| 160 | purple_signal_connect(blist_handle, "buddy-signed-off", plugin, | |
| 161 | PURPLE_CALLBACK(buddy_signoff_cb), NULL); | |
| 5267 | 162 | |
| 163 | return TRUE; | |
| 164 | } | |
| 165 | ||
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
166 | static gboolean |
|
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
167 | plugin_unload(PurplePlugin *plugin, GError **error) |
| 5267 | 168 | { |
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
169 | return TRUE; |
| 5267 | 170 | } |
| 171 | ||
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
172 | PURPLE_PLUGIN_INIT(statenotify, plugin_query, plugin_load, plugin_unload); |