summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-05 16:30:20 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-06 11:43:02 +0100
commitebc9b3a24bb537784415f6e1e75a84c7197dd6da (patch)
tree0caa3f961a1043dd30d01d9f156d6e7a2de89892
parent87df2bc27a610a6c815fd1c4c59c256990552dfe (diff)
salut: move more common files to plugin-base
"ifdef soup" Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--plugin-base/Makefile.am4
-rw-r--r--plugin-base/caps-manager.c4
-rw-r--r--plugin-base/channel-manager.c (renamed from salut/channel-manager.c)69
-rw-r--r--plugin-base/channel-manager.h (renamed from salut/channel-manager.h)4
-rw-r--r--plugin-base/ytstenut.c (renamed from salut/ytstenut.c)59
-rw-r--r--plugin-base/ytstenut.h (renamed from salut/ytstenut.h)0
-rw-r--r--salut/Makefile.am8
7 files changed, 127 insertions, 21 deletions
diff --git a/plugin-base/Makefile.am b/plugin-base/Makefile.am
index dfaa9f9..f1e676e 100644
--- a/plugin-base/Makefile.am
+++ b/plugin-base/Makefile.am
@@ -1,5 +1,9 @@
EXTRA_DIST = \
caps-manager.c \
caps-manager.h \
+ channel-manager.c \
+ channel-manager.h \
+ ytstenut.c \
+ ytstenut.h \
utils.c \
utils.h
diff --git a/plugin-base/caps-manager.c b/plugin-base/caps-manager.c
index be61ef1..73d34fc 100644
--- a/plugin-base/caps-manager.c
+++ b/plugin-base/caps-manager.c
@@ -241,7 +241,11 @@ caps_channel_manager_iface_init (
gpointer g_iface,
gpointer data G_GNUC_UNUSED)
{
+#ifdef SALUT /* sigh */
GabbleCapsChannelManagerIface *iface = g_iface;
+#else
+ GabbleCapsChannelManagerInterface *iface = g_iface;
+#endif
iface->represent_client = ytst_caps_manager_represent_client;
}
diff --git a/salut/channel-manager.c b/plugin-base/channel-manager.c
index c8ba267..9d81168 100644
--- a/salut/channel-manager.c
+++ b/plugin-base/channel-manager.c
@@ -32,7 +32,13 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/util.h>
+#include <wocky/wocky-session.h>
+
+#ifdef SALUT
#include <salut/caps-channel-manager.h>
+#else
+#include <gabble/caps-channel-manager.h>
+#endif
#include <telepathy-ytstenut-glib/telepathy-ytstenut-glib.h>
@@ -61,7 +67,11 @@ enum
/* private structure */
struct _YtstChannelManagerPrivate
{
+#ifdef SALUT
SalutConnection *connection;
+#else
+ GabbleConnection *connection;
+#endif
GQueue *channels;
gulong status_changed_id;
guint message_handler_id;
@@ -118,7 +128,9 @@ message_stanza_callback (WockyPorter *porter,
TP_HANDLE_TYPE_CONTACT);
YtstMessageChannel *channel;
TpHandle handle;
+#ifdef SALUT
WockyContact *contact = wocky_stanza_get_from_contact (stanza);
+#endif
gchar *jid;
/* needs to be type get or set */
@@ -132,7 +144,11 @@ message_stanza_callback (WockyPorter *porter,
if (wocky_node_get_attribute (top, "id") == NULL)
return FALSE;
+#ifdef SALUT
jid = wocky_contact_dup_jid (WOCKY_CONTACT (contact));
+#else
+ jid = g_strdup (wocky_stanza_get_from (stanza));
+#endif
handle = tp_handle_lookup (handle_repo, jid, NULL, NULL);
if (handle == 0)
{
@@ -141,7 +157,12 @@ message_stanza_callback (WockyPorter *porter,
}
channel = ytst_message_channel_new (priv->connection,
- WOCKY_LL_CONTACT (contact), stanza, handle, handle, FALSE);
+#ifdef SALUT
+ WOCKY_LL_CONTACT (contact),
+#else
+ jid,
+#endif
+ stanza, handle, handle, FALSE);
manager_take_ownership_of_channel (self, channel);
tp_channel_manager_emit_new_channel (self, TP_EXPORTABLE_CHANNEL (channel),
NULL);
@@ -173,7 +194,7 @@ manager_close_all (YtstChannelManager *self)
}
static void
-on_connection_status_changed (SalutConnection *conn,
+on_connection_status_changed (TpBaseConnection *conn,
guint status,
guint reason,
YtstChannelManager *self)
@@ -243,7 +264,11 @@ ytst_channel_manager_constructed (GObject *object)
priv->channels = g_queue_new ();
+#ifdef SALUT
session = salut_connection_get_session (priv->connection);
+#else
+ session = gabble_connection_get_session (priv->connection);
+#endif
priv->message_handler_id = wocky_porter_register_handler_from_anyone (
wocky_session_get_porter (session),
@@ -273,7 +298,11 @@ ytst_channel_manager_dispose (GObject *object)
priv->dispose_has_run = TRUE;
+#ifdef SALUT
session = salut_connection_get_session (priv->connection);
+#else
+ session = gabble_connection_get_session (priv->connection);
+#endif
if (session != NULL)
{
@@ -304,9 +333,9 @@ ytst_channel_manager_class_init (YtstChannelManagerClass *klass)
param_spec = g_param_spec_object (
"connection",
- "SalutConnection object",
- "Salut connection object that owns this channel factory object.",
- SALUT_TYPE_CONNECTION,
+ "TpBaseConnection object",
+ "Connection object that owns this channel factory object.",
+ TP_TYPE_BASE_CONNECTION,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
@@ -395,9 +424,13 @@ ytst_channel_manager_create_channel (TpChannelManager *manager,
TpHandle handle;
GError *error = NULL;
const gchar *name;
+#ifdef SALUT
WockySession *session;
WockyContactFactory *factory;
WockyLLContact *contact;
+#else
+ TpHandle self_handle;
+#endif
WockyStanza *request;
GSList *tokens = NULL;
YtstMessageChannel *channel;
@@ -425,6 +458,7 @@ ytst_channel_manager_create_channel (TpChannelManager *manager,
name = tp_handle_inspect (handle_repo, handle);
DEBUG ("Requested channel for handle: %u (%s)", handle, name);
+#ifdef SALUT
session = salut_connection_get_session (priv->connection);
factory = wocky_session_get_contact_factory (session);
contact = wocky_contact_factory_lookup_ll_contact (factory, name);
@@ -434,14 +468,27 @@ ytst_channel_manager_create_channel (TpChannelManager *manager,
"%s is not online", name);
goto error;
}
+#else
+ self_handle = tp_base_connection_get_self_handle (base_conn);
+#endif
request = ytst_message_channel_build_request (request_properties,
- salut_connection_get_name (priv->connection), contact, &error);
+#ifdef SALUT
+ salut_connection_get_name (priv->connection), contact,
+#else
+ tp_handle_inspect (handle_repo, self_handle), name,
+#endif
+ &error);
if (request == NULL)
goto error;
- channel = ytst_message_channel_new (priv->connection, contact, request, handle,
- base_conn->self_handle, TRUE);
+ channel = ytst_message_channel_new (priv->connection,
+#ifdef SALUT
+ contact,
+#else
+ name,
+#endif
+ request, handle, base_conn->self_handle, TRUE);
manager_take_ownership_of_channel (self, channel);
g_object_unref (request);
@@ -484,7 +531,11 @@ static void
ytst_caps_channel_manager_iface_init (gpointer g_iface,
gpointer iface_data)
{
+#ifdef SALUT /* sigh */
GabbleCapsChannelManagerIface *iface = g_iface;
+#else
+ GabbleCapsChannelManagerInterface *iface = g_iface;
+#endif
/* we don't need any of these */
iface->reset_caps = NULL;
@@ -494,7 +545,7 @@ ytst_caps_channel_manager_iface_init (gpointer g_iface,
/* public functions */
YtstChannelManager *
-ytst_channel_manager_new (SalutConnection *connection)
+ytst_channel_manager_new (TpBaseConnection *connection)
{
return g_object_new (YTST_TYPE_CHANNEL_MANAGER,
"connection", connection,
diff --git a/salut/channel-manager.h b/plugin-base/channel-manager.h
index 31e3952..13b27a5 100644
--- a/salut/channel-manager.h
+++ b/plugin-base/channel-manager.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
-#include <salut/connection.h>
+#include <telepathy-glib/base-connection.h>
G_BEGIN_DECLS
@@ -59,6 +59,6 @@ GType ytst_channel_manager_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), YTST_TYPE_CHANNEL_MANAGER, \
YtstChannelManagerClass))
-YtstChannelManager * ytst_channel_manager_new (SalutConnection *connection);
+YtstChannelManager * ytst_channel_manager_new (TpBaseConnection *connection);
#endif /* #ifndef __YTST_CHANNEL_MANAGER_H__*/
diff --git a/salut/ytstenut.c b/plugin-base/ytstenut.c
index edb03fa..f2a7662 100644
--- a/salut/ytstenut.c
+++ b/plugin-base/ytstenut.c
@@ -26,8 +26,12 @@
#include "status.h"
#include "channel-manager.h"
+#ifdef SALUT
#include <salut/plugin.h>
#include <salut/protocol.h>
+#else
+#include <gabble/plugin.h>
+#endif
#include <telepathy-ytstenut-glib/telepathy-ytstenut-glib.h>
@@ -42,7 +46,11 @@ static const gchar * const sidecar_interfaces[] = {
static void plugin_iface_init (gpointer g_iface, gpointer data);
G_DEFINE_TYPE_WITH_CODE (YtstPlugin, ytst_plugin, G_TYPE_OBJECT,
+#ifdef SALUT
G_IMPLEMENT_INTERFACE (SALUT_TYPE_PLUGIN, plugin_iface_init);
+#else
+ G_IMPLEMENT_INTERFACE (GABBLE_TYPE_PLUGIN, plugin_iface_init);
+#endif
)
static void
@@ -56,6 +64,7 @@ ytst_plugin_class_init (YtstPluginClass *klass)
{
}
+#ifdef SALUT
static void
ytstenut_plugin_initialize (SalutPlugin *plugin,
TpBaseConnectionManager *connection_manager)
@@ -68,27 +77,49 @@ ytstenut_plugin_initialize (SalutPlugin *plugin,
"_ytstenut._tcp", "local-ytstenut", "Ytstenut protocol", "im-ytstenut");
tp_base_connection_manager_add_protocol (connection_manager, protocol);
}
+#endif
static void
ytstenut_plugin_create_sidecar (
+#ifdef SALUT
SalutPlugin *plugin,
+#else
+ GabblePlugin *plugin,
+#endif
const gchar *sidecar_interface,
+#ifdef SALUT
SalutConnection *connection,
+#else
+ GabbleConnection *connection,
+#endif
WockySession *session,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin),
callback, user_data,
- /* sic: all plugins share salut_plugin_create_sidecar_finish() so we
+ /* sic: all plugins share {salut,gabble}_plugin_create_sidecar_finish() so we
* need to use the same source tag.
*/
- salut_plugin_create_sidecar_async);
+#ifdef SALUT
+ salut_plugin_create_sidecar_async
+#else
+ gabble_plugin_create_sidecar
+#endif
+ );
+#ifdef SALUT
SalutSidecar *sidecar = NULL;
+#else
+ GabbleSidecar *sidecar = NULL;
+#endif
if (!tp_strdiff (sidecar_interface, TP_YTS_IFACE_STATUS))
{
+#ifdef SALUT
sidecar = SALUT_SIDECAR (ytst_status_new (session, connection));
+#else
+ sidecar = GABBLE_SIDECAR (ytst_status_new (session, connection));
+#endif
DEBUG ("created side car for: %s", TP_YTS_IFACE_STATUS);
}
else
@@ -105,7 +136,12 @@ ytstenut_plugin_create_sidecar (
}
static GPtrArray *
-ytstenut_plugin_create_channel_managers (SalutPlugin *plugin,
+ytstenut_plugin_create_channel_managers (
+#ifdef SALUT
+ SalutPlugin *plugin,
+#else
+ GabblePlugin *plugin,
+#endif
TpBaseConnection *connection)
{
GPtrArray *ret = g_ptr_array_sized_new (1);
@@ -113,8 +149,7 @@ ytstenut_plugin_create_channel_managers (SalutPlugin *plugin,
DEBUG ("%p on connection %p", plugin, connection);
g_ptr_array_add (ret, g_object_new (YTST_TYPE_CAPS_MANAGER, NULL));
- g_ptr_array_add (ret, ytst_channel_manager_new (
- SALUT_CONNECTION (connection)));
+ g_ptr_array_add (ret, ytst_channel_manager_new (connection));
return ret;
}
@@ -123,20 +158,32 @@ static void
plugin_iface_init (gpointer g_iface,
gpointer data G_GNUC_UNUSED)
{
+#ifdef SALUT
SalutPluginInterface *iface = g_iface;
+#else
+ GabblePluginInterface *iface = g_iface;
+ #endif
+#ifdef SALUT
iface->api_version = SALUT_PLUGIN_CURRENT_VERSION;
+ iface->initialize = ytstenut_plugin_initialize;
+#endif
+
iface->name = "Ytstenut plugin";
iface->version = PACKAGE_VERSION;
iface->sidecar_interfaces = sidecar_interfaces;
iface->create_sidecar = ytstenut_plugin_create_sidecar;
- iface->initialize = ytstenut_plugin_initialize;
iface->create_channel_managers = ytstenut_plugin_create_channel_managers;
}
+#ifdef SALUT
SalutPlugin *
salut_plugin_create (void)
+#else
+GabblePlugin *
+gabble_plugin_create (void)
+#endif
{
return g_object_new (YTST_TYPE_PLUGIN, NULL);
}
diff --git a/salut/ytstenut.h b/plugin-base/ytstenut.h
index fdd5389..fdd5389 100644
--- a/salut/ytstenut.h
+++ b/plugin-base/ytstenut.h
diff --git a/salut/Makefile.am b/salut/Makefile.am
index 181154c..20ea5ac 100644
--- a/salut/Makefile.am
+++ b/salut/Makefile.am
@@ -16,15 +16,15 @@ ytstenut_salut_la_LIBADD = \
$(TELEPATHY_YTSTENUT_LIBS)
ytstenut_salut_la_SOURCES = \
- ytstenut.c \
- ytstenut.h \
+ $(top_srcdir)/plugin-base/ytstenut.c \
+ $(top_srcdir)/plugin-base/ytstenut.h \
$(top_srcdir)/plugin-base/caps-manager.c \
$(top_srcdir)/plugin-base/caps-manager.h \
status.c \
status.h \
message-channel.c \
message-channel.h \
- channel-manager.c \
- channel-manager.h \
+ $(top_srcdir)/plugin-base/channel-manager.c \
+ $(top_srcdir)/plugin-base/channel-manager.h \
$(top_srcdir)/plugin-base/utils.c \
$(top_srcdir)/plugin-base/utils.h