Mercurial > pidgin-audacious
annotate pidgin-audacious.c @ 11:43cb653de212
paste template has been implemented.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 18 Sep 2008 01:55:32 +0900 |
parents | 7c9624c8a109 |
children | 79f081cdfb19 |
rev | line source |
---|---|
0 | 1 /* |
2 * Pidgin-Audacious plugin. | |
3 * | |
4 * This program is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU General Public License as | |
6 * published by the Free Software Foundation; either version 2 of the | |
7 * License, or (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, but | |
10 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
17 * 02111-1307, USA. | |
18 */ | |
19 #define PURPLE_PLUGINS 1 | |
20 | |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <glib.h> | |
25 | |
26 #include "gtkplugin.h" | |
27 #include "util.h" | |
28 #include "debug.h" | |
29 #include "connection.h" | |
30 #include "version.h" | |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
31 #include "cmds.h" |
0 | 32 #include <audacious/audctrl.h> |
33 #include <audacious/dbus.h> | |
34 | |
7
feb13e877029
follow the change of botch_utf()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3
diff
changeset
|
35 extern gchar *botch_utf(const gchar *msg, gsize len, gsize *newlen) __attribute__ ((weak)); |
0 | 36 |
37 #define PIDGINAUD_PLUGIN_ID "pidgin_audacious" | |
38 | |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
39 #define OPT_PIDGINAUD "/plugins/pidgin_audacious" |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
40 #define OPT_PROCESS_STATUS OPT_PIDGINAUD "/process_status" |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
41 #define OPT_PROCESS_USERINFO OPT_PIDGINAUD "/process_userinfo" |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
42 #define OPT_PROCESS_ALIAS OPT_PIDGINAUD "/process_alias" |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
43 #define OPT_PASTE_TEMPLATE OPT_PIDGINAUD "/paste_template" |
0 | 44 |
45 #define SONG_TOKEN "%song" | |
46 #define NO_SONG_MESSAGE "No song being played." | |
47 | |
48 #define BUDDY_ALIAS_MAXLEN 387 | |
49 | |
50 #define aud_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, "Pidgin-Audacious", \ | |
51 fmt, ## __VA_ARGS__); | |
52 #define aud_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, "Pidgin-Audacious", \ | |
53 fmt, ## __VA_ARGS__); | |
54 | |
55 static gint timeout_tag = 0; | |
56 | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
57 GHashTable *seed_status; |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
58 GHashTable *seed_userinfo; |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
59 GHashTable *seed_alias; |
0 | 60 |
61 GHashTable *pushed_status; | |
62 GHashTable *pushed_userinfo; | |
63 GHashTable *pushed_alias; | |
64 | |
65 DBusGProxy *session = NULL; | |
66 | |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
67 static PurpleCmdId cmdid_paste_current_song; |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
68 |
0 | 69 static void aud_process(gchar *aud_info); |
70 | |
71 static DBusGProxy *get_dbus_proxy(void) | |
72 { | |
73 DBusGConnection *connection = NULL; | |
74 DBusGProxy *session = NULL; | |
75 GError *error = NULL; | |
76 connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); | |
77 g_clear_error(&error); | |
78 | |
79 session = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE, | |
80 AUDACIOUS_DBUS_PATH, | |
81 AUDACIOUS_DBUS_INTERFACE); | |
82 | |
83 g_clear_error(&error); | |
84 return session; | |
85 } | |
86 | |
87 static gboolean | |
88 watchdog_func(void) | |
89 { | |
90 gint playpos = 0; | |
91 gchar *song = NULL, *tmp = NULL; | |
92 | |
93 gboolean rv = TRUE; | |
94 size_t dummy; | |
95 | |
96 aud_debug("session = %p\n", session); | |
97 | |
98 aud_debug("is_playing = %d\n", audacious_remote_is_playing(session)); | |
99 | |
100 if(!audacious_remote_is_playing(session)) { /* audacious isn't playing */ | |
101 aud_process(NULL); | |
102 return rv; | |
103 } | |
104 | |
105 playpos = audacious_remote_get_playlist_pos(session); | |
106 tmp = audacious_remote_get_playlist_title(session, playpos); | |
107 if(tmp) { | |
108 if(botch_utf) // function exists | |
109 song = (gchar *) botch_utf(tmp, strlen(tmp), &dummy); | |
110 else | |
111 song = g_strdup(tmp); | |
112 } | |
113 g_free(tmp); | |
114 tmp = NULL; | |
115 | |
116 aud_process(song); | |
117 g_free(song); | |
118 song = NULL; | |
119 return rv; | |
120 } | |
121 | |
122 static void | |
123 aud_process_status(PurpleConnection *gc, gchar *aud_info) | |
124 { | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
125 gchar *new = NULL, *key = NULL; |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
126 const gchar *current, *seed, *pushed, *proto; |
0 | 127 PurpleAccount *account; |
128 PurplePresence *presence; | |
129 PurplePlugin *prpl; | |
130 PurplePluginProtocolInfo *prpl_info; | |
131 PurpleStatus *status; | |
132 | |
133 account = purple_connection_get_account(gc); | |
134 presence = purple_account_get_presence(account); | |
135 | |
136 proto = purple_account_get_protocol_id(account); | |
137 prpl = purple_find_prpl(proto); | |
138 g_return_if_fail(prpl != NULL); | |
139 | |
140 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); | |
141 g_return_if_fail(prpl_info != NULL && prpl_info->set_status != NULL); | |
142 | |
143 status = purple_presence_get_active_status(presence); | |
144 g_return_if_fail(status != NULL); | |
145 | |
146 /* generate key for hash table */ | |
147 key = g_strdup_printf("%s %s", account->username, account->protocol_id); | |
148 | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
149 /* retrieve current user status */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
150 current = purple_status_get_attr_string(status, "message"); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
151 aud_debug("status current = %s\n", current); |
0 | 152 |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
153 /* invalidate pushded status on auto away etc. */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
154 if(current == NULL || strlen(current) == 0) { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
155 g_hash_table_replace(pushed_status, g_strdup(key), g_strdup("")); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
156 g_free(key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
157 return; |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
158 } |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
159 |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
160 /* pop pushed_status */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
161 pushed = (gchar *)g_hash_table_lookup(pushed_status, key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
162 |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
163 /* if current status differs from pushed_status or contains token, replace hashes with current. */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
164 if( (pushed && g_ascii_strcasecmp(current, pushed)) || strstr(current, SONG_TOKEN) ) { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
165 g_hash_table_replace(seed_status, g_strdup(key), g_strdup(current)); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
166 g_hash_table_replace(pushed_status, g_strdup(key), g_strdup(current)); |
0 | 167 } |
168 | |
169 /* construct new status message */ | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
170 seed = (gchar *)g_hash_table_lookup(seed_status, key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
171 g_return_if_fail(seed != NULL); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
172 aud_debug("status seed = %s\n", seed); |
0 | 173 |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
174 if(strstr(seed, SONG_TOKEN)) { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
175 if(aud_info){ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
176 new = purple_strreplace(seed, SONG_TOKEN, aud_info); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
177 } |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
178 else { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
179 new = g_strdup(NO_SONG_MESSAGE); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
180 } |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
181 } |
0 | 182 g_return_if_fail(new != NULL); |
183 | |
184 /* set status message only if text has been changed */ | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
185 pushed = (gchar *)g_hash_table_lookup(pushed_status, key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
186 aud_debug("status pushed = %s\n", pushed); |
0 | 187 |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
188 if (!pushed || g_ascii_strcasecmp(pushed, new)) { |
0 | 189 g_hash_table_replace(pushed_status, g_strdup(key), g_strdup(new)); |
190 purple_status_set_attr_string(status, "message", new); | |
191 prpl_info->set_status(account, status); | |
192 } | |
193 g_free(key); | |
194 g_free(new); | |
195 } | |
196 | |
197 | |
198 static void | |
199 aud_process_userinfo(PurpleConnection *gc, gchar *aud_info) | |
200 { | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
201 gchar *new = NULL, *key = NULL; |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
202 const gchar *current, *seed, *pushed, *proto; |
0 | 203 PurpleAccount *account; |
204 PurplePlugin *prpl; | |
205 PurplePluginProtocolInfo *prpl_info; | |
206 | |
207 account = purple_connection_get_account(gc); | |
208 | |
209 proto = purple_account_get_protocol_id(account); | |
210 prpl = purple_find_prpl(proto); | |
211 g_return_if_fail(prpl != NULL); | |
212 | |
213 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); | |
214 g_return_if_fail(prpl_info != NULL && prpl_info->set_info != NULL); | |
215 | |
216 /* generate key for hash table*/ | |
217 key = g_strdup_printf("%s %s", account->username, account->protocol_id); | |
218 | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
219 /* retrieve current user info */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
220 current = purple_account_get_user_info(account); /* it's always from account.xml! */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
221 aud_debug("userinfo current = %s\n", current); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
222 |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
223 /* invalidate pushded status on auto away etc. */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
224 if(current == NULL || strlen(current) == 0) { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
225 g_hash_table_replace(pushed_userinfo, g_strdup(key), g_strdup("")); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
226 g_free(key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
227 return; |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
228 } |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
229 |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
230 /* pop pushed_userinfo */ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
231 pushed = g_hash_table_lookup(pushed_userinfo, key); |
0 | 232 |
233 /* if current alias differs from pushed_alias or contains token, replace seed with this. */ | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
234 if( (pushed && g_ascii_strcasecmp(current, pushed)) || strstr(current, SONG_TOKEN) ) { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
235 g_hash_table_replace(seed_userinfo, g_strdup(key), g_strdup(current)); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
236 g_hash_table_replace(pushed_userinfo, g_strdup(key), g_strdup(current)); |
0 | 237 } |
238 | |
239 /* construct new status message */ | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
240 seed = (gchar *)g_hash_table_lookup(seed_userinfo, key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
241 g_return_if_fail(seed != NULL); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
242 aud_debug("userinfo seed = %s\n", seed); |
0 | 243 |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
244 if(strstr(seed, SONG_TOKEN)) { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
245 if(aud_info){ |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
246 new = purple_strreplace(seed, SONG_TOKEN, aud_info); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
247 } |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
248 else { |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
249 new = g_strdup(NO_SONG_MESSAGE); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
250 } |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
251 } |
0 | 252 g_return_if_fail(new != NULL); |
253 | |
254 /* set user info only if text has been changed */ | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
255 pushed = (gchar *)g_hash_table_lookup(pushed_userinfo, key); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
256 aud_debug("userinfo pushed = %s\n", pushed); |
0 | 257 |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
258 if (!pushed || g_ascii_strcasecmp(pushed, new) != 0) { |
0 | 259 g_hash_table_replace(pushed_userinfo, g_strdup(key), g_strdup(new)); |
260 prpl_info->set_info(gc, new); | |
261 } | |
262 g_free(key); | |
263 g_free(new); | |
264 } | |
265 | |
266 static void | |
267 aud_process_alias(PurpleConnection *gc, gchar *aud_info) | |
268 { | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
269 gchar *new = NULL, *key = NULL; |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
270 const gchar *current, *seed, *pushed, *proto; |
0 | 271 PurpleAccount *account; |
272 PurplePlugin *prpl; | |
273 PurplePluginProtocolInfo *prpl_info; | |
274 | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
275 glong bytes; |
0 | 276 |
277 account = purple_connection_get_account(gc); | |
278 | |
279 proto = purple_account_get_protocol_id(account); | |
280 prpl = purple_find_prpl(proto); | |
281 g_return_if_fail(prpl != NULL); | |
282 | |
283 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); | |
284 g_return_if_fail(prpl_info != NULL); | |
285 | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
286 /* generate key for hash table*/ |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
287 key = g_strdup_printf("%s %s", account->username, account->protocol_id); |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
288 |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
289 /* retrieve current alias */ |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
290 current = purple_account_get_alias(account); |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
291 if(current == NULL || strlen(current) == 0) { |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
292 aud_error("couldn't get current alias\n"); |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
293 g_free(key); |
0 | 294 return; |
295 } | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
296 aud_debug("current alias = %s\n", current); |
0 | 297 |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
298 /* pop pushed_alias */ |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
299 pushed = g_hash_table_lookup(pushed_alias, key); |
0 | 300 |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
301 /* if current alias differs from pushed_alias or contains token, replace seed with current. */ |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
302 if( (pushed && g_ascii_strcasecmp(current, pushed)) || strstr(current, SONG_TOKEN) ) { |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
303 g_hash_table_replace(seed_alias, g_strdup(key), g_strdup(current)); |
0 | 304 } |
305 | |
306 /* construct new status message */ | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
307 seed = g_hash_table_lookup(seed_alias, key); |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
308 g_return_if_fail(seed != NULL); |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
309 aud_debug("alias: seed = %s\n", (gchar *)seed); |
0 | 310 |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
311 bytes = strlen(seed); |
0 | 312 bytes -= strlen(SONG_TOKEN); |
313 aud_debug("alias: bytes = %ld", bytes); | |
314 | |
315 if(aud_info){ | |
316 gchar *tmp = g_malloc0(BUDDY_ALIAS_MAXLEN); | |
317 glong utflen = g_utf8_strlen(aud_info, BUDDY_ALIAS_MAXLEN/3 - bytes - 1); | |
318 g_utf8_strncpy(tmp, aud_info, utflen); | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
319 new = purple_strreplace(seed, SONG_TOKEN, tmp); |
0 | 320 g_free(tmp); |
321 } | |
322 else { | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
323 new = purple_strreplace(seed, SONG_TOKEN, NO_SONG_MESSAGE); |
0 | 324 } |
325 g_return_if_fail(new != NULL); | |
326 | |
327 /* set user info only if text has been changed */ | |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
328 pushed = g_hash_table_lookup(pushed_alias, key); |
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
329 aud_debug("alias pushed = %s\n", (gchar *)pushed); |
0 | 330 |
2
f1dc959e4706
modify process_alias to follow recent changes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1
diff
changeset
|
331 if (!pushed || g_ascii_strcasecmp(pushed, new) != 0) { |
0 | 332 gboolean ok = FALSE; |
333 PurplePlugin *msn_plugin = NULL; | |
334 msn_plugin = purple_plugins_find_with_id("prpl-msn"); | |
335 aud_debug("msn_plugin = %p\n", msn_plugin); | |
336 | |
337 g_hash_table_replace(pushed_alias, g_strdup(key), g_strdup(new)); | |
338 purple_plugin_ipc_call(msn_plugin, "msn_set_friendly_name", &ok, gc, new); | |
339 aud_debug("ipc %d\n", ok); | |
340 } | |
341 g_free(key); | |
342 g_free(new); | |
343 } | |
344 | |
345 static void | |
346 aud_process(gchar *aud_info) | |
347 { | |
348 GList *l; | |
349 PurpleConnection *gc; | |
350 | |
351 for (l = purple_connections_get_all(); l != NULL; l = l->next) { | |
352 gc = (PurpleConnection *) l->data; | |
353 | |
354 /* make sure we're connected */ | |
355 if (purple_connection_get_state(gc) != PURPLE_CONNECTED) { | |
356 continue; | |
357 } | |
358 | |
359 if (purple_prefs_get_bool(OPT_PROCESS_USERINFO)) { | |
360 aud_process_userinfo(gc, aud_info); | |
361 } | |
362 | |
363 if (purple_prefs_get_bool(OPT_PROCESS_STATUS)) { | |
364 aud_process_status(gc, aud_info); | |
365 } | |
366 | |
367 if (purple_prefs_get_bool(OPT_PROCESS_ALIAS)) { | |
368 aud_process_alias(gc, aud_info); | |
369 } | |
370 | |
371 } | |
372 } | |
373 static void | |
374 removekey(gpointer data) | |
375 { | |
376 g_free(data); | |
377 } | |
378 | |
379 static void | |
380 removeval(gpointer data) | |
381 { | |
382 g_free(data); | |
383 } | |
384 | |
385 static gboolean | |
386 restore_alias(PurpleConnection *gc, gpointer data) | |
387 { | |
388 PurpleAccount *account; | |
389 gpointer val = NULL; | |
390 gchar *key = NULL; | |
391 | |
392 aud_debug("********** restore_alias called **********\n"); | |
393 account = purple_connection_get_account(gc); | |
394 | |
395 key = g_strdup_printf("%s %s", account->username, account->protocol_id); | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
396 val = g_hash_table_lookup(seed_alias, key); |
0 | 397 g_return_val_if_fail(val != NULL, FALSE); |
398 | |
9
d5702f04b19c
Fixed a bug that disabling this plugin while watch dog function has been hooked causes crash.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
399 aud_debug("write back alias %s\n", (char *)val); |
0 | 400 purple_account_set_alias(account, val); //oct16 |
401 | |
402 g_free(key); | |
403 | |
404 return TRUE; | |
405 } | |
406 | |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
407 static PurpleCmdRet |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
408 paste_current_song(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
409 { |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
410 gint playpos = 0; |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
411 gchar *song = NULL, *tmp = NULL, *tmp2 = NULL; |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
412 PurpleConversationType type = purple_conversation_get_type(conv); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
413 size_t dummy; |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
414 const gchar *template = NULL; |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
415 |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
416 /* audacious isn't playing */ |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
417 if(!audacious_remote_is_playing(session)) { |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
418 return PURPLE_CMD_RET_OK; |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
419 } |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
420 |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
421 playpos = audacious_remote_get_playlist_pos(session); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
422 tmp = audacious_remote_get_playlist_title(session, playpos); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
423 |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
424 template = purple_prefs_get_string(OPT_PASTE_TEMPLATE); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
425 |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
426 if(template && strstr(template, SONG_TOKEN)) { |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
427 tmp2 = purple_strreplace(template, SONG_TOKEN, tmp); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
428 g_free(tmp); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
429 tmp = NULL; |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
430 } |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
431 else { |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
432 tmp2 = tmp; |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
433 } |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
434 |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
435 if(tmp2) { |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
436 if(botch_utf) { |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
437 song = (gchar *) botch_utf(tmp2, strlen(tmp2), &dummy); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
438 g_free(tmp2); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
439 tmp2 = NULL; |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
440 } |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
441 else |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
442 song = tmp2; |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
443 } |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
444 |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
445 if(type == PURPLE_CONV_TYPE_CHAT) { |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
446 PurpleConvChat *chat = purple_conversation_get_chat_data(conv); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
447 if (chat && song) |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
448 purple_conv_chat_send(chat, song); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
449 } |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
450 else if(type == PURPLE_CONV_TYPE_IM) { |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
451 PurpleConvIm *im = purple_conversation_get_im_data(conv); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
452 if(im && song) |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
453 purple_conv_im_send(im, song); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
454 } |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
455 |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
456 g_free(song); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
457 return PURPLE_CMD_RET_OK; |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
458 } |
0 | 459 |
460 static gboolean | |
461 load_plugin(PurplePlugin *plugin) | |
462 { | |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
463 seed_status = g_hash_table_new_full(g_str_hash, g_str_equal, removekey, removeval); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
464 seed_alias = g_hash_table_new_full(g_str_hash, g_str_equal, removekey, removeval); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
465 seed_userinfo = g_hash_table_new_full(g_str_hash, g_str_equal, removekey, removeval); |
0 | 466 |
467 pushed_status = g_hash_table_new_full(g_str_hash, g_str_equal, removekey, removeval); | |
468 pushed_alias = g_hash_table_new_full(g_str_hash, g_str_equal, removekey, removeval); | |
469 pushed_userinfo = g_hash_table_new_full(g_str_hash, g_str_equal, removekey, removeval); | |
470 | |
471 timeout_tag = g_timeout_add(15*1000, (gpointer)watchdog_func, NULL); | |
472 | |
473 /* connect to signing-off signal */ | |
474 purple_signal_connect(purple_connections_get_handle(), "signing-off", plugin, | |
475 PURPLE_CALLBACK(restore_alias), NULL); | |
476 | |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
477 cmdid_paste_current_song = |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
478 purple_cmd_register("song", "", PURPLE_CMD_P_DEFAULT, |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
479 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT, |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
480 NULL, paste_current_song, |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
481 "song: Paste currently plaing song", NULL); |
0 | 482 |
483 return TRUE; | |
484 } | |
485 | |
486 static gboolean | |
487 unload_plugin(PurplePlugin *plugin) | |
488 { | |
489 aud_debug("pidgin-audacious unload called\n"); | |
490 | |
9
d5702f04b19c
Fixed a bug that disabling this plugin while watch dog function has been hooked causes crash.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
491 g_source_remove(timeout_tag); |
d5702f04b19c
Fixed a bug that disabling this plugin while watch dog function has been hooked causes crash.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
492 |
1
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
493 g_hash_table_destroy(seed_status); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
494 g_hash_table_destroy(seed_alias); |
46071692f191
implement new replace logic to status and userinfo.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
495 g_hash_table_destroy(seed_userinfo); |
0 | 496 |
497 g_hash_table_destroy(pushed_status); | |
498 g_hash_table_destroy(pushed_alias); | |
499 g_hash_table_destroy(pushed_userinfo); | |
500 | |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
501 purple_cmd_unregister(cmdid_paste_current_song); |
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
502 |
0 | 503 return TRUE; |
504 } | |
505 | |
506 static PurplePluginPrefFrame * | |
507 get_plugin_pref_frame(PurplePlugin *plugin) | |
508 { | |
509 PurplePluginPref *pref; | |
510 PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new(); | |
511 | |
512 /* create gtk elements for the plugin preferences */ | |
513 pref = purple_plugin_pref_new_with_label("Pidgin-Audacious Configuration"); | |
514 purple_plugin_pref_frame_add(frame, pref); | |
9
d5702f04b19c
Fixed a bug that disabling this plugin while watch dog function has been hooked causes crash.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
515 |
0 | 516 pref = purple_plugin_pref_new_with_name_and_label(OPT_PROCESS_STATUS, |
517 "Expand " SONG_TOKEN " to song info in the status message"); | |
518 purple_plugin_pref_frame_add(frame, pref); | |
9
d5702f04b19c
Fixed a bug that disabling this plugin while watch dog function has been hooked causes crash.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
519 |
0 | 520 pref = purple_plugin_pref_new_with_name_and_label(OPT_PROCESS_USERINFO, |
521 "Expand " SONG_TOKEN " to song info in the user info"); | |
522 purple_plugin_pref_frame_add(frame, pref); | |
523 | |
524 pref = purple_plugin_pref_new_with_name_and_label(OPT_PROCESS_ALIAS, | |
525 "Expand " SONG_TOKEN " to song info in the alias"); | |
526 purple_plugin_pref_frame_add(frame, pref); | |
527 | |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
528 /* paste template */ |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
529 pref = purple_plugin_pref_new_with_name_and_label(OPT_PASTE_TEMPLATE, |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
530 "Paste template"); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
531 purple_plugin_pref_frame_add(frame, pref); |
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
532 |
0 | 533 return frame; |
534 } | |
535 | |
536 static PurplePluginUiInfo pref_info = | |
537 { | |
538 get_plugin_pref_frame | |
539 }; | |
540 | |
541 static PurplePluginInfo info = | |
542 { | |
543 PURPLE_PLUGIN_MAGIC, | |
544 PURPLE_MAJOR_VERSION, | |
545 PURPLE_MINOR_VERSION, | |
546 PURPLE_PLUGIN_STANDARD, /**< type */ | |
547 NULL, /**< ui_req */ | |
548 0, /**< flags */ | |
549 NULL, /**< deps */ | |
550 PURPLE_PRIORITY_DEFAULT, /**< priority */ | |
551 PIDGINAUD_PLUGIN_ID, /**< id */ | |
552 "Pidgin-Audacious", /**< name */ | |
10
7c9624c8a109
added /song command which sends name of currently playing song.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
553 "2.1.0d1", /**< version */ |
0 | 554 "Automatically updates your Pidgin status info with the currently " |
555 "playing music in Audacious.", /** summary */ | |
556 "Automatically updates your Pidgin status info with the currently " | |
557 "playing music in Audacious.", /** desc */ | |
558 "Yoshiki Yazawa (yaz@honeyplanet.jp)", /**< author */ | |
559 "http://www.honeyplanet.jp", /**< homepage */ | |
560 load_plugin, /**< load */ | |
561 unload_plugin, /**< unload */ | |
562 NULL, /**< destroy */ | |
563 NULL, /**< ui_info */ | |
564 NULL, /**< extra_info */ | |
565 &pref_info, /**< pref info */ | |
566 NULL | |
567 }; | |
568 | |
569 static void | |
570 init_plugin(PurplePlugin *plugin) | |
571 { | |
572 g_type_init(); | |
573 | |
574 /* add plugin preferences */ | |
575 purple_prefs_add_none(OPT_PIDGINAUD); | |
576 purple_prefs_add_bool(OPT_PROCESS_STATUS, TRUE); | |
577 purple_prefs_add_bool(OPT_PROCESS_USERINFO, TRUE); | |
578 purple_prefs_add_bool(OPT_PROCESS_ALIAS, TRUE); | |
11
43cb653de212
paste template has been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
10
diff
changeset
|
579 purple_prefs_add_string(OPT_PASTE_TEMPLATE, SONG_TOKEN); |
0 | 580 |
581 session = get_dbus_proxy(); | |
582 } | |
583 | |
584 PURPLE_INIT_PLUGIN(pidgin_audacious, init_plugin, info) |