Diffstat (limited to 'noncore/unsupported/mailit/emailhandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 06e978d..02b3e9a 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfileinfo.h> | 20 | #include <qfileinfo.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include "emailhandler.h" | 25 | #include "emailhandler.h" |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
28 | 28 | ||
29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) | 29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (Enclosure *) d); | 31 | return dupl( (Enclosure *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | Enclosure* EnclosureList::dupl(Enclosure *in) | 34 | Enclosure* EnclosureList::dupl(Enclosure *in) |
35 | { | 35 | { |
36 | ac = new Enclosure(*in); | 36 | ac = new Enclosure(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::EmailHandler() |
41 | { | 41 | { |
42 | qDebug("EMailHandler::EmailHandler"); | 42 | qDebug("EMailHandler::EmailHandler"); |
43 | 43 | ||
44 | smtpClient = new SmtpClient(); | 44 | smtpClient = new SmtpClient(); |
45 | popClient = new PopClient(); | 45 | popClient = new PopClient(); |
46 | 46 | ||
47 | connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this, | 47 | connect(smtpClient, SIGNAL(errorOccurred(int,const QString&)), this, |
48 | SIGNAL(smtpError(int, const QString &)) ); | 48 | SIGNAL(smtpError(int,const QString&)) ); |
49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
50 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 50 | connect(smtpClient, SIGNAL(updateStatus(const QString&)), this, |
51 | SIGNAL(updateSmtpStatus(const QString &)) ); | 51 | SIGNAL(updateSmtpStatus(const QString&)) ); |
52 | 52 | ||
53 | connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this, | 53 | connect(popClient, SIGNAL(errorOccurred(int,const QString&)), this, |
54 | SIGNAL(popError(int, const QString &)) ); | 54 | SIGNAL(popError(int,const QString&)) ); |
55 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 55 | connect(popClient, SIGNAL(newMessage(const QString&,int,uint,bool)), |
56 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 56 | this, SLOT(messageArrived(const QString&,int,uint,bool)) ); |
57 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 57 | connect(popClient, SIGNAL(updateStatus(const QString&)), this, |
58 | SIGNAL(updatePopStatus(const QString &)) ); | 58 | SIGNAL(updatePopStatus(const QString&)) ); |
59 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 59 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
60 | SIGNAL(mailTransfered(int)) ); | 60 | SIGNAL(mailTransfered(int)) ); |
61 | 61 | ||
62 | 62 | ||
63 | //relaying size information | 63 | //relaying size information |
64 | connect(popClient, SIGNAL(currentMailSize(int)), | 64 | connect(popClient, SIGNAL(currentMailSize(int)), |
65 | this, SIGNAL(currentMailSize(int)) ); | 65 | this, SIGNAL(currentMailSize(int)) ); |
66 | connect(popClient, SIGNAL(downloadedSize(int)), | 66 | connect(popClient, SIGNAL(downloadedSize(int)), |
67 | this, SIGNAL(downloadedSize(int)) ); | 67 | this, SIGNAL(downloadedSize(int)) ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void EmailHandler::sendMail(QList<Email> *mailList) | 70 | void EmailHandler::sendMail(QList<Email> *mailList) |
71 | { | 71 | { |
72 | Email *currentMail; | 72 | Email *currentMail; |
73 | QString temp; | 73 | QString temp; |
74 | QString userName = QString::null; | 74 | QString userName = QString::null; |
75 | // not supported by ALL SMTP servers in the MAIL From field | 75 | // not supported by ALL SMTP servers in the MAIL From field |
76 | // userName = "\""+mailAccount.name+"\""; | 76 | // userName = "\""+mailAccount.name+"\""; |
77 | userName += "<" + mailAccount.emailAddress + ">"; | 77 | userName += "<" + mailAccount.emailAddress + ">"; |
78 | 78 | ||
79 | for (currentMail = mailList->first(); currentMail != 0; | 79 | for (currentMail = mailList->first(); currentMail != 0; |
80 | currentMail = mailList->next()) { | 80 | currentMail = mailList->next()) { |
81 | 81 | ||
82 | if (encodeMime(currentMail) == 0) { | 82 | if (encodeMime(currentMail) == 0) { |
83 | smtpClient->addMail(userName, currentMail->subject, | 83 | smtpClient->addMail(userName, currentMail->subject, |
84 | currentMail->recipients, currentMail->rawMail); | 84 | currentMail->recipients, currentMail->rawMail); |
85 | } else { //error | 85 | } else { //error |
86 | temp = tr("Could not locate all files in \nmail with subject: ") + | 86 | temp = tr("Could not locate all files in \nmail with subject: ") + |
87 | currentMail->subject; | 87 | currentMail->subject; |
88 | temp += tr("\nMail has NOT been sent"); | 88 | temp += tr("\nMail has NOT been sent"); |
89 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 89 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
90 | 90 | ||
91 | } | 91 | } |
92 | } | 92 | } |
93 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 93 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
94 | } | 94 | } |
95 | 95 | ||
96 | void EmailHandler::setAccount(MailAccount account) | 96 | void EmailHandler::setAccount(MailAccount account) |
97 | { | 97 | { |
98 | mailAccount = account; | 98 | mailAccount = account; |
99 | } | 99 | } |
100 | 100 | ||
101 | void EmailHandler::getMail() | 101 | void EmailHandler::getMail() |
102 | { | 102 | { |
103 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 103 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
104 | if (mailAccount.synchronize) { | 104 | if (mailAccount.synchronize) { |
105 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 105 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
106 | } else { | 106 | } else { |
107 | popClient->removeSynchronize(); | 107 | popClient->removeSynchronize(); |
108 | } | 108 | } |
109 | 109 | ||
110 | headers = FALSE; | 110 | headers = FALSE; |
111 | //popClient->headersOnly(headers, 0); | 111 | //popClient->headersOnly(headers, 0); |
112 | popClient->newConnection(mailAccount.popServer, 110); | 112 | popClient->newConnection(mailAccount.popServer, 110); |
113 | } | 113 | } |
114 | 114 | ||
115 | void EmailHandler::getMailHeaders() | 115 | void EmailHandler::getMailHeaders() |
116 | { | 116 | { |
117 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 117 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
118 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); | 118 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | qDebug("Initiating connection"); | 122 | qDebug("Initiating connection"); |
123 | popClient->newConnection(mailAccount.popServer, 110); | 123 | popClient->newConnection(mailAccount.popServer, 110); |
124 | } | 124 | } |
125 | 125 | ||
126 | void EmailHandler::getMailByList(MailList *mailList) | 126 | void EmailHandler::getMailByList(MailList *mailList) |
127 | { | 127 | { |
128 | if (mailList->count() == 0) { //should not occur though | 128 | if (mailList->count() == 0) { //should not occur though |
129 | emit mailTransfered(0); | 129 | emit mailTransfered(0); |
130 | return; | 130 | return; |
131 | } | 131 | } |
132 | 132 | ||
133 | headers = FALSE; | 133 | headers = FALSE; |
134 | popClient->headersOnly(FALSE, 0); | 134 | popClient->headersOnly(FALSE, 0); |
135 | 135 | ||
136 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); | 136 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); |
137 | popClient->setSelectedMails(mailList); | 137 | popClient->setSelectedMails(mailList); |
138 | popClient->newConnection(mailAccount.popServer, 110); | 138 | popClient->newConnection(mailAccount.popServer, 110); |
139 | } | 139 | } |
140 | 140 | ||
141 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 141 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
142 | { | 142 | { |
143 | Email mail; | 143 | Email mail; |
144 | 144 | ||
145 | mail.rawMail = message; | 145 | mail.rawMail = message; |
146 | mail.serverId = id; | 146 | mail.serverId = id; |
147 | mail.size = size; | 147 | mail.size = size; |
148 | mail.downloaded = complete; | 148 | mail.downloaded = complete; |
149 | 149 | ||
150 | emit mailArrived(mail, FALSE); | 150 | emit mailArrived(mail, FALSE); |
151 | } | 151 | } |
152 | 152 | ||
153 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) | 153 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) |
154 | { | 154 | { |