annotate libpurple/protocols/mxit/voicevideo.c @ 32214:75d20c9836c1

Remove the deprecated purple_network_listen(), and rename the newer purple_network_listen_family() to renamed to purple_network_listen().
author andrew.victor@mxit.com
date Sat, 24 Sep 2011 20:36:47 +0000
parents 4b15c5c68aa4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
1 /*
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
2 * MXit Protocol libPurple Plugin
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
3 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
4 * -- voice & video --
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
5 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
6 * Andrew Victor <libpurple@mxit.com>
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
7 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
8 * (C) Copyright 2010 MXit Lifestyle (Pty) Ltd.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
9 * <http://www.mxitlifestyle.com>
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
10 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
14 * (at your option) any later version.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
15 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
19 * GNU General Public License for more details.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
20 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
24 */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
25
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
26 #include "purple.h"
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
27 #include "mxit.h"
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
28 #include "roster.h"
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
29 #include "voicevideo.h"
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
30
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
31 #if defined(USE_VV) && defined(MXIT_DEV_VV)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
32
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
33 #warning "MXit VV support enabled."
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
34
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
35 /*------------------------------------------------------------------------
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
36 * Does this client support Voice?
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
37 */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
38 gboolean mxit_audio_enabled(void)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
39 {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
40 PurpleMediaManager *manager = purple_media_manager_get();
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
41 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
42
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
43 return (caps & PURPLE_MEDIA_CAPS_AUDIO);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
44 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
45
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
46 /*------------------------------------------------------------------------
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
47 * Does this client support Voice and Video?
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
48 */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
49 gboolean mxit_video_enabled(void)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
50 {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
51 PurpleMediaManager *manager = purple_media_manager_get();
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
52 PurpleMediaCaps caps = purple_media_manager_get_ui_caps(manager);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
53
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
54 return (caps & PURPLE_MEDIA_CAPS_VIDEO);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
55 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
56
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
57 /*------------------------------------------------------------------------
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
58 * Return the list of media capabilities this contact supports.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
59 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
60 * @param account The MXit account object
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
61 * @param who The username of the contact.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
62 * @return The media capabilities supported
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
63 */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
64 PurpleMediaCaps mxit_media_caps(PurpleAccount *account, const char *who)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
65 {
31935
4b15c5c68aa4 Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents: 31906
diff changeset
66 struct MXitSession* session = purple_connection_get_protocol_data(purple_account_get_connection(account));
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
67 PurpleBuddy* buddy;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
68 struct contact* contact;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
69 PurpleMediaCaps capa = PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
70
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
71 purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_caps: buddy '%s'\n", who);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
72
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
73 /* We need to have a voice/video server */
31906
e8d4755ef84b Don't use strlen() when you're just checking whether a string is
Mark Doliner <mark@kingant.net>
parents: 31882
diff changeset
74 if (!*session->voip_server)
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
75 return PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
76
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
77 /* find the buddy information for this contact (reference: "libpurple/blist.h") */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
78 buddy = purple_find_buddy(account, who);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
79 if (!buddy) {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
80 purple_debug_warning(MXIT_PLUGIN_ID, "mxit_media_caps: unable to find the buddy '%s'\n", who);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
81 return PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
82 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
83
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
84 contact = purple_buddy_get_protocol_data(buddy);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
85 if (!contact)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
86 return PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
87
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
88 /* can only communicate with MXit users */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
89 if (contact->type != MXIT_TYPE_MXIT)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
90 return PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
91
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
92 /* and only with contacts in the 'Both' subscription state */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
93 if (contact->subtype != MXIT_SUBTYPE_BOTH)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
94 return PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
95
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
96 /* and only when they're online */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
97 if (contact->presence == MXIT_PRESENCE_OFFLINE)
31882
94b71f521edb Returning wrong value here.
andrew.victor@mxit.com
parents: 31640
diff changeset
98 return PURPLE_MEDIA_CAPS_NONE;
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
99
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
100 /* they support voice-only */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
101 if (contact->capabilities & MXIT_PFLAG_VOICE)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
102 capa |= PURPLE_MEDIA_CAPS_AUDIO;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
103
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
104 /* they support voice-and-video */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
105 if (contact->capabilities & MXIT_PFLAG_VIDEO)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
106 capa |= (PURPLE_MEDIA_CAPS_AUDIO | PURPLE_MEDIA_CAPS_VIDEO | PURPLE_MEDIA_CAPS_AUDIO_VIDEO);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
107
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
108 return capa;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
109 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
110
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
111
31640
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
112 static void mxit_candidates_prepared_cb(PurpleMedia* media, gchar* sessionid, gchar* who, void* session)
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
113 {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
114 purple_debug_info(MXIT_PLUGIN_ID, "mxit_candidates_prepared_cb: buddy '%s', session '%s'\n", who, sessionid);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
115
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
116 if (purple_media_is_initiator(media, sessionid, who)) {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
117 // TODO: Send INVITE via SIP.
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
118 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
119 else {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
120 // TODO: ??
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
121 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
122 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
123
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
124 static void mxit_stream_info_cb(PurpleMedia* media, PurpleMediaInfoType type, char* sessionid, gchar* who, gboolean local, void* session)
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
125 {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
126 purple_debug_info(MXIT_PLUGIN_ID, "mxit_stream_info_cb: buddy '%s', session '%s', info %d \n", who, sessionid, type);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
127
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
128 switch (type) {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
129 case PURPLE_MEDIA_INFO_HANGUP:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
130 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
131 case PURPLE_MEDIA_INFO_ACCEPT:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
132 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
133 case PURPLE_MEDIA_INFO_REJECT:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
134 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
135 case PURPLE_MEDIA_INFO_MUTE:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
136 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
137 case PURPLE_MEDIA_INFO_UNMUTE:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
138 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
139 case PURPLE_MEDIA_INFO_PAUSE:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
140 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
141 case PURPLE_MEDIA_INFO_UNPAUSE:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
142 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
143 case PURPLE_MEDIA_INFO_HOLD:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
144 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
145 case PURPLE_MEDIA_INFO_UNHOLD:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
146 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
147 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
148 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
149
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
150 static void mxit_state_changed_cb(PurpleMedia* media, PurpleMediaState state, gchar* sessionid, char* who, void* session)
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
151 {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
152 purple_debug_info(MXIT_PLUGIN_ID, "mxit_state_changed_cb: buddy '%s', session '%s', state %d\n", who, sessionid, state);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
153
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
154 switch (state) {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
155 case PURPLE_MEDIA_STATE_NEW:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
156 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
157 case PURPLE_MEDIA_STATE_CONNECTED:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
158 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
159 case PURPLE_MEDIA_STATE_END:
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
160 break;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
161 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
162 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
163
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
164
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
165 /*------------------------------------------------------------------------
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
166 * Initiate a voice/video session with a contact.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
167 *
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
168 * @param account The MXit account object
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
169 * @param who The username of the contact.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
170 * @param type The type of media session to initiate
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
171 * @return TRUE if session was initiated
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
172 */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
173 gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
174 {
31640
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
175 gchar* transmitter = "rawudp";
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
176 PurpleMedia* media = NULL;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
177
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
178 purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: buddy '%s'\n", who);
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
179
31640
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
180 media = purple_media_manager_create_media(
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
181 purple_media_manager_get(),
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
182 account,
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
183 "fsrtpconference",
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
184 who,
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
185 TRUE
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
186 );
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
187
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
188 if (!media) {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
189 purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: could not create media session\n");
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
190 return FALSE;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
191 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
192
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
193 /* attach callbacks */
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
194 g_signal_connect(G_OBJECT(media), "candidates-prepared", G_CALLBACK(mxit_candidates_prepared_cb), NULL);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
195 g_signal_connect(G_OBJECT(media), "stream-info", G_CALLBACK(mxit_stream_info_cb), NULL);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
196 g_signal_connect(G_OBJECT(media), "state-changed", G_CALLBACK(mxit_state_changed_cb), NULL);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
197
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
198 /* initiate audio session */
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
199 if ((type & PURPLE_MEDIA_AUDIO) &&
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
200 (!purple_media_add_stream(media, "audio", who, PURPLE_MEDIA_AUDIO, TRUE, transmitter, 0, NULL))) {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
201 purple_media_end(media, NULL, NULL);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
202 return FALSE;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
203 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
204
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
205 /* initiate video session */
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
206 if ((type & PURPLE_MEDIA_VIDEO) &&
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
207 (!purple_media_add_stream(media, "video", who, PURPLE_MEDIA_VIDEO, TRUE, transmitter, 0, NULL))) {
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
208 purple_media_end(media, NULL, NULL);
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
209 return FALSE;
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
210 }
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
211
5b51e5fb8d76 MXit VV WIP.
andrew.victor@mxit.com
parents: 31286
diff changeset
212 return TRUE;
31286
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
213 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
214
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
215 #else
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
216
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
217 /*
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
218 * Voice and Video not supported.
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
219 */
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
220
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
221 gboolean mxit_audio_enabled(void)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
222 {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
223 return FALSE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
224 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
225
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
226 gboolean mxit_video_enabled(void)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
227 {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
228 return FALSE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
229 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
230
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
231 PurpleMediaCaps mxit_media_caps(PurpleAccount *account, const char *who)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
232 {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
233 return PURPLE_MEDIA_CAPS_NONE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
234 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
235
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
236 gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type)
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
237 {
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
238 return FALSE;
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
239 }
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
240
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
241 #endif
b8d9329dda4a The initial protocol infrastructure for MXit Voice/Video support.
andrew.victor@mxit.com
parents:
diff changeset
242