Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/jabber.c @ 29413:7cab6dc6b79c
Fix jabber_get_media_caps for buddies with a single resource that has no
name. I don't believe the resource is required, and Facebook doesn't have
them, causing a NULL-printf crash on Windows.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 11 Feb 2010 03:59:56 +0000 |
parents | 1cf9103727f2 |
children | 9e735d7e2f1d |
comparison
equal
deleted
inserted
replaced
29412:64bee7ae306f | 29413:7cab6dc6b79c |
---|---|
3146 purple_account_get_connection(account)->proto_data; | 3146 purple_account_get_connection(account)->proto_data; |
3147 JabberBuddy *jb; | 3147 JabberBuddy *jb; |
3148 JabberBuddyResource *jbr; | 3148 JabberBuddyResource *jbr; |
3149 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE; | 3149 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE; |
3150 gchar *resource; | 3150 gchar *resource; |
3151 GList *specific = NULL, *l; | |
3151 | 3152 |
3152 if (!js) { | 3153 if (!js) { |
3153 purple_debug_info("jabber", | 3154 purple_debug_info("jabber", |
3154 "jabber_can_do_media: NULL stream\n"); | 3155 "jabber_can_do_media: NULL stream\n"); |
3155 return FALSE; | 3156 return FALSE; |
3156 } | 3157 } |
3157 | 3158 |
3158 if ((resource = jabber_get_resource(who)) != NULL) { | 3159 jb = jabber_buddy_find(js, who, FALSE); |
3160 | |
3161 if (!jb || !jb->resources) { | |
3162 /* no resources online, we're trying to get caps for someone | |
3163 * whose presence we're not subscribed to, or | |
3164 * someone who is offline. */ | |
3165 return caps; | |
3166 | |
3167 } else if ((resource = jabber_get_resource(who)) != NULL) { | |
3159 /* they've specified a resource, no need to ask or | 3168 /* they've specified a resource, no need to ask or |
3160 * default or anything, just do it */ | 3169 * default or anything, just do it */ |
3161 | |
3162 jb = jabber_buddy_find(js, who, FALSE); | |
3163 jbr = jabber_buddy_find_resource(jb, resource); | 3170 jbr = jabber_buddy_find_resource(jb, resource); |
3164 g_free(resource); | 3171 g_free(resource); |
3165 | 3172 |
3166 if (!jbr) { | 3173 if (!jbr) { |
3167 purple_debug_error("jabber", "jabber_get_media_caps:" | 3174 purple_debug_error("jabber", "jabber_get_media_caps:" |
3168 " Can't find resource %s\n", who); | 3175 " Can't find resource %s\n", who); |
3169 return caps; | 3176 return caps; |
3170 } | 3177 } |
3178 | |
3179 l = specific = g_list_prepend(specific, jbr); | |
3180 | |
3181 } else { | |
3182 /* we've got multiple resources, combine their caps */ | |
3183 l = jb->resources; | |
3184 } | |
3185 | |
3186 for (; l; l = l->next) { | |
3187 jbr = l->data; | |
3171 | 3188 |
3172 if (jabber_resource_has_capability(jbr, | 3189 if (jabber_resource_has_capability(jbr, |
3173 JINGLE_APP_RTP_SUPPORT_AUDIO)) | 3190 JINGLE_APP_RTP_SUPPORT_AUDIO)) |
3174 caps |= PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION | | 3191 caps |= PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION | |
3175 PURPLE_MEDIA_CAPS_AUDIO; | 3192 PURPLE_MEDIA_CAPS_AUDIO; |
3195 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) { | 3212 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) { |
3196 caps |= PURPLE_MEDIA_CAPS_AUDIO; | 3213 caps |= PURPLE_MEDIA_CAPS_AUDIO; |
3197 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO)) | 3214 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO)) |
3198 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO; | 3215 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO; |
3199 } | 3216 } |
3200 return caps; | 3217 } |
3201 } | 3218 |
3202 | 3219 if (specific) { |
3203 jb = jabber_buddy_find(js, who, FALSE); | 3220 g_list_free(specific); |
3204 | |
3205 if(!jb || !jb->resources) { | |
3206 /* no resources online, we're trying to get caps for someone | |
3207 * whose presence we're not subscribed to, or | |
3208 * someone who is offline. */ | |
3209 return caps; | |
3210 } else if(!jb->resources->next) { | |
3211 /* only 1 resource online (probably our most common case) */ | |
3212 gchar *name; | |
3213 jbr = jb->resources->data; | |
3214 name = g_strdup_printf("%s/%s", who, jbr->name); | |
3215 caps = jabber_get_media_caps(account, name); | |
3216 g_free(name); | |
3217 } else { | |
3218 /* we've got multiple resources, combine their caps */ | |
3219 GList *l; | |
3220 | |
3221 for(l = jb->resources; l; l = l->next) | |
3222 { | |
3223 gchar *name; | |
3224 jbr = l->data; | |
3225 name = g_strdup_printf("%s/%s", who, jbr->name); | |
3226 caps |= jabber_get_media_caps(account, name); | |
3227 g_free(name); | |
3228 } | |
3229 } | 3221 } |
3230 | 3222 |
3231 return caps; | 3223 return caps; |
3232 #else | 3224 #else |
3233 return PURPLE_MEDIA_CAPS_NONE; | 3225 return PURPLE_MEDIA_CAPS_NONE; |