[Telepathy-commits] [telepathy-glib/master] example CMs: generate .manager, .service files and optionally install to libexecdir

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Mar 2 09:00:44 PST 2009


---
 examples/cm/channelspecific/Makefile.am            |   35 +++++++++++++++++++-
 examples/cm/channelspecific/connection-manager.c   |   12 +------
 examples/cm/channelspecific/manager-file.py        |   19 +++++++++++
 examples/cm/echo-message-parts/Makefile.am         |   34 ++++++++++++++++++-
 .../cm/echo-message-parts/connection-manager.c     |   11 +-----
 examples/cm/echo-message-parts/manager-file.py     |   19 +++++++++++
 examples/cm/echo/Makefile.am                       |   34 ++++++++++++++++++-
 examples/cm/echo/connection-manager.c              |   11 +-----
 examples/cm/echo/manager-file.py                   |   19 +++++++++++
 examples/cm/extended/Makefile.am                   |   34 ++++++++++++++++++-
 examples/cm/extended/connection-manager.c          |   13 ++------
 examples/cm/extended/manager-file.py               |   19 +++++++++++
 examples/cm/no-protocols/Makefile.am               |   34 ++++++++++++++++++-
 examples/cm/no-protocols/connection-manager.c      |    3 ++
 examples/cm/no-protocols/manager-file.py           |    7 ++++
 15 files changed, 261 insertions(+), 43 deletions(-)
 create mode 100644 examples/cm/channelspecific/manager-file.py
 create mode 100644 examples/cm/echo-message-parts/manager-file.py
 create mode 100644 examples/cm/echo/manager-file.py
 create mode 100644 examples/cm/extended/manager-file.py
 create mode 100644 examples/cm/no-protocols/manager-file.py

diff --git a/examples/cm/channelspecific/Makefile.am b/examples/cm/channelspecific/Makefile.am
index a147855..5c95b84 100644
--- a/examples/cm/channelspecific/Makefile.am
+++ b/examples/cm/channelspecific/Makefile.am
@@ -1,9 +1,15 @@
 # Example connection manager with chatrooms where contacts have
 # channel-specific handles.
 
-noinst_PROGRAMS = telepathy-example-cm-csh
+EXAMPLES = telepathy-example-cm-csh
 noinst_LTLIBRARIES = libexample-cm-csh.la
 
+if INSTALL_EXAMPLES
+libexec_PROGRAMS = $(EXAMPLES)
+else
+noinst_PROGRAMS = $(EXAMPLES)
+endif
+
 libexample_cm_csh_la_SOURCES = \
     conn.c \
     conn.h \
@@ -32,3 +38,30 @@ AM_CFLAGS = \
     $(DBUS_CFLAGS) \
     $(GLIB_CFLAGS) \
     $(TP_GLIB_CFLAGS)
+
+EXTRA_DIST = manager-file.py
+
+servicedir = ${datadir}/dbus-1/services
+
+if INSTALL_EXAMPLES
+service_DATA = _gen/org.freedesktop.Telepathy.ConnectionManager.example_csh.service
+$(service_DATA): %: Makefile
+	$(mkdir_p) _gen
+	{ echo "[D-BUS Service]" && \
+	echo "Name=org.freedesktop.Telepathy.ConnectionManager.example_csh" && \
+	echo "Exec=${libexecdir}/telepathy-example-cm-csh"; } > $@
+
+managerdir = ${datadir}/telepathy/managers
+manager_DATA = _gen/example_csh.manager
+endif
+
+_gen/example_csh.manager _gen/param-spec-struct.h: \
+		manager-file.py $(top_srcdir)/tools/manager-file.py
+	$(mkdir_p) _gen
+	$(PYTHON) $(top_srcdir)/tools/manager-file.py $(srcdir)/manager-file.py _gen
+
+BUILT_SOURCES = _gen/param-spec-struct.h
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local:
+	rm -rf _gen
diff --git a/examples/cm/channelspecific/connection-manager.c b/examples/cm/channelspecific/connection-manager.c
index 8c2cd18..801cb62 100644
--- a/examples/cm/channelspecific/connection-manager.c
+++ b/examples/cm/channelspecific/connection-manager.c
@@ -74,15 +74,7 @@ account_param_filter (const TpCMParamSpec *paramspec,
   return TRUE;
 }
 
