[telepathy-mission-control/master] McdChannel: export the McdChannel on D-Bus if it represents a ChannelRequest
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Apr 2 09:12:19 PDT 2009
While we're changing API, change user action time to gint64 as per
telepathy-spec, rather than guint64, except in the
Account.Interface.Requests D-Bus API itself (which keeps guint64).
---
src/mcd-account-requests.c | 9 +++++--
src/mcd-channel.c | 45 ++++++++++++++++++++++++++++++++++++++-----
src/mcd-channel.h | 6 +++-
3 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/src/mcd-account-requests.c b/src/mcd-account-requests.c
index 1d3282f..31144ea 100644
--- a/src/mcd-account-requests.c
+++ b/src/mcd-account-requests.c
@@ -154,11 +154,14 @@ on_channel_status_changed (McdChannel *channel, McdChannelStatus status,
static McdChannel *
create_request (McdAccount *account, GHashTable *properties,
- guint64 user_time, const gchar *preferred_handler,
+ gint64 user_time, const gchar *preferred_handler,
gboolean use_existing, GError **error)
{
McdChannel *channel;
GHashTable *props;
+ TpDBusDaemon *dbus_daemon = mcd_account_manager_get_dbus_daemon (
+ mcd_account_get_account_manager (account));
+ DBusGConnection *dgc = tp_proxy_get_dbus_connection (dbus_daemon);
g_return_val_if_fail (error != NULL, NULL);
@@ -172,7 +175,7 @@ create_request (McdAccount *account, GHashTable *properties,
/* We MUST deep-copy the hash-table, as we don't know how dbus-glib will
* free it */
props = _mcd_deepcopy_asv (properties);
- channel = mcd_channel_new_request (props, user_time,
+ channel = mcd_channel_new_request (account, dgc, props, user_time,
preferred_handler);
g_hash_table_unref (props);
_mcd_channel_set_request_use_existing (channel, use_existing);
@@ -208,7 +211,7 @@ const McdDBusProp account_channelrequests_properties[] = {
static void
account_request_common (McdAccount *account, GHashTable *properties,
- guint64 user_time, const gchar *preferred_handler,
+ gint64 user_time, const gchar *preferred_handler,
DBusGMethodInvocation *context, gboolean use_existing)
{
GError *error = NULL;
diff --git a/src/mcd-channel.c b/src/mcd-channel.c
index 53c3371..2503ead 100644
--- a/src/mcd-channel.c
+++ b/src/mcd-channel.c
@@ -83,8 +83,9 @@ struct _McdChannelRequestData
GHashTable *properties;
guint target_handle; /* used only if the Requests interface is absent */
- guint64 user_time;
+ gint64 user_time;
gchar *preferred_handler;
+ gchar *account_path;
gboolean use_existing;
};
@@ -349,17 +350,36 @@ _mcd_channel_get_property (GObject * obj, guint prop_id,
break;
case PROP_ACCOUNT_PATH:
- /* FIXME: stub */
+ if (priv->request_data != NULL &&
+ priv->request_data->account_path != NULL)
+ {
+ g_value_set_boxed (val, priv->request_data->account_path);
+ break;
+ }
g_value_set_static_boxed (val, "/");
break;
case PROP_USER_ACTION_TIME:
- /* FIXME: stub */
+ if (priv->request_data != NULL)
+ {
+ g_value_set_int64 (val, priv->request_data->user_time);
+ break;
+ }
g_value_set_int64 (val, 0);
break;
case PROP_REQUESTS:
- /* FIXME: stub */
+ if (priv->request_data != NULL &&
+ priv->request_data->properties != NULL)
+ {
+ GPtrArray *arr = g_ptr_array_sized_new (1);
+
+ g_ptr_array_add (arr,
+ g_hash_table_ref (priv->request_data->properties));
+
+ g_value_take_boxed (val, arr);
+ break;
+ }
g_value_take_boxed (val, g_ptr_array_sized_new (0));
break;
@@ -1068,6 +1088,8 @@ mcd_channel_get_error (McdChannel *channel)
/**
* mcd_channel_new_request:
+ * @account: an account.
+ * @dgc: a #DBusGConnection on which to export the ChannelRequest object.
* @properties: a #GHashTable of desired channel properties.
* @user_time: user action time.
* @preferred_handler: well-known name of preferred handler.
@@ -1079,20 +1101,25 @@ mcd_channel_get_error (McdChannel *channel)
* Returns: a newly created #McdChannel.
*/
McdChannel *
-mcd_channel_new_request (GHashTable *properties, guint64 user_time,
+mcd_channel_new_request (McdAccount *account,
+ DBusGConnection *dgc,
+ GHashTable *properties,
+ gint64 user_time,
const gchar *preferred_handler)
{
McdChannel *channel;
McdChannelRequestData *crd;
+ const gchar *account_path = mcd_account_get_object_path (account);
channel = g_object_new (MCD_TYPE_CHANNEL,
"outgoing", TRUE,
NULL);
/* TODO: these data could be freed when the channel status becomes
- * MCD_CHANNEL_STATUS_DISPATCHED */
+ * MCD_CHANNEL_STATUS_DISPATCHED or MCD_CHANNEL_STATUS_FAILED */
crd = g_slice_new (McdChannelRequestData);
crd->path = g_strdup_printf (REQUEST_OBJ_BASE "%u", last_req_id++);
+ crd->account_path = g_strdup (account_path);
crd->properties = g_hash_table_ref (properties);
crd->user_time = user_time;
crd->preferred_handler = g_strdup (preferred_handler);
@@ -1102,6 +1129,12 @@ mcd_channel_new_request (GHashTable *properties, guint64 user_time,
mcd_channel_set_status (channel, MCD_CHANNEL_STATUS_REQUEST);
+ /* This could do with refactoring so that requests are a separate object
+ * that dies at the appropriate time, but for now the path of least
+ * resistance is to have the McdChannel be a ChannelRequest throughout
+ * its lifetime */
+ dbus_g_connection_register_g_object (dgc, crd->path, (GObject *) channel);
+
return channel;
}
diff --git a/src/mcd-channel.h b/src/mcd-channel.h
index e4b8db3..e933f78 100644
--- a/src/mcd-channel.h
+++ b/src/mcd-channel.h
@@ -97,8 +97,10 @@ McdChannel *mcd_channel_new_from_path (TpConnection *connection,
const gchar *object_path,
const gchar *type, guint handle,
TpHandleType handle_type);
-McdChannel *mcd_channel_new_request (GHashTable *properties,
- guint64 user_time,
+McdChannel *mcd_channel_new_request (McdAccount *account,
+ DBusGConnection *dgc,
+ GHashTable *properties,
+ gint64 user_time,
const gchar *preferred_handler);
G_GNUC_INTERNAL
--
1.5.6.5
More information about the telepathy-commits
mailing list