summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-09-13 17:57:35 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-10-08 15:19:42 +0100
commit2637ab782d2ff562c40e18bae1f86f4d850537ed (patch)
tree9ae7a0bd6ed4c4e345a0ad0c4e33559e3b4a034d
parentcaacfe66c11a3c01fd29e935dd7b0ea7b9b474a6 (diff)
replace sealed struct members with getters and use TpProtocol
Originally two patches for 'next' by Jonny Lamb. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55391 Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
-rw-r--r--src/mcd-account-manager.c4
-rw-r--r--src/mcd-account.c98
-rw-r--r--src/mcd-channel.c4
-rw-r--r--src/mcd-connection.c7
-rw-r--r--src/mcd-dispatcher.c2
-rw-r--r--src/mcd-manager-priv.h2
-rw-r--r--src/mcd-manager.c18
-rw-r--r--src/mcd-master.c6
-rw-r--r--tests/twisted/mc-debug-server.c4
9 files changed, 85 insertions, 60 deletions
diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 0f995089..f1c723f3 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -1385,7 +1385,7 @@ migrate_accounts (McdAccountManager *self,
if (cm == NULL)
continue;
- if (!tp_strdiff (cm->name, "butterfly"))
+ if (!tp_strdiff (tp_connection_manager_get_name (cm), "butterfly"))
migrate_butterfly_account (self, account, lad);
}
}
@@ -1479,7 +1479,7 @@ register_dbus_service (McdAccountManager *account_manager)
if (priv->dbus_registered)
return;
- dbus_connection = TP_PROXY (priv->dbus_daemon)->dbus_connection;
+ dbus_connection = tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus_daemon));
if (!tp_dbus_daemon_request_name (priv->dbus_daemon,
TP_ACCOUNT_MANAGER_BUS_NAME,
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 68751ce9..3858b3f8 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -2153,10 +2153,17 @@ properties_iface_init (TpSvcDBusPropertiesClass *iface, gpointer iface_data)
static GType
mc_param_type (const TpConnectionManagerParam *param)
{
- if (G_UNLIKELY (param == NULL)) return G_TYPE_INVALID;
- if (G_UNLIKELY (!param->dbus_signature)) return G_TYPE_INVALID;
+ const gchar *dbus_signature;
- switch (param->dbus_signature[0])
+ if (G_UNLIKELY (param == NULL))
+ return G_TYPE_INVALID;
+
+ dbus_signature = tp_connection_manager_param_get_dbus_signature (param);
+
+ if (G_UNLIKELY (!dbus_signature))
+ return G_TYPE_INVALID;
+
+ switch (dbus_signature[0])
{
case DBUS_TYPE_STRING:
return G_TYPE_STRING;
@@ -2188,13 +2195,13 @@ mc_param_type (const TpConnectionManagerParam *param)
return G_TYPE_UINT64;
case DBUS_TYPE_ARRAY:
- if (param->dbus_signature[1] == DBUS_TYPE_STRING)
+ if (dbus_signature[1] == DBUS_TYPE_STRING)
return G_TYPE_STRV;
/* other array types are not supported:
* fall through the default case */
default:
g_warning ("skipping parameter %s, unknown type %s",
- param->name, param->dbus_signature);
+ tp_connection_manager_param_get_name (param), dbus_signature);
}
return G_TYPE_INVALID;
}
@@ -2312,8 +2319,9 @@ mcd_account_check_parameters (McdAccount *account,
gpointer user_data)
{
McdAccountPrivate *priv = account->priv;
- TpConnectionManagerProtocol *protocol;
- const TpConnectionManagerParam *param;
+ TpProtocol *protocol;
+ GList *params = NULL;
+ GList *iter;
GError *error = NULL;
g_return_if_fail (callback != NULL);
@@ -2329,15 +2337,20 @@ mcd_account_check_parameters (McdAccount *account,
goto out;
}
- for (param = protocol->params; param->name != NULL; param++)
+ params = tp_protocol_dup_params (protocol);
+
+ for (iter = params; iter != NULL; iter = iter->next)
{
- if (!(param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED))
+ TpConnectionManagerParam *param = iter->data;
+ const gchar *param_name = tp_connection_manager_param_get_name (param);
+
+ if (!tp_connection_manager_param_is_required ((param)))
continue;
- if (!mcd_account_get_parameter (account, param->name, NULL, NULL))
+ if (!mcd_account_get_parameter (account, param_name, NULL, NULL))
{
g_set_error (&error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
- "missing required parameter '%s'", param->name);
+ "missing required parameter '%s'", param_name);
goto out;
}
}
@@ -2350,7 +2363,9 @@ out:
callback (account, error, user_data);
g_clear_error (&error);
- tp_clear_pointer (&protocol, tp_connection_manager_protocol_free);
+ g_list_free_full (params,
+ (GDestroyNotify) tp_connection_manager_param_free);
+ g_clear_object (&protocol);
}
static void
@@ -2408,24 +2423,26 @@ set_parameter_changed (GHashTable *dbus_properties,
const TpConnectionManagerParam *param,
const GValue *new_value)
{
- DEBUG ("Parameter %s changed", param->name);
+ const gchar *name = tp_connection_manager_param_get_name (param);
+
+ DEBUG ("Parameter %s changed", name);
/* can the param be updated on the fly? If yes, prepare to do so; and if
* not, prepare to reset the connection */
- if (param->flags & TP_CONN_MGR_PARAM_FLAG_DBUS_PROPERTY)
+ if (tp_connection_manager_param_is_dbus_property (param))
{
- g_hash_table_insert (dbus_properties, g_strdup (param->name),
+ g_hash_table_insert (dbus_properties, g_strdup (name),
tp_g_value_slice_dup (new_value));
}
else
{
- g_ptr_array_add (not_yet, g_strdup (param->name));
+ g_ptr_array_add (not_yet, g_strdup (name));
}
}
static gboolean
check_one_parameter_update (McdAccount *account,
- TpConnectionManagerProtocol *protocol,
+ TpProtocol *protocol,
GHashTable *dbus_properties,
GPtrArray *not_yet,
const gchar *name,
@@ -2433,14 +2450,14 @@ check_one_parameter_update (McdAccount *account,
GError **error)
{
const TpConnectionManagerParam *param =
- tp_connection_manager_protocol_get_param (protocol, name);
+ tp_protocol_get_param (protocol, name);
GType type;
if (param == NULL)
{
g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
"Protocol '%s' does not have parameter '%s'",
- protocol->name, name);
+ tp_protocol_get_name (protocol), name);
return FALSE;
}
@@ -2451,7 +2468,7 @@ check_one_parameter_update (McdAccount *account,
/* FIXME: use D-Bus type names, not GType names. */
g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
"parameter '%s' must be of type %s, not %s",
- param->name,
+ tp_connection_manager_param_get_name (param),
g_type_name (type), G_VALUE_TYPE_NAME (new_value));
return FALSE;
}
@@ -2464,7 +2481,7 @@ check_one_parameter_update (McdAccount *account,
/* Check if the parameter's current value (or its default, if it has
* one and it's not set to anything) matches the new value.
*/
- if (mcd_account_get_parameter (account, param->name,
+ if (mcd_account_get_parameter (account, tp_connection_manager_param_get_name (param),
&current_value, NULL) ||
tp_connection_manager_param_get_default (param, &current_value))
{
@@ -2488,14 +2505,14 @@ check_one_parameter_update (McdAccount *account,
static gboolean
check_one_parameter_unset (McdAccount *account,
- TpConnectionManagerProtocol *protocol,
+ TpProtocol *protocol,
GHashTable *dbus_properties,
GPtrArray *not_yet,
const gchar *name,
GError **error)
{
const TpConnectionManagerParam *param =
- tp_connection_manager_protocol_get_param (protocol, name);
+ tp_protocol_get_param (protocol, name);
/* The spec decrees that “If the given parameters […] do not exist at all,
* the account manager MUST accept this without error.”. Thus this function
@@ -2507,8 +2524,8 @@ check_one_parameter_unset (McdAccount *account,
{
GValue current_value = G_VALUE_INIT;
- if (mcd_account_get_parameter (account, param->name, &current_value,
- NULL))
+ if (mcd_account_get_parameter (account, tp_connection_manager_param_get_name (param),
+ &current_value, NULL))
{
/* There's an existing value; let's see if it's the same as the
* default, if any.
@@ -2528,7 +2545,7 @@ check_one_parameter_unset (McdAccount *account,
/* It has no default; we're gonna have to reconnect to make
* this take effect.
*/
- g_ptr_array_add (not_yet, g_strdup (param->name));
+ g_ptr_array_add (not_yet, g_strdup (tp_connection_manager_param_get_name (param)));
}
g_value_unset (&current_value);
@@ -2540,7 +2557,7 @@ check_one_parameter_unset (McdAccount *account,
static gboolean
check_parameters (McdAccount *account,
- TpConnectionManagerProtocol *protocol,
+ TpProtocol *protocol,
GHashTable *params,
const gchar **unset,
GHashTable *dbus_properties,
@@ -2593,7 +2610,7 @@ _mcd_account_set_parameters (McdAccount *account, GHashTable *params,
GHashTable *dbus_properties = NULL;
GPtrArray *not_yet = NULL;
GError *error = NULL;
- TpConnectionManagerProtocol *protocol = NULL;
+ TpProtocol *protocol = NULL;
DEBUG ("called");
if (G_UNLIKELY (!priv->manager && !load_manager (account)))
@@ -2640,7 +2657,7 @@ out:
g_clear_error (&error);
tp_clear_pointer (&dbus_properties, g_hash_table_unref);
tp_clear_pointer (&not_yet, g_ptr_array_unref);
- tp_clear_pointer (&protocol, tp_connection_manager_protocol_free);
+ g_clear_object (&protocol);
}
static void
@@ -2775,7 +2792,7 @@ register_dbus_service (McdAccount *self,
dbus_daemon = self->priv->dbus_daemon;
g_return_if_fail (dbus_daemon != NULL);
- dbus_connection = TP_PROXY (dbus_daemon)->dbus_connection;
+ dbus_connection = tp_proxy_get_dbus_connection (TP_PROXY (dbus_daemon));
if (G_LIKELY (dbus_connection))
dbus_g_connection_register_g_object (dbus_connection,
@@ -3503,8 +3520,9 @@ GHashTable *
_mcd_account_dup_parameters (McdAccount *account)
{
McdAccountPrivate *priv;
- TpConnectionManagerProtocol *protocol;
- const TpConnectionManagerParam *param;
+ TpProtocol *protocol;
+ GList *protocol_params;
+ GList *iter;
GHashTable *params;
g_return_val_if_fail (MCD_IS_ACCOUNT (account), NULL);
@@ -3540,19 +3558,25 @@ _mcd_account_dup_parameters (McdAccount *account)
g_free,
(GDestroyNotify) tp_g_value_slice_free);
- for (param = protocol->params; param->name != NULL; param++)
+ protocol_params = tp_protocol_dup_params (protocol);
+
+ for (iter = protocol_params; iter != NULL; iter = iter->next)
{
+ TpConnectionManagerParam *param = iter->data;
+ const gchar *name = tp_connection_manager_param_get_name (param);
GValue v = G_VALUE_INIT;
- if (mcd_account_get_parameter (account, param->name, &v, NULL))
+ if (mcd_account_get_parameter (account, name, &v, NULL))
{
- g_hash_table_insert (params, g_strdup (param->name),
+ g_hash_table_insert (params, g_strdup (name),
tp_g_value_slice_dup (&v));
g_value_unset (&v);
}
}
- tp_connection_manager_protocol_free (protocol);
+ g_list_free_full (protocol_params,
+ (GDestroyNotify) tp_connection_manager_param_free);
+ g_object_unref (protocol);
return params;
}
@@ -4675,7 +4699,7 @@ mcd_account_parameter_is_secret (McdAccount *self, const gchar *name)
priv->protocol_name, name);
return (param != NULL &&
- (param->flags & TP_CONN_MGR_PARAM_FLAG_SECRET) != 0);
+ tp_connection_manager_param_is_secret (param));
}
void
diff --git a/src/mcd-channel.c b/src/mcd-channel.c
index 3d6b0660..4f0a893a 100644
--- a/src/mcd-channel.c
+++ b/src/mcd-channel.c
@@ -749,7 +749,7 @@ mcd_channel_get_object_path (McdChannel *channel)
{
McdChannelPrivate *priv = MCD_CHANNEL_PRIV (channel);
- return priv->tp_chan ? TP_PROXY (priv->tp_chan)->object_path : NULL;
+ return priv->tp_chan ? tp_proxy_get_object_path (priv->tp_chan) : NULL;
}
/*
@@ -825,7 +825,7 @@ mcd_channel_get_error (McdChannel *channel)
return priv->error;
if (priv->tp_chan)
- return TP_PROXY (priv->tp_chan)->invalidated;
+ return tp_proxy_get_invalidated (priv->tp_chan);
return NULL;
}
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index f2518491..8fc7aa3a 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -494,7 +494,8 @@ _mcd_connection_call_disconnect (McdConnection *connection)
{
TpConnection *tp_conn = connection->priv->tp_conn;
- if (!tp_conn || TP_PROXY (tp_conn)->invalidated != NULL) return;
+ if (!tp_conn || tp_proxy_get_invalidated (TP_PROXY (tp_conn)) != NULL)
+ return;
if (tp_connection_get_status (tp_conn, NULL) ==
TP_CONNECTION_STATUS_DISCONNECTED) return;
@@ -2536,7 +2537,7 @@ mcd_connection_get_object_path (McdConnection *connection)
McdConnectionPrivate *priv = connection->priv;
if (priv->tp_conn)
- return TP_PROXY (priv->tp_conn)->object_path;
+ return tp_proxy_get_object_path (TP_PROXY (priv->tp_conn));
else
return NULL;
}
@@ -2547,7 +2548,7 @@ mcd_connection_get_name (McdConnection *connection)
McdConnectionPrivate *priv = connection->priv;
if (priv->tp_conn)
- return TP_PROXY (priv->tp_conn)->bus_name;
+ return tp_proxy_get_bus_name (TP_PROXY (priv->tp_conn));
else
return NULL;
}
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 48ebc833..23c943d9 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -788,7 +788,7 @@ mcd_dispatcher_constructed (GObject *object)
G_CALLBACK (mcd_dispatcher_client_registry_ready_cb),
object);
- dgc = TP_PROXY (priv->dbus_daemon)->dbus_connection;
+ dgc = tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus_daemon));
if (!tp_dbus_daemon_request_name (priv->dbus_daemon,
TP_CHANNEL_DISPATCHER_BUS_NAME,
diff --git a/src/mcd-manager-priv.h b/src/mcd-manager-priv.h
index 3dc8a429..76c97cd6 100644
--- a/src/mcd-manager-priv.h
+++ b/src/mcd-manager-priv.h
@@ -31,7 +31,7 @@
G_BEGIN_DECLS
-TpConnectionManagerProtocol *_mcd_manager_dup_protocol (McdManager *manager,
+TpProtocol *_mcd_manager_dup_protocol (McdManager *manager,
const gchar *protocol);
G_END_DECLS
diff --git a/src/mcd-manager.c b/src/mcd-manager.c
index 5c0e9fbf..39d09ea2 100644
--- a/src/mcd-manager.c
+++ b/src/mcd-manager.c
@@ -338,21 +338,21 @@ mcd_manager_get_name (McdManager *manager)
return priv->name;
}
-TpConnectionManagerProtocol *
+TpProtocol *
_mcd_manager_dup_protocol (McdManager *manager,
const gchar *protocol)
{
- const TpConnectionManagerProtocol *p;
+ TpProtocol *p;
g_return_val_if_fail (MCD_IS_MANAGER (manager), NULL);
g_return_val_if_fail (protocol != NULL, NULL);
- p = tp_connection_manager_get_protocol (manager->priv->tp_conn_mgr,
- protocol);
+ p = tp_connection_manager_get_protocol_object (manager->priv->tp_conn_mgr,
+ protocol);
if (p == NULL)
return NULL;
else
- return tp_connection_manager_protocol_copy (p);
+ return g_object_ref (p);
}
const TpConnectionManagerParam *
@@ -360,7 +360,7 @@ mcd_manager_get_protocol_param (McdManager *manager, const gchar *protocol,
const gchar *param)
{
McdManagerPrivate *priv;
- const TpConnectionManagerProtocol *cm_protocol;
+ TpProtocol *cm_protocol;
g_return_val_if_fail (MCD_IS_MANAGER (manager), NULL);
g_return_val_if_fail (protocol != NULL, NULL);
@@ -368,13 +368,13 @@ mcd_manager_get_protocol_param (McdManager *manager, const gchar *protocol,
priv = manager->priv;
- cm_protocol = tp_connection_manager_get_protocol (priv->tp_conn_mgr,
- protocol);
+ cm_protocol = tp_connection_manager_get_protocol_object (priv->tp_conn_mgr,
+ protocol);
if (cm_protocol == NULL)
return NULL;
- return tp_connection_manager_protocol_get_param (cm_protocol, param);
+ return tp_protocol_get_param (cm_protocol, param);
}
McdConnection *
diff --git a/src/mcd-master.c b/src/mcd-master.c
index ccf34d6d..c7f1d976 100644
--- a/src/mcd-master.c
+++ b/src/mcd-master.c
@@ -287,8 +287,8 @@ _mcd_master_get_property (GObject * obj, guint prop_id,
g_value_set_object (val, priv->dbus_daemon);
break;
case PROP_DBUS_CONNECTION:
- g_value_set_pointer (val,
- TP_PROXY (priv->dbus_daemon)->dbus_connection);
+ g_value_set_pointer (val, tp_proxy_get_dbus_connection (
+ TP_PROXY (priv->dbus_daemon)));
break;
case PROP_ACCOUNT_MANAGER:
g_value_set_object (val, priv->account_manager);
@@ -389,7 +389,7 @@ mcd_master_constructor (GType type, guint n_params,
dbus_connection_set_exit_on_disconnect (
dbus_g_connection_get_connection (
- TP_PROXY (priv->dbus_daemon)->dbus_connection),
+ tp_proxy_get_dbus_connection (TP_PROXY (priv->dbus_daemon))),
TRUE);
mcd_kludge_transport_install (master);
diff --git a/tests/twisted/mc-debug-server.c b/tests/twisted/mc-debug-server.c
index 03055e8d..15944fed 100644
--- a/tests/twisted/mc-debug-server.c
+++ b/tests/twisted/mc-debug-server.c
@@ -73,7 +73,7 @@ billy_idle (gpointer user_data)
{
DBusMessage *reply = user_data;
DBusConnection *connection = dbus_g_connection_get_connection (
- ((TpProxy *) bus_daemon)->dbus_connection);
+ tp_proxy_get_dbus_connection (bus_daemon));
if (!dbus_connection_send (connection, reply, NULL))
g_error ("Out of memory");
@@ -192,7 +192,7 @@ main (int argc, char **argv)
* DBUS_HANDLER_RESULT_HANDLED for signals, so for *our* filter to have any
* effect, we need to install it as soon as possible */
connection = dbus_g_connection_get_connection (
- ((TpProxy *) bus_daemon)->dbus_connection);
+ tp_proxy_get_dbus_connection (bus_daemon));
dbus_connection_add_filter (connection, dbus_filter_function, NULL, NULL);
#if ENABLE_GNOME_KEYRING