-
-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),
-    account_param_filter, NULL },
-
-  { NULL }
-};
+#include "_gen/param-spec-struct.h"
 
 static gpointer
 alloc_params (void)
@@ -101,7 +93,7 @@ free_params (gpointer p)
 }
 
 static const TpCMProtocolSpec example_protocols[] = {
-  { "example", example_params, alloc_params, free_params },
+  { "example", example_csh_example_params, alloc_params, free_params },
   { NULL, NULL }
 };
 
diff --git a/examples/cm/channelspecific/manager-file.py b/examples/cm/channelspecific/manager-file.py
new file mode 100644
index 0000000..d9a4e98
--- /dev/null
+++ b/examples/cm/channelspecific/manager-file.py
@@ -0,0 +1,19 @@
+# Input for tools/manager-file.py
+
+MANAGER = 'example_csh'
+PARAMS = {
+        'example' : {
+            'account': {
+                'dtype': 's',
+                'flags': 'required register',
+                'filter': 'account_param_filter',
+                # 'filter_data': 'NULL',
+                # 'default': ...,
+                # 'struct_field': '...',
+                # 'setter_data': 'NULL',
+                },
+            },
+        }
+STRUCTS = {
+        'example': 'ExampleParams'
+        }
diff --git a/examples/cm/echo-message-parts/Makefile.am b/examples/cm/echo-message-parts/Makefile.am
index a1d129a..1e12bb9 100644
--- a/examples/cm/echo-message-parts/Makefile.am
+++ b/examples/cm/echo-message-parts/Makefile.am
@@ -1,6 +1,12 @@
-noinst_PROGRAMS = telepathy-example-cm-echo-2
+EXAMPLES = telepathy-example-cm-echo-2
 noinst_LTLIBRARIES = libexample-cm-echo-2.la
 
+if INSTALL_EXAMPLES
+libexec_PROGRAMS = $(EXAMPLES)
+else
+noinst_PROGRAMS = $(EXAMPLES)
+endif
+
 libexample_cm_echo_2_la_SOURCES = \
     chan.c \
     chan.h \
@@ -29,3 +35,29 @@ AM_CFLAGS = \
     $(DBUS_CFLAGS) \
     $(GLIB_CFLAGS) \
     $(TP_GLIB_CFLAGS)
+
+EXTRA_DIST = manager-file.py
+
+if INSTALL_EXAMPLES
+servicedir = ${datadir}/dbus-1/services
+service_DATA = _gen/org.freedesktop.Telepathy.ConnectionManager.example_echo_2.service
+$(service_DATA): %: Makefile
+	$(mkdir_p) _gen
+	{ echo "[D-BUS Service]" && \
+	echo "Name=org.freedesktop.Telepathy.ConnectionManager.example_echo_2" && \
+	echo "Exec=${libexecdir}/telepathy-example-cm-echo-2"; } > $@
+
+managerdir = ${datadir}/telepathy/managers
+manager_DATA = _gen/example_echo_2.manager
+endif
+
+_gen/example_echo_2.manager _gen/param-spec-struct.h: \
+		manager-file.py $(top_srcdir)/tools/manager-file.py
+	$(mkdir_p) _gen
+	$(PYTHON) $(top_srcdir)/tools/manager-file.py $(srcdir)/manager-file.py _gen
+
+BUILT_SOURCES = _gen/param-spec-struct.h
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local:
+	rm -rf _gen
diff --git a/examples/cm/echo-message-parts/connection-manager.c b/examples/cm/echo-message-parts/connection-manager.c
index 8601217..200009d 100644
--- a/examples/cm/echo-message-parts/connection-manager.c
+++ b/examples/cm/echo-message-parts/connection-manager.c
@@ -36,14 +36,7 @@ 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 }
-};
+#include "_gen/param-spec-struct.h"
 
 static gpointer
 alloc_params (void)
