Sun, 23 Jun 2013 15:23:44 +0530
Global replace - renamed functions and types according to GObject-based PurpleConversation API
| 12859 | 1 | |
| 2 | ||
| 3 | #include "internal.h" | |
| 4 | ||
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
5 | #include "account.h" |
| 12859 | 6 | #include "blist.h" |
| 7 | #include "conversation.h" | |
| 8 | #include "debug.h" | |
| 9 | #include "signals.h" | |
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
10 | #include "status.h" |
| 12859 | 11 | #include "version.h" |
| 12 | ||
| 13 | #include "plugin.h" | |
| 14 | #include "pluginpref.h" | |
| 15 | #include "prefs.h" | |
| 16 | ||
| 17 | ||
| 18 | #define PLUGIN_ID "core-psychic" | |
| 19 | #define PLUGIN_NAME N_("Psychic Mode") | |
| 20 | #define PLUGIN_SUMMARY N_("Psychic mode for incoming conversation") | |
| 21 | #define PLUGIN_DESC N_("Causes conversation windows to appear as other" \ | |
|
13248
fffad481d1ad
[gaim-migrate @ 15613]
Mark Doliner <markdoliner@pidgin.im>
parents:
12925
diff
changeset
|
22 | " users begin to message you. This works for" \ |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16799
diff
changeset
|
23 | " AIM, ICQ, XMPP, Sametime, and Yahoo!") |
| 12859 | 24 | #define PLUGIN_AUTHOR "Christopher O'Brien <siege@preoccupied.net>" |
| 25 | ||
| 26 | ||
| 16481 | 27 | #define PREFS_BASE "/plugins/core/psychic" |
| 12859 | 28 | #define PREF_BUDDIES PREFS_BASE "/buddies_only" |
| 29 | #define PREF_NOTICE PREFS_BASE "/show_notice" | |
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
30 | #define PREF_STATUS PREFS_BASE "/activate_online" |
| 14977 | 31 | #define PREF_RAISE PREFS_BASE "/raise_conv" |
| 12859 | 32 | |
| 33 | ||
| 34 | static void | |
| 15884 | 35 | buddy_typing_cb(PurpleAccount *acct, const char *name, void *data) { |
| 36 | PurpleConversation *gconv; | |
| 12859 | 37 | |
| 15884 | 38 | if(purple_prefs_get_bool(PREF_STATUS) && |
| 39 | ! purple_status_is_available(purple_account_get_active_status(acct))) { | |
| 40 | purple_debug_info("psychic", "not available, doing nothing\n"); | |
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
41 | return; |
|
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
42 | } |
|
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
43 | |
| 15884 | 44 | if(purple_prefs_get_bool(PREF_BUDDIES) && |
| 45 | ! purple_find_buddy(acct, name)) { | |
| 46 | purple_debug_info("psychic", "not in blist, doing nothing\n"); | |
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
47 | return; |
| 12859 | 48 | } |
| 49 | ||
|
34575
e08f2d070470
Refactored libpurple/plugins according to changes to PurpleAccount
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
50 | if(FALSE == purple_account_privacy_check(acct, name)) { |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16961
diff
changeset
|
51 | purple_debug_info("psychic", "user %s is blocked\n", name); |
|
16733
97cc23596b8a
Cause Psychic Mode to obey privacy settings when apprpriate. Thanks
Ethan Blanton <elb@pidgin.im>
parents:
16481
diff
changeset
|
52 | return; |
|
97cc23596b8a
Cause Psychic Mode to obey privacy settings when apprpriate. Thanks
Ethan Blanton <elb@pidgin.im>
parents:
16481
diff
changeset
|
53 | } |
|
97cc23596b8a
Cause Psychic Mode to obey privacy settings when apprpriate. Thanks
Ethan Blanton <elb@pidgin.im>
parents:
16481
diff
changeset
|
54 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34575
diff
changeset
|
55 | gconv = purple_conversations_find_with_account(PURPLE_CONV_TYPE_IM, name, acct); |
| 12859 | 56 | if(! gconv) { |
| 15884 | 57 | purple_debug_info("psychic", "no previous conversation exists\n"); |
| 58 | gconv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, name); | |
| 14977 | 59 | |
| 15884 | 60 | if(purple_prefs_get_bool(PREF_RAISE)) { |
| 61 | purple_conversation_present(gconv); | |
| 14977 | 62 | } |
| 12859 | 63 | |
| 15884 | 64 | if(purple_prefs_get_bool(PREF_NOTICE)) { |
| 14977 | 65 | |
| 66 | /* This is a quote from Star Wars. You should probably not | |
| 67 | translate it literally. If you can't find a fitting cultural | |
| 68 | reference in your language, consider translating something | |
| 69 | like this instead: "You feel a new message coming." */ | |
| 15884 | 70 | purple_conversation_write(gconv, NULL, |
|
12861
60c0456f1fff
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
71 | _("You feel a disturbance in the force..."), |
| 15884 | 72 | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_ACTIVE_ONLY, |
|
12895
e075f4a4bcb3
[gaim-migrate @ 15248]
Richard Laager <rlaager@pidgin.im>
parents:
12861
diff
changeset
|
73 | time(NULL)); |
| 12859 | 74 | } |
|
13248
fffad481d1ad
[gaim-migrate @ 15613]
Mark Doliner <markdoliner@pidgin.im>
parents:
12925
diff
changeset
|
75 | |
|
27250
47fc0f87ce94
Consistently emit conversation-updated for typing state changes.
Florian Quèze <florian@instantbird.org>
parents:
20288
diff
changeset
|
76 | /* Necessary because we may be creating a new conversation window. */ |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34575
diff
changeset
|
77 | purple_im_conversation_set_typing_state(PURPLE_CONV_IM(gconv), PURPLE_IM_CONVERSATION_TYPING); |
| 12859 | 78 | } |
| 79 | } | |
| 80 | ||
| 81 | ||
| 15884 | 82 | static PurplePluginPrefFrame * |
| 83 | get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 12859 | 84 | |
| 15884 | 85 | PurplePluginPrefFrame *frame; |
| 86 | PurplePluginPref *pref; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
87 | |
| 15884 | 88 | frame = purple_plugin_pref_frame_new(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
89 | |
| 15884 | 90 | pref = purple_plugin_pref_new_with_name(PREF_BUDDIES); |
| 91 | purple_plugin_pref_set_label(pref, _("Only enable for users on" | |
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
92 | " the buddy list")); |
| 15884 | 93 | purple_plugin_pref_frame_add(frame, pref); |
|
12924
ed6ed1510bb1
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
94 | |
| 15884 | 95 | pref = purple_plugin_pref_new_with_name(PREF_STATUS); |
| 96 | purple_plugin_pref_set_label(pref, _("Disable when away")); | |
| 97 | purple_plugin_pref_frame_add(frame, pref); | |
| 12859 | 98 | |
| 15884 | 99 | pref = purple_plugin_pref_new_with_name(PREF_NOTICE); |
| 100 | purple_plugin_pref_set_label(pref, _("Display notification message in" | |
| 12859 | 101 | " conversations")); |
| 15884 | 102 | purple_plugin_pref_frame_add(frame, pref); |
| 12859 | 103 | |
| 15884 | 104 | pref = purple_plugin_pref_new_with_name(PREF_RAISE); |
| 105 | purple_plugin_pref_set_label(pref, _("Raise psychic conversations")); | |
| 106 | purple_plugin_pref_frame_add(frame, pref); | |
| 14977 | 107 | |
| 12859 | 108 | return frame; |
| 109 | } | |
| 110 | ||
| 111 | ||
| 112 | static gboolean | |
| 15884 | 113 | plugin_load(PurplePlugin *plugin) { |
| 12859 | 114 | |
| 115 | void *convs_handle; | |
| 15884 | 116 | convs_handle = purple_conversations_get_handle(); |
| 12859 | 117 | |
| 15884 | 118 | purple_signal_connect(convs_handle, "buddy-typing", plugin, |
| 119 | PURPLE_CALLBACK(buddy_typing_cb), NULL); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
120 | |
| 12859 | 121 | return TRUE; |
| 122 | } | |
| 123 | ||
| 124 | ||
| 15884 | 125 | static PurplePluginUiInfo prefs_info = { |
| 12859 | 126 | get_plugin_pref_frame, |
| 127 | 0, /* page_num (Reserved) */ | |
| 128 | NULL, /* frame (Reserved) */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
129 | |
|
16745
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
130 | /* padding */ |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
131 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
132 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
133 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
134 | NULL |
| 12859 | 135 | }; |
| 136 | ||
| 137 | ||
| 15884 | 138 | static PurplePluginInfo info = { |
| 139 | PURPLE_PLUGIN_MAGIC, | |
| 140 | PURPLE_MAJOR_VERSION, | |
| 141 | PURPLE_MINOR_VERSION, | |
| 142 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 12859 | 143 | NULL, /**< ui_requirement */ |
| 144 | 0, /**< flags */ | |
| 145 | NULL, /**< dependencies */ | |
| 15884 | 146 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
147 | |
| 12859 | 148 | PLUGIN_ID, /**< id */ |
| 149 | PLUGIN_NAME, /**< name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
150 | DISPLAY_VERSION, /**< version */ |
| 12859 | 151 | PLUGIN_SUMMARY, /**< summary */ |
| 152 | PLUGIN_DESC, /**< description */ | |
| 153 | PLUGIN_AUTHOR, /**< author */ | |
| 15884 | 154 | PURPLE_WEBSITE, /**< homepage */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
155 | |
| 12859 | 156 | plugin_load, /**< load */ |
| 157 | NULL, /**< unload */ | |
| 158 | NULL, /**< destroy */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
27250
diff
changeset
|
159 | |
| 12859 | 160 | NULL, /**< ui_info */ |
| 161 | NULL, /**< extra_info */ | |
| 162 | &prefs_info, /**< prefs_info */ | |
| 163 | NULL, /**< actions */ | |
|
16745
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
164 | |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
165 | /* padding */ |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
166 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
167 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
168 | NULL, |
|
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
169 | NULL |
| 12859 | 170 | }; |
| 171 | ||
| 172 | ||
| 173 | static void | |
| 15884 | 174 | init_plugin(PurplePlugin *plugin) { |
| 175 | purple_prefs_add_none(PREFS_BASE); | |
| 176 | purple_prefs_add_bool(PREF_BUDDIES, FALSE); | |
| 177 | purple_prefs_add_bool(PREF_NOTICE, TRUE); | |
| 178 | purple_prefs_add_bool(PREF_STATUS, TRUE); | |
| 12859 | 179 | } |
| 180 | ||
| 181 | ||
| 15884 | 182 | PURPLE_INIT_PLUGIN(psychic, init_plugin, info) |