[empathy] tp-call: add account property



commit 2f6aec58f110a13b8c370d676bdd9fb6946893ee
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Aug 12 16:34:52 2010 +0200

    tp-call: add account property

 libempathy/empathy-call-factory.c |    2 +-
 libempathy/empathy-call-handler.c |   10 +++++++---
 libempathy/empathy-tp-call.c      |   32 +++++++++++++++++++++++++++++++-
 libempathy/empathy-tp-call.h      |    5 ++++-
 src/empathy-event-manager.c       |    2 +-
 5 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c
index 9ac4af2..49bc60d 100644
--- a/libempathy/empathy-call-factory.c
+++ b/libempathy/empathy-call-factory.c
@@ -314,7 +314,7 @@ handle_channels_cb (TpSimpleHandler *handler,
           TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
         continue;
 
-      call = empathy_tp_call_new (channel);
+      call = empathy_tp_call_new (account, channel);
 
       if (empathy_tp_call_get_status (call) <= EMPATHY_TP_CALL_STATUS_READYING)
         {
diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c
index a895f53..dc734b2 100644
--- a/libempathy/empathy-call-handler.c
+++ b/libempathy/empathy-call-handler.c
@@ -762,9 +762,11 @@ empathy_call_handler_request_cb (GObject *source,
   EmpathyCallHandlerPriv *priv = GET_PRIV (self);
   TpChannel *channel;
   GError *error = NULL;
+  TpAccountChannelRequest *req = TP_ACCOUNT_CHANNEL_REQUEST (source);
+  TpAccount *account;
 
-  channel = tp_account_channel_request_create_and_handle_channel_finish (
-      TP_ACCOUNT_CHANNEL_REQUEST (source), result, NULL, &error);
+  channel = tp_account_channel_request_create_and_handle_channel_finish (req,
+      result, NULL, &error);
   if (channel == NULL)
     {
       DEBUG ("Failed to create the channel: %s", error->message);
@@ -772,7 +774,9 @@ empathy_call_handler_request_cb (GObject *source,
       return;
     }
 
-  priv->call = empathy_tp_call_new (channel);
+  account = tp_account_channel_request_get_account (req);
+
+  priv->call = empathy_tp_call_new (account, channel);
 
   g_object_notify (G_OBJECT (self), "tp-call");
 
diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c
index 16689e6..97b8bce 100644
--- a/libempathy/empathy-tp-call.c
+++ b/libempathy/empathy-tp-call.c
@@ -39,6 +39,7 @@
 typedef struct
 {
   gboolean dispose_has_run;
+  TpAccount *account;
   TpChannel *channel;
   EmpathyContact *contact;
   gboolean is_incoming;
@@ -60,6 +61,7 @@ static guint signals[LAST_SIGNAL] = {0};
 enum
 {
   PROP_0,
+  PROP_ACCOUNT,
   PROP_CHANNEL,
   PROP_CONTACT,
   PROP_STATUS,
@@ -444,6 +446,8 @@ tp_call_dispose (GObject *object)
   if (priv->contact != NULL)
       g_object_unref (priv->contact);
 
+  tp_clear_object (&priv->account);
+
   if (G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose)
     G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose (object);
 }
@@ -471,6 +475,9 @@ tp_call_set_property (GObject *object,
 
   switch (prop_id)
     {
+    case PROP_ACCOUNT:
+      priv->account = g_value_dup_object (value);
+      break;
     case PROP_CHANNEL:
       priv->channel = g_value_dup_object (value);
       break;
@@ -490,6 +497,9 @@ tp_call_get_property (GObject *object,
 
   switch (prop_id)
     {
+    case PROP_ACCOUNT:
+      g_value_set_object (value, priv->channel);
+      break;
     case PROP_CHANNEL:
       g_value_set_object (value, priv->channel);
       break;
@@ -524,23 +534,33 @@ empathy_tp_call_class_init (EmpathyTpCallClass *klass)
 
   g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
 
+  g_object_class_install_property (object_class, PROP_ACCOUNT,
+      g_param_spec_object ("account", "TpAccount", "TpAccount",
+      TP_TYPE_ACCOUNT,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+      G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_property (object_class, PROP_CHANNEL,
       g_param_spec_object ("channel", "channel", "channel",
       TP_TYPE_CHANNEL,
       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
       G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_CONTACT,
       g_param_spec_object ("contact", "Call contact", "Call contact",
       EMPATHY_TYPE_CONTACT,
       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_STATUS,
       g_param_spec_uint ("status", "Call status",
       "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
       G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
       g_param_spec_pointer ("audio-stream", "Audio stream data",
       "Audio stream data",
       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
       g_param_spec_pointer ("video-stream", "Video stream data",
       "Video stream data",
@@ -581,11 +601,13 @@ empathy_tp_call_init (EmpathyTpCall *call)
 }
 
 EmpathyTpCall *
-empathy_tp_call_new (TpChannel *channel)
+empathy_tp_call_new (TpAccount *account,
+    TpChannel *channel)
 {
   g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
 
   return g_object_new (EMPATHY_TYPE_TP_CALL,
+      "account", account,
       "channel", channel,
       NULL);
 }
@@ -840,3 +862,11 @@ empathy_tp_call_get_status (EmpathyTpCall *self)
 
   return priv->status;
 }
+
+TpAccount *
+empathy_tp_call_get_account (EmpathyTpCall *self)
+{
+  EmpathyTpCallPriv *priv = GET_PRIV (self);
+
+  return priv->account;
+}
diff --git a/libempathy/empathy-tp-call.h b/libempathy/empathy-tp-call.h
index d866a2e..c633da3 100644
--- a/libempathy/empathy-tp-call.h
+++ b/libempathy/empathy-tp-call.h
@@ -73,7 +73,8 @@ typedef struct
 } EmpathyTpCallStream;
 
 GType empathy_tp_call_get_type (void) G_GNUC_CONST;
-EmpathyTpCall *empathy_tp_call_new (TpChannel *channel);
+EmpathyTpCall *empathy_tp_call_new (TpAccount *account,
+    TpChannel *channel);
 void empathy_tp_call_close (EmpathyTpCall *call);
 
 void empathy_tp_call_accept_incoming_call (EmpathyTpCall *call);
@@ -93,6 +94,8 @@ void empathy_tp_call_leave (EmpathyTpCall *self);
 
 EmpathyTpCallStatus empathy_tp_call_get_status (EmpathyTpCall *self);
 
+TpAccount * empathy_tp_call_get_account (EmpathyTpCall *self);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_TP_CALL_H__ */
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index bc998a8..5916ddd 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -902,7 +902,7 @@ approve_channels (TpSimpleApprover *approver,
   else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
     {
       EmpathyContact *contact;
-      EmpathyTpCall *call = empathy_tp_call_new (channel);
+      EmpathyTpCall *call = empathy_tp_call_new (account, channel);
 
       approval->handler_instance = G_OBJECT (call);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]