@@ -62,7 +55,7 @@ free_params (gpointer p)
 }
 
 static const TpCMProtocolSpec example_protocols[] = {
-  { "example", example_params, alloc_params, free_params },
+  { "example", example_echo_2_example_params, alloc_params, free_params },
   { NULL, NULL }
 };
 
diff --git a/examples/cm/echo-message-parts/manager-file.py b/examples/cm/echo-message-parts/manager-file.py
new file mode 100644
index 0000000..c3338f7
--- /dev/null
+++ b/examples/cm/echo-message-parts/manager-file.py
@@ -0,0 +1,19 @@
+# Input for tools/manager-file.py
+
+MANAGER = 'example_echo_2'
+PARAMS = {
+        'example' : {
+            'account': {
+                'dtype': 's',
+                'flags': 'required register',
+                'filter': 'tp_cm_param_filter_string_nonempty',
+                # 'filter_data': 'NULL',
+                # 'default': ...,
+                # 'struct_field': '...',
+                # 'setter_data': 'NULL',
+                },
+            },
+        }
+STRUCTS = {
+        'example': 'ExampleParams'
+        }
diff --git a/examples/cm/echo/Makefile.am b/examples/cm/echo/Makefile.am
index 536728a..de29fad 100644
--- a/examples/cm/echo/Makefile.am
+++ b/examples/cm/echo/Makefile.am
@@ -1,6 +1,12 @@
-noinst_PROGRAMS = telepathy-example-cm-echo
+EXAMPLES = telepathy-example-cm-echo
 noinst_LTLIBRARIES = libexample-cm-echo.la
 
+if INSTALL_EXAMPLES
+libexec_PROGRAMS = $(EXAMPLES)
+else
+noinst_PROGRAMS = $(EXAMPLES)
+endif
+
 libexample_cm_echo_la_SOURCES = \
     chan.c \
     chan.h \
@@ -29,3 +35,29 @@ AM_CFLAGS = \
     $(DBUS_CFLAGS) \
     $(GLIB_CFLAGS) \
     $(TP_GLIB_CFLAGS)
+
+EXTRA_DIST = manager-file.py
+
+if INSTALL_EXAMPLES
+servicedir = ${datadir}/dbus-1/services
+service_DATA = _gen/org.freedesktop.Telepathy.ConnectionManager.example_echo.service
+$(service_DATA): %: Makefile
+	$(mkdir_p) _gen
+	{ echo "[D-BUS Service]" && \
+	echo "Name=org.freedesktop.Telepathy.ConnectionManager.example_echo" && \
+	echo "Exec=${libexecdir}/telepathy-example-cm-echo"; } > $@
+
+managerdir = ${datadir}/telepathy/managers
+manager_DATA = _gen/example_echo.manager
+endif
+
+_gen/example_echo.manager _gen/param-spec-struct.h: \
+		manager-file.py $(top_srcdir)/tools/manager-file.py
+	$(mkdir_p) _gen
+	$(PYTHON) $(top_srcdir)/tools/manager-file.py $(srcdir)/manager-file.py _gen
+
+BUILT_SOURCES = _gen/param-spec-struct.h
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local:
+	rm -rf _gen
diff --git a/examples/cm/echo/connection-manager.c b/examples/cm/echo/connection-manager.c
index 9eb72ad..96c44b3 100644
--- a/examples/cm/echo/connection-manager.c
+++ b/examples/cm/echo/connection-manager.c
@@ -35,14 +35,7 @@ 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 }
-};
+#include "_gen/param-spec-struct.h"
 
 static gpointer
 alloc_params (void)
