Mercurial > pidgin.yaz
annotate plugins/psychic.c @ 13304:5e9f17b439cd
[gaim-migrate @ 15670]
2 updates
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 17 Feb 2006 00:29:36 +0000 |
parents | c1a75785c8f2 |
children | 465c368366f8 |
rev | line source |
---|---|
12859 | 1 |
2 | |
3 #include "internal.h" | |
4 | |
12924
e841e23a334c
[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
e841e23a334c
[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 DEBUG_INFO(a...) gaim_debug_info("psychic", a) | |
19 | |
20 | |
21 #define PLUGIN_ID "core-psychic" | |
22 #define PLUGIN_NAME N_("Psychic Mode") | |
23 #define PLUGIN_SUMMARY N_("Psychic mode for incoming conversation") | |
24 #define PLUGIN_DESC N_("Causes conversation windows to appear as other" \ | |
13247 | 25 " users begin to message you. This works for" \ |
26 " AIM, ICQ, Jabber, Sametime, and Yahoo!") | |
12859 | 27 #define PLUGIN_AUTHOR "Christopher O'Brien <siege@preoccupied.net>" |
28 | |
29 | |
30 #define PREFS_BASE "/plugins/core/psychic" | |
31 #define PREF_BUDDIES PREFS_BASE "/buddies_only" | |
32 #define PREF_NOTICE PREFS_BASE "/show_notice" | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
33 #define PREF_STATUS PREFS_BASE "/activate_online" |
12859 | 34 |
35 | |
36 static void | |
37 buddy_typing_cb(GaimAccount *acct, const char *name, void *data) { | |
38 GaimConversation *gconv; | |
39 | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
40 if(gaim_prefs_get_bool(PREF_STATUS) && |
12925
fd734d1fb2f4
[gaim-migrate @ 15278]
Christopher O'Brien <siege@pidgin.im>
parents:
12924
diff
changeset
|
41 ! gaim_status_is_available(gaim_account_get_active_status(acct))) { |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
42 DEBUG_INFO("not available, doing nothing\n"); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
43 return; |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
44 } |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
45 |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
46 if(gaim_prefs_get_bool(PREF_BUDDIES) && |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
47 ! gaim_find_buddy(acct, name)) { |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
48 DEBUG_INFO("not in blist, doing nothing\n"); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
49 return; |
12859 | 50 } |
51 | |
52 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, acct); | |
53 if(! gconv) { | |
54 DEBUG_INFO("no previous conversation exists\n"); | |
55 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, name); | |
56 gaim_conversation_present(gconv); | |
57 | |
58 if(gaim_prefs_get_bool(PREF_NOTICE)) { | |
12861
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
59 gaim_conversation_write(gconv, NULL, |
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
60 _("You feel a disturbance in the force..."), |
12895
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
61 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, |
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
62 time(NULL)); |
12859 | 63 } |
13247 | 64 |
65 gaim_conv_im_set_typing_state(GAIM_CONV_IM(gconv), GAIM_TYPING); | |
12859 | 66 } |
67 } | |
68 | |
69 | |
70 static GaimPluginPrefFrame * | |
71 get_plugin_pref_frame(GaimPlugin *plugin) { | |
72 | |
73 GaimPluginPrefFrame *frame; | |
74 GaimPluginPref *pref; | |
75 | |
76 frame = gaim_plugin_pref_frame_new(); | |
77 | |
78 pref = gaim_plugin_pref_new_with_name(PREF_BUDDIES); | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
79 gaim_plugin_pref_set_label(pref, _("Only enable for users on" |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
80 " the buddy list")); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
81 gaim_plugin_pref_frame_add(frame, pref); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
82 |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
83 pref = gaim_plugin_pref_new_with_name(PREF_STATUS); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
84 gaim_plugin_pref_set_label(pref, _("Disable when away")); |
12859 | 85 gaim_plugin_pref_frame_add(frame, pref); |
86 | |
87 pref = gaim_plugin_pref_new_with_name(PREF_NOTICE); | |
88 gaim_plugin_pref_set_label(pref, _("Display notification message in" | |
89 " conversations")); | |
90 gaim_plugin_pref_frame_add(frame, pref); | |
91 | |
92 return frame; | |
93 } | |
94 | |
95 | |
96 static gboolean | |
97 plugin_load(GaimPlugin *plugin) { | |
98 | |
99 void *convs_handle; | |
100 convs_handle = gaim_conversations_get_handle(); | |
101 | |
102 gaim_signal_connect(convs_handle, "buddy-typing", plugin, | |
103 GAIM_CALLBACK(buddy_typing_cb), NULL); | |
104 | |
105 return TRUE; | |
106 } | |
107 | |
108 | |
109 static GaimPluginUiInfo prefs_info = { | |
110 get_plugin_pref_frame, | |
111 0, /* page_num (Reserved) */ | |
112 NULL, /* frame (Reserved) */ | |
113 }; | |
114 | |
115 | |
116 static GaimPluginInfo info = { | |
117 GAIM_PLUGIN_MAGIC, | |
118 GAIM_MAJOR_VERSION, | |
119 GAIM_MINOR_VERSION, | |
120 GAIM_PLUGIN_STANDARD, /**< type */ | |
121 NULL, /**< ui_requirement */ | |
122 0, /**< flags */ | |
123 NULL, /**< dependencies */ | |
124 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
125 | |
126 PLUGIN_ID, /**< id */ | |
127 PLUGIN_NAME, /**< name */ | |
128 VERSION, /**< version */ | |
129 PLUGIN_SUMMARY, /**< summary */ | |
130 PLUGIN_DESC, /**< description */ | |
131 PLUGIN_AUTHOR, /**< author */ | |
132 GAIM_WEBSITE, /**< homepage */ | |
133 | |
134 plugin_load, /**< load */ | |
135 NULL, /**< unload */ | |
136 NULL, /**< destroy */ | |
137 | |
138 NULL, /**< ui_info */ | |
139 NULL, /**< extra_info */ | |
140 &prefs_info, /**< prefs_info */ | |
141 NULL, /**< actions */ | |
142 }; | |
143 | |
144 | |
145 static void | |
146 init_plugin(GaimPlugin *plugin) { | |
147 gaim_prefs_add_none(PREFS_BASE); | |
148 gaim_prefs_add_bool(PREF_BUDDIES, FALSE); | |
149 gaim_prefs_add_bool(PREF_NOTICE, TRUE); | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
150 gaim_prefs_add_bool(PREF_STATUS, TRUE); |
12859 | 151 } |
152 | |
153 | |
154 GAIM_INIT_PLUGIN(psychic, init_plugin, info) |