Mercurial > pidgin.yaz
annotate plugins/statenotify.c @ 10060:7570908c558f
[gaim-migrate @ 11030]
<seanegan> It removes the Web Browser dropdown if you're running GNOME and uses the GNOME browser instead of what's set in prefs.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Thu, 23 Sep 2004 03:09:46 +0000 |
parents | f8e395a054e2 |
children | cf45c2a6a7cf |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3 #include "blist.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
4 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5 #include "debug.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
6 #include "signals.h" |
9943 | 7 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
8 |
9583 | 9 #include "plugin.h" |
10 #include "pluginpref.h" | |
11 #include "prefs.h" | |
12 | |
13 #define STATENOTIFY_PLUGIN_ID "core-statenotify" | |
14 | |
5267 | 15 static void |
6695 | 16 write_status(GaimBuddy *buddy, const char *message) |
5267 | 17 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5587
diff
changeset
|
18 GaimConversation *conv; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
19 const char *who; |
5267 | 20 char buf[256]; |
21 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
22 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
5267 | 23 |
24 if (conv == NULL) | |
25 return; | |
26 | |
9620 | 27 who = gaim_buddy_get_alias(buddy); |
5267 | 28 |
6489 | 29 g_snprintf(buf, sizeof(buf), message, who); |
5267 | 30 |
6982 | 31 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
5267 | 32 } |
33 | |
34 static void | |
6695 | 35 buddy_away_cb(GaimBuddy *buddy, void *data) |
5267 | 36 { |
9583 | 37 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) |
38 write_status(buddy, _("%s has gone away.")); | |
5267 | 39 } |
40 | |
41 static void | |
6695 | 42 buddy_unaway_cb(GaimBuddy *buddy, void *data) |
5267 | 43 { |
9583 | 44 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) |
45 write_status(buddy, _("%s is no longer away.")); | |
5267 | 46 } |
47 | |
48 static void | |
6695 | 49 buddy_idle_cb(GaimBuddy *buddy, void *data) |
5267 | 50 { |
9583 | 51 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) |
52 write_status(buddy, _("%s has become idle.")); | |
5267 | 53 } |
54 | |
55 static void | |
6695 | 56 buddy_unidle_cb(GaimBuddy *buddy, void *data) |
5267 | 57 { |
9583 | 58 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) |
59 write_status(buddy, _("%s is no longer idle.")); | |
60 } | |
61 | |
62 static GaimPluginPrefFrame * | |
63 get_plugin_pref_frame(GaimPlugin *plugin) | |
64 { | |
65 GaimPluginPrefFrame *frame; | |
66 GaimPluginPref *ppref; | |
67 | |
68 frame = gaim_plugin_pref_frame_new(); | |
69 | |
9648 | 70 ppref = gaim_plugin_pref_new_with_label(_("Notify When")); |
9583 | 71 gaim_plugin_pref_frame_add(frame, ppref); |
72 | |
9648 | 73 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", _("Buddy Goes _Away")); |
9583 | 74 gaim_plugin_pref_frame_add(frame, ppref); |
75 | |
9648 | 76 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); |
9583 | 77 gaim_plugin_pref_frame_add(frame, ppref); |
78 | |
79 return frame; | |
5267 | 80 } |
81 | |
82 static gboolean | |
83 plugin_load(GaimPlugin *plugin) | |
84 { | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
85 void *blist_handle = gaim_blist_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
86 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
87 gaim_signal_connect(blist_handle, "buddy-away", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
88 plugin, GAIM_CALLBACK(buddy_away_cb), NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
89 gaim_signal_connect(blist_handle, "buddy-back", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
90 plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
91 gaim_signal_connect(blist_handle, "buddy-idle", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
92 plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
93 gaim_signal_connect(blist_handle, "buddy-unidle", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
94 plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); |
5267 | 95 |
96 return TRUE; | |
97 } | |
98 | |
9583 | 99 static GaimPluginUiInfo prefs_info = |
100 { | |
101 get_plugin_pref_frame | |
102 }; | |
103 | |
5267 | 104 static GaimPluginInfo info = |
105 { | |
9943 | 106 GAIM_PLUGIN_MAGIC, |
107 GAIM_MAJOR_VERSION, | |
108 GAIM_MINOR_VERSION, | |
5267 | 109 GAIM_PLUGIN_STANDARD, /**< type */ |
110 NULL, /**< ui_requirement */ | |
111 0, /**< flags */ | |
112 NULL, /**< dependencies */ | |
113 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
114 | |
9583 | 115 STATENOTIFY_PLUGIN_ID, /**< id */ |
5267 | 116 N_("Buddy State Notification"), /**< name */ |
117 VERSION, /**< version */ | |
118 /** summary */ | |
119 N_("Notifies in a conversation window when a buddy goes or returns from " | |
120 "away or idle."), | |
121 /** description */ | |
122 N_("Notifies in a conversation window when a buddy goes or returns from " | |
123 "away or idle."), | |
124 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
125 GAIM_WEBSITE, /**< homepage */ |
5267 | 126 |
127 plugin_load, /**< load */ | |
128 NULL, /**< unload */ | |
129 NULL, /**< destroy */ | |
130 | |
131 NULL, /**< ui_info */ | |
8993 | 132 NULL, /**< extra_info */ |
9583 | 133 &prefs_info, /**< prefs_info */ |
8993 | 134 NULL |
5267 | 135 }; |
136 | |
137 static void | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
138 init_plugin(GaimPlugin *plugin) |
5267 | 139 { |
9583 | 140 gaim_prefs_add_none("/plugins/core/statenotify"); |
141 gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); | |
142 gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); | |
5267 | 143 } |
144 | |
6063 | 145 GAIM_INIT_PLUGIN(statenotify, init_plugin, info) |