Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/usertune.c @ 20276:c1d3d25e8c49
Merged xmpp leak fixes
applied changes from 73d2587302ffbbe62f6b7f3e745508c0687813ba
through db4583bc475b46b7cb9baa38229f12473d331870
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sat, 29 Sep 2007 04:24:59 +0000 |
parents | ab38146f8f78 |
children | 5913725cbcd6 |
comparison
equal
deleted
inserted
replaced
20275:9ad7979b4838 | 20276:c1d3d25e8c49 |
---|---|
39 | 39 |
40 /* ignore the tune of people not on our buddy list */ | 40 /* ignore the tune of people not on our buddy list */ |
41 if (!buddy || !item) | 41 if (!buddy || !item) |
42 return; | 42 return; |
43 | 43 |
44 tuneinfodata.artist = ""; | 44 tuneinfodata.artist = NULL; |
45 tuneinfodata.title = ""; | 45 tuneinfodata.title = NULL; |
46 tuneinfodata.album = ""; | 46 tuneinfodata.album = NULL; |
47 tuneinfodata.track = ""; | 47 tuneinfodata.track = NULL; |
48 tuneinfodata.time = -1; | 48 tuneinfodata.time = -1; |
49 tuneinfodata.url = ""; | 49 tuneinfodata.url = NULL; |
50 | 50 |
51 tune = xmlnode_get_child_with_namespace(item, "tune", "http://jabber.org/protocol/tune"); | 51 tune = xmlnode_get_child_with_namespace(item, "tune", "http://jabber.org/protocol/tune"); |
52 if (!tune) | 52 if (!tune) |
53 return; | 53 return; |
54 resource = jabber_buddy_find_resource(buddy, NULL); | |
55 if(!resource) | |
56 return; /* huh? */ | |
54 for (tuneinfo = tune->child; tuneinfo; tuneinfo = tuneinfo->next) { | 57 for (tuneinfo = tune->child; tuneinfo; tuneinfo = tuneinfo->next) { |
55 if (tuneinfo->type == XMLNODE_TYPE_TAG) { | 58 if (tuneinfo->type == XMLNODE_TYPE_TAG) { |
56 if (!strcmp(tuneinfo->name, "artist")) { | 59 if (!strcmp(tuneinfo->name, "artist")) { |
57 if (tuneinfodata.artist[0] == '\0') /* only pick the first one */ | 60 if (tuneinfodata.artist == NULL) /* only pick the first one */ |
58 tuneinfodata.artist = xmlnode_get_data(tuneinfo); | 61 tuneinfodata.artist = xmlnode_get_data(tuneinfo); |
59 } else if (!strcmp(tuneinfo->name, "length")) { | 62 } else if (!strcmp(tuneinfo->name, "length")) { |
60 if (tuneinfodata.time == -1) { | 63 if (tuneinfodata.time == -1) { |
61 char *length = xmlnode_get_data(tuneinfo); | 64 char *length = xmlnode_get_data(tuneinfo); |
62 if (length) | 65 if (length) |
63 tuneinfodata.time = strtol(length, NULL, 10); | 66 tuneinfodata.time = strtol(length, NULL, 10); |
67 g_free(length); | |
64 } | 68 } |
65 } else if (!strcmp(tuneinfo->name, "source")) { | 69 } else if (!strcmp(tuneinfo->name, "source")) { |
66 if (tuneinfodata.album[0] == '\0') /* only pick the first one */ | 70 if (tuneinfodata.album == NULL) /* only pick the first one */ |
67 tuneinfodata.album = xmlnode_get_data(tuneinfo); | 71 tuneinfodata.album = xmlnode_get_data(tuneinfo); |
68 } else if (!strcmp(tuneinfo->name, "title")) { | 72 } else if (!strcmp(tuneinfo->name, "title")) { |
69 if (tuneinfodata.title[0] == '\0') /* only pick the first one */ | 73 if (tuneinfodata.title == NULL) /* only pick the first one */ |
70 tuneinfodata.title = xmlnode_get_data(tuneinfo); | 74 tuneinfodata.title = xmlnode_get_data(tuneinfo); |
71 } else if (!strcmp(tuneinfo->name, "track")) { | 75 } else if (!strcmp(tuneinfo->name, "track")) { |
72 if (tuneinfodata.track[0] == '\0') /* only pick the first one */ | 76 if (tuneinfodata.track == NULL) /* only pick the first one */ |
73 tuneinfodata.track = xmlnode_get_data(tuneinfo); | 77 tuneinfodata.track = xmlnode_get_data(tuneinfo); |
74 } else if (!strcmp(tuneinfo->name, "uri")) { | 78 } else if (!strcmp(tuneinfo->name, "uri")) { |
75 if (tuneinfodata.url[0] == '\0') /* only pick the first one */ | 79 if (tuneinfodata.url == NULL) /* only pick the first one */ |
76 tuneinfodata.url = xmlnode_get_data(tuneinfo); | 80 tuneinfodata.url = xmlnode_get_data(tuneinfo); |
77 } | 81 } |
78 } | 82 } |
79 } | 83 } |
80 resource = jabber_buddy_find_resource(buddy, NULL); | |
81 if(!resource) | |
82 return; /* huh? */ | |
83 status_id = jabber_buddy_state_get_status_id(resource->state); | 84 status_id = jabber_buddy_state_get_status_id(resource->state); |
84 | 85 |
85 purple_prpl_got_user_status(js->gc->account, from, status_id, PURPLE_TUNE_ARTIST, tuneinfodata.artist, PURPLE_TUNE_TITLE, tuneinfodata.title, PURPLE_TUNE_ALBUM, tuneinfodata.album, PURPLE_TUNE_TRACK, tuneinfodata.track, PURPLE_TUNE_TIME, tuneinfodata.time, PURPLE_TUNE_URL, tuneinfodata.url, NULL); | 86 purple_prpl_got_user_status(js->gc->account, from, status_id, |
87 PURPLE_TUNE_ARTIST, tuneinfodata.artist, | |
88 PURPLE_TUNE_TITLE, tuneinfodata.title, | |
89 PURPLE_TUNE_ALBUM, tuneinfodata.album, | |
90 PURPLE_TUNE_TRACK, tuneinfodata.track, | |
91 PURPLE_TUNE_TIME, tuneinfodata.time, | |
92 PURPLE_TUNE_URL, tuneinfodata.url, NULL); | |
93 | |
94 g_free(tuneinfodata.artist); | |
95 g_free(tuneinfodata.title); | |
96 g_free(tuneinfodata.album); | |
97 g_free(tuneinfodata.track); | |
98 g_free(tuneinfodata.url); | |
86 } | 99 } |
87 | 100 |
88 void jabber_tune_init(void) { | 101 void jabber_tune_init(void) { |
89 jabber_add_feature("tune", "http://jabber.org/protocol/tune", jabber_pep_namespace_only_when_pep_enabled_cb); | 102 jabber_add_feature("tune", "http://jabber.org/protocol/tune", jabber_pep_namespace_only_when_pep_enabled_cb); |
90 jabber_pep_register_handler("tunen", "http://jabber.org/protocol/tune", jabber_tune_cb); | 103 jabber_pep_register_handler("tunen", "http://jabber.org/protocol/tune", jabber_tune_cb); |