Mercurial > pidgin
annotate plugins/psychic.c @ 14130:544e7f57836c
[gaim-migrate @ 16769]
I'm not really sure why I removed gettext
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 15 Aug 2006 08:59:11 +0000 |
parents | 85267a333422 |
children |
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 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" \ | |
13247 | 22 " users begin to message you. This works for" \ |
23 " AIM, ICQ, Jabber, Sametime, and Yahoo!") | |
12859 | 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" | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
30 #define PREF_STATUS PREFS_BASE "/activate_online" |
12859 | 31 |
32 | |
33 static void | |
34 buddy_typing_cb(GaimAccount *acct, const char *name, void *data) { | |
35 GaimConversation *gconv; | |
36 | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
37 if(gaim_prefs_get_bool(PREF_STATUS) && |
12925
fd734d1fb2f4
[gaim-migrate @ 15278]
Christopher O'Brien <siege@pidgin.im>
parents:
12924
diff
changeset
|
38 ! gaim_status_is_available(gaim_account_get_active_status(acct))) { |
13683 | 39 gaim_debug_info("psychic", "not available, doing nothing\n"); |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
40 return; |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
41 } |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
42 |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
43 if(gaim_prefs_get_bool(PREF_BUDDIES) && |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
44 ! gaim_find_buddy(acct, name)) { |
13683 | 45 gaim_debug_info("psychic", "not in blist, doing nothing\n"); |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
46 return; |
12859 | 47 } |
48 | |
49 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, acct); | |
50 if(! gconv) { | |
13683 | 51 gaim_debug_info("psychic", "no previous conversation exists\n"); |
12859 | 52 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, name); |
53 gaim_conversation_present(gconv); | |
54 | |
55 if(gaim_prefs_get_bool(PREF_NOTICE)) { | |
12861
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
56 gaim_conversation_write(gconv, NULL, |
13700
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13683
diff
changeset
|
57 /* This is a quote from Star Wars. You should |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13683
diff
changeset
|
58 probably not translate it literally. If |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13683
diff
changeset
|
59 you can't find a fitting cultural reference |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13683
diff
changeset
|
60 in your language, consider translating |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13683
diff
changeset
|
61 something like this instead: |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13683
diff
changeset
|
62 "You feel a new message coming." */ |
12861
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
63 _("You feel a disturbance in the force..."), |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13247
diff
changeset
|
64 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG | GAIM_MESSAGE_ACTIVE_ONLY, |
12895
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
65 time(NULL)); |
12859 | 66 } |
13247 | 67 |
68 gaim_conv_im_set_typing_state(GAIM_CONV_IM(gconv), GAIM_TYPING); | |
12859 | 69 } |
70 } | |
71 | |
72 | |
73 static GaimPluginPrefFrame * | |
74 get_plugin_pref_frame(GaimPlugin *plugin) { | |
75 | |
76 GaimPluginPrefFrame *frame; | |
77 GaimPluginPref *pref; | |
78 | |
79 frame = gaim_plugin_pref_frame_new(); | |
80 | |
81 pref = gaim_plugin_pref_new_with_name(PREF_BUDDIES); | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
82 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
|
83 " the buddy list")); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
84 gaim_plugin_pref_frame_add(frame, pref); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
85 |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
86 pref = gaim_plugin_pref_new_with_name(PREF_STATUS); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
87 gaim_plugin_pref_set_label(pref, _("Disable when away")); |
12859 | 88 gaim_plugin_pref_frame_add(frame, pref); |
89 | |
90 pref = gaim_plugin_pref_new_with_name(PREF_NOTICE); | |
91 gaim_plugin_pref_set_label(pref, _("Display notification message in" | |
92 " conversations")); | |
93 gaim_plugin_pref_frame_add(frame, pref); | |
94 | |
95 return frame; | |
96 } | |
97 | |
98 | |
99 static gboolean | |
100 plugin_load(GaimPlugin *plugin) { | |
101 | |
102 void *convs_handle; | |
103 convs_handle = gaim_conversations_get_handle(); | |
104 | |
105 gaim_signal_connect(convs_handle, "buddy-typing", plugin, | |
106 GAIM_CALLBACK(buddy_typing_cb), NULL); | |
107 | |
108 return TRUE; | |
109 } | |
110 | |
111 | |
112 static GaimPluginUiInfo prefs_info = { | |
113 get_plugin_pref_frame, | |
114 0, /* page_num (Reserved) */ | |
115 NULL, /* frame (Reserved) */ | |
116 }; | |
117 | |
118 | |
119 static GaimPluginInfo info = { | |
120 GAIM_PLUGIN_MAGIC, | |
121 GAIM_MAJOR_VERSION, | |
122 GAIM_MINOR_VERSION, | |
123 GAIM_PLUGIN_STANDARD, /**< type */ | |
124 NULL, /**< ui_requirement */ | |
125 0, /**< flags */ | |
126 NULL, /**< dependencies */ | |
127 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
128 | |
129 PLUGIN_ID, /**< id */ | |
130 PLUGIN_NAME, /**< name */ | |
131 VERSION, /**< version */ | |
132 PLUGIN_SUMMARY, /**< summary */ | |
133 PLUGIN_DESC, /**< description */ | |
134 PLUGIN_AUTHOR, /**< author */ | |
135 GAIM_WEBSITE, /**< homepage */ | |
136 | |
137 plugin_load, /**< load */ | |
138 NULL, /**< unload */ | |
139 NULL, /**< destroy */ | |
140 | |
141 NULL, /**< ui_info */ | |
142 NULL, /**< extra_info */ | |
143 &prefs_info, /**< prefs_info */ | |
144 NULL, /**< actions */ | |
145 }; | |
146 | |
147 | |
148 static void | |
149 init_plugin(GaimPlugin *plugin) { | |
150 gaim_prefs_add_none(PREFS_BASE); | |
151 gaim_prefs_add_bool(PREF_BUDDIES, FALSE); | |
152 gaim_prefs_add_bool(PREF_NOTICE, TRUE); | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
153 gaim_prefs_add_bool(PREF_STATUS, TRUE); |
12859 | 154 } |
155 | |
156 | |
157 GAIM_INIT_PLUGIN(psychic, init_plugin, info) |