Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/jabber.c @ 29754:5dec9d90fb51
propagate from branch 'im.pidgin.pidgin' (head d14a1fe9d288c6942c8bfc6d1df3c8297ba7ca54)
to branch 'im.pidgin.pidgin.next.minor' (head 8761a76439ad0ebb03090ebdd75ca3aa5422d105)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 11 Feb 2010 04:38:48 +0000 |
parents | 422889fb57e0 9e735d7e2f1d |
children | 2ad2e3490b23 |
comparison
equal
deleted
inserted
replaced
29753:05d727f76ca9 | 29754:5dec9d90fb51 |
---|---|
3140 #ifdef USE_VV | 3140 #ifdef USE_VV |
3141 JabberStream *js = (JabberStream *) | 3141 JabberStream *js = (JabberStream *) |
3142 purple_account_get_connection(account)->proto_data; | 3142 purple_account_get_connection(account)->proto_data; |
3143 JabberBuddy *jb; | 3143 JabberBuddy *jb; |
3144 JabberBuddyResource *jbr; | 3144 JabberBuddyResource *jbr; |
3145 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE; | 3145 PurpleMediaCaps total = PURPLE_MEDIA_CAPS_NONE; |
3146 gchar *resource; | 3146 gchar *resource; |
3147 GList *specific = NULL, *l; | |
3147 | 3148 |
3148 if (!js) { | 3149 if (!js) { |
3149 purple_debug_info("jabber", | 3150 purple_debug_info("jabber", |
3150 "jabber_can_do_media: NULL stream\n"); | 3151 "jabber_can_do_media: NULL stream\n"); |
3151 return FALSE; | 3152 return FALSE; |
3152 } | 3153 } |
3153 | 3154 |
3154 if ((resource = jabber_get_resource(who)) != NULL) { | 3155 jb = jabber_buddy_find(js, who, FALSE); |
3156 | |
3157 if (!jb || !jb->resources) { | |
3158 /* no resources online, we're trying to get caps for someone | |
3159 * whose presence we're not subscribed to, or | |
3160 * someone who is offline. */ | |
3161 return total; | |
3162 | |
3163 } else if ((resource = jabber_get_resource(who)) != NULL) { | |
3155 /* they've specified a resource, no need to ask or | 3164 /* they've specified a resource, no need to ask or |
3156 * default or anything, just do it */ | 3165 * default or anything, just do it */ |
3157 | |
3158 jb = jabber_buddy_find(js, who, FALSE); | |
3159 jbr = jabber_buddy_find_resource(jb, resource); | 3166 jbr = jabber_buddy_find_resource(jb, resource); |
3160 g_free(resource); | 3167 g_free(resource); |
3161 | 3168 |
3162 if (!jbr) { | 3169 if (!jbr) { |
3163 purple_debug_error("jabber", "jabber_get_media_caps:" | 3170 purple_debug_error("jabber", "jabber_get_media_caps:" |
3164 " Can't find resource %s\n", who); | 3171 " Can't find resource %s\n", who); |
3165 return caps; | 3172 return total; |
3166 } | 3173 } |
3174 | |
3175 l = specific = g_list_prepend(specific, jbr); | |
3176 | |
3177 } else { | |
3178 /* we've got multiple resources, combine their caps */ | |
3179 l = jb->resources; | |
3180 } | |
3181 | |
3182 for (; l; l = l->next) { | |
3183 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE; | |
3184 jbr = l->data; | |
3167 | 3185 |
3168 if (jabber_resource_has_capability(jbr, | 3186 if (jabber_resource_has_capability(jbr, |
3169 JINGLE_APP_RTP_SUPPORT_AUDIO)) | 3187 JINGLE_APP_RTP_SUPPORT_AUDIO)) |
3170 caps |= PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION | | 3188 caps |= PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION | |
3171 PURPLE_MEDIA_CAPS_AUDIO; | 3189 PURPLE_MEDIA_CAPS_AUDIO; |
3191 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) { | 3209 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE)) { |
3192 caps |= PURPLE_MEDIA_CAPS_AUDIO; | 3210 caps |= PURPLE_MEDIA_CAPS_AUDIO; |
3193 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO)) | 3211 if (jabber_resource_has_capability(jbr, NS_GOOGLE_VIDEO)) |
3194 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO; | 3212 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO; |
3195 } | 3213 } |
3196 return caps; | 3214 |
3197 } | 3215 total |= caps; |
3198 | 3216 } |
3199 jb = jabber_buddy_find(js, who, FALSE); | 3217 |
3200 | 3218 if (specific) { |
3201 if(!jb || !jb->resources) { | 3219 g_list_free(specific); |
3202 /* no resources online, we're trying to get caps for someone | 3220 } |
3203 * whose presence we're not subscribed to, or | 3221 |
3204 * someone who is offline. */ | 3222 return total; |
3205 return caps; | |
3206 } else if(!jb->resources->next) { | |
3207 /* only 1 resource online (probably our most common case) */ | |
3208 gchar *name; | |
3209 jbr = jb->resources->data; | |
3210 name = g_strdup_printf("%s/%s", who, jbr->name); | |
3211 caps = jabber_get_media_caps(account, name); | |
3212 g_free(name); | |
3213 } else { | |
3214 /* we've got multiple resources, combine their caps */ | |
3215 GList *l; | |
3216 | |
3217 for(l = jb->resources; l; l = l->next) | |
3218 { | |
3219 gchar *name; | |
3220 jbr = l->data; | |
3221 name = g_strdup_printf("%s/%s", who, jbr->name); | |
3222 caps |= jabber_get_media_caps(account, name); | |
3223 g_free(name); | |
3224 } | |
3225 } | |
3226 | |
3227 return caps; | |
3228 #else | 3223 #else |
3229 return PURPLE_MEDIA_CAPS_NONE; | 3224 return PURPLE_MEDIA_CAPS_NONE; |
3230 #endif | 3225 #endif |
3231 } | 3226 } |
3232 | 3227 |