summaryrefslogtreecommitdiff
path: root/telepathy-glib/media-interfaces.c
blob: 8f046baed339706a9e1af9046b500463a44426ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
 * media-interfaces.c - proxies for Telepathy media session/stream handlers
 *
 * Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
 * Copyright (C) 2007 Nokia Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "config.h"

#include "telepathy-glib/media-interfaces.h"

#include <telepathy-glib/dbus.h>
#include <telepathy-glib/errors.h>
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/proxy-subclass.h>

#include "telepathy-glib/_gen/tp-cli-media-session-handler-body.h"
#include "telepathy-glib/_gen/tp-cli-media-stream-handler-body.h"

/**
 * SECTION:media-interfaces
 * @title: TpMediaSessionHandler, TpMediaStreamHandler
 * @short_description: proxy objects for Telepathy media streaming
 * @see_also: #TpChannel, #TpProxy
 *
 * This module provides access to the auxiliary objects used to
 * implement #TpSvcChannelTypeStreamedMedia.
 *
 * Since: 0.7.1
 */

/**
 * TpMediaStreamHandlerClass:
 *
 * The class of a #TpMediaStreamHandler.
 *
 * Since: 0.7.1
 */
struct _TpMediaStreamHandlerClass {
    TpProxyClass parent_class;
    /*<private>*/
    gpointer priv;
};

/**
 * TpMediaStreamHandler:
 *
 * A proxy object for a Telepathy connection manager.
 *
 * Since: 0.7.1
 */
struct _TpMediaStreamHandler {
    TpProxy parent;
    /*<private>*/
    TpMediaStreamHandlerPrivate *priv;
};

G_DEFINE_TYPE (TpMediaStreamHandler,
    tp_media_stream_handler,
    TP_TYPE_PROXY)

static void
tp_media_stream_handler_init (TpMediaStreamHandler *self)
{
}

static void
tp_media_stream_handler_class_init (TpMediaStreamHandlerClass *klass)
{
  TpProxyClass *proxy_class = (TpProxyClass *) klass;

  proxy_class->must_have_unique_name = TRUE;
  proxy_class->interface = TP_IFACE_QUARK_MEDIA_STREAM_HANDLER;
  tp_media_stream_handler_init_known_interfaces ();
}

/**
 * tp_media_stream_handler_new:
 * @dbus: a D-Bus daemon; may not be %NULL
 * @unique_name: the unique name of the connection process; may not be %NULL
 *  or a well-known name
 * @object_path: the object path of the media stream handler; may not be %NULL
 * @error: used to indicate the error if %NULL is returned
 *
 * <!-- -->
 *
 * Returns: a new media stream handler proxy, or %NULL on invalid arguments
 *
 * Since: 0.7.1
 */
TpMediaStreamHandler *
tp_media_stream_handler_new (TpDBusDaemon *dbus,
                             const gchar *unique_name,
                             const gchar *object_path,
                             GError **error)
{
  TpMediaStreamHandler *ret = NULL;

  if (!tp_dbus_check_valid_bus_name (unique_name,
        TP_DBUS_NAME_TYPE_UNIQUE, error))
    goto finally;

  if (!tp_dbus_check_valid_object_path (object_path, error))
    goto finally;

  ret = TP_MEDIA_STREAM_HANDLER (g_object_new (TP_TYPE_MEDIA_STREAM_HANDLER,
        "dbus-daemon", dbus,
        "bus-name", unique_name,
        "object-path", object_path,
        NULL));

finally:
  return ret;
}

/**
 * TpMediaSessionHandlerClass:
 *
 * The class of a #TpMediaSessionHandler.
 *
 * Since: 0.7.1
 */
struct _TpMediaSessionHandlerClass {
    TpProxyClass parent_class;
    /*<private>*/
    gpointer priv;
};

/**
 * TpMediaSessionHandler:
 *
 * A proxy object for a Telepathy connection manager.
 *
 * Since: 0.7.1
 */
