Mercurial > pidgin
comparison libpurple/plugins/statenotify.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | 4999bbc52881 |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
11 #include "prefs.h" | 11 #include "prefs.h" |
12 | 12 |
13 #define STATENOTIFY_PLUGIN_ID "core-statenotify" | 13 #define STATENOTIFY_PLUGIN_ID "core-statenotify" |
14 | 14 |
15 static void | 15 static void |
16 write_status(GaimBuddy *buddy, const char *message) | 16 write_status(PurpleBuddy *buddy, const char *message) |
17 { | 17 { |
18 GaimConversation *conv; | 18 PurpleConversation *conv; |
19 const char *who; | 19 const char *who; |
20 char buf[256]; | 20 char buf[256]; |
21 char *escaped; | 21 char *escaped; |
22 | 22 |
23 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, | 23 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
24 buddy->name, buddy->account); | 24 buddy->name, buddy->account); |
25 | 25 |
26 if (conv == NULL) | 26 if (conv == NULL) |
27 return; | 27 return; |
28 g_return_if_fail(conv->type == GAIM_CONV_TYPE_IM); | 28 g_return_if_fail(conv->type == PURPLE_CONV_TYPE_IM); |
29 | 29 |
30 who = gaim_buddy_get_alias(buddy); | 30 who = purple_buddy_get_alias(buddy); |
31 escaped = g_markup_escape_text(who, -1); | 31 escaped = g_markup_escape_text(who, -1); |
32 | 32 |
33 g_snprintf(buf, sizeof(buf), message, escaped); | 33 g_snprintf(buf, sizeof(buf), message, escaped); |
34 g_free(escaped); | 34 g_free(escaped); |
35 | 35 |
36 gaim_conv_im_write(conv->u.im, NULL, buf, GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_ACTIVE_ONLY, time(NULL)); | 36 purple_conv_im_write(conv->u.im, NULL, buf, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ACTIVE_ONLY, time(NULL)); |
37 } | 37 } |
38 | 38 |
39 static void | 39 static void |
40 buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, | 40 buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status, |
41 GaimStatus *status, void *data) | 41 PurpleStatus *status, void *data) |
42 { | 42 { |
43 gboolean available, old_available; | 43 gboolean available, old_available; |
44 | 44 |
45 available = gaim_status_is_available(status); | 45 available = purple_status_is_available(status); |
46 old_available = gaim_status_is_available(old_status); | 46 old_available = purple_status_is_available(old_status); |
47 | 47 |
48 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) { | 48 if (purple_prefs_get_bool("/plugins/core/statenotify/notify_away")) { |
49 if (available && !old_available) | 49 if (available && !old_available) |
50 write_status(buddy, _("%s is no longer away.")); | 50 write_status(buddy, _("%s is no longer away.")); |
51 else if (!available && old_available) | 51 else if (!available && old_available) |
52 write_status(buddy, _("%s has gone away.")); | 52 write_status(buddy, _("%s has gone away.")); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 static void | 56 static void |
57 buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle, | 57 buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle, |
58 void *data) | 58 void *data) |
59 { | 59 { |
60 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { | 60 if (purple_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { |
61 if (idle) { | 61 if (idle) { |
62 write_status(buddy, _("%s has become idle.")); | 62 write_status(buddy, _("%s has become idle.")); |
63 } else { | 63 } else { |
64 write_status(buddy, _("%s is no longer idle.")); | 64 write_status(buddy, _("%s is no longer idle.")); |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 static void | 69 static void |
70 buddy_signon_cb(GaimBuddy *buddy, void *data) | 70 buddy_signon_cb(PurpleBuddy *buddy, void *data) |
71 { | 71 { |
72 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_signon")) | 72 if (purple_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
73 write_status(buddy, _("%s has signed on.")); | 73 write_status(buddy, _("%s has signed on.")); |
74 } | 74 } |
75 | 75 |
76 static void | 76 static void |
77 buddy_signoff_cb(GaimBuddy *buddy, void *data) | 77 buddy_signoff_cb(PurpleBuddy *buddy, void *data) |
78 { | 78 { |
79 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_signon")) | 79 if (purple_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
80 write_status(buddy, _("%s has signed off.")); | 80 write_status(buddy, _("%s has signed off.")); |
81 } | 81 } |
82 | 82 |
83 static GaimPluginPrefFrame * | 83 static PurplePluginPrefFrame * |
84 get_plugin_pref_frame(GaimPlugin *plugin) | 84 get_plugin_pref_frame(PurplePlugin *plugin) |
85 { | 85 { |
86 GaimPluginPrefFrame *frame; | 86 PurplePluginPrefFrame *frame; |
87 GaimPluginPref *ppref; | 87 PurplePluginPref *ppref; |
88 | 88 |
89 frame = gaim_plugin_pref_frame_new(); | 89 frame = purple_plugin_pref_frame_new(); |
90 | 90 |
91 ppref = gaim_plugin_pref_new_with_label(_("Notify When")); | 91 ppref = purple_plugin_pref_new_with_label(_("Notify When")); |
92 gaim_plugin_pref_frame_add(frame, ppref); | 92 purple_plugin_pref_frame_add(frame, ppref); |
93 | 93 |
94 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", _("Buddy Goes _Away")); | 94 ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", _("Buddy Goes _Away")); |
95 gaim_plugin_pref_frame_add(frame, ppref); | 95 purple_plugin_pref_frame_add(frame, ppref); |
96 | 96 |
97 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); | 97 ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); |
98 gaim_plugin_pref_frame_add(frame, ppref); | 98 purple_plugin_pref_frame_add(frame, ppref); |
99 | 99 |
100 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_signon", _("Buddy _Signs On/Off")); | 100 ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_signon", _("Buddy _Signs On/Off")); |
101 gaim_plugin_pref_frame_add(frame, ppref); | 101 purple_plugin_pref_frame_add(frame, ppref); |
102 | 102 |
103 return frame; | 103 return frame; |
104 } | 104 } |
105 | 105 |
106 static gboolean | 106 static gboolean |
107 plugin_load(GaimPlugin *plugin) | 107 plugin_load(PurplePlugin *plugin) |
108 { | 108 { |
109 void *blist_handle = gaim_blist_get_handle(); | 109 void *blist_handle = purple_blist_get_handle(); |
110 | 110 |
111 gaim_signal_connect(blist_handle, "buddy-status-changed", plugin, | 111 purple_signal_connect(blist_handle, "buddy-status-changed", plugin, |
112 GAIM_CALLBACK(buddy_status_changed_cb), NULL); | 112 PURPLE_CALLBACK(buddy_status_changed_cb), NULL); |
113 gaim_signal_connect(blist_handle, "buddy-idle-changed", plugin, | 113 purple_signal_connect(blist_handle, "buddy-idle-changed", plugin, |
114 GAIM_CALLBACK(buddy_idle_changed_cb), NULL); | 114 PURPLE_CALLBACK(buddy_idle_changed_cb), NULL); |
115 gaim_signal_connect(blist_handle, "buddy-signed-on", plugin, | 115 purple_signal_connect(blist_handle, "buddy-signed-on", plugin, |
116 GAIM_CALLBACK(buddy_signon_cb), NULL); | 116 PURPLE_CALLBACK(buddy_signon_cb), NULL); |
117 gaim_signal_connect(blist_handle, "buddy-signed-off", plugin, | 117 purple_signal_connect(blist_handle, "buddy-signed-off", plugin, |
118 GAIM_CALLBACK(buddy_signoff_cb), NULL); | 118 PURPLE_CALLBACK(buddy_signoff_cb), NULL); |
119 | 119 |
120 return TRUE; | 120 return TRUE; |
121 } | 121 } |
122 | 122 |
123 static GaimPluginUiInfo prefs_info = | 123 static PurplePluginUiInfo prefs_info = |
124 { | 124 { |
125 get_plugin_pref_frame, | 125 get_plugin_pref_frame, |
126 0, /* page_num (Reserved) */ | 126 0, /* page_num (Reserved) */ |
127 NULL /* frame (Reserved) */ | 127 NULL /* frame (Reserved) */ |
128 }; | 128 }; |
129 | 129 |
130 static GaimPluginInfo info = | 130 static PurplePluginInfo info = |
131 { | 131 { |
132 GAIM_PLUGIN_MAGIC, | 132 PURPLE_PLUGIN_MAGIC, |
133 GAIM_MAJOR_VERSION, | 133 PURPLE_MAJOR_VERSION, |
134 GAIM_MINOR_VERSION, | 134 PURPLE_MINOR_VERSION, |
135 GAIM_PLUGIN_STANDARD, /**< type */ | 135 PURPLE_PLUGIN_STANDARD, /**< type */ |
136 NULL, /**< ui_requirement */ | 136 NULL, /**< ui_requirement */ |
137 0, /**< flags */ | 137 0, /**< flags */ |
138 NULL, /**< dependencies */ | 138 NULL, /**< dependencies */ |
139 GAIM_PRIORITY_DEFAULT, /**< priority */ | 139 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
140 | 140 |
141 STATENOTIFY_PLUGIN_ID, /**< id */ | 141 STATENOTIFY_PLUGIN_ID, /**< id */ |
142 N_("Buddy State Notification"), /**< name */ | 142 N_("Buddy State Notification"), /**< name */ |
143 VERSION, /**< version */ | 143 VERSION, /**< version */ |
144 /** summary */ | 144 /** summary */ |
146 "away or idle."), | 146 "away or idle."), |
147 /** description */ | 147 /** description */ |
148 N_("Notifies in a conversation window when a buddy goes or returns from " | 148 N_("Notifies in a conversation window when a buddy goes or returns from " |
149 "away or idle."), | 149 "away or idle."), |
150 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | 150 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ |
151 GAIM_WEBSITE, /**< homepage */ | 151 PURPLE_WEBSITE, /**< homepage */ |
152 | 152 |
153 plugin_load, /**< load */ | 153 plugin_load, /**< load */ |
154 NULL, /**< unload */ | 154 NULL, /**< unload */ |
155 NULL, /**< destroy */ | 155 NULL, /**< destroy */ |
156 | 156 |
159 &prefs_info, /**< prefs_info */ | 159 &prefs_info, /**< prefs_info */ |
160 NULL | 160 NULL |
161 }; | 161 }; |
162 | 162 |
163 static void | 163 static void |
164 init_plugin(GaimPlugin *plugin) | 164 init_plugin(PurplePlugin *plugin) |
165 { | 165 { |
166 gaim_prefs_add_none("/plugins/core/statenotify"); | 166 purple_prefs_add_none("/plugins/core/statenotify"); |
167 gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); | 167 purple_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); |
168 gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); | 168 purple_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); |
169 gaim_prefs_add_bool("/plugins/core/statenotify/notify_signon", TRUE); | 169 purple_prefs_add_bool("/plugins/core/statenotify/notify_signon", TRUE); |
170 } | 170 } |
171 | 171 |
172 GAIM_INIT_PLUGIN(statenotify, init_plugin, info) | 172 PURPLE_INIT_PLUGIN(statenotify, init_plugin, info) |