Tue, 18 Dec 2012 15:57:47 +0200
Update with changes in release-2.x.y
|
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 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
26 | #include "purple.h" |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
27 | #include "mxit.h" |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
28 | #include "roster.h" |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
29 | #include "voicevideo.h" |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
30 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
31 | #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
|
32 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
33 | #warning "MXit VV support enabled." |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
34 | |
|
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 | * Does this client support Voice? |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
37 | */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
38 | gboolean mxit_audio_enabled(void) |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
39 | { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
40 | 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
|
41 | 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
|
42 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
43 | 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
|
44 | } |
|
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 | * 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
|
48 | */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
49 | gboolean mxit_video_enabled(void) |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
50 | { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
51 | 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
|
52 | 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
|
53 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
54 | 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
|
55 | } |
|
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 | * 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
|
59 | * |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
60 | * @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
|
61 | * @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
|
62 | * @return The media capabilities supported |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
63 | */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
64 | 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
|
65 | { |
|
33211
97c8cd903433
Backport the remaining code-cleanup changes from 3.0.0-devel tree.
Andrew Victor <andrew.victor@mxit.com>
parents:
33203
diff
changeset
|
66 | 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
|
67 | PurpleBuddy* buddy; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
68 | struct contact* contact; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
69 | 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
|
70 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
71 | 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
|
72 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
73 | /* We need to have a voice/video server */ |
|
33211
97c8cd903433
Backport the remaining code-cleanup changes from 3.0.0-devel tree.
Andrew Victor <andrew.victor@mxit.com>
parents:
33203
diff
changeset
|
74 | if (!*session->voip_server) |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
75 | return PURPLE_MEDIA_CAPS_NONE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
76 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
77 | /* 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
|
78 | 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
|
79 | if (!buddy) { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <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); |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
81 | return PURPLE_MEDIA_CAPS_NONE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
82 | } |
|
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 | 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
|
85 | if (!contact) |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
86 | return PURPLE_MEDIA_CAPS_NONE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
87 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
88 | /* 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
|
89 | 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
|
90 | return PURPLE_MEDIA_CAPS_NONE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
91 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
92 | /* 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
|
93 | 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
|
94 | return PURPLE_MEDIA_CAPS_NONE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
95 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
96 | /* 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
|
97 | if (contact->presence == MXIT_PRESENCE_OFFLINE) |
|
33552
185f05b59f3f
The MXit get_media_caps() should return PURPLE_MEDIA_CAPS_NONE if the
Andrew Victor <andrew.victor@mxit.com>
parents:
33211
diff
changeset
|
98 | 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
|
99 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
100 | /* they support voice-only */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
101 | 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
|
102 | capa |= PURPLE_MEDIA_CAPS_AUDIO; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
103 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
104 | /* they support voice-and-video */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
105 | 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
|
106 | 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
|
107 | |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
108 | return capa; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
109 | } |
|
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 | |
| 31845 | 112 | static void mxit_candidates_prepared_cb(PurpleMedia* media, gchar* sessionid, gchar* who, void* session) |
| 113 | { | |
| 114 | purple_debug_info(MXIT_PLUGIN_ID, "mxit_candidates_prepared_cb: buddy '%s', session '%s'\n", who, sessionid); | |
| 115 | ||
| 116 | if (purple_media_is_initiator(media, sessionid, who)) { | |
| 117 | // TODO: Send INVITE via SIP. | |
| 118 | } | |
| 119 | else { | |
| 120 | // TODO: ?? | |
| 121 | } | |
| 122 | } | |
| 123 | ||
| 124 | static void mxit_stream_info_cb(PurpleMedia* media, PurpleMediaInfoType type, char* sessionid, gchar* who, gboolean local, void* session) | |
| 125 | { | |
| 126 | purple_debug_info(MXIT_PLUGIN_ID, "mxit_stream_info_cb: buddy '%s', session '%s', info %d \n", who, sessionid, type); | |
| 127 | ||
| 128 | switch (type) { | |
| 129 | case PURPLE_MEDIA_INFO_HANGUP: | |
| 130 | break; | |
| 131 | case PURPLE_MEDIA_INFO_ACCEPT: | |
| 132 | break; | |
| 133 | case PURPLE_MEDIA_INFO_REJECT: | |
| 134 | break; | |
| 135 | case PURPLE_MEDIA_INFO_MUTE: | |
| 136 | break; | |
| 137 | case PURPLE_MEDIA_INFO_UNMUTE: | |
| 138 | break; | |
| 139 | case PURPLE_MEDIA_INFO_PAUSE: | |
| 140 | break; | |
| 141 | case PURPLE_MEDIA_INFO_UNPAUSE: | |
| 142 | break; | |
| 143 | case PURPLE_MEDIA_INFO_HOLD: | |
| 144 | break; | |
| 145 | case PURPLE_MEDIA_INFO_UNHOLD: | |
| 146 | break; | |
| 147 | } | |
| 148 | } | |
| 149 | ||
| 150 | static void mxit_state_changed_cb(PurpleMedia* media, PurpleMediaState state, gchar* sessionid, char* who, void* session) | |
| 151 | { | |
| 152 | purple_debug_info(MXIT_PLUGIN_ID, "mxit_state_changed_cb: buddy '%s', session '%s', state %d\n", who, sessionid, state); | |
| 153 | ||
| 154 | switch (state) { | |
| 155 | case PURPLE_MEDIA_STATE_NEW: | |
| 156 | break; | |
| 157 | case PURPLE_MEDIA_STATE_CONNECTED: | |
| 158 | break; | |
| 159 | case PURPLE_MEDIA_STATE_END: | |
| 160 | break; | |
| 161 | } | |
| 162 | } | |
| 163 | ||
| 164 | ||
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
165 | /*------------------------------------------------------------------------ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
166 | * 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
|
167 | * |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
168 | * @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
|
169 | * @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
|
170 | * @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
|
171 | * @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
|
172 | */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
173 | 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
|
174 | { |
| 31845 | 175 | gchar* transmitter = "rawudp"; |
| 176 | PurpleMedia* media = NULL; | |
| 177 | ||
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
178 | 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
|
179 | |
| 31845 | 180 | media = purple_media_manager_create_media( |
| 181 | purple_media_manager_get(), | |
| 182 | account, | |
| 183 | "fsrtpconference", | |
| 184 | who, | |
| 185 | TRUE | |
| 186 | ); | |
| 187 | ||
| 188 | if (!media) { | |
| 189 | purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: could not create media session\n"); | |
| 190 | return FALSE; | |
| 191 | } | |
| 192 | ||
| 193 | /* attach callbacks */ | |
| 194 | g_signal_connect(G_OBJECT(media), "candidates-prepared", G_CALLBACK(mxit_candidates_prepared_cb), NULL); | |
| 195 | g_signal_connect(G_OBJECT(media), "stream-info", G_CALLBACK(mxit_stream_info_cb), NULL); | |
| 196 | g_signal_connect(G_OBJECT(media), "state-changed", G_CALLBACK(mxit_state_changed_cb), NULL); | |
| 197 | ||
| 198 | /* initiate audio session */ | |
| 199 | if ((type & PURPLE_MEDIA_AUDIO) && | |
| 200 | (!purple_media_add_stream(media, "audio", who, PURPLE_MEDIA_AUDIO, TRUE, transmitter, 0, NULL))) { | |
| 201 | purple_media_end(media, NULL, NULL); | |
| 202 | return FALSE; | |
| 203 | } | |
| 204 | ||
| 205 | /* initiate video session */ | |
| 206 | if ((type & PURPLE_MEDIA_VIDEO) && | |
| 207 | (!purple_media_add_stream(media, "video", who, PURPLE_MEDIA_VIDEO, TRUE, transmitter, 0, NULL))) { | |
| 208 | purple_media_end(media, NULL, NULL); | |
| 209 | return FALSE; | |
| 210 | } | |
| 211 | ||
| 212 | return TRUE; | |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
213 | } |
|
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 | #else |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
216 | |
|
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 | * Voice and Video not supported. |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
219 | */ |
|
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 | gboolean mxit_audio_enabled(void) |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
222 | { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
223 | return FALSE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
224 | } |
|
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 | gboolean mxit_video_enabled(void) |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
227 | { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
228 | return FALSE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
229 | } |
|
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 | 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
|
232 | { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
233 | return PURPLE_MEDIA_CAPS_NONE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
234 | } |
|
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 | 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
|
237 | { |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
238 | return FALSE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
239 | } |
|
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 | #endif |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
diff
changeset
|
242 |