10 commits - pykolab/cli pykolab/imap pykolab/wap_client share/templates
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Fri Aug 9 14:40:19 CEST 2013
pykolab/cli/cmd_list_deleted_mailboxes.py | 42 ++++++++++++++++++++-
pykolab/cli/cmd_list_mailboxes.py | 18 ++++++++-
pykolab/cli/cmd_list_messages.py | 7 ++-
pykolab/cli/cmd_list_quota.py | 15 +++++++
pykolab/cli/cmd_list_user_subscriptions.py | 17 +++++++-
pykolab/cli/cmd_transfer_mailbox.py | 3 +
pykolab/cli/cmd_user_info.py | 48 +++++++++++++++++++++++++
pykolab/imap/cyrus.py | 4 +-
pykolab/wap_client/__init__.py | 27 +++++++++++++-
share/templates/roundcubemail/main.inc.php.tpl | 4 +-
10 files changed, 170 insertions(+), 15 deletions(-)
New commits:
commit 433171ba6745cb252e2118757f50d648372618f1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Aug 9 13:39:59 2013 +0100
Only attempt to set the mailhost attribute on actual entries
diff --git a/pykolab/cli/cmd_transfer_mailbox.py b/pykolab/cli/cmd_transfer_mailbox.py
index cef9ec1..56aab24 100644
--- a/pykolab/cli/cmd_transfer_mailbox.py
+++ b/pykolab/cli/cmd_transfer_mailbox.py
@@ -64,4 +64,5 @@ def execute(*args, **kw):
imap.connect(server=source_server)
imap.imap.xfer(mailfolder, target_server)
- auth.set_entry_attributes(domain, user, {'mailhost': target_server})
+ if not user == None and not len(user) < 1:
+ auth.set_entry_attributes(domain, user, {'mailhost': target_server})
commit 35775e2b6ab5be8ba4fd583cd30b11d20a6a18b8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Aug 9 13:39:24 2013 +0100
Add --raw to list-user-subscriptions to allow displaying the folder names in raw utf-7
diff --git a/pykolab/cli/cmd_list_user_subscriptions.py b/pykolab/cli/cmd_list_user_subscriptions.py
index 7e4fe8d..3360613 100644
--- a/pykolab/cli/cmd_list_user_subscriptions.py
+++ b/pykolab/cli/cmd_list_user_subscriptions.py
@@ -21,6 +21,7 @@ import commands
import pykolab
+from pykolab import imap_utf7
from pykolab.imap import IMAP
from pykolab.translate import _
from pykolab import utils
@@ -33,6 +34,12 @@ def __init__():
def cli_options(*args, **kw):
my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ my_option_group.add_option( '--raw',
+ dest = "raw",
+ action = "store_true",
+ default = False,
+ help = _("Display raw IMAP UTF-7 folder names"))
+
my_option_group.add_option( '--unsubscribed',
dest = "unsubscribed",
action = "store_true",
@@ -83,9 +90,15 @@ def execute(*args, **kw):
unsubscribed_folders.append(folder)
if len(unsubscribed_folders) > 0:
- print "\n".join(unsubscribed_folders)
+ if not conf.raw:
+ print "\n".join([imap_utf7.decode(x) for x in unsubscribed_folders])
+ else:
+ print "\n".join(unsubscribed_folders)
else:
print _("No unsubscribed folders for user %s") % (user)
else:
- print "\n".join(subscribed_folders)
+ if not conf.raw:
+ print "\n".join([imap_utf7.decode(x) for x in subscribed_folders])
+ else:
+ print "\n".join(subscribed_folders)
commit 2e3f4492c4ee9197b8f4e62e07a57bb94501fc00
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Aug 9 13:39:03 2013 +0100
Add --server=server to list-quota
diff --git a/pykolab/cli/cmd_list_quota.py b/pykolab/cli/cmd_list_quota.py
index 4d3221f..9980ea3 100644
--- a/pykolab/cli/cmd_list_quota.py
+++ b/pykolab/cli/cmd_list_quota.py
@@ -32,6 +32,15 @@ conf = pykolab.getConf()
def __init__():
commands.register('list_quota', execute, description=description(), aliases=['lq'])
+def cli_options():
+ my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ my_option_group.add_option( '--server',
+ dest = "connect_server",
+ action = "store",
+ default = None,
+ metavar = "SERVER",
+ help = _("List mailboxes on server SERVER only."))
+
def description():
return """List quota for a folder."""
@@ -46,7 +55,11 @@ def execute(*args, **kw):
quota_folder = '*'
imap = IMAP()
- imap.connect()
+
+ if not conf.connect_server == None:
+ imap.connect(server=conf.connect_server)
+ else:
+ imap.connect()
folders = []
commit b5746f0301982bd1b5efaf5027fae9c366765636
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Aug 9 13:38:37 2013 +0100
Correct the selection of the folder for list-messages
diff --git a/pykolab/cli/cmd_list_messages.py b/pykolab/cli/cmd_list_messages.py
index 2016020..716cdd3 100644
--- a/pykolab/cli/cmd_list_messages.py
+++ b/pykolab/cli/cmd_list_messages.py
@@ -23,6 +23,7 @@ import commands
import pykolab
+from pykolab import imap_utf7
from pykolab.imap import IMAP
from pykolab.translate import _
@@ -60,7 +61,7 @@ def execute(*args, **kw):
imap = IMAP()
imap.connect()
- _folder = imap.lm(folder)
+ _folder = imap.lm(imap_utf7.encode(folder))
if _folder == None or _folder == []:
log.error(_("No such folder"))
@@ -68,7 +69,7 @@ def execute(*args, **kw):
imap.set_acl(folder, 'cyrus-admin', 'lrs')
- imap.select(folder)
+ imap.select(imap_utf7.encode(folder))
if conf.list_deleted:
typ, data = imap.search(None, 'ALL')
@@ -94,3 +95,5 @@ def execute(*args, **kw):
print num
else:
print num
+
+ imap.set_acl(folder, 'cyrus-admin', '')
commit 2cf945f17f2001f37c71d1fb8fdba80a79457d5f
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu Aug 8 16:26:00 2013 +0100
Disable http_authentication and listcommands plugins by default
diff --git a/share/templates/roundcubemail/main.inc.php.tpl b/share/templates/roundcubemail/main.inc.php.tpl
index 9fe7f81..0f75834 100644
--- a/share/templates/roundcubemail/main.inc.php.tpl
+++ b/share/templates/roundcubemail/main.inc.php.tpl
@@ -90,7 +90,7 @@
'acl',
'archive',
'calendar',
- 'http_authentication',
+ // 'http_authentication',
'jqueryui',
'kolab_activesync',
'kolab_addressbook',
@@ -99,7 +99,7 @@
'kolab_folders',
'libkolab',
'libcalendaring',
- 'listcommands',
+ // 'listcommands'
'managesieve',
'newmail_notifier',
'odfviewer',
commit 1a75eb26893928bebcb258da49ebed0d9052be56
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat Aug 3 20:10:46 2013 +0100
Add user_find method and do not traceback when the result is not OK
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 9274be3..1dd6aab 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -292,7 +292,8 @@ def request(method, api_uri, get=None, post=None, headers={}):
del response_data['status']
return response_data['result']
else:
- return response_data['result']
+ print "ERROR: %r" % (response_data['reason'])
+ return False
def request_raw(method, api_uri, get=None, post=None, headers={}):
global session_id
@@ -383,6 +384,30 @@ def user_edit(user = None, attributes={}):
return user_edit
+def user_find(attribs=None):
+ if attribs == None:
+ post = {
+ 'search': {
+ 'params': {
+ utils.ask_question("Attribute") : {
+ 'value': utils.ask_question("value"),
+ 'type': 'exact'
+ }
+ }
+ }
+ }
+ else:
+ post = { 'search': { 'params': {} } }
+
+ for (k,v) in attribs.iteritems():
+ post['search']['params'][k] = { 'value': v, 'type': 'exact' }
+
+ post = json.dumps(post)
+
+ user = request('POST', 'user.find', post=post)
+
+ return user
+
def user_form_value_generate(params=None):
if params == None:
params = get_user_input()
commit 7e4e391a82a19a587173cf85f1efb01905c56238
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat Aug 3 20:09:48 2013 +0100
Do not convert folder names that are already raw to utf7 again
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index ed3b29f..6881740 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -363,7 +363,7 @@ class Cyrus(cyruslib.CYRUS):
if not mbox['domain'] == None:
verify_folder_search = "%s@%s" % (verify_folder_search, mbox['domain'])
- folders = self.lm(self.folder_utf7(verify_folder_search))
+ folders = self.lm(verify_folder_search)
# NOTE: Case also covered is valid hexadecimal folders; won't be the
# actual check as intended, but doesn't give you anyone else's data
@@ -375,7 +375,7 @@ class Cyrus(cyruslib.CYRUS):
# but it still would not cover all cases.
#
- # If no folders where found... well... then there you go.
+ # If no folders were found... well... then there you go.
if len(folders) < 1:
return None
commit 6c3f6f84fc9a05f0512f83770fb9d12e2848a3d3
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat Aug 3 20:09:21 2013 +0100
Add a command-line option to specify a specific server
diff --git a/pykolab/cli/cmd_list_mailboxes.py b/pykolab/cli/cmd_list_mailboxes.py
index 4640bc5..ebfefb7 100644
--- a/pykolab/cli/cmd_list_mailboxes.py
+++ b/pykolab/cli/cmd_list_mailboxes.py
@@ -44,6 +44,13 @@ def cli_options():
default = False,
help = _("Display raw IMAP UTF-7 folder names"))
+ my_option_group.add_option( '--server',
+ dest = "connect_server",
+ action = "store",
+ default = None,
+ metavar = "SERVER",
+ help = _("List mailboxes on server SERVER only."))
+
def execute(*args, **kw):
"""
List mailboxes
@@ -68,7 +75,11 @@ def execute(*args, **kw):
searches = [ '' ]
imap = IMAP()
- imap.connect()
+
+ if not conf.connect_server == None:
+ imap.connect(server=conf.connect_server)
+ else:
+ imap.connect()
folders = []
@@ -77,4 +88,7 @@ def execute(*args, **kw):
folders.extend(imap.lm(search))
for folder in folders:
- print imap_utf7.decode(folder)
+ if not conf.raw:
+ print imap_utf7.decode(folder)
+ else:
+ print folder
commit 90c83a2e762943e0c8180b65b1426dfe1b6301bf
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat Aug 3 20:09:03 2013 +0100
List deleted mailboxes with the deletion date
diff --git a/pykolab/cli/cmd_list_deleted_mailboxes.py b/pykolab/cli/cmd_list_deleted_mailboxes.py
index 79c253e..305a129 100644
--- a/pykolab/cli/cmd_list_deleted_mailboxes.py
+++ b/pykolab/cli/cmd_list_deleted_mailboxes.py
@@ -17,10 +17,14 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
+import datetime
+
import commands
import pykolab
+from pykolab import imap_utf7
+from pykolab.auth import Auth
from pykolab.imap import IMAP
from pykolab.translate import _
@@ -30,14 +34,48 @@ conf = pykolab.getConf()
def __init__():
commands.register('list_deleted_mailboxes', execute)
+def cli_options():
+ my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ my_option_group.add_option( '--raw',
+ dest = "raw",
+ action = "store_true",
+ default = False,
+ help = _("Display raw IMAP UTF-7 folder names"))
+
+ my_option_group.add_option( '--server',
+ dest = "connect_server",
+ action = "store",
+ default = None,
+ metavar = "SERVER",
+ help = _("List mailboxes on server SERVER only."))
+
def execute(*args, **kw):
"""
List deleted mailboxes
"""
imap = IMAP()
imap.connect()
- folders = imap.lm("DELETED/*")
+
+ auth = Auth()
+ auth.connect()
+
+ domains = auth.list_domains()
+
+ folders = []
+ for primary,secondaries in domains:
+ folders.extend(imap.lm("DELETED/*@%s" % (primary)))
+ for secondary in secondaries:
+ folders.extend(imap.lm("DELETED/*@%s" % (secondary)))
+
+ folders.extend(imap.lm("DELETED/*"))
+
print "Deleted folders:"
+
for folder in folders:
- print folder
+ mbox_parts = imap.parse_mailfolder(folder)
+
+ if not conf.raw:
+ print "%s (Deleted at %s)" % (imap_utf7.decode(folder), datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
+ else:
+ print "%s (Deleted at %s)" % (folder, datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
commit 553e2c82142f405e772f480ecfc446ff91da17b7
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat Aug 3 12:53:01 2013 +0100
Add a command user-info
diff --git a/pykolab/cli/cmd_user_info.py b/pykolab/cli/cmd_user_info.py
new file mode 100644
index 0000000..23fceb8
--- /dev/null
+++ b/pykolab/cli/cmd_user_info.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 3 or, at your option, any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+import commands
+
+import pykolab
+
+from pykolab import utils
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.cli')
+conf = pykolab.getConf()
+
+def __init__():
+ commands.register('user_info', execute, description="Display user information.")
+
+def execute(*args, **kw):
+ from pykolab import wap_client
+
+ try:
+ user = conf.cli_args.pop(0)
+ except IndexError, errmsg:
+ user = utils.ask_question(_("Email address"))
+
+ wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw"))
+ if len(user.split('@')) > 1:
+ wap_client.system_select_domain(user.split('@')[1])
+
+ user_info = wap_client.user_find({'mail':user})
+
+ for (k,v) in user_info.iteritems():
+ print "%s: %r" % (k,v)
More information about the commits
mailing list