Mercurial > pidgin.yaz
annotate plugins/psychic.c @ 13050:fb607b2d4ff2
[gaim-migrate @ 15411]
Some fixes and documentation. I'm not sure if we were escaping everything
correctly after my changes last night, but it's definitely working
correctly now.
Selecting a saved status with a message will not show the imhtml. Instead
it'll show the title and the first part of the message directly on the
status box. That seemed like a good idea to me.
Selecting one of the 4 basic transient statuses (available, away, invisible,
offline) with no substatuses will make the status box show the primtive
and open the imhtml.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 27 Jan 2006 06:40:38 +0000 |
parents | fd734d1fb2f4 |
children | c1a75785c8f2 |
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" \ | |
25 " users begin to message you") | |
26 #define PLUGIN_AUTHOR "Christopher O'Brien <siege@preoccupied.net>" | |
27 | |
28 | |
29 #define PREFS_BASE "/plugins/core/psychic" | |
30 #define PREF_BUDDIES PREFS_BASE "/buddies_only" | |
31 #define PREF_NOTICE PREFS_BASE "/show_notice" | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
32 #define PREF_STATUS PREFS_BASE "/activate_online" |
12859 | 33 |
34 | |
35 static void | |
36 buddy_typing_cb(GaimAccount *acct, const char *name, void *data) { | |
37 GaimConversation *gconv; | |
38 | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
39 if(gaim_prefs_get_bool(PREF_STATUS) && |
12925
fd734d1fb2f4
[gaim-migrate @ 15278]
Christopher O'Brien <siege@pidgin.im>
parents:
12924
diff
changeset
|
40 ! 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
|
41 DEBUG_INFO("not available, doing nothing\n"); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
42 return; |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
43 } |
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 if(gaim_prefs_get_bool(PREF_BUDDIES) && |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
46 ! gaim_find_buddy(acct, name)) { |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
47 DEBUG_INFO("not in blist, doing nothing\n"); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
48 return; |
12859 | 49 } |
50 | |
51 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, acct); | |
52 if(! gconv) { | |
53 DEBUG_INFO("no previous conversation exists\n"); | |
54 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, name); | |
55 gaim_conversation_present(gconv); | |
56 | |
57 if(gaim_prefs_get_bool(PREF_NOTICE)) { | |
12861
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
58 gaim_conversation_write(gconv, NULL, |
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
59 _("You feel a disturbance in the force..."), |
12895
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
60 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, |
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
61 time(NULL)); |
12859 | 62 } |
63 } | |
64 } | |
65 | |
66 | |
67 static GaimPluginPrefFrame * | |
68 get_plugin_pref_frame(GaimPlugin *plugin) { | |
69 | |
70 GaimPluginPrefFrame *frame; | |
71 GaimPluginPref *pref; | |
72 | |
73 frame = gaim_plugin_pref_frame_new(); | |
74 | |
75 pref = gaim_plugin_pref_new_with_name(PREF_BUDDIES); | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
76 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
|
77 " the buddy list")); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
78 gaim_plugin_pref_frame_add(frame, pref); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
79 |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
80 pref = gaim_plugin_pref_new_with_name(PREF_STATUS); |
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
81 gaim_plugin_pref_set_label(pref, _("Disable when away")); |
12859 | 82 gaim_plugin_pref_frame_add(frame, pref); |
83 | |
84 pref = gaim_plugin_pref_new_with_name(PREF_NOTICE); | |
85 gaim_plugin_pref_set_label(pref, _("Display notification message in" | |
86 " conversations")); | |
87 gaim_plugin_pref_frame_add(frame, pref); | |
88 | |
89 return frame; | |
90 } | |
91 | |
92 | |
93 static gboolean | |
94 plugin_load(GaimPlugin *plugin) { | |
95 | |
96 void *convs_handle; | |
97 convs_handle = gaim_conversations_get_handle(); | |
98 | |
99 gaim_signal_connect(convs_handle, "buddy-typing", plugin, | |
100 GAIM_CALLBACK(buddy_typing_cb), NULL); | |
101 | |
102 return TRUE; | |
103 } | |
104 | |
105 | |
106 static GaimPluginUiInfo prefs_info = { | |
107 get_plugin_pref_frame, | |
108 0, /* page_num (Reserved) */ | |
109 NULL, /* frame (Reserved) */ | |
110 }; | |
111 | |
112 | |
113 static GaimPluginInfo info = { | |
114 GAIM_PLUGIN_MAGIC, | |
115 GAIM_MAJOR_VERSION, | |
116 GAIM_MINOR_VERSION, | |
117 GAIM_PLUGIN_STANDARD, /**< type */ | |
118 NULL, /**< ui_requirement */ | |
119 0, /**< flags */ | |
120 NULL, /**< dependencies */ | |
121 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
122 | |
123 PLUGIN_ID, /**< id */ | |
124 PLUGIN_NAME, /**< name */ | |
125 VERSION, /**< version */ | |
126 PLUGIN_SUMMARY, /**< summary */ | |
127 PLUGIN_DESC, /**< description */ | |
128 PLUGIN_AUTHOR, /**< author */ | |
129 GAIM_WEBSITE, /**< homepage */ | |
130 | |
131 plugin_load, /**< load */ | |
132 NULL, /**< unload */ | |
133 NULL, /**< destroy */ | |
134 | |
135 NULL, /**< ui_info */ | |
136 NULL, /**< extra_info */ | |
137 &prefs_info, /**< prefs_info */ | |
138 NULL, /**< actions */ | |
139 }; | |
140 | |
141 | |
142 static void | |
143 init_plugin(GaimPlugin *plugin) { | |
144 gaim_prefs_add_none(PREFS_BASE); | |
145 gaim_prefs_add_bool(PREF_BUDDIES, FALSE); | |
146 gaim_prefs_add_bool(PREF_NOTICE, TRUE); | |
12924
e841e23a334c
[gaim-migrate @ 15277]
Christopher O'Brien <siege@pidgin.im>
parents:
12895
diff
changeset
|
147 gaim_prefs_add_bool(PREF_STATUS, TRUE); |
12859 | 148 } |
149 | |
150 | |
151 GAIM_INIT_PLUGIN(psychic, init_plugin, info) |