Mercurial > pidgin.yaz
annotate plugins/statenotify.c @ 10210:4d3c2749deec
[gaim-migrate @ 11332]
Now checking GAIMLANG and GAIMHOME instead of LANG and HOME
env variables, to avoid conflicts with other apps that use them and to avoid
HOME env variables intended for cygwin (using unix style path). Removed
some obsolete code.
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Fri, 19 Nov 2004 20:39:09 +0000 |
parents | cf45c2a6a7cf |
children | a66cf83552dc |
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]; |
10167 | 21 char *escaped; |
5267 | 22 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
23 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
5267 | 24 |
25 if (conv == NULL) | |
26 return; | |
27 | |
9620 | 28 who = gaim_buddy_get_alias(buddy); |
10167 | 29 escaped = g_markup_escape_text(who, -1); |
5267 | 30 |
10167 | 31 g_snprintf(buf, sizeof(buf), message, escaped); |
32 g_free(escaped); | |
5267 | 33 |
6982 | 34 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
5267 | 35 } |
36 | |
37 static void | |
6695 | 38 buddy_away_cb(GaimBuddy *buddy, void *data) |
5267 | 39 { |
9583 | 40 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) |
41 write_status(buddy, _("%s has gone away.")); | |
5267 | 42 } |
43 | |
44 static void | |
6695 | 45 buddy_unaway_cb(GaimBuddy *buddy, void *data) |
5267 | 46 { |
9583 | 47 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) |
48 write_status(buddy, _("%s is no longer away.")); | |
5267 | 49 } |
50 | |
51 static void | |
6695 | 52 buddy_idle_cb(GaimBuddy *buddy, void *data) |
5267 | 53 { |
9583 | 54 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) |
55 write_status(buddy, _("%s has become idle.")); | |
5267 | 56 } |
57 | |
58 static void | |
6695 | 59 buddy_unidle_cb(GaimBuddy *buddy, void *data) |
5267 | 60 { |
9583 | 61 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) |
62 write_status(buddy, _("%s is no longer idle.")); | |
63 } | |
64 | |
65 static GaimPluginPrefFrame * | |
66 get_plugin_pref_frame(GaimPlugin *plugin) | |
67 { | |
68 GaimPluginPrefFrame *frame; | |
69 GaimPluginPref *ppref; | |
70 | |
71 frame = gaim_plugin_pref_frame_new(); | |
72 | |
9648 | 73 ppref = gaim_plugin_pref_new_with_label(_("Notify When")); |
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_away", _("Buddy Goes _Away")); |
9583 | 77 gaim_plugin_pref_frame_add(frame, ppref); |
78 | |
9648 | 79 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); |
9583 | 80 gaim_plugin_pref_frame_add(frame, ppref); |
81 | |
82 return frame; | |
5267 | 83 } |
84 | |
85 static gboolean | |
86 plugin_load(GaimPlugin *plugin) | |
87 { | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
88 void *blist_handle = gaim_blist_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
89 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
90 gaim_signal_connect(blist_handle, "buddy-away", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
91 plugin, GAIM_CALLBACK(buddy_away_cb), NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
92 gaim_signal_connect(blist_handle, "buddy-back", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
93 plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
94 gaim_signal_connect(blist_handle, "buddy-idle", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
95 plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
96 gaim_signal_connect(blist_handle, "buddy-unidle", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
97 plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); |
5267 | 98 |
99 return TRUE; | |
100 } | |
101 | |
9583 | 102 static GaimPluginUiInfo prefs_info = |
103 { | |
104 get_plugin_pref_frame | |
105 }; | |
106 | |
5267 | 107 static GaimPluginInfo info = |
108 { | |
9943 | 109 GAIM_PLUGIN_MAGIC, |
110 GAIM_MAJOR_VERSION, | |
111 GAIM_MINOR_VERSION, | |
5267 | 112 GAIM_PLUGIN_STANDARD, /**< type */ |
113 NULL, /**< ui_requirement */ | |
114 0, /**< flags */ | |
115 NULL, /**< dependencies */ | |
116 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
117 | |
9583 | 118 STATENOTIFY_PLUGIN_ID, /**< id */ |
5267 | 119 N_("Buddy State Notification"), /**< name */ |
120 VERSION, /**< version */ | |
121 /** summary */ | |
122 N_("Notifies in a conversation window when a buddy goes or returns from " | |
123 "away or idle."), | |
124 /** description */ | |
125 N_("Notifies in a conversation window when a buddy goes or returns from " | |
126 "away or idle."), | |
127 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
128 GAIM_WEBSITE, /**< homepage */ |
5267 | 129 |
130 plugin_load, /**< load */ | |
131 NULL, /**< unload */ | |
132 NULL, /**< destroy */ | |
133 | |
134 NULL, /**< ui_info */ | |
8993 | 135 NULL, /**< extra_info */ |
9583 | 136 &prefs_info, /**< prefs_info */ |
8993 | 137 NULL |
5267 | 138 }; |
139 | |
140 static void | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
141 init_plugin(GaimPlugin *plugin) |
5267 | 142 { |
9583 | 143 gaim_prefs_add_none("/plugins/core/statenotify"); |
144 gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); | |
145 gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); | |
5267 | 146 } |
147 | |
6063 | 148 GAIM_INIT_PLUGIN(statenotify, init_plugin, info) |