author | groucho <groucho> | 2003-04-07 07:35:39 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-04-07 07:35:39 (UTC) |
commit | 1725b536c8a5a939a481196cce1dc35af2d9a63a (patch) (unidiff) | |
tree | 1e4c80853f2b484dd4193827225eafc1bd632330 | |
parent | 4c0390976930423c4e05394563564ab00faf8009 (diff) | |
download | opie-1725b536c8a5a939a481196cce1dc35af2d9a63a.zip opie-1725b536c8a5a939a481196cce1dc35af2d9a63a.tar.gz opie-1725b536c8a5a939a481196cce1dc35af2d9a63a.tar.bz2 |
Better look, crystal icons and path corrections
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.h | 4 | ||||
-rw-r--r-- | noncore/net/mailit/mailit.pro | 2 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.h | 4 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailit.pro | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.cpp | 6 |
8 files changed, 20 insertions, 20 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 2e82623..fc4276b 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -1,858 +1,858 @@ | |||
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 <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include "resource.h" | 26 | #include "resource.h" |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | 28 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 29 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (MailAccount *) d); | 31 | return dupl( (MailAccount *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 34 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 35 | { |
36 | ac = new MailAccount(*in); | 36 | ac = new MailAccount(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 41 | : QMainWindow( parent, name, fl ) |
42 | { | 42 | { |
43 | emailHandler = new EmailHandler(); | 43 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList( getPath(FALSE) + "mail_adr"); | 44 | addressList = new AddressList( getPath(FALSE) + "mail_adr"); |
45 | 45 | ||
46 | sending = FALSE; | 46 | sending = FALSE; |
47 | receiving = FALSE; | 47 | receiving = FALSE; |
48 | previewingMail = FALSE; | 48 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 49 | mailIdCount = 1; |
50 | accountIdCount = 1; | 50 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 51 | allAccounts = FALSE; |
52 | 52 | ||
53 | init(); | 53 | init(); |
54 | 54 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 56 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 57 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 58 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 59 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 60 | SLOT(popError(int)) ); |
61 | 61 | ||
62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | 64 | ||
65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
66 | SLOT(mailArrived(const Email &, bool)) ); | 66 | SLOT(mailArrived(const Email &, bool)) ); |
67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
68 | SLOT(allMailArrived(int)) ); | 68 | SLOT(allMailArrived(int)) ); |
69 | 69 | ||
70 | mailconf = new Config("mailit"); | 70 | mailconf = new Config("mailit"); |
71 | //In case Synchronize is not defined in settings.txt | 71 | //In case Synchronize is not defined in settings.txt |
72 | 72 | ||
73 | readSettings(); | 73 | readSettings(); |
74 | 74 | ||
75 | updateAccounts(); | 75 | updateAccounts(); |
76 | 76 | ||
77 | lineShift = "\n"; | 77 | lineShift = "\n"; |
78 | readMail(); | 78 | readMail(); |
79 | lineShift = "\r\n"; | 79 | lineShift = "\r\n"; |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | EmailClient::~EmailClient() | 84 | EmailClient::~EmailClient() |
85 | { | 85 | { |
86 | //needs to be moved from destructor to closewindow event | 86 | //needs to be moved from destructor to closewindow event |
87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
88 | //does not currently work. Defining outbox in the same | 88 | //does not currently work. Defining outbox in the same |
89 | //format as inbox is not a good solution as they have | 89 | //format as inbox is not a good solution as they have |
90 | //different properties | 90 | //different properties |
91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
92 | saveSettings(); | 92 | saveSettings(); |
93 | 93 | ||
94 | mailconf->write(); | 94 | mailconf->write(); |
95 | delete mailconf; | 95 | delete mailconf; |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void EmailClient::init() | 99 | void EmailClient::init() |
100 | { | 100 | { |
101 | statusBar = new QStatusBar(this); | 101 | statusBar = new QStatusBar(this); |
102 | statusBar->setSizeGripEnabled(FALSE); | 102 | statusBar->setSizeGripEnabled(FALSE); |
103 | 103 | ||
104 | status1Label = new QLabel( tr("Idle"), statusBar); | 104 | status1Label = new QLabel( tr("Idle"), statusBar); |
105 | status2Label = new QLabel("", statusBar); | 105 | status2Label = new QLabel("", statusBar); |
106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
107 | status2Label, SLOT(setText(const QString &)) ); | 107 | status2Label, SLOT(setText(const QString &)) ); |
108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
109 | status2Label, SLOT(setText(const QString &)) ); | 109 | status2Label, SLOT(setText(const QString &)) ); |
110 | 110 | ||
111 | progressBar = new QProgressBar(statusBar); | 111 | progressBar = new QProgressBar(statusBar); |
112 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 112 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
113 | this, SLOT(setTotalSize(int)) ); | 113 | this, SLOT(setTotalSize(int)) ); |
114 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 114 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
115 | this, SLOT(setMailSize(int)) ); | 115 | this, SLOT(setMailSize(int)) ); |
116 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 116 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
117 | this, SLOT(setDownloadedSize(int)) ); | 117 | this, SLOT(setDownloadedSize(int)) ); |
118 | 118 | ||
119 | statusBar->addWidget(status1Label); | 119 | statusBar->addWidget(status1Label); |
120 | statusBar->addWidget(progressBar); | 120 | statusBar->addWidget(progressBar); |
121 | statusBar->addWidget(status2Label); | 121 | statusBar->addWidget(status2Label); |
122 | 122 | ||
123 | setToolBarsMovable(FALSE); | 123 | setToolBarsMovable(FALSE); |
124 | 124 | ||
125 | bar = new QToolBar(this); | 125 | bar = new QToolBar(this); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | mb = new QMenuBar( bar ); | 128 | mb = new QMenuBar( bar ); |
129 | 129 | ||
130 | QPopupMenu *mail = new QPopupMenu(mb); | 130 | QPopupMenu *mail = new QPopupMenu(mb); |
131 | mb->insertItem( tr( "&Mail" ), mail); | 131 | mb->insertItem( tr( "&Mail" ), mail); |
132 | 132 | ||
133 | QPopupMenu *configure = new QPopupMenu(mb); | 133 | QPopupMenu *configure = new QPopupMenu(mb); |
134 | mb->insertItem( tr( "Accounts" ), configure); | 134 | mb->insertItem( tr( "Accounts" ), configure); |
135 | 135 | ||
136 | selectAccountMenu = new QPopupMenu(mb); | 136 | selectAccountMenu = new QPopupMenu(mb); |
137 | editAccountMenu = new QPopupMenu(mb); | 137 | editAccountMenu = new QPopupMenu(mb); |
138 | deleteAccountMenu = new QPopupMenu(mb); | 138 | deleteAccountMenu = new QPopupMenu(mb); |
139 | 139 | ||
140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
141 | configure->insertItem(tr("Edit account"), editAccountMenu); | 141 | configure->insertItem(tr("Edit account"), editAccountMenu); |
142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
143 | 143 | ||
144 | bar = new QToolBar(this); | 144 | bar = new QToolBar(this); |
145 | 145 | ||
146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | 146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); |
147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | 147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); |
148 | getMailButton->addTo(bar); | 148 | getMailButton->addTo(bar); |
149 | getMailButton->addTo(mail); | 149 | getMailButton->addTo(mail); |
150 | 150 | ||
151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); | 151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); |
152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
153 | sendMailButton->addTo(bar); | 153 | sendMailButton->addTo(bar); |
154 | sendMailButton->addTo(mail); | 154 | sendMailButton->addTo(mail); |
155 | 155 | ||
156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
158 | composeButton->addTo(bar); | 158 | composeButton->addTo(bar); |
159 | composeButton->addTo(mail); | 159 | composeButton->addTo(mail); |
160 | 160 | ||
161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("reset"), QString::null, 0, this, 0); | 161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
163 | cancelButton->addTo(mail); | 163 | cancelButton->addTo(mail); |
164 | cancelButton->setEnabled(FALSE); | 164 | cancelButton->setEnabled(FALSE); |
165 | 165 | ||
166 | mailboxView = new QTabWidget( this, "mailboxView" ); | 166 | mailboxView = new OTabWidget( this, "mailboxView" ); |
167 | 167 | ||
168 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 168 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
169 | grid_2 = new QGridLayout( widget ); | 169 | grid_2 = new QGridLayout( widget ); |
170 | // grid_2->setSpacing(6); | 170 | // grid_2->setSpacing(6); |
171 | // grid_2->setMargin( 11 ); | 171 | // grid_2->setMargin( 11 ); |
172 | 172 | ||
173 | inboxView = new QListView( widget, "inboxView" ); | 173 | inboxView = new QListView( widget, "inboxView" ); |
174 | inboxView->addColumn( tr( "From" ) ); | 174 | inboxView->addColumn( tr( "From" ) ); |
175 | inboxView->addColumn( tr( "Subject" ) ); | 175 | inboxView->addColumn( tr( "Subject" ) ); |
176 | inboxView->addColumn( tr( "Date" ) ); | 176 | inboxView->addColumn( tr( "Date" ) ); |
177 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 177 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
178 | inboxView->setAllColumnsShowFocus(TRUE); | 178 | inboxView->setAllColumnsShowFocus(TRUE); |
179 | 179 | ||
180 | grid_2->addWidget( inboxView, 2, 0 ); | 180 | grid_2->addWidget( inboxView, 2, 0 ); |
181 | mailboxView->insertTab( widget, tr( "Inbox" ) ); | 181 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
182 | 182 | ||
183 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 183 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
184 | grid_3 = new QGridLayout( widget_2 ); | 184 | grid_3 = new QGridLayout( widget_2 ); |
185 | // grid_3->setSpacing(6); | 185 | // grid_3->setSpacing(6); |
186 | // grid_3->setMargin( 11 ); | 186 | // grid_3->setMargin( 11 ); |
187 | 187 | ||
188 | outboxView = new QListView( widget_2, "outboxView" ); | 188 | outboxView = new QListView( widget_2, "outboxView" ); |
189 | outboxView->addColumn( tr( "To" ) ); | 189 | outboxView->addColumn( tr( "To" ) ); |
190 | outboxView->addColumn( tr( "Subject" ) ); | 190 | outboxView->addColumn( tr( "Subject" ) ); |
191 | outboxView->setAllColumnsShowFocus(TRUE); | 191 | outboxView->setAllColumnsShowFocus(TRUE); |
192 | 192 | ||
193 | grid_3->addWidget( outboxView, 0, 0 ); | 193 | grid_3->addWidget( outboxView, 0, 0 ); |
194 | mailboxView->insertTab( widget_2, tr( "Outbox" ) ); | 194 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
195 | 195 | ||
196 | setCentralWidget(mailboxView); | 196 | setCentralWidget(mailboxView); |
197 | } | 197 | } |
198 | 198 | ||
199 | void EmailClient::compose() | 199 | void EmailClient::compose() |
200 | { | 200 | { |
201 | emit composeRequested(); | 201 | emit composeRequested(); |
202 | } | 202 | } |
203 | 203 | ||
204 | void EmailClient::cancel() | 204 | void EmailClient::cancel() |
205 | { | 205 | { |
206 | emailHandler->cancel(); | 206 | emailHandler->cancel(); |
207 | } | 207 | } |
208 | 208 | ||
209 | AddressList* EmailClient::getAdrListRef() | 209 | AddressList* EmailClient::getAdrListRef() |
210 | { | 210 | { |
211 | return addressList; | 211 | return addressList; |
212 | } | 212 | } |
213 | 213 | ||
214 | //this needs to be rewritten to syncronize with outboxView | 214 | //this needs to be rewritten to syncronize with outboxView |
215 | void EmailClient::enqueMail(const Email &mail) | 215 | void EmailClient::enqueMail(const Email &mail) |
216 | { | 216 | { |
217 | if (accountList.count() > 0) { | 217 | if (accountList.count() > 0) { |
218 | currentAccount = accountList.first(); | 218 | currentAccount = accountList.first(); |
219 | qWarning("using account " + currentAccount->name); | 219 | qWarning("using account " + currentAccount->name); |
220 | } | 220 | } |
221 | 221 | ||
222 | Email addMail = mail; | 222 | Email addMail = mail; |
223 | addMail.from = currentAccount->name; | 223 | addMail.from = currentAccount->name; |
224 | addMail.fromMail = currentAccount->emailAddress; | 224 | addMail.fromMail = currentAccount->emailAddress; |
225 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 225 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
226 | item = new EmailListItem(outboxView, addMail, false); | 226 | item = new EmailListItem(outboxView, addMail, false); |
227 | 227 | ||
228 | } | 228 | } |
229 | 229 | ||
230 | void EmailClient::sendQuedMail() | 230 | void EmailClient::sendQuedMail() |
231 | { | 231 | { |
232 | int count = 0; | 232 | int count = 0; |
233 | 233 | ||
234 | if (accountList.count() == 0) { | 234 | if (accountList.count() == 0) { |
235 | QMessageBox::warning(qApp->activeWindow(), | 235 | QMessageBox::warning(qApp->activeWindow(), |
236 | "No account selected", "You must create an account", "OK\n"); | 236 | "No account selected", "You must create an account", "OK\n"); |
237 | return; | 237 | return; |
238 | } | 238 | } |
239 | //traverse listview, find messages to send | 239 | //traverse listview, find messages to send |
240 | if (! sending) { | 240 | if (! sending) { |
241 | item = (EmailListItem *) outboxView->firstChild(); | 241 | item = (EmailListItem *) outboxView->firstChild(); |
242 | if (item != NULL) { | 242 | if (item != NULL) { |
243 | while (item != NULL) { | 243 | while (item != NULL) { |
244 | quedMessages.append(item->getMail()); | 244 | quedMessages.append(item->getMail()); |
245 | item = (EmailListItem *) item->nextSibling(); | 245 | item = (EmailListItem *) item->nextSibling(); |
246 | count++; | 246 | count++; |
247 | } | 247 | } |
248 | setMailAccount(); | 248 | setMailAccount(); |
249 | emailHandler->sendMail(&quedMessages); | 249 | emailHandler->sendMail(&quedMessages); |
250 | sending = TRUE; | 250 | sending = TRUE; |
251 | sendMailButton->setEnabled(FALSE); | 251 | sendMailButton->setEnabled(FALSE); |
252 | cancelButton->setEnabled(TRUE); | 252 | cancelButton->setEnabled(TRUE); |
253 | } else { | 253 | } else { |
254 | qWarning("sendQuedMail(): no messages to send"); | 254 | qWarning("sendQuedMail(): no messages to send"); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | void EmailClient::setMailAccount() | 259 | void EmailClient::setMailAccount() |
260 | { | 260 | { |
261 | emailHandler->setAccount(*currentAccount); | 261 | emailHandler->setAccount(*currentAccount); |
262 | } | 262 | } |
263 | 263 | ||
264 | void EmailClient::mailSent() | 264 | void EmailClient::mailSent() |
265 | { | 265 | { |
266 | sending = FALSE; | 266 | sending = FALSE; |
267 | sendMailButton->setEnabled(TRUE); | 267 | sendMailButton->setEnabled(TRUE); |
268 | 268 | ||
269 | quedMessages.clear(); | 269 | quedMessages.clear(); |
270 | outboxView->clear(); //should be moved to an sentBox | 270 | outboxView->clear(); //should be moved to an sentBox |
271 | } | 271 | } |
272 | 272 | ||
273 | void EmailClient::getNewMail() { | 273 | void EmailClient::getNewMail() { |
274 | 274 | ||
275 | if (accountList.count() == 0) { | 275 | if (accountList.count() == 0) { |
276 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 276 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
277 | "You must create an account", "OK\n"); | 277 | "You must create an account", "OK\n"); |
278 | return; | 278 | return; |
279 | } | 279 | } |
280 | 280 | ||
281 | setMailAccount(); | 281 | setMailAccount(); |
282 | 282 | ||
283 | receiving = TRUE; | 283 | receiving = TRUE; |
284 | previewingMail = TRUE; | 284 | previewingMail = TRUE; |
285 | getMailButton->setEnabled(FALSE); | 285 | getMailButton->setEnabled(FALSE); |
286 | cancelButton->setEnabled(TRUE); | 286 | cancelButton->setEnabled(TRUE); |
287 | selectAccountMenu->setEnabled(FALSE); | 287 | selectAccountMenu->setEnabled(FALSE); |
288 | 288 | ||
289 | status1Label->setText(currentAccount->accountName + " headers"); | 289 | status1Label->setText(currentAccount->accountName + " headers"); |
290 | progressBar->reset(); | 290 | progressBar->reset(); |
291 | 291 | ||
292 | //get any previous mails not downloaded and add to queue | 292 | //get any previous mails not downloaded and add to queue |
293 | mailDownloadList.clear(); | 293 | mailDownloadList.clear(); |
294 | Email *mailPtr; | 294 | Email *mailPtr; |
295 | item = (EmailListItem *) inboxView->firstChild(); | 295 | item = (EmailListItem *) inboxView->firstChild(); |
296 | while (item != NULL) { | 296 | while (item != NULL) { |
297 | mailPtr = item->getMail(); | 297 | mailPtr = item->getMail(); |
298 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 298 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
299 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 299 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
300 | } | 300 | } |
301 | item = (EmailListItem *) item->nextSibling(); | 301 | item = (EmailListItem *) item->nextSibling(); |
302 | } | 302 | } |
303 | 303 | ||
304 | emailHandler->getMailHeaders(); | 304 | emailHandler->getMailHeaders(); |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::getAllNewMail() | 307 | void EmailClient::getAllNewMail() |
308 | { | 308 | { |
309 | allAccounts = TRUE; | 309 | allAccounts = TRUE; |
310 | currentAccount = accountList.first(); | 310 | currentAccount = accountList.first(); |
311 | getNewMail(); | 311 | getNewMail(); |
312 | } | 312 | } |
313 | 313 | ||
314 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 314 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
315 | { | 315 | { |
316 | Enclosure *ePtr; | 316 | Enclosure *ePtr; |
317 | Email newMail; | 317 | Email newMail; |
318 | int thisMailId; | 318 | int thisMailId; |
319 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 319 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
320 | 320 | ||
321 | mailconf->setGroup(newMail.id); | 321 | mailconf->setGroup(newMail.id); |
322 | 322 | ||
323 | if (fromDisk) { | 323 | if (fromDisk) { |
324 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 324 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
325 | newMail.size = mailconf->readNumEntry("size"); | 325 | newMail.size = mailconf->readNumEntry("size"); |
326 | newMail.serverId = mailconf->readNumEntry("serverid"); | 326 | newMail.serverId = mailconf->readNumEntry("serverid"); |
327 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 327 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
328 | } else { //mail arrived from server | 328 | } else { //mail arrived from server |
329 | newMail.serverId = mail.serverId; | 329 | newMail.serverId = mail.serverId; |
330 | newMail.size = mail.size; | 330 | newMail.size = mail.size; |
331 | newMail.downloaded = mail.downloaded; | 331 | newMail.downloaded = mail.downloaded; |
332 | 332 | ||
333 | newMail.fromAccountId = currentAccount->id; | 333 | newMail.fromAccountId = currentAccount->id; |
334 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 334 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
335 | } | 335 | } |
336 | 336 | ||
337 | //add if read or not | 337 | //add if read or not |
338 | newMail.read = mailconf->readBoolEntry("mailread"); | 338 | newMail.read = mailconf->readBoolEntry("mailread"); |
339 | 339 | ||
340 | //check if new mail | 340 | //check if new mail |
341 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 341 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
342 | thisMailId = mailIdCount; | 342 | thisMailId = mailIdCount; |
343 | mailIdCount++; | 343 | mailIdCount++; |
344 | 344 | ||
345 | //set server count, so that if the user aborts, the new | 345 | //set server count, so that if the user aborts, the new |
346 | //header is not reloaded | 346 | //header is not reloaded |
347 | if (currentAccount->synchronize) | 347 | if (currentAccount->synchronize) |
348 | currentAccount->lastServerMailCount++; | 348 | currentAccount->lastServerMailCount++; |
349 | 349 | ||
350 | mailconf->writeEntry("internalmailid", thisMailId); | 350 | mailconf->writeEntry("internalmailid", thisMailId); |
351 | mailconf->writeEntry("downloaded", newMail.downloaded); | 351 | mailconf->writeEntry("downloaded", newMail.downloaded); |
352 | mailconf->writeEntry("size", (int) newMail.size); | 352 | mailconf->writeEntry("size", (int) newMail.size); |
353 | mailconf->writeEntry("serverid", newMail.serverId); | 353 | mailconf->writeEntry("serverid", newMail.serverId); |
354 | 354 | ||
355 | addressList->addContact(newMail.fromMail, newMail.from); | 355 | addressList->addContact(newMail.fromMail, newMail.from); |
356 | } else if (!fromDisk) { //body to header arrived | 356 | } else if (!fromDisk) { //body to header arrived |
357 | mailconf->writeEntry("downloaded", TRUE); | 357 | mailconf->writeEntry("downloaded", TRUE); |
358 | } | 358 | } |
359 | QString stringMailId; | 359 | QString stringMailId; |
360 | stringMailId.setNum(thisMailId); | 360 | stringMailId.setNum(thisMailId); |
361 | //se if any attatchments needs to be stored | 361 | //se if any attatchments needs to be stored |
362 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { | 362 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { |
363 | QString stringId; | 363 | QString stringId; |
364 | stringId.setNum(ePtr->id); | 364 | stringId.setNum(ePtr->id); |
365 | 365 | ||
366 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 366 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
367 | if (id != ePtr->id) { //new entry | 367 | if (id != ePtr->id) { //new entry |
368 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 368 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
369 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 369 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
370 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 370 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
371 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 371 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
372 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 372 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
373 | mailconf->writeEntry("installed_" + stringId, FALSE); | 373 | mailconf->writeEntry("installed_" + stringId, FALSE); |
374 | 374 | ||
375 | ePtr->name = stringMailId + "_" + stringId; | 375 | ePtr->name = stringMailId + "_" + stringId; |
376 | ePtr->path = getPath(TRUE); | 376 | ePtr->path = getPath(TRUE); |
377 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 377 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
378 | ePtr->saved = TRUE; | 378 | ePtr->saved = TRUE; |
379 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 379 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
380 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 380 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
381 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 381 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
382 | } else { | 382 | } else { |
383 | ePtr->saved = FALSE; | 383 | ePtr->saved = FALSE; |
384 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 384 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
385 | } | 385 | } |
386 | } else { | 386 | } else { |
387 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 387 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
388 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 388 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
389 | if (ePtr->saved) { | 389 | if (ePtr->saved) { |
390 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 390 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
391 | ePtr->path = mailconf->readEntry("path_" + stringId); | 391 | ePtr->path = mailconf->readEntry("path_" + stringId); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | } | 394 | } |
395 | if (!previewingMail && !fromDisk) { | 395 | if (!previewingMail && !fromDisk) { |
396 | Email *mailPtr; | 396 | Email *mailPtr; |
397 | item = (EmailListItem *) inboxView->firstChild(); | 397 | item = (EmailListItem *) inboxView->firstChild(); |
398 | while (item != NULL) { | 398 | while (item != NULL) { |
399 | mailPtr = item->getMail(); | 399 | mailPtr = item->getMail(); |
400 | if (mailPtr->id == newMail.id) { | 400 | if (mailPtr->id == newMail.id) { |
401 | item->setMail(newMail); | 401 | item->setMail(newMail); |
402 | emit mailUpdated(item->getMail()); | 402 | emit mailUpdated(item->getMail()); |
403 | } | 403 | } |
404 | item = (EmailListItem *) item->nextSibling(); | 404 | item = (EmailListItem *) item->nextSibling(); |
405 | } | 405 | } |
406 | } else { | 406 | } else { |
407 | item = new EmailListItem(inboxView, newMail, TRUE); | 407 | item = new EmailListItem(inboxView, newMail, TRUE); |
408 | if (!newMail.downloaded) | 408 | if (!newMail.downloaded) |
409 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); | 409 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); |
410 | } | 410 | } |
411 | 411 | ||
412 | } | 412 | } |
413 | 413 | ||
414 | void EmailClient::allMailArrived(int count) | 414 | void EmailClient::allMailArrived(int count) |
415 | { | 415 | { |
416 | // not previewing means all mailtransfer has been done | 416 | // not previewing means all mailtransfer has been done |
417 | if (!previewingMail) { | 417 | if (!previewingMail) { |
418 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 418 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
419 | emit newCaption("Mailit - " + currentAccount->accountName); | 419 | emit newCaption("Mailit - " + currentAccount->accountName); |
420 | getNewMail(); | 420 | getNewMail(); |
421 | return; | 421 | return; |
422 | } else { | 422 | } else { |
423 | allAccounts = FALSE; | 423 | allAccounts = FALSE; |
424 | receiving = FALSE; | 424 | receiving = FALSE; |
425 | getMailButton->setEnabled(TRUE); | 425 | getMailButton->setEnabled(TRUE); |
426 | cancelButton->setEnabled(FALSE); | 426 | cancelButton->setEnabled(FALSE); |
427 | selectAccountMenu->setEnabled(TRUE); | 427 | selectAccountMenu->setEnabled(TRUE); |
428 | status1Label->setText("Idle"); | 428 | status1Label->setText("Idle"); |
429 | 429 | ||
430 | progressBar->reset(); | 430 | progressBar->reset(); |
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | // all headers downloaded from server, start downloading remaining mails | 435 | // all headers downloaded from server, start downloading remaining mails |
436 | previewingMail = FALSE; | 436 | previewingMail = FALSE; |
437 | status1Label->setText(currentAccount->accountName); | 437 | status1Label->setText(currentAccount->accountName); |
438 | progressBar->reset(); | 438 | progressBar->reset(); |
439 | 439 | ||
440 | emailHandler->getMailByList(&mailDownloadList); | 440 | emailHandler->getMailByList(&mailDownloadList); |
441 | } | 441 | } |
442 | 442 | ||
443 | void EmailClient::moveMailFront(Email *mailPtr) | 443 | void EmailClient::moveMailFront(Email *mailPtr) |
444 | { | 444 | { |
445 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 445 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
446 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 446 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | void EmailClient::smtpError(int code) | 450 | void EmailClient::smtpError(int code) |
451 | { | 451 | { |
452 | QString temp; | 452 | QString temp; |
453 | 453 | ||
454 | if (code == ErrUnknownResponse) | 454 | if (code == ErrUnknownResponse) |
455 | temp = "Unknown response from server"; | 455 | temp = "Unknown response from server"; |
456 | 456 | ||
457 | if (code == QSocket::ErrHostNotFound) | 457 | if (code == QSocket::ErrHostNotFound) |
458 | temp = "host not found"; | 458 | temp = "host not found"; |
459 | if (code == QSocket::ErrConnectionRefused) | 459 | if (code == QSocket::ErrConnectionRefused) |
460 | temp = "connection refused"; | 460 | temp = "connection refused"; |
461 | if (code == QSocket::ErrSocketRead) | 461 | if (code == QSocket::ErrSocketRead) |
462 | temp = "socket packet error"; | 462 | temp = "socket packet error"; |
463 | 463 | ||
464 | if (code != ErrCancel) { | 464 | if (code != ErrCancel) { |
465 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 465 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
466 | } else { | 466 | } else { |
467 | status2Label->setText("Aborted by user"); | 467 | status2Label->setText("Aborted by user"); |
468 | } | 468 | } |
469 | 469 | ||
470 | sending = FALSE; | 470 | sending = FALSE; |
471 | sendMailButton->setEnabled(TRUE); | 471 | sendMailButton->setEnabled(TRUE); |
472 | cancelButton->setEnabled(FALSE); | 472 | cancelButton->setEnabled(FALSE); |
473 | quedMessages.clear(); | 473 | quedMessages.clear(); |
474 | } | 474 | } |
475 | 475 | ||
476 | void EmailClient::popError(int code) | 476 | void EmailClient::popError(int code) |
477 | { | 477 | { |
478 | QString temp; | 478 | QString temp; |
479 | 479 | ||
480 | if (code == ErrUnknownResponse) | 480 | if (code == ErrUnknownResponse) |
481 | temp = "Unknown response from server"; | 481 | temp = "Unknown response from server"; |
482 | if (code == ErrLoginFailed) | 482 | if (code == ErrLoginFailed) |
483 | temp = "Login failed\nCheck user name and password"; | 483 | temp = "Login failed\nCheck user name and password"; |
484 | 484 | ||
485 | if (code == QSocket::ErrHostNotFound) | 485 | if (code == QSocket::ErrHostNotFound) |
486 | temp = "host not found"; | 486 | temp = "host not found"; |
487 | if (code == QSocket::ErrConnectionRefused) | 487 | if (code == QSocket::ErrConnectionRefused) |
488 | temp = "connection refused"; | 488 | temp = "connection refused"; |
489 | if (code == QSocket::ErrSocketRead) | 489 | if (code == QSocket::ErrSocketRead) |
490 | temp = "socket packet error"; | 490 | temp = "socket packet error"; |
491 | 491 | ||
492 | if (code != ErrCancel) { | 492 | if (code != ErrCancel) { |
493 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 493 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
494 | } else { | 494 | } else { |
495 | status2Label->setText("Aborted by user"); | 495 | status2Label->setText("Aborted by user"); |
496 | } | 496 | } |
497 | 497 | ||
498 | receiving = FALSE; | 498 | receiving = FALSE; |
499 | getMailButton->setEnabled(TRUE); | 499 | getMailButton->setEnabled(TRUE); |
500 | cancelButton->setEnabled(FALSE); | 500 | cancelButton->setEnabled(FALSE); |
501 | selectAccountMenu->setEnabled(TRUE); | 501 | selectAccountMenu->setEnabled(TRUE); |
502 | } | 502 | } |
503 | 503 | ||
504 | void EmailClient::inboxItemSelected() | 504 | void EmailClient::inboxItemSelected() |
505 | { | 505 | { |
506 | item = (EmailListItem*) inboxView->selectedItem(); | 506 | item = (EmailListItem*) inboxView->selectedItem(); |
507 | if (item != NULL) { | 507 | if (item != NULL) { |
508 | emit viewEmail(inboxView, item->getMail()); | 508 | emit viewEmail(inboxView, item->getMail()); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | void EmailClient::outboxItemSelected() | 512 | void EmailClient::outboxItemSelected() |
513 | { | 513 | { |
514 | item = (EmailListItem*) outboxView->selectedItem(); | 514 | item = (EmailListItem*) outboxView->selectedItem(); |
515 | if (item != NULL) { | 515 | if (item != NULL) { |
516 | emit viewEmail(outboxView, item->getMail()); | 516 | emit viewEmail(outboxView, item->getMail()); |
517 | } | 517 | } |
518 | 518 | ||
519 | } | 519 | } |
520 | 520 | ||
521 | void EmailClient::readMail() | 521 | void EmailClient::readMail() |
522 | { | 522 | { |
523 | Email mail; | 523 | Email mail; |
524 | int start, stop; | 524 | int start, stop; |
525 | QString s, del; | 525 | QString s, del; |
526 | 526 | ||
527 | QFile f(getPath(FALSE) + "inbox.txt"); | 527 | QFile f(getPath(FALSE) + "inbox.txt"); |
528 | // QFileInfo fi(f); | 528 | // QFileInfo fi(f); |
529 | qDebug( f.name()); | 529 | qDebug( f.name()); |
530 | 530 | ||
531 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 531 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
532 | QTextStream t( &f ); // use a text stream | 532 | QTextStream t( &f ); // use a text stream |
533 | s = t.read(); | 533 | s = t.read(); |
534 | f.close(); | 534 | f.close(); |
535 | 535 | ||
536 | start = 0; | 536 | start = 0; |
537 | del = "\n.\n"; | 537 | del = "\n.\n"; |
538 | while ((uint) start < s.length()) { | 538 | while ((uint) start < s.length()) { |
539 | stop = s.find(del, start); | 539 | stop = s.find(del, start); |
540 | if (stop == -1) | 540 | if (stop == -1) |
541 | stop = s.length() - del.length(); | 541 | stop = s.length() - del.length(); |
542 | 542 | ||
543 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 543 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
544 | start = stop + del.length(); | 544 | start = stop + del.length(); |
545 | mailArrived(mail, TRUE); | 545 | mailArrived(mail, TRUE); |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | QFile fo(getPath(FALSE) + "outbox.txt"); | 549 | QFile fo(getPath(FALSE) + "outbox.txt"); |
550 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 550 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
551 | QTextStream t( &fo ); // use a text stream | 551 | QTextStream t( &fo ); // use a text stream |
552 | s = t.read(); | 552 | s = t.read(); |
553 | fo.close(); | 553 | fo.close(); |
554 | 554 | ||
555 | start = 0; | 555 | start = 0; |
556 | del = "\n.\n"; | 556 | del = "\n.\n"; |
557 | while ((uint) start < s.length()) { | 557 | while ((uint) start < s.length()) { |
558 | stop = s.find(del, start); | 558 | stop = s.find(del, start); |
559 | if (stop == -1) | 559 | if (stop == -1) |
560 | stop = s.length() - del.length(); | 560 | stop = s.length() - del.length(); |
561 | 561 | ||
562 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 562 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
563 | start = stop + del.length(); | 563 | start = stop + del.length(); |
564 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 564 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
565 | mail.sent = false; | 565 | mail.sent = false; |
566 | mail.received = false; | 566 | mail.received = false; |
567 | enqueMail(mail); | 567 | enqueMail(mail); |
568 | 568 | ||
569 | } | 569 | } |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | void EmailClient::saveMail(QString fileName, QListView *view) | 573 | void EmailClient::saveMail(QString fileName, QListView *view) |
574 | { | 574 | { |
575 | QFile f(fileName); | 575 | QFile f(fileName); |
576 | Email *mail; | 576 | Email *mail; |
577 | 577 | ||
578 | if (! f.open(IO_WriteOnly) ) { | 578 | if (! f.open(IO_WriteOnly) ) { |
579 | qWarning("could not open file"); | 579 | qWarning("could not open file"); |
580 | return; | 580 | return; |
581 | } | 581 | } |
582 | item = (EmailListItem *) view->firstChild(); | 582 | item = (EmailListItem *) view->firstChild(); |
583 | qDebug (QString("Write : ") ); | 583 | qDebug (QString("Write : ") ); |
584 | QTextStream t(&f); | 584 | QTextStream t(&f); |
585 | while (item != NULL) { | 585 | while (item != NULL) { |
586 | mail = item->getMail(); | 586 | mail = item->getMail(); |
587 | qDebug(mail->rawMail); | 587 | qDebug(mail->rawMail); |
588 | qDebug(mail->recipients.first()); | 588 | qDebug(mail->recipients.first()); |
589 | t << mail->rawMail; | 589 | t << mail->rawMail; |
590 | 590 | ||
591 | mailconf->setGroup(mail->id); | 591 | mailconf->setGroup(mail->id); |
592 | mailconf->writeEntry("mailread", mail->read); | 592 | mailconf->writeEntry("mailread", mail->read); |
593 | 593 | ||
594 | item = (EmailListItem *) item->nextSibling(); | 594 | item = (EmailListItem *) item->nextSibling(); |
595 | } | 595 | } |
596 | f.close(); | 596 | f.close(); |
597 | } | 597 | } |
598 | 598 | ||
599 | //paths for mailit, is settings, inbox, enclosures | 599 | //paths for mailit, is settings, inbox, enclosures |
600 | QString EmailClient::getPath(bool enclosurePath) | 600 | QString EmailClient::getPath(bool enclosurePath) |
601 | { | 601 | { |
602 | QString basePath = "qtmail"; | 602 | QString basePath = "qtmail"; |
603 | QString enclosures = "enclosures"; | 603 | QString enclosures = "enclosures"; |
604 | 604 | ||
605 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 605 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
606 | if ( !dir.exists() ) | 606 | if ( !dir.exists() ) |
607 | dir.mkdir( dir.path() ); | 607 | dir.mkdir( dir.path() ); |
608 | 608 | ||
609 | if (enclosurePath) { | 609 | if (enclosurePath) { |
610 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 610 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
611 | 611 | ||
612 | if ( !dir.exists() ) | 612 | if ( !dir.exists() ) |
613 | dir.mkdir( dir.path() ); | 613 | dir.mkdir( dir.path() ); |
614 | 614 | ||
615 | return (dir.path() + "/"); | 615 | return (dir.path() + "/"); |
616 | 616 | ||
617 | } | 617 | } |
618 | return (dir.path() + "/"); | 618 | return (dir.path() + "/"); |
619 | } | 619 | } |
620 | 620 | ||
621 | void EmailClient::readSettings() | 621 | void EmailClient::readSettings() |
622 | { | 622 | { |
623 | TextParser *p; | 623 | TextParser *p; |
624 | QString s; | 624 | QString s; |
625 | int pos, accountPos, y; | 625 | int pos, accountPos, y; |
626 | QFile f( getPath(FALSE) + "settings.txt"); | 626 | QFile f( getPath(FALSE) + "settings.txt"); |
627 | 627 | ||
628 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 628 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
629 | QTextStream t( &f ); // use a text stream | 629 | QTextStream t( &f ); // use a text stream |
630 | s = t.read(); | 630 | s = t.read(); |
631 | f.close(); | 631 | f.close(); |
632 | 632 | ||
633 | p = new TextParser(s, "\n"); | 633 | p = new TextParser(s, "\n"); |
634 | 634 | ||
635 | accountPos = 0; | 635 | accountPos = 0; |
636 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { | 636 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { |
637 | accountPos++; | 637 | accountPos++; |
638 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) | 638 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) |
639 | account.accountName = p->getString(& ++pos, 'z', TRUE); | 639 | account.accountName = p->getString(& ++pos, 'z', TRUE); |
640 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) | 640 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) |
641 | account.name = p->getString(& ++pos, 'z', TRUE); | 641 | account.name = p->getString(& ++pos, 'z', TRUE); |
642 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | 642 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) |
643 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | 643 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); |
644 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 644 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
645 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 645 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
646 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 646 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
647 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 647 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
648 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 648 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
649 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 649 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
650 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 650 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
651 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 651 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 652 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
653 | s = p->getString(& ++pos, 'z', TRUE); | 653 | s = p->getString(& ++pos, 'z', TRUE); |
654 | account.id = s.toInt(); | 654 | account.id = s.toInt(); |
655 | } | 655 | } |
656 | 656 | ||
657 | account.lastServerMailCount = 0; | 657 | account.lastServerMailCount = 0; |
658 | account.synchronize = FALSE; | 658 | account.synchronize = FALSE; |
659 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 659 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
660 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 660 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
661 | account.synchronize = TRUE; | 661 | account.synchronize = TRUE; |
662 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 662 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
663 | s = p->getString(& ++pos, 'z', TRUE); | 663 | s = p->getString(& ++pos, 'z', TRUE); |
664 | account.lastServerMailCount = s.toInt(); | 664 | account.lastServerMailCount = s.toInt(); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | } | 667 | } |
668 | accountList.append(&account); | 668 | accountList.append(&account); |
669 | } | 669 | } |
670 | delete p; | 670 | delete p; |
671 | } | 671 | } |
672 | mailconf->setGroup("mailitglobal"); | 672 | mailconf->setGroup("mailitglobal"); |
673 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 673 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
674 | mailIdCount = y; | 674 | mailIdCount = y; |
675 | } | 675 | } |
676 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 676 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
677 | accountIdCount = y; | 677 | accountIdCount = y; |
678 | } | 678 | } |
679 | } | 679 | } |
680 | 680 | ||
681 | void EmailClient::saveSettings() | 681 | void EmailClient::saveSettings() |
682 | { | 682 | { |
683 | QString temp; | 683 | QString temp; |
684 | QFile f( getPath(FALSE) + "settings.txt"); | 684 | QFile f( getPath(FALSE) + "settings.txt"); |
685 | MailAccount *accountPtr; | 685 | MailAccount *accountPtr; |
686 | 686 | ||
687 | if (! f.open(IO_WriteOnly) ) { | 687 | if (! f.open(IO_WriteOnly) ) { |
688 | qWarning("could not save settings file"); | 688 | qWarning("could not save settings file"); |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | QTextStream t(&f); | 691 | QTextStream t(&f); |
692 | t << "#Settings for QPE Mailit program\n"; | 692 | t << "#Settings for QPE Mailit program\n"; |
693 | 693 | ||
694 | for (accountPtr = accountList.first(); accountPtr != 0; | 694 | for (accountPtr = accountList.first(); accountPtr != 0; |
695 | accountPtr = accountList.next()) { | 695 | accountPtr = accountList.next()) { |
696 | 696 | ||
697 | t << "accountStart;\n"; | 697 | t << "accountStart;\n"; |
698 | t << "AccountName: " + accountPtr->accountName + "\n"; | 698 | t << "AccountName: " + accountPtr->accountName + "\n"; |
699 | t << "Name: " + accountPtr->name + "\n"; | 699 | t << "Name: " + accountPtr->name + "\n"; |
700 | t << "Email: " + accountPtr->emailAddress + "\n"; | 700 | t << "Email: " + accountPtr->emailAddress + "\n"; |
701 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 701 | t << "POPUser: " + accountPtr->popUserName + "\n"; |
702 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 702 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; |
703 | t << "POPServer: " + accountPtr->popServer + "\n"; | 703 | t << "POPServer: " + accountPtr->popServer + "\n"; |
704 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 704 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; |
705 | t << "AccountId: " << accountPtr->id << "\n"; | 705 | t << "AccountId: " << accountPtr->id << "\n"; |
706 | if (accountPtr->synchronize) { | 706 | if (accountPtr->synchronize) { |
707 | t << "Synchronize: Yes\n"; | 707 | t << "Synchronize: Yes\n"; |
708 | t << "LastServerMailCount: "; | 708 | t << "LastServerMailCount: "; |
709 | t << accountPtr->lastServerMailCount << "\n"; | 709 | t << accountPtr->lastServerMailCount << "\n"; |
710 | } else { | 710 | } else { |
711 | t << "Synchronize: No\n"; | 711 | t << "Synchronize: No\n"; |
712 | } | 712 | } |
713 | t << "accountEnd;\n"; | 713 | t << "accountEnd;\n"; |
714 | } | 714 | } |
715 | f.close(); | 715 | f.close(); |
716 | 716 | ||
717 | mailconf->setGroup("mailitglobal"); | 717 | mailconf->setGroup("mailitglobal"); |
718 | mailconf->writeEntry("mailidcount", mailIdCount); | 718 | mailconf->writeEntry("mailidcount", mailIdCount); |
719 | mailconf->writeEntry("accountidcount", accountIdCount); | 719 | mailconf->writeEntry("accountidcount", accountIdCount); |
720 | } | 720 | } |
721 | 721 | ||
722 | void EmailClient::selectAccount(int id) | 722 | void EmailClient::selectAccount(int id) |
723 | { | 723 | { |
724 | if (accountList.count() > 0) { | 724 | if (accountList.count() > 0) { |
725 | currentAccount = accountList.at(id); | 725 | currentAccount = accountList.at(id); |
726 | emit newCaption("Mailit - " + currentAccount->accountName); | 726 | emit newCaption("Mailit - " + currentAccount->accountName); |
727 | getNewMail(); | 727 | getNewMail(); |
728 | } else { | 728 | } else { |
729 | emit newCaption("Mailit ! No account defined"); | 729 | emit newCaption("Mailit ! No account defined"); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | 732 | ||
733 | void EmailClient::editAccount(int id) | 733 | void EmailClient::editAccount(int id) |
734 | { | 734 | { |
735 | MailAccount *newAccount; | 735 | MailAccount *newAccount; |
736 | 736 | ||
737 | editAccountView = new EditAccount(this, "account", TRUE); | 737 | editAccountView = new EditAccount(this, "account", TRUE); |
738 | if (id == newAccountId) { //new account | 738 | if (id == newAccountId) { //new account |
739 | newAccount = new MailAccount; | 739 | newAccount = new MailAccount; |
740 | editAccountView->setAccount(newAccount); | 740 | editAccountView->setAccount(newAccount); |
741 | } else { | 741 | } else { |
742 | newAccount = accountList.at(id); | 742 | newAccount = accountList.at(id); |
743 | editAccountView->setAccount(newAccount, FALSE); | 743 | editAccountView->setAccount(newAccount, FALSE); |
744 | } | 744 | } |
745 | 745 | ||
746 | editAccountView->showMaximized(); | 746 | editAccountView->showMaximized(); |
747 | editAccountView->exec(); | 747 | editAccountView->exec(); |
748 | 748 | ||
749 | if (editAccountView->result() == QDialog::Accepted) { | 749 | if (editAccountView->result() == QDialog::Accepted) { |
750 | if (id == newAccountId) { | 750 | if (id == newAccountId) { |
751 | newAccount->id = accountIdCount; | 751 | newAccount->id = accountIdCount; |
752 | accountIdCount++; | 752 | accountIdCount++; |
753 | accountList.append(newAccount); | 753 | accountList.append(newAccount); |
754 | updateAccounts(); | 754 | updateAccounts(); |
755 | } else { | 755 | } else { |
756 | updateAccounts(); | 756 | updateAccounts(); |
757 | } | 757 | } |
758 | } | 758 | } |
759 | 759 | ||
760 | delete editAccountView; | 760 | delete editAccountView; |
761 | } | 761 | } |
762 | 762 | ||
763 | void EmailClient::deleteAccount(int id) | 763 | void EmailClient::deleteAccount(int id) |
764 | { | 764 | { |
765 | MailAccount *newAccount; | 765 | MailAccount *newAccount; |
766 | QString message; | 766 | QString message; |
767 | 767 | ||
768 | newAccount = accountList.at(id); | 768 | newAccount = accountList.at(id); |
769 | message = "Delete account:\n" + newAccount->accountName; | 769 | message = "Delete account:\n" + newAccount->accountName; |
770 | switch( QMessageBox::warning( this, "Mailit", message, | 770 | switch( QMessageBox::warning( this, "Mailit", message, |
771 | "Yes", "No", 0, 0, 1 ) ) { | 771 | "Yes", "No", 0, 0, 1 ) ) { |
772 | 772 | ||
773 | case 0: accountList.remove(id); | 773 | case 0: accountList.remove(id); |
774 | updateAccounts(); | 774 | updateAccounts(); |
775 | break; | 775 | break; |
776 | case 1: | 776 | case 1: |
777 | break; | 777 | break; |
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | void EmailClient::updateAccounts() | 781 | void EmailClient::updateAccounts() |
782 | { | 782 | { |
783 | MailAccount *accountPtr; | 783 | MailAccount *accountPtr; |
784 | 784 | ||
785 | //rebuild menus, clear all first | 785 | //rebuild menus, clear all first |
786 | editAccountMenu->clear(); | 786 | editAccountMenu->clear(); |
787 | selectAccountMenu->clear(); | 787 | selectAccountMenu->clear(); |
788 | deleteAccountMenu->clear(); | 788 | deleteAccountMenu->clear(); |
789 | 789 | ||
790 | newAccountId = editAccountMenu->insertItem("New", this, | 790 | newAccountId = editAccountMenu->insertItem("New", this, |
791 | SLOT(editAccount(int)) ); | 791 | SLOT(editAccount(int)) ); |
792 | editAccountMenu->insertSeparator(); | 792 | editAccountMenu->insertSeparator(); |
793 | 793 | ||
794 | idCount = 0; | 794 | idCount = 0; |
795 | for (accountPtr = accountList.first(); accountPtr != 0; | 795 | for (accountPtr = accountList.first(); accountPtr != 0; |
796 | accountPtr = accountList.next()) { | 796 | accountPtr = accountList.next()) { |
797 | 797 | ||
798 | editAccountMenu->insertItem(accountPtr->accountName, | 798 | editAccountMenu->insertItem(accountPtr->accountName, |
799 | this, SLOT(editAccount(int)), 0, idCount); | 799 | this, SLOT(editAccount(int)), 0, idCount); |
800 | selectAccountMenu->insertItem(accountPtr->accountName, | 800 | selectAccountMenu->insertItem(accountPtr->accountName, |
801 | this, SLOT(selectAccount(int)), 0, idCount); | 801 | this, SLOT(selectAccount(int)), 0, idCount); |
802 | deleteAccountMenu->insertItem(accountPtr->accountName, | 802 | deleteAccountMenu->insertItem(accountPtr->accountName, |
803 | this, SLOT(deleteAccount(int)), 0, idCount); | 803 | this, SLOT(deleteAccount(int)), 0, idCount); |
804 | idCount++; | 804 | idCount++; |
805 | } | 805 | } |
806 | } | 806 | } |
807 | 807 | ||
808 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 808 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
809 | { | 809 | { |
810 | Email *mPtr; | 810 | Email *mPtr; |
811 | Enclosure *ePtr; | 811 | Enclosure *ePtr; |
812 | 812 | ||
813 | if (inbox) { | 813 | if (inbox) { |
814 | mPtr = mailItem->getMail(); | 814 | mPtr = mailItem->getMail(); |
815 | 815 | ||
816 | //if mail is in queue for download, remove it from | 816 | //if mail is in queue for download, remove it from |
817 | //queue if possible | 817 | //queue if possible |
818 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 818 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
819 | if ( !mPtr->downloaded ) | 819 | if ( !mPtr->downloaded ) |
820 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 820 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
821 | } | 821 | } |
822 | 822 | ||
823 | mailconf->setGroup(mPtr->id); | 823 | mailconf->setGroup(mPtr->id); |
824 | mailconf->clearGroup(); | 824 | mailconf->clearGroup(); |
825 | 825 | ||
826 | //delete any temporary attatchemnts storing | 826 | //delete any temporary attatchemnts storing |
827 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 827 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
828 | if (ePtr->saved) { | 828 | if (ePtr->saved) { |
829 | QFile::remove( (ePtr->path + ePtr->name) ); | 829 | QFile::remove( (ePtr->path + ePtr->name) ); |
830 | } | 830 | } |
831 | } | 831 | } |
832 | inboxView->takeItem(mailItem); | 832 | inboxView->takeItem(mailItem); |
833 | } else { | 833 | } else { |
834 | outboxView->takeItem(mailItem); | 834 | outboxView->takeItem(mailItem); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void EmailClient::setMailSize(int size) | 838 | void EmailClient::setMailSize(int size) |
839 | { | 839 | { |
840 | progressBar->reset(); | 840 | progressBar->reset(); |
841 | progressBar->setTotalSteps(size); | 841 | progressBar->setTotalSteps(size); |
842 | } | 842 | } |
843 | 843 | ||
844 | void EmailClient::setTotalSize(int size) | 844 | void EmailClient::setTotalSize(int size) |
845 | { | 845 | { |
846 | 846 | ||
847 | } | 847 | } |
848 | 848 | ||
849 | void EmailClient::setDownloadedSize(int size) | 849 | void EmailClient::setDownloadedSize(int size) |
850 | { | 850 | { |
851 | int total = progressBar->totalSteps(); | 851 | int total = progressBar->totalSteps(); |
852 | 852 | ||
853 | if (size < total) { | 853 | if (size < total) { |
854 | progressBar->setProgress(size); | 854 | progressBar->setProgress(size); |
855 | } else { | 855 | } else { |
856 | progressBar->setProgress(total); | 856 | progressBar->setProgress(total); |
857 | } | 857 | } |
858 | } | 858 | } |
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h index 135bfaa..80457f9 100644 --- a/noncore/net/mailit/emailclient.h +++ b/noncore/net/mailit/emailclient.h | |||
@@ -1,149 +1,149 @@ | |||
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 | #ifndef EMAILCLIENT_H | 20 | #ifndef EMAILCLIENT_H |
21 | #define EMAILCLIENT_H | 21 | #define EMAILCLIENT_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qtabwidget.h> | ||
33 | #include <qaction.h> | 32 | #include <qaction.h> |
34 | #include <qlayout.h> | 33 | #include <qlayout.h> |
35 | #include <qtooltip.h> | 34 | #include <qtooltip.h> |
36 | #include <qimage.h> | 35 | #include <qimage.h> |
37 | #include <qpixmap.h> | 36 | #include <qpixmap.h> |
38 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
39 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
40 | #include <qstatusbar.h> | 39 | #include <qstatusbar.h> |
41 | #include <qdir.h> | 40 | #include <qdir.h> |
42 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <opie/otabwidget.h> | ||
43 | 43 | ||
44 | #include "emailhandler.h" | 44 | #include "emailhandler.h" |
45 | #include "emaillistitem.h" | 45 | #include "emaillistitem.h" |
46 | #include "textparser.h" | 46 | #include "textparser.h" |
47 | #include "editaccount.h" | 47 | #include "editaccount.h" |
48 | #include "maillist.h" | 48 | #include "maillist.h" |
49 | #include "addresslist.h" | 49 | #include "addresslist.h" |
50 | 50 | ||
51 | #include <qpe/config.h> | 51 | #include <qpe/config.h> |
52 | 52 | ||
53 | class AccountList : public QList<MailAccount> | 53 | class AccountList : public QList<MailAccount> |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | Item newItem(Item d); | 56 | Item newItem(Item d); |
57 | private: | 57 | private: |
58 | MailAccount* dupl(MailAccount *in); | 58 | MailAccount* dupl(MailAccount *in); |
59 | MailAccount *ac; | 59 | MailAccount *ac; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | //class EmailClient : public EmailClientBase | 62 | //class EmailClient : public EmailClientBase |
63 | class EmailClient : public QMainWindow | 63 | class EmailClient : public QMainWindow |
64 | { | 64 | { |
65 | Q_OBJECT | 65 | Q_OBJECT |
66 | 66 | ||
67 | public: | 67 | public: |
68 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); | 68 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); |
69 | ~EmailClient(); | 69 | ~EmailClient(); |
70 | AddressList* getAdrListRef(); | 70 | AddressList* getAdrListRef(); |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void composeRequested(); | 73 | void composeRequested(); |
74 | void viewEmail(QListView *, Email *); | 74 | void viewEmail(QListView *, Email *); |
75 | void mailUpdated(Email *); | 75 | void mailUpdated(Email *); |
76 | void newCaption(const QString &); | 76 | void newCaption(const QString &); |
77 | 77 | ||
78 | public slots: | 78 | public slots: |
79 | void compose(); | 79 | void compose(); |
80 | void cancel(); | 80 | void cancel(); |
81 | void enqueMail(const Email &mail); | 81 | void enqueMail(const Email &mail); |
82 | void setMailAccount(); | 82 | void setMailAccount(); |
83 | void sendQuedMail(); | 83 | void sendQuedMail(); |
84 | void mailSent(); | 84 | void mailSent(); |
85 | void getNewMail(); | 85 | void getNewMail(); |
86 | void getAllNewMail(); | 86 | void getAllNewMail(); |
87 | void smtpError(int code); | 87 | void smtpError(int code); |
88 | void popError(int code); | 88 | void popError(int code); |
89 | void inboxItemSelected(); | 89 | void inboxItemSelected(); |
90 | void outboxItemSelected(); | 90 | void outboxItemSelected(); |
91 | void mailArrived(const Email &mail, bool fromDisk); | 91 | void mailArrived(const Email &mail, bool fromDisk); |
92 | void allMailArrived(int); | 92 | void allMailArrived(int); |
93 | void saveMail(QString fileName, QListView *view); | 93 | void saveMail(QString fileName, QListView *view); |
94 | void selectAccount(int); | 94 | void selectAccount(int); |
95 | void editAccount(int); | 95 | void editAccount(int); |
96 | void updateAccounts(); | 96 | void updateAccounts(); |
97 | void deleteAccount(int); | 97 | void deleteAccount(int); |
98 | void deleteMail(EmailListItem *mailItem, bool &inbox); | 98 | void deleteMail(EmailListItem *mailItem, bool &inbox); |
99 | void setTotalSize(int); | 99 | void setTotalSize(int); |
100 | void setMailSize(int); | 100 | void setMailSize(int); |
101 | void setDownloadedSize(int); | 101 | void setDownloadedSize(int); |
102 | void moveMailFront(Email *mailPtr); | 102 | void moveMailFront(Email *mailPtr); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | void init(); | 105 | void init(); |
106 | void readMail(); | 106 | void readMail(); |
107 | QString getPath(bool enclosurePath); | 107 | QString getPath(bool enclosurePath); |
108 | void readSettings(); | 108 | void readSettings(); |
109 | void saveSettings(); | 109 | void saveSettings(); |
110 | 110 | ||
111 | private: | 111 | private: |
112 | Config *mailconf; | 112 | Config *mailconf; |
113 | int newAccountId, idCount, mailIdCount; | 113 | int newAccountId, idCount, mailIdCount; |
114 | int accountIdCount; | 114 | int accountIdCount; |
115 | AccountList accountList; | 115 | AccountList accountList; |
116 | AddressList *addressList; | 116 | AddressList *addressList; |
117 | 117 | ||
118 | EditAccount *editAccountView; | 118 | EditAccount *editAccountView; |
119 | EmailListItem *item; | 119 | EmailListItem *item; |
120 | EmailHandler *emailHandler; | 120 | EmailHandler *emailHandler; |
121 | QList<Email> quedMessages; | 121 | QList<Email> quedMessages; |
122 | MailList mailDownloadList; | 122 | MailList mailDownloadList; |
123 | bool sending, receiving, previewingMail, allAccounts; | 123 | bool sending, receiving, previewingMail, allAccounts; |
124 | QString lineShift; | 124 | QString lineShift; |
125 | MailAccount account, *currentAccount; | 125 | MailAccount account, *currentAccount; |
126 | 126 | ||
127 | QToolBar *bar; | 127 | QToolBar *bar; |
128 | QProgressBar *progressBar; | 128 | QProgressBar *progressBar; |
129 | QStatusBar *statusBar; | 129 | QStatusBar *statusBar; |
130 | QLabel *status1Label, *status2Label; | 130 | QLabel *status1Label, *status2Label; |
131 | QAction *getMailButton; | 131 | QAction *getMailButton; |
132 | QAction *sendMailButton; | 132 | QAction *sendMailButton; |
133 | QAction *composeButton; | 133 | QAction *composeButton; |
134 | QAction *cancelButton; | 134 | QAction *cancelButton; |
135 | 135 | ||
136 | QMenuBar *mb; | 136 | QMenuBar *mb; |
137 | QPopupMenu *selectAccountMenu; | 137 | QPopupMenu *selectAccountMenu; |
138 | QPopupMenu *editAccountMenu; | 138 | QPopupMenu *editAccountMenu; |
139 | QPopupMenu *deleteAccountMenu; | 139 | QPopupMenu *deleteAccountMenu; |
140 | 140 | ||
141 | QTabWidget* mailboxView; | 141 | OTabWidget* mailboxView; |
142 | QListView* inboxView; | 142 | QListView* inboxView; |
143 | QListView* outboxView; | 143 | QListView* outboxView; |
144 | 144 | ||
145 | QGridLayout* grid_2; | 145 | QGridLayout* grid_2; |
146 | QGridLayout* grid_3; | 146 | QGridLayout* grid_3; |
147 | }; | 147 | }; |
148 | 148 | ||
149 | #endif // EMAILCLIENT_H | 149 | #endif // EMAILCLIENT_H |
diff --git a/noncore/net/mailit/mailit.pro b/noncore/net/mailit/mailit.pro index d51126a..a404884 100644 --- a/noncore/net/mailit/mailit.pro +++ b/noncore/net/mailit/mailit.pro | |||
@@ -1,43 +1,43 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = emailclient.h \ | 3 | HEADERS = emailclient.h \ |
4 | emailhandler.h \ | 4 | emailhandler.h \ |
5 | emaillistitem.h \ | 5 | emaillistitem.h \ |
6 | mailitwindow.h \ | 6 | mailitwindow.h \ |
7 | md5.h \ | 7 | md5.h \ |
8 | popclient.h \ | 8 | popclient.h \ |
9 | readmail.h \ | 9 | readmail.h \ |
10 | smtpclient.h \ | 10 | smtpclient.h \ |
11 | writemail.h \ | 11 | writemail.h \ |
12 | textparser.h \ | 12 | textparser.h \ |
13 | viewatt.h \ | 13 | viewatt.h \ |
14 | addatt.h \ | 14 | addatt.h \ |
15 | editaccount.h \ | 15 | editaccount.h \ |
16 | maillist.h \ | 16 | maillist.h \ |
17 | addresslist.h | 17 | addresslist.h |
18 | SOURCES = emailclient.cpp \ | 18 | SOURCES = emailclient.cpp \ |
19 | emailhandler.cpp \ | 19 | emailhandler.cpp \ |
20 | emaillistitem.cpp \ | 20 | emaillistitem.cpp \ |
21 | mailitwindow.cpp \ | 21 | mailitwindow.cpp \ |
22 | main.cpp \ | 22 | main.cpp \ |
23 | md5.c \ | 23 | md5.c \ |
24 | popclient.cpp \ | 24 | popclient.cpp \ |
25 | readmail.cpp \ | 25 | readmail.cpp \ |
26 | smtpclient.cpp \ | 26 | smtpclient.cpp \ |
27 | writemail.cpp \ | 27 | writemail.cpp \ |
28 | textparser.cpp \ | 28 | textparser.cpp \ |
29 | viewatt.cpp \ | 29 | viewatt.cpp \ |
30 | addatt.cpp \ | 30 | addatt.cpp \ |
31 | editaccount.cpp \ | 31 | editaccount.cpp \ |
32 | maillist.cpp \ | 32 | maillist.cpp \ |
33 | addresslist.cpp | 33 | addresslist.cpp |
34 | 34 | ||
35 | INCLUDEPATH += $(OPIEDIR)/include | 35 | INCLUDEPATH += $(OPIEDIR)/include |
36 | DEPENDPATH += $(OPIEDIR)/include | 36 | DEPENDPATH += $(OPIEDIR)/include |
37 | LIBS += -lqpe | 37 | LIBS += -lqpe -lopie |
38 | # -lssl | 38 | # -lssl |
39 | MOC_DIR=qpeobj | 39 | MOC_DIR=qpeobj |
40 | OBJECTS_DIR=qpeobj | 40 | OBJECTS_DIR=qpeobj |
41 | DESTDIR=$(OPIEDIR)/bin | 41 | DESTDIR=$(OPIEDIR)/bin |
42 | 42 | ||
43 | include ( $(OPIEDIR)/include.pro ) | 43 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp index 4954f34..2011ecf 100644 --- a/noncore/net/mailit/readmail.cpp +++ b/noncore/net/mailit/readmail.cpp | |||
@@ -1,326 +1,326 @@ | |||
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 "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include "resource.h" | 24 | #include "resource.h" |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "pass" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | ||
63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
65 | previousButton->addTo(bar); | 65 | previousButton->addTo(bar); |
66 | previousButton->addTo(viewMenu); | 66 | previousButton->addTo(viewMenu); |
67 | 67 | ||
68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
70 | nextButton->addTo(bar); | 70 | nextButton->addTo(bar); |
71 | nextButton->addTo(viewMenu); | 71 | nextButton->addTo(viewMenu); |
72 | 72 | ||
73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
74 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 74 | connect( attatchmentsButton, SIGNAL( activated() ), this, |
75 | SLOT( viewAttatchments() ) ); | 75 | SLOT( viewAttatchments() ) ); |
76 | attatchmentsButton->addTo(bar); | 76 | attatchmentsButton->addTo(bar); |
77 | attatchmentsButton->addTo(viewMenu); | 77 | attatchmentsButton->addTo(viewMenu); |
78 | 78 | ||
79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0, TRUE); | 79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
81 | plainTextButton->addTo(bar); | 81 | plainTextButton->addTo(bar); |
82 | plainTextButton->addTo(viewMenu); | 82 | plainTextButton->addTo(viewMenu); |
83 | 83 | ||
84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
86 | deleteButton->addTo(bar); | 86 | deleteButton->addTo(bar); |
87 | deleteButton->addTo(mailMenu); | 87 | deleteButton->addTo(mailMenu); |
88 | 88 | ||
89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
90 | 90 | ||
91 | emailView = new QTextView( this, "emailView" ); | 91 | emailView = new QTextView( this, "emailView" ); |
92 | setCentralWidget(emailView); | 92 | setCentralWidget(emailView); |
93 | 93 | ||
94 | mime = new QMimeSourceFactory(); | 94 | mime = new QMimeSourceFactory(); |
95 | emailView->setMimeSourceFactory(mime); | 95 | emailView->setMimeSourceFactory(mime); |
96 | } | 96 | } |
97 | 97 | ||
98 | void ReadMail::updateView() | 98 | void ReadMail::updateView() |
99 | { | 99 | { |
100 | Enclosure *ePtr; | 100 | Enclosure *ePtr; |
101 | QString mailStringSize; | 101 | QString mailStringSize; |
102 | QString text, temp; | 102 | QString text, temp; |
103 | 103 | ||
104 | mail->read = TRUE; //mark as read | 104 | mail->read = TRUE; //mark as read |
105 | inbox = mail->received; | 105 | inbox = mail->received; |
106 | 106 | ||
107 | replyButton->removeFrom(mailMenu); | 107 | replyButton->removeFrom(mailMenu); |
108 | replyButton->removeFrom(bar); | 108 | replyButton->removeFrom(bar); |
109 | 109 | ||
110 | if (inbox == TRUE) { | 110 | if (inbox == TRUE) { |
111 | replyButton->addTo(bar); | 111 | replyButton->addTo(bar); |
112 | replyButton->addTo(mailMenu); | 112 | replyButton->addTo(mailMenu); |
113 | 113 | ||
114 | if (!mail->downloaded) { | 114 | if (!mail->downloaded) { |
115 | //report currently viewed mail so that it will be | 115 | //report currently viewed mail so that it will be |
116 | //placed first in the queue of new mails to download | 116 | //placed first in the queue of new mails to download |
117 | emit viewingMail(mail); | 117 | emit viewingMail(mail); |
118 | 118 | ||
119 | double mailSize = (double) mail->size; | 119 | double mailSize = (double) mail->size; |
120 | if (mailSize < 1024) { | 120 | if (mailSize < 1024) { |
121 | mailStringSize.setNum(mailSize); | 121 | mailStringSize.setNum(mailSize); |
122 | mailStringSize += " Bytes"; | 122 | mailStringSize += " Bytes"; |
123 | } else if (mailSize < 1024*1024) { | 123 | } else if (mailSize < 1024*1024) { |
124 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 124 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
125 | mailStringSize += " Kb"; | 125 | mailStringSize += " Kb"; |
126 | } else { | 126 | } else { |
127 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 127 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
128 | mailStringSize += " Mb"; | 128 | mailStringSize += " Mb"; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 133 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
134 | 134 | ||
135 | if (! plainTxt) { //use RichText, inline pics etc. | 135 | if (! plainTxt) { //use RichText, inline pics etc. |
136 | emailView->setTextFormat(QTextView::RichText); | 136 | emailView->setTextFormat(QTextView::RichText); |
137 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 137 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
138 | +"</font></center></big></b><br>"; | 138 | +"</font></center></big></b><br>"; |
139 | text += "<b>From: </b>" + mail->from + " <i>" + | 139 | text += "<b>From: </b>" + mail->from + " <i>" + |
140 | mail->fromMail + "</i><br>"; | 140 | mail->fromMail + "</i><br>"; |
141 | 141 | ||
142 | text +="<b>To: </b>"; | 142 | text +="<b>To: </b>"; |
143 | for (QStringList::Iterator it = mail->recipients.begin(); | 143 | for (QStringList::Iterator it = mail->recipients.begin(); |
144 | it != mail->recipients.end(); ++it ) { | 144 | it != mail->recipients.end(); ++it ) { |
145 | text += *it + " "; | 145 | text += *it + " "; |
146 | } | 146 | } |
147 | text += "<br>" + mail->date; | 147 | text += "<br>" + mail->date; |
148 | 148 | ||
149 | if (mail->files.count() > 0) { | 149 | if (mail->files.count() > 0) { |
150 | text += "<br><b>Attatchments: </b>"; | 150 | text += "<br><b>Attatchments: </b>"; |
151 | 151 | ||
152 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 152 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
153 | text += ePtr->originalName + " "; | 153 | text += ePtr->originalName + " "; |
154 | } | 154 | } |
155 | text += "<hr><br>" + mail->body; | 155 | text += "<hr><br>" + mail->body; |
156 | 156 | ||
157 | if (inbox) { | 157 | if (inbox) { |
158 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 158 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
159 | 159 | ||
160 | text += "<br><hr><b>Attatchment: </b>" + | 160 | text += "<br><hr><b>Attatchment: </b>" + |
161 | ePtr->originalName + "<hr>"; | 161 | ePtr->originalName + "<hr>"; |
162 | 162 | ||
163 | if (ePtr->contentType == "TEXT") { | 163 | if (ePtr->contentType == "TEXT") { |
164 | QFile f(ePtr->path + ePtr->name); | 164 | QFile f(ePtr->path + ePtr->name); |
165 | 165 | ||
166 | if (f.open(IO_ReadOnly) ) { | 166 | if (f.open(IO_ReadOnly) ) { |
167 | QTextStream t(&f); | 167 | QTextStream t(&f); |
168 | temp = t.read(); | 168 | temp = t.read(); |
169 | text += temp + "<br>"; | 169 | text += temp + "<br>"; |
170 | f.close(); | 170 | f.close(); |
171 | } else { | 171 | } else { |
172 | text += "<b>Could not locate file</b><br>"; | 172 | text += "<b>Could not locate file</b><br>"; |
173 | } | 173 | } |
174 | 174 | ||
175 | } | 175 | } |
176 | if (ePtr->contentType == "IMAGE") { | 176 | if (ePtr->contentType == "IMAGE") { |
177 | // temp.setNum(emailView->width());//get display width | 177 | // temp.setNum(emailView->width());//get display width |
178 | // text += "<img width=" + temp +" src =""" + | 178 | // text += "<img width=" + temp +" src =""" + |
179 | // ePtr->originalName + """> </img>"; | 179 | // ePtr->originalName + """> </img>"; |
180 | text += "<img src =""" + | 180 | text += "<img src =""" + |
181 | ePtr->originalName + """> </img>"; | 181 | ePtr->originalName + """> </img>"; |
182 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 182 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | if (mail->downloaded || !inbox) { | 187 | if (mail->downloaded || !inbox) { |
188 | text += "<hr><br>" + mail->body; | 188 | text += "<hr><br>" + mail->body; |
189 | } else { | 189 | } else { |
190 | text += "<hr><br><b> Awaiting download </b><br>"; | 190 | text += "<hr><br><b> Awaiting download </b><br>"; |
191 | text += "Size of mail: " + mailStringSize; | 191 | text += "Size of mail: " + mailStringSize; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | emailView->setText(text); | 194 | emailView->setText(text); |
195 | } else { // show plain txt mail | 195 | } else { // show plain txt mail |
196 | emailView->setTextFormat(QTextView::PlainText); | 196 | emailView->setTextFormat(QTextView::PlainText); |
197 | text = "Subject: " + mail->subject + "\n"; | 197 | text = "Subject: " + mail->subject + "\n"; |
198 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; | 198 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; |
199 | text += "To: "; | 199 | text += "To: "; |
200 | for (QStringList::Iterator it = mail->recipients.begin(); | 200 | for (QStringList::Iterator it = mail->recipients.begin(); |
201 | it != mail->recipients.end(); ++it ) { | 201 | it != mail->recipients.end(); ++it ) { |
202 | text += *it + " "; | 202 | text += *it + " "; |
203 | } | 203 | } |
204 | text += "\nDate: " + mail->date + "\n"; | 204 | text += "\nDate: " + mail->date + "\n"; |
205 | if (mail->files.count() > 0) { | 205 | if (mail->files.count() > 0) { |
206 | text += "Attatchments: "; | 206 | text += "Attatchments: "; |
207 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 207 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
208 | text += ePtr->originalName + " "; | 208 | text += ePtr->originalName + " "; |
209 | } | 209 | } |
210 | text += "\n\n"; | 210 | text += "\n\n"; |
211 | } else text += "\n"; | 211 | } else text += "\n"; |
212 | 212 | ||
213 | if (!inbox) { | 213 | if (!inbox) { |
214 | text += mail->body; | 214 | text += mail->body; |
215 | } else if (mail->downloaded) { | 215 | } else if (mail->downloaded) { |
216 | text += mail->bodyPlain; | 216 | text += mail->bodyPlain; |
217 | } else { | 217 | } else { |
218 | text += "\nAwaiting download\n"; | 218 | text += "\nAwaiting download\n"; |
219 | text += "Size of mail: " + mailStringSize; | 219 | text += "Size of mail: " + mailStringSize; |
220 | } | 220 | } |
221 | 221 | ||
222 | emailView->setText(text); | 222 | emailView->setText(text); |
223 | } | 223 | } |
224 | 224 | ||
225 | if (mail->files.count() == 0) | 225 | if (mail->files.count() == 0) |
226 | attatchmentsButton->setEnabled(FALSE); | 226 | attatchmentsButton->setEnabled(FALSE); |
227 | else attatchmentsButton->setEnabled(TRUE); | 227 | else attatchmentsButton->setEnabled(TRUE); |
228 | 228 | ||
229 | setCaption("Examining mail: " + mail->subject); | 229 | setCaption("Examining mail: " + mail->subject); |
230 | } | 230 | } |
231 | 231 | ||
232 | //update view with current EmailListItem (item) | 232 | //update view with current EmailListItem (item) |
233 | void ReadMail::update(QListView *thisView, Email *mailIn) | 233 | void ReadMail::update(QListView *thisView, Email *mailIn) |
234 | { | 234 | { |
235 | view = thisView; | 235 | view = thisView; |
236 | item = (EmailListItem *) view->selectedItem(); | 236 | item = (EmailListItem *) view->selectedItem(); |
237 | mail = mailIn; | 237 | mail = mailIn; |
238 | updateView(); | 238 | updateView(); |
239 | updateButtons(); | 239 | updateButtons(); |
240 | } | 240 | } |
241 | 241 | ||
242 | void ReadMail::mailUpdated(Email *mailIn) | 242 | void ReadMail::mailUpdated(Email *mailIn) |
243 | { | 243 | { |
244 | if (mailIn == mail) { | 244 | if (mailIn == mail) { |
245 | updateView(); | 245 | updateView(); |
246 | } else { | 246 | } else { |
247 | updateButtons(); | 247 | updateButtons(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void ReadMail::close() | 251 | void ReadMail::close() |
252 | { | 252 | { |
253 | emit cancelView(); | 253 | emit cancelView(); |
254 | } | 254 | } |
255 | 255 | ||
256 | //gets next item in listview, exits if there is no next | 256 | //gets next item in listview, exits if there is no next |
257 | void ReadMail::next() | 257 | void ReadMail::next() |
258 | { | 258 | { |
259 | item = (EmailListItem *) item->nextSibling(); | 259 | item = (EmailListItem *) item->nextSibling(); |
260 | if (item != NULL) { | 260 | if (item != NULL) { |
261 | mail = item->getMail(); | 261 | mail = item->getMail(); |
262 | updateView(); | 262 | updateView(); |
263 | } | 263 | } |
264 | updateButtons(); | 264 | updateButtons(); |
265 | } | 265 | } |
266 | 266 | ||
267 | //gets previous item in listview, exits if there is no previous | 267 | //gets previous item in listview, exits if there is no previous |
268 | void ReadMail::previous() | 268 | void ReadMail::previous() |
269 | { | 269 | { |
270 | item = (EmailListItem *) item->itemAbove(); | 270 | item = (EmailListItem *) item->itemAbove(); |
271 | if (item != NULL) { | 271 | if (item != NULL) { |
272 | mail = item->getMail(); | 272 | mail = item->getMail(); |
273 | updateView(); | 273 | updateView(); |
274 | } | 274 | } |
275 | updateButtons(); | 275 | updateButtons(); |
276 | } | 276 | } |
277 | 277 | ||
278 | //deletes item, tries bringing up next or previous, exits if unsucessful | 278 | //deletes item, tries bringing up next or previous, exits if unsucessful |
279 | void ReadMail::deleteItem() | 279 | void ReadMail::deleteItem() |
280 | { | 280 | { |
281 | EmailListItem *temp = item; | 281 | EmailListItem *temp = item; |
282 | temp = (EmailListItem *) item->nextSibling();//trybelow | 282 | temp = (EmailListItem *) item->nextSibling();//trybelow |
283 | if (temp == NULL) | 283 | if (temp == NULL) |
284 | temp = (EmailListItem *) item->itemAbove(); //try above | 284 | temp = (EmailListItem *) item->itemAbove(); //try above |
285 | 285 | ||
286 | emit removeItem(item, inbox); | 286 | emit removeItem(item, inbox); |
287 | 287 | ||
288 | item = temp; | 288 | item = temp; |
289 | if (item != NULL) { //more items in list | 289 | if (item != NULL) { //more items in list |
290 | mail = item->getMail(); | 290 | mail = item->getMail(); |
291 | updateView(); | 291 | updateView(); |
292 | updateButtons(); | 292 | updateButtons(); |
293 | } else close(); //no more items to see | 293 | } else close(); //no more items to see |
294 | } | 294 | } |
295 | 295 | ||
296 | void ReadMail::updateButtons() | 296 | void ReadMail::updateButtons() |
297 | { | 297 | { |
298 | EmailListItem *temp; | 298 | EmailListItem *temp; |
299 | 299 | ||
300 | temp = item; | 300 | temp = item; |
301 | if ((EmailListItem *) temp->nextSibling() == NULL) | 301 | if ((EmailListItem *) temp->nextSibling() == NULL) |
302 | nextButton->setEnabled(FALSE); | 302 | nextButton->setEnabled(FALSE); |
303 | else nextButton->setEnabled(TRUE); | 303 | else nextButton->setEnabled(TRUE); |
304 | 304 | ||
305 | temp = item; | 305 | temp = item; |
306 | if ((EmailListItem *) temp->itemAbove() == NULL) | 306 | if ((EmailListItem *) temp->itemAbove() == NULL) |
307 | previousButton->setEnabled(FALSE); | 307 | previousButton->setEnabled(FALSE); |
308 | else previousButton->setEnabled(TRUE); | 308 | else previousButton->setEnabled(TRUE); |
309 | } | 309 | } |
310 | 310 | ||
311 | void ReadMail::shiftText() | 311 | void ReadMail::shiftText() |
312 | { | 312 | { |
313 | plainTxt = ! plainTxt; | 313 | plainTxt = ! plainTxt; |
314 | updateView(); | 314 | updateView(); |
315 | } | 315 | } |
316 | 316 | ||
317 | void ReadMail::viewAttatchments() | 317 | void ReadMail::viewAttatchments() |
318 | { | 318 | { |
319 | viewAtt->update(mail, inbox); | 319 | viewAtt->update(mail, inbox); |
320 | viewAtt->showMaximized(); | 320 | viewAtt->showMaximized(); |
321 | } | 321 | } |
322 | 322 | ||
323 | void ReadMail::reply() | 323 | void ReadMail::reply() |
324 | { | 324 | { |
325 | emit replyRequested(*mail); | 325 | emit replyRequested(*mail); |
326 | } | 326 | } |
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 2e82623..fc4276b 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -1,858 +1,858 @@ | |||
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 <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include "resource.h" | 26 | #include "resource.h" |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | 28 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 29 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (MailAccount *) d); | 31 | return dupl( (MailAccount *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 34 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 35 | { |
36 | ac = new MailAccount(*in); | 36 | ac = new MailAccount(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 41 | : QMainWindow( parent, name, fl ) |
42 | { | 42 | { |
43 | emailHandler = new EmailHandler(); | 43 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList( getPath(FALSE) + "mail_adr"); | 44 | addressList = new AddressList( getPath(FALSE) + "mail_adr"); |
45 | 45 | ||
46 | sending = FALSE; | 46 | sending = FALSE; |
47 | receiving = FALSE; | 47 | receiving = FALSE; |
48 | previewingMail = FALSE; | 48 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 49 | mailIdCount = 1; |
50 | accountIdCount = 1; | 50 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 51 | allAccounts = FALSE; |
52 | 52 | ||
53 | init(); | 53 | init(); |
54 | 54 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 56 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 57 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 58 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 59 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 60 | SLOT(popError(int)) ); |
61 | 61 | ||
62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | 64 | ||
65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
66 | SLOT(mailArrived(const Email &, bool)) ); | 66 | SLOT(mailArrived(const Email &, bool)) ); |
67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
68 | SLOT(allMailArrived(int)) ); | 68 | SLOT(allMailArrived(int)) ); |
69 | 69 | ||
70 | mailconf = new Config("mailit"); | 70 | mailconf = new Config("mailit"); |
71 | //In case Synchronize is not defined in settings.txt | 71 | //In case Synchronize is not defined in settings.txt |
72 | 72 | ||
73 | readSettings(); | 73 | readSettings(); |
74 | 74 | ||
75 | updateAccounts(); | 75 | updateAccounts(); |
76 | 76 | ||
77 | lineShift = "\n"; | 77 | lineShift = "\n"; |
78 | readMail(); | 78 | readMail(); |
79 | lineShift = "\r\n"; | 79 | lineShift = "\r\n"; |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | EmailClient::~EmailClient() | 84 | EmailClient::~EmailClient() |
85 | { | 85 | { |
86 | //needs to be moved from destructor to closewindow event | 86 | //needs to be moved from destructor to closewindow event |
87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
88 | //does not currently work. Defining outbox in the same | 88 | //does not currently work. Defining outbox in the same |
89 | //format as inbox is not a good solution as they have | 89 | //format as inbox is not a good solution as they have |
90 | //different properties | 90 | //different properties |
91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
92 | saveSettings(); | 92 | saveSettings(); |
93 | 93 | ||
94 | mailconf->write(); | 94 | mailconf->write(); |
95 | delete mailconf; | 95 | delete mailconf; |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void EmailClient::init() | 99 | void EmailClient::init() |
100 | { | 100 | { |
101 | statusBar = new QStatusBar(this); | 101 | statusBar = new QStatusBar(this); |
102 | statusBar->setSizeGripEnabled(FALSE); | 102 | statusBar->setSizeGripEnabled(FALSE); |
103 | 103 | ||
104 | status1Label = new QLabel( tr("Idle"), statusBar); | 104 | status1Label = new QLabel( tr("Idle"), statusBar); |
105 | status2Label = new QLabel("", statusBar); | 105 | status2Label = new QLabel("", statusBar); |
106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
107 | status2Label, SLOT(setText(const QString &)) ); | 107 | status2Label, SLOT(setText(const QString &)) ); |
108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
109 | status2Label, SLOT(setText(const QString &)) ); | 109 | status2Label, SLOT(setText(const QString &)) ); |
110 | 110 | ||
111 | progressBar = new QProgressBar(statusBar); | 111 | progressBar = new QProgressBar(statusBar); |
112 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 112 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
113 | this, SLOT(setTotalSize(int)) ); | 113 | this, SLOT(setTotalSize(int)) ); |
114 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 114 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
115 | this, SLOT(setMailSize(int)) ); | 115 | this, SLOT(setMailSize(int)) ); |
116 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 116 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
117 | this, SLOT(setDownloadedSize(int)) ); | 117 | this, SLOT(setDownloadedSize(int)) ); |
118 | 118 | ||
119 | statusBar->addWidget(status1Label); | 119 | statusBar->addWidget(status1Label); |
120 | statusBar->addWidget(progressBar); | 120 | statusBar->addWidget(progressBar); |
121 | statusBar->addWidget(status2Label); | 121 | statusBar->addWidget(status2Label); |
122 | 122 | ||
123 | setToolBarsMovable(FALSE); | 123 | setToolBarsMovable(FALSE); |
124 | 124 | ||
125 | bar = new QToolBar(this); | 125 | bar = new QToolBar(this); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | mb = new QMenuBar( bar ); | 128 | mb = new QMenuBar( bar ); |
129 | 129 | ||
130 | QPopupMenu *mail = new QPopupMenu(mb); | 130 | QPopupMenu *mail = new QPopupMenu(mb); |
131 | mb->insertItem( tr( "&Mail" ), mail); | 131 | mb->insertItem( tr( "&Mail" ), mail); |
132 | 132 | ||
133 | QPopupMenu *configure = new QPopupMenu(mb); | 133 | QPopupMenu *configure = new QPopupMenu(mb); |
134 | mb->insertItem( tr( "Accounts" ), configure); | 134 | mb->insertItem( tr( "Accounts" ), configure); |
135 | 135 | ||
136 | selectAccountMenu = new QPopupMenu(mb); | 136 | selectAccountMenu = new QPopupMenu(mb); |
137 | editAccountMenu = new QPopupMenu(mb); | 137 | editAccountMenu = new QPopupMenu(mb); |
138 | deleteAccountMenu = new QPopupMenu(mb); | 138 | deleteAccountMenu = new QPopupMenu(mb); |
139 | 139 | ||
140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
141 | configure->insertItem(tr("Edit account"), editAccountMenu); | 141 | configure->insertItem(tr("Edit account"), editAccountMenu); |
142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
143 | 143 | ||
144 | bar = new QToolBar(this); | 144 | bar = new QToolBar(this); |
145 | 145 | ||
146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | 146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); |
147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | 147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); |
148 | getMailButton->addTo(bar); | 148 | getMailButton->addTo(bar); |
149 | getMailButton->addTo(mail); | 149 | getMailButton->addTo(mail); |
150 | 150 | ||
151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); | 151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); |
152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
153 | sendMailButton->addTo(bar); | 153 | sendMailButton->addTo(bar); |
154 | sendMailButton->addTo(mail); | 154 | sendMailButton->addTo(mail); |
155 | 155 | ||
156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
158 | composeButton->addTo(bar); | 158 | composeButton->addTo(bar); |
159 | composeButton->addTo(mail); | 159 | composeButton->addTo(mail); |
160 | 160 | ||
161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("reset"), QString::null, 0, this, 0); | 161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
163 | cancelButton->addTo(mail); | 163 | cancelButton->addTo(mail); |
164 | cancelButton->setEnabled(FALSE); | 164 | cancelButton->setEnabled(FALSE); |
165 | 165 | ||
166 | mailboxView = new QTabWidget( this, "mailboxView" ); | 166 | mailboxView = new OTabWidget( this, "mailboxView" ); |
167 | 167 | ||
168 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 168 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
169 | grid_2 = new QGridLayout( widget ); | 169 | grid_2 = new QGridLayout( widget ); |
170 | // grid_2->setSpacing(6); | 170 | // grid_2->setSpacing(6); |
171 | // grid_2->setMargin( 11 ); | 171 | // grid_2->setMargin( 11 ); |
172 | 172 | ||
173 | inboxView = new QListView( widget, "inboxView" ); | 173 | inboxView = new QListView( widget, "inboxView" ); |
174 | inboxView->addColumn( tr( "From" ) ); | 174 | inboxView->addColumn( tr( "From" ) ); |
175 | inboxView->addColumn( tr( "Subject" ) ); | 175 | inboxView->addColumn( tr( "Subject" ) ); |
176 | inboxView->addColumn( tr( "Date" ) ); | 176 | inboxView->addColumn( tr( "Date" ) ); |
177 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 177 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
178 | inboxView->setAllColumnsShowFocus(TRUE); | 178 | inboxView->setAllColumnsShowFocus(TRUE); |
179 | 179 | ||
180 | grid_2->addWidget( inboxView, 2, 0 ); | 180 | grid_2->addWidget( inboxView, 2, 0 ); |
181 | mailboxView->insertTab( widget, tr( "Inbox" ) ); | 181 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
182 | 182 | ||
183 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 183 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
184 | grid_3 = new QGridLayout( widget_2 ); | 184 | grid_3 = new QGridLayout( widget_2 ); |
185 | // grid_3->setSpacing(6); | 185 | // grid_3->setSpacing(6); |
186 | // grid_3->setMargin( 11 ); | 186 | // grid_3->setMargin( 11 ); |
187 | 187 | ||
188 | outboxView = new QListView( widget_2, "outboxView" ); | 188 | outboxView = new QListView( widget_2, "outboxView" ); |
189 | outboxView->addColumn( tr( "To" ) ); | 189 | outboxView->addColumn( tr( "To" ) ); |
190 | outboxView->addColumn( tr( "Subject" ) ); | 190 | outboxView->addColumn( tr( "Subject" ) ); |
191 | outboxView->setAllColumnsShowFocus(TRUE); | 191 | outboxView->setAllColumnsShowFocus(TRUE); |
192 | 192 | ||
193 | grid_3->addWidget( outboxView, 0, 0 ); | 193 | grid_3->addWidget( outboxView, 0, 0 ); |
194 | mailboxView->insertTab( widget_2, tr( "Outbox" ) ); | 194 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
195 | 195 | ||
196 | setCentralWidget(mailboxView); | 196 | setCentralWidget(mailboxView); |
197 | } | 197 | } |
198 | 198 | ||
199 | void EmailClient::compose() | 199 | void EmailClient::compose() |
200 | { | 200 | { |
201 | emit composeRequested(); | 201 | emit composeRequested(); |
202 | } | 202 | } |
203 | 203 | ||
204 | void EmailClient::cancel() | 204 | void EmailClient::cancel() |
205 | { | 205 | { |
206 | emailHandler->cancel(); | 206 | emailHandler->cancel(); |
207 | } | 207 | } |
208 | 208 | ||
209 | AddressList* EmailClient::getAdrListRef() | 209 | AddressList* EmailClient::getAdrListRef() |
210 | { | 210 | { |
211 | return addressList; | 211 | return addressList; |
212 | } | 212 | } |
213 | 213 | ||
214 | //this needs to be rewritten to syncronize with outboxView | 214 | //this needs to be rewritten to syncronize with outboxView |
215 | void EmailClient::enqueMail(const Email &mail) | 215 | void EmailClient::enqueMail(const Email &mail) |
216 | { | 216 | { |
217 | if (accountList.count() > 0) { | 217 | if (accountList.count() > 0) { |
218 | currentAccount = accountList.first(); | 218 | currentAccount = accountList.first(); |
219 | qWarning("using account " + currentAccount->name); | 219 | qWarning("using account " + currentAccount->name); |
220 | } | 220 | } |
221 | 221 | ||
222 | Email addMail = mail; | 222 | Email addMail = mail; |
223 | addMail.from = currentAccount->name; | 223 | addMail.from = currentAccount->name; |
224 | addMail.fromMail = currentAccount->emailAddress; | 224 | addMail.fromMail = currentAccount->emailAddress; |
225 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 225 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
226 | item = new EmailListItem(outboxView, addMail, false); | 226 | item = new EmailListItem(outboxView, addMail, false); |
227 | 227 | ||
228 | } | 228 | } |
229 | 229 | ||
230 | void EmailClient::sendQuedMail() | 230 | void EmailClient::sendQuedMail() |
231 | { | 231 | { |
232 | int count = 0; | 232 | int count = 0; |
233 | 233 | ||
234 | if (accountList.count() == 0) { | 234 | if (accountList.count() == 0) { |
235 | QMessageBox::warning(qApp->activeWindow(), | 235 | QMessageBox::warning(qApp->activeWindow(), |
236 | "No account selected", "You must create an account", "OK\n"); | 236 | "No account selected", "You must create an account", "OK\n"); |
237 | return; | 237 | return; |
238 | } | 238 | } |
239 | //traverse listview, find messages to send | 239 | //traverse listview, find messages to send |
240 | if (! sending) { | 240 | if (! sending) { |
241 | item = (EmailListItem *) outboxView->firstChild(); | 241 | item = (EmailListItem *) outboxView->firstChild(); |
242 | if (item != NULL) { | 242 | if (item != NULL) { |
243 | while (item != NULL) { | 243 | while (item != NULL) { |
244 | quedMessages.append(item->getMail()); | 244 | quedMessages.append(item->getMail()); |
245 | item = (EmailListItem *) item->nextSibling(); | 245 | item = (EmailListItem *) item->nextSibling(); |
246 | count++; | 246 | count++; |
247 | } | 247 | } |
248 | setMailAccount(); | 248 | setMailAccount(); |
249 | emailHandler->sendMail(&quedMessages); | 249 | emailHandler->sendMail(&quedMessages); |
250 | sending = TRUE; | 250 | sending = TRUE; |
251 | sendMailButton->setEnabled(FALSE); | 251 | sendMailButton->setEnabled(FALSE); |
252 | cancelButton->setEnabled(TRUE); | 252 | cancelButton->setEnabled(TRUE); |
253 | } else { | 253 | } else { |
254 | qWarning("sendQuedMail(): no messages to send"); | 254 | qWarning("sendQuedMail(): no messages to send"); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | void EmailClient::setMailAccount() | 259 | void EmailClient::setMailAccount() |
260 | { | 260 | { |
261 | emailHandler->setAccount(*currentAccount); | 261 | emailHandler->setAccount(*currentAccount); |
262 | } | 262 | } |
263 | 263 | ||
264 | void EmailClient::mailSent() | 264 | void EmailClient::mailSent() |
265 | { | 265 | { |
266 | sending = FALSE; | 266 | sending = FALSE; |
267 | sendMailButton->setEnabled(TRUE); | 267 | sendMailButton->setEnabled(TRUE); |
268 | 268 | ||
269 | quedMessages.clear(); | 269 | quedMessages.clear(); |
270 | outboxView->clear(); //should be moved to an sentBox | 270 | outboxView->clear(); //should be moved to an sentBox |
271 | } | 271 | } |
272 | 272 | ||
273 | void EmailClient::getNewMail() { | 273 | void EmailClient::getNewMail() { |
274 | 274 | ||
275 | if (accountList.count() == 0) { | 275 | if (accountList.count() == 0) { |
276 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 276 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
277 | "You must create an account", "OK\n"); | 277 | "You must create an account", "OK\n"); |
278 | return; | 278 | return; |
279 | } | 279 | } |
280 | 280 | ||
281 | setMailAccount(); | 281 | setMailAccount(); |
282 | 282 | ||
283 | receiving = TRUE; | 283 | receiving = TRUE; |
284 | previewingMail = TRUE; | 284 | previewingMail = TRUE; |
285 | getMailButton->setEnabled(FALSE); | 285 | getMailButton->setEnabled(FALSE); |
286 | cancelButton->setEnabled(TRUE); | 286 | cancelButton->setEnabled(TRUE); |
287 | selectAccountMenu->setEnabled(FALSE); | 287 | selectAccountMenu->setEnabled(FALSE); |
288 | 288 | ||
289 | status1Label->setText(currentAccount->accountName + " headers"); | 289 | status1Label->setText(currentAccount->accountName + " headers"); |
290 | progressBar->reset(); | 290 | progressBar->reset(); |
291 | 291 | ||
292 | //get any previous mails not downloaded and add to queue | 292 | //get any previous mails not downloaded and add to queue |
293 | mailDownloadList.clear(); | 293 | mailDownloadList.clear(); |
294 | Email *mailPtr; | 294 | Email *mailPtr; |
295 | item = (EmailListItem *) inboxView->firstChild(); | 295 | item = (EmailListItem *) inboxView->firstChild(); |
296 | while (item != NULL) { | 296 | while (item != NULL) { |
297 | mailPtr = item->getMail(); | 297 | mailPtr = item->getMail(); |
298 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 298 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
299 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 299 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
300 | } | 300 | } |
301 | item = (EmailListItem *) item->nextSibling(); | 301 | item = (EmailListItem *) item->nextSibling(); |
302 | } | 302 | } |
303 | 303 | ||
304 | emailHandler->getMailHeaders(); | 304 | emailHandler->getMailHeaders(); |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::getAllNewMail() | 307 | void EmailClient::getAllNewMail() |
308 | { | 308 | { |
309 | allAccounts = TRUE; | 309 | allAccounts = TRUE; |
310 | currentAccount = accountList.first(); | 310 | currentAccount = accountList.first(); |
311 | getNewMail(); | 311 | getNewMail(); |
312 | } | 312 | } |
313 | 313 | ||
314 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 314 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
315 | { | 315 | { |
316 | Enclosure *ePtr; | 316 | Enclosure *ePtr; |
317 | Email newMail; | 317 | Email newMail; |
318 | int thisMailId; | 318 | int thisMailId; |
319 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 319 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
320 | 320 | ||
321 | mailconf->setGroup(newMail.id); | 321 | mailconf->setGroup(newMail.id); |
322 | 322 | ||
323 | if (fromDisk) { | 323 | if (fromDisk) { |
324 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 324 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
325 | newMail.size = mailconf->readNumEntry("size"); | 325 | newMail.size = mailconf->readNumEntry("size"); |
326 | newMail.serverId = mailconf->readNumEntry("serverid"); | 326 | newMail.serverId = mailconf->readNumEntry("serverid"); |
327 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 327 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
328 | } else { //mail arrived from server | 328 | } else { //mail arrived from server |
329 | newMail.serverId = mail.serverId; | 329 | newMail.serverId = mail.serverId; |
330 | newMail.size = mail.size; | 330 | newMail.size = mail.size; |
331 | newMail.downloaded = mail.downloaded; | 331 | newMail.downloaded = mail.downloaded; |
332 | 332 | ||
333 | newMail.fromAccountId = currentAccount->id; | 333 | newMail.fromAccountId = currentAccount->id; |
334 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 334 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
335 | } | 335 | } |
336 | 336 | ||
337 | //add if read or not | 337 | //add if read or not |
338 | newMail.read = mailconf->readBoolEntry("mailread"); | 338 | newMail.read = mailconf->readBoolEntry("mailread"); |
339 | 339 | ||
340 | //check if new mail | 340 | //check if new mail |
341 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 341 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
342 | thisMailId = mailIdCount; | 342 | thisMailId = mailIdCount; |
343 | mailIdCount++; | 343 | mailIdCount++; |
344 | 344 | ||
345 | //set server count, so that if the user aborts, the new | 345 | //set server count, so that if the user aborts, the new |
346 | //header is not reloaded | 346 | //header is not reloaded |
347 | if (currentAccount->synchronize) | 347 | if (currentAccount->synchronize) |
348 | currentAccount->lastServerMailCount++; | 348 | currentAccount->lastServerMailCount++; |
349 | 349 | ||
350 | mailconf->writeEntry("internalmailid", thisMailId); | 350 | mailconf->writeEntry("internalmailid", thisMailId); |
351 | mailconf->writeEntry("downloaded", newMail.downloaded); | 351 | mailconf->writeEntry("downloaded", newMail.downloaded); |
352 | mailconf->writeEntry("size", (int) newMail.size); | 352 | mailconf->writeEntry("size", (int) newMail.size); |
353 | mailconf->writeEntry("serverid", newMail.serverId); | 353 | mailconf->writeEntry("serverid", newMail.serverId); |
354 | 354 | ||
355 | addressList->addContact(newMail.fromMail, newMail.from); | 355 | addressList->addContact(newMail.fromMail, newMail.from); |
356 | } else if (!fromDisk) { //body to header arrived | 356 | } else if (!fromDisk) { //body to header arrived |
357 | mailconf->writeEntry("downloaded", TRUE); | 357 | mailconf->writeEntry("downloaded", TRUE); |
358 | } | 358 | } |
359 | QString stringMailId; | 359 | QString stringMailId; |
360 | stringMailId.setNum(thisMailId); | 360 | stringMailId.setNum(thisMailId); |
361 | //se if any attatchments needs to be stored | 361 | //se if any attatchments needs to be stored |
362 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { | 362 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { |
363 | QString stringId; | 363 | QString stringId; |
364 | stringId.setNum(ePtr->id); | 364 | stringId.setNum(ePtr->id); |
365 | 365 | ||
366 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 366 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
367 | if (id != ePtr->id) { //new entry | 367 | if (id != ePtr->id) { //new entry |
368 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 368 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
369 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 369 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
370 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 370 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
371 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 371 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
372 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 372 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
373 | mailconf->writeEntry("installed_" + stringId, FALSE); | 373 | mailconf->writeEntry("installed_" + stringId, FALSE); |
374 | 374 | ||
375 | ePtr->name = stringMailId + "_" + stringId; | 375 | ePtr->name = stringMailId + "_" + stringId; |
376 | ePtr->path = getPath(TRUE); | 376 | ePtr->path = getPath(TRUE); |
377 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 377 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
378 | ePtr->saved = TRUE; | 378 | ePtr->saved = TRUE; |
379 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 379 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
380 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 380 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
381 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 381 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
382 | } else { | 382 | } else { |
383 | ePtr->saved = FALSE; | 383 | ePtr->saved = FALSE; |
384 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 384 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
385 | } | 385 | } |
386 | } else { | 386 | } else { |
387 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 387 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
388 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 388 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
389 | if (ePtr->saved) { | 389 | if (ePtr->saved) { |
390 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 390 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
391 | ePtr->path = mailconf->readEntry("path_" + stringId); | 391 | ePtr->path = mailconf->readEntry("path_" + stringId); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | } | 394 | } |
395 | if (!previewingMail && !fromDisk) { | 395 | if (!previewingMail && !fromDisk) { |
396 | Email *mailPtr; | 396 | Email *mailPtr; |
397 | item = (EmailListItem *) inboxView->firstChild(); | 397 | item = (EmailListItem *) inboxView->firstChild(); |
398 | while (item != NULL) { | 398 | while (item != NULL) { |
399 | mailPtr = item->getMail(); | 399 | mailPtr = item->getMail(); |
400 | if (mailPtr->id == newMail.id) { | 400 | if (mailPtr->id == newMail.id) { |
401 | item->setMail(newMail); | 401 | item->setMail(newMail); |
402 | emit mailUpdated(item->getMail()); | 402 | emit mailUpdated(item->getMail()); |
403 | } | 403 | } |
404 | item = (EmailListItem *) item->nextSibling(); | 404 | item = (EmailListItem *) item->nextSibling(); |
405 | } | 405 | } |
406 | } else { | 406 | } else { |
407 | item = new EmailListItem(inboxView, newMail, TRUE); | 407 | item = new EmailListItem(inboxView, newMail, TRUE); |
408 | if (!newMail.downloaded) | 408 | if (!newMail.downloaded) |
409 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); | 409 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); |
410 | } | 410 | } |
411 | 411 | ||
412 | } | 412 | } |
413 | 413 | ||
414 | void EmailClient::allMailArrived(int count) | 414 | void EmailClient::allMailArrived(int count) |
415 | { | 415 | { |
416 | // not previewing means all mailtransfer has been done | 416 | // not previewing means all mailtransfer has been done |
417 | if (!previewingMail) { | 417 | if (!previewingMail) { |
418 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 418 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
419 | emit newCaption("Mailit - " + currentAccount->accountName); | 419 | emit newCaption("Mailit - " + currentAccount->accountName); |
420 | getNewMail(); | 420 | getNewMail(); |
421 | return; | 421 | return; |
422 | } else { | 422 | } else { |
423 | allAccounts = FALSE; | 423 | allAccounts = FALSE; |
424 | receiving = FALSE; | 424 | receiving = FALSE; |
425 | getMailButton->setEnabled(TRUE); | 425 | getMailButton->setEnabled(TRUE); |
426 | cancelButton->setEnabled(FALSE); | 426 | cancelButton->setEnabled(FALSE); |
427 | selectAccountMenu->setEnabled(TRUE); | 427 | selectAccountMenu->setEnabled(TRUE); |
428 | status1Label->setText("Idle"); | 428 | status1Label->setText("Idle"); |
429 | 429 | ||
430 | progressBar->reset(); | 430 | progressBar->reset(); |
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | // all headers downloaded from server, start downloading remaining mails | 435 | // all headers downloaded from server, start downloading remaining mails |
436 | previewingMail = FALSE; | 436 | previewingMail = FALSE; |
437 | status1Label->setText(currentAccount->accountName); | 437 | status1Label->setText(currentAccount->accountName); |
438 | progressBar->reset(); | 438 | progressBar->reset(); |
439 | 439 | ||
440 | emailHandler->getMailByList(&mailDownloadList); | 440 | emailHandler->getMailByList(&mailDownloadList); |
441 | } | 441 | } |
442 | 442 | ||
443 | void EmailClient::moveMailFront(Email *mailPtr) | 443 | void EmailClient::moveMailFront(Email *mailPtr) |
444 | { | 444 | { |
445 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 445 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
446 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 446 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | void EmailClient::smtpError(int code) | 450 | void EmailClient::smtpError(int code) |
451 | { | 451 | { |
452 | QString temp; | 452 | QString temp; |
453 | 453 | ||
454 | if (code == ErrUnknownResponse) | 454 | if (code == ErrUnknownResponse) |
455 | temp = "Unknown response from server"; | 455 | temp = "Unknown response from server"; |
456 | 456 | ||
457 | if (code == QSocket::ErrHostNotFound) | 457 | if (code == QSocket::ErrHostNotFound) |
458 | temp = "host not found"; | 458 | temp = "host not found"; |
459 | if (code == QSocket::ErrConnectionRefused) | 459 | if (code == QSocket::ErrConnectionRefused) |
460 | temp = "connection refused"; | 460 | temp = "connection refused"; |
461 | if (code == QSocket::ErrSocketRead) | 461 | if (code == QSocket::ErrSocketRead) |
462 | temp = "socket packet error"; | 462 | temp = "socket packet error"; |
463 | 463 | ||
464 | if (code != ErrCancel) { | 464 | if (code != ErrCancel) { |
465 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 465 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
466 | } else { | 466 | } else { |
467 | status2Label->setText("Aborted by user"); | 467 | status2Label->setText("Aborted by user"); |
468 | } | 468 | } |
469 | 469 | ||
470 | sending = FALSE; | 470 | sending = FALSE; |
471 | sendMailButton->setEnabled(TRUE); | 471 | sendMailButton->setEnabled(TRUE); |
472 | cancelButton->setEnabled(FALSE); | 472 | cancelButton->setEnabled(FALSE); |
473 | quedMessages.clear(); | 473 | quedMessages.clear(); |
474 | } | 474 | } |
475 | 475 | ||
476 | void EmailClient::popError(int code) | 476 | void EmailClient::popError(int code) |
477 | { | 477 | { |
478 | QString temp; | 478 | QString temp; |
479 | 479 | ||
480 | if (code == ErrUnknownResponse) | 480 | if (code == ErrUnknownResponse) |
481 | temp = "Unknown response from server"; | 481 | temp = "Unknown response from server"; |
482 | if (code == ErrLoginFailed) | 482 | if (code == ErrLoginFailed) |
483 | temp = "Login failed\nCheck user name and password"; | 483 | temp = "Login failed\nCheck user name and password"; |
484 | 484 | ||
485 | if (code == QSocket::ErrHostNotFound) | 485 | if (code == QSocket::ErrHostNotFound) |
486 | temp = "host not found"; | 486 | temp = "host not found"; |
487 | if (code == QSocket::ErrConnectionRefused) | 487 | if (code == QSocket::ErrConnectionRefused) |
488 | temp = "connection refused"; | 488 | temp = "connection refused"; |
489 | if (code == QSocket::ErrSocketRead) | 489 | if (code == QSocket::ErrSocketRead) |
490 | temp = "socket packet error"; | 490 | temp = "socket packet error"; |
491 | 491 | ||
492 | if (code != ErrCancel) { | 492 | if (code != ErrCancel) { |
493 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 493 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
494 | } else { | 494 | } else { |
495 | status2Label->setText("Aborted by user"); | 495 | status2Label->setText("Aborted by user"); |
496 | } | 496 | } |
497 | 497 | ||
498 | receiving = FALSE; | 498 | receiving = FALSE; |
499 | getMailButton->setEnabled(TRUE); | 499 | getMailButton->setEnabled(TRUE); |
500 | cancelButton->setEnabled(FALSE); | 500 | cancelButton->setEnabled(FALSE); |
501 | selectAccountMenu->setEnabled(TRUE); | 501 | selectAccountMenu->setEnabled(TRUE); |
502 | } | 502 | } |
503 | 503 | ||
504 | void EmailClient::inboxItemSelected() | 504 | void EmailClient::inboxItemSelected() |
505 | { | 505 | { |
506 | item = (EmailListItem*) inboxView->selectedItem(); | 506 | item = (EmailListItem*) inboxView->selectedItem(); |
507 | if (item != NULL) { | 507 | if (item != NULL) { |
508 | emit viewEmail(inboxView, item->getMail()); | 508 | emit viewEmail(inboxView, item->getMail()); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | void EmailClient::outboxItemSelected() | 512 | void EmailClient::outboxItemSelected() |
513 | { | 513 | { |
514 | item = (EmailListItem*) outboxView->selectedItem(); | 514 | item = (EmailListItem*) outboxView->selectedItem(); |
515 | if (item != NULL) { | 515 | if (item != NULL) { |
516 | emit viewEmail(outboxView, item->getMail()); | 516 | emit viewEmail(outboxView, item->getMail()); |
517 | } | 517 | } |
518 | 518 | ||
519 | } | 519 | } |
520 | 520 | ||
521 | void EmailClient::readMail() | 521 | void EmailClient::readMail() |
522 | { | 522 | { |
523 | Email mail; | 523 | Email mail; |
524 | int start, stop; | 524 | int start, stop; |
525 | QString s, del; | 525 | QString s, del; |
526 | 526 | ||
527 | QFile f(getPath(FALSE) + "inbox.txt"); | 527 | QFile f(getPath(FALSE) + "inbox.txt"); |
528 | // QFileInfo fi(f); | 528 | // QFileInfo fi(f); |
529 | qDebug( f.name()); | 529 | qDebug( f.name()); |
530 | 530 | ||
531 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 531 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
532 | QTextStream t( &f ); // use a text stream | 532 | QTextStream t( &f ); // use a text stream |
533 | s = t.read(); | 533 | s = t.read(); |
534 | f.close(); | 534 | f.close(); |
535 | 535 | ||
536 | start = 0; | 536 | start = 0; |
537 | del = "\n.\n"; | 537 | del = "\n.\n"; |
538 | while ((uint) start < s.length()) { | 538 | while ((uint) start < s.length()) { |
539 | stop = s.find(del, start); | 539 | stop = s.find(del, start); |
540 | if (stop == -1) | 540 | if (stop == -1) |
541 | stop = s.length() - del.length(); | 541 | stop = s.length() - del.length(); |
542 | 542 | ||
543 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 543 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
544 | start = stop + del.length(); | 544 | start = stop + del.length(); |
545 | mailArrived(mail, TRUE); | 545 | mailArrived(mail, TRUE); |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | QFile fo(getPath(FALSE) + "outbox.txt"); | 549 | QFile fo(getPath(FALSE) + "outbox.txt"); |
550 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 550 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
551 | QTextStream t( &fo ); // use a text stream | 551 | QTextStream t( &fo ); // use a text stream |
552 | s = t.read(); | 552 | s = t.read(); |
553 | fo.close(); | 553 | fo.close(); |
554 | 554 | ||
555 | start = 0; | 555 | start = 0; |
556 | del = "\n.\n"; | 556 | del = "\n.\n"; |
557 | while ((uint) start < s.length()) { | 557 | while ((uint) start < s.length()) { |
558 | stop = s.find(del, start); | 558 | stop = s.find(del, start); |
559 | if (stop == -1) | 559 | if (stop == -1) |
560 | stop = s.length() - del.length(); | 560 | stop = s.length() - del.length(); |
561 | 561 | ||
562 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 562 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
563 | start = stop + del.length(); | 563 | start = stop + del.length(); |
564 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 564 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
565 | mail.sent = false; | 565 | mail.sent = false; |
566 | mail.received = false; | 566 | mail.received = false; |
567 | enqueMail(mail); | 567 | enqueMail(mail); |
568 | 568 | ||
569 | } | 569 | } |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | void EmailClient::saveMail(QString fileName, QListView *view) | 573 | void EmailClient::saveMail(QString fileName, QListView *view) |
574 | { | 574 | { |
575 | QFile f(fileName); | 575 | QFile f(fileName); |
576 | Email *mail; | 576 | Email *mail; |
577 | 577 | ||
578 | if (! f.open(IO_WriteOnly) ) { | 578 | if (! f.open(IO_WriteOnly) ) { |
579 | qWarning("could not open file"); | 579 | qWarning("could not open file"); |
580 | return; | 580 | return; |
581 | } | 581 | } |
582 | item = (EmailListItem *) view->firstChild(); | 582 | item = (EmailListItem *) view->firstChild(); |
583 | qDebug (QString("Write : ") ); | 583 | qDebug (QString("Write : ") ); |
584 | QTextStream t(&f); | 584 | QTextStream t(&f); |
585 | while (item != NULL) { | 585 | while (item != NULL) { |
586 | mail = item->getMail(); | 586 | mail = item->getMail(); |
587 | qDebug(mail->rawMail); | 587 | qDebug(mail->rawMail); |
588 | qDebug(mail->recipients.first()); | 588 | qDebug(mail->recipients.first()); |
589 | t << mail->rawMail; | 589 | t << mail->rawMail; |
590 | 590 | ||
591 | mailconf->setGroup(mail->id); | 591 | mailconf->setGroup(mail->id); |
592 | mailconf->writeEntry("mailread", mail->read); | 592 | mailconf->writeEntry("mailread", mail->read); |
593 | 593 | ||
594 | item = (EmailListItem *) item->nextSibling(); | 594 | item = (EmailListItem *) item->nextSibling(); |
595 | } | 595 | } |
596 | f.close(); | 596 | f.close(); |
597 | } | 597 | } |
598 | 598 | ||
599 | //paths for mailit, is settings, inbox, enclosures | 599 | //paths for mailit, is settings, inbox, enclosures |
600 | QString EmailClient::getPath(bool enclosurePath) | 600 | QString EmailClient::getPath(bool enclosurePath) |
601 | { | 601 | { |
602 | QString basePath = "qtmail"; | 602 | QString basePath = "qtmail"; |
603 | QString enclosures = "enclosures"; | 603 | QString enclosures = "enclosures"; |
604 | 604 | ||
605 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 605 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
606 | if ( !dir.exists() ) | 606 | if ( !dir.exists() ) |
607 | dir.mkdir( dir.path() ); | 607 | dir.mkdir( dir.path() ); |
608 | 608 | ||
609 | if (enclosurePath) { | 609 | if (enclosurePath) { |
610 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 610 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
611 | 611 | ||
612 | if ( !dir.exists() ) | 612 | if ( !dir.exists() ) |
613 | dir.mkdir( dir.path() ); | 613 | dir.mkdir( dir.path() ); |
614 | 614 | ||
615 | return (dir.path() + "/"); | 615 | return (dir.path() + "/"); |
616 | 616 | ||
617 | } | 617 | } |
618 | return (dir.path() + "/"); | 618 | return (dir.path() + "/"); |
619 | } | 619 | } |
620 | 620 | ||
621 | void EmailClient::readSettings() | 621 | void EmailClient::readSettings() |
622 | { | 622 | { |
623 | TextParser *p; | 623 | TextParser *p; |
624 | QString s; | 624 | QString s; |
625 | int pos, accountPos, y; | 625 | int pos, accountPos, y; |
626 | QFile f( getPath(FALSE) + "settings.txt"); | 626 | QFile f( getPath(FALSE) + "settings.txt"); |
627 | 627 | ||
628 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 628 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
629 | QTextStream t( &f ); // use a text stream | 629 | QTextStream t( &f ); // use a text stream |
630 | s = t.read(); | 630 | s = t.read(); |
631 | f.close(); | 631 | f.close(); |
632 | 632 | ||
633 | p = new TextParser(s, "\n"); | 633 | p = new TextParser(s, "\n"); |
634 | 634 | ||
635 | accountPos = 0; | 635 | accountPos = 0; |
636 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { | 636 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { |
637 | accountPos++; | 637 | accountPos++; |
638 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) | 638 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) |
639 | account.accountName = p->getString(& ++pos, 'z', TRUE); | 639 | account.accountName = p->getString(& ++pos, 'z', TRUE); |
640 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) | 640 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) |
641 | account.name = p->getString(& ++pos, 'z', TRUE); | 641 | account.name = p->getString(& ++pos, 'z', TRUE); |
642 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | 642 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) |
643 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | 643 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); |
644 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 644 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
645 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 645 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
646 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 646 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
647 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 647 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
648 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 648 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
649 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 649 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
650 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 650 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
651 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 651 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 652 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
653 | s = p->getString(& ++pos, 'z', TRUE); | 653 | s = p->getString(& ++pos, 'z', TRUE); |
654 | account.id = s.toInt(); | 654 | account.id = s.toInt(); |
655 | } | 655 | } |
656 | 656 | ||
657 | account.lastServerMailCount = 0; | 657 | account.lastServerMailCount = 0; |
658 | account.synchronize = FALSE; | 658 | account.synchronize = FALSE; |
659 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 659 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
660 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 660 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
661 | account.synchronize = TRUE; | 661 | account.synchronize = TRUE; |
662 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 662 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
663 | s = p->getString(& ++pos, 'z', TRUE); | 663 | s = p->getString(& ++pos, 'z', TRUE); |
664 | account.lastServerMailCount = s.toInt(); | 664 | account.lastServerMailCount = s.toInt(); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | } | 667 | } |
668 | accountList.append(&account); | 668 | accountList.append(&account); |
669 | } | 669 | } |
670 | delete p; | 670 | delete p; |
671 | } | 671 | } |
672 | mailconf->setGroup("mailitglobal"); | 672 | mailconf->setGroup("mailitglobal"); |
673 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 673 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
674 | mailIdCount = y; | 674 | mailIdCount = y; |
675 | } | 675 | } |
676 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 676 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
677 | accountIdCount = y; | 677 | accountIdCount = y; |
678 | } | 678 | } |
679 | } | 679 | } |
680 | 680 | ||
681 | void EmailClient::saveSettings() | 681 | void EmailClient::saveSettings() |
682 | { | 682 | { |
683 | QString temp; | 683 | QString temp; |
684 | QFile f( getPath(FALSE) + "settings.txt"); | 684 | QFile f( getPath(FALSE) + "settings.txt"); |
685 | MailAccount *accountPtr; | 685 | MailAccount *accountPtr; |
686 | 686 | ||
687 | if (! f.open(IO_WriteOnly) ) { | 687 | if (! f.open(IO_WriteOnly) ) { |
688 | qWarning("could not save settings file"); | 688 | qWarning("could not save settings file"); |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | QTextStream t(&f); | 691 | QTextStream t(&f); |
692 | t << "#Settings for QPE Mailit program\n"; | 692 | t << "#Settings for QPE Mailit program\n"; |
693 | 693 | ||
694 | for (accountPtr = accountList.first(); accountPtr != 0; | 694 | for (accountPtr = accountList.first(); accountPtr != 0; |
695 | accountPtr = accountList.next()) { | 695 | accountPtr = accountList.next()) { |
696 | 696 | ||
697 | t << "accountStart;\n"; | 697 | t << "accountStart;\n"; |
698 | t << "AccountName: " + accountPtr->accountName + "\n"; | 698 | t << "AccountName: " + accountPtr->accountName + "\n"; |
699 | t << "Name: " + accountPtr->name + "\n"; | 699 | t << "Name: " + accountPtr->name + "\n"; |
700 | t << "Email: " + accountPtr->emailAddress + "\n"; | 700 | t << "Email: " + accountPtr->emailAddress + "\n"; |
701 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 701 | t << "POPUser: " + accountPtr->popUserName + "\n"; |
702 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 702 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; |
703 | t << "POPServer: " + accountPtr->popServer + "\n"; | 703 | t << "POPServer: " + accountPtr->popServer + "\n"; |
704 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 704 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; |
705 | t << "AccountId: " << accountPtr->id << "\n"; | 705 | t << "AccountId: " << accountPtr->id << "\n"; |
706 | if (accountPtr->synchronize) { | 706 | if (accountPtr->synchronize) { |
707 | t << "Synchronize: Yes\n"; | 707 | t << "Synchronize: Yes\n"; |
708 | t << "LastServerMailCount: "; | 708 | t << "LastServerMailCount: "; |
709 | t << accountPtr->lastServerMailCount << "\n"; | 709 | t << accountPtr->lastServerMailCount << "\n"; |
710 | } else { | 710 | } else { |
711 | t << "Synchronize: No\n"; | 711 | t << "Synchronize: No\n"; |
712 | } | 712 | } |
713 | t << "accountEnd;\n"; | 713 | t << "accountEnd;\n"; |
714 | } | 714 | } |
715 | f.close(); | 715 | f.close(); |
716 | 716 | ||
717 | mailconf->setGroup("mailitglobal"); | 717 | mailconf->setGroup("mailitglobal"); |
718 | mailconf->writeEntry("mailidcount", mailIdCount); | 718 | mailconf->writeEntry("mailidcount", mailIdCount); |
719 | mailconf->writeEntry("accountidcount", accountIdCount); | 719 | mailconf->writeEntry("accountidcount", accountIdCount); |
720 | } | 720 | } |
721 | 721 | ||
722 | void EmailClient::selectAccount(int id) | 722 | void EmailClient::selectAccount(int id) |
723 | { | 723 | { |
724 | if (accountList.count() > 0) { | 724 | if (accountList.count() > 0) { |
725 | currentAccount = accountList.at(id); | 725 | currentAccount = accountList.at(id); |
726 | emit newCaption("Mailit - " + currentAccount->accountName); | 726 | emit newCaption("Mailit - " + currentAccount->accountName); |
727 | getNewMail(); | 727 | getNewMail(); |
728 | } else { | 728 | } else { |
729 | emit newCaption("Mailit ! No account defined"); | 729 | emit newCaption("Mailit ! No account defined"); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | 732 | ||
733 | void EmailClient::editAccount(int id) | 733 | void EmailClient::editAccount(int id) |
734 | { | 734 | { |
735 | MailAccount *newAccount; | 735 | MailAccount *newAccount; |
736 | 736 | ||
737 | editAccountView = new EditAccount(this, "account", TRUE); | 737 | editAccountView = new EditAccount(this, "account", TRUE); |
738 | if (id == newAccountId) { //new account | 738 | if (id == newAccountId) { //new account |
739 | newAccount = new MailAccount; | 739 | newAccount = new MailAccount; |
740 | editAccountView->setAccount(newAccount); | 740 | editAccountView->setAccount(newAccount); |
741 | } else { | 741 | } else { |
742 | newAccount = accountList.at(id); | 742 | newAccount = accountList.at(id); |
743 | editAccountView->setAccount(newAccount, FALSE); | 743 | editAccountView->setAccount(newAccount, FALSE); |
744 | } | 744 | } |
745 | 745 | ||
746 | editAccountView->showMaximized(); | 746 | editAccountView->showMaximized(); |
747 | editAccountView->exec(); | 747 | editAccountView->exec(); |
748 | 748 | ||
749 | if (editAccountView->result() == QDialog::Accepted) { | 749 | if (editAccountView->result() == QDialog::Accepted) { |
750 | if (id == newAccountId) { | 750 | if (id == newAccountId) { |
751 | newAccount->id = accountIdCount; | 751 | newAccount->id = accountIdCount; |
752 | accountIdCount++; | 752 | accountIdCount++; |
753 | accountList.append(newAccount); | 753 | accountList.append(newAccount); |
754 | updateAccounts(); | 754 | updateAccounts(); |
755 | } else { | 755 | } else { |
756 | updateAccounts(); | 756 | updateAccounts(); |
757 | } | 757 | } |
758 | } | 758 | } |
759 | 759 | ||
760 | delete editAccountView; | 760 | delete editAccountView; |
761 | } | 761 | } |
762 | 762 | ||
763 | void EmailClient::deleteAccount(int id) | 763 | void EmailClient::deleteAccount(int id) |
764 | { | 764 | { |
765 | MailAccount *newAccount; | 765 | MailAccount *newAccount; |
766 | QString message; | 766 | QString message; |
767 | 767 | ||
768 | newAccount = accountList.at(id); | 768 | newAccount = accountList.at(id); |
769 | message = "Delete account:\n" + newAccount->accountName; | 769 | message = "Delete account:\n" + newAccount->accountName; |
770 | switch( QMessageBox::warning( this, "Mailit", message, | 770 | switch( QMessageBox::warning( this, "Mailit", message, |
771 | "Yes", "No", 0, 0, 1 ) ) { | 771 | "Yes", "No", 0, 0, 1 ) ) { |
772 | 772 | ||
773 | case 0: accountList.remove(id); | 773 | case 0: accountList.remove(id); |
774 | updateAccounts(); | 774 | updateAccounts(); |
775 | break; | 775 | break; |
776 | case 1: | 776 | case 1: |
777 | break; | 777 | break; |
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | void EmailClient::updateAccounts() | 781 | void EmailClient::updateAccounts() |
782 | { | 782 | { |
783 | MailAccount *accountPtr; | 783 | MailAccount *accountPtr; |
784 | 784 | ||
785 | //rebuild menus, clear all first | 785 | //rebuild menus, clear all first |
786 | editAccountMenu->clear(); | 786 | editAccountMenu->clear(); |
787 | selectAccountMenu->clear(); | 787 | selectAccountMenu->clear(); |
788 | deleteAccountMenu->clear(); | 788 | deleteAccountMenu->clear(); |
789 | 789 | ||
790 | newAccountId = editAccountMenu->insertItem("New", this, | 790 | newAccountId = editAccountMenu->insertItem("New", this, |
791 | SLOT(editAccount(int)) ); | 791 | SLOT(editAccount(int)) ); |
792 | editAccountMenu->insertSeparator(); | 792 | editAccountMenu->insertSeparator(); |
793 | 793 | ||
794 | idCount = 0; | 794 | idCount = 0; |
795 | for (accountPtr = accountList.first(); accountPtr != 0; | 795 | for (accountPtr = accountList.first(); accountPtr != 0; |
796 | accountPtr = accountList.next()) { | 796 | accountPtr = accountList.next()) { |
797 | 797 | ||
798 | editAccountMenu->insertItem(accountPtr->accountName, | 798 | editAccountMenu->insertItem(accountPtr->accountName, |
799 | this, SLOT(editAccount(int)), 0, idCount); | 799 | this, SLOT(editAccount(int)), 0, idCount); |
800 | selectAccountMenu->insertItem(accountPtr->accountName, | 800 | selectAccountMenu->insertItem(accountPtr->accountName, |
801 | this, SLOT(selectAccount(int)), 0, idCount); | 801 | this, SLOT(selectAccount(int)), 0, idCount); |
802 | deleteAccountMenu->insertItem(accountPtr->accountName, | 802 | deleteAccountMenu->insertItem(accountPtr->accountName, |
803 | this, SLOT(deleteAccount(int)), 0, idCount); | 803 | this, SLOT(deleteAccount(int)), 0, idCount); |
804 | idCount++; | 804 | idCount++; |
805 | } | 805 | } |
806 | } | 806 | } |
807 | 807 | ||
808 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 808 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
809 | { | 809 | { |
810 | Email *mPtr; | 810 | Email *mPtr; |
811 | Enclosure *ePtr; | 811 | Enclosure *ePtr; |
812 | 812 | ||
813 | if (inbox) { | 813 | if (inbox) { |
814 | mPtr = mailItem->getMail(); | 814 | mPtr = mailItem->getMail(); |
815 | 815 | ||
816 | //if mail is in queue for download, remove it from | 816 | //if mail is in queue for download, remove it from |
817 | //queue if possible | 817 | //queue if possible |
818 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 818 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
819 | if ( !mPtr->downloaded ) | 819 | if ( !mPtr->downloaded ) |
820 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 820 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
821 | } | 821 | } |
822 | 822 | ||
823 | mailconf->setGroup(mPtr->id); | 823 | mailconf->setGroup(mPtr->id); |
824 | mailconf->clearGroup(); | 824 | mailconf->clearGroup(); |
825 | 825 | ||
826 | //delete any temporary attatchemnts storing | 826 | //delete any temporary attatchemnts storing |
827 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 827 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
828 | if (ePtr->saved) { | 828 | if (ePtr->saved) { |
829 | QFile::remove( (ePtr->path + ePtr->name) ); | 829 | QFile::remove( (ePtr->path + ePtr->name) ); |
830 | } | 830 | } |
831 | } | 831 | } |
832 | inboxView->takeItem(mailItem); | 832 | inboxView->takeItem(mailItem); |
833 | } else { | 833 | } else { |
834 | outboxView->takeItem(mailItem); | 834 | outboxView->takeItem(mailItem); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void EmailClient::setMailSize(int size) | 838 | void EmailClient::setMailSize(int size) |
839 | { | 839 | { |
840 | progressBar->reset(); | 840 | progressBar->reset(); |
841 | progressBar->setTotalSteps(size); | 841 | progressBar->setTotalSteps(size); |
842 | } | 842 | } |
843 | 843 | ||
844 | void EmailClient::setTotalSize(int size) | 844 | void EmailClient::setTotalSize(int size) |
845 | { | 845 | { |
846 | 846 | ||
847 | } | 847 | } |
848 | 848 | ||
849 | void EmailClient::setDownloadedSize(int size) | 849 | void EmailClient::setDownloadedSize(int size) |
850 | { | 850 | { |
851 | int total = progressBar->totalSteps(); | 851 | int total = progressBar->totalSteps(); |
852 | 852 | ||
853 | if (size < total) { | 853 | if (size < total) { |
854 | progressBar->setProgress(size); | 854 | progressBar->setProgress(size); |
855 | } else { | 855 | } else { |
856 | progressBar->setProgress(total); | 856 | progressBar->setProgress(total); |
857 | } | 857 | } |
858 | } | 858 | } |
diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h index 135bfaa..80457f9 100644 --- a/noncore/unsupported/mailit/emailclient.h +++ b/noncore/unsupported/mailit/emailclient.h | |||
@@ -1,149 +1,149 @@ | |||
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 | #ifndef EMAILCLIENT_H | 20 | #ifndef EMAILCLIENT_H |
21 | #define EMAILCLIENT_H | 21 | #define EMAILCLIENT_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qtabwidget.h> | ||
33 | #include <qaction.h> | 32 | #include <qaction.h> |
34 | #include <qlayout.h> | 33 | #include <qlayout.h> |
35 | #include <qtooltip.h> | 34 | #include <qtooltip.h> |
36 | #include <qimage.h> | 35 | #include <qimage.h> |
37 | #include <qpixmap.h> | 36 | #include <qpixmap.h> |
38 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
39 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
40 | #include <qstatusbar.h> | 39 | #include <qstatusbar.h> |
41 | #include <qdir.h> | 40 | #include <qdir.h> |
42 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <opie/otabwidget.h> | ||
43 | 43 | ||
44 | #include "emailhandler.h" | 44 | #include "emailhandler.h" |
45 | #include "emaillistitem.h" | 45 | #include "emaillistitem.h" |
46 | #include "textparser.h" | 46 | #include "textparser.h" |
47 | #include "editaccount.h" | 47 | #include "editaccount.h" |
48 | #include "maillist.h" | 48 | #include "maillist.h" |
49 | #include "addresslist.h" | 49 | #include "addresslist.h" |
50 | 50 | ||
51 | #include <qpe/config.h> | 51 | #include <qpe/config.h> |
52 | 52 | ||
53 | class AccountList : public QList<MailAccount> | 53 | class AccountList : public QList<MailAccount> |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | Item newItem(Item d); | 56 | Item newItem(Item d); |
57 | private: | 57 | private: |
58 | MailAccount* dupl(MailAccount *in); | 58 | MailAccount* dupl(MailAccount *in); |
59 | MailAccount *ac; | 59 | MailAccount *ac; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | //class EmailClient : public EmailClientBase | 62 | //class EmailClient : public EmailClientBase |
63 | class EmailClient : public QMainWindow | 63 | class EmailClient : public QMainWindow |
64 | { | 64 | { |
65 | Q_OBJECT | 65 | Q_OBJECT |
66 | 66 | ||
67 | public: | 67 | public: |
68 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); | 68 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); |
69 | ~EmailClient(); | 69 | ~EmailClient(); |
70 | AddressList* getAdrListRef(); | 70 | AddressList* getAdrListRef(); |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void composeRequested(); | 73 | void composeRequested(); |
74 | void viewEmail(QListView *, Email *); | 74 | void viewEmail(QListView *, Email *); |
75 | void mailUpdated(Email *); | 75 | void mailUpdated(Email *); |
76 | void newCaption(const QString &); | 76 | void newCaption(const QString &); |
77 | 77 | ||
78 | public slots: | 78 | public slots: |
79 | void compose(); | 79 | void compose(); |
80 | void cancel(); | 80 | void cancel(); |
81 | void enqueMail(const Email &mail); | 81 | void enqueMail(const Email &mail); |
82 | void setMailAccount(); | 82 | void setMailAccount(); |
83 | void sendQuedMail(); | 83 | void sendQuedMail(); |
84 | void mailSent(); | 84 | void mailSent(); |
85 | void getNewMail(); | 85 | void getNewMail(); |
86 | void getAllNewMail(); | 86 | void getAllNewMail(); |
87 | void smtpError(int code); | 87 | void smtpError(int code); |
88 | void popError(int code); | 88 | void popError(int code); |
89 | void inboxItemSelected(); | 89 | void inboxItemSelected(); |
90 | void outboxItemSelected(); | 90 | void outboxItemSelected(); |
91 | void mailArrived(const Email &mail, bool fromDisk); | 91 | void mailArrived(const Email &mail, bool fromDisk); |
92 | void allMailArrived(int); | 92 | void allMailArrived(int); |
93 | void saveMail(QString fileName, QListView *view); | 93 | void saveMail(QString fileName, QListView *view); |
94 | void selectAccount(int); | 94 | void selectAccount(int); |
95 | void editAccount(int); | 95 | void editAccount(int); |
96 | void updateAccounts(); | 96 | void updateAccounts(); |
97 | void deleteAccount(int); | 97 | void deleteAccount(int); |
98 | void deleteMail(EmailListItem *mailItem, bool &inbox); | 98 | void deleteMail(EmailListItem *mailItem, bool &inbox); |
99 | void setTotalSize(int); | 99 | void setTotalSize(int); |
100 | void setMailSize(int); | 100 | void setMailSize(int); |
101 | void setDownloadedSize(int); | 101 | void setDownloadedSize(int); |
102 | void moveMailFront(Email *mailPtr); | 102 | void moveMailFront(Email *mailPtr); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | void init(); | 105 | void init(); |
106 | void readMail(); | 106 | void readMail(); |
107 | QString getPath(bool enclosurePath); | 107 | QString getPath(bool enclosurePath); |
108 | void readSettings(); | 108 | void readSettings(); |
109 | void saveSettings(); | 109 | void saveSettings(); |
110 | 110 | ||
111 | private: | 111 | private: |
112 | Config *mailconf; | 112 | Config *mailconf; |
113 | int newAccountId, idCount, mailIdCount; | 113 | int newAccountId, idCount, mailIdCount; |
114 | int accountIdCount; | 114 | int accountIdCount; |
115 | AccountList accountList; | 115 | AccountList accountList; |
116 | AddressList *addressList; | 116 | AddressList *addressList; |
117 | 117 | ||
118 | EditAccount *editAccountView; | 118 | EditAccount *editAccountView; |
119 | EmailListItem *item; | 119 | EmailListItem *item; |
120 | EmailHandler *emailHandler; | 120 | EmailHandler *emailHandler; |
121 | QList<Email> quedMessages; | 121 | QList<Email> quedMessages; |
122 | MailList mailDownloadList; | 122 | MailList mailDownloadList; |
123 | bool sending, receiving, previewingMail, allAccounts; | 123 | bool sending, receiving, previewingMail, allAccounts; |
124 | QString lineShift; | 124 | QString lineShift; |
125 | MailAccount account, *currentAccount; | 125 | MailAccount account, *currentAccount; |
126 | 126 | ||
127 | QToolBar *bar; | 127 | QToolBar *bar; |
128 | QProgressBar *progressBar; | 128 | QProgressBar *progressBar; |
129 | QStatusBar *statusBar; | 129 | QStatusBar *statusBar; |
130 | QLabel *status1Label, *status2Label; | 130 | QLabel *status1Label, *status2Label; |
131 | QAction *getMailButton; | 131 | QAction *getMailButton; |
132 | QAction *sendMailButton; | 132 | QAction *sendMailButton; |
133 | QAction *composeButton; | 133 | QAction *composeButton; |
134 | QAction *cancelButton; | 134 | QAction *cancelButton; |
135 | 135 | ||
136 | QMenuBar *mb; | 136 | QMenuBar *mb; |
137 | QPopupMenu *selectAccountMenu; | 137 | QPopupMenu *selectAccountMenu; |
138 | QPopupMenu *editAccountMenu; | 138 | QPopupMenu *editAccountMenu; |
139 | QPopupMenu *deleteAccountMenu; | 139 | QPopupMenu *deleteAccountMenu; |
140 | 140 | ||
141 | QTabWidget* mailboxView; | 141 | OTabWidget* mailboxView; |
142 | QListView* inboxView; | 142 | QListView* inboxView; |
143 | QListView* outboxView; | 143 | QListView* outboxView; |
144 | 144 | ||
145 | QGridLayout* grid_2; | 145 | QGridLayout* grid_2; |
146 | QGridLayout* grid_3; | 146 | QGridLayout* grid_3; |
147 | }; | 147 | }; |
148 | 148 | ||
149 | #endif // EMAILCLIENT_H | 149 | #endif // EMAILCLIENT_H |
diff --git a/noncore/unsupported/mailit/mailit.pro b/noncore/unsupported/mailit/mailit.pro index d51126a..a404884 100644 --- a/noncore/unsupported/mailit/mailit.pro +++ b/noncore/unsupported/mailit/mailit.pro | |||
@@ -1,43 +1,43 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = emailclient.h \ | 3 | HEADERS = emailclient.h \ |
4 | emailhandler.h \ | 4 | emailhandler.h \ |
5 | emaillistitem.h \ | 5 | emaillistitem.h \ |
6 | mailitwindow.h \ | 6 | mailitwindow.h \ |
7 | md5.h \ | 7 | md5.h \ |
8 | popclient.h \ | 8 | popclient.h \ |
9 | readmail.h \ | 9 | readmail.h \ |
10 | smtpclient.h \ | 10 | smtpclient.h \ |
11 | writemail.h \ | 11 | writemail.h \ |
12 | textparser.h \ | 12 | textparser.h \ |
13 | viewatt.h \ | 13 | viewatt.h \ |
14 | addatt.h \ | 14 | addatt.h \ |
15 | editaccount.h \ | 15 | editaccount.h \ |
16 | maillist.h \ | 16 | maillist.h \ |
17 | addresslist.h | 17 | addresslist.h |
18 | SOURCES = emailclient.cpp \ | 18 | SOURCES = emailclient.cpp \ |
19 | emailhandler.cpp \ | 19 | emailhandler.cpp \ |
20 | emaillistitem.cpp \ | 20 | emaillistitem.cpp \ |
21 | mailitwindow.cpp \ | 21 | mailitwindow.cpp \ |
22 | main.cpp \ | 22 | main.cpp \ |
23 | md5.c \ | 23 | md5.c \ |
24 | popclient.cpp \ | 24 | popclient.cpp \ |
25 | readmail.cpp \ | 25 | readmail.cpp \ |
26 | smtpclient.cpp \ | 26 | smtpclient.cpp \ |
27 | writemail.cpp \ | 27 | writemail.cpp \ |
28 | textparser.cpp \ | 28 | textparser.cpp \ |
29 | viewatt.cpp \ | 29 | viewatt.cpp \ |
30 | addatt.cpp \ | 30 | addatt.cpp \ |
31 | editaccount.cpp \ | 31 | editaccount.cpp \ |
32 | maillist.cpp \ | 32 | maillist.cpp \ |
33 | addresslist.cpp | 33 | addresslist.cpp |
34 | 34 | ||
35 | INCLUDEPATH += $(OPIEDIR)/include | 35 | INCLUDEPATH += $(OPIEDIR)/include |
36 | DEPENDPATH += $(OPIEDIR)/include | 36 | DEPENDPATH += $(OPIEDIR)/include |
37 | LIBS += -lqpe | 37 | LIBS += -lqpe -lopie |
38 | # -lssl | 38 | # -lssl |
39 | MOC_DIR=qpeobj | 39 | MOC_DIR=qpeobj |
40 | OBJECTS_DIR=qpeobj | 40 | OBJECTS_DIR=qpeobj |
41 | DESTDIR=$(OPIEDIR)/bin | 41 | DESTDIR=$(OPIEDIR)/bin |
42 | 42 | ||
43 | include ( $(OPIEDIR)/include.pro ) | 43 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp index 4954f34..2011ecf 100644 --- a/noncore/unsupported/mailit/readmail.cpp +++ b/noncore/unsupported/mailit/readmail.cpp | |||
@@ -1,326 +1,326 @@ | |||
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 "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include "resource.h" | 24 | #include "resource.h" |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "pass" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | ||
63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
65 | previousButton->addTo(bar); | 65 | previousButton->addTo(bar); |
66 | previousButton->addTo(viewMenu); | 66 | previousButton->addTo(viewMenu); |
67 | 67 | ||
68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
70 | nextButton->addTo(bar); | 70 | nextButton->addTo(bar); |
71 | nextButton->addTo(viewMenu); | 71 | nextButton->addTo(viewMenu); |
72 | 72 | ||
73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
74 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 74 | connect( attatchmentsButton, SIGNAL( activated() ), this, |
75 | SLOT( viewAttatchments() ) ); | 75 | SLOT( viewAttatchments() ) ); |
76 | attatchmentsButton->addTo(bar); | 76 | attatchmentsButton->addTo(bar); |
77 | attatchmentsButton->addTo(viewMenu); | 77 | attatchmentsButton->addTo(viewMenu); |
78 | 78 | ||
79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0, TRUE); | 79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
81 | plainTextButton->addTo(bar); | 81 | plainTextButton->addTo(bar); |
82 | plainTextButton->addTo(viewMenu); | 82 | plainTextButton->addTo(viewMenu); |
83 | 83 | ||
84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
86 | deleteButton->addTo(bar); | 86 | deleteButton->addTo(bar); |
87 | deleteButton->addTo(mailMenu); | 87 | deleteButton->addTo(mailMenu); |
88 | 88 | ||
89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
90 | 90 | ||
91 | emailView = new QTextView( this, "emailView" ); | 91 | emailView = new QTextView( this, "emailView" ); |
92 | setCentralWidget(emailView); | 92 | setCentralWidget(emailView); |
93 | 93 | ||
94 | mime = new QMimeSourceFactory(); | 94 | mime = new QMimeSourceFactory(); |
95 | emailView->setMimeSourceFactory(mime); | 95 | emailView->setMimeSourceFactory(mime); |
96 | } | 96 | } |
97 | 97 | ||
98 | void ReadMail::updateView() | 98 | void ReadMail::updateView() |
99 | { | 99 | { |
100 | Enclosure *ePtr; | 100 | Enclosure *ePtr; |
101 | QString mailStringSize; | 101 | QString mailStringSize; |
102 | QString text, temp; | 102 | QString text, temp; |
103 | 103 | ||
104 | mail->read = TRUE; //mark as read | 104 | mail->read = TRUE; //mark as read |
105 | inbox = mail->received; | 105 | inbox = mail->received; |
106 | 106 | ||
107 | replyButton->removeFrom(mailMenu); | 107 | replyButton->removeFrom(mailMenu); |
108 | replyButton->removeFrom(bar); | 108 | replyButton->removeFrom(bar); |
109 | 109 | ||
110 | if (inbox == TRUE) { | 110 | if (inbox == TRUE) { |
111 | replyButton->addTo(bar); | 111 | replyButton->addTo(bar); |
112 | replyButton->addTo(mailMenu); | 112 | replyButton->addTo(mailMenu); |
113 | 113 | ||
114 | if (!mail->downloaded) { | 114 | if (!mail->downloaded) { |
115 | //report currently viewed mail so that it will be | 115 | //report currently viewed mail so that it will be |
116 | //placed first in the queue of new mails to download | 116 | //placed first in the queue of new mails to download |
117 | emit viewingMail(mail); | 117 | emit viewingMail(mail); |
118 | 118 | ||
119 | double mailSize = (double) mail->size; | 119 | double mailSize = (double) mail->size; |
120 | if (mailSize < 1024) { | 120 | if (mailSize < 1024) { |
121 | mailStringSize.setNum(mailSize); | 121 | mailStringSize.setNum(mailSize); |
122 | mailStringSize += " Bytes"; | 122 | mailStringSize += " Bytes"; |
123 | } else if (mailSize < 1024*1024) { | 123 | } else if (mailSize < 1024*1024) { |
124 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 124 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
125 | mailStringSize += " Kb"; | 125 | mailStringSize += " Kb"; |
126 | } else { | 126 | } else { |
127 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 127 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
128 | mailStringSize += " Mb"; | 128 | mailStringSize += " Mb"; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 133 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
134 | 134 | ||
135 | if (! plainTxt) { //use RichText, inline pics etc. | 135 | if (! plainTxt) { //use RichText, inline pics etc. |
136 | emailView->setTextFormat(QTextView::RichText); | 136 | emailView->setTextFormat(QTextView::RichText); |
137 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 137 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
138 | +"</font></center></big></b><br>"; | 138 | +"</font></center></big></b><br>"; |
139 | text += "<b>From: </b>" + mail->from + " <i>" + | 139 | text += "<b>From: </b>" + mail->from + " <i>" + |
140 | mail->fromMail + "</i><br>"; | 140 | mail->fromMail + "</i><br>"; |
141 | 141 | ||
142 | text +="<b>To: </b>"; | 142 | text +="<b>To: </b>"; |
143 | for (QStringList::Iterator it = mail->recipients.begin(); | 143 | for (QStringList::Iterator it = mail->recipients.begin(); |
144 | it != mail->recipients.end(); ++it ) { | 144 | it != mail->recipients.end(); ++it ) { |
145 | text += *it + " "; | 145 | text += *it + " "; |
146 | } | 146 | } |
147 | text += "<br>" + mail->date; | 147 | text += "<br>" + mail->date; |
148 | 148 | ||
149 | if (mail->files.count() > 0) { | 149 | if (mail->files.count() > 0) { |
150 | text += "<br><b>Attatchments: </b>"; | 150 | text += "<br><b>Attatchments: </b>"; |
151 | 151 | ||
152 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 152 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
153 | text += ePtr->originalName + " "; | 153 | text += ePtr->originalName + " "; |
154 | } | 154 | } |
155 | text += "<hr><br>" + mail->body; | 155 | text += "<hr><br>" + mail->body; |
156 | 156 | ||
157 | if (inbox) { | 157 | if (inbox) { |
158 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 158 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
159 | 159 | ||
160 | text += "<br><hr><b>Attatchment: </b>" + | 160 | text += "<br><hr><b>Attatchment: </b>" + |
161 | ePtr->originalName + "<hr>"; | 161 | ePtr->originalName + "<hr>"; |
162 | 162 | ||
163 | if (ePtr->contentType == "TEXT") { | 163 | if (ePtr->contentType == "TEXT") { |
164 | QFile f(ePtr->path + ePtr->name); | 164 | QFile f(ePtr->path + ePtr->name); |
165 | 165 | ||
166 | if (f.open(IO_ReadOnly) ) { | 166 | if (f.open(IO_ReadOnly) ) { |
167 | QTextStream t(&f); | 167 | QTextStream t(&f); |
168 | temp = t.read(); | 168 | temp = t.read(); |
169 | text += temp + "<br>"; | 169 | text += temp + "<br>"; |
170 | f.close(); | 170 | f.close(); |
171 | } else { | 171 | } else { |
172 | text += "<b>Could not locate file</b><br>"; | 172 | text += "<b>Could not locate file</b><br>"; |
173 | } | 173 | } |
174 | 174 | ||
175 | } | 175 | } |
176 | if (ePtr->contentType == "IMAGE") { | 176 | if (ePtr->contentType == "IMAGE") { |
177 | // temp.setNum(emailView->width());//get display width | 177 | // temp.setNum(emailView->width());//get display width |
178 | // text += "<img width=" + temp +" src =""" + | 178 | // text += "<img width=" + temp +" src =""" + |
179 | // ePtr->originalName + """> </img>"; | 179 | // ePtr->originalName + """> </img>"; |
180 | text += "<img src =""" + | 180 | text += "<img src =""" + |
181 | ePtr->originalName + """> </img>"; | 181 | ePtr->originalName + """> </img>"; |
182 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 182 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | if (mail->downloaded || !inbox) { | 187 | if (mail->downloaded || !inbox) { |
188 | text += "<hr><br>" + mail->body; | 188 | text += "<hr><br>" + mail->body; |
189 | } else { | 189 | } else { |
190 | text += "<hr><br><b> Awaiting download </b><br>"; | 190 | text += "<hr><br><b> Awaiting download </b><br>"; |
191 | text += "Size of mail: " + mailStringSize; | 191 | text += "Size of mail: " + mailStringSize; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | emailView->setText(text); | 194 | emailView->setText(text); |
195 | } else { // show plain txt mail | 195 | } else { // show plain txt mail |
196 | emailView->setTextFormat(QTextView::PlainText); | 196 | emailView->setTextFormat(QTextView::PlainText); |
197 | text = "Subject: " + mail->subject + "\n"; | 197 | text = "Subject: " + mail->subject + "\n"; |
198 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; | 198 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; |
199 | text += "To: "; | 199 | text += "To: "; |
200 | for (QStringList::Iterator it = mail->recipients.begin(); | 200 | for (QStringList::Iterator it = mail->recipients.begin(); |
201 | it != mail->recipients.end(); ++it ) { | 201 | it != mail->recipients.end(); ++it ) { |
202 | text += *it + " "; | 202 | text += *it + " "; |
203 | } | 203 | } |
204 | text += "\nDate: " + mail->date + "\n"; | 204 | text += "\nDate: " + mail->date + "\n"; |
205 | if (mail->files.count() > 0) { | 205 | if (mail->files.count() > 0) { |
206 | text += "Attatchments: "; | 206 | text += "Attatchments: "; |
207 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 207 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
208 | text += ePtr->originalName + " "; | 208 | text += ePtr->originalName + " "; |
209 | } | 209 | } |
210 | text += "\n\n"; | 210 | text += "\n\n"; |
211 | } else text += "\n"; | 211 | } else text += "\n"; |
212 | 212 | ||
213 | if (!inbox) { | 213 | if (!inbox) { |
214 | text += mail->body; | 214 | text += mail->body; |
215 | } else if (mail->downloaded) { | 215 | } else if (mail->downloaded) { |
216 | text += mail->bodyPlain; | 216 | text += mail->bodyPlain; |
217 | } else { | 217 | } else { |
218 | text += "\nAwaiting download\n"; | 218 | text += "\nAwaiting download\n"; |
219 | text += "Size of mail: " + mailStringSize; | 219 | text += "Size of mail: " + mailStringSize; |
220 | } | 220 | } |
221 | 221 | ||
222 | emailView->setText(text); | 222 | emailView->setText(text); |
223 | } | 223 | } |
224 | 224 | ||
225 | if (mail->files.count() == 0) | 225 | if (mail->files.count() == 0) |
226 | attatchmentsButton->setEnabled(FALSE); | 226 | attatchmentsButton->setEnabled(FALSE); |
227 | else attatchmentsButton->setEnabled(TRUE); | 227 | else attatchmentsButton->setEnabled(TRUE); |
228 | 228 | ||
229 | setCaption("Examining mail: " + mail->subject); | 229 | setCaption("Examining mail: " + mail->subject); |
230 | } | 230 | } |
231 | 231 | ||
232 | //update view with current EmailListItem (item) | 232 | //update view with current EmailListItem (item) |
233 | void ReadMail::update(QListView *thisView, Email *mailIn) | 233 | void ReadMail::update(QListView *thisView, Email *mailIn) |
234 | { | 234 | { |
235 | view = thisView; | 235 | view = thisView; |
236 | item = (EmailListItem *) view->selectedItem(); | 236 | item = (EmailListItem *) view->selectedItem(); |
237 | mail = mailIn; | 237 | mail = mailIn; |
238 | updateView(); | 238 | updateView(); |
239 | updateButtons(); | 239 | updateButtons(); |
240 | } | 240 | } |
241 | 241 | ||
242 | void ReadMail::mailUpdated(Email *mailIn) | 242 | void ReadMail::mailUpdated(Email *mailIn) |
243 | { | 243 | { |
244 | if (mailIn == mail) { | 244 | if (mailIn == mail) { |
245 | updateView(); | 245 | updateView(); |
246 | } else { | 246 | } else { |
247 | updateButtons(); | 247 | updateButtons(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void ReadMail::close() | 251 | void ReadMail::close() |
252 | { | 252 | { |
253 | emit cancelView(); | 253 | emit cancelView(); |
254 | } | 254 | } |
255 | 255 | ||
256 | //gets next item in listview, exits if there is no next | 256 | //gets next item in listview, exits if there is no next |
257 | void ReadMail::next() | 257 | void ReadMail::next() |
258 | { | 258 | { |
259 | item = (EmailListItem *) item->nextSibling(); | 259 | item = (EmailListItem *) item->nextSibling(); |
260 | if (item != NULL) { | 260 | if (item != NULL) { |
261 | mail = item->getMail(); | 261 | mail = item->getMail(); |
262 | updateView(); | 262 | updateView(); |
263 | } | 263 | } |
264 | updateButtons(); | 264 | updateButtons(); |
265 | } | 265 | } |
266 | 266 | ||
267 | //gets previous item in listview, exits if there is no previous | 267 | //gets previous item in listview, exits if there is no previous |
268 | void ReadMail::previous() | 268 | void ReadMail::previous() |
269 | { | 269 | { |
270 | item = (EmailListItem *) item->itemAbove(); | 270 | item = (EmailListItem *) item->itemAbove(); |
271 | if (item != NULL) { | 271 | if (item != NULL) { |
272 | mail = item->getMail(); | 272 | mail = item->getMail(); |
273 | updateView(); | 273 | updateView(); |
274 | } | 274 | } |
275 | updateButtons(); | 275 | updateButtons(); |
276 | } | 276 | } |
277 | 277 | ||
278 | //deletes item, tries bringing up next or previous, exits if unsucessful | 278 | //deletes item, tries bringing up next or previous, exits if unsucessful |
279 | void ReadMail::deleteItem() | 279 | void ReadMail::deleteItem() |
280 | { | 280 | { |
281 | EmailListItem *temp = item; | 281 | EmailListItem *temp = item; |
282 | temp = (EmailListItem *) item->nextSibling();//trybelow | 282 | temp = (EmailListItem *) item->nextSibling();//trybelow |
283 | if (temp == NULL) | 283 | if (temp == NULL) |
284 | temp = (EmailListItem *) item->itemAbove(); //try above | 284 | temp = (EmailListItem *) item->itemAbove(); //try above |
285 | 285 | ||
286 | emit removeItem(item, inbox); | 286 | emit removeItem(item, inbox); |
287 | 287 | ||
288 | item = temp; | 288 | item = temp; |
289 | if (item != NULL) { //more items in list | 289 | if (item != NULL) { //more items in list |
290 | mail = item->getMail(); | 290 | mail = item->getMail(); |
291 | updateView(); | 291 | updateView(); |
292 | updateButtons(); | 292 | updateButtons(); |
293 | } else close(); //no more items to see | 293 | } else close(); //no more items to see |
294 | } | 294 | } |
295 | 295 | ||
296 | void ReadMail::updateButtons() | 296 | void ReadMail::updateButtons() |
297 | { | 297 | { |
298 | EmailListItem *temp; | 298 | EmailListItem *temp; |
299 | 299 | ||
300 | temp = item; | 300 | temp = item; |
301 | if ((EmailListItem *) temp->nextSibling() == NULL) | 301 | if ((EmailListItem *) temp->nextSibling() == NULL) |
302 | nextButton->setEnabled(FALSE); | 302 | nextButton->setEnabled(FALSE); |
303 | else nextButton->setEnabled(TRUE); | 303 | else nextButton->setEnabled(TRUE); |
304 | 304 | ||
305 | temp = item; | 305 | temp = item; |
306 | if ((EmailListItem *) temp->itemAbove() == NULL) | 306 | if ((EmailListItem *) temp->itemAbove() == NULL) |
307 | previousButton->setEnabled(FALSE); | 307 | previousButton->setEnabled(FALSE); |
308 | else previousButton->setEnabled(TRUE); | 308 | else previousButton->setEnabled(TRUE); |
309 | } | 309 | } |
310 | 310 | ||
311 | void ReadMail::shiftText() | 311 | void ReadMail::shiftText() |
312 | { | 312 | { |
313 | plainTxt = ! plainTxt; | 313 | plainTxt = ! plainTxt; |
314 | updateView(); | 314 | updateView(); |
315 | } | 315 | } |
316 | 316 | ||
317 | void ReadMail::viewAttatchments() | 317 | void ReadMail::viewAttatchments() |
318 | { | 318 | { |
319 | viewAtt->update(mail, inbox); | 319 | viewAtt->update(mail, inbox); |
320 | viewAtt->showMaximized(); | 320 | viewAtt->showMaximized(); |
321 | } | 321 | } |
322 | 322 | ||
323 | void ReadMail::reply() | 323 | void ReadMail::reply() |
324 | { | 324 | { |
325 | emit replyRequested(*mail); | 325 | emit replyRequested(*mail); |
326 | } | 326 | } |