summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/setup/setup_freebusy.py58
1 files changed, 54 insertions, 4 deletions
diff --git a/pykolab/setup/setup_freebusy.py b/pykolab/setup/setup_freebusy.py
index 7c0df1d..6d1199b 100644
--- a/pykolab/setup/setup_freebusy.py
+++ b/pykolab/setup/setup_freebusy.py
@@ -21,6 +21,7 @@ from ConfigParser import RawConfigParser
import os
import sys
import time
+from urlparse import urlparse
import components
@@ -52,16 +53,62 @@ def execute(*args, **kw):
if not os.path.isfile('/etc/kolab-freebusy/config.ini'):
os.rename('/etc/kolab-freebusy/config.ini.sample', '/etc/kolab-freebusy/config.ini')
+ imap_backend = conf.get('kolab', 'imap_backend')
+ admin_login = conf.get(imap_backend, 'admin_login')
+ admin_password = conf.get(imap_backend, 'admin_password')
+ imap_uri = conf.get(imap_backend, 'imap_uri')
+ if imap_uri == None:
+ imap_uri = conf.get(imap_backend, 'uri')
+
+ scheme = None
+ hostname = None
+ port = None
+
+ result = urlparse(imap_uri)
+
+ if hasattr(result, 'hostname'):
+ hostname = result.hostname
+ else:
+ scheme = imap_uri.split(':')[0]
+ (hostname, port) = imap_uri.split('/')[2].split(':')
+
+ if port == None:
+ port = 993
+
+ if scheme == None or scheme == "":
+ scheme = 'imaps'
+
+ resources_imap_uri = '%s://%s:%s@%s:%s/%%kolabtargetfolder?acl=lrs' % (scheme, admin_login, admin_password, hostname, port)
+ users_imap_uri = '%s://%%mail:%s@%s:%s/?proxy_auth=%s' % (scheme, admin_password, hostname, port, admin_login)
+
freebusy_settings = {
- 'directory "kolab-ldap"': {
+ 'directory "kolab-users"': {
+ 'type': 'ldap',
'host': conf.get('ldap', 'ldap_uri'),
'base_dn': conf.get('ldap', 'base_dn'),
'bind_dn': conf.get('ldap', 'service_bind_dn'),
'bind_pw': conf.get('ldap', 'service_bind_pw'),
- 'fbsource': 'file:/var/lib/kolab-freebusy/%mail.ifb',
+ 'filter': '(&(objectClass=kolabInetOrgPerson)(|(uid=%s)(mail=%s)(alias=%s)))',
+ 'attributes': 'mail',
+ 'lc_attributes': 'mail',
+ 'fbsource': users_imap_uri,
+ 'cacheto': '/var/cache/kolab-freebusy/%mail.ifb',
+ 'expires': '15m',
+ 'loglevel': 300,
+ },
+ 'directory "kolab-resources"': {
+ 'type': 'ldap',
+ 'host': conf.get('ldap', 'ldap_uri'),
+ 'base_dn': conf.get('ldap', 'resource_base_dn'),
+ 'bind_dn': conf.get('ldap', 'service_bind_dn'),
+ 'bind_pw': conf.get('ldap', 'service_bind_pw'),
+ 'attributes': 'mail, kolabtargetfolder',
+ 'filter': '(&(objectClass=kolabsharedfolder)(mail=%s))',
+ 'fbsource': resources_imap_uri,
+ 'cacheto': '/var/cache/kolab-freebusy/%mail.ifb',
+ 'expires': '15m',
+ 'loglevel': 300
},
- 'httpauth': {
- }
}
cfg_parser = RawConfigParser()
@@ -73,6 +120,9 @@ def execute(*args, **kw):
continue
for key in freebusy_settings[section].keys():
+ if not cfg_parser.has_section(section):
+ cfg_parser.add_section(section)
+
cfg_parser.set(section, key, freebusy_settings[section][key])
fp = open('/etc/kolab-freebusy/config.ini', "w+")