Mercurial > pidgin.yaz
annotate plugins/psychic.c @ 12861:6cc43e23ad36
[gaim-migrate @ 15212]
resiak is smart, and I like to get away from that impersonal voice for a while
committer: Tailor Script <tailor@pidgin.im>
author | Christopher O'Brien <siege@pidgin.im> |
---|---|
date | Fri, 13 Jan 2006 17:49:47 +0000 |
parents | 02e1ef5bc3d5 |
children | a355472257f4 |
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..."), |
12859 | 52 GAIM_MESSAGE_NO_LOG, time(NULL)); |
53 } | |
54 } | |
55 } | |
56 | |
57 | |
58 static GaimPluginPrefFrame * | |
59 get_plugin_pref_frame(GaimPlugin *plugin) { | |
60 | |
61 GaimPluginPrefFrame *frame; | |
62 GaimPluginPref *pref; | |
63 | |
64 frame = gaim_plugin_pref_frame_new(); | |
65 | |
66 pref = gaim_plugin_pref_new_with_name(PREF_BUDDIES); | |
67 gaim_plugin_pref_set_label(pref, _("Only enable for users in buddy list")); | |
68 gaim_plugin_pref_frame_add(frame, pref); | |
69 | |
70 pref = gaim_plugin_pref_new_with_name(PREF_NOTICE); | |
71 gaim_plugin_pref_set_label(pref, _("Display notification message in" | |
72 " conversations")); | |
73 gaim_plugin_pref_frame_add(frame, pref); | |
74 | |
75 return frame; | |
76 } | |
77 | |
78 | |
79 static gboolean | |
80 plugin_load(GaimPlugin *plugin) { | |
81 | |
82 void *convs_handle; | |
83 convs_handle = gaim_conversations_get_handle(); | |
84 | |
85 gaim_signal_connect(convs_handle, "buddy-typing", plugin, | |
86 GAIM_CALLBACK(buddy_typing_cb), NULL); | |
87 | |
88 return TRUE; | |
89 } | |
90 | |
91 | |
92 static GaimPluginUiInfo prefs_info = { | |
93 get_plugin_pref_frame, | |
94 0, /* page_num (Reserved) */ | |
95 NULL, /* frame (Reserved) */ | |
96 }; | |
97 | |
98 | |
99 static GaimPluginInfo info = { | |
100 GAIM_PLUGIN_MAGIC, | |
101 GAIM_MAJOR_VERSION, | |
102 GAIM_MINOR_VERSION, | |
103 GAIM_PLUGIN_STANDARD, /**< type */ | |
104 NULL, /**< ui_requirement */ | |
105 0, /**< flags */ | |
106 NULL, /**< dependencies */ | |
107 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
108 | |
109 PLUGIN_ID, /**< id */ | |
110 PLUGIN_NAME, /**< name */ | |
111 VERSION, /**< version */ | |
112 PLUGIN_SUMMARY, /**< summary */ | |
113 PLUGIN_DESC, /**< description */ | |
114 PLUGIN_AUTHOR, /**< author */ | |
115 GAIM_WEBSITE, /**< homepage */ | |
116 | |
117 plugin_load, /**< load */ | |
118 NULL, /**< unload */ | |
119 NULL, /**< destroy */ | |
120 | |
121 NULL, /**< ui_info */ | |
122 NULL, /**< extra_info */ | |
123 &prefs_info, /**< prefs_info */ | |
124 NULL, /**< actions */ | |
125 }; | |
126 | |
127 | |
128 static void | |
129 init_plugin(GaimPlugin *plugin) { | |
130 gaim_prefs_add_none(PREFS_BASE); | |
131 gaim_prefs_add_bool(PREF_BUDDIES, FALSE); | |
132 gaim_prefs_add_bool(PREF_NOTICE, TRUE); | |
133 } | |
134 | |
135 | |
136 GAIM_INIT_PLUGIN(psychic, init_plugin, info) |