[Telepathy-commits] [telepathy-glib/master] extended example CM: add connection- prefix to manager.[ch]
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Jan 7 07:46:12 PST 2009
Also rename ExampleConnectionManager to
ExampleExtendedConnectionManager
---
examples/cm/extended/Makefile.am | 6 +-
examples/cm/extended/connection-manager.c | 96 +++++++++++++++++++++++++++++
examples/cm/extended/connection-manager.h | 59 ++++++++++++++++++
examples/cm/extended/main.c | 5 +-
examples/cm/extended/manager.c | 94 ----------------------------
examples/cm/extended/manager.h | 52 ----------------
6 files changed, 161 insertions(+), 151 deletions(-)
create mode 100644 examples/cm/extended/connection-manager.c
create mode 100644 examples/cm/extended/connection-manager.h
delete mode 100644 examples/cm/extended/manager.c
delete mode 100644 examples/cm/extended/manager.h
diff --git a/examples/cm/extended/Makefile.am b/examples/cm/extended/Makefile.am
index 2739f33..d6a05d6 100644
--- a/examples/cm/extended/Makefile.am
+++ b/examples/cm/extended/Makefile.am
@@ -3,9 +3,9 @@ noinst_PROGRAMS = telepathy-example-cm-extended
telepathy_example_cm_extended_SOURCES = \
conn.c \
conn.h \
- main.c \
- manager.c \
- manager.h
+ connection-manager.c \
+ connection-manager.h \
+ main.c
# In an external project you'd use $(TP_GLIB_LIBS) (obtained from
# pkg-config via autoconf) instead of the path to libtelepathy-glib.la
diff --git a/examples/cm/extended/connection-manager.c b/examples/cm/extended/connection-manager.c
new file mode 100644
index 0000000..5a1087b
--- /dev/null
+++ b/examples/cm/extended/connection-manager.c
@@ -0,0 +1,96 @@
+/*
+ * manager.c - an example connection manager
+ *
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * Copying and distribution of this file, with or without modification,
+ * are permitted in any medium without royalty provided the copyright
+ * notice and this notice are preserved.
+ */
+
+#include "connection-manager.h"
+
+#include <dbus/dbus-protocol.h>
+#include <dbus/dbus-glib.h>
+
+#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/errors.h>
+
+#include "conn.h"
+
+G_DEFINE_TYPE (ExampleExtendedConnectionManager,
+ example_extended_connection_manager,
+ TP_TYPE_BASE_CONNECTION_MANAGER)
+
+/* type definition stuff */
+
+static void
+example_extended_connection_manager_init (
+ ExampleExtendedConnectionManager *self)
+{
+}
+
+/* private data */
+
+typedef struct {
+ gchar *account;
+} ExampleParams;
+
+static const TpCMParamSpec example_params[] = {
+ { "account", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING,
+ TP_CONN_MGR_PARAM_FLAG_REQUIRED | TP_CONN_MGR_PARAM_FLAG_REGISTER, NULL,
+ G_STRUCT_OFFSET (ExampleParams, account),
+ tp_cm_param_filter_string_nonempty, NULL },
+
+ { NULL }
+};
+
+static gpointer
+alloc_params (void)
+{
+ return g_slice_new0 (ExampleParams);
+}
+
+static void
+free_params (gpointer p)
+{
+ ExampleParams *params = p;
+
+ g_free (params->account);
+
+ g_slice_free (ExampleParams, params);
+}
+
+static const TpCMProtocolSpec example_protocols[] = {
+ { "example", example_params, alloc_params, free_params },
+ { NULL, NULL }
+};
+
+static TpBaseConnection *
+new_connection (TpBaseConnectionManager *self,
+ const gchar *proto,
+ TpIntSet *params_present,
+ gpointer parsed_params,
+ GError **error)
+{
+ ExampleParams *params = parsed_params;
+ ExampleConnection *conn = EXAMPLE_CONNECTION
+ (g_object_new (EXAMPLE_TYPE_CONNECTION,
+ "account", params->account,
+ "protocol", proto,
+ NULL));
+
+ return (TpBaseConnection *) conn;
+}
+
+static void
+example_extended_connection_manager_class_init (
+ ExampleExtendedConnectionManagerClass *klass)
+{
+ TpBaseConnectionManagerClass *base_class =
+ (TpBaseConnectionManagerClass *) klass;
+
+ base_class->new_connection = new_connection;
+ base_class->cm_dbus_name = "example_extended";
+ base_class->protocol_params = example_protocols;
+}
diff --git a/examples/cm/extended/connection-manager.h b/examples/cm/extended/connection-manager.h
new file mode 100644
index 0000000..caae01a
--- /dev/null
+++ b/examples/cm/extended/connection-manager.h
@@ -0,0 +1,59 @@
+/*
+ * manager.h - header for an example connection manager
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * Copying and distribution of this file, with or without modification,
+ * are permitted in any medium without royalty provided the copyright
+ * notice and this notice are preserved.
+ */
+
+#ifndef __EXAMPLE_EXTENDED_CONNECTION_MANAGER_H__
+#define __EXAMPLE_EXTENDED_CONNECTION_MANAGER_H__
+
+#include <glib-object.h>
+#include <telepathy-glib/base-connection-manager.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ExampleExtendedConnectionManager
+ ExampleExtendedConnectionManager;
+typedef struct _ExampleExtendedConnectionManagerClass
+ ExampleExtendedConnectionManagerClass;
+
+struct _ExampleExtendedConnectionManagerClass {
+ TpBaseConnectionManagerClass parent_class;
+};
+
+struct _ExampleExtendedConnectionManager {
+ TpBaseConnectionManager parent;
+
+ gpointer priv;
+};
+
+GType example_extended_connection_manager_get_type (void);
+
+/* TYPE MACROS */
+#define EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER \
+ (example_extended_connection_manager_get_type ())
+#define EXAMPLE_EXTENDED_CONNECTION_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER, \
+ ExampleExtendedConnectionManager))
+#define EXAMPLE_EXTENDED_CONNECTION_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER, \
+ ExampleExtendedConnectionManagerClass))
+#define EXAMPLE_IS_EXTENDED_CONNECTION_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER))
+#define EXAMPLE_IS_EXTENDED_CONNECTION_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER))
+#define EXAMPLE_EXTENDED_CONNECTION_MANAGER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER, \
+ ExampleExtendedConnectionManagerClass))
+
+G_END_DECLS
+
+#endif
diff --git a/examples/cm/extended/main.c b/examples/cm/extended/main.c
index b82e230..b0aba71 100644
--- a/examples/cm/extended/main.c
+++ b/examples/cm/extended/main.c
@@ -13,13 +13,14 @@
#include <telepathy-glib/debug.h>
#include <telepathy-glib/run.h>
-#include "manager.h"
+
+#include "connection-manager.h"
static TpBaseConnectionManager *
construct_cm (void)
{
return (TpBaseConnectionManager *) g_object_new (
- EXAMPLE_TYPE_CONNECTION_MANAGER,
+ EXAMPLE_TYPE_EXTENDED_CONNECTION_MANAGER,
NULL);
}
diff --git a/examples/cm/extended/manager.c b/examples/cm/extended/manager.c
deleted file mode 100644
index 16dc023..0000000
--- a/examples/cm/extended/manager.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * manager.c - an example connection manager
- *
- * Copyright (C) 2007 Collabora Ltd.
- *
- * Copying and distribution of this file, with or without modification,
- * are permitted in any medium without royalty provided the copyright
- * notice and this notice are preserved.
- */
-
-#include "manager.h"
-
-#include <dbus/dbus-protocol.h>
-#include <dbus/dbus-glib.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/errors.h>
-
-#include "conn.h"
-
-G_DEFINE_TYPE (ExampleConnectionManager,
- example_connection_manager,
- TP_TYPE_BASE_CONNECTION_MANAGER)
-
-/* type definition stuff */
-
-static void
-example_connection_manager_init (ExampleConnectionManager *self)
-{
-}
-
-/* private data */
-
-typedef struct {
- gchar *account;
-} ExampleParams;
-
-static const TpCMParamSpec example_params[] = {
- { "account", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING,
- TP_CONN_MGR_PARAM_FLAG_REQUIRED | TP_CONN_MGR_PARAM_FLAG_REGISTER, NULL,
- G_STRUCT_OFFSET (ExampleParams, account),
- tp_cm_param_filter_string_nonempty, NULL },
-
- { NULL }
-};
-
-static gpointer
-alloc_params (void)
-{
- return g_slice_new0 (ExampleParams);
-}
-
-static void
-free_params (gpointer p)
-{
- ExampleParams *params = p;
-
- g_free (params->account);
-
- g_slice_free (ExampleParams, params);
-}
-
-static const TpCMProtocolSpec example_protocols[] = {
- { "example", example_params, alloc_params, free_params },
- { NULL, NULL }
-};
-
-static TpBaseConnection *
-new_connection (TpBaseConnectionManager *self,
- const gchar *proto,
- TpIntSet *params_present,
- gpointer parsed_params,
- GError **error)
-{
- ExampleParams *params = parsed_params;
- ExampleConnection *conn = EXAMPLE_CONNECTION
- (g_object_new (EXAMPLE_TYPE_CONNECTION,
- "account", params->account,
- "protocol", proto,
- NULL));
-
- return (TpBaseConnection *) conn;
-}
-
-static void
-example_connection_manager_class_init (ExampleConnectionManagerClass *klass)
-{
- TpBaseConnectionManagerClass *base_class =
- (TpBaseConnectionManagerClass *) klass;
-
- base_class->new_connection = new_connection;
- base_class->cm_dbus_name = "example_extended";
- base_class->protocol_params = example_protocols;
-}
diff --git a/examples/cm/extended/manager.h b/examples/cm/extended/manager.h
deleted file mode 100644
index bad2850..0000000
--- a/examples/cm/extended/manager.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * manager.h - header for an example connection manager
- * Copyright (C) 2007 Collabora Ltd.
- *
- * Copying and distribution of this file, with or without modification,
- * are permitted in any medium without royalty provided the copyright
- * notice and this notice are preserved.
- */
-
-#ifndef __EXAMPLE_CONNECTION_MANAGER_H__
-#define __EXAMPLE_CONNECTION_MANAGER_H__
-
-#include <glib-object.h>
-#include <telepathy-glib/base-connection-manager.h>
-
-G_BEGIN_DECLS
-
-typedef struct _ExampleConnectionManager ExampleConnectionManager;
-typedef struct _ExampleConnectionManagerClass ExampleConnectionManagerClass;
-
-struct _ExampleConnectionManagerClass {
- TpBaseConnectionManagerClass parent_class;
-};
-
-struct _ExampleConnectionManager {
- TpBaseConnectionManager parent;
-
- gpointer priv;
-};
-
-GType example_connection_manager_get_type (void);
-
-/* TYPE MACROS */
-#define EXAMPLE_TYPE_CONNECTION_MANAGER \
- (example_connection_manager_get_type ())
-#define EXAMPLE_CONNECTION_MANAGER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), EXAMPLE_TYPE_CONNECTION_MANAGER, \
- ExampleConnectionManager))
-#define EXAMPLE_CONNECTION_MANAGER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), EXAMPLE_TYPE_CONNECTION_MANAGER, \
- ExampleConnectionManagerClass))
-#define EXAMPLE_IS_CONNECTION_MANAGER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), EXAMPLE_TYPE_CONNECTION_MANAGER))
-#define EXAMPLE_IS_CONNECTION_MANAGER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), EXAMPLE_TYPE_CONNECTION_MANAGER))
-#define EXAMPLE_CONNECTION_MANAGER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), EXAMPLE_TYPE_CONNECTION_MANAGER, \
- ExampleConnectionManagerClass))
-
-G_END_DECLS
-
-#endif /* #ifndef __EXAMPLE_CONNECTION_MANAGER_H__*/
--
1.5.6.5
More information about the Telepathy-commits
mailing list