summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-05-29 12:52:42 +0200
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-06-28 13:50:00 +0200
commit005b08101e316ac0bdf375f18cc75df7f6990857 (patch)
treea6d2f474ab4fac7518102ed36ce197cc2a3539b7
parent25a3af6923d9e17ff4d6ae3e1bcf9322e7da3731 (diff)
downloadtelepathy-glib-005b08101e316ac0bdf375f18cc75df7f6990857.tar.gz
TpDynamicHandleRepo: factor out ensure_handle_take_normalized_id()
https://bugs.freedesktop.org/show_bug.cgi?id=50341
-rw-r--r--telepathy-glib/handle-repo-dynamic.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/telepathy-glib/handle-repo-dynamic.c b/telepathy-glib/handle-repo-dynamic.c
index e324f440d..9bd651387 100644
--- a/telepathy-glib/handle-repo-dynamic.c
+++ b/telepathy-glib/handle-repo-dynamic.c
@@ -469,29 +469,14 @@ dynamic_lookup_handle (TpHandleRepoIface *irepo,
}
static TpHandle
-dynamic_ensure_handle (TpHandleRepoIface *irepo,
- const char *id,
- gpointer context,
- GError **error)
+ensure_handle_take_normalized_id (TpDynamicHandleRepo *self,
+ gchar *normal_id)
{
- TpDynamicHandleRepo *self = TP_DYNAMIC_HANDLE_REPO (irepo);
TpHandle handle;
TpHandlePriv *priv;
- gchar *normal_id = NULL;
- if (context == NULL)
- context = self->default_normalize_context;
-
- if (self->normalize_function)
- {
- normal_id = (self->normalize_function) (irepo, id, context, error);
- if (normal_id == NULL)
- return 0;
-
- id = normal_id;
- }
-
- handle = GPOINTER_TO_UINT (g_hash_table_lookup (self->string_to_handle, id));
+ handle = GPOINTER_TO_UINT (g_hash_table_lookup (self->string_to_handle,
+ normal_id));
if (handle != 0)
{
@@ -499,9 +484,6 @@ dynamic_ensure_handle (TpHandleRepoIface *irepo,
return handle;
}
- if (normal_id == NULL)
- normal_id = g_strdup (id);
-
handle = self->handle_to_priv->len;
g_array_append_val (self->handle_to_priv, empty_priv);
priv = &g_array_index (self->handle_to_priv, TpHandlePriv, handle);
@@ -513,6 +495,31 @@ dynamic_ensure_handle (TpHandleRepoIface *irepo,
return handle;
}
+static TpHandle
+dynamic_ensure_handle (TpHandleRepoIface *irepo,
+ const char *id,
+ gpointer context,
+ GError **error)
+{
+ TpDynamicHandleRepo *self = TP_DYNAMIC_HANDLE_REPO (irepo);
+ gchar *normal_id;
+
+ if (context == NULL)
+ context = self->default_normalize_context;
+
+ if (self->normalize_function)
+ {
+ normal_id = (self->normalize_function) (irepo, id, context, error);
+ if (normal_id == NULL)
+ return 0;
+ }
+ else
+ {
+ normal_id = g_strdup (id);
+ }
+
+ return ensure_handle_take_normalized_id (self, normal_id);
+}
static void
dynamic_set_qdata (TpHandleRepoIface *repo, TpHandle handle,