telepathy-glib: future-account: store account manager, manager, and protocol

Jonny Lamb jonny at kemper.freedesktop.org
Thu May 10 07:41:17 PDT 2012


Module: telepathy-glib
Branch: master
Commit: 5bc3b939d8c7f21c3abae71091353b507a64da9a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=5bc3b939d8c7f21c3abae71091353b507a64da9a

Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date:   Wed Apr 25 18:47:31 2012 +0100

future-account: store account manager, manager, and protocol

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>

---

 telepathy-glib/future-account.c |  130 ++++++++++++++++++++++++++++++++++++++-
 telepathy-glib/future-account.h |    5 +-
 2 files changed, 131 insertions(+), 4 deletions(-)

diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index c15eec0..976d28a 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -22,6 +22,8 @@
 
 #include "telepathy-glib/future-account.h"
 
+#include <telepathy-glib/util.h>
+
 #define DEBUG_FLAG TP_DEBUG_ACCOUNTS
 #include "telepathy-glib/debug-internal.h"
 
@@ -53,6 +55,11 @@
 
 struct _TpFutureAccountPrivate {
   gboolean dispose_has_run;
+
+  TpAccountManager *account_manager;
+
+  gchar *cm_name;
+  gchar *proto_name;
 };
 
 G_DEFINE_TYPE (TpFutureAccount, tp_future_account, G_TYPE_OBJECT)
@@ -66,6 +73,9 @@ enum {
 
 /* properties */
 enum {
+  PROP_ACCOUNT_MANAGER = 1,
+  PROP_CONNECTION_MANAGER,
+  PROP_PROTOCOL,
   N_PROPS
 };
 
@@ -77,6 +87,60 @@ tp_future_account_init (TpFutureAccount *self)
 }
 
 static void
+tp_future_account_get_property (GObject *object,
+    guint prop_id,
+    GValue *value,
+    GParamSpec *pspec)
+{
+  TpFutureAccount *self = TP_FUTURE_ACCOUNT (object);
+
+  switch (prop_id)
+    {
+    case PROP_ACCOUNT_MANAGER:
+      g_value_set_object (value, self->priv->account_manager);
+      break;
+    case PROP_CONNECTION_MANAGER:
+      g_value_set_string (value, self->priv->cm_name);
+      break;
+    case PROP_PROTOCOL:
+      g_value_set_string (value, self->priv->proto_name);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+tp_future_account_set_property (GObject *object,
+    guint property_id,
+    const GValue *value,
+    GParamSpec *pspec)
+{
+  TpFutureAccount *self = TP_FUTURE_ACCOUNT (object);
+  TpFutureAccountPrivate *priv = self->priv;
+
+  switch (property_id)
+    {
+    case PROP_ACCOUNT_MANAGER:
+      g_assert (priv->account_manager == NULL);
+      priv->account_manager = g_value_dup_object (value);
+      break;
+    case PROP_CONNECTION_MANAGER:
+      g_assert (priv->cm_name == NULL);
+      priv->cm_name = g_value_dup_string (value);
+      break;
+    case PROP_PROTOCOL:
+      g_assert (priv->proto_name == NULL);
+      priv->proto_name = g_value_dup_string (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
 tp_future_account_dispose (GObject *object)
 {
   TpFutureAccount *self = TP_FUTURE_ACCOUNT (object);
@@ -96,6 +160,12 @@ tp_future_account_dispose (GObject *object)
 static void
 tp_future_account_finalize (GObject *object)
 {
+  TpFutureAccount *self = TP_FUTURE_ACCOUNT (object);
+  TpFutureAccountPrivate *priv = self->priv;
+
+  tp_clear_pointer (&priv->cm_name, g_free);
+  tp_clear_pointer (&priv->proto_name, g_free);
+
   /* free any data held directly by the object here */
 
   if (G_OBJECT_CLASS (tp_future_account_parent_class)->finalize != NULL)
@@ -109,20 +179,74 @@ tp_future_account_class_init (TpFutureAccountClass *klass)
 
   g_type_class_add_private (klass, sizeof (TpFutureAccountPrivate));
 
+  object_class->get_property = tp_future_account_get_property;
+  object_class->set_property = tp_future_account_set_property;
   object_class->dispose = tp_future_account_dispose;
   object_class->finalize = tp_future_account_finalize;
+
+  /**
+   * TpFutureAccount:account-manager:
+   *
+   * TODO
+   */
+  g_object_class_install_property (object_class, PROP_ACCOUNT_MANAGER,
+      g_param_spec_object ("account-manager",
+          "Account manager",
+          "The future account's account manager",
+          TP_TYPE_ACCOUNT_MANAGER,
+          G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  /**
+   * TpFutureAccount:connection-manager:
+   *
+   * The account's connection manager name.
+   */
+  g_object_class_install_property (object_class, PROP_CONNECTION_MANAGER,
+      g_param_spec_string ("connection-manager",
+          "Connection manager",
+          "The account's connection manager name",
+          NULL,
+          G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  /**
+   * TpFutureAccount:protocol:
+   *
+   * The account's machine-readable protocol name, such as "jabber", "msn" or
+   * "local-xmpp". Recommended names for most protocols can be found in the
+   * Telepathy D-Bus Interface Specification.
+   */
+  g_object_class_install_property (object_class, PROP_PROTOCOL,
+      g_param_spec_string ("protocol",
+          "Protocol",
+          "The account's protocol name",
+          NULL,
+          G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 /**
  * tp_future_account_new:
+ * @account_manager: TODO
+ * @manager: TODO
+ * @protocol: TODO
  *
  * Convenience function to create a new future account object.
  *
- * Returns: a new reference to a future account object, or %NULL
+ * Returns: a new reference to a future account object, or %NULL if
+ *   any argument is incorrect
  */
 TpFutureAccount *
-tp_future_account_new (void)
+tp_future_account_new (TpAccountManager *account_manager,
+    const gchar *manager,
+    const gchar *protocol)
 {
-  return g_object_new (TP_TYPE_FUTURE_ACCOUNT, NULL);
+  g_return_val_if_fail (TP_IS_ACCOUNT_MANAGER (account_manager), NULL);
+  g_return_val_if_fail (manager != NULL, NULL);
+  g_return_val_if_fail (protocol != NULL, NULL);
+
+  return g_object_new (TP_TYPE_FUTURE_ACCOUNT,
+      "account-manager", account_manager,
+      "connection-manager", manager,
+      "protocol", protocol,
+      NULL);
 }
 
diff --git a/telepathy-glib/future-account.h b/telepathy-glib/future-account.h
index df7e31a..805aa95 100644
--- a/telepathy-glib/future-account.h
+++ b/telepathy-glib/future-account.h
@@ -21,6 +21,8 @@
 #ifndef TP_FUTURE_ACCOUNT_H
 #define TP_FUTURE_ACCOUNT_H
 
+#include <telepathy-glib/account-manager.h>
+
 G_BEGIN_DECLS
 
 typedef struct _TpFutureAccount TpFutureAccount;
@@ -57,7 +59,8 @@ GType tp_future_account_get_type (void);
   (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_FUTURE_ACCOUNT, \
                               TpFutureAccountClass))
 
-TpFutureAccount * tp_future_account_new (void) G_GNUC_WARN_UNUSED_RESULT;
+TpFutureAccount * tp_future_account_new (TpAccountManager *account_manager,
+    const gchar *manager, const gchar *protocol) G_GNUC_WARN_UNUSED_RESULT;
 
 G_END_DECLS
 



More information about the telepathy-commits mailing list