aboutsummaryrefslogtreecommitdiffstats
path: root/ubuntu-online-accounts
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-18 17:37:04 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-24 22:20:04 +0800
commite296ad8a3b6dd5049caa9ea6b739a34d9d16dea6 (patch)
tree80e2f62effaad99f044fd64bc36a82ecc949390c /ubuntu-online-accounts
parent32cbd280f3a2ec826f4d4ae76c99765218014c36 (diff)
downloadgsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.tar
gsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.tar.gz
gsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.tar.bz2
gsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.tar.lz
gsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.tar.xz
gsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.tar.zst
gsoc2013-empathy-e296ad8a3b6dd5049caa9ea6b739a34d9d16dea6.zip
add generate-plugins.py
Handy script to generate all the boilerplates for each protocol we are supporting. https://bugzilla.gnome.org/show_bug.cgi?id=680448
Diffstat (limited to 'ubuntu-online-accounts')
-rw-r--r--ubuntu-online-accounts/cc-plugins/Makefile.am2
-rwxr-xr-xubuntu-online-accounts/cc-plugins/generate-plugins.py167
-rw-r--r--ubuntu-online-accounts/cc-plugins/providers/Makefile.am2
-rw-r--r--ubuntu-online-accounts/cc-plugins/providers/jabber.provider2
-rw-r--r--ubuntu-online-accounts/cc-plugins/services/Makefile.am2
-rw-r--r--ubuntu-online-accounts/cc-plugins/services/jabber-im.service2
6 files changed, 177 insertions, 0 deletions
diff --git a/ubuntu-online-accounts/cc-plugins/Makefile.am b/ubuntu-online-accounts/cc-plugins/Makefile.am
index c90caf72f..2b6029807 100644
--- a/ubuntu-online-accounts/cc-plugins/Makefile.am
+++ b/ubuntu-online-accounts/cc-plugins/Makefile.am
@@ -1,3 +1,5 @@
+# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+# Do NOT edit manually
SUBDIRS = providers services
plugindir = $(ACCOUNTS_PROVIDER_PLUGIN_DIR)
diff --git a/ubuntu-online-accounts/cc-plugins/generate-plugins.py b/ubuntu-online-accounts/cc-plugins/generate-plugins.py
new file mode 100755
index 000000000..9f03a289b
--- /dev/null
+++ b/ubuntu-online-accounts/cc-plugins/generate-plugins.py
@@ -0,0 +1,167 @@
+#!/usr/bin/env python
+
+# (name, CM, protocol, icon)
+ALL = [
+ ('Jabber', 'gabble', 'jabber', 'jabber'),
+ ]
+
+class Plugin:
+ def __init__(self, name, cm, protocol, icon):
+ self.name = name
+ self.cm = cm
+ self.protocol = protocol
+ self.icon = icon
+
+##### The plugin itself #####
+
+def generate_build_block(p):
+ la = 'lib%s_la' % p.protocol.replace('-', '_')
+
+ output = '''%s_SOURCES = \\
+ empathy-accounts-plugin.c \\
+ empathy-accounts-plugin.h \\
+ empathy-accounts-plugin-widget.c \\
+ empathy-accounts-plugin-widget.h
+%s_LDFLAGS = -module -avoid-version
+%s_LIBADD = \\
+ $(UOA_LIBS) \\
+ $(top_builddir)/libempathy-gtk/libempathy-gtk.la
+''' % (la, la, la)
+
+ return output
+
+def generate_makefile_am(plugins):
+ '''Generate Makefile.am'''
+ libs = []
+ build_blocks = []
+
+ for p in plugins:
+ name = ' lib%s.la' % p.protocol
+ libs.append(name)
+
+ build_blocks.append(generate_build_block(p))
+
+ f = open('Makefile.am', 'w')
+
+ f.write(
+'''# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+# Do NOT edit manually
+SUBDIRS = providers services
+
+plugindir = $(ACCOUNTS_PROVIDER_PLUGIN_DIR)
+
+INCLUDES = \\
+ -I$(top_builddir) \\
+ -I$(top_srcdir) \\
+ -DLOCALEDIR=\\""$(datadir)/locale"\\" \\
+ $(UOA_CFLAGS) \\
+ $(WARN_CFLAGS) \\
+ $(ERROR_CFLAGS) \\
+ $(DISABLE_DEPRECATED) \\
+ $(EMPATHY_CFLAGS)
+
+plugin_LTLIBRARIES = \\
+%s \\
+ $(NULL)
+
+%s''' % ('\\\n'.join(libs), '\n\n'.join(build_blocks)))
+
+##### Providers #####
+
+def generate_provider_file(p):
+ f = open('providers/%s.provider' % p.protocol, 'w')
+
+ f.write(
+'''<?xml version="1.0" encoding="UTF-8" ?>
+<!-- Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+ Do NOT edit manually -->
+<provider id="%s">
+ <name>%s</name>
+ <icon>%s</icon>
+</provider>
+''' % (p.protocol, p.name, p.icon))
+
+def generate_providers(plugins):
+ '''generate providers/*.provider files and providers/Makefile.am'''
+
+ providers = []
+ for p in plugins:
+ providers.append(' %s.provider' % p.protocol)
+
+ generate_provider_file(p)
+
+ # providers/Makefile.am
+ f = open('providers/Makefile.am', 'w')
+ f.write(
+'''# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+# Do NOT edit manually
+providersdir = $(ACCOUNTS_PROVIDER_FILES_DIR)
+
+providers_DATA = \\
+%s \\
+ $(NULL)
+
+EXTRA_DIST = $(providers_DATA)
+''' % ('\\\n'.join(providers)))
+
+##### Services #####
+
+def generate_service_file(p):
+ f = open('services/%s-im.service' % p.protocol, 'w')
+
+ f.write(
+'''<?xml version="1.0" encoding="UTF-8" ?>
+<!-- Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+ Do NOT edit manually -->
+<service id="%s-im">
+ <type>IM</type>
+ <name>%s</name>
+ <icon>%s</icon>
+ <provider>%s</provider>
+
+ <!-- default settings (account settings have precedence over these) -->
+ <template>
+ <group name="telepathy">
+ <setting name="manager">%s</setting>
+ <setting name="protocol">%s</setting>
+ </group>
+ </template>
+
+</service>
+''' % (p.protocol, p.name, p.icon, p.protocol, p.cm, p.protocol))
+
+def generate_services(plugins):
+ '''generate services/*-im.service files and services/Makefile.am'''
+
+ services = []
+ for p in plugins:
+ services.append(' %s-im.service' % p.protocol)
+
+ generate_service_file(p)
+
+ # providers/Makefile.am
+ f = open('services/Makefile.am', 'w')
+ f.write(
+'''# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+# Do NOT edit manually
+servicesdir = $(ACCOUNTS_SERVICE_FILES_DIR)
+
+services_DATA = \\
+%s \\
+ $(NULL)
+
+EXTRA_DIST = $(services_DATA)
+''' % ('\\\n'.join(services)))
+
+def generate_all():
+ plugins = []
+
+ for name, cm, protocol, icon in ALL:
+ plugins.append(Plugin(name, cm, protocol, icon))
+
+ generate_makefile_am(plugins)
+ generate_providers(plugins)
+ generate_services(plugins)
+
+if __name__ == '__main__':
+ generate_all()
diff --git a/ubuntu-online-accounts/cc-plugins/providers/Makefile.am b/ubuntu-online-accounts/cc-plugins/providers/Makefile.am
index 72254202a..3941ed608 100644
--- a/ubuntu-online-accounts/cc-plugins/providers/Makefile.am
+++ b/ubuntu-online-accounts/cc-plugins/providers/Makefile.am
@@ -1,3 +1,5 @@
+# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+# Do NOT edit manually
providersdir = $(ACCOUNTS_PROVIDER_FILES_DIR)
providers_DATA = \
diff --git a/ubuntu-online-accounts/cc-plugins/providers/jabber.provider b/ubuntu-online-accounts/cc-plugins/providers/jabber.provider
index fc07da468..ff553d245 100644
--- a/ubuntu-online-accounts/cc-plugins/providers/jabber.provider
+++ b/ubuntu-online-accounts/cc-plugins/providers/jabber.provider
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
+<!-- Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+ Do NOT edit manually -->
<provider id="jabber">
<name>Jabber</name>
<icon>jabber</icon>
diff --git a/ubuntu-online-accounts/cc-plugins/services/Makefile.am b/ubuntu-online-accounts/cc-plugins/services/Makefile.am
index 71901cd6b..2c0dfa3d5 100644
--- a/ubuntu-online-accounts/cc-plugins/services/Makefile.am
+++ b/ubuntu-online-accounts/cc-plugins/services/Makefile.am
@@ -1,3 +1,5 @@
+# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+# Do NOT edit manually
servicesdir = $(ACCOUNTS_SERVICE_FILES_DIR)
services_DATA = \
diff --git a/ubuntu-online-accounts/cc-plugins/services/jabber-im.service b/ubuntu-online-accounts/cc-plugins/services/jabber-im.service
index dd6ab55b2..156fa6bda 100644
--- a/ubuntu-online-accounts/cc-plugins/services/jabber-im.service
+++ b/ubuntu-online-accounts/cc-plugins/services/jabber-im.service
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
+<!-- Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
+ Do NOT edit manually -->
<service id="jabber-im">
<type>IM</type>
<name>Jabber</name>