3 # (name, CM, protocol, icon)
5 ('AIM', 'haze', 'aim', 'aim'),
6 ('GaduGadu', 'haze', 'gadugadu', 'gadugadu'),
7 ('Groupwise', 'haze', 'groupwise', 'groupwise'),
8 ('ICQ', 'haze', 'icq', 'icq'),
9 ('IRC', 'idle', 'irc', 'irc'),
10 ('Jabber', 'gabble', 'jabber', 'jabber'),
11 ('Mxit', 'haze', 'mxit', 'mxit'),
12 ('Myspace', 'haze', 'myspace', 'myspace'),
13 ('SIP', 'sofiasip', 'sip', 'sip'),
14 ('Salut', 'salut', 'local-xmpp', 'people-nearby'),
15 ('Sametime', 'haze', 'sametime', 'sametime'),
16 ('Yahoo Japan', 'haze', 'yahoojp', 'yahoo'),
17 ('Yahoo!', 'haze', 'yahoo', 'yahoo'),
18 ('Zephyr', 'haze', 'zephyr', 'zephyr'),
22 def __init__(self, name, cm, protocol, icon):
25 self.protocol = protocol
28 ##### account-plugins/ #####
30 def magic_replace(text, protocol):
31 p = protocol.replace('-', '_')
33 l = protocol.split('-')
37 text = text.replace('$lower', p)
38 text = text.replace('$UPPER', p.upper())
39 text = text.replace('$Camel', camel)
43 def generate_plugin_header(p):
45 f = open('account-plugins/empathy-accounts-plugin-%s.h' % p.protocol, 'w')
47 tmp = '''/* # Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
48 * Do NOT edit manually */
51 * empathy-accounts-plugin-%s.h
53 * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
55 * This library is free software; you can redistribute it and/or
56 * modify it under the terms of the GNU Lesser General Public
57 * License as published by the Free Software Foundation; either
58 * version 2.1 of the License, or (at your option) any later version.
60 * This library is distributed in the hope that it will be useful,
61 * but WITHOUT ANY WARRANTY; without even the implied warranty of
62 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
63 * Lesser General Public License for more details.
65 * You should have received a copy of the GNU Lesser General Public
66 * License along with this library; if not, write to the Free Software
67 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
71 #ifndef __EMPATHY_ACCOUNTS_PLUGIN_$UPPER_H__
72 #define __EMPATHY_ACCOUNTS_PLUGIN_$UPPER_H__
74 #include "empathy-accounts-plugin.h"
78 typedef struct _EmpathyAccountsPlugin$Camel EmpathyAccountsPlugin$Camel;
79 typedef struct _EmpathyAccountsPlugin$CamelClass EmpathyAccountsPlugin$CamelClass;
81 struct _EmpathyAccountsPlugin$CamelClass
84 EmpathyAccountsPluginClass parent_class;
87 struct _EmpathyAccountsPlugin$Camel
90 EmpathyAccountsPlugin parent;
93 GType empathy_accounts_plugin_$lower_get_type (void);
96 #define EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER \\
97 (empathy_accounts_plugin_$lower_get_type ())
98 #define EMPATHY_ACCOUNTS_PLUGIN_$UPPER(obj) \\
99 (G_TYPE_CHECK_INSTANCE_CAST((obj), \\
100 EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER, \\
101 EmpathyAccountsPlugin$Camel))
102 #define EMPATHY_ACCOUNTS_PLUGIN_$UPPER_CLASS(klass) \\
103 (G_TYPE_CHECK_CLASS_CAST((klass), \\
104 EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER, \\
105 EmpathyAccountsPlugin$CamelClass))
106 #define EMPATHY_IS_ACCOUNTS_PLUGIN_$UPPER(obj) \\
107 (G_TYPE_CHECK_INSTANCE_TYPE((obj), \\
108 EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER))
109 #define EMPATHY_IS_ACCOUNTS_PLUGIN_$UPPER_CLASS(klass) \\
110 (G_TYPE_CHECK_CLASS_TYPE((klass), \\
111 EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER))
112 #define EMPATHY_ACCOUNTS_PLUGIN_$UPPER_GET_CLASS(obj) \\
113 (G_TYPE_INSTANCE_GET_CLASS ((obj), \\
114 EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER, \\
115 EmpathyAccountsPlugin$CamelClass))
117 GType ap_module_get_object_type (void);
121 #endif /* #ifndef __EMPATHY_ACCOUNTS_PLUGIN_$UPPER_H__*/''' % (p.protocol)
123 f.write(magic_replace (tmp, p.protocol))
125 def generate_plugin_code(p):
127 f = open('account-plugins/empathy-accounts-plugin-%s.c' % p.protocol, 'w')
129 tmp = '''/* # Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
130 * Do NOT edit manually */
133 * empathy-accounts-plugin-%s.c
135 * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
137 * This library is free software; you can redistribute it and/or
138 * modify it under the terms of the GNU Lesser General Public
139 * License as published by the Free Software Foundation; either
140 * version 2.1 of the License, or (at your option) any later version.
142 * This library is distributed in the hope that it will be useful,
143 * but WITHOUT ANY WARRANTY; without even the implied warranty of
144 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
145 * Lesser General Public License for more details.
147 * You should have received a copy of the GNU Lesser General Public
148 * License along with this library; if not, write to the Free Software
149 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
154 #include "empathy-accounts-plugin-%s.h"
156 G_DEFINE_TYPE (EmpathyAccountsPlugin$Camel, empathy_accounts_plugin_$lower,\\
157 EMPATHY_TYPE_ACCOUNTS_PLUGIN)
160 empathy_accounts_plugin_$lower_class_init (
161 EmpathyAccountsPlugin$CamelClass *klass)
166 empathy_accounts_plugin_$lower_init (EmpathyAccountsPlugin$Camel *self)
171 ap_module_get_object_type (void)
173 return EMPATHY_TYPE_ACCOUNTS_PLUGIN_$UPPER;
174 }''' % (p.protocol, p.protocol)
176 f.write(magic_replace (tmp, p.protocol))
178 def generate_build_block(p):
179 la = 'lib%s_la' % p.protocol.replace('-', '_')
181 output = '''%s_SOURCES = \\
182 empathy-accounts-plugin-%s.c \\
183 empathy-accounts-plugin-%s.h
184 %s_LDFLAGS = -module -avoid-version
186 libempathy-uoa-account-plugin.la \\
187 $(top_builddir)/libempathy/libempathy.la \\
188 $(top_builddir)/libempathy-gtk/libempathy-gtk.la
189 ''' % (la, p.protocol, p.protocol, la, la)
194 def generate_account_plugins(plugins):
195 '''account-plugins/'''
200 # empathy-accounts-plugin-$protocol.[ch]'''
201 generate_plugin_header(p)
202 generate_plugin_code(p)
204 name = ' lib%s.la' % p.protocol
207 build_blocks.append(generate_build_block(p))
210 f = open('account-plugins/Makefile.am', 'w')
213 '''# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
214 # Do NOT edit manually
215 plugindir = $(ACCOUNTS_PROVIDER_PLUGIN_DIR)
220 -DLOCALEDIR=\\""$(datadir)/locale"\\" \\
224 $(DISABLE_DEPRECATED) \\
227 pkglib_LTLIBRARIES = libempathy-uoa-account-plugin.la
229 # this API is not stable and will never be, so use -release to make the
230 # SONAME of the plugin library change with every Empathy release.
231 libempathy_uoa_account_plugin_la_LDFLAGS = \\
235 libempathy_uoa_account_plugin_la_SOURCES = \\
236 empathy-accounts-plugin.c \\
237 empathy-accounts-plugin.h \\
238 empathy-accounts-plugin-widget.c \\
239 empathy-accounts-plugin-widget.h
241 libempathy_uoa_account_plugin_la_LIBADD = \\
244 plugin_LTLIBRARIES = \\
248 %s''' % ('\\\n'.join(libs), '\n\n'.join(build_blocks)))
250 ##### providers/ #####
252 def generate_provider_file(p):
253 f = open('providers/%s.provider' % p.protocol, 'w')
256 '''<?xml version="1.0" encoding="UTF-8" ?>
257 <!-- Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
258 Do NOT edit manually -->
263 ''' % (p.protocol, p.name, p.icon))
265 def generate_providers(plugins):
266 '''generate providers/*.provider files and providers/Makefile.am'''
270 providers.append(' %s.provider' % p.protocol)
272 generate_provider_file(p)
274 # providers/Makefile.am
275 f = open('providers/Makefile.am', 'w')
277 '''# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
278 # Do NOT edit manually
279 providersdir = $(ACCOUNTS_PROVIDER_FILES_DIR)
285 EXTRA_DIST = $(providers_DATA)
286 ''' % ('\\\n'.join(providers)))
288 ##### services/ #####
290 def generate_service_file(p):
291 f = open('services/%s-im.service' % p.protocol, 'w')
294 '''<?xml version="1.0" encoding="UTF-8" ?>
295 <!-- Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
296 Do NOT edit manually -->
301 <provider>%s</provider>
303 <!-- default settings (account settings have precedence over these) -->
305 <group name="telepathy">
306 <setting name="manager">%s</setting>
307 <setting name="protocol">%s</setting>
310 <setting name="method">password</setting>
311 <setting name="mechanism">password</setting>
316 ''' % (p.protocol, p.name, p.icon, p.protocol, p.cm, p.protocol))
318 def generate_services(plugins):
319 '''generate services/*-im.service files and services/Makefile.am'''
323 services.append(' %s-im.service' % p.protocol)
325 generate_service_file(p)
327 # providers/Makefile.am
328 f = open('services/Makefile.am', 'w')
330 '''# Generated using empathy/ubuntu-online-accounts/cc-plugins/generate-plugins.py
331 # Do NOT edit manually
332 servicesdir = $(ACCOUNTS_SERVICE_FILES_DIR)
338 EXTRA_DIST = $(services_DATA)
339 ''' % ('\\\n'.join(services)))
344 for name, cm, protocol, icon in ALL:
345 plugins.append(Plugin(name, cm, protocol, icon))
347 generate_account_plugins(plugins)
348 generate_providers(plugins)
349 generate_services(plugins)
351 if __name__ == '__main__':