@@ -61,7 +54,7 @@ free_params (gpointer p)
 }
 
 static const TpCMProtocolSpec example_protocols[] = {
-  { "example", example_params, alloc_params, free_params },
+  { "example", example_echo_example_params, alloc_params, free_params },
   { NULL, NULL }
 };
 
diff --git a/examples/cm/echo/manager-file.py b/examples/cm/echo/manager-file.py
new file mode 100644
index 0000000..4c173b9
--- /dev/null
+++ b/examples/cm/echo/manager-file.py
@@ -0,0 +1,19 @@
+# Input for tools/manager-file.py
+
+MANAGER = 'example_echo'
+PARAMS = {
+        'example' : {
+            'account': {
+                'dtype': 's',
+                'flags': 'required register',
+                'filter': 'tp_cm_param_filter_string_nonempty',
+                # 'filter_data': 'NULL',
+                # 'default': ...,
+                # 'struct_field': '...',
+                # 'setter_data': 'NULL',
+                },
+            },
+        }
+STRUCTS = {
+        'example': 'ExampleParams'
+        }
diff --git a/examples/cm/extended/Makefile.am b/examples/cm/extended/Makefile.am
index d6a05d6..d558cc0 100644
--- a/examples/cm/extended/Makefile.am
+++ b/examples/cm/extended/Makefile.am
@@ -1,4 +1,10 @@
-noinst_PROGRAMS = telepathy-example-cm-extended
+EXAMPLES = telepathy-example-cm-extended
+
+if INSTALL_EXAMPLES
+libexec_PROGRAMS = $(EXAMPLES)
+else
+noinst_PROGRAMS = $(EXAMPLES)
+endif
 
 telepathy_example_cm_extended_SOURCES = \
     conn.c \
@@ -20,3 +26,29 @@ AM_CFLAGS = \
     $(DBUS_CFLAGS) \
     $(GLIB_CFLAGS) \
     $(TP_GLIB_CFLAGS)
+
+EXTRA_DIST = manager-file.py
+
+if INSTALL_EXAMPLES
+servicedir = ${datadir}/dbus-1/services
+service_DATA = _gen/org.freedesktop.Telepathy.ConnectionManager.example_extended.service
+$(service_DATA): %: Makefile
+	$(mkdir_p) _gen
+	{ echo "[D-BUS Service]" && \
+	echo "Name=org.freedesktop.Telepathy.ConnectionManager.example_extended" && \
+	echo "Exec=${libexecdir}/telepathy-example-cm-extended"; } > $@
+
+managerdir = ${datadir}/telepathy/managers
+manager_DATA = _gen/example_extended.manager
+endif
+
+_gen/example_extended.manager _gen/param-spec-struct.h: \
+		manager-file.py $(top_srcdir)/tools/manager-file.py
+	$(mkdir_p) _gen
+	$(PYTHON) $(top_srcdir)/tools/manager-file.py $(srcdir)/manager-file.py _gen
+
+BUILT_SOURCES = _gen/param-spec-struct.h
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local:
+	rm -rf _gen
diff --git a/examples/cm/extended/connection-manager.c b/examples/cm/extended/connection-manager.c
index 0362e19..8fd193d 100644
--- a/examples/cm/extended/connection-manager.c
+++ b/examples/cm/extended/connection-manager.c
@@ -36,15 +36,6 @@ 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)
 {
@@ -61,8 +52,10 @@ free_params (gpointer p)
   g_slice_free (ExampleParams, params);
 }
 
+#include "_gen/param-spec-struct.h"
+
 static const TpCMProtocolSpec example_protocols[] = {
-  { "example", example_params, alloc_params, free_params },
+  { "example", example_extended_example_params, alloc_params, free_params },
   { NULL, NULL }
 };
 
