#include <telepathy-glib/proxy-subclass.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/interfaces.h>
#include <extensions/extensions.h>
-#include <libempathy/empathy-contact-factory.h>
-#include <libempathy/empathy-tp-group.h>
-#include <libempathy/empathy-utils.h>
#include "empathy-tp-call.h"
+#include "empathy-contact-factory.h"
+#include "empathy-tp-group.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_TP
#include "empathy-debug.h"
-#define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE \
- ((object), EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv))
-
#define STREAM_ENGINE_BUS_NAME "org.freedesktop.Telepathy.StreamEngine"
#define STREAM_ENGINE_OBJECT_PATH "/org/freedesktop/Telepathy/StreamEngine"
-typedef struct _EmpathyTpCallPriv EmpathyTpCallPriv;
-
-struct _EmpathyTpCallPriv
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpCall)
+typedef struct
{
TpChannel *channel;
TpProxy *stream_engine;
EmpathyTpCallStream *audio;
EmpathyTpCallStream *video;
-};
+} EmpathyTpCallPriv;
enum
{
g_array_free (stream_types, TRUE);
}
-static void
-tp_call_request_streams (EmpathyTpCall *call)
-{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
-
- tp_call_request_streams_for_capabilities (call,
- empathy_contact_get_capabilities (priv->contact));
-}
-
static void
tp_call_member_added_cb (EmpathyTpGroup *group,
EmpathyContact *contact,
{
EmpathyTpCallPriv *priv = GET_PRIV (call);
+ g_object_ref (call);
if (!priv->contact && !empathy_contact_is_user (contact))
{
priv->contact = g_object_ref (contact);
priv->is_incoming = TRUE;
priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
- tp_call_request_streams (call);
g_object_notify (G_OBJECT (call), "is-incoming");
- g_object_notify (G_OBJECT (call), "contact");
- g_object_notify (G_OBJECT (call), "status");
+ g_object_notify (G_OBJECT (call), "contact");
+ g_object_notify (G_OBJECT (call), "status");
}
if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
g_object_notify (G_OBJECT (call), "status");
}
+ g_object_unref (call);
}
static void
{
EmpathyTpCallPriv *priv = GET_PRIV (call);
+ g_object_ref (call);
if (!priv->contact && !empathy_contact_is_user (contact))
{
priv->contact = g_object_ref (contact);
priv->is_incoming = FALSE;
priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
- tp_call_request_streams (call);
g_object_notify (G_OBJECT (call), "is-incoming");
g_object_notify (G_OBJECT (call), "contact");
g_object_notify (G_OBJECT (call), "status");
+ tp_call_request_streams_for_capabilities (call,
+ EMPATHY_CAPABILITIES_AUDIO);
}
+ g_object_unref (call);
}
static void
GObject *call)
{
if (error)
- {
DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
- }
}
static void
static void
empathy_tp_call_init (EmpathyTpCall *call)
{
- EmpathyTpCallPriv *priv = GET_PRIV (call);
+ EmpathyTpCallPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
+ EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv);
+ call->priv = priv;
priv->status = EMPATHY_TP_CALL_STATUS_READYING;
priv->contact = NULL;
priv->stream_engine_running = FALSE;
G_OBJECT (call));
}
+void
+empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
+{
+ EmpathyTpCallPriv *priv = GET_PRIV (call);
+
+ g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+ g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
+
+ if (!priv->audio->exists)
+ return;
+
+ tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
+ priv->audio->id, event,
+ (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_call_async_cb,
+ "starting tone", NULL, G_OBJECT (call));
+}
+
+void
+empathy_tp_call_stop_tone (EmpathyTpCall *call)
+{
+ EmpathyTpCallPriv *priv = GET_PRIV (call);
+
+ g_return_if_fail (EMPATHY_IS_TP_CALL (call));
+ g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
+
+ if (!priv->audio->exists)
+ return;
+
+ tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
+ priv->audio->id,
+ (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_call_async_cb,
+ "stoping tone", NULL, G_OBJECT (call));
+}
+
+gboolean
+empathy_tp_call_has_dtmf (EmpathyTpCall *call)
+{
+ EmpathyTpCallPriv *priv = GET_PRIV (call);
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
+
+ return tp_proxy_has_interface_by_id (priv->channel,
+ TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
+}
+