[telepathy-gabble/master] Add a utility function to convert a list of candidates to the a GPtrArray
Sjoerd Simons
sjoerd.simons at collabora.co.uk
Tue Dec 29 05:35:06 PST 2009
---
src/call-stream.c | 31 ++-----------------------------
src/util.c | 39 +++++++++++++++++++++++++++++++++++++++
src/util.h | 2 ++
3 files changed, 43 insertions(+), 29 deletions(-)
diff --git a/src/call-stream.c b/src/call-stream.c
index 5fe28e0..acf1e90 100644
--- a/src/call-stream.c
+++ b/src/call-stream.c
@@ -115,37 +115,10 @@ gabble_call_stream_get_property (GObject *object,
GPtrArray *arr;
GList *candidates =
gabble_jingle_content_get_local_candidates (priv->content);
- GList *c;
-
- arr = g_ptr_array_sized_new (g_list_length (candidates));
-
- for (c = candidates; c != NULL; c = g_list_next (c))
- {
- JingleCandidate *cand = (JingleCandidate *) c->data;
- GValueArray *a;
- GHashTable *info;
-
- info = tp_asv_new (
- "Protocol", G_TYPE_UINT, cand->protocol,
- "Type", G_TYPE_UINT, cand->type,
- "Foundation", G_TYPE_STRING, cand->id,
- "Priority", G_TYPE_UINT,
- (guint) cand->preference * 65536,
- "Username", G_TYPE_STRING, cand->username,
- "Password", G_TYPE_STRING, cand->password,
- NULL);
-
- a = gabble_value_array_build (4,
- G_TYPE_UINT, cand->component,
- G_TYPE_STRING, cand->address,
- G_TYPE_UINT, cand->port,
- GABBLE_HASH_TYPE_CANDIDATE_INFO, info,
- G_TYPE_INVALID);
-
- g_ptr_array_add (arr, a);
- }
+ arr = gabble_call_candidates_to_array (candidates);
g_value_set_boxed (value, arr);
+ g_ptr_array_unref (arr);
break;
}
diff --git a/src/util.c b/src/util.c
index 84b74eb..46eb2a8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -31,6 +31,9 @@
#include <wocky/wocky-utils.h>
#include <telepathy-glib/handle-repo-dynamic.h>
+#include <telepathy-glib/dbus.h>
+
+#include <extensions/extensions.h>
#ifdef HAVE_UUID
# include <uuid.h>
@@ -1237,3 +1240,39 @@ gabble_value_array_build (gsize length,
return arr;
}
+GPtrArray *
+gabble_call_candidates_to_array (GList *candidates)
+{
+ GPtrArray *arr;
+ GList *c;
+
+ arr = g_ptr_array_sized_new (g_list_length (candidates));
+
+ for (c = candidates; c != NULL; c = g_list_next (c))
+ {
+ JingleCandidate *cand = (JingleCandidate *) c->data;
+ GValueArray *a;
+ GHashTable *info;
+
+ info = tp_asv_new (
+ "Protocol", G_TYPE_UINT, cand->protocol,
+ "Type", G_TYPE_UINT, cand->type,
+ "Foundation", G_TYPE_STRING, cand->id,
+ "Priority", G_TYPE_UINT,
+ (guint) cand->preference * 65536,
+ "Username", G_TYPE_STRING, cand->username,
+ "Password", G_TYPE_STRING, cand->password,
+ NULL);
+
+ a = gabble_value_array_build (4,
+ G_TYPE_UINT, cand->component,
+ G_TYPE_STRING, cand->address,
+ G_TYPE_UINT, cand->port,
+ GABBLE_HASH_TYPE_CANDIDATE_INFO, info,
+ G_TYPE_INVALID);
+
+ g_ptr_array_add (arr, a);
+ }
+
+ return arr;
+}
diff --git a/src/util.h b/src/util.h
index 1174b0c..e724f74 100644
--- a/src/util.h
+++ b/src/util.h
@@ -120,4 +120,6 @@ GValueArray *gabble_value_array_build (gsize length,
GType type,
...);
+GPtrArray *gabble_call_candidates_to_array (GList *candidates);
+
#endif /* __GABBLE_UTIL_H__ */
--
1.5.6.5
More information about the telepathy-commits
mailing list