diff --git a/examples/cm/extended/manager-file.py b/examples/cm/extended/manager-file.py
new file mode 100644
index 0000000..48b87ef
--- /dev/null
+++ b/examples/cm/extended/manager-file.py
@@ -0,0 +1,19 @@
+# Input for tools/manager-file.py
+
+MANAGER = 'example_extended'
+PARAMS = {
+        'example' : {
+            'account': {
+                'dtype': 's',
+                'flags': 'required register',
+                'filter': 'tp_cm_param_filter_string_nonempty',
+                # 'filter_data': 'NULL',
+                # 'default': ...,
+                # 'struct_field': '...',
+                # 'setter_data': 'NULL',
+                },
+            },
+        }
+STRUCTS = {
+        'example': 'ExampleParams'
+        }
diff --git a/examples/cm/no-protocols/Makefile.am b/examples/cm/no-protocols/Makefile.am
index d05305b..b85bba6 100644
--- a/examples/cm/no-protocols/Makefile.am
+++ b/examples/cm/no-protocols/Makefile.am
@@ -1,4 +1,10 @@
-noinst_PROGRAMS = telepathy-example-no-protocols
+EXAMPLES = telepathy-example-no-protocols
+
+if INSTALL_EXAMPLES
+libexec_PROGRAMS = $(EXAMPLES)
+else
+noinst_PROGRAMS = $(EXAMPLES)
+endif
 
 telepathy_example_no_protocols_SOURCES = \
     connection-manager.c \
@@ -17,3 +23,29 @@ AM_CFLAGS = \
     @DBUS_CFLAGS@ \
     @GLIB_CFLAGS@ \
     @TP_GLIB_CFLAGS@
+
+EXTRA_DIST = manager-file.py
+
+if INSTALL_EXAMPLES
+servicedir = ${datadir}/dbus-1/services
+service_DATA = _gen/org.freedesktop.Telepathy.ConnectionManager.example_no_protocols.service
+$(service_DATA): %: Makefile
+	$(mkdir_p) _gen
+	{ echo "[D-BUS Service]" && \
+	echo "Name=org.freedesktop.Telepathy.ConnectionManager.example_no_protocols" && \
+	echo "Exec=${libexecdir}/telepathy-example-cm-no-protocols"; } > $@
+
+managerdir = ${datadir}/telepathy/managers
+manager_DATA = _gen/example_no_protocols.manager
+endif
+
+_gen/example_no_protocols.manager _gen/param-spec-struct.h: \
+		manager-file.py $(top_srcdir)/tools/manager-file.py
+	$(mkdir_p) _gen
+	$(PYTHON) $(top_srcdir)/tools/manager-file.py $(srcdir)/manager-file.py _gen
+
+BUILT_SOURCES = _gen/param-spec-struct.h
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local:
+	rm -rf _gen
diff --git a/examples/cm/no-protocols/connection-manager.c b/examples/cm/no-protocols/connection-manager.c
index 0c1dda3..aca26ee 100644
--- a/examples/cm/no-protocols/connection-manager.c
+++ b/examples/cm/no-protocols/connection-manager.c
@@ -31,6 +31,9 @@ example_no_protocols_connection_manager_init (
 /* private data */
 
 /* We don't actually support any protocols */
+
+#include "_gen/param-spec-struct.h"
+
 const TpCMProtocolSpec stub_protocols[] = {
   { NULL, NULL }
 };
diff --git a/examples/cm/no-protocols/manager-file.py b/examples/cm/no-protocols/manager-file.py
new file mode 100644
index 0000000..c18d035
--- /dev/null
+++ b/examples/cm/no-protocols/manager-file.py
@@ -0,0 +1,7 @@
+# Input for tools/manager-file.py
+
+MANAGER = 'example_no_protocols'
+PARAMS = {
+        }
+STRUCTS = {
+        }
-- 
1.5.6.5




More information about the telepathy-commits mailing list