struct _TpMediaSessionHandler {
    TpProxy parent;
    /*<private>*/
    TpMediaSessionHandlerPrivate *priv;
};

G_DEFINE_TYPE (TpMediaSessionHandler,
    tp_media_session_handler,
    TP_TYPE_PROXY)

static void
tp_media_session_handler_init (TpMediaSessionHandler *self)
{
}

static void
tp_media_session_handler_class_init (TpMediaSessionHandlerClass *klass)
{
  TpProxyClass *proxy_class = (TpProxyClass *) klass;

  proxy_class->must_have_unique_name = TRUE;
  proxy_class->interface = TP_IFACE_QUARK_MEDIA_SESSION_HANDLER;
  tp_media_session_handler_init_known_interfaces ();
}

/**
 * tp_media_session_handler_new:
 * @dbus: a D-Bus daemon; may not be %NULL
 * @unique_name: the unique name of the connection process; may not be %NULL
 *  or a well-known name
 * @object_path: the object path of the media session handler; may not be %NULL
 * @error: used to indicate the error if %NULL is returned
 *
 * <!-- -->
 *
 * Returns: a new media session handler proxy, or %NULL on invalid arguments
 *
 * Since: 0.7.1
 */
TpMediaSessionHandler *
tp_media_session_handler_new (TpDBusDaemon *dbus,
                              const gchar *unique_name,
                              const gchar *object_path,
                              GError **error)
{
  TpMediaSessionHandler *ret = NULL;

  if (!tp_dbus_check_valid_bus_name (unique_name,
        TP_DBUS_NAME_TYPE_UNIQUE, error))
    goto finally;

  if (!tp_dbus_check_valid_object_path (object_path, error))
    goto finally;

  ret = TP_MEDIA_SESSION_HANDLER (g_object_new (TP_TYPE_MEDIA_SESSION_HANDLER,
        "dbus-daemon", dbus,
        "bus-name", unique_name,
        "object-path", object_path,
        NULL));

finally:
  return ret;
}

/**
 * tp_media_stream_handler_init_known_interfaces:
 *
 * Ensure that the known interfaces for TpMediaStreamHandler have been set up.
 * This is done automatically when necessary, but for correct
 * overriding of library interfaces by local extensions, you should
 * call this function before calling
 * tp_proxy_or_subclass_hook_on_interface_add() with first argument
 * %TP_TYPE_MEDIA_STREAM_HANDLER.
 *
 * Since: 0.7.32
 */
void
tp_media_stream_handler_init_known_interfaces (void)
{
  static gsize once = 0;

  if (g_once_init_enter (&once))
    {
      GType tp_type = TP_TYPE_MEDIA_STREAM_HANDLER;

      tp_proxy_init_known_interfaces ();
      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
          tp_cli_media_stream_handler_add_signals);
      tp_proxy_subclass_add_error_mapping (tp_type,
          TP_ERROR_PREFIX, TP_ERROR, TP_TYPE_ERROR);

      g_once_init_leave (&once, 1);
    }
}

/**
 * tp_media_session_handler_init_known_interfaces:
 *
 * Ensure that the known interfaces for TpMediaSessionHandler have been set up.
 * This is done automatically when necessary, but for correct
 * overriding of library interfaces by local extensions, you should
 * call this function before calling
 * tp_proxy_or_subclass_hook_on_interface_add() with first argument
 * %TP_TYPE_MEDIA_SESSION_HANDLER.
 *
 * Since: 0.7.32
 */
void
tp_media_session_handler_init_known_interfaces (void)
{
  static gsize once = 0;

  if (g_once_init_enter (&once))
    {
      GType tp_type = TP_TYPE_MEDIA_SESSION_HANDLER;

      tp_proxy_init_known_interfaces ();
      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
          tp_cli_media_session_handler_add_signals);
      tp_proxy_subclass_add_error_mapping (tp_type,
          TP_ERROR_PREFIX, TP_ERROR, TP_TYPE_ERROR);

      g_once_init_leave (&once, 1);
    }
}