Mercurial > pidgin.yaz
annotate plugins/psychic.c @ 12902:3bf3f489b64b
[gaim-migrate @ 15255]
SF Patch #1406005 from Sadrul
"This is a fix for bug #1386557."
Basically, it moves the emission of "displayed-im-msg"/"displayed-chat-msg".
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 17 Jan 2006 01:54:27 +0000 |
parents | a355472257f4 |
children | e841e23a334c |
rev | line source |
---|---|
12859 | 1 |
2 | |
3 #include "internal.h" | |
4 | |
5 #include "blist.h" | |
6 #include "conversation.h" | |
7 #include "debug.h" | |
8 #include "signals.h" | |
9 #include "version.h" | |
10 | |
11 #include "plugin.h" | |
12 #include "pluginpref.h" | |
13 #include "prefs.h" | |
14 | |
15 | |
16 #define DEBUG_INFO(a...) gaim_debug_info("psychic", a) | |
17 | |
18 | |
19 #define PLUGIN_ID "core-psychic" | |
20 #define PLUGIN_NAME N_("Psychic Mode") | |
21 #define PLUGIN_SUMMARY N_("Psychic mode for incoming conversation") | |
22 #define PLUGIN_DESC N_("Causes conversation windows to appear as other" \ | |
23 " users begin to message you") | |
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 | |
31 | |
32 static void | |
33 buddy_typing_cb(GaimAccount *acct, const char *name, void *data) { | |
34 GaimConversation *gconv; | |
35 | |
36 if(gaim_prefs_get_bool(PREF_BUDDIES)) { | |
37 if(! gaim_find_buddy(acct, name)) { | |
38 DEBUG_INFO("not in blist, doing nothing\n"); | |
39 return; | |
40 } | |
41 } | |
42 | |
43 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, acct); | |
44 if(! gconv) { | |
45 DEBUG_INFO("no previous conversation exists\n"); | |
46 gconv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, name); | |
47 gaim_conversation_present(gconv); | |
48 | |
49 if(gaim_prefs_get_bool(PREF_NOTICE)) { | |
12861
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
50 gaim_conversation_write(gconv, NULL, |
6cc43e23ad36
[gaim-migrate @ 15212]
Christopher O'Brien <siege@pidgin.im>
parents:
12859
diff
changeset
|
51 _("You feel a disturbance in the force..."), |
12895
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
52 GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, |
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
53 time(NULL)); |
12859 | 54 } |
55 } | |
56 } | |
57 | |
58 | |
59 static GaimPluginPrefFrame * | |
60 get_plugin_pref_frame(GaimPlugin *plugin) { | |
61 | |
62 GaimPluginPrefFrame *frame; | |
63 GaimPluginPref *pref; | |
64 | |
65 frame = gaim_plugin_pref_frame_new(); | |
66 | |
67 pref = gaim_plugin_pref_new_with_name(PREF_BUDDIES); | |
12895
a355472257f4
[gaim-migrate @ 15248]
Richard Laager <rlaager@wiktel.com>
parents:
12861
diff
changeset
|
68 gaim_plugin_pref_set_label(pref, _("Only enable for users on the buddy list")); |
12859 | 69 gaim_plugin_pref_frame_add(frame, pref); |
70 | |
71 pref = gaim_plugin_pref_new_with_name(PREF_NOTICE); | |
72 gaim_plugin_pref_set_label(pref, _("Display notification message in" | |
73 " conversations")); | |
74 gaim_plugin_pref_frame_add(frame, pref); | |
75 | |
76 return frame; | |
77 } | |
78 | |
79 | |
80 static gboolean | |
81 plugin_load(GaimPlugin *plugin) { | |
82 | |
83 void *convs_handle; | |
84 convs_handle = gaim_conversations_get_handle(); | |
85 | |
86 gaim_signal_connect(convs_handle, "buddy-typing", plugin, | |
87 GAIM_CALLBACK(buddy_typing_cb), NULL); | |
88 | |
89 return TRUE; | |
90 } | |
91 | |
92 | |
93 static GaimPluginUiInfo prefs_info = { | |
94 get_plugin_pref_frame, | |
95 0, /* page_num (Reserved) */ | |
96 NULL, /* frame (Reserved) */ | |
97 }; | |
98 | |
99 | |
100 static GaimPluginInfo info = { | |
101 GAIM_PLUGIN_MAGIC, | |
102 GAIM_MAJOR_VERSION, | |
103 GAIM_MINOR_VERSION, | |
104 GAIM_PLUGIN_STANDARD, /**< type */ | |
105 NULL, /**< ui_requirement */ | |
106 0, /**< flags */ | |
107 NULL, /**< dependencies */ | |
108 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
109 | |
110 PLUGIN_ID, /**< id */ | |
111 PLUGIN_NAME, /**< name */ | |
112 VERSION, /**< version */ | |
113 PLUGIN_SUMMARY, /**< summary */ | |
114 PLUGIN_DESC, /**< description */ | |
115 PLUGIN_AUTHOR, /**< author */ | |
116 GAIM_WEBSITE, /**< homepage */ | |
117 | |
118 plugin_load, /**< load */ | |
119 NULL, /**< unload */ | |
120 NULL, /**< destroy */ | |
121 | |
122 NULL, /**< ui_info */ | |
123 NULL, /**< extra_info */ | |
124 &prefs_info, /**< prefs_info */ | |
125 NULL, /**< actions */ | |
126 }; | |
127 | |
128 | |
129 static void | |
130 init_plugin(GaimPlugin *plugin) { | |
131 gaim_prefs_add_none(PREFS_BASE); | |
132 gaim_prefs_add_bool(PREF_BUDDIES, FALSE); | |
133 gaim_prefs_add_bool(PREF_NOTICE, TRUE); | |
134 } | |
135 | |
136 | |
137 GAIM_INIT_PLUGIN(psychic, init_plugin, info) |