Mercurial > pidgin
annotate libpurple/protocols/jabber/usertune.c @ 21562:926970c64bd2
merge of '201e11a069d84d6e66abf5192dbb2083233beb4c'
and 'a3ce66d03a900d5475b414ed3bad0c3d5bad2456'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 17 Nov 2007 01:45:03 +0000 |
parents | 5913725cbcd6 |
children | cacc01b50a23 |
rev | line source |
---|---|
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
1 /* |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
2 * purple - Jabber Protocol Plugin |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
3 * |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com> |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
5 * |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
9 * (at your option) any later version. |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
10 * |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
15 * |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
19 * |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
20 */ |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
21 |
19698
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17869
diff
changeset
|
22 #include "internal.h" |
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17869
diff
changeset
|
23 |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
24 #include "usertune.h" |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
25 #include "pep.h" |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
26 #include <string.h> |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
27 #include "internal.h" |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
28 #include "request.h" |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
29 #include "status.h" |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
30 |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
31 static void jabber_tune_cb(JabberStream *js, const char *from, xmlnode *items) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
32 /* it doesn't make sense to have more than one item here, so let's just pick the first one */ |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
33 xmlnode *item = xmlnode_get_child(items, "item"); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
34 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
35 xmlnode *tuneinfo, *tune; |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
36 PurpleJabberTuneInfo tuneinfodata; |
17868
6820304c215f
Removed some C99-code
Andreas Monitzer <pidgin@monitzer.com>
parents:
17866
diff
changeset
|
37 JabberBuddyResource *resource; |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
38 |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
39 /* ignore the tune of people not on our buddy list */ |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
40 if (!buddy || !item) |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
41 return; |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
42 |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
43 tuneinfodata.artist = NULL; |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
44 tuneinfodata.title = NULL; |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
45 tuneinfodata.album = NULL; |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
46 tuneinfodata.track = NULL; |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
47 tuneinfodata.time = -1; |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
48 tuneinfodata.url = NULL; |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
49 |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
50 tune = xmlnode_get_child_with_namespace(item, "tune", "http://jabber.org/protocol/tune"); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
51 if (!tune) |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
52 return; |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
53 resource = jabber_buddy_find_resource(buddy, NULL); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
54 if(!resource) |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
55 return; /* huh? */ |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
56 for (tuneinfo = tune->child; tuneinfo; tuneinfo = tuneinfo->next) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
57 if (tuneinfo->type == XMLNODE_TYPE_TAG) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
58 if (!strcmp(tuneinfo->name, "artist")) { |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
59 if (tuneinfodata.artist == NULL) /* only pick the first one */ |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
60 tuneinfodata.artist = xmlnode_get_data(tuneinfo); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
61 } else if (!strcmp(tuneinfo->name, "length")) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
62 if (tuneinfodata.time == -1) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
63 char *length = xmlnode_get_data(tuneinfo); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
64 if (length) |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
65 tuneinfodata.time = strtol(length, NULL, 10); |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
66 g_free(length); |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
67 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
68 } else if (!strcmp(tuneinfo->name, "source")) { |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
69 if (tuneinfodata.album == NULL) /* only pick the first one */ |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
70 tuneinfodata.album = xmlnode_get_data(tuneinfo); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
71 } else if (!strcmp(tuneinfo->name, "title")) { |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
72 if (tuneinfodata.title == NULL) /* only pick the first one */ |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
73 tuneinfodata.title = xmlnode_get_data(tuneinfo); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
74 } else if (!strcmp(tuneinfo->name, "track")) { |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
75 if (tuneinfodata.track == NULL) /* only pick the first one */ |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
76 tuneinfodata.track = xmlnode_get_data(tuneinfo); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
77 } else if (!strcmp(tuneinfo->name, "uri")) { |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
78 if (tuneinfodata.url == NULL) /* only pick the first one */ |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
79 tuneinfodata.url = xmlnode_get_data(tuneinfo); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
80 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
81 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
82 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
83 |
20570
5913725cbcd6
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20058
diff
changeset
|
84 purple_prpl_got_user_status(js->gc->account, from, "tune", |
20058
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
85 PURPLE_TUNE_ARTIST, tuneinfodata.artist, |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
86 PURPLE_TUNE_TITLE, tuneinfodata.title, |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
87 PURPLE_TUNE_ALBUM, tuneinfodata.album, |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
88 PURPLE_TUNE_TRACK, tuneinfodata.track, |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
89 PURPLE_TUNE_TIME, tuneinfodata.time, |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
90 PURPLE_TUNE_URL, tuneinfodata.url, NULL); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
91 |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
92 g_free(tuneinfodata.artist); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
93 g_free(tuneinfodata.title); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
94 g_free(tuneinfodata.album); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
95 g_free(tuneinfodata.track); |
5103485b4b26
Plug some memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20000
diff
changeset
|
96 g_free(tuneinfodata.url); |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
97 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
98 |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
99 void jabber_tune_init(void) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
100 jabber_add_feature("tune", "http://jabber.org/protocol/tune", jabber_pep_namespace_only_when_pep_enabled_cb); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
101 jabber_pep_register_handler("tunen", "http://jabber.org/protocol/tune", jabber_tune_cb); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
102 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
103 |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
104 void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo) { |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
105 xmlnode *publish, *tunenode; |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
106 JabberStream *js = gc->proto_data; |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
107 |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
108 publish = xmlnode_new("publish"); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
109 xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/tune"); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
110 tunenode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "tune"); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
111 xmlnode_set_namespace(tunenode, "http://jabber.org/protocol/tune"); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
112 |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
113 if(tuneinfo) { |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
114 if(tuneinfo->artist && tuneinfo->artist[0] != '\0') |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
115 xmlnode_insert_data(xmlnode_new_child(tunenode, "artist"),tuneinfo->artist,-1); |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
116 if(tuneinfo->title && tuneinfo->title[0] != '\0') |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
117 xmlnode_insert_data(xmlnode_new_child(tunenode, "title"),tuneinfo->title,-1); |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
118 if(tuneinfo->album && tuneinfo->album[0] != '\0') |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
119 xmlnode_insert_data(xmlnode_new_child(tunenode, "source"),tuneinfo->album,-1); |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
120 if(tuneinfo->url && tuneinfo->url[0] != '\0') |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
121 xmlnode_insert_data(xmlnode_new_child(tunenode, "uri"),tuneinfo->url,-1); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
122 if(tuneinfo->time >= 0) { |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
123 char *length = g_strdup_printf("%d", tuneinfo->time); |
17860
84638e3af1bc
Minor compilation fixes and corrected some typos on user tune. Added convenience function for setting the user tune.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17857
diff
changeset
|
124 xmlnode_insert_data(xmlnode_new_child(tunenode, "length"),length,-1); |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
125 g_free(length); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
126 } |
17866
759cd72bd2ff
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 <pidgin@monitzer.com>
parents:
17863
diff
changeset
|
127 if(tuneinfo->track && tuneinfo->track[0] != '\0') |
17857
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
128 xmlnode_insert_data(xmlnode_new_child(tunenode, "track"),tuneinfo->track,-1); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
129 } |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
130 |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
131 jabber_pep_publish(js, publish); |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
132 /* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
133 (yay for well-defined memory management rules) */ |
3e437e86bd6e
Implemented user tune, currently untested.
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
134 } |