-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 2cedc51..b039cc4 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -1,1032 +1,1036 @@ | |||
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 <qvbox.h> | 22 | #include <qvbox.h> |
23 | #include <qfile.h> | 23 | #include <qfile.h> |
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qaction.h> | 26 | #include <qaction.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include "emailclient.h" | 29 | #include "emailclient.h" |
30 | #include "writemail.h" | 30 | #include "writemail.h" |
31 | 31 | ||
32 | QCollection::Item AccountList::newItem(QCollection::Item d) | 32 | QCollection::Item AccountList::newItem(QCollection::Item d) |
33 | { | 33 | { |
34 | return dupl( (MailAccount *) d); | 34 | return dupl( (MailAccount *) d); |
35 | } | 35 | } |
36 | 36 | ||
37 | MailAccount* AccountList::dupl(MailAccount *in) | 37 | MailAccount* AccountList::dupl(MailAccount *in) |
38 | { | 38 | { |
39 | ac = new MailAccount(*in); | 39 | ac = new MailAccount(*in); |
40 | return ac; | 40 | return ac; |
41 | } | 41 | } |
42 | 42 | ||
43 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 43 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
44 | : QMainWindow( parent, name, fl ) | 44 | : QMainWindow( parent, name, fl ) |
45 | { | 45 | { |
46 | emailHandler = new EmailHandler(); | 46 | emailHandler = new EmailHandler(); |
47 | addressList = new AddressList(); | 47 | addressList = new AddressList(); |
48 | 48 | ||
49 | sending = FALSE; | 49 | sending = FALSE; |
50 | receiving = FALSE; | 50 | receiving = FALSE; |
51 | previewingMail = FALSE; | 51 | previewingMail = FALSE; |
52 | mailIdCount = 1; | 52 | mailIdCount = 1; |
53 | accountIdCount = 1; | 53 | accountIdCount = 1; |
54 | allAccounts = FALSE; | 54 | allAccounts = FALSE; |
55 | 55 | ||
56 | init(); | 56 | init(); |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 60 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
61 | 61 | ||
62 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 62 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
63 | SLOT(smtpError(int)) ); | 63 | SLOT(smtpError(int)) ); |
64 | connect(emailHandler, SIGNAL(popError(int)), this, | 64 | connect(emailHandler, SIGNAL(popError(int)), this, |
65 | SLOT(popError(int)) ); | 65 | SLOT(popError(int)) ); |
66 | 66 | ||
67 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 67 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
69 | 69 | ||
70 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | 70 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); |
71 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | 71 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); |
72 | 72 | ||
73 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 73 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
74 | SLOT(mailArrived(const Email &, bool)) ); | 74 | SLOT(mailArrived(const Email &, bool)) ); |
75 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 75 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
76 | SLOT(allMailArrived(int)) ); | 76 | SLOT(allMailArrived(int)) ); |
77 | 77 | ||
78 | mailconf = new Config("mailit"); | 78 | mailconf = new Config("mailit"); |
79 | //In case Synchronize is not defined in settings.txt | 79 | //In case Synchronize is not defined in settings.txt |
80 | 80 | ||
81 | readSettings(); | 81 | readSettings(); |
82 | 82 | ||
83 | updateAccounts(); | 83 | updateAccounts(); |
84 | 84 | ||
85 | lineShift = "\n"; | 85 | lineShift = "\n"; |
86 | readMail(); | 86 | readMail(); |
87 | lineShift = "\r\n"; | 87 | lineShift = "\r\n"; |
88 | 88 | ||
89 | mailboxView->setCurrentTab(0); //ensure that inbox has focus | 89 | mailboxView->setCurrentTab(0); //ensure that inbox has focus |
90 | 90 | ||
91 | /*channel = new QCopChannel( "QPE/Application/mailit", this ); | 91 | /*channel = new QCopChannel( "QPE/Application/mailit", this ); |
92 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 92 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
93 | this, SLOT(receive(const QCString&, const QByteArray&)) );*/ | 93 | this, SLOT(receive(const QCString&, const QByteArray&)) );*/ |
94 | 94 | ||
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | EmailClient::~EmailClient() | 98 | EmailClient::~EmailClient() |
99 | { | 99 | { |
100 | //needs to be moved from destructor to closewindow event | 100 | //needs to be moved from destructor to closewindow event |
101 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 101 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
102 | //does not currently work. Defining outbox in the same | 102 | //does not currently work. Defining outbox in the same |
103 | //format as inbox is not a good solution as they have | 103 | //format as inbox is not a good solution as they have |
104 | //different properties | 104 | //different properties |
105 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 105 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
106 | saveSettings(); | 106 | saveSettings(); |
107 | 107 | ||
108 | mailconf->write(); | 108 | mailconf->write(); |
109 | delete mailconf; | 109 | delete mailconf; |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | void EmailClient::init() | 113 | void EmailClient::init() |
114 | { | 114 | { |
115 | initStatusBar(this); | 115 | initStatusBar(this); |
116 | 116 | ||
117 | setToolBarsMovable(FALSE); | 117 | setToolBarsMovable(FALSE); |
118 | 118 | ||
119 | bar = new QToolBar(this); | 119 | bar = new QToolBar(this); |
120 | QWhatsThis::add(bar,tr("Main operation toolbar")); | 120 | QWhatsThis::add(bar,tr("Main operation toolbar")); |
121 | bar->setHorizontalStretchable( TRUE ); | 121 | bar->setHorizontalStretchable( TRUE ); |
122 | 122 | ||
123 | mb = new QMenuBar( bar ); | 123 | mb = new QMenuBar( bar ); |
124 | 124 | ||
125 | QPopupMenu *mail = new QPopupMenu(mb); | 125 | QPopupMenu *mail = new QPopupMenu(mb); |
126 | mb->insertItem( tr( "&Mail" ), mail); | 126 | mb->insertItem( tr( "&Mail" ), mail); |
127 | 127 | ||
128 | QPopupMenu *configure = new QPopupMenu(mb); | 128 | QPopupMenu *configure = new QPopupMenu(mb); |
129 | mb->insertItem( tr( "Accounts" ), configure); | 129 | mb->insertItem( tr( "Accounts" ), configure); |
130 | 130 | ||
131 | selectAccountMenu = new QPopupMenu(mb); | 131 | selectAccountMenu = new QPopupMenu(mb); |
132 | editAccountMenu = new QPopupMenu(mb); | 132 | editAccountMenu = new QPopupMenu(mb); |
133 | deleteAccountMenu = new QPopupMenu(mb); | 133 | deleteAccountMenu = new QPopupMenu(mb); |
134 | 134 | ||
135 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 135 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
136 | configure->insertItem(tr("Edit account"), editAccountMenu); | 136 | configure->insertItem(tr("Edit account"), editAccountMenu); |
137 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 137 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
138 | 138 | ||
139 | bar = new QToolBar(this); | 139 | bar = new QToolBar(this); |
140 | 140 | ||
141 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); | 141 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
142 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); | 142 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); |
143 | 143 | ||
144 | getMailButton->setPopup(selectAccountMenu); | 144 | getMailButton->setPopup(selectAccountMenu); |
145 | 145 | ||
146 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 146 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
147 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 147 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
148 | sendMailButton->addTo(bar); | 148 | sendMailButton->addTo(bar); |
149 | sendMailButton->addTo(mail); | 149 | sendMailButton->addTo(mail); |
150 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); | 150 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); |
151 | 151 | ||
152 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 152 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
153 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 153 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
154 | composeButton->addTo(bar); | 154 | composeButton->addTo(bar); |
155 | composeButton->addTo(mail); | 155 | composeButton->addTo(mail); |
156 | composeButton->setWhatsThis("Compose a new mail"); | 156 | composeButton->setWhatsThis("Compose a new mail"); |
157 | 157 | ||
158 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 158 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
159 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 159 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
160 | cancelButton->addTo(mail); | 160 | cancelButton->addTo(mail); |
161 | cancelButton->addTo(bar); | 161 | cancelButton->addTo(bar); |
162 | cancelButton->setEnabled(FALSE); | 162 | cancelButton->setEnabled(FALSE); |
163 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); | 163 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); |
164 | 164 | ||
165 | 165 | ||
166 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 166 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
167 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 167 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
168 | deleteButton->addTo(bar); | 168 | deleteButton->addTo(bar); |
169 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); | 169 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); |
170 | 170 | ||
171 | mailboxView = new OTabWidget( this, "mailboxView" ); | 171 | mailboxView = new OTabWidget( this, "mailboxView" ); |
172 | 172 | ||
173 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 173 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
174 | grid_2 = new QGridLayout( widget ); | 174 | grid_2 = new QGridLayout( widget ); |
175 | // grid_2->setSpacing(6); | 175 | // grid_2->setSpacing(6); |
176 | // grid_2->setMargin( 11 ); | 176 | // grid_2->setMargin( 11 ); |
177 | 177 | ||
178 | inboxView = new QListView( widget, "inboxView" ); | 178 | inboxView = new QListView( widget, "inboxView" ); |
179 | inboxView->addColumn( tr( "From" ) ); | 179 | inboxView->addColumn( tr( "From" ) ); |
180 | inboxView->addColumn( tr( "Subject" ) ); | 180 | inboxView->addColumn( tr( "Subject" ) ); |
181 | inboxView->addColumn( tr( "Date" ) ); | 181 | inboxView->addColumn( tr( "Date" ) ); |
182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
183 | inboxView->setAllColumnsShowFocus(TRUE); | 183 | inboxView->setAllColumnsShowFocus(TRUE); |
184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" | 184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" |
185 | "It keeps the fetched mail which can be \n" | 185 | "It keeps the fetched mail which can be \n" |
186 | "viewed by double clicking the entry.\n" | 186 | "viewed by double clicking the entry.\n" |
187 | "blue attachment icon shows whether this \n" | 187 | "blue attachment icon shows whether this \n" |
188 | "mailhas attachments.\n")); | 188 | "mailhas attachments.\n")); |
189 | 189 | ||
190 | grid_2->addWidget( inboxView, 2, 0 ); | 190 | grid_2->addWidget( inboxView, 2, 0 ); |
191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
192 | 192 | ||
193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
194 | grid_3 = new QGridLayout( widget_2 ); | 194 | grid_3 = new QGridLayout( widget_2 ); |
195 | // grid_3->setSpacing(6); | 195 | // grid_3->setSpacing(6); |
196 | // grid_3->setMargin( 11 ); | 196 | // grid_3->setMargin( 11 ); |
197 | 197 | ||
198 | outboxView = new QListView( widget_2, "outboxView" ); | 198 | outboxView = new QListView( widget_2, "outboxView" ); |
199 | outboxView->addColumn( tr( "To" ) ); | 199 | outboxView->addColumn( tr( "To" ) ); |
200 | outboxView->addColumn( tr( "Subject" ) ); | 200 | outboxView->addColumn( tr( "Subject" ) ); |
201 | outboxView->setAllColumnsShowFocus(TRUE); | 201 | outboxView->setAllColumnsShowFocus(TRUE); |
202 | 202 | ||
203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" | 203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" |
204 | "It keeps the queued mails to send which can be \n" | 204 | "It keeps the queued mails to send which can be \n" |
205 | "reviewed by double clicking the entry.")); | 205 | "reviewed by double clicking the entry.")); |
206 | grid_3->addWidget( outboxView, 0, 0 ); | 206 | grid_3->addWidget( outboxView, 0, 0 ); |
207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
208 | 208 | ||
209 | setCentralWidget(mailboxView); | 209 | setCentralWidget(mailboxView); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void EmailClient::initStatusBar(QWidget* parent) | 213 | void EmailClient::initStatusBar(QWidget* parent) |
214 | { | 214 | { |
215 | statusBar = new QStatusBar(parent); | 215 | statusBar = new QStatusBar(parent); |
216 | statusBar->setSizeGripEnabled(FALSE); | 216 | statusBar->setSizeGripEnabled(FALSE); |
217 | 217 | ||
218 | status1Label = new QLabel( tr("Idle"), statusBar); | 218 | status1Label = new QLabel( tr("Idle"), statusBar); |
219 | status2Label = new QLabel("", statusBar); | 219 | status2Label = new QLabel("", statusBar); |
220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
221 | status2Label, SLOT(setText(const QString &)) ); | 221 | status2Label, SLOT(setText(const QString &)) ); |
222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
223 | status2Label, SLOT(setText(const QString &)) ); | 223 | status2Label, SLOT(setText(const QString &)) ); |
224 | 224 | ||
225 | progressBar = new QProgressBar(statusBar); | 225 | progressBar = new QProgressBar(statusBar); |
226 | 226 | ||
227 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 227 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
228 | this, SLOT(setTotalSize(int)) ); | 228 | this, SLOT(setTotalSize(int)) ); |
229 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 229 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
230 | this, SLOT(setMailSize(int)) ); | 230 | this, SLOT(setMailSize(int)) ); |
231 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 231 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
232 | this, SLOT(setDownloadedSize(int)) ); | 232 | this, SLOT(setDownloadedSize(int)) ); |
233 | 233 | ||
234 | statusBar->addWidget(status1Label); | 234 | statusBar->addWidget(status1Label); |
235 | statusBar->addWidget(progressBar); | 235 | statusBar->addWidget(progressBar); |
236 | statusBar->addWidget(status2Label); | 236 | statusBar->addWidget(status2Label); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void EmailClient::compose() | 240 | void EmailClient::compose() |
241 | { | 241 | { |
242 | emit composeRequested(); | 242 | emit composeRequested(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void EmailClient::cancel() | 245 | void EmailClient::cancel() |
246 | { | 246 | { |
247 | emailHandler->cancel(); | 247 | emailHandler->cancel(); |
248 | } | 248 | } |
249 | 249 | ||
250 | AddressList* EmailClient::getAdrListRef() | 250 | AddressList* EmailClient::getAdrListRef() |
251 | { | 251 | { |
252 | return addressList; | 252 | return addressList; |
253 | } | 253 | } |
254 | 254 | ||
255 | //this needs to be rewritten to syncronize with outboxView | 255 | //this needs to be rewritten to syncronize with outboxView |
256 | void EmailClient::enqueMail(const Email &mail) | 256 | void EmailClient::enqueMail(const Email &mail) |
257 | { | 257 | { |
258 | if (accountList.count() == 0) { | 258 | if (accountList.count() == 0) { |
259 | QMessageBox::warning(qApp->activeWindow(), | 259 | QMessageBox::warning(qApp->activeWindow(), |
260 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 260 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | if (accountList.count() > 0) { | 264 | if (accountList.count() > 0) { |
265 | currentAccount = accountList.first(); | 265 | currentAccount = accountList.first(); |
266 | qWarning("using account " + currentAccount->name); | 266 | qWarning("using account " + currentAccount->name); |
267 | } | 267 | } |
268 | 268 | ||
269 | Email addMail = mail; | 269 | Email addMail = mail; |
270 | addMail.from = currentAccount->name; | 270 | addMail.from = currentAccount->name; |
271 | addMail.fromMail = currentAccount->emailAddress; | 271 | addMail.fromMail = currentAccount->emailAddress; |
272 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 272 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
273 | item = new EmailListItem(outboxView, addMail, false); | 273 | item = new EmailListItem(outboxView, addMail, false); |
274 | 274 | ||
275 | mailboxView->setCurrentTab(1); | 275 | mailboxView->setCurrentTab(1); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | void EmailClient::sendQuedMail() | 279 | void EmailClient::sendQuedMail() |
280 | { | 280 | { |
281 | int count = 0; | 281 | int count = 0; |
282 | 282 | ||
283 | if (accountList.count() == 0) { | 283 | if (accountList.count() == 0) { |
284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | //traverse listview, find messages to send | 287 | //traverse listview, find messages to send |
288 | if (! sending) { | 288 | if (! sending) { |
289 | item = (EmailListItem *) outboxView->firstChild(); | 289 | item = (EmailListItem *) outboxView->firstChild(); |
290 | if (item != NULL) { | 290 | if (item != NULL) { |
291 | while (item != NULL) { | 291 | while (item != NULL) { |
292 | quedMessages.append(item->getMail()); | 292 | quedMessages.append(item->getMail()); |
293 | item = (EmailListItem *) item->nextSibling(); | 293 | item = (EmailListItem *) item->nextSibling(); |
294 | count++; | 294 | count++; |
295 | } | 295 | } |
296 | setMailAccount(); | 296 | setMailAccount(); |
297 | emailHandler->sendMail(&quedMessages); | 297 | emailHandler->sendMail(&quedMessages); |
298 | sending = TRUE; | 298 | sending = TRUE; |
299 | sendMailButton->setEnabled(FALSE); | 299 | sendMailButton->setEnabled(FALSE); |
300 | cancelButton->setEnabled(TRUE); | 300 | cancelButton->setEnabled(TRUE); |
301 | } else { | 301 | } else { |
302 | qWarning("sendQuedMail(): no messages to send"); | 302 | qWarning("sendQuedMail(): no messages to send"); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::setMailAccount() | 307 | void EmailClient::setMailAccount() |
308 | { | 308 | { |
309 | emailHandler->setAccount(*currentAccount); | 309 | emailHandler->setAccount(*currentAccount); |
310 | } | 310 | } |
311 | 311 | ||
312 | void EmailClient::mailSent() | 312 | void EmailClient::mailSent() |
313 | { | 313 | { |
314 | sending = FALSE; | 314 | sending = FALSE; |
315 | sendMailButton->setEnabled(TRUE); | 315 | sendMailButton->setEnabled(TRUE); |
316 | 316 | ||
317 | quedMessages.clear(); | 317 | quedMessages.clear(); |
318 | outboxView->clear(); //should be moved to an sentBox | 318 | outboxView->clear(); //should be moved to an sentBox |
319 | } | 319 | } |
320 | 320 | ||
321 | void EmailClient::getNewMail() { | 321 | void EmailClient::getNewMail() { |
322 | 322 | ||
323 | if (accountList.count() == 0) { | 323 | if (accountList.count() == 0) { |
324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
325 | "You must create an account", "OK\n"); | 325 | "You must create an account", "OK\n"); |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | 328 | ||
329 | setMailAccount(); | 329 | setMailAccount(); |
330 | 330 | ||
331 | receiving = TRUE; | 331 | receiving = TRUE; |
332 | previewingMail = TRUE; | 332 | previewingMail = TRUE; |
333 | getMailButton->setEnabled(FALSE); | 333 | getMailButton->setEnabled(FALSE); |
334 | cancelButton->setEnabled(TRUE); | 334 | cancelButton->setEnabled(TRUE); |
335 | selectAccountMenu->setEnabled(FALSE); | 335 | selectAccountMenu->setEnabled(FALSE); |
336 | 336 | ||
337 | status1Label->setText(currentAccount->accountName + " headers"); | 337 | status1Label->setText(currentAccount->accountName + " headers"); |
338 | progressBar->reset(); | 338 | progressBar->reset(); |
339 | 339 | ||
340 | //get any previous mails not downloaded and add to queue | 340 | //get any previous mails not downloaded and add to queue |
341 | /*mailDownloadList.clear(); | 341 | /*mailDownloadList.clear(); |
342 | Email *mailPtr; | 342 | Email *mailPtr; |
343 | item = (EmailListItem *) inboxView->firstChild(); | 343 | item = (EmailListItem *) inboxView->firstChild(); |
344 | while (item != NULL) { | 344 | while (item != NULL) { |
345 | mailPtr = item->getMail(); | 345 | mailPtr = item->getMail(); |
346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
348 | } | 348 | } |
349 | item = (EmailListItem *) item->nextSibling(); | 349 | item = (EmailListItem *) item->nextSibling(); |
350 | }*/ | 350 | }*/ |
351 | 351 | ||
352 | emailHandler->getMailHeaders(); | 352 | emailHandler->getMailHeaders(); |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void EmailClient::getAllNewMail() | 356 | void EmailClient::getAllNewMail() |
357 | { | 357 | { |
358 | allAccounts = TRUE; | 358 | allAccounts = TRUE; |
359 | currentAccount = accountList.first(); | 359 | currentAccount = accountList.first(); |
360 | getNewMail(); | 360 | getNewMail(); |
361 | } | 361 | } |
362 | 362 | ||
363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
364 | { | 364 | { |
365 | Enclosure *ePtr; | 365 | Enclosure *ePtr; |
366 | Email newMail; | 366 | Email newMail; |
367 | int thisMailId; | 367 | int thisMailId; |
368 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 368 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
369 | mailconf->setGroup(newMail.id); | 369 | mailconf->setGroup(newMail.id); |
370 | 370 | ||
371 | if (fromDisk) | 371 | if (fromDisk) |
372 | { | 372 | { |
373 | 373 | ||
374 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 374 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
375 | newMail.size = mailconf->readNumEntry("size"); | 375 | newMail.size = mailconf->readNumEntry("size"); |
376 | newMail.serverId = mailconf->readNumEntry("serverid"); | 376 | newMail.serverId = mailconf->readNumEntry("serverid"); |
377 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 377 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
378 | } | 378 | } |
379 | else | 379 | else |
380 | { //mail arrived from server | 380 | { //mail arrived from server |
381 | 381 | ||
382 | newMail.serverId = mail.serverId; | 382 | newMail.serverId = mail.serverId; |
383 | newMail.size = mail.size; | 383 | newMail.size = mail.size; |
384 | newMail.downloaded = mail.downloaded; | 384 | newMail.downloaded = mail.downloaded; |
385 | 385 | ||
386 | newMail.fromAccountId = emailHandler->getAccount()->id; | 386 | newMail.fromAccountId = emailHandler->getAccount()->id; |
387 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 387 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
388 | } | 388 | } |
389 | 389 | ||
390 | //add if read or not | 390 | //add if read or not |
391 | newMail.read = mailconf->readBoolEntry("mailread"); | 391 | newMail.read = mailconf->readBoolEntry("mailread"); |
392 | 392 | ||
393 | //check if new mail | 393 | //check if new mail |
394 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 394 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
395 | thisMailId = mailIdCount; | 395 | thisMailId = mailIdCount; |
396 | mailIdCount++; | 396 | mailIdCount++; |
397 | 397 | ||
398 | //set server count, so that if the user aborts, the new | 398 | //set server count, so that if the user aborts, the new |
399 | //header is not reloaded | 399 | //header is not reloaded |
400 | if ((currentAccount)&&(currentAccount->synchronize)) | 400 | if ((currentAccount)&&(currentAccount->synchronize)) |
401 | currentAccount->lastServerMailCount++; | 401 | currentAccount->lastServerMailCount++; |
402 | 402 | ||
403 | mailconf->writeEntry("internalmailid", thisMailId); | 403 | mailconf->writeEntry("internalmailid", thisMailId); |
404 | mailconf->writeEntry("downloaded", newMail.downloaded); | 404 | mailconf->writeEntry("downloaded", newMail.downloaded); |
405 | mailconf->writeEntry("size", (int) newMail.size); | 405 | mailconf->writeEntry("size", (int) newMail.size); |
406 | mailconf->writeEntry("serverid", newMail.serverId); | 406 | mailconf->writeEntry("serverid", newMail.serverId); |
407 | 407 | ||
408 | //addressList->addContact(newMail.fromMail, newMail.from); | 408 | //addressList->addContact(newMail.fromMail, newMail.from); |
409 | } | 409 | } |
410 | 410 | ||
411 | mailconf->writeEntry("downloaded", newMail.downloaded); | 411 | mailconf->writeEntry("downloaded", newMail.downloaded); |
412 | 412 | ||
413 | QString stringMailId; | 413 | QString stringMailId; |
414 | stringMailId.setNum(thisMailId); | 414 | stringMailId.setNum(thisMailId); |
415 | //see if any attatchments needs to be stored | 415 | //see if any attatchments needs to be stored |
416 | 416 | ||
417 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { | 417 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { |
418 | QString stringId; | 418 | QString stringId; |
419 | stringId.setNum(ePtr->id); | 419 | stringId.setNum(ePtr->id); |
420 | 420 | ||
421 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 421 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
422 | if (id != ePtr->id) { //new entry | 422 | if (id != ePtr->id) { //new entry |
423 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 423 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
424 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 424 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
425 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 425 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
426 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 426 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
427 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 427 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
428 | mailconf->writeEntry("installed_" + stringId, FALSE); | 428 | mailconf->writeEntry("installed_" + stringId, FALSE); |
429 | 429 | ||
430 | ePtr->name = stringMailId + "_" + stringId; | 430 | ePtr->name = stringMailId + "_" + stringId; |
431 | ePtr->path = getPath(TRUE); | 431 | ePtr->path = getPath(TRUE); |
432 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 432 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
433 | ePtr->saved = TRUE; | 433 | ePtr->saved = TRUE; |
434 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 434 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
435 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 435 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
436 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 436 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
437 | } else { | 437 | } else { |
438 | ePtr->saved = FALSE; | 438 | ePtr->saved = FALSE; |
439 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 439 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
440 | } | 440 | } |
441 | } else { | 441 | } else { |
442 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 442 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
443 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 443 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
444 | if (ePtr->saved) { | 444 | if (ePtr->saved) { |
445 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 445 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
446 | ePtr->path = mailconf->readEntry("path_" + stringId); | 446 | ePtr->path = mailconf->readEntry("path_" + stringId); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | bool found=false; | 451 | bool found=false; |
452 | 452 | ||
453 | if (!fromDisk) | 453 | if (!fromDisk) |
454 | { | 454 | { |
455 | 455 | ||
456 | Email *mailPtr; | 456 | Email *mailPtr; |
457 | item = (EmailListItem *) inboxView->firstChild(); | 457 | item = (EmailListItem *) inboxView->firstChild(); |
458 | while ((item != NULL)&&(!found)) | 458 | while ((item != NULL)&&(!found)) |
459 | { | 459 | { |
460 | mailPtr = item->getMail(); | 460 | mailPtr = item->getMail(); |
461 | if (mailPtr->id == newMail.id) { | 461 | if (mailPtr->id == newMail.id) { |
462 | item->setMail(newMail); | 462 | item->setMail(newMail); |
463 | emit mailUpdated(item->getMail()); | 463 | emit mailUpdated(item->getMail()); |
464 | found = true; | 464 | found = true; |
465 | } | 465 | } |
466 | item = (EmailListItem *) item->nextSibling(); | 466 | item = (EmailListItem *) item->nextSibling(); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); | 469 | if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); |
470 | 470 | ||
471 | if (item->getMail()->files.count()>0) | ||
472 | { | ||
473 | item->setPixmap(0, Resource::loadPixmap("mailit/attach")); | ||
474 | } | ||
471 | /*if (!newMail.downloaded) | 475 | /*if (!newMail.downloaded) |
472 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ | 476 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ |
473 | 477 | ||
474 | mailboxView->setCurrentTab(0); | 478 | mailboxView->setCurrentTab(0); |
475 | 479 | ||
476 | } | 480 | } |
477 | 481 | ||
478 | void EmailClient::allMailArrived(int count) | 482 | void EmailClient::allMailArrived(int count) |
479 | { | 483 | { |
480 | // not previewing means all mailtransfer has been done | 484 | // not previewing means all mailtransfer has been done |
481 | /*if (!previewingMail) {*/ | 485 | /*if (!previewingMail) {*/ |
482 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 486 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
483 | emit newCaption("Mailit - " + currentAccount->accountName); | 487 | emit newCaption("Mailit - " + currentAccount->accountName); |
484 | getNewMail(); | 488 | getNewMail(); |
485 | return; | 489 | return; |
486 | } else { | 490 | } else { |
487 | allAccounts = FALSE; | 491 | allAccounts = FALSE; |
488 | receiving = FALSE; | 492 | receiving = FALSE; |
489 | getMailButton->setEnabled(TRUE); | 493 | getMailButton->setEnabled(TRUE); |
490 | cancelButton->setEnabled(FALSE); | 494 | cancelButton->setEnabled(FALSE); |
491 | selectAccountMenu->setEnabled(TRUE); | 495 | selectAccountMenu->setEnabled(TRUE); |
492 | status1Label->setText("Idle"); | 496 | status1Label->setText("Idle"); |
493 | 497 | ||
494 | progressBar->reset(); | 498 | progressBar->reset(); |
495 | return; | 499 | return; |
496 | } | 500 | } |
497 | //} | 501 | //} |
498 | 502 | ||
499 | // all headers downloaded from server, start downloading remaining mails | 503 | // all headers downloaded from server, start downloading remaining mails |
500 | previewingMail = FALSE; | 504 | previewingMail = FALSE; |
501 | status1Label->setText(currentAccount->accountName); | 505 | status1Label->setText(currentAccount->accountName); |
502 | progressBar->reset(); | 506 | progressBar->reset(); |
503 | 507 | ||
504 | 508 | ||
505 | mailboxView->setCurrentTab(0); | 509 | mailboxView->setCurrentTab(0); |
506 | } | 510 | } |
507 | 511 | ||
508 | 512 | ||
509 | void EmailClient::moveMailFront(Email *mailPtr) | 513 | void EmailClient::moveMailFront(Email *mailPtr) |
510 | { | 514 | { |
511 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 515 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
512 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 516 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
513 | } | 517 | } |
514 | } | 518 | } |
515 | 519 | ||
516 | void EmailClient::smtpError(int code) | 520 | void EmailClient::smtpError(int code) |
517 | { | 521 | { |
518 | QString temp; | 522 | QString temp; |
519 | 523 | ||
520 | if (code == ErrUnknownResponse) | 524 | if (code == ErrUnknownResponse) |
521 | temp = "Unknown response from server"; | 525 | temp = "Unknown response from server"; |
522 | 526 | ||
523 | if (code == QSocket::ErrHostNotFound) | 527 | if (code == QSocket::ErrHostNotFound) |
524 | temp = "host not found"; | 528 | temp = "host not found"; |
525 | if (code == QSocket::ErrConnectionRefused) | 529 | if (code == QSocket::ErrConnectionRefused) |
526 | temp = "connection refused"; | 530 | temp = "connection refused"; |
527 | if (code == QSocket::ErrSocketRead) | 531 | if (code == QSocket::ErrSocketRead) |
528 | temp = "socket packet error"; | 532 | temp = "socket packet error"; |
529 | 533 | ||
530 | if (code != ErrCancel) { | 534 | if (code != ErrCancel) { |
531 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 535 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
532 | } else { | 536 | } else { |
533 | status2Label->setText("Aborted by user"); | 537 | status2Label->setText("Aborted by user"); |
534 | } | 538 | } |
535 | 539 | ||
536 | sending = FALSE; | 540 | sending = FALSE; |
537 | sendMailButton->setEnabled(TRUE); | 541 | sendMailButton->setEnabled(TRUE); |
538 | cancelButton->setEnabled(FALSE); | 542 | cancelButton->setEnabled(FALSE); |
539 | quedMessages.clear(); | 543 | quedMessages.clear(); |
540 | } | 544 | } |
541 | 545 | ||
542 | void EmailClient::popError(int code) | 546 | void EmailClient::popError(int code) |
543 | { | 547 | { |
544 | QString temp; | 548 | QString temp; |
545 | 549 | ||
546 | if (code == ErrUnknownResponse) | 550 | if (code == ErrUnknownResponse) |
547 | temp = "Unknown response from server"; | 551 | temp = "Unknown response from server"; |
548 | if (code == ErrLoginFailed) | 552 | if (code == ErrLoginFailed) |
549 | temp = "Login failed\nCheck user name and password"; | 553 | temp = "Login failed\nCheck user name and password"; |
550 | 554 | ||
551 | if (code == QSocket::ErrHostNotFound) | 555 | if (code == QSocket::ErrHostNotFound) |
552 | temp = "host not found"; | 556 | temp = "host not found"; |
553 | if (code == QSocket::ErrConnectionRefused) | 557 | if (code == QSocket::ErrConnectionRefused) |
554 | temp = "connection refused"; | 558 | temp = "connection refused"; |
555 | if (code == QSocket::ErrSocketRead) | 559 | if (code == QSocket::ErrSocketRead) |
556 | temp = "socket packet error"; | 560 | temp = "socket packet error"; |
557 | 561 | ||
558 | if (code != ErrCancel) { | 562 | if (code != ErrCancel) { |
559 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 563 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
560 | } else { | 564 | } else { |
561 | status2Label->setText("Aborted by user"); | 565 | status2Label->setText("Aborted by user"); |
562 | } | 566 | } |
563 | 567 | ||
564 | receiving = FALSE; | 568 | receiving = FALSE; |
565 | getMailButton->setEnabled(TRUE); | 569 | getMailButton->setEnabled(TRUE); |
566 | cancelButton->setEnabled(FALSE); | 570 | cancelButton->setEnabled(FALSE); |
567 | selectAccountMenu->setEnabled(TRUE); | 571 | selectAccountMenu->setEnabled(TRUE); |
568 | } | 572 | } |
569 | 573 | ||
570 | void EmailClient::inboxItemSelected() | 574 | void EmailClient::inboxItemSelected() |
571 | { | 575 | { |
572 | //killTimer(timerID); | 576 | //killTimer(timerID); |
573 | 577 | ||
574 | item = (EmailListItem*) inboxView->selectedItem(); | 578 | item = (EmailListItem*) inboxView->selectedItem(); |
575 | if (item != NULL) { | 579 | if (item != NULL) { |
576 | emit viewEmail(inboxView, item->getMail()); | 580 | emit viewEmail(inboxView, item->getMail()); |
577 | } | 581 | } |
578 | } | 582 | } |
579 | 583 | ||
580 | void EmailClient::outboxItemSelected() | 584 | void EmailClient::outboxItemSelected() |
581 | { | 585 | { |
582 | //killTimer(timerID); | 586 | //killTimer(timerID); |
583 | 587 | ||
584 | item = (EmailListItem*) outboxView->selectedItem(); | 588 | item = (EmailListItem*) outboxView->selectedItem(); |
585 | if (item != NULL) { | 589 | if (item != NULL) { |
586 | emit viewEmail(outboxView, item->getMail()); | 590 | emit viewEmail(outboxView, item->getMail()); |
587 | } | 591 | } |
588 | 592 | ||
589 | } | 593 | } |
590 | 594 | ||
591 | void EmailClient::readMail() | 595 | void EmailClient::readMail() |
592 | { | 596 | { |
593 | Email mail; | 597 | Email mail; |
594 | int start, stop; | 598 | int start, stop; |
595 | QString s, del; | 599 | QString s, del; |
596 | 600 | ||
597 | QFile f(getPath(FALSE) + "inbox.txt"); | 601 | QFile f(getPath(FALSE) + "inbox.txt"); |
598 | 602 | ||
599 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 603 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
600 | QTextStream t( &f ); // use a text stream | 604 | QTextStream t( &f ); // use a text stream |
601 | s = t.read(); | 605 | s = t.read(); |
602 | f.close(); | 606 | f.close(); |
603 | 607 | ||
604 | start = 0; | 608 | start = 0; |
605 | del = "\n.\n"; | 609 | del = "\n.\n"; |
606 | while ((uint) start < s.length()) { | 610 | while ((uint) start < s.length()) { |
607 | stop = s.find(del, start); | 611 | stop = s.find(del, start); |
608 | if (stop == -1) | 612 | if (stop == -1) |
609 | stop = s.length() - del.length(); | 613 | stop = s.length() - del.length(); |
610 | 614 | ||
611 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 615 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
612 | start = stop + del.length(); | 616 | start = stop + del.length(); |
613 | mailArrived(mail, TRUE); | 617 | mailArrived(mail, TRUE); |
614 | } | 618 | } |
615 | } | 619 | } |
616 | 620 | ||
617 | QFile fo(getPath(FALSE) + "outbox.txt"); | 621 | QFile fo(getPath(FALSE) + "outbox.txt"); |
618 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 622 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
619 | QTextStream t( &fo ); // use a text stream | 623 | QTextStream t( &fo ); // use a text stream |
620 | s = t.read(); | 624 | s = t.read(); |
621 | fo.close(); | 625 | fo.close(); |
622 | 626 | ||
623 | start = 0; | 627 | start = 0; |
624 | del = "\n.\n"; | 628 | del = "\n.\n"; |
625 | while ((uint) start < s.length()) { | 629 | while ((uint) start < s.length()) { |
626 | stop = s.find(del, start); | 630 | stop = s.find(del, start); |
627 | if (stop == -1) | 631 | if (stop == -1) |
628 | stop = s.length() - del.length(); | 632 | stop = s.length() - del.length(); |
629 | 633 | ||
630 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 634 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
631 | start = stop + del.length(); | 635 | start = stop + del.length(); |
632 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 636 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
633 | mail.sent = false; | 637 | mail.sent = false; |
634 | mail.received = false; | 638 | mail.received = false; |
635 | enqueMail(mail); | 639 | enqueMail(mail); |
636 | 640 | ||
637 | } | 641 | } |
638 | } | 642 | } |
639 | } | 643 | } |
640 | 644 | ||
641 | void EmailClient::saveMail(QString fileName, QListView *view) | 645 | void EmailClient::saveMail(QString fileName, QListView *view) |
642 | { | 646 | { |
643 | QFile f(fileName); | 647 | QFile f(fileName); |
644 | Email *mail; | 648 | Email *mail; |
645 | 649 | ||
646 | if (! f.open(IO_WriteOnly) ) { | 650 | if (! f.open(IO_WriteOnly) ) { |
647 | qWarning("could not open file"); | 651 | qWarning("could not open file"); |
648 | return; | 652 | return; |
649 | } | 653 | } |
650 | item = (EmailListItem *) view->firstChild(); | 654 | item = (EmailListItem *) view->firstChild(); |
651 | QTextStream t(&f); | 655 | QTextStream t(&f); |
652 | while (item != NULL) { | 656 | while (item != NULL) { |
653 | mail = item->getMail(); | 657 | mail = item->getMail(); |
654 | t << mail->rawMail; | 658 | t << mail->rawMail; |
655 | 659 | ||
656 | mailconf->setGroup(mail->id); | 660 | mailconf->setGroup(mail->id); |
657 | mailconf->writeEntry("mailread", mail->read); | 661 | mailconf->writeEntry("mailread", mail->read); |
658 | 662 | ||
659 | item = (EmailListItem *) item->nextSibling(); | 663 | item = (EmailListItem *) item->nextSibling(); |
660 | } | 664 | } |
661 | f.close(); | 665 | f.close(); |
662 | } | 666 | } |
663 | 667 | ||
664 | //paths for mailit, is settings, inbox, enclosures | 668 | //paths for mailit, is settings, inbox, enclosures |
665 | QString EmailClient::getPath(bool enclosurePath) | 669 | QString EmailClient::getPath(bool enclosurePath) |
666 | { | 670 | { |
667 | QString basePath = "qtmail"; | 671 | QString basePath = "qtmail"; |
668 | QString enclosures = "enclosures"; | 672 | QString enclosures = "enclosures"; |
669 | 673 | ||
670 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 674 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
671 | if ( !dir.exists() ) | 675 | if ( !dir.exists() ) |
672 | dir.mkdir( dir.path() ); | 676 | dir.mkdir( dir.path() ); |
673 | 677 | ||
674 | if (enclosurePath) { | 678 | if (enclosurePath) { |
675 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 679 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
676 | 680 | ||
677 | if ( !dir.exists() ) | 681 | if ( !dir.exists() ) |
678 | dir.mkdir( dir.path() ); | 682 | dir.mkdir( dir.path() ); |
679 | 683 | ||
680 | return (dir.path() + "/"); | 684 | return (dir.path() + "/"); |
681 | 685 | ||
682 | } | 686 | } |
683 | return (dir.path() + "/"); | 687 | return (dir.path() + "/"); |
684 | } | 688 | } |
685 | 689 | ||
686 | void EmailClient::readSettings() | 690 | void EmailClient::readSettings() |
687 | { | 691 | { |
688 | int y,acc_count; | 692 | int y,acc_count; |
689 | 693 | ||
690 | mailconf->setGroup("mailitglobal"); | 694 | mailconf->setGroup("mailitglobal"); |
691 | acc_count=mailconf->readNumEntry("Accounts",0); | 695 | acc_count=mailconf->readNumEntry("Accounts",0); |
692 | 696 | ||
693 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) | 697 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) |
694 | { | 698 | { |
695 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... | 699 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... |
696 | account.accountName = mailconf->readEntry("AccName",""); | 700 | account.accountName = mailconf->readEntry("AccName",""); |
697 | account.name = mailconf->readEntry("UserName",""); | 701 | account.name = mailconf->readEntry("UserName",""); |
698 | account.emailAddress = mailconf->readEntry("Email",""); | 702 | account.emailAddress = mailconf->readEntry("Email",""); |
699 | account.popUserName = mailconf->readEntry("POPUser",""); | 703 | account.popUserName = mailconf->readEntry("POPUser",""); |
700 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); | 704 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); |
701 | account.popServer = mailconf->readEntry("POPServer",""); | 705 | account.popServer = mailconf->readEntry("POPServer",""); |
702 | account.smtpServer = mailconf->readEntry("SMTPServer",""); | 706 | account.smtpServer = mailconf->readEntry("SMTPServer",""); |
703 | account.id = mailconf->readNumEntry("AccountId",0); | 707 | account.id = mailconf->readNumEntry("AccountId",0); |
704 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); | 708 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); |
705 | account.lastServerMailCount = 0; | 709 | account.lastServerMailCount = 0; |
706 | account.synchronize = FALSE; | 710 | account.synchronize = FALSE; |
707 | 711 | ||
708 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); | 712 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); |
709 | if (account.synchronize) | 713 | if (account.synchronize) |
710 | { | 714 | { |
711 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); | 715 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); |
712 | } | 716 | } |
713 | 717 | ||
714 | accountList.append(&account); | 718 | accountList.append(&account); |
715 | } | 719 | } |
716 | 720 | ||
717 | mailconf->setGroup("mailitglobal"); | 721 | mailconf->setGroup("mailitglobal"); |
718 | 722 | ||
719 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) | 723 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) |
720 | { | 724 | { |
721 | mailIdCount = y; | 725 | mailIdCount = y; |
722 | } | 726 | } |
723 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) | 727 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) |
724 | { | 728 | { |
725 | accountIdCount = y; | 729 | accountIdCount = y; |
726 | } | 730 | } |
727 | } | 731 | } |
728 | 732 | ||
729 | void EmailClient::saveSettings() | 733 | void EmailClient::saveSettings() |
730 | { | 734 | { |
731 | int acc_count=0; | 735 | int acc_count=0; |
732 | MailAccount *accountPtr; | 736 | MailAccount *accountPtr; |
733 | 737 | ||
734 | 738 | ||
735 | if (!mailconf) | 739 | if (!mailconf) |
736 | { | 740 | { |
737 | qWarning("could not save settings"); | 741 | qWarning("could not save settings"); |
738 | return; | 742 | return; |
739 | } | 743 | } |
740 | 744 | ||
741 | for (accountPtr = accountList.first(); accountPtr != 0; | 745 | for (accountPtr = accountList.first(); accountPtr != 0; |
742 | accountPtr = accountList.next()) | 746 | accountPtr = accountList.next()) |
743 | { | 747 | { |
744 | mailconf->setGroup("Account_"+QString::number(++acc_count)); | 748 | mailconf->setGroup("Account_"+QString::number(++acc_count)); |
745 | mailconf->writeEntry("AccName",accountPtr->accountName ); | 749 | mailconf->writeEntry("AccName",accountPtr->accountName ); |
746 | mailconf->writeEntry("UserName",accountPtr->name); | 750 | mailconf->writeEntry("UserName",accountPtr->name); |
747 | mailconf->writeEntry("Email",accountPtr->emailAddress); | 751 | mailconf->writeEntry("Email",accountPtr->emailAddress); |
748 | mailconf->writeEntry("POPUser",accountPtr->popUserName); | 752 | mailconf->writeEntry("POPUser",accountPtr->popUserName); |
749 | mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); | 753 | mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); |
750 | mailconf->writeEntry("POPServer",accountPtr->popServer); | 754 | mailconf->writeEntry("POPServer",accountPtr->popServer); |
751 | mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); | 755 | mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); |
752 | mailconf->writeEntry("AccountId",accountPtr->id); | 756 | mailconf->writeEntry("AccountId",accountPtr->id); |
753 | if (accountPtr->synchronize) | 757 | if (accountPtr->synchronize) |
754 | { | 758 | { |
755 | mailconf->writeEntry("Synchronize","Yes"); | 759 | mailconf->writeEntry("Synchronize","Yes"); |
756 | mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); | 760 | mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); |
757 | mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); | 761 | mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); |
758 | } | 762 | } |
759 | else | 763 | else |
760 | { | 764 | { |
761 | mailconf->writeEntry("Synchronize", "No"); | 765 | mailconf->writeEntry("Synchronize", "No"); |
762 | } | 766 | } |
763 | } | 767 | } |
764 | 768 | ||
765 | mailconf->setGroup("mailitglobal"); | 769 | mailconf->setGroup("mailitglobal"); |
766 | mailconf->writeEntry("Accounts",acc_count); | 770 | mailconf->writeEntry("Accounts",acc_count); |
767 | mailconf->writeEntry("mailidcount", mailIdCount); | 771 | mailconf->writeEntry("mailidcount", mailIdCount); |
768 | mailconf->writeEntry("accountidcount", accountIdCount); | 772 | mailconf->writeEntry("accountidcount", accountIdCount); |
769 | } | 773 | } |
770 | 774 | ||
771 | void EmailClient::selectAccount(int id) | 775 | void EmailClient::selectAccount(int id) |
772 | { | 776 | { |
773 | if (accountList.count() > 0) { | 777 | if (accountList.count() > 0) { |
774 | currentAccount = accountList.at(id); | 778 | currentAccount = accountList.at(id); |
775 | emit newCaption("Mailit - " + currentAccount->accountName); | 779 | emit newCaption("Mailit - " + currentAccount->accountName); |
776 | getNewMail(); | 780 | getNewMail(); |
777 | } else { | 781 | } else { |
778 | emit newCaption("Mailit ! No account defined"); | 782 | emit newCaption("Mailit ! No account defined"); |
779 | } | 783 | } |
780 | } | 784 | } |
781 | 785 | ||
782 | void EmailClient::editAccount(int id) | 786 | void EmailClient::editAccount(int id) |
783 | { | 787 | { |
784 | MailAccount *newAccount; | 788 | MailAccount *newAccount; |
785 | 789 | ||
786 | editAccountView = new EditAccount(this, "account", TRUE); | 790 | editAccountView = new EditAccount(this, "account", TRUE); |
787 | if (id == newAccountId) { //new account | 791 | if (id == newAccountId) { //new account |
788 | newAccount = new MailAccount; | 792 | newAccount = new MailAccount; |
789 | editAccountView->setAccount(newAccount); | 793 | editAccountView->setAccount(newAccount); |
790 | } else { | 794 | } else { |
791 | newAccount = accountList.at(id); | 795 | newAccount = accountList.at(id); |
792 | editAccountView->setAccount(newAccount, FALSE); | 796 | editAccountView->setAccount(newAccount, FALSE); |
793 | } | 797 | } |
794 | 798 | ||
795 | editAccountView->showMaximized(); | 799 | editAccountView->showMaximized(); |
796 | editAccountView->exec(); | 800 | editAccountView->exec(); |
797 | 801 | ||
798 | if (editAccountView->result() == QDialog::Accepted) { | 802 | if (editAccountView->result() == QDialog::Accepted) { |
799 | if (id == newAccountId) { | 803 | if (id == newAccountId) { |
800 | newAccount->id = accountIdCount; | 804 | newAccount->id = accountIdCount; |
801 | accountIdCount++; | 805 | accountIdCount++; |
802 | accountList.append(newAccount); | 806 | accountList.append(newAccount); |
803 | updateAccounts(); | 807 | updateAccounts(); |
804 | } else { | 808 | } else { |
805 | updateAccounts(); | 809 | updateAccounts(); |
806 | } | 810 | } |
807 | } | 811 | } |
808 | 812 | ||
809 | delete editAccountView; | 813 | delete editAccountView; |
810 | } | 814 | } |
811 | 815 | ||
812 | void EmailClient::deleteAccount(int id) | 816 | void EmailClient::deleteAccount(int id) |
813 | { | 817 | { |
814 | MailAccount *newAccount; | 818 | MailAccount *newAccount; |
815 | QString message; | 819 | QString message; |
816 | 820 | ||
817 | newAccount = accountList.at(id); | 821 | newAccount = accountList.at(id); |
818 | message = "Delete account:\n" + newAccount->accountName; | 822 | message = "Delete account:\n" + newAccount->accountName; |
819 | switch( QMessageBox::warning( this, "Mailit", message, | 823 | switch( QMessageBox::warning( this, "Mailit", message, |
820 | "Yes", "No", 0, 0, 1 ) ) { | 824 | "Yes", "No", 0, 0, 1 ) ) { |
821 | 825 | ||
822 | case 0: accountList.remove(id); | 826 | case 0: accountList.remove(id); |
823 | updateAccounts(); | 827 | updateAccounts(); |
824 | break; | 828 | break; |
825 | case 1: | 829 | case 1: |
826 | break; | 830 | break; |
827 | } | 831 | } |
828 | } | 832 | } |
829 | 833 | ||
830 | void EmailClient::updateAccounts() | 834 | void EmailClient::updateAccounts() |
831 | { | 835 | { |
832 | MailAccount *accountPtr; | 836 | MailAccount *accountPtr; |
833 | 837 | ||
834 | //rebuild menus, clear all first | 838 | //rebuild menus, clear all first |
835 | editAccountMenu->clear(); | 839 | editAccountMenu->clear(); |
836 | selectAccountMenu->clear(); | 840 | selectAccountMenu->clear(); |
837 | deleteAccountMenu->clear(); | 841 | deleteAccountMenu->clear(); |
838 | 842 | ||
839 | newAccountId = editAccountMenu->insertItem("New", this, | 843 | newAccountId = editAccountMenu->insertItem("New", this, |
840 | SLOT(editAccount(int)) ); | 844 | SLOT(editAccount(int)) ); |
841 | editAccountMenu->insertSeparator(); | 845 | editAccountMenu->insertSeparator(); |
842 | 846 | ||
843 | idCount = 0; | 847 | idCount = 0; |
844 | for (accountPtr = accountList.first(); accountPtr != 0; | 848 | for (accountPtr = accountList.first(); accountPtr != 0; |
845 | accountPtr = accountList.next()) { | 849 | accountPtr = accountList.next()) { |
846 | 850 | ||
847 | editAccountMenu->insertItem(accountPtr->accountName, | 851 | editAccountMenu->insertItem(accountPtr->accountName, |
848 | this, SLOT(editAccount(int)), 0, idCount); | 852 | this, SLOT(editAccount(int)), 0, idCount); |
849 | selectAccountMenu->insertItem(accountPtr->accountName, | 853 | selectAccountMenu->insertItem(accountPtr->accountName, |
850 | this, SLOT(selectAccount(int)), 0, idCount); | 854 | this, SLOT(selectAccount(int)), 0, idCount); |
851 | deleteAccountMenu->insertItem(accountPtr->accountName, | 855 | deleteAccountMenu->insertItem(accountPtr->accountName, |
852 | this, SLOT(deleteAccount(int)), 0, idCount); | 856 | this, SLOT(deleteAccount(int)), 0, idCount); |
853 | idCount++; | 857 | idCount++; |
854 | } | 858 | } |
855 | } | 859 | } |
856 | 860 | ||
857 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 861 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
858 | { | 862 | { |
859 | Email *mPtr; | 863 | Email *mPtr; |
860 | Enclosure *ePtr; | 864 | Enclosure *ePtr; |
861 | 865 | ||
862 | if (inbox) | 866 | if (inbox) |
863 | { | 867 | { |
864 | mPtr = mailItem->getMail(); | 868 | mPtr = mailItem->getMail(); |
865 | 869 | ||
866 | //if mail is in queue for download, remove it from | 870 | //if mail is in queue for download, remove it from |
867 | //queue if possible | 871 | //queue if possible |
868 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 872 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
869 | if ( !mPtr->downloaded ) | 873 | if ( !mPtr->downloaded ) |
870 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 874 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
871 | } | 875 | } |
872 | 876 | ||
873 | mailconf->setGroup(mPtr->id); | 877 | mailconf->setGroup(mPtr->id); |
874 | mailconf->clearGroup(); | 878 | mailconf->clearGroup(); |
875 | 879 | ||
876 | //delete any temporary attatchemnts storing | 880 | //delete any temporary attatchemnts storing |
877 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 881 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
878 | if (ePtr->saved) { | 882 | if (ePtr->saved) { |
879 | QFile::remove( (ePtr->path + ePtr->name) ); | 883 | QFile::remove( (ePtr->path + ePtr->name) ); |
880 | } | 884 | } |
881 | } | 885 | } |
882 | inboxView->takeItem(mailItem); | 886 | inboxView->takeItem(mailItem); |
883 | } | 887 | } |
884 | else | 888 | else |
885 | { | 889 | { |
886 | outboxView->takeItem(mailItem); | 890 | outboxView->takeItem(mailItem); |
887 | } | 891 | } |
888 | } | 892 | } |
889 | 893 | ||
890 | void EmailClient::setMailSize(int size) | 894 | void EmailClient::setMailSize(int size) |
891 | { | 895 | { |
892 | progressBar->reset(); | 896 | progressBar->reset(); |
893 | progressBar->setTotalSteps(size); | 897 | progressBar->setTotalSteps(size); |
894 | } | 898 | } |
895 | 899 | ||
896 | void EmailClient::setTotalSize(int size) | 900 | void EmailClient::setTotalSize(int size) |
897 | { | 901 | { |
898 | 902 | ||
899 | } | 903 | } |
900 | 904 | ||
901 | void EmailClient::setDownloadedSize(int size) | 905 | void EmailClient::setDownloadedSize(int size) |
902 | { | 906 | { |
903 | int total = progressBar->totalSteps(); | 907 | int total = progressBar->totalSteps(); |
904 | 908 | ||
905 | if (size < total) { | 909 | if (size < total) { |
906 | progressBar->setProgress(size); | 910 | progressBar->setProgress(size); |
907 | } else { | 911 | } else { |
908 | progressBar->setProgress(total); | 912 | progressBar->setProgress(total); |
909 | } | 913 | } |
910 | } | 914 | } |
911 | 915 | ||
912 | void EmailClient::deleteItem() | 916 | void EmailClient::deleteItem() |
913 | { | 917 | { |
914 | bool inbox=mailboxView->currentTab()==0; | 918 | bool inbox=mailboxView->currentTab()==0; |
915 | QListView* box; | 919 | QListView* box; |
916 | 920 | ||
917 | EmailListItem* eli; | 921 | EmailListItem* eli; |
918 | int pos; | 922 | int pos; |
919 | 923 | ||
920 | inbox ? box=inboxView : box=outboxView; | 924 | inbox ? box=inboxView : box=outboxView; |
921 | 925 | ||
922 | eli=(EmailListItem*)box->selectedItem(); | 926 | eli=(EmailListItem*)box->selectedItem(); |
923 | 927 | ||
924 | if (eli) | 928 | if (eli) |
925 | { | 929 | { |
926 | box->setSelected(eli->itemBelow(),true);//select the previous item | 930 | box->setSelected(eli->itemBelow(),true);//select the previous item |
927 | 931 | ||
928 | deleteMail(eli,(bool&)inbox); //remove mail entry | 932 | deleteMail(eli,(bool&)inbox); //remove mail entry |
929 | } | 933 | } |
930 | } | 934 | } |
931 | 935 | ||
932 | void EmailClient::inboxItemPressed() | 936 | void EmailClient::inboxItemPressed() |
933 | { | 937 | { |
934 | //timerID=startTimer(500); | 938 | //timerID=startTimer(500); |
935 | } | 939 | } |
936 | 940 | ||
937 | void EmailClient::inboxItemReleased() | 941 | void EmailClient::inboxItemReleased() |
938 | { | 942 | { |
939 | //killTimer(timerID); | 943 | //killTimer(timerID); |
940 | } | 944 | } |
941 | 945 | ||
942 | /*void EmailClient::timerEvent(QTimerEvent *e) | 946 | /*void EmailClient::timerEvent(QTimerEvent *e) |
943 | { | 947 | { |
944 | /*killTimer(timerID); | 948 | /*killTimer(timerID); |
945 | 949 | ||
946 | 950 | ||
947 | QPopupMenu *action = new QPopupMenu(this); | 951 | QPopupMenu *action = new QPopupMenu(this); |
948 | 952 | ||
949 | int reply=0; | 953 | int reply=0; |
950 | 954 | ||
951 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | 955 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); |
952 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | 956 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); |
953 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | 957 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); |
954 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | 958 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); |
955 | 959 | ||
956 | action->exec(QCursor::pos()); | 960 | action->exec(QCursor::pos()); |
957 | 961 | ||
958 | if (action) delete action; | 962 | if (action) delete action; |
959 | 963 | ||
960 | }*/ | 964 | }*/ |
961 | 965 | ||
962 | Email* EmailClient::getCurrentMail() | 966 | Email* EmailClient::getCurrentMail() |
963 | { | 967 | { |
964 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | 968 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); |
965 | if (eli!=NULL) | 969 | if (eli!=NULL) |
966 | return eli->getMail(); | 970 | return eli->getMail(); |
967 | else | 971 | else |
968 | return NULL; | 972 | return NULL; |
969 | } | 973 | } |
970 | 974 | ||
971 | void EmailClient::download(Email* mail) | 975 | void EmailClient::download(Email* mail) |
972 | { | 976 | { |
973 | MailAccount* acc=0; | 977 | MailAccount* acc=0; |
974 | 978 | ||
975 | tempMailDownloadList.clear(); | 979 | tempMailDownloadList.clear(); |
976 | tempMailDownloadList.sizeInsert(mail->serverId, mail->size); | 980 | tempMailDownloadList.sizeInsert(mail->serverId, mail->size); |
977 | 981 | ||
978 | acc=accountList.at(mail->fromAccountId-1); | 982 | acc=accountList.at(mail->fromAccountId-1); |
979 | if (acc) | 983 | if (acc) |
980 | { | 984 | { |
981 | emailHandler->setAccount(*acc); | 985 | emailHandler->setAccount(*acc); |
982 | emailHandler->getMailByList(&tempMailDownloadList); | 986 | emailHandler->getMailByList(&tempMailDownloadList); |
983 | } | 987 | } |
984 | else | 988 | else |
985 | QMessageBox::warning(qApp->activeWindow(), | 989 | QMessageBox::warning(qApp->activeWindow(), |
986 | tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); | 990 | tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); |
987 | } | 991 | } |
988 | 992 | ||
989 | void EmailClient::receive(const QCString& msg, const QByteArray& data) | 993 | void EmailClient::receive(const QCString& msg, const QByteArray& data) |
990 | { | 994 | { |
991 | /*if (msg=="getMail()") | 995 | /*if (msg=="getMail()") |
992 | { | 996 | { |
993 | /*QDialog qd(qApp->activeWindow(),"Getting mail",true); | 997 | /*QDialog qd(qApp->activeWindow(),"Getting mail",true); |
994 | QVBoxLayout *vbProg = new QVBoxLayout( &qd ); | 998 | QVBoxLayout *vbProg = new QVBoxLayout( &qd ); |
995 | 999 | ||
996 | initStatusBar(&qd); | 1000 | initStatusBar(&qd); |
997 | 1001 | ||
998 | if (statusBar==0) | 1002 | if (statusBar==0) |
999 | { | 1003 | { |
1000 | qDebug("No Bar ..."); | 1004 | qDebug("No Bar ..."); |
1001 | //statusBar=new ProgressBar(&qd); | 1005 | //statusBar=new ProgressBar(&qd); |
1002 | } | 1006 | } |
1003 | statusBar->show(); | 1007 | statusBar->show(); |
1004 | vbProg->addWidget(statusBar); | 1008 | vbProg->addWidget(statusBar); |
1005 | qd.showMaximized(); | 1009 | qd.showMaximized(); |
1006 | qd.show(); | 1010 | qd.show(); |
1007 | emit getAllNewMail(); | 1011 | emit getAllNewMail(); |
1008 | //qd.exec(); | 1012 | //qd.exec(); |
1009 | } | 1013 | } |
1010 | else if (msg=="compose()") | 1014 | else if (msg=="compose()") |
1011 | { | 1015 | { |
1012 | QDialog qd(qApp->activeWindow(),"Getting mail",true); | 1016 | QDialog qd(qApp->activeWindow(),"Getting mail",true); |
1013 | 1017 | ||
1014 | WriteMail wm(&qd,"write new mail"); | 1018 | WriteMail wm(&qd,"write new mail"); |
1015 | QVBoxLayout vbProg( &qd ); | 1019 | QVBoxLayout vbProg( &qd ); |
1016 | 1020 | ||
1017 | wm.showMaximized(); | 1021 | wm.showMaximized(); |
1018 | vbProg.addWidget(&wm); | 1022 | vbProg.addWidget(&wm); |
1019 | 1023 | ||
1020 | qd.showMaximized(); | 1024 | qd.showMaximized(); |
1021 | 1025 | ||
1022 | emit composeRequested(); | 1026 | emit composeRequested(); |
1023 | qd.exec(); | 1027 | qd.exec(); |
1024 | 1028 | ||
1025 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); | 1029 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); |
1026 | } | 1030 | } |
1027 | 1031 | ||
1028 | else if (msg=="dialog()") | 1032 | else if (msg=="dialog()") |
1029 | { | 1033 | { |
1030 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); | 1034 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); |
1031 | }*/ | 1035 | }*/ |
1032 | } | 1036 | } |
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 2cedc51..b039cc4 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -1,1032 +1,1036 @@ | |||
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 <qvbox.h> | 22 | #include <qvbox.h> |
23 | #include <qfile.h> | 23 | #include <qfile.h> |
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qaction.h> | 26 | #include <qaction.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include "emailclient.h" | 29 | #include "emailclient.h" |
30 | #include "writemail.h" | 30 | #include "writemail.h" |
31 | 31 | ||
32 | QCollection::Item AccountList::newItem(QCollection::Item d) | 32 | QCollection::Item AccountList::newItem(QCollection::Item d) |
33 | { | 33 | { |
34 | return dupl( (MailAccount *) d); | 34 | return dupl( (MailAccount *) d); |
35 | } | 35 | } |
36 | 36 | ||
37 | MailAccount* AccountList::dupl(MailAccount *in) | 37 | MailAccount* AccountList::dupl(MailAccount *in) |
38 | { | 38 | { |
39 | ac = new MailAccount(*in); | 39 | ac = new MailAccount(*in); |
40 | return ac; | 40 | return ac; |
41 | } | 41 | } |
42 | 42 | ||
43 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 43 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
44 | : QMainWindow( parent, name, fl ) | 44 | : QMainWindow( parent, name, fl ) |
45 | { | 45 | { |
46 | emailHandler = new EmailHandler(); | 46 | emailHandler = new EmailHandler(); |
47 | addressList = new AddressList(); | 47 | addressList = new AddressList(); |
48 | 48 | ||
49 | sending = FALSE; | 49 | sending = FALSE; |
50 | receiving = FALSE; | 50 | receiving = FALSE; |
51 | previewingMail = FALSE; | 51 | previewingMail = FALSE; |
52 | mailIdCount = 1; | 52 | mailIdCount = 1; |
53 | accountIdCount = 1; | 53 | accountIdCount = 1; |
54 | allAccounts = FALSE; | 54 | allAccounts = FALSE; |
55 | 55 | ||
56 | init(); | 56 | init(); |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 60 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
61 | 61 | ||
62 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 62 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
63 | SLOT(smtpError(int)) ); | 63 | SLOT(smtpError(int)) ); |
64 | connect(emailHandler, SIGNAL(popError(int)), this, | 64 | connect(emailHandler, SIGNAL(popError(int)), this, |
65 | SLOT(popError(int)) ); | 65 | SLOT(popError(int)) ); |
66 | 66 | ||
67 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 67 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
69 | 69 | ||
70 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | 70 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); |
71 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | 71 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); |
72 | 72 | ||
73 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 73 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
74 | SLOT(mailArrived(const Email &, bool)) ); | 74 | SLOT(mailArrived(const Email &, bool)) ); |
75 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 75 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
76 | SLOT(allMailArrived(int)) ); | 76 | SLOT(allMailArrived(int)) ); |
77 | 77 | ||
78 | mailconf = new Config("mailit"); | 78 | mailconf = new Config("mailit"); |
79 | //In case Synchronize is not defined in settings.txt | 79 | //In case Synchronize is not defined in settings.txt |
80 | 80 | ||
81 | readSettings(); | 81 | readSettings(); |
82 | 82 | ||
83 | updateAccounts(); | 83 | updateAccounts(); |
84 | 84 | ||
85 | lineShift = "\n"; | 85 | lineShift = "\n"; |
86 | readMail(); | 86 | readMail(); |
87 | lineShift = "\r\n"; | 87 | lineShift = "\r\n"; |
88 | 88 | ||
89 | mailboxView->setCurrentTab(0); //ensure that inbox has focus | 89 | mailboxView->setCurrentTab(0); //ensure that inbox has focus |
90 | 90 | ||
91 | /*channel = new QCopChannel( "QPE/Application/mailit", this ); | 91 | /*channel = new QCopChannel( "QPE/Application/mailit", this ); |
92 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 92 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
93 | this, SLOT(receive(const QCString&, const QByteArray&)) );*/ | 93 | this, SLOT(receive(const QCString&, const QByteArray&)) );*/ |
94 | 94 | ||
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | EmailClient::~EmailClient() | 98 | EmailClient::~EmailClient() |
99 | { | 99 | { |
100 | //needs to be moved from destructor to closewindow event | 100 | //needs to be moved from destructor to closewindow event |
101 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 101 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
102 | //does not currently work. Defining outbox in the same | 102 | //does not currently work. Defining outbox in the same |
103 | //format as inbox is not a good solution as they have | 103 | //format as inbox is not a good solution as they have |
104 | //different properties | 104 | //different properties |
105 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 105 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
106 | saveSettings(); | 106 | saveSettings(); |
107 | 107 | ||
108 | mailconf->write(); | 108 | mailconf->write(); |
109 | delete mailconf; | 109 | delete mailconf; |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | void EmailClient::init() | 113 | void EmailClient::init() |
114 | { | 114 | { |
115 | initStatusBar(this); | 115 | initStatusBar(this); |
116 | 116 | ||
117 | setToolBarsMovable(FALSE); | 117 | setToolBarsMovable(FALSE); |
118 | 118 | ||
119 | bar = new QToolBar(this); | 119 | bar = new QToolBar(this); |
120 | QWhatsThis::add(bar,tr("Main operation toolbar")); | 120 | QWhatsThis::add(bar,tr("Main operation toolbar")); |
121 | bar->setHorizontalStretchable( TRUE ); | 121 | bar->setHorizontalStretchable( TRUE ); |
122 | 122 | ||
123 | mb = new QMenuBar( bar ); | 123 | mb = new QMenuBar( bar ); |
124 | 124 | ||
125 | QPopupMenu *mail = new QPopupMenu(mb); | 125 | QPopupMenu *mail = new QPopupMenu(mb); |
126 | mb->insertItem( tr( "&Mail" ), mail); | 126 | mb->insertItem( tr( "&Mail" ), mail); |
127 | 127 | ||
128 | QPopupMenu *configure = new QPopupMenu(mb); | 128 | QPopupMenu *configure = new QPopupMenu(mb); |
129 | mb->insertItem( tr( "Accounts" ), configure); | 129 | mb->insertItem( tr( "Accounts" ), configure); |
130 | 130 | ||
131 | selectAccountMenu = new QPopupMenu(mb); | 131 | selectAccountMenu = new QPopupMenu(mb); |
132 | editAccountMenu = new QPopupMenu(mb); | 132 | editAccountMenu = new QPopupMenu(mb); |
133 | deleteAccountMenu = new QPopupMenu(mb); | 133 | deleteAccountMenu = new QPopupMenu(mb); |
134 | 134 | ||
135 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 135 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
136 | configure->insertItem(tr("Edit account"), editAccountMenu); | 136 | configure->insertItem(tr("Edit account"), editAccountMenu); |
137 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 137 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
138 | 138 | ||
139 | bar = new QToolBar(this); | 139 | bar = new QToolBar(this); |
140 | 140 | ||
141 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); | 141 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
142 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); | 142 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); |
143 | 143 | ||
144 | getMailButton->setPopup(selectAccountMenu); | 144 | getMailButton->setPopup(selectAccountMenu); |
145 | 145 | ||
146 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 146 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
147 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 147 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
148 | sendMailButton->addTo(bar); | 148 | sendMailButton->addTo(bar); |
149 | sendMailButton->addTo(mail); | 149 | sendMailButton->addTo(mail); |
150 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); | 150 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); |
151 | 151 | ||
152 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 152 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
153 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 153 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
154 | composeButton->addTo(bar); | 154 | composeButton->addTo(bar); |
155 | composeButton->addTo(mail); | 155 | composeButton->addTo(mail); |
156 | composeButton->setWhatsThis("Compose a new mail"); | 156 | composeButton->setWhatsThis("Compose a new mail"); |
157 | 157 | ||
158 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 158 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
159 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 159 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
160 | cancelButton->addTo(mail); | 160 | cancelButton->addTo(mail); |
161 | cancelButton->addTo(bar); | 161 | cancelButton->addTo(bar); |
162 | cancelButton->setEnabled(FALSE); | 162 | cancelButton->setEnabled(FALSE); |
163 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); | 163 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); |
164 | 164 | ||
165 | 165 | ||
166 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 166 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
167 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 167 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
168 | deleteButton->addTo(bar); | 168 | deleteButton->addTo(bar); |
169 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); | 169 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); |
170 | 170 | ||
171 | mailboxView = new OTabWidget( this, "mailboxView" ); | 171 | mailboxView = new OTabWidget( this, "mailboxView" ); |
172 | 172 | ||
173 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 173 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
174 | grid_2 = new QGridLayout( widget ); | 174 | grid_2 = new QGridLayout( widget ); |
175 | // grid_2->setSpacing(6); | 175 | // grid_2->setSpacing(6); |
176 | // grid_2->setMargin( 11 ); | 176 | // grid_2->setMargin( 11 ); |
177 | 177 | ||
178 | inboxView = new QListView( widget, "inboxView" ); | 178 | inboxView = new QListView( widget, "inboxView" ); |
179 | inboxView->addColumn( tr( "From" ) ); | 179 | inboxView->addColumn( tr( "From" ) ); |
180 | inboxView->addColumn( tr( "Subject" ) ); | 180 | inboxView->addColumn( tr( "Subject" ) ); |
181 | inboxView->addColumn( tr( "Date" ) ); | 181 | inboxView->addColumn( tr( "Date" ) ); |
182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
183 | inboxView->setAllColumnsShowFocus(TRUE); | 183 | inboxView->setAllColumnsShowFocus(TRUE); |
184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" | 184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" |
185 | "It keeps the fetched mail which can be \n" | 185 | "It keeps the fetched mail which can be \n" |
186 | "viewed by double clicking the entry.\n" | 186 | "viewed by double clicking the entry.\n" |
187 | "blue attachment icon shows whether this \n" | 187 | "blue attachment icon shows whether this \n" |
188 | "mailhas attachments.\n")); | 188 | "mailhas attachments.\n")); |
189 | 189 | ||
190 | grid_2->addWidget( inboxView, 2, 0 ); | 190 | grid_2->addWidget( inboxView, 2, 0 ); |
191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
192 | 192 | ||
193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
194 | grid_3 = new QGridLayout( widget_2 ); | 194 | grid_3 = new QGridLayout( widget_2 ); |
195 | // grid_3->setSpacing(6); | 195 | // grid_3->setSpacing(6); |
196 | // grid_3->setMargin( 11 ); | 196 | // grid_3->setMargin( 11 ); |
197 | 197 | ||
198 | outboxView = new QListView( widget_2, "outboxView" ); | 198 | outboxView = new QListView( widget_2, "outboxView" ); |
199 | outboxView->addColumn( tr( "To" ) ); | 199 | outboxView->addColumn( tr( "To" ) ); |
200 | outboxView->addColumn( tr( "Subject" ) ); | 200 | outboxView->addColumn( tr( "Subject" ) ); |
201 | outboxView->setAllColumnsShowFocus(TRUE); | 201 | outboxView->setAllColumnsShowFocus(TRUE); |
202 | 202 | ||
203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" | 203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" |
204 | "It keeps the queued mails to send which can be \n" | 204 | "It keeps the queued mails to send which can be \n" |
205 | "reviewed by double clicking the entry.")); | 205 | "reviewed by double clicking the entry.")); |
206 | grid_3->addWidget( outboxView, 0, 0 ); | 206 | grid_3->addWidget( outboxView, 0, 0 ); |
207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
208 | 208 | ||
209 | setCentralWidget(mailboxView); | 209 | setCentralWidget(mailboxView); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void EmailClient::initStatusBar(QWidget* parent) | 213 | void EmailClient::initStatusBar(QWidget* parent) |
214 | { | 214 | { |
215 | statusBar = new QStatusBar(parent); | 215 | statusBar = new QStatusBar(parent); |
216 | statusBar->setSizeGripEnabled(FALSE); | 216 | statusBar->setSizeGripEnabled(FALSE); |
217 | 217 | ||
218 | status1Label = new QLabel( tr("Idle"), statusBar); | 218 | status1Label = new QLabel( tr("Idle"), statusBar); |
219 | status2Label = new QLabel("", statusBar); | 219 | status2Label = new QLabel("", statusBar); |
220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
221 | status2Label, SLOT(setText(const QString &)) ); | 221 | status2Label, SLOT(setText(const QString &)) ); |
222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
223 | status2Label, SLOT(setText(const QString &)) ); | 223 | status2Label, SLOT(setText(const QString &)) ); |
224 | 224 | ||
225 | progressBar = new QProgressBar(statusBar); | 225 | progressBar = new QProgressBar(statusBar); |
226 | 226 | ||
227 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 227 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
228 | this, SLOT(setTotalSize(int)) ); | 228 | this, SLOT(setTotalSize(int)) ); |
229 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 229 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
230 | this, SLOT(setMailSize(int)) ); | 230 | this, SLOT(setMailSize(int)) ); |
231 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 231 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
232 | this, SLOT(setDownloadedSize(int)) ); | 232 | this, SLOT(setDownloadedSize(int)) ); |
233 | 233 | ||
234 | statusBar->addWidget(status1Label); | 234 | statusBar->addWidget(status1Label); |
235 | statusBar->addWidget(progressBar); | 235 | statusBar->addWidget(progressBar); |
236 | statusBar->addWidget(status2Label); | 236 | statusBar->addWidget(status2Label); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void EmailClient::compose() | 240 | void EmailClient::compose() |
241 | { | 241 | { |
242 | emit composeRequested(); | 242 | emit composeRequested(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void EmailClient::cancel() | 245 | void EmailClient::cancel() |
246 | { | 246 | { |
247 | emailHandler->cancel(); | 247 | emailHandler->cancel(); |
248 | } | 248 | } |
249 | 249 | ||
250 | AddressList* EmailClient::getAdrListRef() | 250 | AddressList* EmailClient::getAdrListRef() |
251 | { | 251 | { |
252 | return addressList; | 252 | return addressList; |
253 | } | 253 | } |
254 | 254 | ||
255 | //this needs to be rewritten to syncronize with outboxView | 255 | //this needs to be rewritten to syncronize with outboxView |
256 | void EmailClient::enqueMail(const Email &mail) | 256 | void EmailClient::enqueMail(const Email &mail) |
257 | { | 257 | { |
258 | if (accountList.count() == 0) { | 258 | if (accountList.count() == 0) { |
259 | QMessageBox::warning(qApp->activeWindow(), | 259 | QMessageBox::warning(qApp->activeWindow(), |
260 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 260 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | if (accountList.count() > 0) { | 264 | if (accountList.count() > 0) { |
265 | currentAccount = accountList.first(); | 265 | currentAccount = accountList.first(); |
266 | qWarning("using account " + currentAccount->name); | 266 | qWarning("using account " + currentAccount->name); |
267 | } | 267 | } |
268 | 268 | ||
269 | Email addMail = mail; | 269 | Email addMail = mail; |
270 | addMail.from = currentAccount->name; | 270 | addMail.from = currentAccount->name; |
271 | addMail.fromMail = currentAccount->emailAddress; | 271 | addMail.fromMail = currentAccount->emailAddress; |
272 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 272 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
273 | item = new EmailListItem(outboxView, addMail, false); | 273 | item = new EmailListItem(outboxView, addMail, false); |
274 | 274 | ||
275 | mailboxView->setCurrentTab(1); | 275 | mailboxView->setCurrentTab(1); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | void EmailClient::sendQuedMail() | 279 | void EmailClient::sendQuedMail() |
280 | { | 280 | { |
281 | int count = 0; | 281 | int count = 0; |
282 | 282 | ||
283 | if (accountList.count() == 0) { | 283 | if (accountList.count() == 0) { |
284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | //traverse listview, find messages to send | 287 | //traverse listview, find messages to send |
288 | if (! sending) { | 288 | if (! sending) { |
289 | item = (EmailListItem *) outboxView->firstChild(); | 289 | item = (EmailListItem *) outboxView->firstChild(); |
290 | if (item != NULL) { | 290 | if (item != NULL) { |
291 | while (item != NULL) { | 291 | while (item != NULL) { |
292 | quedMessages.append(item->getMail()); | 292 | quedMessages.append(item->getMail()); |
293 | item = (EmailListItem *) item->nextSibling(); | 293 | item = (EmailListItem *) item->nextSibling(); |
294 | count++; | 294 | count++; |
295 | } | 295 | } |
296 | setMailAccount(); | 296 | setMailAccount(); |
297 | emailHandler->sendMail(&quedMessages); | 297 | emailHandler->sendMail(&quedMessages); |
298 | sending = TRUE; | 298 | sending = TRUE; |
299 | sendMailButton->setEnabled(FALSE); | 299 | sendMailButton->setEnabled(FALSE); |
300 | cancelButton->setEnabled(TRUE); | 300 | cancelButton->setEnabled(TRUE); |
301 | } else { | 301 | } else { |
302 | qWarning("sendQuedMail(): no messages to send"); | 302 | qWarning("sendQuedMail(): no messages to send"); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::setMailAccount() | 307 | void EmailClient::setMailAccount() |
308 | { | 308 | { |
309 | emailHandler->setAccount(*currentAccount); | 309 | emailHandler->setAccount(*currentAccount); |
310 | } | 310 | } |
311 | 311 | ||
312 | void EmailClient::mailSent() | 312 | void EmailClient::mailSent() |
313 | { | 313 | { |
314 | sending = FALSE; | 314 | sending = FALSE; |
315 | sendMailButton->setEnabled(TRUE); | 315 | sendMailButton->setEnabled(TRUE); |
316 | 316 | ||
317 | quedMessages.clear(); | 317 | quedMessages.clear(); |
318 | outboxView->clear(); //should be moved to an sentBox | 318 | outboxView->clear(); //should be moved to an sentBox |
319 | } | 319 | } |
320 | 320 | ||
321 | void EmailClient::getNewMail() { | 321 | void EmailClient::getNewMail() { |
322 | 322 | ||
323 | if (accountList.count() == 0) { | 323 | if (accountList.count() == 0) { |
324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
325 | "You must create an account", "OK\n"); | 325 | "You must create an account", "OK\n"); |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | 328 | ||
329 | setMailAccount(); | 329 | setMailAccount(); |
330 | 330 | ||
331 | receiving = TRUE; | 331 | receiving = TRUE; |
332 | previewingMail = TRUE; | 332 | previewingMail = TRUE; |
333 | getMailButton->setEnabled(FALSE); | 333 | getMailButton->setEnabled(FALSE); |
334 | cancelButton->setEnabled(TRUE); | 334 | cancelButton->setEnabled(TRUE); |
335 | selectAccountMenu->setEnabled(FALSE); | 335 | selectAccountMenu->setEnabled(FALSE); |
336 | 336 | ||
337 | status1Label->setText(currentAccount->accountName + " headers"); | 337 | status1Label->setText(currentAccount->accountName + " headers"); |
338 | progressBar->reset(); | 338 | progressBar->reset(); |
339 | 339 | ||
340 | //get any previous mails not downloaded and add to queue | 340 | //get any previous mails not downloaded and add to queue |
341 | /*mailDownloadList.clear(); | 341 | /*mailDownloadList.clear(); |
342 | Email *mailPtr; | 342 | Email *mailPtr; |
343 | item = (EmailListItem *) inboxView->firstChild(); | 343 | item = (EmailListItem *) inboxView->firstChild(); |
344 | while (item != NULL) { | 344 | while (item != NULL) { |
345 | mailPtr = item->getMail(); | 345 | mailPtr = item->getMail(); |
346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
348 | } | 348 | } |
349 | item = (EmailListItem *) item->nextSibling(); | 349 | item = (EmailListItem *) item->nextSibling(); |
350 | }*/ | 350 | }*/ |
351 | 351 | ||
352 | emailHandler->getMailHeaders(); | 352 | emailHandler->getMailHeaders(); |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void EmailClient::getAllNewMail() | 356 | void EmailClient::getAllNewMail() |
357 | { | 357 | { |
358 | allAccounts = TRUE; | 358 | allAccounts = TRUE; |
359 | currentAccount = accountList.first(); | 359 | currentAccount = accountList.first(); |
360 | getNewMail(); | 360 | getNewMail(); |
361 | } | 361 | } |
362 | 362 | ||
363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
364 | { | 364 | { |
365 | Enclosure *ePtr; | 365 | Enclosure *ePtr; |
366 | Email newMail; | 366 | Email newMail; |
367 | int thisMailId; | 367 | int thisMailId; |
368 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 368 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
369 | mailconf->setGroup(newMail.id); | 369 | mailconf->setGroup(newMail.id); |
370 | 370 | ||
371 | if (fromDisk) | 371 | if (fromDisk) |
372 | { | 372 | { |
373 | 373 | ||
374 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 374 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
375 | newMail.size = mailconf->readNumEntry("size"); | 375 | newMail.size = mailconf->readNumEntry("size"); |
376 | newMail.serverId = mailconf->readNumEntry("serverid"); | 376 | newMail.serverId = mailconf->readNumEntry("serverid"); |
377 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 377 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
378 | } | 378 | } |
379 | else | 379 | else |
380 | { //mail arrived from server | 380 | { //mail arrived from server |
381 | 381 | ||
382 | newMail.serverId = mail.serverId; | 382 | newMail.serverId = mail.serverId; |
383 | newMail.size = mail.size; | 383 | newMail.size = mail.size; |
384 | newMail.downloaded = mail.downloaded; | 384 | newMail.downloaded = mail.downloaded; |
385 | 385 | ||
386 | newMail.fromAccountId = emailHandler->getAccount()->id; | 386 | newMail.fromAccountId = emailHandler->getAccount()->id; |
387 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 387 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
388 | } | 388 | } |
389 | 389 | ||
390 | //add if read or not | 390 | //add if read or not |
391 | newMail.read = mailconf->readBoolEntry("mailread"); | 391 | newMail.read = mailconf->readBoolEntry("mailread"); |
392 | 392 | ||
393 | //check if new mail | 393 | //check if new mail |
394 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 394 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
395 | thisMailId = mailIdCount; | 395 | thisMailId = mailIdCount; |
396 | mailIdCount++; | 396 | mailIdCount++; |
397 | 397 | ||
398 | //set server count, so that if the user aborts, the new | 398 | //set server count, so that if the user aborts, the new |
399 | //header is not reloaded | 399 | //header is not reloaded |
400 | if ((currentAccount)&&(currentAccount->synchronize)) | 400 | if ((currentAccount)&&(currentAccount->synchronize)) |
401 | currentAccount->lastServerMailCount++; | 401 | currentAccount->lastServerMailCount++; |
402 | 402 | ||
403 | mailconf->writeEntry("internalmailid", thisMailId); | 403 | mailconf->writeEntry("internalmailid", thisMailId); |
404 | mailconf->writeEntry("downloaded", newMail.downloaded); | 404 | mailconf->writeEntry("downloaded", newMail.downloaded); |
405 | mailconf->writeEntry("size", (int) newMail.size); | 405 | mailconf->writeEntry("size", (int) newMail.size); |
406 | mailconf->writeEntry("serverid", newMail.serverId); | 406 | mailconf->writeEntry("serverid", newMail.serverId); |
407 | 407 | ||
408 | //addressList->addContact(newMail.fromMail, newMail.from); | 408 | //addressList->addContact(newMail.fromMail, newMail.from); |
409 | } | 409 | } |
410 | 410 | ||
411 | mailconf->writeEntry("downloaded", newMail.downloaded); | 411 | mailconf->writeEntry("downloaded", newMail.downloaded); |
412 | 412 | ||
413 | QString stringMailId; | 413 | QString stringMailId; |
414 | stringMailId.setNum(thisMailId); | 414 | stringMailId.setNum(thisMailId); |
415 | //see if any attatchments needs to be stored | 415 | //see if any attatchments needs to be stored |
416 | 416 | ||
417 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { | 417 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { |
418 | QString stringId; | 418 | QString stringId; |
419 | stringId.setNum(ePtr->id); | 419 | stringId.setNum(ePtr->id); |
420 | 420 | ||
421 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 421 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
422 | if (id != ePtr->id) { //new entry | 422 | if (id != ePtr->id) { //new entry |
423 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 423 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
424 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 424 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
425 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 425 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
426 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 426 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
427 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 427 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
428 | mailconf->writeEntry("installed_" + stringId, FALSE); | 428 | mailconf->writeEntry("installed_" + stringId, FALSE); |
429 | 429 | ||
430 | ePtr->name = stringMailId + "_" + stringId; | 430 | ePtr->name = stringMailId + "_" + stringId; |
431 | ePtr->path = getPath(TRUE); | 431 | ePtr->path = getPath(TRUE); |
432 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 432 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
433 | ePtr->saved = TRUE; | 433 | ePtr->saved = TRUE; |
434 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 434 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
435 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 435 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
436 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 436 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
437 | } else { | 437 | } else { |
438 | ePtr->saved = FALSE; | 438 | ePtr->saved = FALSE; |
439 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 439 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
440 | } | 440 | } |
441 | } else { | 441 | } else { |
442 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 442 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
443 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 443 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
444 | if (ePtr->saved) { | 444 | if (ePtr->saved) { |
445 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 445 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
446 | ePtr->path = mailconf->readEntry("path_" + stringId); | 446 | ePtr->path = mailconf->readEntry("path_" + stringId); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | bool found=false; | 451 | bool found=false; |
452 | 452 | ||
453 | if (!fromDisk) | 453 | if (!fromDisk) |
454 | { | 454 | { |
455 | 455 | ||
456 | Email *mailPtr; | 456 | Email *mailPtr; |
457 | item = (EmailListItem *) inboxView->firstChild(); | 457 | item = (EmailListItem *) inboxView->firstChild(); |
458 | while ((item != NULL)&&(!found)) | 458 | while ((item != NULL)&&(!found)) |
459 | { | 459 | { |
460 | mailPtr = item->getMail(); | 460 | mailPtr = item->getMail(); |
461 | if (mailPtr->id == newMail.id) { | 461 | if (mailPtr->id == newMail.id) { |
462 | item->setMail(newMail); | 462 | item->setMail(newMail); |
463 | emit mailUpdated(item->getMail()); | 463 | emit mailUpdated(item->getMail()); |
464 | found = true; | 464 | found = true; |
465 | } | 465 | } |
466 | item = (EmailListItem *) item->nextSibling(); | 466 | item = (EmailListItem *) item->nextSibling(); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); | 469 | if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); |
470 | 470 | ||
471 | if (item->getMail()->files.count()>0) | ||
472 | { | ||
473 | item->setPixmap(0, Resource::loadPixmap("mailit/attach")); | ||
474 | } | ||
471 | /*if (!newMail.downloaded) | 475 | /*if (!newMail.downloaded) |
472 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ | 476 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ |
473 | 477 | ||
474 | mailboxView->setCurrentTab(0); | 478 | mailboxView->setCurrentTab(0); |
475 | 479 | ||
476 | } | 480 | } |
477 | 481 | ||
478 | void EmailClient::allMailArrived(int count) | 482 | void EmailClient::allMailArrived(int count) |
479 | { | 483 | { |
480 | // not previewing means all mailtransfer has been done | 484 | // not previewing means all mailtransfer has been done |
481 | /*if (!previewingMail) {*/ | 485 | /*if (!previewingMail) {*/ |
482 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 486 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
483 | emit newCaption("Mailit - " + currentAccount->accountName); | 487 | emit newCaption("Mailit - " + currentAccount->accountName); |
484 | getNewMail(); | 488 | getNewMail(); |
485 | return; | 489 | return; |
486 | } else { | 490 | } else { |
487 | allAccounts = FALSE; | 491 | allAccounts = FALSE; |
488 | receiving = FALSE; | 492 | receiving = FALSE; |
489 | getMailButton->setEnabled(TRUE); | 493 | getMailButton->setEnabled(TRUE); |
490 | cancelButton->setEnabled(FALSE); | 494 | cancelButton->setEnabled(FALSE); |
491 | selectAccountMenu->setEnabled(TRUE); | 495 | selectAccountMenu->setEnabled(TRUE); |
492 | status1Label->setText("Idle"); | 496 | status1Label->setText("Idle"); |
493 | 497 | ||
494 | progressBar->reset(); | 498 | progressBar->reset(); |
495 | return; | 499 | return; |
496 | } | 500 | } |
497 | //} | 501 | //} |
498 | 502 | ||
499 | // all headers downloaded from server, start downloading remaining mails | 503 | // all headers downloaded from server, start downloading remaining mails |
500 | previewingMail = FALSE; | 504 | previewingMail = FALSE; |
501 | status1Label->setText(currentAccount->accountName); | 505 | status1Label->setText(currentAccount->accountName); |
502 | progressBar->reset(); | 506 | progressBar->reset(); |
503 | 507 | ||
504 | 508 | ||
505 | mailboxView->setCurrentTab(0); | 509 | mailboxView->setCurrentTab(0); |
506 | } | 510 | } |
507 | 511 | ||
508 | 512 | ||
509 | void EmailClient::moveMailFront(Email *mailPtr) | 513 | void EmailClient::moveMailFront(Email *mailPtr) |
510 | { | 514 | { |
511 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 515 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
512 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 516 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
513 | } | 517 | } |
514 | } | 518 | } |
515 | 519 | ||
516 | void EmailClient::smtpError(int code) | 520 | void EmailClient::smtpError(int code) |
517 | { | 521 | { |
518 | QString temp; | 522 | QString temp; |
519 | 523 | ||
520 | if (code == ErrUnknownResponse) | 524 | if (code == ErrUnknownResponse) |
521 | temp = "Unknown response from server"; | 525 | temp = "Unknown response from server"; |
522 | 526 | ||
523 | if (code == QSocket::ErrHostNotFound) | 527 | if (code == QSocket::ErrHostNotFound) |
524 | temp = "host not found"; | 528 | temp = "host not found"; |
525 | if (code == QSocket::ErrConnectionRefused) | 529 | if (code == QSocket::ErrConnectionRefused) |
526 | temp = "connection refused"; | 530 | temp = "connection refused"; |
527 | if (code == QSocket::ErrSocketRead) | 531 | if (code == QSocket::ErrSocketRead) |
528 | temp = "socket packet error"; | 532 | temp = "socket packet error"; |
529 | 533 | ||
530 | if (code != ErrCancel) { | 534 | if (code != ErrCancel) { |
531 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 535 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
532 | } else { | 536 | } else { |
533 | status2Label->setText("Aborted by user"); | 537 | status2Label->setText("Aborted by user"); |
534 | } | 538 | } |
535 | 539 | ||
536 | sending = FALSE; | 540 | sending = FALSE; |
537 | sendMailButton->setEnabled(TRUE); | 541 | sendMailButton->setEnabled(TRUE); |
538 | cancelButton->setEnabled(FALSE); | 542 | cancelButton->setEnabled(FALSE); |
539 | quedMessages.clear(); | 543 | quedMessages.clear(); |
540 | } | 544 | } |
541 | 545 | ||
542 | void EmailClient::popError(int code) | 546 | void EmailClient::popError(int code) |
543 | { | 547 | { |
544 | QString temp; | 548 | QString temp; |
545 | 549 | ||
546 | if (code == ErrUnknownResponse) | 550 | if (code == ErrUnknownResponse) |
547 | temp = "Unknown response from server"; | 551 | temp = "Unknown response from server"; |
548 | if (code == ErrLoginFailed) | 552 | if (code == ErrLoginFailed) |
549 | temp = "Login failed\nCheck user name and password"; | 553 | temp = "Login failed\nCheck user name and password"; |
550 | 554 | ||
551 | if (code == QSocket::ErrHostNotFound) | 555 | if (code == QSocket::ErrHostNotFound) |
552 | temp = "host not found"; | 556 | temp = "host not found"; |
553 | if (code == QSocket::ErrConnectionRefused) | 557 | if (code == QSocket::ErrConnectionRefused) |
554 | temp = "connection refused"; | 558 | temp = "connection refused"; |
555 | if (code == QSocket::ErrSocketRead) | 559 | if (code == QSocket::ErrSocketRead) |
556 | temp = "socket packet error"; | 560 | temp = "socket packet error"; |
557 | 561 | ||
558 | if (code != ErrCancel) { | 562 | if (code != ErrCancel) { |
559 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 563 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
560 | } else { | 564 | } else { |
561 | status2Label->setText("Aborted by user"); | 565 | status2Label->setText("Aborted by user"); |
562 | } | 566 | } |
563 | 567 | ||
564 | receiving = FALSE; | 568 | receiving = FALSE; |
565 | getMailButton->setEnabled(TRUE); | 569 | getMailButton->setEnabled(TRUE); |
566 | cancelButton->setEnabled(FALSE); | 570 | cancelButton->setEnabled(FALSE); |
567 | selectAccountMenu->setEnabled(TRUE); | 571 | selectAccountMenu->setEnabled(TRUE); |
568 | } | 572 | } |
569 | 573 | ||
570 | void EmailClient::inboxItemSelected() | 574 | void EmailClient::inboxItemSelected() |
571 | { | 575 | { |
572 | //killTimer(timerID); | 576 | //killTimer(timerID); |
573 | 577 | ||
574 | item = (EmailListItem*) inboxView->selectedItem(); | 578 | item = (EmailListItem*) inboxView->selectedItem(); |
575 | if (item != NULL) { | 579 | if (item != NULL) { |
576 | emit viewEmail(inboxView, item->getMail()); | 580 | emit viewEmail(inboxView, item->getMail()); |
577 | } | 581 | } |
578 | } | 582 | } |
579 | 583 | ||
580 | void EmailClient::outboxItemSelected() | 584 | void EmailClient::outboxItemSelected() |
581 | { | 585 | { |
582 | //killTimer(timerID); | 586 | //killTimer(timerID); |
583 | 587 | ||
584 | item = (EmailListItem*) outboxView->selectedItem(); | 588 | item = (EmailListItem*) outboxView->selectedItem(); |
585 | if (item != NULL) { | 589 | if (item != NULL) { |
586 | emit viewEmail(outboxView, item->getMail()); | 590 | emit viewEmail(outboxView, item->getMail()); |
587 | } | 591 | } |
588 | 592 | ||
589 | } | 593 | } |
590 | 594 | ||
591 | void EmailClient::readMail() | 595 | void EmailClient::readMail() |
592 | { | 596 | { |
593 | Email mail; | 597 | Email mail; |
594 | int start, stop; | 598 | int start, stop; |
595 | QString s, del; | 599 | QString s, del; |
596 | 600 | ||
597 | QFile f(getPath(FALSE) + "inbox.txt"); | 601 | QFile f(getPath(FALSE) + "inbox.txt"); |
598 | 602 | ||
599 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 603 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
600 | QTextStream t( &f ); // use a text stream | 604 | QTextStream t( &f ); // use a text stream |
601 | s = t.read(); | 605 | s = t.read(); |
602 | f.close(); | 606 | f.close(); |
603 | 607 | ||
604 | start = 0; | 608 | start = 0; |
605 | del = "\n.\n"; | 609 | del = "\n.\n"; |
606 | while ((uint) start < s.length()) { | 610 | while ((uint) start < s.length()) { |
607 | stop = s.find(del, start); | 611 | stop = s.find(del, start); |
608 | if (stop == -1) | 612 | if (stop == -1) |
609 | stop = s.length() - del.length(); | 613 | stop = s.length() - del.length(); |
610 | 614 | ||
611 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 615 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
612 | start = stop + del.length(); | 616 | start = stop + del.length(); |
613 | mailArrived(mail, TRUE); | 617 | mailArrived(mail, TRUE); |
614 | } | 618 | } |
615 | } | 619 | } |
616 | 620 | ||
617 | QFile fo(getPath(FALSE) + "outbox.txt"); | 621 | QFile fo(getPath(FALSE) + "outbox.txt"); |
618 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 622 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
619 | QTextStream t( &fo ); // use a text stream | 623 | QTextStream t( &fo ); // use a text stream |
620 | s = t.read(); | 624 | s = t.read(); |
621 | fo.close(); | 625 | fo.close(); |
622 | 626 | ||
623 | start = 0; | 627 | start = 0; |
624 | del = "\n.\n"; | 628 | del = "\n.\n"; |
625 | while ((uint) start < s.length()) { | 629 | while ((uint) start < s.length()) { |
626 | stop = s.find(del, start); | 630 | stop = s.find(del, start); |
627 | if (stop == -1) | 631 | if (stop == -1) |
628 | stop = s.length() - del.length(); | 632 | stop = s.length() - del.length(); |
629 | 633 | ||
630 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 634 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
631 | start = stop + del.length(); | 635 | start = stop + del.length(); |
632 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 636 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
633 | mail.sent = false; | 637 | mail.sent = false; |
634 | mail.received = false; | 638 | mail.received = false; |
635 | enqueMail(mail); | 639 | enqueMail(mail); |
636 | 640 | ||
637 | } | 641 | } |
638 | } | 642 | } |
639 | } | 643 | } |
640 | 644 | ||
641 | void EmailClient::saveMail(QString fileName, QListView *view) | 645 | void EmailClient::saveMail(QString fileName, QListView *view) |
642 | { | 646 | { |
643 | QFile f(fileName); | 647 | QFile f(fileName); |
644 | Email *mail; | 648 | Email *mail; |
645 | 649 | ||
646 | if (! f.open(IO_WriteOnly) ) { | 650 | if (! f.open(IO_WriteOnly) ) { |
647 | qWarning("could not open file"); | 651 | qWarning("could not open file"); |
648 | return; | 652 | return; |
649 | } | 653 | } |
650 | item = (EmailListItem *) view->firstChild(); | 654 | item = (EmailListItem *) view->firstChild(); |
651 | QTextStream t(&f); | 655 | QTextStream t(&f); |
652 | while (item != NULL) { | 656 | while (item != NULL) { |
653 | mail = item->getMail(); | 657 | mail = item->getMail(); |
654 | t << mail->rawMail; | 658 | t << mail->rawMail; |
655 | 659 | ||
656 | mailconf->setGroup(mail->id); | 660 | mailconf->setGroup(mail->id); |
657 | mailconf->writeEntry("mailread", mail->read); | 661 | mailconf->writeEntry("mailread", mail->read); |
658 | 662 | ||
659 | item = (EmailListItem *) item->nextSibling(); | 663 | item = (EmailListItem *) item->nextSibling(); |
660 | } | 664 | } |
661 | f.close(); | 665 | f.close(); |
662 | } | 666 | } |
663 | 667 | ||
664 | //paths for mailit, is settings, inbox, enclosures | 668 | //paths for mailit, is settings, inbox, enclosures |
665 | QString EmailClient::getPath(bool enclosurePath) | 669 | QString EmailClient::getPath(bool enclosurePath) |
666 | { | 670 | { |
667 | QString basePath = "qtmail"; | 671 | QString basePath = "qtmail"; |
668 | QString enclosures = "enclosures"; | 672 | QString enclosures = "enclosures"; |
669 | 673 | ||
670 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 674 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
671 | if ( !dir.exists() ) | 675 | if ( !dir.exists() ) |
672 | dir.mkdir( dir.path() ); | 676 | dir.mkdir( dir.path() ); |
673 | 677 | ||
674 | if (enclosurePath) { | 678 | if (enclosurePath) { |
675 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 679 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
676 | 680 | ||
677 | if ( !dir.exists() ) | 681 | if ( !dir.exists() ) |
678 | dir.mkdir( dir.path() ); | 682 | dir.mkdir( dir.path() ); |
679 | 683 | ||
680 | return (dir.path() + "/"); | 684 | return (dir.path() + "/"); |
681 | 685 | ||
682 | } | 686 | } |
683 | return (dir.path() + "/"); | 687 | return (dir.path() + "/"); |
684 | } | 688 | } |
685 | 689 | ||
686 | void EmailClient::readSettings() | 690 | void EmailClient::readSettings() |
687 | { | 691 | { |
688 | int y,acc_count; | 692 | int y,acc_count; |
689 | 693 | ||
690 | mailconf->setGroup("mailitglobal"); | 694 | mailconf->setGroup("mailitglobal"); |
691 | acc_count=mailconf->readNumEntry("Accounts",0); | 695 | acc_count=mailconf->readNumEntry("Accounts",0); |
692 | 696 | ||
693 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) | 697 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) |
694 | { | 698 | { |
695 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... | 699 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... |
696 | account.accountName = mailconf->readEntry("AccName",""); | 700 | account.accountName = mailconf->readEntry("AccName",""); |
697 | account.name = mailconf->readEntry("UserName",""); | 701 | account.name = mailconf->readEntry("UserName",""); |
698 | account.emailAddress = mailconf->readEntry("Email",""); | 702 | account.emailAddress = mailconf->readEntry("Email",""); |
699 | account.popUserName = mailconf->readEntry("POPUser",""); | 703 | account.popUserName = mailconf->readEntry("POPUser",""); |
700 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); | 704 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); |
701 | account.popServer = mailconf->readEntry("POPServer",""); | 705 | account.popServer = mailconf->readEntry("POPServer",""); |
702 | account.smtpServer = mailconf->readEntry("SMTPServer",""); | 706 | account.smtpServer = mailconf->readEntry("SMTPServer",""); |
703 | account.id = mailconf->readNumEntry("AccountId",0); | 707 | account.id = mailconf->readNumEntry("AccountId",0); |
704 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); | 708 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); |
705 | account.lastServerMailCount = 0; | 709 | account.lastServerMailCount = 0; |
706 | account.synchronize = FALSE; | 710 | account.synchronize = FALSE; |
707 | 711 | ||
708 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); | 712 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); |
709 | if (account.synchronize) | 713 | if (account.synchronize) |
710 | { | 714 | { |
711 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); | 715 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); |
712 | } | 716 | } |
713 | 717 | ||
714 | accountList.append(&account); | 718 | accountList.append(&account); |
715 | } | 719 | } |
716 | 720 | ||
717 | mailconf->setGroup("mailitglobal"); | 721 | mailconf->setGroup("mailitglobal"); |
718 | 722 | ||
719 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) | 723 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) |
720 | { | 724 | { |
721 | mailIdCount = y; | 725 | mailIdCount = y; |
722 | } | 726 | } |
723 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) | 727 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) |
724 | { | 728 | { |
725 | accountIdCount = y; | 729 | accountIdCount = y; |
726 | } | 730 | } |
727 | } | 731 | } |
728 | 732 | ||
729 | void EmailClient::saveSettings() | 733 | void EmailClient::saveSettings() |
730 | { | 734 | { |
731 | int acc_count=0; | 735 | int acc_count=0; |
732 | MailAccount *accountPtr; | 736 | MailAccount *accountPtr; |
733 | 737 | ||
734 | 738 | ||
735 | if (!mailconf) | 739 | if (!mailconf) |
736 | { | 740 | { |
737 | qWarning("could not save settings"); | 741 | qWarning("could not save settings"); |
738 | return; | 742 | return; |
739 | } | 743 | } |
740 | 744 | ||
741 | for (accountPtr = accountList.first(); accountPtr != 0; | 745 | for (accountPtr = accountList.first(); accountPtr != 0; |
742 | accountPtr = accountList.next()) | 746 | accountPtr = accountList.next()) |
743 | { | 747 | { |
744 | mailconf->setGroup("Account_"+QString::number(++acc_count)); | 748 | mailconf->setGroup("Account_"+QString::number(++acc_count)); |
745 | mailconf->writeEntry("AccName",accountPtr->accountName ); | 749 | mailconf->writeEntry("AccName",accountPtr->accountName ); |
746 | mailconf->writeEntry("UserName",accountPtr->name); | 750 | mailconf->writeEntry("UserName",accountPtr->name); |
747 | mailconf->writeEntry("Email",accountPtr->emailAddress); | 751 | mailconf->writeEntry("Email",accountPtr->emailAddress); |
748 | mailconf->writeEntry("POPUser",accountPtr->popUserName); | 752 | mailconf->writeEntry("POPUser",accountPtr->popUserName); |
749 | mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); | 753 | mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); |
750 | mailconf->writeEntry("POPServer",accountPtr->popServer); | 754 | mailconf->writeEntry("POPServer",accountPtr->popServer); |
751 | mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); | 755 | mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); |
752 | mailconf->writeEntry("AccountId",accountPtr->id); | 756 | mailconf->writeEntry("AccountId",accountPtr->id); |
753 | if (accountPtr->synchronize) | 757 | if (accountPtr->synchronize) |
754 | { | 758 | { |
755 | mailconf->writeEntry("Synchronize","Yes"); | 759 | mailconf->writeEntry("Synchronize","Yes"); |
756 | mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); | 760 | mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); |
757 | mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); | 761 | mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); |
758 | } | 762 | } |
759 | else | 763 | else |
760 | { | 764 | { |
761 | mailconf->writeEntry("Synchronize", "No"); | 765 | mailconf->writeEntry("Synchronize", "No"); |
762 | } | 766 | } |
763 | } | 767 | } |
764 | 768 | ||
765 | mailconf->setGroup("mailitglobal"); | 769 | mailconf->setGroup("mailitglobal"); |
766 | mailconf->writeEntry("Accounts",acc_count); | 770 | mailconf->writeEntry("Accounts",acc_count); |
767 | mailconf->writeEntry("mailidcount", mailIdCount); | 771 | mailconf->writeEntry("mailidcount", mailIdCount); |
768 | mailconf->writeEntry("accountidcount", accountIdCount); | 772 | mailconf->writeEntry("accountidcount", accountIdCount); |
769 | } | 773 | } |
770 | 774 | ||
771 | void EmailClient::selectAccount(int id) | 775 | void EmailClient::selectAccount(int id) |
772 | { | 776 | { |
773 | if (accountList.count() > 0) { | 777 | if (accountList.count() > 0) { |
774 | currentAccount = accountList.at(id); | 778 | currentAccount = accountList.at(id); |
775 | emit newCaption("Mailit - " + currentAccount->accountName); | 779 | emit newCaption("Mailit - " + currentAccount->accountName); |
776 | getNewMail(); | 780 | getNewMail(); |
777 | } else { | 781 | } else { |
778 | emit newCaption("Mailit ! No account defined"); | 782 | emit newCaption("Mailit ! No account defined"); |
779 | } | 783 | } |
780 | } | 784 | } |
781 | 785 | ||
782 | void EmailClient::editAccount(int id) | 786 | void EmailClient::editAccount(int id) |
783 | { | 787 | { |
784 | MailAccount *newAccount; | 788 | MailAccount *newAccount; |
785 | 789 | ||
786 | editAccountView = new EditAccount(this, "account", TRUE); | 790 | editAccountView = new EditAccount(this, "account", TRUE); |
787 | if (id == newAccountId) { //new account | 791 | if (id == newAccountId) { //new account |
788 | newAccount = new MailAccount; | 792 | newAccount = new MailAccount; |
789 | editAccountView->setAccount(newAccount); | 793 | editAccountView->setAccount(newAccount); |
790 | } else { | 794 | } else { |
791 | newAccount = accountList.at(id); | 795 | newAccount = accountList.at(id); |
792 | editAccountView->setAccount(newAccount, FALSE); | 796 | editAccountView->setAccount(newAccount, FALSE); |
793 | } | 797 | } |
794 | 798 | ||
795 | editAccountView->showMaximized(); | 799 | editAccountView->showMaximized(); |
796 | editAccountView->exec(); | 800 | editAccountView->exec(); |
797 | 801 | ||
798 | if (editAccountView->result() == QDialog::Accepted) { | 802 | if (editAccountView->result() == QDialog::Accepted) { |
799 | if (id == newAccountId) { | 803 | if (id == newAccountId) { |
800 | newAccount->id = accountIdCount; | 804 | newAccount->id = accountIdCount; |
801 | accountIdCount++; | 805 | accountIdCount++; |
802 | accountList.append(newAccount); | 806 | accountList.append(newAccount); |
803 | updateAccounts(); | 807 | updateAccounts(); |
804 | } else { | 808 | } else { |
805 | updateAccounts(); | 809 | updateAccounts(); |
806 | } | 810 | } |
807 | } | 811 | } |
808 | 812 | ||
809 | delete editAccountView; | 813 | delete editAccountView; |
810 | } | 814 | } |
811 | 815 | ||
812 | void EmailClient::deleteAccount(int id) | 816 | void EmailClient::deleteAccount(int id) |
813 | { | 817 | { |
814 | MailAccount *newAccount; | 818 | MailAccount *newAccount; |
815 | QString message; | 819 | QString message; |
816 | 820 | ||
817 | newAccount = accountList.at(id); | 821 | newAccount = accountList.at(id); |
818 | message = "Delete account:\n" + newAccount->accountName; | 822 | message = "Delete account:\n" + newAccount->accountName; |
819 | switch( QMessageBox::warning( this, "Mailit", message, | 823 | switch( QMessageBox::warning( this, "Mailit", message, |
820 | "Yes", "No", 0, 0, 1 ) ) { | 824 | "Yes", "No", 0, 0, 1 ) ) { |
821 | 825 | ||
822 | case 0: accountList.remove(id); | 826 | case 0: accountList.remove(id); |
823 | updateAccounts(); | 827 | updateAccounts(); |
824 | break; | 828 | break; |
825 | case 1: | 829 | case 1: |
826 | break; | 830 | break; |
827 | } | 831 | } |
828 | } | 832 | } |
829 | 833 | ||
830 | void EmailClient::updateAccounts() | 834 | void EmailClient::updateAccounts() |
831 | { | 835 | { |
832 | MailAccount *accountPtr; | 836 | MailAccount *accountPtr; |
833 | 837 | ||
834 | //rebuild menus, clear all first | 838 | //rebuild menus, clear all first |
835 | editAccountMenu->clear(); | 839 | editAccountMenu->clear(); |
836 | selectAccountMenu->clear(); | 840 | selectAccountMenu->clear(); |
837 | deleteAccountMenu->clear(); | 841 | deleteAccountMenu->clear(); |
838 | 842 | ||
839 | newAccountId = editAccountMenu->insertItem("New", this, | 843 | newAccountId = editAccountMenu->insertItem("New", this, |
840 | SLOT(editAccount(int)) ); | 844 | SLOT(editAccount(int)) ); |
841 | editAccountMenu->insertSeparator(); | 845 | editAccountMenu->insertSeparator(); |
842 | 846 | ||
843 | idCount = 0; | 847 | idCount = 0; |
844 | for (accountPtr = accountList.first(); accountPtr != 0; | 848 | for (accountPtr = accountList.first(); accountPtr != 0; |
845 | accountPtr = accountList.next()) { | 849 | accountPtr = accountList.next()) { |
846 | 850 | ||
847 | editAccountMenu->insertItem(accountPtr->accountName, | 851 | editAccountMenu->insertItem(accountPtr->accountName, |
848 | this, SLOT(editAccount(int)), 0, idCount); | 852 | this, SLOT(editAccount(int)), 0, idCount); |
849 | selectAccountMenu->insertItem(accountPtr->accountName, | 853 | selectAccountMenu->insertItem(accountPtr->accountName, |
850 | this, SLOT(selectAccount(int)), 0, idCount); | 854 | this, SLOT(selectAccount(int)), 0, idCount); |
851 | deleteAccountMenu->insertItem(accountPtr->accountName, | 855 | deleteAccountMenu->insertItem(accountPtr->accountName, |
852 | this, SLOT(deleteAccount(int)), 0, idCount); | 856 | this, SLOT(deleteAccount(int)), 0, idCount); |
853 | idCount++; | 857 | idCount++; |
854 | } | 858 | } |
855 | } | 859 | } |
856 | 860 | ||
857 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 861 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
858 | { | 862 | { |
859 | Email *mPtr; | 863 | Email *mPtr; |
860 | Enclosure *ePtr; | 864 | Enclosure *ePtr; |
861 | 865 | ||
862 | if (inbox) | 866 | if (inbox) |
863 | { | 867 | { |
864 | mPtr = mailItem->getMail(); | 868 | mPtr = mailItem->getMail(); |
865 | 869 | ||
866 | //if mail is in queue for download, remove it from | 870 | //if mail is in queue for download, remove it from |
867 | //queue if possible | 871 | //queue if possible |
868 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 872 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
869 | if ( !mPtr->downloaded ) | 873 | if ( !mPtr->downloaded ) |
870 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 874 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
871 | } | 875 | } |
872 | 876 | ||
873 | mailconf->setGroup(mPtr->id); | 877 | mailconf->setGroup(mPtr->id); |
874 | mailconf->clearGroup(); | 878 | mailconf->clearGroup(); |
875 | 879 | ||
876 | //delete any temporary attatchemnts storing | 880 | //delete any temporary attatchemnts storing |
877 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 881 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
878 | if (ePtr->saved) { | 882 | if (ePtr->saved) { |
879 | QFile::remove( (ePtr->path + ePtr->name) ); | 883 | QFile::remove( (ePtr->path + ePtr->name) ); |
880 | } | 884 | } |
881 | } | 885 | } |
882 | inboxView->takeItem(mailItem); | 886 | inboxView->takeItem(mailItem); |
883 | } | 887 | } |
884 | else | 888 | else |
885 | { | 889 | { |
886 | outboxView->takeItem(mailItem); | 890 | outboxView->takeItem(mailItem); |
887 | } | 891 | } |
888 | } | 892 | } |
889 | 893 | ||
890 | void EmailClient::setMailSize(int size) | 894 | void EmailClient::setMailSize(int size) |
891 | { | 895 | { |
892 | progressBar->reset(); | 896 | progressBar->reset(); |
893 | progressBar->setTotalSteps(size); | 897 | progressBar->setTotalSteps(size); |
894 | } | 898 | } |
895 | 899 | ||
896 | void EmailClient::setTotalSize(int size) | 900 | void EmailClient::setTotalSize(int size) |
897 | { | 901 | { |
898 | 902 | ||
899 | } | 903 | } |
900 | 904 | ||
901 | void EmailClient::setDownloadedSize(int size) | 905 | void EmailClient::setDownloadedSize(int size) |
902 | { | 906 | { |
903 | int total = progressBar->totalSteps(); | 907 | int total = progressBar->totalSteps(); |
904 | 908 | ||
905 | if (size < total) { | 909 | if (size < total) { |
906 | progressBar->setProgress(size); | 910 | progressBar->setProgress(size); |
907 | } else { | 911 | } else { |
908 | progressBar->setProgress(total); | 912 | progressBar->setProgress(total); |
909 | } | 913 | } |
910 | } | 914 | } |
911 | 915 | ||
912 | void EmailClient::deleteItem() | 916 | void EmailClient::deleteItem() |
913 | { | 917 | { |
914 | bool inbox=mailboxView->currentTab()==0; | 918 | bool inbox=mailboxView->currentTab()==0; |
915 | QListView* box; | 919 | QListView* box; |
916 | 920 | ||
917 | EmailListItem* eli; | 921 | EmailListItem* eli; |
918 | int pos; | 922 | int pos; |
919 | 923 | ||
920 | inbox ? box=inboxView : box=outboxView; | 924 | inbox ? box=inboxView : box=outboxView; |
921 | 925 | ||
922 | eli=(EmailListItem*)box->selectedItem(); | 926 | eli=(EmailListItem*)box->selectedItem(); |
923 | 927 | ||
924 | if (eli) | 928 | if (eli) |
925 | { | 929 | { |
926 | box->setSelected(eli->itemBelow(),true);//select the previous item | 930 | box->setSelected(eli->itemBelow(),true);//select the previous item |
927 | 931 | ||
928 | deleteMail(eli,(bool&)inbox); //remove mail entry | 932 | deleteMail(eli,(bool&)inbox); //remove mail entry |
929 | } | 933 | } |
930 | } | 934 | } |
931 | 935 | ||
932 | void EmailClient::inboxItemPressed() | 936 | void EmailClient::inboxItemPressed() |
933 | { | 937 | { |
934 | //timerID=startTimer(500); | 938 | //timerID=startTimer(500); |
935 | } | 939 | } |
936 | 940 | ||
937 | void EmailClient::inboxItemReleased() | 941 | void EmailClient::inboxItemReleased() |
938 | { | 942 | { |
939 | //killTimer(timerID); | 943 | //killTimer(timerID); |
940 | } | 944 | } |
941 | 945 | ||
942 | /*void EmailClient::timerEvent(QTimerEvent *e) | 946 | /*void EmailClient::timerEvent(QTimerEvent *e) |
943 | { | 947 | { |
944 | /*killTimer(timerID); | 948 | /*killTimer(timerID); |
945 | 949 | ||
946 | 950 | ||
947 | QPopupMenu *action = new QPopupMenu(this); | 951 | QPopupMenu *action = new QPopupMenu(this); |
948 | 952 | ||
949 | int reply=0; | 953 | int reply=0; |
950 | 954 | ||
951 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | 955 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); |
952 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | 956 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); |
953 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | 957 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); |
954 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | 958 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); |
955 | 959 | ||
956 | action->exec(QCursor::pos()); | 960 | action->exec(QCursor::pos()); |
957 | 961 | ||
958 | if (action) delete action; | 962 | if (action) delete action; |
959 | 963 | ||
960 | }*/ | 964 | }*/ |
961 | 965 | ||
962 | Email* EmailClient::getCurrentMail() | 966 | Email* EmailClient::getCurrentMail() |
963 | { | 967 | { |
964 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | 968 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); |
965 | if (eli!=NULL) | 969 | if (eli!=NULL) |
966 | return eli->getMail(); | 970 | return eli->getMail(); |
967 | else | 971 | else |
968 | return NULL; | 972 | return NULL; |
969 | } | 973 | } |
970 | 974 | ||
971 | void EmailClient::download(Email* mail) | 975 | void EmailClient::download(Email* mail) |
972 | { | 976 | { |
973 | MailAccount* acc=0; | 977 | MailAccount* acc=0; |
974 | 978 | ||
975 | tempMailDownloadList.clear(); | 979 | tempMailDownloadList.clear(); |
976 | tempMailDownloadList.sizeInsert(mail->serverId, mail->size); | 980 | tempMailDownloadList.sizeInsert(mail->serverId, mail->size); |
977 | 981 | ||
978 | acc=accountList.at(mail->fromAccountId-1); | 982 | acc=accountList.at(mail->fromAccountId-1); |
979 | if (acc) | 983 | if (acc) |
980 | { | 984 | { |
981 | emailHandler->setAccount(*acc); | 985 | emailHandler->setAccount(*acc); |
982 | emailHandler->getMailByList(&tempMailDownloadList); | 986 | emailHandler->getMailByList(&tempMailDownloadList); |
983 | } | 987 | } |
984 | else | 988 | else |
985 | QMessageBox::warning(qApp->activeWindow(), | 989 | QMessageBox::warning(qApp->activeWindow(), |
986 | tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); | 990 | tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); |
987 | } | 991 | } |
988 | 992 | ||
989 | void EmailClient::receive(const QCString& msg, const QByteArray& data) | 993 | void EmailClient::receive(const QCString& msg, const QByteArray& data) |
990 | { | 994 | { |
991 | /*if (msg=="getMail()") | 995 | /*if (msg=="getMail()") |
992 | { | 996 | { |
993 | /*QDialog qd(qApp->activeWindow(),"Getting mail",true); | 997 | /*QDialog qd(qApp->activeWindow(),"Getting mail",true); |
994 | QVBoxLayout *vbProg = new QVBoxLayout( &qd ); | 998 | QVBoxLayout *vbProg = new QVBoxLayout( &qd ); |
995 | 999 | ||
996 | initStatusBar(&qd); | 1000 | initStatusBar(&qd); |
997 | 1001 | ||
998 | if (statusBar==0) | 1002 | if (statusBar==0) |
999 | { | 1003 | { |
1000 | qDebug("No Bar ..."); | 1004 | qDebug("No Bar ..."); |
1001 | //statusBar=new ProgressBar(&qd); | 1005 | //statusBar=new ProgressBar(&qd); |
1002 | } | 1006 | } |
1003 | statusBar->show(); | 1007 | statusBar->show(); |
1004 | vbProg->addWidget(statusBar); | 1008 | vbProg->addWidget(statusBar); |
1005 | qd.showMaximized(); | 1009 | qd.showMaximized(); |
1006 | qd.show(); | 1010 | qd.show(); |
1007 | emit getAllNewMail(); | 1011 | emit getAllNewMail(); |
1008 | //qd.exec(); | 1012 | //qd.exec(); |
1009 | } | 1013 | } |
1010 | else if (msg=="compose()") | 1014 | else if (msg=="compose()") |
1011 | { | 1015 | { |
1012 | QDialog qd(qApp->activeWindow(),"Getting mail",true); | 1016 | QDialog qd(qApp->activeWindow(),"Getting mail",true); |
1013 | 1017 | ||
1014 | WriteMail wm(&qd,"write new mail"); | 1018 | WriteMail wm(&qd,"write new mail"); |
1015 | QVBoxLayout vbProg( &qd ); | 1019 | QVBoxLayout vbProg( &qd ); |
1016 | 1020 | ||
1017 | wm.showMaximized(); | 1021 | wm.showMaximized(); |
1018 | vbProg.addWidget(&wm); | 1022 | vbProg.addWidget(&wm); |
1019 | 1023 | ||
1020 | qd.showMaximized(); | 1024 | qd.showMaximized(); |
1021 | 1025 | ||
1022 | emit composeRequested(); | 1026 | emit composeRequested(); |
1023 | qd.exec(); | 1027 | qd.exec(); |
1024 | 1028 | ||
1025 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); | 1029 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); |
1026 | } | 1030 | } |
1027 | 1031 | ||
1028 | else if (msg=="dialog()") | 1032 | else if (msg=="dialog()") |
1029 | { | 1033 | { |
1030 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); | 1034 | QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); |
1031 | }*/ | 1035 | }*/ |
1032 | } | 1036 | } |