1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
1 |
#include "internal.h" |
2 |
||
3 |
#include "account.h" |
|
4 |
#include "blist.h" |
|
5 |
#include "conversation.h" |
|
6 |
#include "debug.h" |
|
7 |
#include "signals.h" |
|
8 |
#include "status.h" |
|
9 |
#include "version.h" |
|
10 |
#include "privacy.h" |
|
11 |
||
12 |
#include "plugin.h" |
|
13 |
#include "pluginpref.h" |
|
14 |
#include "prefs.h" |
|
15 |
||
16 |
||
17 |
#define PLUGIN_ID "core-psychic"
|
|
18 |
#define PLUGIN_NAME N_("Psychic Mode")
|
|
19 |
#define PLUGIN_SUMMARY N_("Psychic mode for incoming conversation")
|
|
20 |
#define PLUGIN_DESC N_("Causes conversation windows to appear as other" \
|
|
21 |
" users begin to message you. This works for" \
|
|
22 |
" AIM, ICQ, XMPP, Sametime, and Yahoo!")
|
|
23 |
#define PLUGIN_AUTHOR "Christopher O'Brien <siege@preoccupied.net>"
|
|
1.1.1
by Sebastien Bacher
Import upstream version 2.0.2 |
24 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
25 |
|
26 |
#define PREFS_BASE "/plugins/core/psychic"
|
|
27 |
#define PREF_BUDDIES PREFS_BASE "/buddies_only"
|
|
28 |
#define PREF_NOTICE PREFS_BASE "/show_notice"
|
|
29 |
#define PREF_STATUS PREFS_BASE "/activate_online"
|
|
30 |
#define PREF_RAISE PREFS_BASE "/raise_conv"
|
|
31 |
||
32 |
||
33 |
static void |
|
34 |
buddy_typing_cb(PurpleAccount *acct, const char *name, void *data) { |
|
35 |
PurpleConversation *gconv; |
|
36 |
||
37 |
if(purple_prefs_get_bool(PREF_STATUS) && |
|
38 |
! purple_status_is_available(purple_account_get_active_status(acct))) { |
|
39 |
purple_debug_info("psychic", "not available, doing nothing\n"); |
|
40 |
return; |
|
41 |
}
|
|
42 |
||
43 |
if(purple_prefs_get_bool(PREF_BUDDIES) && |
|
44 |
! purple_find_buddy(acct, name)) { |
|
45 |
purple_debug_info("psychic", "not in blist, doing nothing\n"); |
|
46 |
return; |
|
47 |
}
|
|
48 |
||
49 |
if(FALSE == purple_privacy_check(acct, name)) { |
|
50 |
purple_debug_info("psychic", "user %s is blocked\n", name); |
|
51 |
return; |
|
1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
52 |
}
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
53 |
|
54 |
gconv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, acct); |
|
55 |
if(! gconv) { |
|
56 |
purple_debug_info("psychic", "no previous conversation exists\n"); |
|
57 |
gconv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, name); |
|
58 |
||
59 |
if(purple_prefs_get_bool(PREF_RAISE)) { |
|
60 |
purple_conversation_present(gconv); |
|
61 |
}
|
|
62 |
||
63 |
if(purple_prefs_get_bool(PREF_NOTICE)) { |
|
64 |
||
65 |
/* This is a quote from Star Wars. You should probably not
|
|
66 |
translate it literally. If you can't find a fitting cultural
|
|
67 |
reference in your language, consider translating something
|
|
68 |
like this instead: "You feel a new message coming." */
|
|
69 |
purple_conversation_write(gconv, NULL, |
|
70 |
_("You feel a disturbance in the force..."), |
|
71 |
PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_ACTIVE_ONLY, |
|
72 |
time(NULL)); |
|
73 |
}
|
|
74 |
||
75 |
/* Necessary because we may be creating a new conversation window. */
|
|
76 |
purple_conv_im_set_typing_state(PURPLE_CONV_IM(gconv), PURPLE_TYPING); |
|
1.3.3
by Ari Pollak
Import upstream version 2.6.1 |
77 |
}
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
78 |
}
|
79 |
||
80 |
||
81 |
static PurplePluginPrefFrame * |
|
82 |
get_plugin_pref_frame(PurplePlugin *plugin) { |
|
83 |
||
84 |
PurplePluginPrefFrame *frame; |
|
85 |
PurplePluginPref *pref; |
|
86 |
||
87 |
frame = purple_plugin_pref_frame_new(); |
|
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
88 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
89 |
pref = purple_plugin_pref_new_with_name(PREF_BUDDIES); |
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
90 |
purple_plugin_pref_set_label(pref, _("Only enable for users on" |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
91 |
" the buddy list")); |
92 |
purple_plugin_pref_frame_add(frame, pref); |
|
93 |
||
94 |
pref = purple_plugin_pref_new_with_name(PREF_STATUS); |
|
95 |
purple_plugin_pref_set_label(pref, _("Disable when away")); |
|
96 |
purple_plugin_pref_frame_add(frame, pref); |
|
97 |
||
98 |
pref = purple_plugin_pref_new_with_name(PREF_NOTICE); |
|
99 |
purple_plugin_pref_set_label(pref, _("Display notification message in" |
|
100 |
" conversations")); |
|
101 |
purple_plugin_pref_frame_add(frame, pref); |
|
102 |
||
103 |
pref = purple_plugin_pref_new_with_name(PREF_RAISE); |
|
104 |
purple_plugin_pref_set_label(pref, _("Raise psychic conversations")); |
|
105 |
purple_plugin_pref_frame_add(frame, pref); |
|
106 |
||
107 |
return frame; |
|
108 |
}
|
|
109 |
||
110 |
||
111 |
static gboolean |
|
112 |
plugin_load(PurplePlugin *plugin) { |
|
113 |
||
114 |
void *convs_handle; |
|
115 |
convs_handle = purple_conversations_get_handle(); |
|
116 |
||
117 |
purple_signal_connect(convs_handle, "buddy-typing", plugin, |
|
118 |
PURPLE_CALLBACK(buddy_typing_cb), NULL); |
|
119 |
||
120 |
return TRUE; |
|
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
121 |
}
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
122 |
|
123 |
||
124 |
static PurplePluginUiInfo prefs_info = { |
|
125 |
get_plugin_pref_frame, |
|
126 |
0, /* page_num (Reserved) */ |
|
127 |
NULL, /* frame (Reserved) */ |
|
128 |
||
129 |
/* padding */
|
|
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
130 |
NULL, |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
131 |
NULL, |
132 |
NULL, |
|
133 |
NULL
|
|
134 |
};
|
|
135 |
||
136 |
||
137 |
static PurplePluginInfo info = { |
|
138 |
PURPLE_PLUGIN_MAGIC, |
|
139 |
PURPLE_MAJOR_VERSION, |
|
140 |
PURPLE_MINOR_VERSION, |
|
141 |
PURPLE_PLUGIN_STANDARD, /**< type */ |
|
142 |
NULL, /**< ui_requirement */ |
|
143 |
0, /**< flags */ |
|
144 |
NULL, /**< dependencies */ |
|
145 |
PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
146 |
||
147 |
PLUGIN_ID, /**< id */ |
|
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
148 |
PLUGIN_NAME, /**< name */ |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
149 |
DISPLAY_VERSION, /**< version */ |
150 |
PLUGIN_SUMMARY, /**< summary */ |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
151 |
PLUGIN_DESC, /**< description */ |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
152 |
PLUGIN_AUTHOR, /**< author */ |
153 |
PURPLE_WEBSITE, /**< homepage */ |
|
154 |
||
155 |
plugin_load, /**< load */ |
|
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
156 |
NULL, /**< unload */ |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
157 |
NULL, /**< destroy */ |
158 |
||
159 |
NULL, /**< ui_info */ |
|
1.3.18
by Ari Pollak
Import upstream version 2.7.11 |
160 |
NULL, /**< extra_info */ |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
161 |
&prefs_info, /**< prefs_info */ |
162 |
NULL, /**< actions */ |
|
163 |
||
164 |
/* padding */
|
|
165 |
NULL, |
|
166 |
NULL, |
|
167 |
NULL, |
|
168 |
NULL
|
|
169 |
};
|
|
170 |
||
171 |
||
172 |
static void |
|
173 |
init_plugin(PurplePlugin *plugin) { |
|
174 |
purple_prefs_add_none(PREFS_BASE); |
|
175 |
purple_prefs_add_bool(PREF_BUDDIES, FALSE); |
|
176 |
purple_prefs_add_bool(PREF_NOTICE, TRUE); |
|
177 |
purple_prefs_add_bool(PREF_STATUS, TRUE); |
|
178 |
}
|
|
179 |
||
180 |
||
181 |
PURPLE_INIT_PLUGIN(psychic, init_plugin, info) |
|
182 |
||
183 |