Mercurial > pidgin
comparison libpurple/protocols/mxit/voicevideo.c @ 31286:b8d9329dda4a
The initial protocol infrastructure for MXit Voice/Video support.
(Currently disabled with compile-time flag)
author | andrew.victor@mxit.com |
---|---|
date | Fri, 07 Jan 2011 21:51:05 +0000 |
parents | |
children | 5b51e5fb8d76 |
comparison
equal
deleted
inserted
replaced
31285:607ad979a753 | 31286:b8d9329dda4a |
---|---|
1 /* | |
2 * MXit Protocol libPurple Plugin | |
3 * | |
4 * -- voice & video -- | |
5 * | |
6 * Andrew Victor <libpurple@mxit.com> | |
7 * | |
8 * (C) Copyright 2010 MXit Lifestyle (Pty) Ltd. | |
9 * <http://www.mxitlifestyle.com> | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
24 */ | |
25 | |
26 #include "purple.h" | |
27 #include "mxit.h" | |
28 #include "roster.h" | |
29 #include "voicevideo.h" | |
30 | |
31 #if defined(USE_VV) && defined(MXIT_DEV_VV) | |
32 | |
33 #warning "MXit VV support enabled." | |
34 | |
35 /*------------------------------------------------------------------------ | |
36 * Does this client support Voice? | |
37 */ | |
38 gboolean mxit_audio_enabled(void) | |
39 { | |
40 PurpleMediaManager *manager = purple_media_manager_get(); | |
41 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager); | |
42 | |
43 return (caps & PURPLE_MEDIA_CAPS_AUDIO); | |
44 } | |
45 | |
46 /*------------------------------------------------------------------------ | |
47 * Does this client support Voice and Video? | |
48 */ | |
49 gboolean mxit_video_enabled(void) | |
50 { | |
51 PurpleMediaManager *manager = purple_media_manager_get(); | |
52 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager); | |
53 | |
54 return (caps & PURPLE_MEDIA_CAPS_VIDEO); | |
55 } | |
56 | |
57 /*------------------------------------------------------------------------ | |
58 * Return the list of media capabilities this contact supports. | |
59 * | |
60 * @param account The MXit account object | |
61 * @param who The username of the contact. | |
62 * @return The media capabilities supported | |
63 */ | |
64 PurpleMediaCaps mxit_media_caps(PurpleAccount *account, const char *who) | |
65 { | |
66 struct MXitSession* session = purple_account_get_connection(account)->proto_data; | |
67 PurpleBuddy* buddy; | |
68 struct contact* contact; | |
69 PurpleMediaCaps capa = PURPLE_MEDIA_CAPS_NONE; | |
70 | |
71 purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_caps: buddy '%s'\n", who); | |
72 | |
73 /* We need to have a voice/video server */ | |
74 if (strlen(session->voip_server) == 0) | |
75 return PURPLE_MEDIA_CAPS_NONE; | |
76 | |
77 /* find the buddy information for this contact (reference: "libpurple/blist.h") */ | |
78 buddy = purple_find_buddy(account, who); | |
79 if (!buddy) { | |
80 purple_debug_warning(MXIT_PLUGIN_ID, "mxit_media_caps: unable to find the buddy '%s'\n", who); | |
81 return PURPLE_MEDIA_CAPS_NONE; | |
82 } | |
83 | |
84 contact = purple_buddy_get_protocol_data(buddy); | |
85 if (!contact) | |
86 return PURPLE_MEDIA_CAPS_NONE; | |
87 | |
88 /* can only communicate with MXit users */ | |
89 if (contact->type != MXIT_TYPE_MXIT) | |
90 return PURPLE_MEDIA_CAPS_NONE; | |
91 | |
92 /* and only with contacts in the 'Both' subscription state */ | |
93 if (contact->subtype != MXIT_SUBTYPE_BOTH) | |
94 return PURPLE_MEDIA_CAPS_NONE; | |
95 | |
96 /* and only when they're online */ | |
97 if (contact->presence == MXIT_PRESENCE_OFFLINE) | |
98 return MXIT_PRESENCE_OFFLINE; | |
99 | |
100 /* they support voice-only */ | |
101 if (contact->capabilities & MXIT_PFLAG_VOICE) | |
102 capa |= PURPLE_MEDIA_CAPS_AUDIO; | |
103 | |
104 /* they support voice-and-video */ | |
105 if (contact->capabilities & MXIT_PFLAG_VIDEO) | |
106 capa |= (PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_VIDEO | PURPLE_MEDIA_CAPS_AUDIO_VIDEO); | |
107 | |
108 return capa; | |
109 } | |
110 | |
111 | |
112 /*------------------------------------------------------------------------ | |
113 * Initiate a voice/video session with a contact. | |
114 * | |
115 * @param account The MXit account object | |
116 * @param who The username of the contact. | |
117 * @param type The type of media session to initiate | |
118 * @return TRUE if session was initiated | |
119 */ | |
120 gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type) | |
121 { | |
122 purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: buddy '%s'\n", who); | |
123 | |
124 return FALSE; | |
125 } | |
126 | |
127 #else | |
128 | |
129 /* | |
130 * Voice and Video not supported. | |
131 */ | |
132 | |
133 gboolean mxit_audio_enabled(void) | |
134 { | |
135 return FALSE; | |
136 } | |
137 | |
138 gboolean mxit_video_enabled(void) | |
139 { | |
140 return FALSE; | |
141 } | |
142 | |
143 PurpleMediaCaps mxit_media_caps(PurpleAccount *account, const char *who) | |
144 { | |
145 return PURPLE_MEDIA_CAPS_NONE; | |
146 } | |
147 | |
148 gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type) | |
149 { | |
150 return FALSE; | |
151 } | |
152 | |
153 #endif | |
154 |