First version of the sieve plugin is over \o/ It needs more testing but all functionalities are implemented. Maybe some extra sieve extensions would be nice but I'll see that based on user feedback.

I also include some general refactoring in this commit.

see #139
This commit is contained in:
Antoine Nguyen
2011-06-19 19:11:02 +02:00
parent add222840c
commit 7338dd1c8f
34 changed files with 1709 additions and 1320 deletions
+11 -19
View File
@@ -10,14 +10,15 @@ import socket
import imaplib
import ssl
from datetime import datetime, timedelta
import email.utils
import email
import lxml
from django.utils.translation import ugettext as _
from django.conf import settings
from modoboa.lib import decode, u2u_decode, tables, \
imap_utf7, static_url, parameters
from modoboa.lib.connections import ConnectionsManager
from modoboa.lib.email_listing import MBconnector, EmailListing, Email
from modoboa.lib.email_listing import MBconnector, EmailListing
from modoboa.lib.emailutils import *
class WebmailError(Exception):
errorexpr = re.compile("\[([^\]]+)\]\s*([^\.]+)")
@@ -51,16 +52,6 @@ class WMtable(tables.Table):
except AttributeError:
return value
class EmailAddress(object):
def __init__(self, address):
self.fulladdress = u2u_decode.u2u_decode(address).strip("\r\t\n")
(self.name, self.address) = email.utils.parseaddr(self.fulladdress)
if self.name == "":
self.fulladdress = self.address
def __str__(self):
return self.fulladdress
class IMAPheader(object):
@staticmethod
def parse_address(value, **kwargs):
@@ -250,7 +241,7 @@ class IMAPconnector(object):
from operator import itemgetter
return sorted(result, key=itemgetter("name"))
def getfolders(self, user):
def getfolders(self, user, unseen_messages=True):
md_folders = [{"name" : "INBOX", "class" : "inbox"},
{"name" : parameters.get_user(user, "DRAFTS_FOLDER"),
"class" : "drafts"},
@@ -259,12 +250,13 @@ class IMAPconnector(object):
{"name" : parameters.get_user(user, "TRASH_FOLDER"),
"class" : "trash"}]
md_folders += self._listfolders(md_folders=md_folders)
for fd in md_folders:
key = fd.has_key("path") and "path" or "name"
count = self.unseen_messages(fd[key])
if count == 0:
continue
fd["unseen"] = count
if unseen_messages:
for fd in md_folders:
key = fd.has_key("path") and "path" or "name"
count = self.unseen_messages(fd[key])
if count == 0:
continue
fd["unseen"] = count
return md_folders
def _add_flag(self, folder, mail_id, flag):
+3 -3
View File
@@ -119,7 +119,7 @@ function compose_callback(resp) {
onSuccess: function(resp) {
resp = JSON.decode(resp);
if (resp.status == "ko") {
get_callback("compose")(resp);
current_anchor.get_callback("compose")(resp);
if ($defined(resp.error)) {
infobox.error(resp.error);
@@ -199,7 +199,7 @@ function refreshFolder() {
new Request.JSON({url: query, noCache : true, onSuccess: function(resp) {
var callback = ($defined(resp.callback)) ? resp.callback : "default";
callbacks[callback](resp);
current_anchor.get_callback(callback)(resp);
infobox.info(gettext("Done"));
infobox.hide(1);
}}).get();
@@ -222,7 +222,7 @@ function simple_request(url, params) {
onSuccess : function(response) {
if (response.status == "ok") {
if (!$defined(response.next)) {
get_callback("folder")(response);
current_anchor.get_callback("folder")(response);
}
infobox.info(gettext("Done"));
if ($defined(response.next)) {
@@ -58,11 +58,11 @@ function wm_updatelisting(resp) {
displayID: "quotatext"
});
register_callback("viewmail", viewmail_cb);
register_callback("compose", compose_callback);
register_callback("reply", compose_callback);
register_callback("replyall", compose_callback);
register_callback("forward", compose_callback);
current_anchor.register_callback("viewmail", viewmail_cb);
current_anchor.register_callback("compose", compose_callback);
current_anchor.register_callback("reply", compose_callback);
current_anchor.register_callback("replyall", compose_callback);
current_anchor.register_callback("forward", compose_callback);
window.addEvent("pageRefresh", function() {
if (rtimer) {
@@ -71,7 +71,7 @@ function wm_updatelisting(resp) {
}
});
register_callback("folder", function(resp) {
current_anchor.register_callback("folder", function(resp) {
wm_updatelisting(resp);
rtimer = refreshFolder.periodical({{ refreshrate }});
searchbox_init();