author | alwin <alwin> | 2004-03-10 22:44:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-10 22:44:44 (UTC) |
commit | 9454ac48a53f3b49e03288311b71436ccacd2d04 (patch) (unidiff) | |
tree | e05d40f575c87431d84c5ac374ff8ce656e6a419 /noncore/net/mail/libmailwrapper/abstractmail.cpp | |
parent | a72855867dedd2b4c16f703fa104b5c6175ce484 (diff) | |
download | opie-9454ac48a53f3b49e03288311b71436ccacd2d04.zip opie-9454ac48a53f3b49e03288311b71436ccacd2d04.tar.gz opie-9454ac48a53f3b49e03288311b71436ccacd2d04.tar.bz2 |
some bugfixes
When edit a mail to send and cancel is pressed the mail can stored in a draft
folder and later edit again. This moment we will not store attachments into
drafts.
Diffstat (limited to 'noncore/net/mail/libmailwrapper/abstractmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 9960f88..d71d35c 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -10,48 +10,66 @@ | |||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <libetpan/mailmime_content.h> | 11 | #include <libetpan/mailmime_content.h> |
12 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
13 | 13 | ||
14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
15 | { | 15 | { |
16 | return new IMAPwrapper(a); | 16 | return new IMAPwrapper(a); |
17 | } | 17 | } |
18 | 18 | ||
19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
20 | { | 20 | { |
21 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
22 | } | 22 | } |
23 | 23 | ||
24 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 24 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
25 | { | 25 | { |
26 | return new NNTPwrapper(a); | 26 | return new NNTPwrapper(a); |
27 | } | 27 | } |
28 | 28 | ||
29 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 29 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
30 | { | 30 | { |
31 | return new MHwrapper(a,name); | 31 | return new MHwrapper(a,name); |
32 | } | 32 | } |
33 | 33 | ||
34 | AbstractMail* AbstractMail::getWrapper(Account*a) | ||
35 | { | ||
36 | if (!a) return 0; | ||
37 | switch (a->getType()) { | ||
38 | case MAILLIB::A_IMAP: | ||
39 | return new IMAPwrapper((IMAPaccount*)a); | ||
40 | break; | ||
41 | case MAILLIB::A_POP3: | ||
42 | return new POP3wrapper((POP3account*)a); | ||
43 | break; | ||
44 | case MAILLIB::A_NNTP: | ||
45 | return new NNTPwrapper((NNTPaccount*)a); | ||
46 | break; | ||
47 | default: | ||
48 | return 0; | ||
49 | } | ||
50 | } | ||
51 | |||
34 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 52 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
35 | { | 53 | { |
36 | qDebug("Decode string start"); | 54 | qDebug("Decode string start"); |
37 | char*result_text; | 55 | char*result_text; |
38 | size_t index = 0; | 56 | size_t index = 0; |
39 | /* reset for recursive use! */ | 57 | /* reset for recursive use! */ |
40 | size_t target_length = 0; | 58 | size_t target_length = 0; |
41 | result_text = 0; | 59 | result_text = 0; |
42 | int mimetype = MAILMIME_MECHANISM_7BIT; | 60 | int mimetype = MAILMIME_MECHANISM_7BIT; |
43 | if (enc.lower()=="quoted-printable") { | 61 | if (enc.lower()=="quoted-printable") { |
44 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 62 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
45 | } else if (enc.lower()=="base64") { | 63 | } else if (enc.lower()=="base64") { |
46 | mimetype = MAILMIME_MECHANISM_BASE64; | 64 | mimetype = MAILMIME_MECHANISM_BASE64; |
47 | } else if (enc.lower()=="8bit") { | 65 | } else if (enc.lower()=="8bit") { |
48 | mimetype = MAILMIME_MECHANISM_8BIT; | 66 | mimetype = MAILMIME_MECHANISM_8BIT; |
49 | } else if (enc.lower()=="binary") { | 67 | } else if (enc.lower()=="binary") { |
50 | mimetype = MAILMIME_MECHANISM_BINARY; | 68 | mimetype = MAILMIME_MECHANISM_BINARY; |
51 | } | 69 | } |
52 | 70 | ||
53 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 71 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
54 | &result_text,&target_length); | 72 | &result_text,&target_length); |
55 | 73 | ||
56 | encodedString* result = new encodedString(); | 74 | encodedString* result = new encodedString(); |
57 | if (err == MAILIMF_NO_ERROR) { | 75 | if (err == MAILIMF_NO_ERROR) { |
@@ -84,48 +102,53 @@ QString AbstractMail::convert_String(const char*text) | |||
84 | /* cp & paste from launcher */ | 102 | /* cp & paste from launcher */ |
85 | QString AbstractMail::gen_attachment_id() | 103 | QString AbstractMail::gen_attachment_id() |
86 | { | 104 | { |
87 | QFile file( "/proc/sys/kernel/random/uuid" ); | 105 | QFile file( "/proc/sys/kernel/random/uuid" ); |
88 | if (!file.open(IO_ReadOnly ) ) | 106 | if (!file.open(IO_ReadOnly ) ) |
89 | return QString::null; | 107 | return QString::null; |
90 | 108 | ||
91 | QTextStream stream(&file); | 109 | QTextStream stream(&file); |
92 | 110 | ||
93 | return "{" + stream.read().stripWhiteSpace() + "}"; | 111 | return "{" + stream.read().stripWhiteSpace() + "}"; |
94 | } | 112 | } |
95 | 113 | ||
96 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 114 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) |
97 | { | 115 | { |
98 | return 0; | 116 | return 0; |
99 | } | 117 | } |
100 | 118 | ||
101 | QString AbstractMail::defaultLocalfolder() | 119 | QString AbstractMail::defaultLocalfolder() |
102 | { | 120 | { |
103 | QString f = getenv( "HOME" ); | 121 | QString f = getenv( "HOME" ); |
104 | f += "/Applications/opiemail/localmail"; | 122 | f += "/Applications/opiemail/localmail"; |
105 | return f; | 123 | return f; |
106 | } | 124 | } |
107 | 125 | ||
126 | QString AbstractMail::draftFolder() | ||
127 | { | ||
128 | return QString("Drafts"); | ||
129 | } | ||
130 | |||
108 | /* temporary - will be removed when implemented in all classes */ | 131 | /* temporary - will be removed when implemented in all classes */ |
109 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 132 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) |
110 | { | 133 | { |
111 | } | 134 | } |
112 | 135 | ||
113 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 136 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
114 | { | 137 | { |
115 | QList<RecMail> t; | 138 | QList<RecMail> t; |
116 | listMessages(fromFolder->getName(),t); | 139 | listMessages(fromFolder->getName(),t); |
117 | encodedString*st = 0; | 140 | encodedString*st = 0; |
118 | while (t.count()>0) { | 141 | while (t.count()>0) { |
119 | RecMail*r = t.at(0); | 142 | RecMail*r = t.at(0); |
120 | st = fetchRawBody(*r); | 143 | st = fetchRawBody(*r); |
121 | if (st) { | 144 | if (st) { |
122 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 145 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
123 | delete st; | 146 | delete st; |
124 | } | 147 | } |
125 | t.removeFirst(); | 148 | t.removeFirst(); |
126 | } | 149 | } |
127 | if (moveit) { | 150 | if (moveit) { |
128 | deleteAllMail(fromFolder); | 151 | deleteAllMail(fromFolder); |
129 | } | 152 | } |
130 | } | 153 | } |
131 | 154 | ||