mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
no imports *
This commit is contained in:
@@ -9,10 +9,10 @@ import time
|
||||
from functools import wraps
|
||||
from django.utils.translation import ugettext as _
|
||||
from modoboa.lib import parameters
|
||||
from modoboa.lib.connections import *
|
||||
from modoboa.lib.connections import ConnectionsManager
|
||||
from modoboa.lib.webutils import static_url
|
||||
from exceptions import ImapError, WebmailError
|
||||
from fetch_parser import *
|
||||
from fetch_parser import parse_fetch_response
|
||||
|
||||
#imaplib.Debug = 4
|
||||
|
||||
@@ -80,7 +80,7 @@ class BodyStructure(object):
|
||||
"""
|
||||
pnum = "1" if pnum is None else pnum
|
||||
params = dict(pnum=pnum, params=definition[2], cid=definition[3],
|
||||
description=definition[4], encoding=definition[5],
|
||||
description=definition[4], encoding=definition[5],
|
||||
size=definition[6])
|
||||
mtype = definition[0].lower()
|
||||
subtype = definition[1].lower()
|
||||
@@ -122,7 +122,7 @@ class BodyStructure(object):
|
||||
for part in struct[0]:
|
||||
self.load_from_definition(part, struct[1])
|
||||
return
|
||||
|
||||
|
||||
self.__store_part(struct, pnum, multisubtype)
|
||||
|
||||
def has_attachments(self):
|
||||
@@ -214,7 +214,7 @@ class IMAPconnector(object):
|
||||
cpt += 1
|
||||
else:
|
||||
if bodystruct[0].lower() == mtype and bodystruct[1].lower() == stype:
|
||||
return ("1" if not len(prefix) else prefix,
|
||||
return ("1" if not len(prefix) else prefix,
|
||||
bodystruct[5], int(bodystruct[6]))
|
||||
return (None, None, 0)
|
||||
|
||||
@@ -230,12 +230,12 @@ class IMAPconnector(object):
|
||||
if hasattr(self, "current_mailbox"):
|
||||
del self.current_mailbox
|
||||
else:
|
||||
return
|
||||
return
|
||||
self.login(user, password)
|
||||
|
||||
def login(self, user, passwd):
|
||||
"""Custom login method
|
||||
|
||||
|
||||
We connect to the server, issue a LOGIN command. If
|
||||
successfull, we try to record a eventuel CAPABILITY untagged
|
||||
response. Otherwise, we issue the command.
|
||||
@@ -305,9 +305,9 @@ class IMAPconnector(object):
|
||||
"""Issue a SELECT/EXAMINE command to the server
|
||||
|
||||
The given name is first 'imap-utf7' encoded.
|
||||
|
||||
|
||||
:param name: mailbox's name
|
||||
:param readonly:
|
||||
:param readonly:
|
||||
"""
|
||||
if hasattr(self, "current_mailbox"):
|
||||
if self.current_mailbox == name and not force:
|
||||
@@ -348,7 +348,7 @@ class IMAPconnector(object):
|
||||
break
|
||||
if sdescr is None:
|
||||
sdescr = {"name" : parts[0], "path" : path, "sub" : []}
|
||||
descr += [sdescr]
|
||||
descr += [sdescr]
|
||||
if self._parse_mailbox_name(sdescr["sub"], path, delimiter, parts[1:]):
|
||||
sdescr["class"] = "subfolders"
|
||||
return True
|
||||
@@ -376,7 +376,7 @@ class IMAPconnector(object):
|
||||
if not descr.has_key("path"):
|
||||
descr["path"] = parts[0]
|
||||
descr["sub"] = []
|
||||
if self._parse_mailbox_name(descr["sub"], parts[0], delimiter,
|
||||
if self._parse_mailbox_name(descr["sub"], parts[0], delimiter,
|
||||
parts[1:]):
|
||||
descr["class"] = "subfolders"
|
||||
continue
|
||||
@@ -404,7 +404,7 @@ class IMAPconnector(object):
|
||||
newmboxes += [descr]
|
||||
else:
|
||||
descr = mailboxes[idx]
|
||||
|
||||
|
||||
if r'\Marked' in flags or not r'\UnMarked' in flags:
|
||||
descr["send_status"] = True
|
||||
if r'\HasChildren' in flags:
|
||||
@@ -433,7 +433,7 @@ class IMAPconnector(object):
|
||||
md_mailboxes = []
|
||||
else:
|
||||
md_mailboxes = [{"name" : "INBOX", "class" : "icon-inbox"},
|
||||
{"name" : parameters.get_user(user, "DRAFTS_FOLDER"),
|
||||
{"name" : parameters.get_user(user, "DRAFTS_FOLDER"),
|
||||
"class" : "icon-file"},
|
||||
{"name" : 'Junk', "class" : "icon-fire"},
|
||||
{"name" : parameters.get_user(user, "SENT_FOLDER"),
|
||||
@@ -515,7 +515,7 @@ class IMAPconnector(object):
|
||||
"""Compact a specific mailbox
|
||||
|
||||
Issue an EXPUNGE command for the specified mailbox.
|
||||
|
||||
|
||||
:param mbox: the mailbox's name
|
||||
"""
|
||||
self.select_mailbox(mbox, False)
|
||||
@@ -547,12 +547,12 @@ class IMAPconnector(object):
|
||||
self.quota_limit = self.quota_actual = None
|
||||
return
|
||||
|
||||
data = self._cmd("GETQUOTAROOT", self._encode_mbox_name(mailbox),
|
||||
data = self._cmd("GETQUOTAROOT", self._encode_mbox_name(mailbox),
|
||||
responses=["QUOTAROOT", "QUOTA"])
|
||||
if data is None:
|
||||
self.quota_limit = self.quota_actual = None
|
||||
return
|
||||
|
||||
|
||||
quotadef = data[1][0]
|
||||
m = re.match("[^\s]+ \(STORAGE (\d+) (\d+)\)", quotadef)
|
||||
if not m:
|
||||
@@ -635,7 +635,7 @@ class IMAPconnector(object):
|
||||
headers = ['DATE', 'FROM', 'TO', 'CC', 'SUBJECT']
|
||||
bcmd = "BODY.PEEK" if readonly else "BODY"
|
||||
data = self._cmd(
|
||||
"FETCH", mailid,
|
||||
"FETCH", mailid,
|
||||
"(BODYSTRUCTURE %s[HEADER.FIELDS (%s)])" % (bcmd, " ".join(headers))
|
||||
)
|
||||
return data[int(mailid)]
|
||||
@@ -658,7 +658,7 @@ def get_imapconnector(request):
|
||||
|
||||
:param request: a ``Request`` object
|
||||
"""
|
||||
imapc = IMAPconnector(user=request.user.username,
|
||||
imapc = IMAPconnector(user=request.user.username,
|
||||
password=request.session["password"])
|
||||
return imapc
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ import re
|
||||
from modoboa.lib import u2u_decode, tables, parameters
|
||||
from modoboa.lib.webutils import size2integer
|
||||
from modoboa.lib.email_listing import EmailListing
|
||||
from modoboa.lib.emailutils import *
|
||||
from imaputils import *
|
||||
from exceptions import *
|
||||
from modoboa.extensions.webmail.exceptions import WebmailError
|
||||
from modoboa.extensions.webmail.imaputils import IMAPconnector, get_imapconnector, BodyStructure
|
||||
from modoboa.lib.emailutils import EmailAddress, Email
|
||||
|
||||
|
||||
class WMtable(tables.Table):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# coding: utf-8
|
||||
from modoboa.lib.webutils import ajax_response, _render_error
|
||||
from modoboa.extensions.webmail.exceptions import *
|
||||
from modoboa.extensions.webmail.exceptions import WebmailError, ImapError
|
||||
|
||||
class WebmailErrorMiddleware(object):
|
||||
def process_exception(self, request, exception):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# coding: utf-8
|
||||
from django.conf.urls.defaults import *
|
||||
from django.conf.urls.defaults import patterns
|
||||
|
||||
urlpatterns = patterns(
|
||||
'modoboa.extensions.webmail.views',
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# coding: utf-8
|
||||
from django.conf import settings
|
||||
import os
|
||||
from django.http import HttpResponse
|
||||
from django.template import Template, Context
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -7,8 +9,10 @@ from django.contrib.auth.decorators import login_required
|
||||
from modoboa.lib import parameters
|
||||
from modoboa.lib.webutils import _render, _render_to_string, ajax_response, ajax_simple_response
|
||||
from modoboa.lib.decorators import needs_mailbox
|
||||
from lib import *
|
||||
from forms import *
|
||||
from exceptions import WebmailError
|
||||
from forms import FolderForm, AttachmentForm, ComposeMailForm
|
||||
from imaputils import get_imapconnector, IMAPconnector, separate_mailbox
|
||||
from lib import decode_payload, AttachmentUploadHandler, save_attachment, ImapListing, EmailSignature, clean_attachments, set_compose_session, send_mail, ImapEmail
|
||||
from templatetags import webextras
|
||||
|
||||
@login_required
|
||||
@@ -222,7 +226,7 @@ def attachments(request, tplname="webmail/attachments.html"):
|
||||
return _render(request, "webmail/upload_done.html", {
|
||||
"status" : "ok", "fname" : request.FILES["attachment"],
|
||||
"tmpname" : os.path.basename(tmpname)
|
||||
});
|
||||
})
|
||||
except WebmailError, inst:
|
||||
error = _("Failed to save attachment: ") + str(inst)
|
||||
|
||||
@@ -231,7 +235,7 @@ def attachments(request, tplname="webmail/attachments.html"):
|
||||
% parameters.get_admin("MAX_ATTACHMENT_SIZE"))
|
||||
return _render(request, "webmail/upload_done.html", {
|
||||
"status" : "ko", "error" : error
|
||||
});
|
||||
})
|
||||
ctx = {
|
||||
"title" : _("Attachments"),
|
||||
"formid" : "uploadfile",
|
||||
|
||||
Reference in New Issue
Block a user