1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#!/usr/bin/env python
# (name, CM, protocol, icon)
ALL = [
('AIM', 'haze', 'aim', 'aim'),
('GaduGadu', 'haze', 'gadugadu', 'gadugadu'),
('Groupwise', 'haze', 'groupwise', 'groupwise'),
('ICQ', 'haze', 'icq', 'icq'),
('IRC', 'idle', 'irc', 'irc'),
('Jabber', 'gabble', 'jabber', 'jabber'),
('Mxit', 'haze', 'mxit', 'mxit'),
('Myspace', 'haze', 'myspace', 'myspace'),
('SIP', 'sofiasip', 'sip', 'sip'),
('Salut', 'salut', 'local-xmpp', 'people-nearby'),
('Sametime', 'haze', 'sametime', 'sametime'),
('Yahoo Japan', 'haze', 'yahoojp', 'yahoo'),
('Yahoo!', 'haze', 'yahoo', 'yahoo'),
('Zephyr', 'haze', 'zephyr', 'zephyr'),
]
class Plugin:
def __init__(self, name, cm, protocol, icon):
self.name = name
self.cm = cm
self.protocol = protocol
self.icon = icon
##### 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>
<plugin>empathy-accounts-plugin</plugin>
</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>
<group name="auth">
<setting name="method">password</setting>
<setting name="mechanism">password</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_providers(plugins)
generate_services(plugins)
if __name__ == '__main__':
generate_all()
|