1 /* |
|
2 * capabilities.c - Connection.Interface.Capabilities constants and utilities |
|
3 * Copyright (C) 2005 Collabora Ltd. |
|
4 * |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Lesser General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2.1 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Lesser General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public |
|
17 * License along with this library; if not, write to the Free Software |
|
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 */ |
|
20 |
|
21 #include "capabilities.h" |
|
22 |
|
23 #include "namespaces.h" |
|
24 #include "config.h" |
|
25 #include "gabble-presence-cache.h" |
|
26 #include "telepathy-interfaces.h" |
|
27 #include "gabble-media-channel.h" |
|
28 |
|
29 static const Feature self_advertised_features[] = |
|
30 { |
|
31 { VERSION, NS_GOOGLE_FEAT_SESSION, 0}, |
|
32 { VERSION, NS_GOOGLE_TRANSPORT_P2P, PRESENCE_CAP_GOOGLE_TRANSPORT_P2P}, |
|
33 { VERSION, NS_JINGLE, PRESENCE_CAP_JINGLE}, |
|
34 |
|
35 { BUNDLE_VOICE_V1, NS_GOOGLE_FEAT_VOICE, PRESENCE_CAP_GOOGLE_VOICE}, |
|
36 { BUNDLE_JINGLE_AUDIO, NS_JINGLE_DESCRIPTION_AUDIO, PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO}, |
|
37 { BUNDLE_JINGLE_VIDEO, NS_JINGLE_DESCRIPTION_VIDEO, PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO}, |
|
38 { NULL, NULL, 0} |
|
39 }; |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 GSList * |
|
45 capabilities_get_features (GabblePresenceCapabilities caps) |
|
46 { |
|
47 GSList *features = NULL; |
|
48 const Feature *i; |
|
49 |
|
50 for (i = self_advertised_features; NULL != i->ns; i++) |
|
51 if ((i->caps & caps) == i->caps) |
|
52 features = g_slist_append (features, (gpointer) i); |
|
53 |
|
54 return features; |
|
55 } |
|
56 |
|
57 void |
|
58 capabilities_fill_cache (GabblePresenceCache *cache) |
|
59 { |
|
60 const Feature *feat; |
|
61 for (feat = self_advertised_features; NULL != feat->ns; feat++) |
|
62 { |
|
63 gchar *node = g_strconcat (NS_GABBLE_CAPS "#", feat->bundle, NULL); |
|
64 gabble_presence_cache_add_bundle_caps (cache, |
|
65 node, feat->caps); |
|
66 g_free (node); |
|
67 } |
|
68 |
|
69 gabble_presence_cache_add_bundle_caps (cache, |
|
70 "http://www.google.com/xmpp/client/caps#voice-v1", |
|
71 PRESENCE_CAP_GOOGLE_VOICE); |
|
72 } |
|
73 |
|
74 GabblePresenceCapabilities |
|
75 capabilities_get_initial_caps () |
|
76 { |
|
77 GabblePresenceCapabilities ret = 0; |
|
78 const Feature *feat; |
|
79 |
|
80 for (feat = self_advertised_features; NULL != feat->ns; feat++) |
|
81 { |
|
82 if (g_str_equal (feat->bundle, VERSION)) |
|
83 /* VERSION == bundle means a fixed feature, which we always advertise */ |
|
84 ret |= feat->caps; |
|
85 } |
|
86 |
|
87 return ret; |
|
88 } |
|
89 |
|
90 const CapabilityConversionData capabilities_conversions[] = |
|
91 { |
|
92 { TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, |
|
93 _gabble_media_channel_typeflags_to_caps_tmp, /*_gabble_media_channel_typeflags_to_caps,*/ |
|
94 _gabble_media_channel_caps_to_typeflags_tmp /*_gabble_media_channel_caps_to_typeflags*/ }, |
|
95 { NULL, NULL, NULL} |
|
96 }; |
|
97 |
|