libpurple/protocols/jabber/usertune.c

Fri, 22 Jan 2010 17:36:42 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Fri, 22 Jan 2010 17:36:42 +0000
changeset 29223
52c91204ecd6
parent 28322
ac8fec1d2234
child 32277
97f16af01a05
child 32438
dc8991868906
child 38258
9a6551eba09c
permissions
-rw-r--r--

jabber: Don't fetch Adhoc Commands for MUC chat members.

17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
1 /*
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
6 * source distribution.
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
7 *
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
11 * (at your option) any later version.
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
12 *
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
16 * GNU General Public License for more details.
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
17 *
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
28321
c8d617c408ab Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents: 26072
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
21 *
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
22 */
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
23
19898
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 17803
diff changeset
24 #include "internal.h"
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 17803
diff changeset
25
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
26 #include "usertune.h"
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
27 #include "pep.h"
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
28 #include <string.h>
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
29 #include "internal.h"
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
30 #include "request.h"
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
31 #include "status.h"
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
32
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
33 static void jabber_tune_cb(JabberStream *js, const char *from, xmlnode *items) {
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
34 /* it doesn't make sense to have more than one item here, so let's just pick the first one */
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
35 xmlnode *item = xmlnode_get_child(items, "item");
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
36 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE);
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
37 xmlnode *tuneinfo, *tune;
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
38 PurpleJabberTuneInfo tuneinfodata;
17802
eeefef7389a1 Removed some C99-code
Andreas Monitzer <am@adiumx.com>
parents: 17800
diff changeset
39 JabberBuddyResource *resource;
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
40 gboolean valid = FALSE;
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
41
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
42 /* ignore the tune of people not on our buddy list */
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
43 if (!buddy || !item)
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
44 return;
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
45
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
46 tuneinfodata.artist = NULL;
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
47 tuneinfodata.title = NULL;
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
48 tuneinfodata.album = NULL;
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
49 tuneinfodata.track = NULL;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
50 tuneinfodata.time = -1;
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
51 tuneinfodata.url = NULL;
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
52
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
53 tune = xmlnode_get_child_with_namespace(item, "tune", "http://jabber.org/protocol/tune");
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
54 if (!tune)
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
55 return;
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
56 resource = jabber_buddy_find_resource(buddy, NULL);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
57 if(!resource)
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
58 return; /* huh? */
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
59 for (tuneinfo = tune->child; tuneinfo; tuneinfo = tuneinfo->next) {
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
60 if (tuneinfo->type == XMLNODE_TYPE_TAG) {
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
61 if (!strcmp(tuneinfo->name, "artist")) {
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
62 if (tuneinfodata.artist == NULL) /* only pick the first one */
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
63 tuneinfodata.artist = xmlnode_get_data(tuneinfo);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
64 valid = TRUE;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
65 } else if (!strcmp(tuneinfo->name, "length")) {
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
66 if (tuneinfodata.time == -1) {
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
67 char *length = xmlnode_get_data(tuneinfo);
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
68 if (length)
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
69 tuneinfodata.time = strtol(length, NULL, 10);
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
70 g_free(length);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
71 if (tuneinfodata.time > 0)
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
72 valid = TRUE;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
73 }
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
74 } else if (!strcmp(tuneinfo->name, "source")) {
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
75 if (tuneinfodata.album == NULL) /* only pick the first one */
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
76 tuneinfodata.album = xmlnode_get_data(tuneinfo);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
77 valid = TRUE;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
78 } else if (!strcmp(tuneinfo->name, "title")) {
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
79 if (tuneinfodata.title == NULL) /* only pick the first one */
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
80 tuneinfodata.title = xmlnode_get_data(tuneinfo);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
81 valid = TRUE;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
82 } else if (!strcmp(tuneinfo->name, "track")) {
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
83 if (tuneinfodata.track == NULL) /* only pick the first one */
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
84 tuneinfodata.track = xmlnode_get_data(tuneinfo);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
85 valid = TRUE;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
86 } else if (!strcmp(tuneinfo->name, "uri")) {
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
87 if (tuneinfodata.url == NULL) /* only pick the first one */
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
88 tuneinfodata.url = xmlnode_get_data(tuneinfo);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
89 valid = TRUE;
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
90 }
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
91 }
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
92 }
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
93
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
94 if (valid) {
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
95 purple_prpl_got_user_status(js->gc->account, from, "tune",
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
96 PURPLE_TUNE_ARTIST, tuneinfodata.artist,
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
97 PURPLE_TUNE_TITLE, tuneinfodata.title,
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
98 PURPLE_TUNE_ALBUM, tuneinfodata.album,
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
99 PURPLE_TUNE_TRACK, tuneinfodata.track,
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
100 PURPLE_TUNE_TIME, tuneinfodata.time,
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
101 PURPLE_TUNE_URL, tuneinfodata.url, NULL);
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
102 } else {
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
103 purple_prpl_got_user_status_deactive(js->gc->account, from, "tune");
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
104 }
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
105
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
106 g_free(tuneinfodata.artist);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
107 g_free(tuneinfodata.title);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
108 g_free(tuneinfodata.album);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
109 g_free(tuneinfodata.track);
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
110 g_free(tuneinfodata.url);
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
111 }
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
112
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
113 void jabber_tune_init(void) {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22111
diff changeset
114 jabber_add_feature("http://jabber.org/protocol/tune", jabber_pep_namespace_only_when_pep_enabled_cb);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22111
diff changeset
115 jabber_pep_register_handler("http://jabber.org/protocol/tune", jabber_tune_cb);
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
116 }
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
117
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
118 void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo) {
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
119 xmlnode *publish, *tunenode;
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
120 JabberStream *js = gc->proto_data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22111
diff changeset
121
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
122 publish = xmlnode_new("publish");
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
123 xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/tune");
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
124 tunenode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "tune");
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
125 xmlnode_set_namespace(tunenode, "http://jabber.org/protocol/tune");
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22111
diff changeset
126
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
127 if(tuneinfo) {
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
128 if(tuneinfo->artist && tuneinfo->artist[0] != '\0')
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
129 xmlnode_insert_data(xmlnode_new_child(tunenode, "artist"),tuneinfo->artist,-1);
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
130 if(tuneinfo->title && tuneinfo->title[0] != '\0')
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
131 xmlnode_insert_data(xmlnode_new_child(tunenode, "title"),tuneinfo->title,-1);
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
132 if(tuneinfo->album && tuneinfo->album[0] != '\0')
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
133 xmlnode_insert_data(xmlnode_new_child(tunenode, "source"),tuneinfo->album,-1);
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
134 if(tuneinfo->url && tuneinfo->url[0] != '\0')
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
135 xmlnode_insert_data(xmlnode_new_child(tunenode, "uri"),tuneinfo->url,-1);
22111
7b7ed5e93969 Fixes for incorrectly displaying user tune emblem and empty current media.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21193
diff changeset
136 if(tuneinfo->time > 0) {
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
137 char *length = g_strdup_printf("%d", tuneinfo->time);
17794
80d7ab0c4652 Minor compilation fixes and corrected some typos on user tune. Added convenience function for setting the user tune.
Andreas Monitzer <am@adiumx.com>
parents: 17791
diff changeset
138 xmlnode_insert_data(xmlnode_new_child(tunenode, "length"),length,-1);
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
139 g_free(length);
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
140 }
17800
39a0f9ed0e26 Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents: 17797
diff changeset
141 if(tuneinfo->track && tuneinfo->track[0] != '\0')
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
142 xmlnode_insert_data(xmlnode_new_child(tunenode, "track"),tuneinfo->track,-1);
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
143 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22111
diff changeset
144
17791
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
145 jabber_pep_publish(js, publish);
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
146 /* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
147 (yay for well-defined memory management rules) */
b947d72db9db Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
148 }

mercurial