author | harlekin <harlekin> | 2004-01-04 02:35:03 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-01-04 02:35:03 (UTC) |
commit | d93529cebc9ea9ab4adf674e93e204f5a53d8906 (patch) (unidiff) | |
tree | 727ebb146a3518a2303d515c8e3e5e093397b9dc /noncore/net/mail/libmailwrapper | |
parent | 55df8c221c43d81f6132d033553a173276954f7c (diff) | |
download | opie-d93529cebc9ea9ab4adf674e93e204f5a53d8906.zip opie-d93529cebc9ea9ab4adf674e93e204f5a53d8906.tar.gz opie-d93529cebc9ea9ab4adf674e93e204f5a53d8906.tar.bz2 |
adapt build system to lib etc and get it build
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/.cvsignore | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/config.in | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/libmailwrapper.pro | 44 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 15 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 36 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 4 |
6 files changed, 93 insertions, 16 deletions
diff --git a/noncore/net/mail/libmailwrapper/.cvsignore b/noncore/net/mail/libmailwrapper/.cvsignore new file mode 100644 index 0000000..581c299 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | logindialogui.cpp | ||
2 | logindialogui.h | ||
3 | sendmailprogressui.cpp | ||
4 | sendmailprogressui.h | ||
5 | .moc | ||
6 | Makefile | ||
diff --git a/noncore/net/mail/libmailwrapper/config.in b/noncore/net/mail/libmailwrapper/config.in new file mode 100644 index 0000000..790891e --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config LIBMAILWRAPPER | ||
2 | boolean "libmailwrapper ( wrapper arround libetpan needed by mail3" | ||
3 | default "y" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | ||
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro new file mode 100644 index 0000000..4b4a4f1 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro | |||
@@ -0,0 +1,44 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on debug | ||
3 | |||
4 | HEADERS = mailwrapper.h \ | ||
5 | imapwrapper.h \ | ||
6 | mailtypes.h \ | ||
7 | pop3wrapper.h \ | ||
8 | abstractmail.h \ | ||
9 | smtpwrapper.h \ | ||
10 | genericwrapper.h \ | ||
11 | mboxwrapper.h \ | ||
12 | settings.h \ | ||
13 | logindialog.h \ | ||
14 | sendmailprogress.h | ||
15 | |||
16 | SOURCES = imapwrapper.cpp \ | ||
17 | mailwrapper.cpp \ | ||
18 | mailtypes.cpp \ | ||
19 | pop3wrapper.cpp \ | ||
20 | abstractmail.cpp \ | ||
21 | smtpwrapper.cpp \ | ||
22 | genericwrapper.cpp \ | ||
23 | mboxwrapper.cpp \ | ||
24 | settings.cpp \ | ||
25 | logindialog.cpp \ | ||
26 | sendmailprogress.cpp | ||
27 | |||
28 | INTERFACES = logindialogui.ui \ | ||
29 | sendmailprogressui.ui | ||
30 | |||
31 | |||
32 | INCLUDEPATH += $(OPIEDIR)/include | ||
33 | |||
34 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | ||
35 | contains( CONFTEST, y ){ | ||
36 | LIBS += -lqpe -letpan -lssl -lcrypto -liconv | ||
37 | }else{ | ||
38 | LIBS += -lqpe -letpan -lssl -lcrypto | ||
39 | } | ||
40 | |||
41 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | ||
42 | TARGET = mailwrapper | ||
43 | |||
44 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 9398823..75b9343 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -1,59 +1,70 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | 8 | ||
9 | #include "mailwrapper.h" | 9 | #include "mailwrapper.h" |
10 | #include "logindialog.h" | 10 | //#include "logindialog.h" |
11 | #include "defines.h" | 11 | //#include "defines.h" |
12 | |||
13 | #define UNDEFINED 64 | ||
14 | #define MAXLINE 76 | ||
15 | #define UTF16MASK 0x03FFUL | ||
16 | #define UTF16SHIFT 10 | ||
17 | #define UTF16BASE 0x10000UL | ||
18 | #define UTF16HIGHSTART 0xD800UL | ||
19 | #define UTF16HIGHEND 0xDBFFUL | ||
20 | #define UTF16LOSTART 0xDC00UL | ||
21 | #define UTF16LOEND 0xDFFFUL | ||
22 | |||
12 | 23 | ||
13 | Attachment::Attachment( DocLnk lnk ) | 24 | Attachment::Attachment( DocLnk lnk ) |
14 | { | 25 | { |
15 | doc = lnk; | 26 | doc = lnk; |
16 | size = QFileInfo( doc.file() ).size(); | 27 | size = QFileInfo( doc.file() ).size(); |
17 | } | 28 | } |
18 | 29 | ||
19 | Folder::Folder(const QString&tmp_name, const QString&sep ) | 30 | Folder::Folder(const QString&tmp_name, const QString&sep ) |
20 | { | 31 | { |
21 | name = tmp_name; | 32 | name = tmp_name; |
22 | nameDisplay = name; | 33 | nameDisplay = name; |
23 | separator = sep; | 34 | separator = sep; |
24 | } | 35 | } |
25 | 36 | ||
26 | const QString& Folder::Separator()const | 37 | const QString& Folder::Separator()const |
27 | { | 38 | { |
28 | return separator; | 39 | return separator; |
29 | } | 40 | } |
30 | 41 | ||
31 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&prefix ) | 42 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&prefix ) |
32 | : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) | 43 | : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) |
33 | { | 44 | { |
34 | // Decode IMAP foldername | 45 | // Decode IMAP foldername |
35 | nameDisplay = IMAPFolder::decodeFolderName( name ); | 46 | nameDisplay = IMAPFolder::decodeFolderName( name ); |
36 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); | 47 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); |
37 | 48 | ||
38 | if (prefix.length()>0) { | 49 | if (prefix.length()>0) { |
39 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { | 50 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { |
40 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); | 51 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); |
41 | } | 52 | } |
42 | } | 53 | } |
43 | } | 54 | } |
44 | 55 | ||
45 | static unsigned char base64chars[] = | 56 | static unsigned char base64chars[] = |
46 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; | 57 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; |
47 | 58 | ||
48 | /** | 59 | /** |
49 | * Decodes base64 encoded parts of the imapfolder name | 60 | * Decodes base64 encoded parts of the imapfolder name |
50 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc | 61 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc |
51 | */ | 62 | */ |
52 | QString IMAPFolder::decodeFolderName( const QString &name ) | 63 | QString IMAPFolder::decodeFolderName( const QString &name ) |
53 | { | 64 | { |
54 | unsigned char c, i, bitcount; | 65 | unsigned char c, i, bitcount; |
55 | unsigned long ucs4, utf16, bitbuf; | 66 | unsigned long ucs4, utf16, bitbuf; |
56 | unsigned char base64[256], utf8[6]; | 67 | unsigned char base64[256], utf8[6]; |
57 | unsigned long srcPtr = 0; | 68 | unsigned long srcPtr = 0; |
58 | QCString dst = ""; | 69 | QCString dst = ""; |
59 | QCString src = name.ascii(); | 70 | QCString src = name.ascii(); |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 17aa1b0..c5187f5 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -1,403 +1,413 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | 5 | ||
6 | #include "settings.h" | 6 | #include "settings.h" |
7 | #include "defines.h" | 7 | //#include "defines.h" |
8 | |||
9 | #define IMAP_PORT "143" | ||
10 | #define IMAP_SSL_PORT "993" | ||
11 | #define SMTP_PORT "25" | ||
12 | #define SMTP_SSL_PORT "465" | ||
13 | #define POP3_PORT "110" | ||
14 | #define POP3_SSL_PORT "995" | ||
15 | #define NNTP_PORT "119" | ||
16 | #define NNTP_SSL_PORT "563" | ||
17 | |||
8 | 18 | ||
9 | Settings::Settings() | 19 | Settings::Settings() |
10 | : QObject() | 20 | : QObject() |
11 | { | 21 | { |
12 | updateAccounts(); | 22 | updateAccounts(); |
13 | } | 23 | } |
14 | 24 | ||
15 | void Settings::checkDirectory() | 25 | void Settings::checkDirectory() |
16 | { | 26 | { |
17 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
18 | system( "mkdir -p $HOME/Applications/opiemail" ); | 28 | system( "mkdir -p $HOME/Applications/opiemail" ); |
19 | qDebug( "$HOME/Applications/opiemail created" ); | 29 | qDebug( "$HOME/Applications/opiemail created" ); |
20 | } | 30 | } |
21 | } | 31 | } |
22 | 32 | ||
23 | QList<Account> Settings::getAccounts() | 33 | QList<Account> Settings::getAccounts() |
24 | { | 34 | { |
25 | return accounts; | 35 | return accounts; |
26 | } | 36 | } |
27 | 37 | ||
28 | void Settings::addAccount( Account *account ) | 38 | void Settings::addAccount( Account *account ) |
29 | { | 39 | { |
30 | accounts.append( account ); | 40 | accounts.append( account ); |
31 | } | 41 | } |
32 | 42 | ||
33 | void Settings::delAccount( Account *account ) | 43 | void Settings::delAccount( Account *account ) |
34 | { | 44 | { |
35 | accounts.remove( account ); | 45 | accounts.remove( account ); |
36 | account->remove(); | 46 | account->remove(); |
37 | } | 47 | } |
38 | 48 | ||
39 | void Settings::updateAccounts() | 49 | void Settings::updateAccounts() |
40 | { | 50 | { |
41 | accounts.clear(); | 51 | accounts.clear(); |
42 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
43 | QStringList::Iterator it; | 53 | QStringList::Iterator it; |
44 | 54 | ||
45 | QStringList imap = dir.entryList( "imap-*" ); | 55 | QStringList imap = dir.entryList( "imap-*" ); |
46 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 56 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
47 | qDebug( "Added IMAP account" ); | 57 | qDebug( "Added IMAP account" ); |
48 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
49 | accounts.append( account ); | 59 | accounts.append( account ); |
50 | } | 60 | } |
51 | 61 | ||
52 | QStringList pop3 = dir.entryList( "pop3-*" ); | 62 | QStringList pop3 = dir.entryList( "pop3-*" ); |
53 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
54 | qDebug( "Added POP account" ); | 64 | qDebug( "Added POP account" ); |
55 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
56 | accounts.append( account ); | 66 | accounts.append( account ); |
57 | } | 67 | } |
58 | 68 | ||
59 | QStringList smtp = dir.entryList( "smtp-*" ); | 69 | QStringList smtp = dir.entryList( "smtp-*" ); |
60 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
61 | qDebug( "Added SMTP account" ); | 71 | qDebug( "Added SMTP account" ); |
62 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
63 | accounts.append( account ); | 73 | accounts.append( account ); |
64 | } | 74 | } |
65 | 75 | ||
66 | QStringList nntp = dir.entryList( "nntp-*" ); | 76 | QStringList nntp = dir.entryList( "nntp-*" ); |
67 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
68 | qDebug( "Added NNTP account" ); | 78 | qDebug( "Added NNTP account" ); |
69 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
70 | accounts.append( account ); | 80 | accounts.append( account ); |
71 | } | 81 | } |
72 | 82 | ||
73 | readAccounts(); | 83 | readAccounts(); |
74 | } | 84 | } |
75 | 85 | ||
76 | void Settings::saveAccounts() | 86 | void Settings::saveAccounts() |
77 | { | 87 | { |
78 | checkDirectory(); | 88 | checkDirectory(); |
79 | Account *it; | 89 | Account *it; |
80 | 90 | ||
81 | for ( it = accounts.first(); it; it = accounts.next() ) { | 91 | for ( it = accounts.first(); it; it = accounts.next() ) { |
82 | it->save(); | 92 | it->save(); |
83 | } | 93 | } |
84 | } | 94 | } |
85 | 95 | ||
86 | void Settings::readAccounts() | 96 | void Settings::readAccounts() |
87 | { | 97 | { |
88 | checkDirectory(); | 98 | checkDirectory(); |
89 | Account *it; | 99 | Account *it; |
90 | 100 | ||
91 | for ( it = accounts.first(); it; it = accounts.next() ) { | 101 | for ( it = accounts.first(); it; it = accounts.next() ) { |
92 | it->read(); | 102 | it->read(); |
93 | } | 103 | } |
94 | } | 104 | } |
95 | 105 | ||
96 | Account::Account() | 106 | Account::Account() |
97 | { | 107 | { |
98 | accountName = "changeMe"; | 108 | accountName = "changeMe"; |
99 | type = "changeMe"; | 109 | type = "changeMe"; |
100 | ssl = false; | 110 | ssl = false; |
101 | } | 111 | } |
102 | 112 | ||
103 | void Account::remove() | 113 | void Account::remove() |
104 | { | 114 | { |
105 | QFile file( getFileName() ); | 115 | QFile file( getFileName() ); |
106 | file.remove(); | 116 | file.remove(); |
107 | } | 117 | } |
108 | 118 | ||
109 | IMAPaccount::IMAPaccount() | 119 | IMAPaccount::IMAPaccount() |
110 | : Account() | 120 | : Account() |
111 | { | 121 | { |
112 | file = IMAPaccount::getUniqueFileName(); | 122 | file = IMAPaccount::getUniqueFileName(); |
113 | accountName = "New IMAP Account"; | 123 | accountName = "New IMAP Account"; |
114 | ssl = false; | 124 | ssl = false; |
115 | type = "IMAP"; | 125 | type = "IMAP"; |
116 | port = IMAP_PORT; | 126 | port = IMAP_PORT; |
117 | } | 127 | } |
118 | 128 | ||
119 | IMAPaccount::IMAPaccount( QString filename ) | 129 | IMAPaccount::IMAPaccount( QString filename ) |
120 | : Account() | 130 | : Account() |
121 | { | 131 | { |
122 | file = filename; | 132 | file = filename; |
123 | accountName = "New IMAP Account"; | 133 | accountName = "New IMAP Account"; |
124 | ssl = false; | 134 | ssl = false; |
125 | type = "IMAP"; | 135 | type = "IMAP"; |
126 | port = IMAP_PORT; | 136 | port = IMAP_PORT; |
127 | } | 137 | } |
128 | 138 | ||
129 | QString IMAPaccount::getUniqueFileName() | 139 | QString IMAPaccount::getUniqueFileName() |
130 | { | 140 | { |
131 | int num = 0; | 141 | int num = 0; |
132 | QString unique; | 142 | QString unique; |
133 | 143 | ||
134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 144 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
135 | 145 | ||
136 | QStringList imap = dir.entryList( "imap-*" ); | 146 | QStringList imap = dir.entryList( "imap-*" ); |
137 | do { | 147 | do { |
138 | unique.setNum( num++ ); | 148 | unique.setNum( num++ ); |
139 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 149 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
140 | 150 | ||
141 | return unique; | 151 | return unique; |
142 | } | 152 | } |
143 | 153 | ||
144 | void IMAPaccount::read() | 154 | void IMAPaccount::read() |
145 | { | 155 | { |
146 | Config *conf = new Config( getFileName(), Config::File ); | 156 | Config *conf = new Config( getFileName(), Config::File ); |
147 | conf->setGroup( "IMAP Account" ); | 157 | conf->setGroup( "IMAP Account" ); |
148 | accountName = conf->readEntry( "Account","" ); | 158 | accountName = conf->readEntry( "Account","" ); |
149 | if (accountName.isNull()) accountName = ""; | 159 | if (accountName.isNull()) accountName = ""; |
150 | server = conf->readEntry( "Server","" ); | 160 | server = conf->readEntry( "Server","" ); |
151 | if (server.isNull()) server=""; | 161 | if (server.isNull()) server=""; |
152 | port = conf->readEntry( "Port","" ); | 162 | port = conf->readEntry( "Port","" ); |
153 | if (port.isNull()) port="143"; | 163 | if (port.isNull()) port="143"; |
154 | ssl = conf->readBoolEntry( "SSL",false ); | 164 | ssl = conf->readBoolEntry( "SSL",false ); |
155 | user = conf->readEntry( "User","" ); | 165 | user = conf->readEntry( "User","" ); |
156 | if (user.isNull()) user = ""; | 166 | if (user.isNull()) user = ""; |
157 | password = conf->readEntryCrypt( "Password","" ); | 167 | password = conf->readEntryCrypt( "Password","" ); |
158 | if (password.isNull()) password = ""; | 168 | if (password.isNull()) password = ""; |
159 | prefix = conf->readEntry("MailPrefix",""); | 169 | prefix = conf->readEntry("MailPrefix",""); |
160 | if (prefix.isNull()) prefix = ""; | 170 | if (prefix.isNull()) prefix = ""; |
161 | } | 171 | } |
162 | 172 | ||
163 | void IMAPaccount::save() | 173 | void IMAPaccount::save() |
164 | { | 174 | { |
165 | qDebug( "saving " + getFileName() ); | 175 | qDebug( "saving " + getFileName() ); |
166 | Settings::checkDirectory(); | 176 | Settings::checkDirectory(); |
167 | 177 | ||
168 | Config *conf = new Config( getFileName(), Config::File ); | 178 | Config *conf = new Config( getFileName(), Config::File ); |
169 | conf->setGroup( "IMAP Account" ); | 179 | conf->setGroup( "IMAP Account" ); |
170 | conf->writeEntry( "Account", accountName ); | 180 | conf->writeEntry( "Account", accountName ); |
171 | conf->writeEntry( "Server", server ); | 181 | conf->writeEntry( "Server", server ); |
172 | conf->writeEntry( "Port", port ); | 182 | conf->writeEntry( "Port", port ); |
173 | conf->writeEntry( "SSL", ssl ); | 183 | conf->writeEntry( "SSL", ssl ); |
174 | conf->writeEntry( "User", user ); | 184 | conf->writeEntry( "User", user ); |
175 | conf->writeEntryCrypt( "Password", password ); | 185 | conf->writeEntryCrypt( "Password", password ); |
176 | conf->writeEntry( "MailPrefix",prefix); | 186 | conf->writeEntry( "MailPrefix",prefix); |
177 | conf->write(); | 187 | conf->write(); |
178 | } | 188 | } |
179 | 189 | ||
180 | 190 | ||
181 | QString IMAPaccount::getFileName() | 191 | QString IMAPaccount::getFileName() |
182 | { | 192 | { |
183 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 193 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
184 | } | 194 | } |
185 | 195 | ||
186 | POP3account::POP3account() | 196 | POP3account::POP3account() |
187 | : Account() | 197 | : Account() |
188 | { | 198 | { |
189 | file = POP3account::getUniqueFileName(); | 199 | file = POP3account::getUniqueFileName(); |
190 | accountName = "New POP3 Account"; | 200 | accountName = "New POP3 Account"; |
191 | ssl = false; | 201 | ssl = false; |
192 | type = "POP3"; | 202 | type = "POP3"; |
193 | port = POP3_PORT; | 203 | port = POP3_PORT; |
194 | } | 204 | } |
195 | 205 | ||
196 | POP3account::POP3account( QString filename ) | 206 | POP3account::POP3account( QString filename ) |
197 | : Account() | 207 | : Account() |
198 | { | 208 | { |
199 | file = filename; | 209 | file = filename; |
200 | accountName = "New POP3 Account"; | 210 | accountName = "New POP3 Account"; |
201 | ssl = false; | 211 | ssl = false; |
202 | type = "POP3"; | 212 | type = "POP3"; |
203 | port = POP3_PORT; | 213 | port = POP3_PORT; |
204 | } | 214 | } |
205 | 215 | ||
206 | QString POP3account::getUniqueFileName() | 216 | QString POP3account::getUniqueFileName() |
207 | { | 217 | { |
208 | int num = 0; | 218 | int num = 0; |
209 | QString unique; | 219 | QString unique; |
210 | 220 | ||
211 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 221 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
212 | 222 | ||
213 | QStringList imap = dir.entryList( "pop3-*" ); | 223 | QStringList imap = dir.entryList( "pop3-*" ); |
214 | do { | 224 | do { |
215 | unique.setNum( num++ ); | 225 | unique.setNum( num++ ); |
216 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 226 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
217 | 227 | ||
218 | return unique; | 228 | return unique; |
219 | } | 229 | } |
220 | 230 | ||
221 | void POP3account::read() | 231 | void POP3account::read() |
222 | { | 232 | { |
223 | Config *conf = new Config( getFileName(), Config::File ); | 233 | Config *conf = new Config( getFileName(), Config::File ); |
224 | conf->setGroup( "POP3 Account" ); | 234 | conf->setGroup( "POP3 Account" ); |
225 | accountName = conf->readEntry( "Account" ); | 235 | accountName = conf->readEntry( "Account" ); |
226 | server = conf->readEntry( "Server" ); | 236 | server = conf->readEntry( "Server" ); |
227 | port = conf->readEntry( "Port" ); | 237 | port = conf->readEntry( "Port" ); |
228 | ssl = conf->readBoolEntry( "SSL" ); | 238 | ssl = conf->readBoolEntry( "SSL" ); |
229 | user = conf->readEntry( "User" ); | 239 | user = conf->readEntry( "User" ); |
230 | password = conf->readEntryCrypt( "Password" ); | 240 | password = conf->readEntryCrypt( "Password" ); |
231 | } | 241 | } |
232 | 242 | ||
233 | void POP3account::save() | 243 | void POP3account::save() |
234 | { | 244 | { |
235 | qDebug( "saving " + getFileName() ); | 245 | qDebug( "saving " + getFileName() ); |
236 | Settings::checkDirectory(); | 246 | Settings::checkDirectory(); |
237 | 247 | ||
238 | Config *conf = new Config( getFileName(), Config::File ); | 248 | Config *conf = new Config( getFileName(), Config::File ); |
239 | conf->setGroup( "POP3 Account" ); | 249 | conf->setGroup( "POP3 Account" ); |
240 | conf->writeEntry( "Account", accountName ); | 250 | conf->writeEntry( "Account", accountName ); |
241 | conf->writeEntry( "Server", server ); | 251 | conf->writeEntry( "Server", server ); |
242 | conf->writeEntry( "Port", port ); | 252 | conf->writeEntry( "Port", port ); |
243 | conf->writeEntry( "SSL", ssl ); | 253 | conf->writeEntry( "SSL", ssl ); |
244 | conf->writeEntry( "User", user ); | 254 | conf->writeEntry( "User", user ); |
245 | conf->writeEntryCrypt( "Password", password ); | 255 | conf->writeEntryCrypt( "Password", password ); |
246 | conf->write(); | 256 | conf->write(); |
247 | } | 257 | } |
248 | 258 | ||
249 | 259 | ||
250 | QString POP3account::getFileName() | 260 | QString POP3account::getFileName() |
251 | { | 261 | { |
252 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 262 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
253 | } | 263 | } |
254 | 264 | ||
255 | SMTPaccount::SMTPaccount() | 265 | SMTPaccount::SMTPaccount() |
256 | : Account() | 266 | : Account() |
257 | { | 267 | { |
258 | file = SMTPaccount::getUniqueFileName(); | 268 | file = SMTPaccount::getUniqueFileName(); |
259 | accountName = "New SMTP Account"; | 269 | accountName = "New SMTP Account"; |
260 | ssl = false; | 270 | ssl = false; |
261 | login = false; | 271 | login = false; |
262 | useCC = false; | 272 | useCC = false; |
263 | useBCC = false; | 273 | useBCC = false; |
264 | useReply = false; | 274 | useReply = false; |
265 | type = "SMTP"; | 275 | type = "SMTP"; |
266 | port = SMTP_PORT; | 276 | port = SMTP_PORT; |
267 | } | 277 | } |
268 | 278 | ||
269 | SMTPaccount::SMTPaccount( QString filename ) | 279 | SMTPaccount::SMTPaccount( QString filename ) |
270 | : Account() | 280 | : Account() |
271 | { | 281 | { |
272 | file = filename; | 282 | file = filename; |
273 | accountName = "New SMTP Account"; | 283 | accountName = "New SMTP Account"; |
274 | ssl = false; | 284 | ssl = false; |
275 | login = false; | 285 | login = false; |
276 | type = "SMTP"; | 286 | type = "SMTP"; |
277 | port = SMTP_PORT; | 287 | port = SMTP_PORT; |
278 | } | 288 | } |
279 | 289 | ||
280 | QString SMTPaccount::getUniqueFileName() | 290 | QString SMTPaccount::getUniqueFileName() |
281 | { | 291 | { |
282 | int num = 0; | 292 | int num = 0; |
283 | QString unique; | 293 | QString unique; |
284 | 294 | ||
285 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 295 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
286 | 296 | ||
287 | QStringList imap = dir.entryList( "smtp-*" ); | 297 | QStringList imap = dir.entryList( "smtp-*" ); |
288 | do { | 298 | do { |
289 | unique.setNum( num++ ); | 299 | unique.setNum( num++ ); |
290 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 300 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
291 | 301 | ||
292 | return unique; | 302 | return unique; |
293 | } | 303 | } |
294 | 304 | ||
295 | void SMTPaccount::read() | 305 | void SMTPaccount::read() |
296 | { | 306 | { |
297 | Config *conf = new Config( getFileName(), Config::File ); | 307 | Config *conf = new Config( getFileName(), Config::File ); |
298 | conf->setGroup( "SMTP Account" ); | 308 | conf->setGroup( "SMTP Account" ); |
299 | accountName = conf->readEntry( "Account" ); | 309 | accountName = conf->readEntry( "Account" ); |
300 | server = conf->readEntry( "Server" ); | 310 | server = conf->readEntry( "Server" ); |
301 | port = conf->readEntry( "Port" ); | 311 | port = conf->readEntry( "Port" ); |
302 | ssl = conf->readBoolEntry( "SSL" ); | 312 | ssl = conf->readBoolEntry( "SSL" ); |
303 | login = conf->readBoolEntry( "Login" ); | 313 | login = conf->readBoolEntry( "Login" ); |
304 | user = conf->readEntry( "User" ); | 314 | user = conf->readEntry( "User" ); |
305 | password = conf->readEntryCrypt( "Password" ); | 315 | password = conf->readEntryCrypt( "Password" ); |
306 | } | 316 | } |
307 | 317 | ||
308 | void SMTPaccount::save() | 318 | void SMTPaccount::save() |
309 | { | 319 | { |
310 | qDebug( "saving " + getFileName() ); | 320 | qDebug( "saving " + getFileName() ); |
311 | Settings::checkDirectory(); | 321 | Settings::checkDirectory(); |
312 | 322 | ||
313 | Config *conf = new Config( getFileName(), Config::File ); | 323 | Config *conf = new Config( getFileName(), Config::File ); |
314 | conf->setGroup( "SMTP Account" ); | 324 | conf->setGroup( "SMTP Account" ); |
315 | conf->writeEntry( "Account", accountName ); | 325 | conf->writeEntry( "Account", accountName ); |
316 | conf->writeEntry( "Server", server ); | 326 | conf->writeEntry( "Server", server ); |
317 | conf->writeEntry( "Port", port ); | 327 | conf->writeEntry( "Port", port ); |
318 | conf->writeEntry( "SSL", ssl ); | 328 | conf->writeEntry( "SSL", ssl ); |
319 | conf->writeEntry( "Login", login ); | 329 | conf->writeEntry( "Login", login ); |
320 | conf->writeEntry( "User", user ); | 330 | conf->writeEntry( "User", user ); |
321 | conf->writeEntryCrypt( "Password", password ); | 331 | conf->writeEntryCrypt( "Password", password ); |
322 | conf->write(); | 332 | conf->write(); |
323 | } | 333 | } |
324 | 334 | ||
325 | 335 | ||
326 | QString SMTPaccount::getFileName() | 336 | QString SMTPaccount::getFileName() |
327 | { | 337 | { |
328 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; | 338 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; |
329 | } | 339 | } |
330 | 340 | ||
331 | NNTPaccount::NNTPaccount() | 341 | NNTPaccount::NNTPaccount() |
332 | : Account() | 342 | : Account() |
333 | { | 343 | { |
334 | file = NNTPaccount::getUniqueFileName(); | 344 | file = NNTPaccount::getUniqueFileName(); |
335 | accountName = "New NNTP Account"; | 345 | accountName = "New NNTP Account"; |
336 | ssl = false; | 346 | ssl = false; |
337 | login = false; | 347 | login = false; |
338 | type = "NNTP"; | 348 | type = "NNTP"; |
339 | port = NNTP_PORT; | 349 | port = NNTP_PORT; |
340 | } | 350 | } |
341 | 351 | ||
342 | NNTPaccount::NNTPaccount( QString filename ) | 352 | NNTPaccount::NNTPaccount( QString filename ) |
343 | : Account() | 353 | : Account() |
344 | { | 354 | { |
345 | file = filename; | 355 | file = filename; |
346 | accountName = "New NNTP Account"; | 356 | accountName = "New NNTP Account"; |
347 | ssl = false; | 357 | ssl = false; |
348 | login = false; | 358 | login = false; |
349 | type = "NNTP"; | 359 | type = "NNTP"; |
350 | port = NNTP_PORT; | 360 | port = NNTP_PORT; |
351 | } | 361 | } |
352 | 362 | ||
353 | QString NNTPaccount::getUniqueFileName() | 363 | QString NNTPaccount::getUniqueFileName() |
354 | { | 364 | { |
355 | int num = 0; | 365 | int num = 0; |
356 | QString unique; | 366 | QString unique; |
357 | 367 | ||
358 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 368 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
359 | 369 | ||
360 | QStringList imap = dir.entryList( "nntp-*" ); | 370 | QStringList imap = dir.entryList( "nntp-*" ); |
361 | do { | 371 | do { |
362 | unique.setNum( num++ ); | 372 | unique.setNum( num++ ); |
363 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 373 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
364 | 374 | ||
365 | return unique; | 375 | return unique; |
366 | } | 376 | } |
367 | 377 | ||
368 | void NNTPaccount::read() | 378 | void NNTPaccount::read() |
369 | { | 379 | { |
370 | Config *conf = new Config( getFileName(), Config::File ); | 380 | Config *conf = new Config( getFileName(), Config::File ); |
371 | conf->setGroup( "NNTP Account" ); | 381 | conf->setGroup( "NNTP Account" ); |
372 | accountName = conf->readEntry( "Account" ); | 382 | accountName = conf->readEntry( "Account" ); |
373 | server = conf->readEntry( "Server" ); | 383 | server = conf->readEntry( "Server" ); |
374 | port = conf->readEntry( "Port" ); | 384 | port = conf->readEntry( "Port" ); |
375 | ssl = conf->readBoolEntry( "SSL" ); | 385 | ssl = conf->readBoolEntry( "SSL" ); |
376 | login = conf->readBoolEntry( "Login" ); | 386 | login = conf->readBoolEntry( "Login" ); |
377 | user = conf->readEntry( "User" ); | 387 | user = conf->readEntry( "User" ); |
378 | password = conf->readEntryCrypt( "Password" ); | 388 | password = conf->readEntryCrypt( "Password" ); |
379 | } | 389 | } |
380 | 390 | ||
381 | void NNTPaccount::save() | 391 | void NNTPaccount::save() |
382 | { | 392 | { |
383 | qDebug( "saving " + getFileName() ); | 393 | qDebug( "saving " + getFileName() ); |
384 | Settings::checkDirectory(); | 394 | Settings::checkDirectory(); |
385 | 395 | ||
386 | Config *conf = new Config( getFileName(), Config::File ); | 396 | Config *conf = new Config( getFileName(), Config::File ); |
387 | conf->setGroup( "NNTP Account" ); | 397 | conf->setGroup( "NNTP Account" ); |
388 | conf->writeEntry( "Account", accountName ); | 398 | conf->writeEntry( "Account", accountName ); |
389 | conf->writeEntry( "Server", server ); | 399 | conf->writeEntry( "Server", server ); |
390 | conf->writeEntry( "Port", port ); | 400 | conf->writeEntry( "Port", port ); |
391 | conf->writeEntry( "SSL", ssl ); | 401 | conf->writeEntry( "SSL", ssl ); |
392 | conf->writeEntry( "Login", login ); | 402 | conf->writeEntry( "Login", login ); |
393 | conf->writeEntry( "User", user ); | 403 | conf->writeEntry( "User", user ); |
394 | conf->writeEntryCrypt( "Password", password ); | 404 | conf->writeEntryCrypt( "Password", password ); |
395 | conf->write(); | 405 | conf->write(); |
396 | } | 406 | } |
397 | 407 | ||
398 | 408 | ||
399 | QString NNTPaccount::getFileName() | 409 | QString NNTPaccount::getFileName() |
400 | { | 410 | { |
401 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; | 411 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; |
402 | } | 412 | } |
403 | 413 | ||
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 7e03af9..b9c4ff2 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,70 +1,72 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qt.h> | 8 | #include <qt.h> |
9 | 9 | ||
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | #include <qpe/qcopenvelope_qws.h> | 11 | #include <qpe/qcopenvelope_qws.h> |
12 | 12 | ||
13 | #include <libetpan/libetpan.h> | 13 | #include <libetpan/libetpan.h> |
14 | 14 | ||
15 | #include "smtpwrapper.h" | 15 | #include "smtpwrapper.h" |
16 | #include "mailwrapper.h" | 16 | #include "mailwrapper.h" |
17 | #include "mboxwrapper.h" | 17 | #include "mboxwrapper.h" |
18 | #include "logindialog.h" | 18 | #include "logindialog.h" |
19 | #include "mailtypes.h" | 19 | #include "mailtypes.h" |
20 | #include "defines.h" | 20 | //#include "defines.h" |
21 | #include "sendmailprogress.h" | 21 | #include "sendmailprogress.h" |
22 | 22 | ||
23 | #define USER_AGENT "OpieMail v0.1" | ||
24 | |||
23 | progressMailSend*SMTPwrapper::sendProgress = 0; | 25 | progressMailSend*SMTPwrapper::sendProgress = 0; |
24 | 26 | ||
25 | SMTPwrapper::SMTPwrapper( Settings *s ) | 27 | SMTPwrapper::SMTPwrapper( Settings *s ) |
26 | : QObject() | 28 | : QObject() |
27 | { | 29 | { |
28 | settings = s; | 30 | settings = s; |
29 | Config cfg( "mail" ); | 31 | Config cfg( "mail" ); |
30 | cfg.setGroup( "Status" ); | 32 | cfg.setGroup( "Status" ); |
31 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 33 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
32 | emit queuedMails( m_queuedMail ); | 34 | emit queuedMails( m_queuedMail ); |
33 | connect( this, SIGNAL( queuedMails( int ) ), this, SLOT( emitQCop( int ) ) ); | 35 | connect( this, SIGNAL( queuedMails( int ) ), this, SLOT( emitQCop( int ) ) ); |
34 | } | 36 | } |
35 | 37 | ||
36 | void SMTPwrapper::emitQCop( int queued ) { | 38 | void SMTPwrapper::emitQCop( int queued ) { |
37 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 39 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
38 | env << queued; | 40 | env << queued; |
39 | } | 41 | } |
40 | 42 | ||
41 | QString SMTPwrapper::mailsmtpError( int errnum ) | 43 | QString SMTPwrapper::mailsmtpError( int errnum ) |
42 | { | 44 | { |
43 | switch ( errnum ) { | 45 | switch ( errnum ) { |
44 | case MAILSMTP_NO_ERROR: | 46 | case MAILSMTP_NO_ERROR: |
45 | return tr( "No error" ); | 47 | return tr( "No error" ); |
46 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 48 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
47 | return tr( "Unexpected error code" ); | 49 | return tr( "Unexpected error code" ); |
48 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 50 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
49 | return tr( "Service not available" ); | 51 | return tr( "Service not available" ); |
50 | case MAILSMTP_ERROR_STREAM: | 52 | case MAILSMTP_ERROR_STREAM: |
51 | return tr( "Stream error" ); | 53 | return tr( "Stream error" ); |
52 | case MAILSMTP_ERROR_HOSTNAME: | 54 | case MAILSMTP_ERROR_HOSTNAME: |
53 | return tr( "gethostname() failed" ); | 55 | return tr( "gethostname() failed" ); |
54 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 56 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
55 | return tr( "Not implemented" ); | 57 | return tr( "Not implemented" ); |
56 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 58 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
57 | return tr( "Error, action not taken" ); | 59 | return tr( "Error, action not taken" ); |
58 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 60 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
59 | return tr( "Data exceeds storage allocation" ); | 61 | return tr( "Data exceeds storage allocation" ); |
60 | case MAILSMTP_ERROR_IN_PROCESSING: | 62 | case MAILSMTP_ERROR_IN_PROCESSING: |
61 | return tr( "Error in processing" ); | 63 | return tr( "Error in processing" ); |
62 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 64 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
63 | // return tr( "Insufficient system storage" ); | 65 | // return tr( "Insufficient system storage" ); |
64 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 66 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
65 | return tr( "Mailbox unavailable" ); | 67 | return tr( "Mailbox unavailable" ); |
66 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 68 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
67 | return tr( "Mailbox name not allowed" ); | 69 | return tr( "Mailbox name not allowed" ); |
68 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 70 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
69 | return tr( "Bad command sequence" ); | 71 | return tr( "Bad command sequence" ); |
70 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 72 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |