libpurple/protocols/mxit/voicevideo.c

Fri, 09 Aug 2013 13:03:26 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Fri, 09 Aug 2013 13:03:26 +0200
changeset 34287
6cd0c77b1f6a
parent 33852
368feedc80cf
child 34706
02cb08146888
permissions
-rw-r--r--

HTTP: successful is spelled with one l

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

mercurial