Mercurial > pidgin
annotate libgaim/plugins/psychic.c @ 14956:0b98802a97cf
[gaim-migrate @ 17735]
(09:35:51) Alver: http://studwww.ugent.be/~lvalboom/zephyr.patch
(09:36:03) LSchiere2: how many do you have?
(09:36:14) Alver: That's all so far
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 10 Nov 2006 14:38:08 +0000 |
parents | ad7fa8b56e3e |
children |
rev | line source |
---|---|
14192 | 1 |
2 | |
3 #include "internal.h" | |
4 | |
5 #include "account.h" | |
6 #include "blist.h" | |
7 #include "conversation.h" | |
8 #include "debug.h" | |
9 #include "signals.h" | |
10 #include "status.h" | |
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" \ | |
22 " users begin to message you. This works for" \ | |
23 " AIM, ICQ, Jabber, Sametime, and Yahoo!") | |
24 #define PLUGIN_AUTHOR "Christopher O'Brien <siege@preoccupied.net>" | |
25 | |
26 | |
27 #define PREFS_BASE "/plugins/core/psychic" | |
28 #define PREF_BUDDIES PREFS_BASE "/buddies_only" | |
29 #define PREF_NOTICE PREFS_BASE "/show_notice" | |
30 #define PREF_STATUS PREFS_BASE "/activate_online" | |
14915
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
31 #define PREF_RAISE PREFS_BASE "/raise_conv" |
14192 | 32 |
33 | |
34 static void | |
35 buddy_typing_cb(GaimAccount *acct, const char *name, void *data) { | |
36 GaimConversation *gconv; | |
37 | |
38 if(gaim_prefs_get_bool(PREF_STATUS) && | |
39 ! gaim_status_is_available(gaim_account_get_active_status(acct))) { | |
40 gaim_debug_info("psychic", "not available, doing nothing\n"); | |
41 return; | |
42 } | |
43 | |
44 if(gaim_prefs_get_bool(PREF_BUDDIES) && | |
45 ! gaim_find_buddy(acct, name)) { | |
46 gaim_debug_info("psychic", "not in blist, doing nothing\n"); | |
47 return; | |
48 } | |
49 | |
50 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, acct); | |
51 if(! gconv) { | |
52 gaim_debug_info("psychic", "no previous conversation exists\n"); | |
53 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, name); | |
14915
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
54 |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
55 if(gaim_prefs_get_bool(PREF_RAISE)) { |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
56 gaim_conversation_present(gconv); |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
57 } |
14192 | 58 |
59 if(gaim_prefs_get_bool(PREF_NOTICE)) { | |
14915
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
60 |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
61 /* This is a quote from Star Wars. You should probably not |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
62 translate it literally. If you can't find a fitting cultural |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
63 reference in your language, consider translating something |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
64 like this instead: "You feel a new message coming." */ |
14192 | 65 gaim_conversation_write(gconv, NULL, |
66 _("You feel a disturbance in the force..."), | |
67 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG | GAIM_MESSAGE_ACTIVE_ONLY, | |
68 time(NULL)); | |
69 } | |
70 | |
71 gaim_conv_im_set_typing_state(GAIM_CONV_IM(gconv), GAIM_TYPING); | |
72 } | |
73 } | |
74 | |
75 | |
76 static GaimPluginPrefFrame * | |
77 get_plugin_pref_frame(GaimPlugin *plugin) { | |
78 | |
79 GaimPluginPrefFrame *frame; | |
80 GaimPluginPref *pref; | |
81 | |
82 frame = gaim_plugin_pref_frame_new(); | |
83 | |
84 pref = gaim_plugin_pref_new_with_name(PREF_BUDDIES); | |
85 gaim_plugin_pref_set_label(pref, _("Only enable for users on" | |
86 " the buddy list")); | |
87 gaim_plugin_pref_frame_add(frame, pref); | |
88 | |
89 pref = gaim_plugin_pref_new_with_name(PREF_STATUS); | |
90 gaim_plugin_pref_set_label(pref, _("Disable when away")); | |
91 gaim_plugin_pref_frame_add(frame, pref); | |
92 | |
93 pref = gaim_plugin_pref_new_with_name(PREF_NOTICE); | |
94 gaim_plugin_pref_set_label(pref, _("Display notification message in" | |
95 " conversations")); | |
96 gaim_plugin_pref_frame_add(frame, pref); | |
97 | |
14915
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
98 pref = gaim_plugin_pref_new_with_name(PREF_RAISE); |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
99 gaim_plugin_pref_set_label(pref, _("Raise psychic conversations")); |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
100 gaim_plugin_pref_frame_add(frame, pref); |
ad7fa8b56e3e
[gaim-migrate @ 17687]
Christopher O'Brien <siege@pidgin.im>
parents:
14192
diff
changeset
|
101 |
14192 | 102 return frame; |
103 } | |
104 | |
105 | |
106 static gboolean | |
107 plugin_load(GaimPlugin *plugin) { | |
108 | |
109 void *convs_handle; | |
110 convs_handle = gaim_conversations_get_handle(); | |
111 | |
112 gaim_signal_connect(convs_handle, "buddy-typing", plugin, | |
113 GAIM_CALLBACK(buddy_typing_cb), NULL); | |
114 | |
115 return TRUE; | |
116 } | |
117 | |
118 | |
119 static GaimPluginUiInfo prefs_info = { | |
120 get_plugin_pref_frame, | |
121 0, /* page_num (Reserved) */ | |
122 NULL, /* frame (Reserved) */ | |
123 }; | |
124 | |
125 | |
126 static GaimPluginInfo info = { | |
127 GAIM_PLUGIN_MAGIC, | |
128 GAIM_MAJOR_VERSION, | |
129 GAIM_MINOR_VERSION, | |
130 GAIM_PLUGIN_STANDARD, /**< type */ | |
131 NULL, /**< ui_requirement */ | |
132 0, /**< flags */ | |
133 NULL, /**< dependencies */ | |
134 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
135 | |
136 PLUGIN_ID, /**< id */ | |
137 PLUGIN_NAME, /**< name */ | |
138 VERSION, /**< version */ | |
139 PLUGIN_SUMMARY, /**< summary */ | |
140 PLUGIN_DESC, /**< description */ | |
141 PLUGIN_AUTHOR, /**< author */ | |
142 GAIM_WEBSITE, /**< homepage */ | |
143 | |
144 plugin_load, /**< load */ | |
145 NULL, /**< unload */ | |
146 NULL, /**< destroy */ | |
147 | |
148 NULL, /**< ui_info */ | |
149 NULL, /**< extra_info */ | |
150 &prefs_info, /**< prefs_info */ | |
151 NULL, /**< actions */ | |
152 }; | |
153 | |
154 | |
155 static void | |
156 init_plugin(GaimPlugin *plugin) { | |
157 gaim_prefs_add_none(PREFS_BASE); | |
158 gaim_prefs_add_bool(PREF_BUDDIES, FALSE); | |
159 gaim_prefs_add_bool(PREF_NOTICE, TRUE); | |
160 gaim_prefs_add_bool(PREF_STATUS, TRUE); | |
161 } | |
162 | |
163 | |
164 GAIM_INIT_PLUGIN(psychic, init_plugin, info) |