summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-09-01 17:07:29 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-09-01 17:14:48 +0100
commit569176a4df56da2e8dda637d1a3e5f39a1549f47 (patch)
treecef45162f8074815985a40f5ce77e5018516a4a3
parent0b71b1ad5eefb26b3bb1bc8dfcc41f8c63f6ccfd (diff)
wocky-session: create a contact-factory
-rw-r--r--tests/wocky-session-test.c17
-rw-r--r--wocky/wocky-session.c24
-rw-r--r--wocky/wocky-session.h3
3 files changed, 42 insertions, 2 deletions
diff --git a/tests/wocky-session-test.c b/tests/wocky-session-test.c
index 66980f3..99b624d 100644
--- a/tests/wocky-session-test.c
+++ b/tests/wocky-session-test.c
@@ -44,6 +44,22 @@ test_get_porter (void)
teardown_test (test);
}
+static void
+test_get_contact_factory (void)
+{
+ test_data_t *test = setup_test ();
+ WockySession *session;
+ WockyContactFactory *factory;
+
+ session = wocky_session_new (test->in);
+
+ factory = wocky_session_get_contact_factory (session);
+ g_assert (WOCKY_IS_CONTACT_FACTORY (factory));
+
+ g_object_unref (session);
+ teardown_test (test);
+}
+
int
main (int argc, char **argv)
{
@@ -53,6 +69,7 @@ main (int argc, char **argv)
g_test_add_func ("/session/instantiation", test_instantiation);
g_test_add_func ("/session/get-porter", test_get_porter);
+ g_test_add_func ("/session/get-contact-factory", test_get_contact_factory);
result = g_test_run ();
test_deinit ();
diff --git a/wocky/wocky-session.c b/wocky/wocky-session.c
index e96f67f..b9dec74 100644
--- a/wocky/wocky-session.c
+++ b/wocky/wocky-session.c
@@ -43,6 +43,7 @@ enum
{
PROP_CONNECTION = 1,
PROP_PORTER,
+ PROP_CONTACT_FACTORY,
};
/* signal enum */
@@ -64,6 +65,7 @@ struct _WockySessionPrivate
WockyXmppConnection *connection;
WockyPorter *porter;
+ WockyContactFactory *contact_factory;
};
#define WOCKY_SESSION_GET_PRIVATE(o) \
@@ -73,10 +75,10 @@ struct _WockySessionPrivate
static void
wocky_session_init (WockySession *obj)
{
- /*
WockySession *self = WOCKY_SESSION (obj);
WockySessionPrivate *priv = WOCKY_SESSION_GET_PRIVATE (self);
- */
+
+ priv->contact_factory = wocky_contact_factory_new ();
}
static void
@@ -116,6 +118,9 @@ wocky_session_get_property (GObject *object,
case PROP_PORTER:
g_value_set_object (value, priv->porter);
break;
+ case PROP_CONTACT_FACTORY:
+ g_value_set_object (value, priv->contact_factory);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -146,6 +151,7 @@ wocky_session_dispose (GObject *object)
g_object_unref (priv->connection);
g_object_unref (priv->porter);
+ g_object_unref (priv->contact_factory);
if (G_OBJECT_CLASS (wocky_session_parent_class)->dispose)
G_OBJECT_CLASS (wocky_session_parent_class)->dispose (object);
@@ -191,6 +197,12 @@ wocky_session_class_init (WockySessionClass *wocky_session_class)
G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_PORTER, spec);
+ spec = g_param_spec_object ("contact-factory", "Contact factory",
+ "The WockyContactFactory associated with this session",
+ WOCKY_TYPE_CONTACT_FACTORY,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_CONTACT_FACTORY, spec);
}
WockySession *
@@ -208,3 +220,11 @@ wocky_session_get_porter (WockySession *self)
return priv->porter;
}
+
+WockyContactFactory *
+wocky_session_get_contact_factory (WockySession *self)
+{
+ WockySessionPrivate *priv = WOCKY_SESSION_GET_PRIVATE (self);
+
+ return priv->contact_factory;
+}
diff --git a/wocky/wocky-session.h b/wocky/wocky-session.h
index 0ed5781..449d2aa 100644
--- a/wocky/wocky-session.h
+++ b/wocky/wocky-session.h
@@ -26,6 +26,7 @@
#include "wocky-types.h"
#include "wocky-xmpp-connection.h"
#include "wocky-porter.h"
+#include "wocky-contact-factory.h"
G_BEGIN_DECLS
@@ -61,6 +62,8 @@ WockySession * wocky_session_new (WockyXmppConnection *conn);
WockyPorter * wocky_session_get_porter (WockySession *session);
+WockyContactFactory * wocky_session_get_contact_factory (WockySession *session);
+
G_END_DECLS
#endif /* #ifndef __WOCKY_SESSION_H__*/