author | groucho <groucho> | 2003-04-20 07:59:48 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-04-20 07:59:48 (UTC) |
commit | 8b85cba50912127ff6a2d048021baf68306481c6 (patch) (unidiff) | |
tree | bfd1b377911d05db8e1c816f72fe070d5a5b2ff3 | |
parent | 6b381e438fdeb1757b3278c683349dee9c4ab230 (diff) | |
download | opie-8b85cba50912127ff6a2d048021baf68306481c6.zip opie-8b85cba50912127ff6a2d048021baf68306481c6.tar.gz opie-8b85cba50912127ff6a2d048021baf68306481c6.tar.bz2 |
- Added CC: support
- Added mail forwarding
- Added icon for selective mail download
- Removing mails from mail list via icon
- Temporarily disabled mail header download queue
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 154 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.h | 32 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.h | 8 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.cpp | 36 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.h | 5 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.cpp | 103 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.h | 9 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 154 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.h | 32 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 17 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.h | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.cpp | 36 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 103 | ||||
-rw-r--r-- | noncore/unsupported/mailit/writemail.h | 9 |
18 files changed, 722 insertions, 86 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 0d82a9a..ad1e0b4 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -14,343 +14,371 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | 28 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 29 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (MailAccount *) d); | 31 | return dupl( (MailAccount *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 34 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 35 | { |
36 | ac = new MailAccount(*in); | 36 | ac = new MailAccount(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 41 | : QMainWindow( parent, name, fl ) |
42 | { | 42 | { |
43 | emailHandler = new EmailHandler(); | 43 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList(); | 44 | addressList = new AddressList(); |
45 | 45 | ||
46 | sending = FALSE; | 46 | sending = FALSE; |
47 | receiving = FALSE; | 47 | receiving = FALSE; |
48 | previewingMail = FALSE; | 48 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 49 | mailIdCount = 1; |
50 | accountIdCount = 1; | 50 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 51 | allAccounts = FALSE; |
52 | 52 | ||
53 | init(); | 53 | init(); |
54 | 54 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 56 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 57 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 58 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 59 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 60 | SLOT(popError(int)) ); |
61 | 61 | ||
62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 62 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 63 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | |||
65 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | ||
66 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | ||
67 | |||
64 | 68 | ||
65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 69 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
66 | SLOT(mailArrived(const Email &, bool)) ); | 70 | SLOT(mailArrived(const Email &, bool)) ); |
67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 71 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
68 | SLOT(allMailArrived(int)) ); | 72 | SLOT(allMailArrived(int)) ); |
69 | 73 | ||
70 | mailconf = new Config("mailit"); | 74 | mailconf = new Config("mailit"); |
71 | //In case Synchronize is not defined in settings.txt | 75 | //In case Synchronize is not defined in settings.txt |
72 | 76 | ||
73 | readSettings(); | 77 | readSettings(); |
74 | 78 | ||
75 | updateAccounts(); | 79 | updateAccounts(); |
76 | 80 | ||
77 | lineShift = "\n"; | 81 | lineShift = "\n"; |
78 | readMail(); | 82 | readMail(); |
79 | lineShift = "\r\n"; | 83 | lineShift = "\r\n"; |
80 | 84 | ||
81 | } | 85 | } |
82 | 86 | ||
83 | 87 | ||
84 | EmailClient::~EmailClient() | 88 | EmailClient::~EmailClient() |
85 | { | 89 | { |
86 | //needs to be moved from destructor to closewindow event | 90 | //needs to be moved from destructor to closewindow event |
87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 91 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
88 | //does not currently work. Defining outbox in the same | 92 | //does not currently work. Defining outbox in the same |
89 | //format as inbox is not a good solution as they have | 93 | //format as inbox is not a good solution as they have |
90 | //different properties | 94 | //different properties |
91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 95 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
92 | saveSettings(); | 96 | saveSettings(); |
93 | 97 | ||
94 | mailconf->write(); | 98 | mailconf->write(); |
95 | delete mailconf; | 99 | delete mailconf; |
96 | 100 | ||
97 | } | 101 | } |
98 | 102 | ||
99 | void EmailClient::init() | 103 | void EmailClient::init() |
100 | { | 104 | { |
101 | statusBar = new QStatusBar(this); | 105 | statusBar = new QStatusBar(this); |
102 | statusBar->setSizeGripEnabled(FALSE); | 106 | statusBar->setSizeGripEnabled(FALSE); |
103 | 107 | ||
104 | status1Label = new QLabel( tr("Idle"), statusBar); | 108 | status1Label = new QLabel( tr("Idle"), statusBar); |
105 | status2Label = new QLabel("", statusBar); | 109 | status2Label = new QLabel("", statusBar); |
106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 110 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
107 | status2Label, SLOT(setText(const QString &)) ); | 111 | status2Label, SLOT(setText(const QString &)) ); |
108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 112 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
109 | status2Label, SLOT(setText(const QString &)) ); | 113 | status2Label, SLOT(setText(const QString &)) ); |
110 | 114 | ||
111 | progressBar = new QProgressBar(statusBar); | 115 | progressBar = new QProgressBar(statusBar); |
112 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 116 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
113 | this, SLOT(setTotalSize(int)) ); | 117 | this, SLOT(setTotalSize(int)) ); |
114 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 118 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
115 | this, SLOT(setMailSize(int)) ); | 119 | this, SLOT(setMailSize(int)) ); |
116 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 120 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
117 | this, SLOT(setDownloadedSize(int)) ); | 121 | this, SLOT(setDownloadedSize(int)) ); |
118 | 122 | ||
119 | statusBar->addWidget(status1Label); | 123 | statusBar->addWidget(status1Label); |
120 | statusBar->addWidget(progressBar); | 124 | statusBar->addWidget(progressBar); |
121 | statusBar->addWidget(status2Label); | 125 | statusBar->addWidget(status2Label); |
122 | 126 | ||
123 | setToolBarsMovable(FALSE); | 127 | setToolBarsMovable(FALSE); |
124 | 128 | ||
125 | bar = new QToolBar(this); | 129 | bar = new QToolBar(this); |
126 | bar->setHorizontalStretchable( TRUE ); | 130 | bar->setHorizontalStretchable( TRUE ); |
127 | 131 | ||
128 | mb = new QMenuBar( bar ); | 132 | mb = new QMenuBar( bar ); |
129 | 133 | ||
130 | QPopupMenu *mail = new QPopupMenu(mb); | 134 | QPopupMenu *mail = new QPopupMenu(mb); |
131 | mb->insertItem( tr( "&Mail" ), mail); | 135 | mb->insertItem( tr( "&Mail" ), mail); |
132 | 136 | ||
133 | QPopupMenu *configure = new QPopupMenu(mb); | 137 | QPopupMenu *configure = new QPopupMenu(mb); |
134 | mb->insertItem( tr( "Accounts" ), configure); | 138 | mb->insertItem( tr( "Accounts" ), configure); |
135 | 139 | ||
136 | selectAccountMenu = new QPopupMenu(mb); | 140 | selectAccountMenu = new QPopupMenu(mb); |
137 | editAccountMenu = new QPopupMenu(mb); | 141 | editAccountMenu = new QPopupMenu(mb); |
138 | deleteAccountMenu = new QPopupMenu(mb); | 142 | deleteAccountMenu = new QPopupMenu(mb); |
139 | 143 | ||
140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 144 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
141 | configure->insertItem(tr("Edit account"), editAccountMenu); | 145 | configure->insertItem(tr("Edit account"), editAccountMenu); |
142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 146 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
143 | 147 | ||
144 | bar = new QToolBar(this); | 148 | bar = new QToolBar(this); |
145 | 149 | ||
146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | 150 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
151 | //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); | ||
152 | // setAccountButton->addTo(bar); | ||
153 | //setAccountButton->addTo(mail); | ||
154 | |||
155 | /*idCount = 0; | ||
156 | |||
157 | for (MailAccount* accountPtr = accountList.first(); accountPtr != 0; | ||
158 | accountPtr = accountList.next()) { | ||
159 | |||
160 | selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount); | ||
161 | idCount++; | ||
162 | }*/ | ||
163 | getMailButton->setPopup(selectAccountMenu); | ||
164 | |||
165 | |||
166 | /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | ||
147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | 167 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); |
148 | getMailButton->addTo(bar); | 168 | getMailButton->addTo(bar);*/ |
149 | getMailButton->addTo(mail); | 169 | //getMailButton->addTo(mail); |
150 | 170 | ||
151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 171 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 172 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
153 | sendMailButton->addTo(bar); | 173 | sendMailButton->addTo(bar); |
154 | sendMailButton->addTo(mail); | 174 | sendMailButton->addTo(mail); |
155 | 175 | ||
156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 176 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 177 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
158 | composeButton->addTo(bar); | 178 | composeButton->addTo(bar); |
159 | composeButton->addTo(mail); | 179 | composeButton->addTo(mail); |
160 | 180 | ||
161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 181 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 182 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
163 | cancelButton->addTo(mail); | 183 | cancelButton->addTo(mail); |
164 | cancelButton->addTo(bar); | 184 | cancelButton->addTo(bar); |
165 | cancelButton->setEnabled(FALSE); | 185 | cancelButton->setEnabled(FALSE); |
166 | 186 | ||
187 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | ||
188 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | ||
189 | deleteButton->addTo(bar); | ||
190 | |||
167 | mailboxView = new OTabWidget( this, "mailboxView" ); | 191 | mailboxView = new OTabWidget( this, "mailboxView" ); |
168 | 192 | ||
169 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 193 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
170 | grid_2 = new QGridLayout( widget ); | 194 | grid_2 = new QGridLayout( widget ); |
171 | // grid_2->setSpacing(6); | 195 | // grid_2->setSpacing(6); |
172 | // grid_2->setMargin( 11 ); | 196 | // grid_2->setMargin( 11 ); |
173 | 197 | ||
174 | inboxView = new QListView( widget, "inboxView" ); | 198 | inboxView = new QListView( widget, "inboxView" ); |
175 | inboxView->addColumn( tr( "From" ) ); | 199 | inboxView->addColumn( tr( "From" ) ); |
176 | inboxView->addColumn( tr( "Subject" ) ); | 200 | inboxView->addColumn( tr( "Subject" ) ); |
177 | inboxView->addColumn( tr( "Date" ) ); | 201 | inboxView->addColumn( tr( "Date" ) ); |
178 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 202 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
179 | inboxView->setAllColumnsShowFocus(TRUE); | 203 | inboxView->setAllColumnsShowFocus(TRUE); |
180 | 204 | ||
181 | grid_2->addWidget( inboxView, 2, 0 ); | 205 | grid_2->addWidget( inboxView, 2, 0 ); |
182 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 206 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
183 | 207 | ||
184 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 208 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
185 | grid_3 = new QGridLayout( widget_2 ); | 209 | grid_3 = new QGridLayout( widget_2 ); |
186 | // grid_3->setSpacing(6); | 210 | // grid_3->setSpacing(6); |
187 | // grid_3->setMargin( 11 ); | 211 | // grid_3->setMargin( 11 ); |
188 | 212 | ||
189 | outboxView = new QListView( widget_2, "outboxView" ); | 213 | outboxView = new QListView( widget_2, "outboxView" ); |
190 | outboxView->addColumn( tr( "To" ) ); | 214 | outboxView->addColumn( tr( "To" ) ); |
191 | outboxView->addColumn( tr( "Subject" ) ); | 215 | outboxView->addColumn( tr( "Subject" ) ); |
192 | outboxView->setAllColumnsShowFocus(TRUE); | 216 | outboxView->setAllColumnsShowFocus(TRUE); |
193 | 217 | ||
194 | grid_3->addWidget( outboxView, 0, 0 ); | 218 | grid_3->addWidget( outboxView, 0, 0 ); |
195 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 219 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
196 | 220 | ||
197 | setCentralWidget(mailboxView); | 221 | setCentralWidget(mailboxView); |
222 | |||
223 | mailboxView->setCurrentTab(0); | ||
198 | } | 224 | } |
199 | 225 | ||
200 | void EmailClient::compose() | 226 | void EmailClient::compose() |
201 | { | 227 | { |
202 | emit composeRequested(); | 228 | emit composeRequested(); |
203 | } | 229 | } |
204 | 230 | ||
205 | void EmailClient::cancel() | 231 | void EmailClient::cancel() |
206 | { | 232 | { |
207 | emailHandler->cancel(); | 233 | emailHandler->cancel(); |
208 | } | 234 | } |
209 | 235 | ||
210 | AddressList* EmailClient::getAdrListRef() | 236 | AddressList* EmailClient::getAdrListRef() |
211 | { | 237 | { |
212 | return addressList; | 238 | return addressList; |
213 | } | 239 | } |
214 | 240 | ||
215 | //this needs to be rewritten to syncronize with outboxView | 241 | //this needs to be rewritten to syncronize with outboxView |
216 | void EmailClient::enqueMail(const Email &mail) | 242 | void EmailClient::enqueMail(const Email &mail) |
217 | { | 243 | { |
218 | if (accountList.count() == 0) { | 244 | if (accountList.count() == 0) { |
219 | QMessageBox::warning(qApp->activeWindow(), | 245 | QMessageBox::warning(qApp->activeWindow(), |
220 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 246 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
221 | return; | 247 | return; |
222 | } | 248 | } |
223 | 249 | ||
224 | if (accountList.count() > 0) { | 250 | if (accountList.count() > 0) { |
225 | currentAccount = accountList.first(); | 251 | currentAccount = accountList.first(); |
226 | qWarning("using account " + currentAccount->name); | 252 | qWarning("using account " + currentAccount->name); |
227 | } | 253 | } |
228 | 254 | ||
229 | Email addMail = mail; | 255 | Email addMail = mail; |
230 | addMail.from = currentAccount->name; | 256 | addMail.from = currentAccount->name; |
231 | addMail.fromMail = currentAccount->emailAddress; | 257 | addMail.fromMail = currentAccount->emailAddress; |
232 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 258 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
233 | item = new EmailListItem(outboxView, addMail, false); | 259 | item = new EmailListItem(outboxView, addMail, false); |
234 | 260 | ||
261 | mailboxView->setCurrentTab(1); | ||
262 | |||
235 | } | 263 | } |
236 | 264 | ||
237 | void EmailClient::sendQuedMail() | 265 | void EmailClient::sendQuedMail() |
238 | { | 266 | { |
239 | int count = 0; | 267 | int count = 0; |
240 | 268 | ||
241 | if (accountList.count() == 0) { | 269 | if (accountList.count() == 0) { |
242 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 270 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
243 | return; | 271 | return; |
244 | } | 272 | } |
245 | //traverse listview, find messages to send | 273 | //traverse listview, find messages to send |
246 | if (! sending) { | 274 | if (! sending) { |
247 | item = (EmailListItem *) outboxView->firstChild(); | 275 | item = (EmailListItem *) outboxView->firstChild(); |
248 | if (item != NULL) { | 276 | if (item != NULL) { |
249 | while (item != NULL) { | 277 | while (item != NULL) { |
250 | quedMessages.append(item->getMail()); | 278 | quedMessages.append(item->getMail()); |
251 | item = (EmailListItem *) item->nextSibling(); | 279 | item = (EmailListItem *) item->nextSibling(); |
252 | count++; | 280 | count++; |
253 | } | 281 | } |
254 | setMailAccount(); | 282 | setMailAccount(); |
255 | emailHandler->sendMail(&quedMessages); | 283 | emailHandler->sendMail(&quedMessages); |
256 | sending = TRUE; | 284 | sending = TRUE; |
257 | sendMailButton->setEnabled(FALSE); | 285 | sendMailButton->setEnabled(FALSE); |
258 | cancelButton->setEnabled(TRUE); | 286 | cancelButton->setEnabled(TRUE); |
259 | } else { | 287 | } else { |
260 | qWarning("sendQuedMail(): no messages to send"); | 288 | qWarning("sendQuedMail(): no messages to send"); |
261 | } | 289 | } |
262 | } | 290 | } |
263 | } | 291 | } |
264 | 292 | ||
265 | void EmailClient::setMailAccount() | 293 | void EmailClient::setMailAccount() |
266 | { | 294 | { |
267 | emailHandler->setAccount(*currentAccount); | 295 | emailHandler->setAccount(*currentAccount); |
268 | } | 296 | } |
269 | 297 | ||
270 | void EmailClient::mailSent() | 298 | void EmailClient::mailSent() |
271 | { | 299 | { |
272 | sending = FALSE; | 300 | sending = FALSE; |
273 | sendMailButton->setEnabled(TRUE); | 301 | sendMailButton->setEnabled(TRUE); |
274 | 302 | ||
275 | quedMessages.clear(); | 303 | quedMessages.clear(); |
276 | outboxView->clear(); //should be moved to an sentBox | 304 | outboxView->clear(); //should be moved to an sentBox |
277 | } | 305 | } |
278 | 306 | ||
279 | void EmailClient::getNewMail() { | 307 | void EmailClient::getNewMail() { |
280 | 308 | ||
281 | if (accountList.count() == 0) { | 309 | if (accountList.count() == 0) { |
282 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 310 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
283 | "You must create an account", "OK\n"); | 311 | "You must create an account", "OK\n"); |
284 | return; | 312 | return; |
285 | } | 313 | } |
286 | 314 | ||
287 | setMailAccount(); | 315 | setMailAccount(); |
288 | 316 | ||
289 | receiving = TRUE; | 317 | receiving = TRUE; |
290 | previewingMail = TRUE; | 318 | previewingMail = TRUE; |
291 | getMailButton->setEnabled(FALSE); | 319 | getMailButton->setEnabled(FALSE); |
292 | cancelButton->setEnabled(TRUE); | 320 | cancelButton->setEnabled(TRUE); |
293 | selectAccountMenu->setEnabled(FALSE); | 321 | selectAccountMenu->setEnabled(FALSE); |
294 | 322 | ||
295 | status1Label->setText(currentAccount->accountName + " headers"); | 323 | status1Label->setText(currentAccount->accountName + " headers"); |
296 | progressBar->reset(); | 324 | progressBar->reset(); |
297 | 325 | ||
298 | //get any previous mails not downloaded and add to queue | 326 | //get any previous mails not downloaded and add to queue |
299 | mailDownloadList.clear(); | 327 | /* mailDownloadList.clear(); |
300 | Email *mailPtr; | 328 | Email *mailPtr; |
301 | item = (EmailListItem *) inboxView->firstChild(); | 329 | item = (EmailListItem *) inboxView->firstChild(); |
302 | while (item != NULL) { | 330 | while (item != NULL) { |
303 | mailPtr = item->getMail(); | 331 | mailPtr = item->getMail(); |
304 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 332 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
305 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 333 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
306 | } | 334 | } |
307 | item = (EmailListItem *) item->nextSibling(); | 335 | item = (EmailListItem *) item->nextSibling(); |
308 | } | 336 | }*/ |
309 | 337 | ||
310 | emailHandler->getMailHeaders(); | 338 | emailHandler->getMailHeaders(); |
311 | } | 339 | } |
312 | 340 | ||
313 | void EmailClient::getAllNewMail() | 341 | void EmailClient::getAllNewMail() |
314 | { | 342 | { |
315 | allAccounts = TRUE; | 343 | allAccounts = TRUE; |
316 | currentAccount = accountList.first(); | 344 | currentAccount = accountList.first(); |
317 | getNewMail(); | 345 | getNewMail(); |
318 | } | 346 | } |
319 | 347 | ||
320 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 348 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
321 | { | 349 | { |
322 | Enclosure *ePtr; | 350 | Enclosure *ePtr; |
323 | Email newMail; | 351 | Email newMail; |
324 | int thisMailId; | 352 | int thisMailId; |
325 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 353 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
326 | 354 | ||
327 | mailconf->setGroup(newMail.id); | 355 | mailconf->setGroup(newMail.id); |
328 | 356 | ||
329 | if (fromDisk) { | 357 | if (fromDisk) { |
330 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 358 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
331 | newMail.size = mailconf->readNumEntry("size"); | 359 | newMail.size = mailconf->readNumEntry("size"); |
332 | newMail.serverId = mailconf->readNumEntry("serverid"); | 360 | newMail.serverId = mailconf->readNumEntry("serverid"); |
333 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 361 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
334 | } else { //mail arrived from server | 362 | } else { //mail arrived from server |
335 | newMail.serverId = mail.serverId; | 363 | newMail.serverId = mail.serverId; |
336 | newMail.size = mail.size; | 364 | newMail.size = mail.size; |
337 | newMail.downloaded = mail.downloaded; | 365 | newMail.downloaded = mail.downloaded; |
338 | 366 | ||
339 | newMail.fromAccountId = currentAccount->id; | 367 | newMail.fromAccountId = currentAccount->id; |
340 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 368 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
341 | } | 369 | } |
342 | 370 | ||
343 | //add if read or not | 371 | //add if read or not |
344 | newMail.read = mailconf->readBoolEntry("mailread"); | 372 | newMail.read = mailconf->readBoolEntry("mailread"); |
345 | 373 | ||
346 | //check if new mail | 374 | //check if new mail |
347 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 375 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
348 | thisMailId = mailIdCount; | 376 | thisMailId = mailIdCount; |
349 | mailIdCount++; | 377 | mailIdCount++; |
350 | 378 | ||
351 | //set server count, so that if the user aborts, the new | 379 | //set server count, so that if the user aborts, the new |
352 | //header is not reloaded | 380 | //header is not reloaded |
353 | if (currentAccount->synchronize) | 381 | if (currentAccount->synchronize) |
354 | currentAccount->lastServerMailCount++; | 382 | currentAccount->lastServerMailCount++; |
355 | 383 | ||
356 | mailconf->writeEntry("internalmailid", thisMailId); | 384 | mailconf->writeEntry("internalmailid", thisMailId); |
@@ -370,198 +398,206 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
370 | stringId.setNum(ePtr->id); | 398 | stringId.setNum(ePtr->id); |
371 | 399 | ||
372 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 400 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
373 | if (id != ePtr->id) { //new entry | 401 | if (id != ePtr->id) { //new entry |
374 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 402 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
375 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 403 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
376 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 404 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
377 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 405 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
378 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 406 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
379 | mailconf->writeEntry("installed_" + stringId, FALSE); | 407 | mailconf->writeEntry("installed_" + stringId, FALSE); |
380 | 408 | ||
381 | ePtr->name = stringMailId + "_" + stringId; | 409 | ePtr->name = stringMailId + "_" + stringId; |
382 | ePtr->path = getPath(TRUE); | 410 | ePtr->path = getPath(TRUE); |
383 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 411 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
384 | ePtr->saved = TRUE; | 412 | ePtr->saved = TRUE; |
385 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 413 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
386 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 414 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
387 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 415 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
388 | } else { | 416 | } else { |
389 | ePtr->saved = FALSE; | 417 | ePtr->saved = FALSE; |
390 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 418 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
391 | } | 419 | } |
392 | } else { | 420 | } else { |
393 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 421 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
394 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 422 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
395 | if (ePtr->saved) { | 423 | if (ePtr->saved) { |
396 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 424 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
397 | ePtr->path = mailconf->readEntry("path_" + stringId); | 425 | ePtr->path = mailconf->readEntry("path_" + stringId); |
398 | } | 426 | } |
399 | } | 427 | } |
400 | } | 428 | } |
401 | if (!previewingMail && !fromDisk) { | 429 | if (!previewingMail && !fromDisk) { |
402 | Email *mailPtr; | 430 | Email *mailPtr; |
403 | item = (EmailListItem *) inboxView->firstChild(); | 431 | item = (EmailListItem *) inboxView->firstChild(); |
404 | while (item != NULL) { | 432 | while (item != NULL) { |
405 | mailPtr = item->getMail(); | 433 | mailPtr = item->getMail(); |
406 | if (mailPtr->id == newMail.id) { | 434 | if (mailPtr->id == newMail.id) { |
407 | item->setMail(newMail); | 435 | item->setMail(newMail); |
408 | emit mailUpdated(item->getMail()); | 436 | emit mailUpdated(item->getMail()); |
409 | } | 437 | } |
410 | item = (EmailListItem *) item->nextSibling(); | 438 | item = (EmailListItem *) item->nextSibling(); |
411 | } | 439 | } |
412 | } else { | 440 | } else { |
413 | item = new EmailListItem(inboxView, newMail, TRUE); | 441 | item = new EmailListItem(inboxView, newMail, TRUE); |
414 | if (!newMail.downloaded) | 442 | if (!newMail.downloaded) |
415 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); | 443 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); |
416 | } | 444 | } |
417 | 445 | ||
446 | mailboxView->setCurrentTab(0); | ||
447 | |||
418 | } | 448 | } |
419 | 449 | ||
420 | void EmailClient::allMailArrived(int count) | 450 | void EmailClient::allMailArrived(int count) |
421 | { | 451 | { |
422 | // not previewing means all mailtransfer has been done | 452 | // not previewing means all mailtransfer has been done |
423 | if (!previewingMail) { | 453 | if (!previewingMail) { |
424 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 454 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
425 | emit newCaption("Mailit - " + currentAccount->accountName); | 455 | emit newCaption("Mailit - " + currentAccount->accountName); |
426 | getNewMail(); | 456 | getNewMail(); |
427 | return; | 457 | return; |
428 | } else { | 458 | } else { |
429 | allAccounts = FALSE; | 459 | allAccounts = FALSE; |
430 | receiving = FALSE; | 460 | receiving = FALSE; |
431 | getMailButton->setEnabled(TRUE); | 461 | getMailButton->setEnabled(TRUE); |
432 | cancelButton->setEnabled(FALSE); | 462 | cancelButton->setEnabled(FALSE); |
433 | selectAccountMenu->setEnabled(TRUE); | 463 | selectAccountMenu->setEnabled(TRUE); |
434 | status1Label->setText("Idle"); | 464 | status1Label->setText("Idle"); |
435 | 465 | ||
436 | progressBar->reset(); | 466 | progressBar->reset(); |
437 | return; | 467 | return; |
438 | } | 468 | } |
439 | } | 469 | } |
440 | 470 | ||
441 | // all headers downloaded from server, start downloading remaining mails | 471 | // all headers downloaded from server, start downloading remaining mails |
442 | previewingMail = FALSE; | 472 | previewingMail = FALSE; |
443 | status1Label->setText(currentAccount->accountName); | 473 | status1Label->setText(currentAccount->accountName); |
444 | progressBar->reset(); | 474 | progressBar->reset(); |
445 | 475 | ||
446 | emailHandler->getMailByList(&mailDownloadList); | 476 | emailHandler->getMailByList(&mailDownloadList); |
477 | |||
478 | mailboxView->setCurrentTab(0); | ||
447 | } | 479 | } |
448 | 480 | ||
449 | void EmailClient::moveMailFront(Email *mailPtr) | 481 | void EmailClient::moveMailFront(Email *mailPtr) |
450 | { | 482 | { |
451 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 483 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
452 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 484 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
453 | } | 485 | } |
454 | } | 486 | } |
455 | 487 | ||
456 | void EmailClient::smtpError(int code) | 488 | void EmailClient::smtpError(int code) |
457 | { | 489 | { |
458 | QString temp; | 490 | QString temp; |
459 | 491 | ||
460 | if (code == ErrUnknownResponse) | 492 | if (code == ErrUnknownResponse) |
461 | temp = "Unknown response from server"; | 493 | temp = "Unknown response from server"; |
462 | 494 | ||
463 | if (code == QSocket::ErrHostNotFound) | 495 | if (code == QSocket::ErrHostNotFound) |
464 | temp = "host not found"; | 496 | temp = "host not found"; |
465 | if (code == QSocket::ErrConnectionRefused) | 497 | if (code == QSocket::ErrConnectionRefused) |
466 | temp = "connection refused"; | 498 | temp = "connection refused"; |
467 | if (code == QSocket::ErrSocketRead) | 499 | if (code == QSocket::ErrSocketRead) |
468 | temp = "socket packet error"; | 500 | temp = "socket packet error"; |
469 | 501 | ||
470 | if (code != ErrCancel) { | 502 | if (code != ErrCancel) { |
471 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 503 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
472 | } else { | 504 | } else { |
473 | status2Label->setText("Aborted by user"); | 505 | status2Label->setText("Aborted by user"); |
474 | } | 506 | } |
475 | 507 | ||
476 | sending = FALSE; | 508 | sending = FALSE; |
477 | sendMailButton->setEnabled(TRUE); | 509 | sendMailButton->setEnabled(TRUE); |
478 | cancelButton->setEnabled(FALSE); | 510 | cancelButton->setEnabled(FALSE); |
479 | quedMessages.clear(); | 511 | quedMessages.clear(); |
480 | } | 512 | } |
481 | 513 | ||
482 | void EmailClient::popError(int code) | 514 | void EmailClient::popError(int code) |
483 | { | 515 | { |
484 | QString temp; | 516 | QString temp; |
485 | 517 | ||
486 | if (code == ErrUnknownResponse) | 518 | if (code == ErrUnknownResponse) |
487 | temp = "Unknown response from server"; | 519 | temp = "Unknown response from server"; |
488 | if (code == ErrLoginFailed) | 520 | if (code == ErrLoginFailed) |
489 | temp = "Login failed\nCheck user name and password"; | 521 | temp = "Login failed\nCheck user name and password"; |
490 | 522 | ||
491 | if (code == QSocket::ErrHostNotFound) | 523 | if (code == QSocket::ErrHostNotFound) |
492 | temp = "host not found"; | 524 | temp = "host not found"; |
493 | if (code == QSocket::ErrConnectionRefused) | 525 | if (code == QSocket::ErrConnectionRefused) |
494 | temp = "connection refused"; | 526 | temp = "connection refused"; |
495 | if (code == QSocket::ErrSocketRead) | 527 | if (code == QSocket::ErrSocketRead) |
496 | temp = "socket packet error"; | 528 | temp = "socket packet error"; |
497 | 529 | ||
498 | if (code != ErrCancel) { | 530 | if (code != ErrCancel) { |
499 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 531 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
500 | } else { | 532 | } else { |
501 | status2Label->setText("Aborted by user"); | 533 | status2Label->setText("Aborted by user"); |
502 | } | 534 | } |
503 | 535 | ||
504 | receiving = FALSE; | 536 | receiving = FALSE; |
505 | getMailButton->setEnabled(TRUE); | 537 | getMailButton->setEnabled(TRUE); |
506 | cancelButton->setEnabled(FALSE); | 538 | cancelButton->setEnabled(FALSE); |
507 | selectAccountMenu->setEnabled(TRUE); | 539 | selectAccountMenu->setEnabled(TRUE); |
508 | } | 540 | } |
509 | 541 | ||
510 | void EmailClient::inboxItemSelected() | 542 | void EmailClient::inboxItemSelected() |
511 | { | 543 | { |
544 | killTimer(timerID); | ||
545 | |||
512 | item = (EmailListItem*) inboxView->selectedItem(); | 546 | item = (EmailListItem*) inboxView->selectedItem(); |
513 | if (item != NULL) { | 547 | if (item != NULL) { |
514 | emit viewEmail(inboxView, item->getMail()); | 548 | emit viewEmail(inboxView, item->getMail()); |
515 | } | 549 | } |
516 | } | 550 | } |
517 | 551 | ||
518 | void EmailClient::outboxItemSelected() | 552 | void EmailClient::outboxItemSelected() |
519 | { | 553 | { |
554 | killTimer(timerID); | ||
555 | |||
520 | item = (EmailListItem*) outboxView->selectedItem(); | 556 | item = (EmailListItem*) outboxView->selectedItem(); |
521 | if (item != NULL) { | 557 | if (item != NULL) { |
522 | emit viewEmail(outboxView, item->getMail()); | 558 | emit viewEmail(outboxView, item->getMail()); |
523 | } | 559 | } |
524 | 560 | ||
525 | } | 561 | } |
526 | 562 | ||
527 | void EmailClient::readMail() | 563 | void EmailClient::readMail() |
528 | { | 564 | { |
529 | Email mail; | 565 | Email mail; |
530 | int start, stop; | 566 | int start, stop; |
531 | QString s, del; | 567 | QString s, del; |
532 | 568 | ||
533 | QFile f(getPath(FALSE) + "inbox.txt"); | 569 | QFile f(getPath(FALSE) + "inbox.txt"); |
534 | // QFileInfo fi(f); | 570 | // QFileInfo fi(f); |
535 | //qDebug( f.name()); | 571 | //qDebug( f.name()); |
536 | 572 | ||
537 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 573 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
538 | QTextStream t( &f ); // use a text stream | 574 | QTextStream t( &f ); // use a text stream |
539 | s = t.read(); | 575 | s = t.read(); |
540 | f.close(); | 576 | f.close(); |
541 | 577 | ||
542 | start = 0; | 578 | start = 0; |
543 | del = "\n.\n"; | 579 | del = "\n.\n"; |
544 | while ((uint) start < s.length()) { | 580 | while ((uint) start < s.length()) { |
545 | stop = s.find(del, start); | 581 | stop = s.find(del, start); |
546 | if (stop == -1) | 582 | if (stop == -1) |
547 | stop = s.length() - del.length(); | 583 | stop = s.length() - del.length(); |
548 | 584 | ||
549 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 585 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
550 | start = stop + del.length(); | 586 | start = stop + del.length(); |
551 | mailArrived(mail, TRUE); | 587 | mailArrived(mail, TRUE); |
552 | } | 588 | } |
553 | } | 589 | } |
554 | 590 | ||
555 | QFile fo(getPath(FALSE) + "outbox.txt"); | 591 | QFile fo(getPath(FALSE) + "outbox.txt"); |
556 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 592 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
557 | QTextStream t( &fo ); // use a text stream | 593 | QTextStream t( &fo ); // use a text stream |
558 | s = t.read(); | 594 | s = t.read(); |
559 | fo.close(); | 595 | fo.close(); |
560 | 596 | ||
561 | start = 0; | 597 | start = 0; |
562 | del = "\n.\n"; | 598 | del = "\n.\n"; |
563 | while ((uint) start < s.length()) { | 599 | while ((uint) start < s.length()) { |
564 | stop = s.find(del, start); | 600 | stop = s.find(del, start); |
565 | if (stop == -1) | 601 | if (stop == -1) |
566 | stop = s.length() - del.length(); | 602 | stop = s.length() - del.length(); |
567 | 603 | ||
@@ -647,106 +683,107 @@ void EmailClient::readSettings() | |||
647 | account.name = p->getString(& ++pos, 'z', TRUE); | 683 | account.name = p->getString(& ++pos, 'z', TRUE); |
648 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | 684 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) |
649 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | 685 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); |
650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 686 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 687 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 688 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 689 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 690 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
655 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 691 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 692 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 693 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 694 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
659 | s = p->getString(& ++pos, 'z', TRUE); | 695 | s = p->getString(& ++pos, 'z', TRUE); |
660 | account.id = s.toInt(); | 696 | account.id = s.toInt(); |
661 | } | 697 | } |
662 | 698 | ||
663 | account.lastServerMailCount = 0; | 699 | account.lastServerMailCount = 0; |
664 | account.synchronize = FALSE; | 700 | account.synchronize = FALSE; |
665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 701 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 702 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
667 | account.synchronize = TRUE; | 703 | account.synchronize = TRUE; |
668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 704 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
669 | s = p->getString(& ++pos, 'z', TRUE); | 705 | s = p->getString(& ++pos, 'z', TRUE); |
670 | account.lastServerMailCount = s.toInt(); | 706 | account.lastServerMailCount = s.toInt(); |
671 | } | 707 | } |
672 | } | 708 | } |
673 | } | 709 | } |
674 | 710 | ||
675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | 711 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { |
676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | 712 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); |
677 | } | 713 | } |
678 | 714 | ||
679 | 715 | ||
680 | accountList.append(&account); | 716 | accountList.append(&account); |
681 | } | 717 | } |
682 | delete p; | 718 | delete p; |
683 | } | 719 | } |
684 | mailconf->setGroup("mailitglobal"); | 720 | mailconf->setGroup("mailitglobal"); |
685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 721 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
686 | mailIdCount = y; | 722 | mailIdCount = y; |
687 | } | 723 | } |
688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 724 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
689 | accountIdCount = y; | 725 | accountIdCount = y; |
690 | } | 726 | } |
691 | } | 727 | } |
692 | 728 | ||
693 | void EmailClient::saveSettings() | 729 | void EmailClient::saveSettings() |
694 | { | 730 | { |
731 | |||
695 | QString temp; | 732 | QString temp; |
696 | QFile f( getPath(FALSE) + "settings.txt"); | 733 | QFile f( getPath(FALSE) + "settings.txt"); |
697 | MailAccount *accountPtr; | 734 | MailAccount *accountPtr; |
698 | 735 | ||
699 | if (! f.open(IO_WriteOnly) ) { | 736 | if (! f.open(IO_WriteOnly) ) { |
700 | qWarning("could not save settings file"); | 737 | qWarning("could not save settings file"); |
701 | return; | 738 | return; |
702 | } | 739 | } |
703 | QTextStream t(&f); | 740 | QTextStream t(&f); |
704 | t << "#Settings for QPE Mailit program\n"; | 741 | t << "#Settings for OPIE Mailit program\n"; |
705 | 742 | ||
706 | for (accountPtr = accountList.first(); accountPtr != 0; | 743 | for (accountPtr = accountList.first(); accountPtr != 0; |
707 | accountPtr = accountList.next()) { | 744 | accountPtr = accountList.next()) { |
708 | 745 | ||
709 | t << "accountStart;\n"; | 746 | t << "accountStart;\n"; |
710 | t << "AccountName: " + accountPtr->accountName + "\n"; | 747 | t << "AccountName: " + accountPtr->accountName + "\n"; |
711 | t << "Name: " + accountPtr->name + "\n"; | 748 | t << "Name: " + accountPtr->name + "\n"; |
712 | t << "Email: " + accountPtr->emailAddress + "\n"; | 749 | t << "Email: " + accountPtr->emailAddress + "\n"; |
713 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 750 | t << "POPUser: " + accountPtr->popUserName + "\n"; |
714 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 751 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; |
715 | t << "POPServer: " + accountPtr->popServer + "\n"; | 752 | t << "POPServer: " + accountPtr->popServer + "\n"; |
716 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 753 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; |
717 | t << "AccountId: " << accountPtr->id << "\n"; | 754 | t << "AccountId: " << accountPtr->id << "\n"; |
718 | if (accountPtr->synchronize) { | 755 | if (accountPtr->synchronize) { |
719 | t << "Synchronize: Yes\n"; | 756 | t << "Synchronize: Yes\n"; |
720 | t << "LastServerMailCount: "; | 757 | t << "LastServerMailCount: "; |
721 | t << accountPtr->lastServerMailCount << "\n"; | 758 | t << accountPtr->lastServerMailCount << "\n"; |
722 | } else { | 759 | } else { |
723 | t << "Synchronize: No\n"; | 760 | t << "Synchronize: No\n"; |
724 | } | 761 | } |
725 | t << "SyncLimit: "; | 762 | t << "SyncLimit: "; |
726 | t << accountPtr->syncLimit << "\n"; | 763 | t << accountPtr->syncLimit << "\n"; |
727 | t << "accountEnd;\n"; | 764 | t << "accountEnd;\n"; |
728 | } | 765 | } |
729 | f.close(); | 766 | f.close(); |
730 | 767 | ||
731 | mailconf->setGroup("mailitglobal"); | 768 | mailconf->setGroup("mailitglobal"); |
732 | mailconf->writeEntry("mailidcount", mailIdCount); | 769 | mailconf->writeEntry("mailidcount", mailIdCount); |
733 | mailconf->writeEntry("accountidcount", accountIdCount); | 770 | mailconf->writeEntry("accountidcount", accountIdCount); |
734 | } | 771 | } |
735 | 772 | ||
736 | void EmailClient::selectAccount(int id) | 773 | void EmailClient::selectAccount(int id) |
737 | { | 774 | { |
738 | if (accountList.count() > 0) { | 775 | if (accountList.count() > 0) { |
739 | currentAccount = accountList.at(id); | 776 | currentAccount = accountList.at(id); |
740 | emit newCaption("Mailit - " + currentAccount->accountName); | 777 | emit newCaption("Mailit - " + currentAccount->accountName); |
741 | getNewMail(); | 778 | getNewMail(); |
742 | } else { | 779 | } else { |
743 | emit newCaption("Mailit ! No account defined"); | 780 | emit newCaption("Mailit ! No account defined"); |
744 | } | 781 | } |
745 | } | 782 | } |
746 | 783 | ||
747 | void EmailClient::editAccount(int id) | 784 | void EmailClient::editAccount(int id) |
748 | { | 785 | { |
749 | MailAccount *newAccount; | 786 | MailAccount *newAccount; |
750 | 787 | ||
751 | editAccountView = new EditAccount(this, "account", TRUE); | 788 | editAccountView = new EditAccount(this, "account", TRUE); |
752 | if (id == newAccountId) { //new account | 789 | if (id == newAccountId) { //new account |
@@ -766,107 +803,202 @@ void EmailClient::editAccount(int id) | |||
766 | accountIdCount++; | 803 | accountIdCount++; |
767 | accountList.append(newAccount); | 804 | accountList.append(newAccount); |
768 | updateAccounts(); | 805 | updateAccounts(); |
769 | } else { | 806 | } else { |
770 | updateAccounts(); | 807 | updateAccounts(); |
771 | } | 808 | } |
772 | } | 809 | } |
773 | 810 | ||
774 | delete editAccountView; | 811 | delete editAccountView; |
775 | } | 812 | } |
776 | 813 | ||
777 | void EmailClient::deleteAccount(int id) | 814 | void EmailClient::deleteAccount(int id) |
778 | { | 815 | { |
779 | MailAccount *newAccount; | 816 | MailAccount *newAccount; |
780 | QString message; | 817 | QString message; |
781 | 818 | ||
782 | newAccount = accountList.at(id); | 819 | newAccount = accountList.at(id); |
783 | message = "Delete account:\n" + newAccount->accountName; | 820 | message = "Delete account:\n" + newAccount->accountName; |
784 | switch( QMessageBox::warning( this, "Mailit", message, | 821 | switch( QMessageBox::warning( this, "Mailit", message, |
785 | "Yes", "No", 0, 0, 1 ) ) { | 822 | "Yes", "No", 0, 0, 1 ) ) { |
786 | 823 | ||
787 | case 0: accountList.remove(id); | 824 | case 0: accountList.remove(id); |
788 | updateAccounts(); | 825 | updateAccounts(); |
789 | break; | 826 | break; |
790 | case 1: | 827 | case 1: |
791 | break; | 828 | break; |
792 | } | 829 | } |
793 | } | 830 | } |
794 | 831 | ||
795 | void EmailClient::updateAccounts() | 832 | void EmailClient::updateAccounts() |
796 | { | 833 | { |
797 | MailAccount *accountPtr; | 834 | MailAccount *accountPtr; |
798 | 835 | ||
799 | //rebuild menus, clear all first | 836 | //rebuild menus, clear all first |
800 | editAccountMenu->clear(); | 837 | editAccountMenu->clear(); |
801 | selectAccountMenu->clear(); | 838 | selectAccountMenu->clear(); |
802 | deleteAccountMenu->clear(); | 839 | deleteAccountMenu->clear(); |
803 | 840 | ||
804 | newAccountId = editAccountMenu->insertItem("New", this, | 841 | newAccountId = editAccountMenu->insertItem("New", this, |
805 | SLOT(editAccount(int)) ); | 842 | SLOT(editAccount(int)) ); |
806 | editAccountMenu->insertSeparator(); | 843 | editAccountMenu->insertSeparator(); |
807 | 844 | ||
808 | idCount = 0; | 845 | idCount = 0; |
809 | for (accountPtr = accountList.first(); accountPtr != 0; | 846 | for (accountPtr = accountList.first(); accountPtr != 0; |
810 | accountPtr = accountList.next()) { | 847 | accountPtr = accountList.next()) { |
811 | 848 | ||
812 | editAccountMenu->insertItem(accountPtr->accountName, | 849 | editAccountMenu->insertItem(accountPtr->accountName, |
813 | this, SLOT(editAccount(int)), 0, idCount); | 850 | this, SLOT(editAccount(int)), 0, idCount); |
814 | selectAccountMenu->insertItem(accountPtr->accountName, | 851 | selectAccountMenu->insertItem(accountPtr->accountName, |
815 | this, SLOT(selectAccount(int)), 0, idCount); | 852 | this, SLOT(selectAccount(int)), 0, idCount); |
816 | deleteAccountMenu->insertItem(accountPtr->accountName, | 853 | deleteAccountMenu->insertItem(accountPtr->accountName, |
817 | this, SLOT(deleteAccount(int)), 0, idCount); | 854 | this, SLOT(deleteAccount(int)), 0, idCount); |
818 | idCount++; | 855 | idCount++; |
819 | } | 856 | } |
820 | } | 857 | } |
821 | 858 | ||
822 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 859 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
823 | { | 860 | { |
824 | Email *mPtr; | 861 | Email *mPtr; |
825 | Enclosure *ePtr; | 862 | Enclosure *ePtr; |
826 | 863 | ||
827 | if (inbox) { | 864 | if (inbox) |
865 | { | ||
828 | mPtr = mailItem->getMail(); | 866 | mPtr = mailItem->getMail(); |
829 | 867 | ||
830 | //if mail is in queue for download, remove it from | 868 | //if mail is in queue for download, remove it from |
831 | //queue if possible | 869 | //queue if possible |
832 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 870 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
833 | if ( !mPtr->downloaded ) | 871 | if ( !mPtr->downloaded ) |
834 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 872 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
835 | } | 873 | } |
836 | 874 | ||
837 | mailconf->setGroup(mPtr->id); | 875 | mailconf->setGroup(mPtr->id); |
838 | mailconf->clearGroup(); | 876 | mailconf->clearGroup(); |
839 | 877 | ||
840 | //delete any temporary attatchemnts storing | 878 | //delete any temporary attatchemnts storing |
841 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 879 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
842 | if (ePtr->saved) { | 880 | if (ePtr->saved) { |
843 | QFile::remove( (ePtr->path + ePtr->name) ); | 881 | QFile::remove( (ePtr->path + ePtr->name) ); |
844 | } | 882 | } |
845 | } | 883 | } |
846 | inboxView->takeItem(mailItem); | 884 | inboxView->takeItem(mailItem); |
847 | } else { | 885 | } |
886 | else | ||
887 | { | ||
848 | outboxView->takeItem(mailItem); | 888 | outboxView->takeItem(mailItem); |
849 | } | 889 | } |
850 | } | 890 | } |
851 | 891 | ||
852 | void EmailClient::setMailSize(int size) | 892 | void EmailClient::setMailSize(int size) |
853 | { | 893 | { |
854 | progressBar->reset(); | 894 | progressBar->reset(); |
855 | progressBar->setTotalSteps(size); | 895 | progressBar->setTotalSteps(size); |
856 | } | 896 | } |
857 | 897 | ||
858 | void EmailClient::setTotalSize(int size) | 898 | void EmailClient::setTotalSize(int size) |
859 | { | 899 | { |
860 | 900 | ||
861 | } | 901 | } |
862 | 902 | ||
863 | void EmailClient::setDownloadedSize(int size) | 903 | void EmailClient::setDownloadedSize(int size) |
864 | { | 904 | { |
865 | int total = progressBar->totalSteps(); | 905 | int total = progressBar->totalSteps(); |
866 | 906 | ||
867 | if (size < total) { | 907 | if (size < total) { |
868 | progressBar->setProgress(size); | 908 | progressBar->setProgress(size); |
869 | } else { | 909 | } else { |
870 | progressBar->setProgress(total); | 910 | progressBar->setProgress(total); |
871 | } | 911 | } |
872 | } | 912 | } |
913 | |||
914 | void EmailClient::deleteItem() | ||
915 | { | ||
916 | bool inbox=mailboxView->currentTab()==0; | ||
917 | |||
918 | EmailListItem* eli; | ||
919 | |||
920 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); | ||
921 | |||
922 | if (eli) | ||
923 | deleteMail(eli,(bool&)inbox); | ||
924 | } | ||
925 | |||
926 | void EmailClient::inboxItemPressed() | ||
927 | { | ||
928 | //timerID=startTimer(500); | ||
929 | } | ||
930 | |||
931 | void EmailClient::inboxItemReleased() | ||
932 | { | ||
933 | //killTimer(timerID); | ||
934 | } | ||
935 | |||
936 | void EmailClient::timerEvent(QTimerEvent *e) | ||
937 | { | ||
938 | /*killTimer(timerID); | ||
939 | |||
940 | |||
941 | QPopupMenu *action = new QPopupMenu(this); | ||
942 | |||
943 | int reply=0; | ||
944 | |||
945 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | ||
946 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | ||
947 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | ||
948 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | ||
949 | |||
950 | action->exec(QCursor::pos()); | ||
951 | |||
952 | if (action) delete action; | ||
953 | */ | ||
954 | } | ||
955 | |||
956 | Email* EmailClient::getCurrentMail() | ||
957 | { | ||
958 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | ||
959 | if (eli!=NULL) | ||
960 | return eli->getMail(); | ||
961 | else | ||
962 | return NULL; | ||
963 | } | ||
964 | |||
965 | /* | ||
966 | void EmailClient::reply() | ||
967 | { | ||
968 | Email* mail=getCurrentMail(); | ||
969 | |||
970 | if (mail!=NULL) | ||
971 | { | ||
972 | emit reply(*mail); | ||
973 | } | ||
974 | } | ||
975 | |||
976 | void EmailClient::replyAll() | ||
977 | { | ||
978 | Email* mail=getCurrentMail(); | ||
979 | |||
980 | if (mail!=NULL) | ||
981 | { | ||
982 | emit replyAll(*mail); | ||
983 | } | ||
984 | } | ||
985 | |||
986 | void EmailClient::forward() | ||
987 | { | ||
988 | Email* mail=getCurrentMail(); | ||
989 | |||
990 | if (mail!=NULL) | ||
991 | { | ||
992 | emit reply(*mail); | ||
993 | } | ||
994 | } | ||
995 | |||
996 | void EmailClient::remove() | ||
997 | { | ||
998 | Email* mail=getCurrentMail(); | ||
999 | |||
1000 | if (mail!=NULL) | ||
1001 | { | ||
1002 | emit remove(*mail); | ||
1003 | } | ||
1004 | }*/ \ No newline at end of file | ||
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h index 80457f9..0890dcf 100644 --- a/noncore/net/mailit/emailclient.h +++ b/noncore/net/mailit/emailclient.h | |||
@@ -1,149 +1,171 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef EMAILCLIENT_H | 20 | #ifndef EMAILCLIENT_H |
21 | #define EMAILCLIENT_H | 21 | #define EMAILCLIENT_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qaction.h> | 32 | #include <qaction.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qtooltip.h> | 34 | #include <qtooltip.h> |
35 | #include <qtoolbutton.h> | ||
35 | #include <qimage.h> | 36 | #include <qimage.h> |
36 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
37 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
38 | #include <qprogressbar.h> | 39 | #include <qprogressbar.h> |
39 | #include <qstatusbar.h> | 40 | #include <qstatusbar.h> |
40 | #include <qdir.h> | 41 | #include <qdir.h> |
41 | #include <stdlib.h> | 42 | #include <stdlib.h> |
42 | #include <opie/otabwidget.h> | 43 | #include <opie/otabwidget.h> |
44 | #include <qtimer.h> | ||
43 | 45 | ||
44 | #include "emailhandler.h" | 46 | #include "emailhandler.h" |
45 | #include "emaillistitem.h" | 47 | #include "emaillistitem.h" |
46 | #include "textparser.h" | 48 | #include "textparser.h" |
47 | #include "editaccount.h" | 49 | #include "editaccount.h" |
48 | #include "maillist.h" | 50 | #include "maillist.h" |
49 | #include "addresslist.h" | 51 | #include "addresslist.h" |
50 | 52 | ||
51 | #include <qpe/config.h> | 53 | #include <qpe/config.h> |
52 | 54 | ||
53 | class AccountList : public QList<MailAccount> | 55 | class AccountList : public QList<MailAccount> |
54 | { | 56 | { |
55 | public: | 57 | public: |
56 | Item newItem(Item d); | 58 | Item newItem(Item d); |
57 | private: | 59 | private: |
58 | MailAccount* dupl(MailAccount *in); | 60 | MailAccount* dupl(MailAccount *in); |
59 | MailAccount *ac; | 61 | MailAccount *ac; |
60 | }; | 62 | }; |
61 | 63 | ||
62 | //class EmailClient : public EmailClientBase | 64 | //class EmailClient : public EmailClientBase |
63 | class EmailClient : public QMainWindow | 65 | class EmailClient : public QMainWindow |
64 | { | 66 | { |
65 | Q_OBJECT | 67 | Q_OBJECT |
66 | 68 | ||
67 | public: | 69 | public: |
68 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); | 70 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); |
69 | ~EmailClient(); | 71 | ~EmailClient(); |
70 | AddressList* getAdrListRef(); | 72 | AddressList* getAdrListRef(); |
71 | 73 | ||
74 | protected: | ||
75 | void timerEvent(QTimerEvent*); | ||
76 | |||
72 | signals: | 77 | signals: |
73 | void composeRequested(); | 78 | void composeRequested(); |
74 | void viewEmail(QListView *, Email *); | 79 | void viewEmail(QListView *, Email *); |
75 | void mailUpdated(Email *); | 80 | void mailUpdated(Email *); |
76 | void newCaption(const QString &); | 81 | void newCaption(const QString &); |
77 | 82 | void replyRequested(Email&, bool&); | |
83 | void forwardRequested(Email&); | ||
84 | void removeItem(EmailListItem*, bool&); | ||
85 | /*void reply(Email&); | ||
86 | void replyAll(Email&); | ||
87 | void remove(Email&); | ||
88 | void forward(Email&);*/ | ||
89 | |||
78 | public slots: | 90 | public slots: |
79 | void compose(); | 91 | void compose(); |
80 | void cancel(); | 92 | void cancel(); |
81 | void enqueMail(const Email &mail); | 93 | void enqueMail(const Email &mail); |
82 | void setMailAccount(); | 94 | void setMailAccount(); |
83 | void sendQuedMail(); | 95 | void sendQuedMail(); |
84 | void mailSent(); | 96 | void mailSent(); |
97 | void deleteItem(); | ||
85 | void getNewMail(); | 98 | void getNewMail(); |
86 | void getAllNewMail(); | 99 | void getAllNewMail(); |
87 | void smtpError(int code); | 100 | void smtpError(int code); |
88 | void popError(int code); | 101 | void popError(int code); |
89 | void inboxItemSelected(); | 102 | void inboxItemSelected(); |
90 | void outboxItemSelected(); | 103 | void outboxItemSelected(); |
104 | void inboxItemPressed(); | ||
105 | void inboxItemReleased(); | ||
91 | void mailArrived(const Email &mail, bool fromDisk); | 106 | void mailArrived(const Email &mail, bool fromDisk); |
92 | void allMailArrived(int); | 107 | void allMailArrived(int); |
93 | void saveMail(QString fileName, QListView *view); | 108 | void saveMail(QString fileName, QListView *view); |
94 | void selectAccount(int); | 109 | void selectAccount(int); |
95 | void editAccount(int); | 110 | void editAccount(int); |
96 | void updateAccounts(); | 111 | void updateAccounts(); |
97 | void deleteAccount(int); | 112 | void deleteAccount(int); |
98 | void deleteMail(EmailListItem *mailItem, bool &inbox); | 113 | void deleteMail(EmailListItem *mailItem, bool &inbox); |
99 | void setTotalSize(int); | 114 | void setTotalSize(int); |
100 | void setMailSize(int); | 115 | void setMailSize(int); |
101 | void setDownloadedSize(int); | 116 | void setDownloadedSize(int); |
102 | void moveMailFront(Email *mailPtr); | 117 | void moveMailFront(Email *mailPtr); |
118 | /* void reply(); | ||
119 | void replyAll(); | ||
120 | void forward(); | ||
121 | void remove();*/ | ||
103 | 122 | ||
104 | private: | 123 | private: |
105 | void init(); | 124 | void init(); |
106 | void readMail(); | 125 | void readMail(); |
107 | QString getPath(bool enclosurePath); | 126 | QString getPath(bool enclosurePath); |
108 | void readSettings(); | 127 | void readSettings(); |
109 | void saveSettings(); | 128 | void saveSettings(); |
110 | 129 | Email* getCurrentMail(); | |
111 | private: | 130 | int timerID; |
112 | Config *mailconf; | 131 | Config *mailconf; |
113 | int newAccountId, idCount, mailIdCount; | 132 | int newAccountId, idCount, mailIdCount; |
114 | int accountIdCount; | 133 | int accountIdCount; |
115 | AccountList accountList; | 134 | AccountList accountList; |
116 | AddressList *addressList; | 135 | AddressList *addressList; |
117 | 136 | ||
118 | EditAccount *editAccountView; | 137 | EditAccount *editAccountView; |
119 | EmailListItem *item; | 138 | EmailListItem *item; |
120 | EmailHandler *emailHandler; | 139 | EmailHandler *emailHandler; |
121 | QList<Email> quedMessages; | 140 | QList<Email> quedMessages; |
122 | MailList mailDownloadList; | 141 | MailList mailDownloadList; |
123 | bool sending, receiving, previewingMail, allAccounts; | 142 | bool sending, receiving, previewingMail, allAccounts; |
124 | QString lineShift; | 143 | QString lineShift; |
125 | MailAccount account, *currentAccount; | 144 | MailAccount account, *currentAccount; |
126 | 145 | ||
127 | QToolBar *bar; | 146 | QToolBar *bar; |
128 | QProgressBar *progressBar; | 147 | QProgressBar *progressBar; |
129 | QStatusBar *statusBar; | 148 | QStatusBar *statusBar; |
130 | QLabel *status1Label, *status2Label; | 149 | QLabel *status1Label, *status2Label; |
131 | QAction *getMailButton; | 150 | QToolButton *getMailButton; |
132 | QAction *sendMailButton; | 151 | QAction *sendMailButton; |
133 | QAction *composeButton; | 152 | QAction *composeButton; |
134 | QAction *cancelButton; | 153 | QAction *cancelButton; |
135 | 154 | QAction *deleteButton; | |
155 | //QToolButton *setAccountButton; | ||
156 | |||
136 | QMenuBar *mb; | 157 | QMenuBar *mb; |
137 | QPopupMenu *selectAccountMenu; | 158 | QPopupMenu *selectAccountMenu; |
138 | QPopupMenu *editAccountMenu; | 159 | QPopupMenu *editAccountMenu; |
139 | QPopupMenu *deleteAccountMenu; | 160 | QPopupMenu *deleteAccountMenu; |
161 | QPopupMenu *setAccountMenu; | ||
140 | 162 | ||
141 | OTabWidget* mailboxView; | 163 | OTabWidget* mailboxView; |
142 | QListView* inboxView; | 164 | QListView* inboxView; |
143 | QListView* outboxView; | 165 | QListView* outboxView; |
144 | 166 | ||
145 | QGridLayout* grid_2; | 167 | QGridLayout* grid_2; |
146 | QGridLayout* grid_3; | 168 | QGridLayout* grid_3; |
147 | }; | 169 | }; |
148 | 170 | ||
149 | #endif // EMAILCLIENT_H | 171 | #endif // EMAILCLIENT_H |
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 03f8a28..f6c6d60 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -155,103 +155,109 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
155 | QString content, contentType, contentAttribute, id, encoding; | 155 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 156 | QString fileName, storedName; |
157 | int enclosureId = 0; | 157 | int enclosureId = 0; |
158 | 158 | ||
159 | mail->rawMail = in; | 159 | mail->rawMail = in; |
160 | mail->received = TRUE; | 160 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 161 | mail->files.setAutoDelete(TRUE); |
162 | 162 | ||
163 | temp = lineShift + "." + lineShift; | 163 | temp = lineShift + "." + lineShift; |
164 | 164 | ||
165 | if (in.right(temp.length()) != temp) { | 165 | if (in.right(temp.length()) != temp) { |
166 | mail->rawMail += temp; | 166 | mail->rawMail += temp; |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
171 | pos = in.find(delimiter, 0, FALSE); | 171 | pos = in.find(delimiter, 0, FALSE); |
172 | header = in.left(pos); | 172 | header = in.left(pos); |
173 | body = in.right(in.length() - pos - delimiter.length()); | 173 | body = in.right(in.length() - pos - delimiter.length()); |
174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
175 | body.truncate(body.length()-2); | 175 | body.truncate(body.length()-2); |
176 | 176 | ||
177 | TextParser p(header, lineShift); | 177 | TextParser p(header, lineShift); |
178 | 178 | ||
179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
180 | pos++; | 180 | pos++; |
181 | if (p.separatorAt(pos) == ' ') { | 181 | if (p.separatorAt(pos) == ' ') { |
182 | mail->from = p.getString(&pos, '<', false); | 182 | mail->from = p.getString(&pos, '<', false); |
183 | mail->from = mail->from.stripWhiteSpace(); | 183 | mail->from = mail->from.stripWhiteSpace(); |
184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
185 | mail->from = mail->from.left(mail->from.length() - 1); | 185 | mail->from = mail->from.left(mail->from.length() - 1); |
186 | mail->from = mail->from.right(mail->from.length() - 1); | 186 | mail->from = mail->from.right(mail->from.length() - 1); |
187 | } | 187 | } |
188 | pos++; | 188 | pos++; |
189 | mail->fromMail = p.getString(&pos, '>', false); | 189 | mail->fromMail = p.getString(&pos, '>', false); |
190 | } else { | 190 | } else { |
191 | if ((p.separatorAt(pos) == '<') | 191 | if ((p.separatorAt(pos) == '<') |
192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
193 | pos++; | 193 | pos++; |
194 | pos++; | 194 | pos++; |
195 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 195 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
197 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 197 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
198 | mail->from=mail->fromMail; | 198 | mail->from=mail->fromMail; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: |
203 | if (pos = p.find("TO",':', pos, TRUE) != -1) | 203 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) |
204 | { | 204 | { |
205 | pos++; | 205 | pos++; |
206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | |
210 | if ((pos = p.find("CC",':', 0, TRUE)) != -1) | ||
211 | { | ||
212 | pos++; | ||
213 | mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); | ||
214 | } | ||
215 | |||
210 | 216 | ||
211 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 217 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
212 | pos++; | 218 | pos++; |
213 | mail->subject = p.getString(&pos, 'z', TRUE); | 219 | mail->subject = p.getString(&pos, 'z', TRUE); |
214 | } | 220 | } |
215 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 221 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
216 | pos++; | 222 | pos++; |
217 | mail->date = p.getString(&pos, 'z', true); | 223 | mail->date = p.getString(&pos, 'z', true); |
218 | } | 224 | } |
219 | 225 | ||
220 | 226 | ||
221 | 227 | ||
222 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 228 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
223 | pos++; | 229 | pos++; |
224 | if ( (p.wordAt(pos).upper() == "ID") && | 230 | if ( (p.wordAt(pos).upper() == "ID") && |
225 | (p.separatorAt(pos) == ':') ) { | 231 | (p.separatorAt(pos) == ':') ) { |
226 | 232 | ||
227 | id = p.getString(&pos, 'z', TRUE); | 233 | id = p.getString(&pos, 'z', TRUE); |
228 | mail->id = id; | 234 | mail->id = id; |
229 | } | 235 | } |
230 | } | 236 | } |
231 | 237 | ||
232 | pos = 0; | 238 | pos = 0; |
233 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 239 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
234 | pos++; | 240 | pos++; |
235 | if ( (p.wordAt(pos).upper() == "VERSION") && | 241 | if ( (p.wordAt(pos).upper() == "VERSION") && |
236 | (p.separatorAt(pos) == ':') ) { | 242 | (p.separatorAt(pos) == ':') ) { |
237 | pos++; | 243 | pos++; |
238 | if (p.getString(&pos, 'z', true) == "1.0") { | 244 | if (p.getString(&pos, 'z', true) == "1.0") { |
239 | mail->mimeType = 1; | 245 | mail->mimeType = 1; |
240 | } | 246 | } |
241 | } | 247 | } |
242 | } | 248 | } |
243 | 249 | ||
244 | if (mail->mimeType == 1) { | 250 | if (mail->mimeType == 1) { |
245 | boundary = ""; | 251 | boundary = ""; |
246 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 252 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
247 | pos++; | 253 | pos++; |
248 | boundary = p.getString(&pos, 'z', true); | 254 | boundary = p.getString(&pos, 'z', true); |
249 | if (boundary[0] == '"') { | 255 | if (boundary[0] == '"') { |
250 | boundary = boundary.left(boundary.length() - 1); //strip " | 256 | boundary = boundary.left(boundary.length() - 1); //strip " |
251 | boundary = boundary.right(boundary.length() - 1); //strip " | 257 | boundary = boundary.right(boundary.length() - 1); //strip " |
252 | } | 258 | } |
253 | boundary = "--" + boundary; //create boundary field | 259 | boundary = "--" + boundary; //create boundary field |
254 | } | 260 | } |
255 | 261 | ||
256 | if (boundary == "") { //fooled by Mime-Version | 262 | if (boundary == "") { //fooled by Mime-Version |
257 | mail->body = body; | 263 | mail->body = body; |
@@ -389,96 +395,103 @@ int EmailHandler::parse64base(char *src, char *bufOut) { | |||
389 | li[x] = (int) c - (int) 'a' + 26; | 395 | li[x] = (int) c - (int) 'a' + 26; |
390 | if ( (int) c >= '0' && (int) c <= '9') | 396 | if ( (int) c >= '0' && (int) c <= '9') |
391 | li[x] = (int) c - (int) '0' + 52; | 397 | li[x] = (int) c - (int) '0' + 52; |
392 | if (c == '+') | 398 | if (c == '+') |
393 | li[x] = 62; | 399 | li[x] = 62; |
394 | if (c == '/') | 400 | if (c == '/') |
395 | li[x] = 63; | 401 | li[x] = 63; |
396 | } | 402 | } |
397 | 403 | ||
398 | processed = 1; | 404 | processed = 1; |
399 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 405 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
400 | bufOut[0] <<= 2; | 406 | bufOut[0] <<= 2; |
401 | z = li[1] >> 4; | 407 | z = li[1] >> 4; |
402 | bufOut[0] = bufOut[0] | z; //first byte retrived | 408 | bufOut[0] = bufOut[0] | z; //first byte retrived |
403 | 409 | ||
404 | if (src[2] != '=') { | 410 | if (src[2] != '=') { |
405 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 411 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
406 | bufOut[1] <<= 4; | 412 | bufOut[1] <<= 4; |
407 | z = li[2] >> 2; | 413 | z = li[2] >> 2; |
408 | bufOut[1] = bufOut[1] | z; //second byte retrived | 414 | bufOut[1] = bufOut[1] | z; //second byte retrived |
409 | processed++; | 415 | processed++; |
410 | 416 | ||
411 | if (src[3] != '=') { | 417 | if (src[3] != '=') { |
412 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 418 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
413 | bufOut[2] <<= 6; | 419 | bufOut[2] <<= 6; |
414 | z = li[3]; | 420 | z = li[3]; |
415 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 421 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
416 | processed++; | 422 | processed++; |
417 | } | 423 | } |
418 | } | 424 | } |
419 | return processed; | 425 | return processed; |
420 | } | 426 | } |
421 | 427 | ||
422 | int EmailHandler::encodeMime(Email *mail) | 428 | int EmailHandler::encodeMime(Email *mail) |
423 | { | 429 | { |
424 | 430 | ||
425 | QString fileName, fileType, contentType, newBody, boundary; | 431 | QString fileName, fileType, contentType, newBody, boundary; |
426 | Enclosure *ePtr; | 432 | Enclosure *ePtr; |
427 | 433 | ||
428 | QString userName = mailAccount.name; | 434 | QString userName = mailAccount.name; |
429 | if (userName.length()>0)//only embrace it if there is a user name | 435 | if (userName.length()>0)//only embrace it if there is a user name |
430 | userName += " <" + mailAccount.emailAddress + ">"; | 436 | userName += " <" + mailAccount.emailAddress + ">"; |
431 | 437 | ||
432 | //add standard headers | 438 | //add standard headers |
433 | newBody = "From: " + userName + "\r\nTo: "; | 439 | newBody = "From: " + userName + "\r\nTo: "; |
434 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 440 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
435 | newBody += *it + " "; | 441 | newBody += *it + " "; |
436 | } | 442 | } |
443 | |||
444 | newBody += "\r\nCC: "; | ||
445 | |||
446 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { | ||
447 | newBody += *it + " "; | ||
448 | } | ||
449 | |||
437 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 450 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
438 | 451 | ||
439 | if (mail->files.count() == 0) { //just a simple mail | 452 | if (mail->files.count() == 0) { //just a simple mail |
440 | newBody += "\r\n" + mail->body; | 453 | newBody += "\r\n" + mail->body; |
441 | mail->rawMail = newBody; | 454 | mail->rawMail = newBody; |
442 | return 0; | 455 | return 0; |
443 | } | 456 | } |
444 | 457 | ||
445 | //Build mime encoded mail | 458 | //Build mime encoded mail |
446 | boundary = "-----4345=next_bound=0495----"; | 459 | boundary = "-----4345=next_bound=0495----"; |
447 | 460 | ||
448 | newBody += "Mime-Version: 1.0\r\n"; | 461 | newBody += "Mime-Version: 1.0\r\n"; |
449 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 462 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
450 | boundary + "\"\r\n\r\n"; | 463 | boundary + "\"\r\n\r\n"; |
451 | 464 | ||
452 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 465 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
453 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 466 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
454 | newBody += mail->body; | 467 | newBody += mail->body; |
455 | 468 | ||
456 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 469 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
457 | fileName = ePtr->originalName; | 470 | fileName = ePtr->originalName; |
458 | fileType = ePtr->contentType; | 471 | fileType = ePtr->contentType; |
459 | QFileInfo fi(fileName); | 472 | QFileInfo fi(fileName); |
460 | 473 | ||
461 | // This specification of contentType is temporary | 474 | // This specification of contentType is temporary |
462 | contentType = ""; | 475 | contentType = ""; |
463 | if (fileType == "Picture") { | 476 | if (fileType == "Picture") { |
464 | contentType = "image/x-image"; | 477 | contentType = "image/x-image"; |
465 | } else if (fileType == "Document") { | 478 | } else if (fileType == "Document") { |
466 | contentType = "text/plain"; | 479 | contentType = "text/plain"; |
467 | } else if (fileType == "Sound") { | 480 | } else if (fileType == "Sound") { |
468 | contentType = "audio/x-wav"; | 481 | contentType = "audio/x-wav"; |
469 | } else if (fileType == "Movie") { | 482 | } else if (fileType == "Movie") { |
470 | contentType = "video/mpeg"; | 483 | contentType = "video/mpeg"; |
471 | } else { | 484 | } else { |
472 | contentType = "application/octet-stream"; | 485 | contentType = "application/octet-stream"; |
473 | } | 486 | } |
474 | 487 | ||
475 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 488 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
476 | newBody += "Content-Type: " + contentType + "; name=\"" + | 489 | newBody += "Content-Type: " + contentType + "; name=\"" + |
477 | fi.fileName() + "\"\r\n"; | 490 | fi.fileName() + "\"\r\n"; |
478 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 491 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
479 | newBody += "Content-Disposition: inline; filename=\"" + | 492 | newBody += "Content-Disposition: inline; filename=\"" + |
480 | fi.fileName() + "\"\r\n\r\n"; | 493 | fi.fileName() + "\"\r\n\r\n"; |
481 | 494 | ||
482 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 495 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
483 | return -1; | 496 | return -1; |
484 | } | 497 | } |
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index 2bf1dcb..ef5fc09 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp | |||
@@ -2,132 +2,164 @@ | |||
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 "mailitwindow.h" | 20 | #include "mailitwindow.h" |
21 | 21 | ||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
23 | : QMainWindow(parent, name, fl) | 23 | : QMainWindow(parent, name, fl) |
24 | { | 24 | { |
25 | currentCaption = "Mailit"; | 25 | currentCaption = "Mailit"; |
26 | setCaption(tr(currentCaption)); | 26 | setCaption(tr(currentCaption)); |
27 | views = new QWidgetStack(this); | 27 | views = new QWidgetStack(this); |
28 | setCentralWidget(views); | 28 | setCentralWidget(views); |
29 | 29 | ||
30 | emailClient = new EmailClient(views, "client"); | 30 | emailClient = new EmailClient(views, "client"); |
31 | writeMail = new WriteMail(views, "writing"); | 31 | writeMail = new WriteMail(views, "writing"); |
32 | readMail = new ReadMail(views, "reading"); | 32 | readMail = new ReadMail(views, "reading"); |
33 | 33 | ||
34 | views->raiseWidget(emailClient); | 34 | views->raiseWidget(emailClient); |
35 | 35 | ||
36 | connect(emailClient, SIGNAL(composeRequested()), | 36 | connect(emailClient, SIGNAL(composeRequested()), |
37 | this, SLOT(compose()) ); | 37 | this, SLOT(compose()) ); |
38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
39 | SLOT(viewMail(QListView *, Email *)) ); | 39 | SLOT(viewMail(QListView *, Email *)) ); |
40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
41 | SLOT(updateMailView(Email *)) ); | 41 | SLOT(updateMailView(Email *)) ); |
42 | 42 | ||
43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
45 | SLOT(showEmailClient()) ); | 45 | SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
47 | SLOT(enqueMail(const Email &)) ); | 47 | SLOT(enqueMail(const Email &)) ); |
48 | 48 | ||
49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
50 | connect(readMail, SIGNAL(replyRequested(Email &)), this, | 50 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, |
51 | SLOT(composeReply(Email &)) ); | 51 | SLOT(composeReply(Email &, bool&)) ); |
52 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, | ||
53 | SLOT(composeForward(Email &)) ); | ||
54 | |||
52 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 55 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
53 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 56 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
54 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 57 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
55 | SLOT(moveMailFront(Email *)) ); | 58 | SLOT(moveMailFront(Email *)) ); |
56 | 59 | ||
57 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 60 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
58 | this, SLOT(updateCaption(const QString &)) ); | 61 | this, SLOT(updateCaption(const QString &)) ); |
59 | viewingMail = FALSE; | 62 | viewingMail = FALSE; |
60 | 63 | ||
61 | } | 64 | } |
62 | 65 | ||
63 | MailItWindow::~MailItWindow() | 66 | MailItWindow::~MailItWindow() |
64 | { | 67 | { |
65 | } | 68 | } |
66 | 69 | ||
67 | void MailItWindow::closeEvent(QCloseEvent *e) | 70 | void MailItWindow::closeEvent(QCloseEvent *e) |
68 | { | 71 | { |
69 | if (views->visibleWidget() == emailClient) { | 72 | if (views->visibleWidget() == emailClient) { |
70 | e->accept(); | 73 | e->accept(); |
71 | } else { | 74 | } else { |
72 | showEmailClient(); | 75 | showEmailClient(); |
73 | } | 76 | } |
74 | } | 77 | } |
75 | 78 | ||
76 | void MailItWindow::compose() | 79 | void MailItWindow::compose() |
77 | { | 80 | { |
78 | viewingMail = FALSE; | 81 | viewingMail = FALSE; |
79 | emailClient->hide(); | 82 | emailClient->hide(); |
80 | readMail->hide(); | 83 | readMail->hide(); |
81 | views->raiseWidget(writeMail); | 84 | views->raiseWidget(writeMail); |
82 | writeMail->setAddressList(emailClient->getAdrListRef()); | 85 | writeMail->setAddressList(emailClient->getAdrListRef()); |
83 | setCaption( tr( "Write mail" ) ); | 86 | setCaption( tr( "Write mail" ) ); |
84 | } | 87 | } |
85 | 88 | ||
86 | void MailItWindow::composeReply(Email &mail) | 89 | void MailItWindow::composeReply(Email &mail, bool& replyAll) |
90 | { | ||
91 | compose(); | ||
92 | writeMail->reply(mail,replyAll) ; | ||
93 | } | ||
94 | |||
95 | void MailItWindow::composeForward(Email &mail) | ||
87 | { | 96 | { |
88 | compose(); | 97 | compose(); |
89 | writeMail->reply(mail); | 98 | writeMail->forward(mail) ; |
90 | } | 99 | } |
91 | 100 | ||
101 | |||
92 | void MailItWindow::showEmailClient() | 102 | void MailItWindow::showEmailClient() |
93 | { | 103 | { |
94 | viewingMail = FALSE; | 104 | viewingMail = FALSE; |
95 | writeMail->hide(); | 105 | writeMail->hide(); |
96 | readMail->hide(); | 106 | readMail->hide(); |
97 | views->raiseWidget(emailClient); | 107 | views->raiseWidget(emailClient); |
98 | setCaption( tr(currentCaption) ); | 108 | setCaption( tr(currentCaption) ); |
99 | } | 109 | } |
100 | 110 | ||
101 | void MailItWindow::viewMail(QListView *view, Email *mail) | 111 | void MailItWindow::viewMail(QListView *view, Email *mail) |
102 | { | 112 | { |
103 | viewingMail = TRUE; | 113 | viewingMail = TRUE; |
104 | emailClient->hide(); | 114 | emailClient->hide(); |
105 | readMail->update(view, mail); | 115 | readMail->update(view, mail); |
106 | views->raiseWidget(readMail); | 116 | views->raiseWidget(readMail); |
107 | setCaption( tr( "Examine mail" ) ); | 117 | setCaption( tr( "Examine mail" ) ); |
108 | } | 118 | } |
109 | 119 | ||
110 | void MailItWindow::updateMailView(Email *mail) | 120 | void MailItWindow::updateMailView(Email *mail) |
111 | { | 121 | { |
112 | if (viewingMail) { | 122 | if (viewingMail) { |
113 | readMail->mailUpdated(mail); | 123 | readMail->mailUpdated(mail); |
114 | } | 124 | } |
115 | } | 125 | } |
116 | 126 | ||
117 | void MailItWindow::updateCaption(const QString &newCaption) | 127 | void MailItWindow::updateCaption(const QString &newCaption) |
118 | { | 128 | { |
119 | currentCaption = newCaption; | 129 | currentCaption = newCaption; |
120 | setCaption(tr(currentCaption)); | 130 | setCaption(tr(currentCaption)); |
121 | } | 131 | } |
122 | 132 | ||
123 | void MailItWindow::setDocument(const QString &_address) | 133 | void MailItWindow::setDocument(const QString &_address) |
124 | { | 134 | { |
125 | // strip leading 'mailto:' | 135 | // strip leading 'mailto:' |
126 | QString address = _address; | 136 | QString address = _address; |
127 | if (address.startsWith("mailto:")) | 137 | if (address.startsWith("mailto:")) |
128 | address = address.mid(6); | 138 | address = address.mid(6); |
129 | 139 | ||
130 | compose(); | 140 | compose(); |
131 | writeMail->setRecipient(address); | 141 | writeMail->setRecipient(address); |
132 | } | 142 | } |
133 | 143 | ||
144 | /*void MailItWindow::reply(Email& mail) | ||
145 | { | ||
146 | qDebug("####EmailClient: 0 reached"); | ||
147 | composeReply(mail,(bool&)FALSE); | ||
148 | } | ||
149 | |||
150 | void MailItWindow::replyAll(Email& mail) | ||
151 | { | ||
152 | qDebug("####EmailClient: 1 reached"); | ||
153 | composeReply(mail,(bool&)TRUE); | ||
154 | } | ||
155 | |||
156 | void MailItWindow::forward(Email& mail) | ||
157 | { | ||
158 | qDebug("####EmailClient: 2 reached"); | ||
159 | } | ||
160 | |||
161 | void MailItWindow::remove(Email&) | ||
162 | { | ||
163 | qDebug("####EmailClient: 3 reached"); | ||
164 | //emit removeItem(eli,(bool&)TRUE); | ||
165 | } */ \ No newline at end of file | ||
diff --git a/noncore/net/mailit/mailitwindow.h b/noncore/net/mailit/mailitwindow.h index 667960b..e818d32 100644 --- a/noncore/net/mailit/mailitwindow.h +++ b/noncore/net/mailit/mailitwindow.h | |||
@@ -1,58 +1,64 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MailItWindow_H | 20 | #ifndef MailItWindow_H |
21 | #define MailItWindow_H | 21 | #define MailItWindow_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qwidgetstack.h> | 24 | #include <qwidgetstack.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | //#include <qlayout.h> | 26 | //#include <qlayout.h> |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | #include "writemail.h" | 28 | #include "writemail.h" |
29 | #include "readmail.h" | 29 | #include "readmail.h" |
30 | #include "addresslist.h" | 30 | #include "addresslist.h" |
31 | 31 | ||
32 | class MailItWindow: public QMainWindow | 32 | class MailItWindow: public QMainWindow |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 36 | MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
37 | ~MailItWindow(); | 37 | ~MailItWindow(); |
38 | 38 | ||
39 | signals: | ||
39 | public slots: | 40 | public slots: |
40 | void compose(); | 41 | void compose(); |
41 | void composeReply(Email &); | 42 | void composeReply(Email &, bool&); |
43 | void composeForward(Email &); | ||
42 | void showEmailClient(); | 44 | void showEmailClient(); |
43 | void viewMail(QListView *, Email *mail); | 45 | void viewMail(QListView *, Email *mail); |
44 | void updateMailView(Email *mail); | 46 | void updateMailView(Email *mail); |
45 | void closeEvent(QCloseEvent *e); | 47 | void closeEvent(QCloseEvent *e); |
46 | void updateCaption(const QString &); | 48 | void updateCaption(const QString &); |
47 | void setDocument(const QString &); | 49 | void setDocument(const QString &); |
50 | /*void reply(Email&); | ||
51 | void replyAll(Email&); | ||
52 | void forward(Email&); | ||
53 | void remove(Email&);*/ | ||
48 | 54 | ||
49 | private: | 55 | private: |
50 | EmailClient *emailClient; | 56 | EmailClient *emailClient; |
51 | WriteMail *writeMail; | 57 | WriteMail *writeMail; |
52 | ReadMail *readMail; | 58 | ReadMail *readMail; |
53 | QWidgetStack *views; | 59 | QWidgetStack *views; |
54 | QString currentCaption; | 60 | QString currentCaption; |
55 | bool viewingMail; | 61 | bool viewingMail; |
56 | }; | 62 | }; |
57 | 63 | ||
58 | #endif | 64 | #endif |
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp index 7cd3e09..dc98a6f 100644 --- a/noncore/net/mailit/readmail.cpp +++ b/noncore/net/mailit/readmail.cpp | |||
@@ -14,239 +14,263 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | ||
63 | forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), | ||
64 | QString::null, 0, this, 0 ); | ||
65 | connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); | ||
66 | |||
63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 67 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 68 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
65 | previousButton->addTo(bar); | 69 | previousButton->addTo(bar); |
66 | previousButton->addTo(viewMenu); | 70 | previousButton->addTo(viewMenu); |
67 | 71 | ||
68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 72 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 73 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
70 | nextButton->addTo(bar); | 74 | nextButton->addTo(bar); |
71 | nextButton->addTo(viewMenu); | 75 | nextButton->addTo(viewMenu); |
72 | 76 | ||
73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); | 77 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
74 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 78 | connect( attatchmentsButton, SIGNAL( activated() ), this, |
75 | SLOT( viewAttatchments() ) ); | 79 | SLOT( viewAttatchments() ) ); |
76 | attatchmentsButton->addTo(bar); | 80 | attatchmentsButton->addTo(bar); |
77 | attatchmentsButton->addTo(viewMenu); | 81 | attatchmentsButton->addTo(viewMenu); |
78 | 82 | ||
79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); | 83 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 84 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
81 | plainTextButton->addTo(bar); | 85 | plainTextButton->addTo(bar); |
82 | plainTextButton->addTo(viewMenu); | 86 | plainTextButton->addTo(viewMenu); |
83 | 87 | ||
84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 88 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 89 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
86 | deleteButton->addTo(bar); | 90 | deleteButton->addTo(bar); |
87 | deleteButton->addTo(mailMenu); | 91 | deleteButton->addTo(mailMenu); |
88 | 92 | ||
89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 93 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
90 | 94 | ||
91 | emailView = new QTextView( this, "emailView" ); | 95 | emailView = new QTextView( this, "emailView" ); |
92 | 96 | ||
93 | setCentralWidget(emailView); | 97 | setCentralWidget(emailView); |
94 | 98 | ||
95 | mime = new QMimeSourceFactory(); | 99 | mime = new QMimeSourceFactory(); |
96 | emailView->setMimeSourceFactory(mime); | 100 | emailView->setMimeSourceFactory(mime); |
97 | } | 101 | } |
98 | 102 | ||
99 | void ReadMail::updateView() | 103 | void ReadMail::updateView() |
100 | { | 104 | { |
101 | Enclosure *ePtr; | 105 | Enclosure *ePtr; |
102 | QString mailStringSize; | 106 | QString mailStringSize; |
103 | QString text, temp; | 107 | QString text, temp; |
104 | 108 | ||
105 | mail->read = TRUE; //mark as read | 109 | mail->read = TRUE; //mark as read |
106 | inbox = mail->received; | 110 | inbox = mail->received; |
107 | 111 | ||
108 | replyButton->removeFrom(mailMenu); | 112 | replyButton->removeFrom(mailMenu); |
109 | replyButton->removeFrom(bar); | 113 | replyButton->removeFrom(bar); |
114 | forwardButton->removeFrom(mailMenu); | ||
115 | forwardButton->removeFrom(bar); | ||
110 | 116 | ||
111 | if (inbox == TRUE) { | 117 | if (inbox == TRUE) { |
112 | replyButton->addTo(bar); | 118 | replyButton->addTo(bar); |
113 | replyButton->addTo(mailMenu); | 119 | replyButton->addTo(mailMenu); |
114 | 120 | forwardButton->addTo(bar); | |
121 | forwardButton->addTo(mailMenu); | ||
122 | |||
123 | |||
115 | if (!mail->downloaded) { | 124 | if (!mail->downloaded) { |
116 | //report currently viewed mail so that it will be | 125 | //report currently viewed mail so that it will be |
117 | //placed first in the queue of new mails to download | 126 | //placed first in the queue of new mails to download |
118 | emit viewingMail(mail); | 127 | emit viewingMail(mail); |
119 | 128 | ||
120 | double mailSize = (double) mail->size; | 129 | double mailSize = (double) mail->size; |
121 | if (mailSize < 1024) { | 130 | if (mailSize < 1024) { |
122 | mailStringSize.setNum(mailSize); | 131 | mailStringSize.setNum(mailSize); |
123 | mailStringSize += " Bytes"; | 132 | mailStringSize += " Bytes"; |
124 | } else if (mailSize < 1024*1024) { | 133 | } else if (mailSize < 1024*1024) { |
125 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 134 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
126 | mailStringSize += " Kb"; | 135 | mailStringSize += " Kb"; |
127 | } else { | 136 | } else { |
128 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 137 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
129 | mailStringSize += " Mb"; | 138 | mailStringSize += " Mb"; |
130 | } | 139 | } |
131 | } | 140 | } |
132 | } | 141 | } |
133 | 142 | ||
134 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 143 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
135 | 144 | ||
136 | if (! plainTxt) { //use RichText, inline pics etc. | 145 | if (! plainTxt) { //use RichText, inline pics etc. |
137 | emailView->setTextFormat(QTextView::RichText); | 146 | emailView->setTextFormat(QTextView::RichText); |
138 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 147 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
139 | +"</font></center></big></b><br>"; | 148 | +"</font></center></big></b><br>"; |
140 | text += "<b>From: </b>" + mail->from + " <i>" + | 149 | text += "<b>From: </b>" + mail->from + " <i>" + |
141 | mail->fromMail + "</i><br>"; | 150 | mail->fromMail + "</i><br>"; |
142 | 151 | ||
143 | text +="<b>To: </b>"; | 152 | text +="<b>To: </b>"; |
144 | for (QStringList::Iterator it = mail->recipients.begin(); | 153 | for (QStringList::Iterator it = mail->recipients.begin(); |
145 | it != mail->recipients.end(); ++it ) { | 154 | it != mail->recipients.end(); ++it ) { |
146 | text += *it + " "; | 155 | text += *it + " "; |
147 | } | 156 | } |
157 | |||
158 | text +="<br><b>CC: </b>"; | ||
159 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | ||
160 | it != mail->carbonCopies.end(); ++it ) { | ||
161 | text += *it + " "; | ||
162 | } | ||
163 | |||
148 | text += "<br>" + mail->date; | 164 | text += "<br>" + mail->date; |
149 | 165 | ||
150 | if (mail->files.count() > 0) { | 166 | if (mail->files.count() > 0) { |
151 | text += "<br><b>Attatchments: </b>"; | 167 | text += "<br><b>Attatchments: </b>"; |
152 | 168 | ||
153 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 169 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
154 | text += ePtr->originalName + " "; | 170 | text += ePtr->originalName + " "; |
155 | } | 171 | } |
156 | text += "<hr><br>" + mail->body; | 172 | text += "<hr><br>" + mail->body; |
157 | 173 | ||
158 | if (inbox) { | 174 | if (inbox) { |
159 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 175 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
160 | 176 | ||
161 | text += "<br><hr><b>Attatchment: </b>" + | 177 | text += "<br><hr><b>Attatchment: </b>" + |
162 | ePtr->originalName + "<hr>"; | 178 | ePtr->originalName + "<hr>"; |
163 | 179 | ||
164 | if (ePtr->contentType == "TEXT") { | 180 | if (ePtr->contentType == "TEXT") { |
165 | QFile f(ePtr->path + ePtr->name); | 181 | QFile f(ePtr->path + ePtr->name); |
166 | 182 | ||
167 | if (f.open(IO_ReadOnly) ) { | 183 | if (f.open(IO_ReadOnly) ) { |
168 | QTextStream t(&f); | 184 | QTextStream t(&f); |
169 | temp = t.read(); | 185 | temp = t.read(); |
170 | text += temp + "<br>"; | 186 | text += temp + "<br>"; |
171 | f.close(); | 187 | f.close(); |
172 | } else { | 188 | } else { |
173 | text += "<b>Could not locate file</b><br>"; | 189 | text += "<b>Could not locate file</b><br>"; |
174 | } | 190 | } |
175 | 191 | ||
176 | } | 192 | } |
177 | if (ePtr->contentType == "IMAGE") { | 193 | if (ePtr->contentType == "IMAGE") { |
178 | // temp.setNum(emailView->width());//get display width | 194 | // temp.setNum(emailView->width());//get display width |
179 | // text += "<img width=" + temp +" src =""" + | 195 | // text += "<img width=" + temp +" src =""" + |
180 | // ePtr->originalName + """> </img>"; | 196 | // ePtr->originalName + """> </img>"; |
181 | text += "<img src =""" + | 197 | text += "<img src =""" + |
182 | ePtr->originalName + """> </img>"; | 198 | ePtr->originalName + """> </img>"; |
183 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 199 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
184 | } | 200 | } |
185 | } | 201 | } |
186 | } | 202 | } |
187 | } else { | 203 | } else { |
188 | if (mail->downloaded || !inbox) { | 204 | if (mail->downloaded || !inbox) { |
189 | text += "<hr><br>" + mail->body; | 205 | text += "<hr><br>" + mail->body; |
190 | } else { | 206 | } else { |
191 | text += "<hr><br><b> Awaiting download </b><br>"; | 207 | text += "<hr><br><b> Awaiting download </b><br>"; |
192 | text += "Size of mail: " + mailStringSize; | 208 | text += "Size of mail: " + mailStringSize; |
193 | } | 209 | } |
194 | } | 210 | } |
195 | emailView->setText(text); | 211 | emailView->setText(text); |
196 | } else { // show plain txt mail | 212 | } else { // show plain txt mail |
197 | emailView->setTextFormat(QTextView::PlainText); | 213 | emailView->setTextFormat(QTextView::PlainText); |
198 | text = "Subject: " + mail->subject + "\n"; | 214 | text = "Subject: " + mail->subject + "\n"; |
199 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; | 215 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; |
200 | text += "To: "; | 216 | text += "To: "; |
201 | for (QStringList::Iterator it = mail->recipients.begin(); | 217 | for (QStringList::Iterator it = mail->recipients.begin(); |
202 | it != mail->recipients.end(); ++it ) { | 218 | it != mail->recipients.end(); ++it ) { |
203 | text += *it + " "; | 219 | text += *it + " "; |
204 | } | 220 | } |
221 | |||
222 | text += "\nCC: "; | ||
223 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | ||
224 | it != mail->carbonCopies.end(); ++it ) { | ||
225 | text += *it + " "; | ||
226 | } | ||
227 | |||
228 | |||
205 | text += "\nDate: " + mail->date + "\n"; | 229 | text += "\nDate: " + mail->date + "\n"; |
206 | if (mail->files.count() > 0) { | 230 | if (mail->files.count() > 0) { |
207 | text += "Attatchments: "; | 231 | text += "Attatchments: "; |
208 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 232 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
209 | text += ePtr->originalName + " "; | 233 | text += ePtr->originalName + " "; |
210 | } | 234 | } |
211 | text += "\n\n"; | 235 | text += "\n\n"; |
212 | } else text += "\n"; | 236 | } else text += "\n"; |
213 | 237 | ||
214 | if (!inbox) { | 238 | if (!inbox) { |
215 | text += mail->body; | 239 | text += mail->body; |
216 | } else if (mail->downloaded) { | 240 | } else if (mail->downloaded) { |
217 | text += mail->bodyPlain; | 241 | text += mail->bodyPlain; |
218 | } else { | 242 | } else { |
219 | text += "\nAwaiting download\n"; | 243 | text += "\nAwaiting download\n"; |
220 | text += "Size of mail: " + mailStringSize; | 244 | text += "Size of mail: " + mailStringSize; |
221 | } | 245 | } |
222 | 246 | ||
223 | emailView->setText(text); | 247 | emailView->setText(text); |
224 | } | 248 | } |
225 | 249 | ||
226 | if (mail->files.count() == 0) | 250 | if (mail->files.count() == 0) |
227 | attatchmentsButton->setEnabled(FALSE); | 251 | attatchmentsButton->setEnabled(FALSE); |
228 | else attatchmentsButton->setEnabled(TRUE); | 252 | else attatchmentsButton->setEnabled(TRUE); |
229 | 253 | ||
230 | setCaption("Examining mail: " + mail->subject); | 254 | setCaption("Examining mail: " + mail->subject); |
231 | } | 255 | } |
232 | 256 | ||
233 | //update view with current EmailListItem (item) | 257 | //update view with current EmailListItem (item) |
234 | void ReadMail::update(QListView *thisView, Email *mailIn) | 258 | void ReadMail::update(QListView *thisView, Email *mailIn) |
235 | { | 259 | { |
236 | view = thisView; | 260 | view = thisView; |
237 | item = (EmailListItem *) view->selectedItem(); | 261 | item = (EmailListItem *) view->selectedItem(); |
238 | mail = mailIn; | 262 | mail = mailIn; |
239 | updateView(); | 263 | updateView(); |
240 | updateButtons(); | 264 | updateButtons(); |
241 | } | 265 | } |
242 | 266 | ||
243 | void ReadMail::mailUpdated(Email *mailIn) | 267 | void ReadMail::mailUpdated(Email *mailIn) |
244 | { | 268 | { |
245 | if (mailIn == mail) { | 269 | if (mailIn == mail) { |
246 | updateView(); | 270 | updateView(); |
247 | } else { | 271 | } else { |
248 | updateButtons(); | 272 | updateButtons(); |
249 | } | 273 | } |
250 | } | 274 | } |
251 | 275 | ||
252 | void ReadMail::close() | 276 | void ReadMail::close() |
@@ -278,50 +302,56 @@ void ReadMail::previous() | |||
278 | 302 | ||
279 | //deletes item, tries bringing up next or previous, exits if unsucessful | 303 | //deletes item, tries bringing up next or previous, exits if unsucessful |
280 | void ReadMail::deleteItem() | 304 | void ReadMail::deleteItem() |
281 | { | 305 | { |
282 | EmailListItem *temp = item; | 306 | EmailListItem *temp = item; |
283 | temp = (EmailListItem *) item->nextSibling();//trybelow | 307 | temp = (EmailListItem *) item->nextSibling();//trybelow |
284 | if (temp == NULL) | 308 | if (temp == NULL) |
285 | temp = (EmailListItem *) item->itemAbove(); //try above | 309 | temp = (EmailListItem *) item->itemAbove(); //try above |
286 | 310 | ||
287 | emit removeItem(item, inbox); | 311 | emit removeItem(item, inbox); |
288 | 312 | ||
289 | item = temp; | 313 | item = temp; |
290 | if (item != NULL) { //more items in list | 314 | if (item != NULL) { //more items in list |
291 | mail = item->getMail(); | 315 | mail = item->getMail(); |
292 | updateView(); | 316 | updateView(); |
293 | updateButtons(); | 317 | updateButtons(); |
294 | } else close(); //no more items to see | 318 | } else close(); //no more items to see |
295 | } | 319 | } |
296 | 320 | ||
297 | void ReadMail::updateButtons() | 321 | void ReadMail::updateButtons() |
298 | { | 322 | { |
299 | EmailListItem *temp; | 323 | EmailListItem *temp; |
300 | 324 | ||
301 | temp = item; | 325 | temp = item; |
302 | if ((EmailListItem *) temp->nextSibling() == NULL) | 326 | if ((EmailListItem *) temp->nextSibling() == NULL) |
303 | nextButton->setEnabled(FALSE); | 327 | nextButton->setEnabled(FALSE); |
304 | else nextButton->setEnabled(TRUE); | 328 | else nextButton->setEnabled(TRUE); |
305 | 329 | ||
306 | temp = item; | 330 | temp = item; |
307 | if ((EmailListItem *) temp->itemAbove() == NULL) | 331 | if ((EmailListItem *) temp->itemAbove() == NULL) |
308 | previousButton->setEnabled(FALSE); | 332 | previousButton->setEnabled(FALSE); |
309 | else previousButton->setEnabled(TRUE); | 333 | else previousButton->setEnabled(TRUE); |
310 | } | 334 | } |
311 | 335 | ||
312 | void ReadMail::shiftText() | 336 | void ReadMail::shiftText() |
313 | { | 337 | { |
314 | plainTxt = ! plainTxt; | 338 | plainTxt = ! plainTxt; |
315 | updateView(); | 339 | updateView(); |
316 | } | 340 | } |
317 | 341 | ||
318 | void ReadMail::viewAttatchments() | 342 | void ReadMail::viewAttatchments() |
319 | { | 343 | { |
320 | viewAtt->update(mail, inbox); | 344 | viewAtt->update(mail, inbox); |
321 | viewAtt->showMaximized(); | 345 | viewAtt->showMaximized(); |
322 | } | 346 | } |
323 | 347 | ||
324 | void ReadMail::reply() | 348 | void ReadMail::reply() |
325 | { | 349 | { |
326 | emit replyRequested(*mail); | 350 | emit replyRequested(*mail, (bool&)TRUE); |
327 | } | 351 | } |
352 | |||
353 | void ReadMail::forward() | ||
354 | { | ||
355 | emit forwardRequested(*mail); | ||
356 | } | ||
357 | |||
diff --git a/noncore/net/mailit/readmail.h b/noncore/net/mailit/readmail.h index d0bb067..0fe0646 100644 --- a/noncore/net/mailit/readmail.h +++ b/noncore/net/mailit/readmail.h | |||
@@ -1,86 +1,89 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef READMAIL_H | 20 | #ifndef READMAIL_H |
21 | #define READMAIL_H | 21 | #define READMAIL_H |
22 | 22 | ||
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtextview.h> | 30 | #include <qtextview.h> |
31 | 31 | ||
32 | #include "emailhandler.h" | 32 | #include "emailhandler.h" |
33 | #include "emaillistitem.h" | 33 | #include "emaillistitem.h" |
34 | #include "viewatt.h" | 34 | #include "viewatt.h" |
35 | 35 | ||
36 | class ReadMail : public QMainWindow | 36 | class ReadMail : public QMainWindow |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
42 | ~ReadMail(); | 42 | ~ReadMail(); |
43 | void update(QListView *thisView, Email *mailIn); | 43 | void update(QListView *thisView, Email *mailIn); |
44 | void updateView(); | 44 | void updateView(); |
45 | void mailUpdated(Email *mailIn); | 45 | void mailUpdated(Email *mailIn); |
46 | 46 | ||
47 | signals: | 47 | signals: |
48 | void cancelView(); | 48 | void cancelView(); |
49 | void replyRequested(Email &); | 49 | void replyRequested(Email &, bool &); |
50 | void forwardRequested(Email&); | ||
50 | void removeItem(EmailListItem *, bool &); | 51 | void removeItem(EmailListItem *, bool &); |
51 | void viewingMail(Email *); | 52 | void viewingMail(Email *); |
52 | 53 | ||
53 | public slots: | 54 | public slots: |
54 | void close(); | 55 | void close(); |
55 | void next(); | 56 | void next(); |
56 | void previous(); | 57 | void previous(); |
57 | void deleteItem(); | 58 | void deleteItem(); |
58 | void shiftText(); | 59 | void shiftText(); |
59 | void viewAttatchments(); | 60 | void viewAttatchments(); |
60 | void reply(); | 61 | void reply(); |
62 | void forward(); | ||
61 | 63 | ||
62 | private: | 64 | private: |
63 | void init(); | 65 | void init(); |
64 | void updateButtons(); | 66 | void updateButtons(); |
65 | 67 | ||
66 | private: | 68 | private: |
67 | QListView *view; | 69 | QListView *view; |
68 | EmailListItem *item; | 70 | EmailListItem *item; |
69 | bool plainTxt, inbox; | 71 | bool plainTxt, inbox; |
70 | Email *mail; | 72 | Email *mail; |
71 | ViewAtt *viewAtt; | 73 | ViewAtt *viewAtt; |
72 | 74 | ||
73 | QToolBar *bar; | 75 | QToolBar *bar; |
74 | QMenuBar *menu; | 76 | QMenuBar *menu; |
75 | QPopupMenu *viewMenu, *mailMenu; | 77 | QPopupMenu *viewMenu, *mailMenu; |
76 | QAction *deleteButton; | 78 | QAction *deleteButton; |
77 | QMimeSourceFactory *mime; | 79 | QMimeSourceFactory *mime; |
78 | QAction *plainTextButton; | 80 | QAction *plainTextButton; |
79 | QAction *nextButton; | 81 | QAction *nextButton; |
80 | QTextView *emailView; | 82 | QTextView *emailView; |
81 | QAction *attatchmentsButton; | 83 | QAction *attatchmentsButton; |
82 | QAction *previousButton; | 84 | QAction *previousButton; |
83 | QAction *replyButton; | 85 | QAction *replyButton; |
86 | QAction *forwardButton; | ||
84 | }; | 87 | }; |
85 | 88 | ||
86 | #endif // READMAIL_H | 89 | #endif // READMAIL_H |
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index 38a2596..a9dcb02 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp | |||
@@ -38,261 +38,336 @@ WriteMail::~WriteMail() | |||
38 | void WriteMail::setAddressList(AddressList *list) | 38 | void WriteMail::setAddressList(AddressList *list) |
39 | { | 39 | { |
40 | Contact *cPtr; | 40 | Contact *cPtr; |
41 | 41 | ||
42 | addressList = list; | 42 | addressList = list; |
43 | 43 | ||
44 | addressView->clear(); | 44 | addressView->clear(); |
45 | QList<Contact> *cListPtr = addressList->getContactList(); | 45 | QList<Contact> *cListPtr = addressList->getContactList(); |
46 | QListViewItem *item; | 46 | QListViewItem *item; |
47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); | 48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void WriteMail::init() | 52 | void WriteMail::init() |
53 | { | 53 | { |
54 | setToolBarsMovable(FALSE); | 54 | setToolBarsMovable(FALSE); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
58 | 58 | ||
59 | menu = new QMenuBar( bar ); | 59 | menu = new QMenuBar( bar ); |
60 | 60 | ||
61 | mailMenu = new QPopupMenu(menu); | 61 | mailMenu = new QPopupMenu(menu); |
62 | menu->insertItem( tr( "&Mail" ), mailMenu); | 62 | menu->insertItem( tr( "&Mail" ), mailMenu); |
63 | addMenu = new QPopupMenu(menu); | 63 | addMenu = new QPopupMenu(menu); |
64 | menu->insertItem( tr( "&Add" ), addMenu); | 64 | menu->insertItem( tr( "&Add" ), addMenu); |
65 | 65 | ||
66 | bar = new QToolBar(this); | 66 | bar = new QToolBar(this); |
67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); | 67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
68 | attatchButton->addTo(bar); | 68 | attatchButton->addTo(bar); |
69 | attatchButton->addTo(addMenu); | 69 | attatchButton->addTo(addMenu); |
70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); | 70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); |
71 | 71 | ||
72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
73 | confirmButton->addTo(bar); | 73 | confirmButton->addTo(bar); |
74 | confirmButton->addTo(mailMenu); | 74 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
76 | 76 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 78 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 80 | ||
81 | widget = new QWidget(this, "widget"); | 81 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 82 | grid = new QGridLayout( widget ); |
83 | 83 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 85 | recipientsBox->insertItem( tr( "To:" ) ); |
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 86 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 87 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 88 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | ||
90 | |||
89 | 91 | ||
90 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 92 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
91 | subjetLabel->setText( tr( "Subject:" ) ); | 93 | subjetLabel->setText( tr( "Subject:" ) ); |
92 | 94 | ||
93 | grid->addWidget( subjetLabel, 1, 0 ); | 95 | grid->addWidget( subjetLabel, 1, 0 ); |
94 | 96 | ||
95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 97 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
96 | ToolButton13_2->setText( tr( "..." ) ); | 98 | ToolButton13_2->setText( tr( "..." ) ); |
97 | grid->addWidget( ToolButton13_2, 1, 2 ); | 99 | grid->addWidget( ToolButton13_2, 1, 2 ); |
98 | 100 | ||
99 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 101 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
100 | grid->addWidget( subjectInput, 1, 1 ); | 102 | grid->addWidget( subjectInput, 1, 1 ); |
101 | 103 | ||
102 | toInput = new QLineEdit( widget, "toInput" ); | 104 | toInput = new QLineEdit( widget, "toInput" ); |
103 | grid->addWidget( toInput, 0, 1 ); | 105 | grid->addWidget( toInput, 0, 1 ); |
104 | 106 | ||
107 | ccInput = new QLineEdit( widget, "ccInput" ); | ||
108 | ccInput->hide(); | ||
109 | grid->addWidget( ccInput, 0, 1 ); | ||
110 | |||
111 | |||
105 | addressButton = new QToolButton( widget, "addressButton" ); | 112 | addressButton = new QToolButton( widget, "addressButton" ); |
106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 113 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
107 | addressButton->setToggleButton(TRUE); | 114 | addressButton->setToggleButton(TRUE); |
108 | grid->addWidget( addressButton, 0, 2 ); | 115 | grid->addWidget( addressButton, 0, 2 ); |
109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 116 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
110 | 117 | ||
111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 118 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 119 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
113 | 120 | ||
114 | 121 | ||
115 | addressView = new QListView( widget, "addressView"); | 122 | addressView = new QListView( widget, "addressView"); |
116 | addressView->addColumn("Name"); | 123 | addressView->addColumn("Name"); |
117 | addressView->addColumn("EMail"); | 124 | addressView->addColumn("EMail"); |
118 | addressView->setAllColumnsShowFocus(TRUE); | 125 | addressView->setAllColumnsShowFocus(TRUE); |
119 | addressView->setMultiSelection(TRUE); | 126 | addressView->setMultiSelection(TRUE); |
120 | addressView->hide(); | 127 | addressView->hide(); |
121 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 128 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
122 | 129 | ||
123 | okButton = new QToolButton(bar, "ok"); | 130 | okButton = new QToolButton(bar, "ok"); |
124 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 131 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
125 | okButton->hide(); | 132 | okButton->hide(); |
126 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 133 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
127 | 134 | ||
128 | setCentralWidget(widget); | 135 | setCentralWidget(widget); |
129 | } | 136 | } |
130 | 137 | ||
131 | void WriteMail::reject() | 138 | void WriteMail::reject() |
132 | { | 139 | { |
133 | emit cancelMail(); | 140 | emit cancelMail(); |
134 | } | 141 | } |
135 | 142 | ||
136 | // need to insert date | 143 | // need to insert date |
137 | void WriteMail::accept() | 144 | void WriteMail::accept() |
138 | { | 145 | { |
139 | QStringList attatchedFiles, attatchmentsType; | 146 | QStringList attatchedFiles, attatchmentsType; |
140 | int idCount = 0; | 147 | int idCount = 0; |
141 | 148 | ||
142 | if (toInput->text() == "") { | 149 | if (toInput->text() == "") |
143 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); | 150 | { |
151 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | ||
152 | return; | ||
153 | } | ||
154 | |||
155 | if (! getRecipients(false) ) | ||
156 | { | ||
157 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | ||
158 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | ||
144 | return; | 159 | return; |
145 | } | 160 | } |
146 | if (! getRecipients() ) { | 161 | |
147 | QMessageBox::warning(this,"Incorrect recipient separator", | 162 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
148 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); | 163 | { |
164 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | ||
165 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | ||
149 | return; | 166 | return; |
150 | } | 167 | } |
168 | |||
151 | mail.subject = subjectInput->text(); | 169 | mail.subject = subjectInput->text(); |
152 | mail.body = emailInput->text(); | 170 | mail.body = emailInput->text(); |
153 | mail.sent = false; | 171 | mail.sent = false; |
154 | mail.received = false; | 172 | mail.received = false; |
173 | |||
155 | mail.rawMail = "To: "; | 174 | mail.rawMail = "To: "; |
156 | 175 | ||
157 | for (QStringList::Iterator it = mail.recipients.begin(); | 176 | for (QStringList::Iterator it = mail.recipients.begin(); |
158 | it != mail.recipients.end(); ++it) { | 177 | it != mail.recipients.end(); ++it) { |
159 | 178 | ||
160 | mail.rawMail += (*it); | 179 | mail.rawMail += (*it); |
161 | mail.rawMail += ",\n"; | 180 | mail.rawMail += ",\n"; |
162 | } | 181 | } |
182 | |||
163 | mail.rawMail.truncate(mail.rawMail.length()-2); | 183 | mail.rawMail.truncate(mail.rawMail.length()-2); |
184 | |||
185 | mail.rawMail += "\nCC: "; | ||
186 | |||
187 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | ||
188 | it != mail.carbonCopies.end(); ++it) { | ||
189 | |||
190 | mail.rawMail += (*it); | ||
191 | mail.rawMail += ",\n"; | ||
192 | } | ||
193 | |||
164 | mail.rawMail += mail.from; | 194 | mail.rawMail += mail.from; |
165 | mail.rawMail += "\nSubject: "; | 195 | mail.rawMail += "\nSubject: "; |
166 | mail.rawMail += mail.subject; | 196 | mail.rawMail += mail.subject; |
167 | mail.rawMail += "\n\n"; | 197 | mail.rawMail += "\n\n"; |
168 | 198 | ||
169 | attatchedFiles = addAtt->returnAttatchedFiles(); | 199 | attatchedFiles = addAtt->returnAttatchedFiles(); |
170 | attatchmentsType = addAtt->returnFileTypes(); | 200 | attatchmentsType = addAtt->returnFileTypes(); |
171 | 201 | ||
172 | QStringList::Iterator itType = attatchmentsType.begin(); | 202 | QStringList::Iterator itType = attatchmentsType.begin(); |
173 | 203 | ||
174 | Enclosure e; | 204 | Enclosure e; |
175 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { | 205 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { |
176 | e.id = idCount; | 206 | e.id = idCount; |
177 | e.originalName = (*it).latin1(); | 207 | e.originalName = (*it).latin1(); |
178 | e.contentType = (*itType).latin1(); | 208 | e.contentType = (*itType).latin1(); |
179 | e.contentAttribute = (*itType).latin1(); | 209 | e.contentAttribute = (*itType).latin1(); |
180 | e.saved = TRUE; | 210 | e.saved = TRUE; |
181 | mail.addEnclosure(&e); | 211 | mail.addEnclosure(&e); |
182 | 212 | ||
183 | itType++; | 213 | itType++; |
184 | idCount++; | 214 | idCount++; |
185 | } | 215 | } |
186 | mail.rawMail += mail.body; | 216 | mail.rawMail += mail.body; |
187 | mail.rawMail += "\n"; | 217 | mail.rawMail += "\n"; |
188 | mail.rawMail += ".\n"; | 218 | mail.rawMail += ".\n"; |
189 | emit sendMailRequested(mail); | 219 | emit sendMailRequested(mail); |
190 | addAtt->clear(); | 220 | addAtt->clear(); |
191 | } | 221 | } |
192 | 222 | ||
193 | void WriteMail::getAddress() | 223 | void WriteMail::getAddress() |
194 | { | 224 | { |
195 | showingAddressList = !showingAddressList; | 225 | showingAddressList = !showingAddressList; |
196 | 226 | ||
197 | if (showingAddressList) { | 227 | if (showingAddressList) { |
198 | emailInput->hide(); | 228 | emailInput->hide(); |
199 | addressView->show(); | 229 | addressView->show(); |
200 | okButton->show(); | 230 | okButton->show(); |
201 | 231 | ||
202 | } else { | 232 | } else { |
203 | addressView->hide(); | 233 | addressView->hide(); |
204 | okButton->hide(); | 234 | okButton->hide(); |
205 | emailInput->show(); | 235 | emailInput->show(); |
206 | } | 236 | } |
207 | } | 237 | } |
208 | 238 | ||
209 | void WriteMail::attatchFile() | 239 | void WriteMail::attatchFile() |
210 | { | 240 | { |
211 | addAtt->showMaximized(); | 241 | addAtt->showMaximized(); |
212 | } | 242 | } |
213 | 243 | ||
214 | void WriteMail::reply(Email replyMail) | 244 | void WriteMail::reply(Email replyMail, bool replyAll) |
215 | { | 245 | { |
216 | int pos; | 246 | int pos; |
217 | 247 | ||
218 | mail = replyMail; | 248 | mail = replyMail; |
219 | mail.files.clear(); | 249 | mail.files.clear(); |
220 | 250 | ||
221 | toInput->setText(mail.fromMail); | 251 | toInput->setText(mail.fromMail); |
222 | subjectInput->setText("Re: " + mail.subject); | 252 | //replyAll ? ccInput->setText(mail.c) |
253 | |||
254 | addRecipients(replyAll); | ||
255 | |||
256 | subjectInput->setText(tr("Re: ") + mail.subject); | ||
223 | 257 | ||
224 | pos = 0; | 258 | pos = 0; |
225 | mail.body.insert(pos, ">>"); | 259 | mail.body.insert(pos, ">>"); |
226 | while (pos != -1) { | 260 | while (pos != -1) { |
227 | pos = mail.body.find('\n', pos); | 261 | pos = mail.body.find('\n', pos); |
228 | if (pos != -1) | 262 | if (pos != -1) |
229 | mail.body.insert(++pos, ">>"); | 263 | mail.body.insert(++pos, ">>"); |
230 | } | 264 | } |
231 | 265 | ||
232 | emailInput->setText(mail.body); | 266 | emailInput->setText(mail.body); |
233 | } | 267 | } |
234 | 268 | ||
235 | bool WriteMail::getRecipients() | 269 | void WriteMail::forward(Email forwMail) |
270 | { | ||
271 | int pos=0; | ||
272 | |||
273 | QString fwdBody=tr("======forwarded message from "); | ||
274 | fwdBody.append(forwMail.fromMail); | ||
275 | fwdBody.append(tr(" starts======\n\n")); | ||
276 | |||
277 | mail=forwMail; | ||
278 | toInput->setText(""); | ||
279 | ccInput->setText(""); | ||
280 | subjectInput->setText(tr("FWD: ") + mail.subject); | ||
281 | |||
282 | fwdBody+=mail.body; | ||
283 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | ||
284 | |||
285 | emailInput->setText(fwdBody); | ||
286 | } | ||
287 | |||
288 | bool WriteMail::getRecipients(bool ccField) | ||
236 | { | 289 | { |
237 | QString str, temp; | 290 | QString str, temp; |
238 | int pos = 0; | 291 | int pos = 0; |
239 | 292 | ||
240 | mail.recipients.clear(); | 293 | mail.recipients.clear(); |
241 | 294 | ||
242 | temp = toInput->text(); | 295 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
296 | |||
243 | while ( (pos = temp.find(';')) != -1) { | 297 | while ( (pos = temp.find(';')) != -1) { |
244 | str = temp.left(pos).stripWhiteSpace(); | 298 | str = temp.left(pos).stripWhiteSpace(); |
245 | temp = temp.right(temp.length() - (pos + 1)); | 299 | temp = temp.right(temp.length() - (pos + 1)); |
246 | if ( str.find('@') == -1) | 300 | if ( str.find('@') == -1) |
247 | return false; | 301 | return false; |
248 | mail.recipients.append(str); | 302 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
249 | addressList->addContact(str, ""); | 303 | addressList->addContact(str, ""); |
250 | } | 304 | } |
251 | temp = temp.stripWhiteSpace(); | 305 | temp = temp.stripWhiteSpace(); |
252 | if ( temp.find('@') == -1) | 306 | if ( temp.find('@') == -1) |
253 | return false; | 307 | return false; |
254 | mail.recipients.append(temp); | 308 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
255 | addressList->addContact(temp, ""); | 309 | addressList->addContact(temp, ""); |
256 | 310 | ||
257 | return TRUE; | 311 | return TRUE; |
258 | } | 312 | } |
259 | |||
260 | 313 | ||
261 | void WriteMail::addRecipients() | 314 | void WriteMail::addRecipients() |
262 | { | 315 | { |
316 | |||
317 | addRecipients(false); | ||
318 | } | ||
319 | |||
320 | void WriteMail::addRecipients(bool ccField) | ||
321 | { | ||
263 | QString recipients = ""; | 322 | QString recipients = ""; |
264 | 323 | ||
265 | mail.recipients.clear(); | 324 | mail.recipients.clear(); |
325 | |||
266 | QListViewItem *item = addressView->firstChild(); | 326 | QListViewItem *item = addressView->firstChild(); |
267 | while (item != NULL) { | 327 | while (item != NULL) { |
268 | if ( item->isSelected() ) { | 328 | if ( item->isSelected() ) { |
269 | if (recipients == "") { | 329 | if (recipients == "") { |
270 | recipients = item->text(0); | 330 | recipients = item->text(0); |
271 | } else { | 331 | } else { |
272 | recipients += "; " + item->text(0); | 332 | recipients += "; " + item->text(0); |
273 | } | 333 | } |
274 | } | 334 | } |
275 | item = item->nextSibling(); | 335 | item = item->nextSibling(); |
276 | } | 336 | } |
277 | toInput->setText(recipients); | 337 | |
338 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | ||
278 | 339 | ||
279 | addressView->hide(); | 340 | addressView->hide(); |
280 | okButton->hide(); | 341 | okButton->hide(); |
281 | emailInput->show(); | 342 | emailInput->show(); |
282 | addressButton->setOn(FALSE); | 343 | addressButton->setOn(FALSE); |
283 | showingAddressList = !showingAddressList; | 344 | showingAddressList = !showingAddressList; |
284 | } | 345 | } |
285 | 346 | ||
347 | void WriteMail::changeRecipients(int selection) | ||
348 | { | ||
349 | if (selection==0) | ||
350 | { | ||
351 | toInput->show(); | ||
352 | ccInput->hide(); | ||
353 | } | ||
354 | else if (selection==1) | ||
355 | { | ||
356 | toInput->hide(); | ||
357 | ccInput->show(); | ||
358 | } | ||
359 | } | ||
360 | |||
286 | void WriteMail::setRecipient(const QString &recipient) | 361 | void WriteMail::setRecipient(const QString &recipient) |
287 | { | 362 | { |
288 | toInput->setText(recipient); | 363 | toInput->setText(recipient); |
289 | } | 364 | } |
290 | 365 | ||
291 | void WriteMail::newMail() | 366 | void WriteMail::newMail() |
292 | { | 367 | { |
293 | toInput->clear(); | 368 | toInput->clear(); |
294 | subjectInput->clear(); | 369 | subjectInput->clear(); |
295 | emailInput->clear(); | 370 | emailInput->clear(); |
296 | //to clear selected | 371 | //to clear selected |
297 | setAddressList(addressList); | 372 | setAddressList(addressList); |
298 | } | 373 | } |
diff --git a/noncore/net/mailit/writemail.h b/noncore/net/mailit/writemail.h index dd12063..f193b13 100644 --- a/noncore/net/mailit/writemail.h +++ b/noncore/net/mailit/writemail.h | |||
@@ -1,91 +1,96 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef WRITEMAIL_H | 20 | #ifndef WRITEMAIL_H |
21 | #define WRITEMAIL_H | 21 | #define WRITEMAIL_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qmultilineedit.h> | 31 | #include <qmultilineedit.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | 34 | ||
35 | #include "emailhandler.h" | 35 | #include "emailhandler.h" |
36 | #include "addresslist.h" | 36 | #include "addresslist.h" |
37 | #include "addatt.h" | 37 | #include "addatt.h" |
38 | 38 | ||
39 | class WriteMail : public QMainWindow | 39 | class WriteMail : public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); | 44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); |
45 | ~WriteMail(); | 45 | ~WriteMail(); |
46 | void reply(Email replyMail); | 46 | void reply(Email replyMail, bool replyAll); |
47 | void setRecipient(const QString &recipient); | 47 | void setRecipient(const QString &recipient); |
48 | void setAddressList(AddressList *list); | 48 | void setAddressList(AddressList *list); |
49 | void forward(Email forwMail); | ||
49 | 50 | ||
50 | signals: | 51 | signals: |
51 | void sendMailRequested(const Email &mail); | 52 | void sendMailRequested(const Email &mail); |
52 | void cancelMail(); | 53 | void cancelMail(); |
54 | |||
53 | 55 | ||
54 | public slots: | 56 | public slots: |
55 | void getAddress(); | 57 | void getAddress(); |
56 | void attatchFile(); | 58 | void attatchFile(); |
57 | void addRecipients(); | 59 | void addRecipients(); |
58 | void newMail(); | 60 | void newMail(); |
59 | void accept(); | 61 | void accept(); |
60 | void reject(); | 62 | void reject(); |
63 | void changeRecipients(int); | ||
61 | 64 | ||
62 | private: | 65 | private: |
63 | bool getRecipients(); | 66 | bool getRecipients(bool); |
64 | void init(); | 67 | void init(); |
68 | void addRecipients(bool); | ||
65 | 69 | ||
66 | Email mail; | 70 | Email mail; |
67 | AddAtt *addAtt; | 71 | AddAtt *addAtt; |
68 | AddressList *addressList; | 72 | AddressList *addressList; |
69 | bool showingAddressList; | 73 | bool showingAddressList; |
70 | 74 | ||
71 | QToolBar *bar; | 75 | QToolBar *bar; |
72 | QMenuBar *menu; | 76 | QMenuBar *menu; |
73 | QPopupMenu *addMenu, *mailMenu; | 77 | QPopupMenu *addMenu, *mailMenu; |
74 | QListView *addressView; | 78 | QListView *addressView; |
75 | 79 | ||
76 | QToolButton *okButton; | 80 | QToolButton *okButton; |
77 | QWidget *widget; | 81 | QWidget *widget; |
78 | QAction *attatchButton; | 82 | QAction *attatchButton; |
79 | QAction *confirmButton; | 83 | QAction *confirmButton; |
80 | QAction *newButton; | 84 | QAction *newButton; |
81 | QLabel* subjetLabel; | 85 | QLabel* subjetLabel; |
82 | QToolButton* ToolButton13_2; | 86 | QToolButton* ToolButton13_2; |
83 | QComboBox* recipientsBox; | 87 | QComboBox* recipientsBox; |
84 | QLineEdit *subjectInput; | 88 | QLineEdit *subjectInput; |
85 | QLineEdit *toInput; | 89 | QLineEdit *toInput; |
90 | QLineEdit *ccInput; | ||
86 | QToolButton* addressButton; | 91 | QToolButton* addressButton; |
87 | QMultiLineEdit* emailInput; | 92 | QMultiLineEdit* emailInput; |
88 | QGridLayout* grid; | 93 | QGridLayout* grid; |
89 | }; | 94 | }; |
90 | 95 | ||
91 | #endif // WRITEMAIL_H | 96 | #endif // WRITEMAIL_H |
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 0d82a9a..ad1e0b4 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -14,343 +14,371 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | 28 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 29 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (MailAccount *) d); | 31 | return dupl( (MailAccount *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 34 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 35 | { |
36 | ac = new MailAccount(*in); | 36 | ac = new MailAccount(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 41 | : QMainWindow( parent, name, fl ) |
42 | { | 42 | { |
43 | emailHandler = new EmailHandler(); | 43 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList(); | 44 | addressList = new AddressList(); |
45 | 45 | ||
46 | sending = FALSE; | 46 | sending = FALSE; |
47 | receiving = FALSE; | 47 | receiving = FALSE; |
48 | previewingMail = FALSE; | 48 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 49 | mailIdCount = 1; |
50 | accountIdCount = 1; | 50 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 51 | allAccounts = FALSE; |
52 | 52 | ||
53 | init(); | 53 | init(); |
54 | 54 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 56 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 57 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 58 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 59 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 60 | SLOT(popError(int)) ); |
61 | 61 | ||
62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 62 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 63 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | |||
65 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | ||
66 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | ||
67 | |||
64 | 68 | ||
65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 69 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
66 | SLOT(mailArrived(const Email &, bool)) ); | 70 | SLOT(mailArrived(const Email &, bool)) ); |
67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 71 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
68 | SLOT(allMailArrived(int)) ); | 72 | SLOT(allMailArrived(int)) ); |
69 | 73 | ||
70 | mailconf = new Config("mailit"); | 74 | mailconf = new Config("mailit"); |
71 | //In case Synchronize is not defined in settings.txt | 75 | //In case Synchronize is not defined in settings.txt |
72 | 76 | ||
73 | readSettings(); | 77 | readSettings(); |
74 | 78 | ||
75 | updateAccounts(); | 79 | updateAccounts(); |
76 | 80 | ||
77 | lineShift = "\n"; | 81 | lineShift = "\n"; |
78 | readMail(); | 82 | readMail(); |
79 | lineShift = "\r\n"; | 83 | lineShift = "\r\n"; |
80 | 84 | ||
81 | } | 85 | } |
82 | 86 | ||
83 | 87 | ||
84 | EmailClient::~EmailClient() | 88 | EmailClient::~EmailClient() |
85 | { | 89 | { |
86 | //needs to be moved from destructor to closewindow event | 90 | //needs to be moved from destructor to closewindow event |
87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 91 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
88 | //does not currently work. Defining outbox in the same | 92 | //does not currently work. Defining outbox in the same |
89 | //format as inbox is not a good solution as they have | 93 | //format as inbox is not a good solution as they have |
90 | //different properties | 94 | //different properties |
91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 95 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
92 | saveSettings(); | 96 | saveSettings(); |
93 | 97 | ||
94 | mailconf->write(); | 98 | mailconf->write(); |
95 | delete mailconf; | 99 | delete mailconf; |
96 | 100 | ||
97 | } | 101 | } |
98 | 102 | ||
99 | void EmailClient::init() | 103 | void EmailClient::init() |
100 | { | 104 | { |
101 | statusBar = new QStatusBar(this); | 105 | statusBar = new QStatusBar(this); |
102 | statusBar->setSizeGripEnabled(FALSE); | 106 | statusBar->setSizeGripEnabled(FALSE); |
103 | 107 | ||
104 | status1Label = new QLabel( tr("Idle"), statusBar); | 108 | status1Label = new QLabel( tr("Idle"), statusBar); |
105 | status2Label = new QLabel("", statusBar); | 109 | status2Label = new QLabel("", statusBar); |
106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 110 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
107 | status2Label, SLOT(setText(const QString &)) ); | 111 | status2Label, SLOT(setText(const QString &)) ); |
108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 112 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
109 | status2Label, SLOT(setText(const QString &)) ); | 113 | status2Label, SLOT(setText(const QString &)) ); |
110 | 114 | ||
111 | progressBar = new QProgressBar(statusBar); | 115 | progressBar = new QProgressBar(statusBar); |
112 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 116 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
113 | this, SLOT(setTotalSize(int)) ); | 117 | this, SLOT(setTotalSize(int)) ); |
114 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 118 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
115 | this, SLOT(setMailSize(int)) ); | 119 | this, SLOT(setMailSize(int)) ); |
116 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 120 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
117 | this, SLOT(setDownloadedSize(int)) ); | 121 | this, SLOT(setDownloadedSize(int)) ); |
118 | 122 | ||
119 | statusBar->addWidget(status1Label); | 123 | statusBar->addWidget(status1Label); |
120 | statusBar->addWidget(progressBar); | 124 | statusBar->addWidget(progressBar); |
121 | statusBar->addWidget(status2Label); | 125 | statusBar->addWidget(status2Label); |
122 | 126 | ||
123 | setToolBarsMovable(FALSE); | 127 | setToolBarsMovable(FALSE); |
124 | 128 | ||
125 | bar = new QToolBar(this); | 129 | bar = new QToolBar(this); |
126 | bar->setHorizontalStretchable( TRUE ); | 130 | bar->setHorizontalStretchable( TRUE ); |
127 | 131 | ||
128 | mb = new QMenuBar( bar ); | 132 | mb = new QMenuBar( bar ); |
129 | 133 | ||
130 | QPopupMenu *mail = new QPopupMenu(mb); | 134 | QPopupMenu *mail = new QPopupMenu(mb); |
131 | mb->insertItem( tr( "&Mail" ), mail); | 135 | mb->insertItem( tr( "&Mail" ), mail); |
132 | 136 | ||
133 | QPopupMenu *configure = new QPopupMenu(mb); | 137 | QPopupMenu *configure = new QPopupMenu(mb); |
134 | mb->insertItem( tr( "Accounts" ), configure); | 138 | mb->insertItem( tr( "Accounts" ), configure); |
135 | 139 | ||
136 | selectAccountMenu = new QPopupMenu(mb); | 140 | selectAccountMenu = new QPopupMenu(mb); |
137 | editAccountMenu = new QPopupMenu(mb); | 141 | editAccountMenu = new QPopupMenu(mb); |
138 | deleteAccountMenu = new QPopupMenu(mb); | 142 | deleteAccountMenu = new QPopupMenu(mb); |
139 | 143 | ||
140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 144 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
141 | configure->insertItem(tr("Edit account"), editAccountMenu); | 145 | configure->insertItem(tr("Edit account"), editAccountMenu); |
142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 146 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
143 | 147 | ||
144 | bar = new QToolBar(this); | 148 | bar = new QToolBar(this); |
145 | 149 | ||
146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | 150 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
151 | //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); | ||
152 | // setAccountButton->addTo(bar); | ||
153 | //setAccountButton->addTo(mail); | ||
154 | |||
155 | /*idCount = 0; | ||
156 | |||
157 | for (MailAccount* accountPtr = accountList.first(); accountPtr != 0; | ||
158 | accountPtr = accountList.next()) { | ||
159 | |||
160 | selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount); | ||
161 | idCount++; | ||
162 | }*/ | ||
163 | getMailButton->setPopup(selectAccountMenu); | ||
164 | |||
165 | |||
166 | /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | ||
147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | 167 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); |
148 | getMailButton->addTo(bar); | 168 | getMailButton->addTo(bar);*/ |
149 | getMailButton->addTo(mail); | 169 | //getMailButton->addTo(mail); |
150 | 170 | ||
151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 171 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 172 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
153 | sendMailButton->addTo(bar); | 173 | sendMailButton->addTo(bar); |
154 | sendMailButton->addTo(mail); | 174 | sendMailButton->addTo(mail); |
155 | 175 | ||
156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 176 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 177 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
158 | composeButton->addTo(bar); | 178 | composeButton->addTo(bar); |
159 | composeButton->addTo(mail); | 179 | composeButton->addTo(mail); |
160 | 180 | ||
161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 181 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 182 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
163 | cancelButton->addTo(mail); | 183 | cancelButton->addTo(mail); |
164 | cancelButton->addTo(bar); | 184 | cancelButton->addTo(bar); |
165 | cancelButton->setEnabled(FALSE); | 185 | cancelButton->setEnabled(FALSE); |
166 | 186 | ||
187 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | ||
188 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | ||
189 | deleteButton->addTo(bar); | ||
190 | |||
167 | mailboxView = new OTabWidget( this, "mailboxView" ); | 191 | mailboxView = new OTabWidget( this, "mailboxView" ); |
168 | 192 | ||
169 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 193 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
170 | grid_2 = new QGridLayout( widget ); | 194 | grid_2 = new QGridLayout( widget ); |
171 | // grid_2->setSpacing(6); | 195 | // grid_2->setSpacing(6); |
172 | // grid_2->setMargin( 11 ); | 196 | // grid_2->setMargin( 11 ); |
173 | 197 | ||
174 | inboxView = new QListView( widget, "inboxView" ); | 198 | inboxView = new QListView( widget, "inboxView" ); |
175 | inboxView->addColumn( tr( "From" ) ); | 199 | inboxView->addColumn( tr( "From" ) ); |
176 | inboxView->addColumn( tr( "Subject" ) ); | 200 | inboxView->addColumn( tr( "Subject" ) ); |
177 | inboxView->addColumn( tr( "Date" ) ); | 201 | inboxView->addColumn( tr( "Date" ) ); |
178 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 202 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
179 | inboxView->setAllColumnsShowFocus(TRUE); | 203 | inboxView->setAllColumnsShowFocus(TRUE); |
180 | 204 | ||
181 | grid_2->addWidget( inboxView, 2, 0 ); | 205 | grid_2->addWidget( inboxView, 2, 0 ); |
182 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 206 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
183 | 207 | ||
184 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 208 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
185 | grid_3 = new QGridLayout( widget_2 ); | 209 | grid_3 = new QGridLayout( widget_2 ); |
186 | // grid_3->setSpacing(6); | 210 | // grid_3->setSpacing(6); |
187 | // grid_3->setMargin( 11 ); | 211 | // grid_3->setMargin( 11 ); |
188 | 212 | ||
189 | outboxView = new QListView( widget_2, "outboxView" ); | 213 | outboxView = new QListView( widget_2, "outboxView" ); |
190 | outboxView->addColumn( tr( "To" ) ); | 214 | outboxView->addColumn( tr( "To" ) ); |
191 | outboxView->addColumn( tr( "Subject" ) ); | 215 | outboxView->addColumn( tr( "Subject" ) ); |
192 | outboxView->setAllColumnsShowFocus(TRUE); | 216 | outboxView->setAllColumnsShowFocus(TRUE); |
193 | 217 | ||
194 | grid_3->addWidget( outboxView, 0, 0 ); | 218 | grid_3->addWidget( outboxView, 0, 0 ); |
195 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 219 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
196 | 220 | ||
197 | setCentralWidget(mailboxView); | 221 | setCentralWidget(mailboxView); |
222 | |||
223 | mailboxView->setCurrentTab(0); | ||
198 | } | 224 | } |
199 | 225 | ||
200 | void EmailClient::compose() | 226 | void EmailClient::compose() |
201 | { | 227 | { |
202 | emit composeRequested(); | 228 | emit composeRequested(); |
203 | } | 229 | } |
204 | 230 | ||
205 | void EmailClient::cancel() | 231 | void EmailClient::cancel() |
206 | { | 232 | { |
207 | emailHandler->cancel(); | 233 | emailHandler->cancel(); |
208 | } | 234 | } |
209 | 235 | ||
210 | AddressList* EmailClient::getAdrListRef() | 236 | AddressList* EmailClient::getAdrListRef() |
211 | { | 237 | { |
212 | return addressList; | 238 | return addressList; |
213 | } | 239 | } |
214 | 240 | ||
215 | //this needs to be rewritten to syncronize with outboxView | 241 | //this needs to be rewritten to syncronize with outboxView |
216 | void EmailClient::enqueMail(const Email &mail) | 242 | void EmailClient::enqueMail(const Email &mail) |
217 | { | 243 | { |
218 | if (accountList.count() == 0) { | 244 | if (accountList.count() == 0) { |
219 | QMessageBox::warning(qApp->activeWindow(), | 245 | QMessageBox::warning(qApp->activeWindow(), |
220 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 246 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
221 | return; | 247 | return; |
222 | } | 248 | } |
223 | 249 | ||
224 | if (accountList.count() > 0) { | 250 | if (accountList.count() > 0) { |
225 | currentAccount = accountList.first(); | 251 | currentAccount = accountList.first(); |
226 | qWarning("using account " + currentAccount->name); | 252 | qWarning("using account " + currentAccount->name); |
227 | } | 253 | } |
228 | 254 | ||
229 | Email addMail = mail; | 255 | Email addMail = mail; |
230 | addMail.from = currentAccount->name; | 256 | addMail.from = currentAccount->name; |
231 | addMail.fromMail = currentAccount->emailAddress; | 257 | addMail.fromMail = currentAccount->emailAddress; |
232 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 258 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
233 | item = new EmailListItem(outboxView, addMail, false); | 259 | item = new EmailListItem(outboxView, addMail, false); |
234 | 260 | ||
261 | mailboxView->setCurrentTab(1); | ||
262 | |||
235 | } | 263 | } |
236 | 264 | ||
237 | void EmailClient::sendQuedMail() | 265 | void EmailClient::sendQuedMail() |
238 | { | 266 | { |
239 | int count = 0; | 267 | int count = 0; |
240 | 268 | ||
241 | if (accountList.count() == 0) { | 269 | if (accountList.count() == 0) { |
242 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 270 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
243 | return; | 271 | return; |
244 | } | 272 | } |
245 | //traverse listview, find messages to send | 273 | //traverse listview, find messages to send |
246 | if (! sending) { | 274 | if (! sending) { |
247 | item = (EmailListItem *) outboxView->firstChild(); | 275 | item = (EmailListItem *) outboxView->firstChild(); |
248 | if (item != NULL) { | 276 | if (item != NULL) { |
249 | while (item != NULL) { | 277 | while (item != NULL) { |
250 | quedMessages.append(item->getMail()); | 278 | quedMessages.append(item->getMail()); |
251 | item = (EmailListItem *) item->nextSibling(); | 279 | item = (EmailListItem *) item->nextSibling(); |
252 | count++; | 280 | count++; |
253 | } | 281 | } |
254 | setMailAccount(); | 282 | setMailAccount(); |
255 | emailHandler->sendMail(&quedMessages); | 283 | emailHandler->sendMail(&quedMessages); |
256 | sending = TRUE; | 284 | sending = TRUE; |
257 | sendMailButton->setEnabled(FALSE); | 285 | sendMailButton->setEnabled(FALSE); |
258 | cancelButton->setEnabled(TRUE); | 286 | cancelButton->setEnabled(TRUE); |
259 | } else { | 287 | } else { |
260 | qWarning("sendQuedMail(): no messages to send"); | 288 | qWarning("sendQuedMail(): no messages to send"); |
261 | } | 289 | } |
262 | } | 290 | } |
263 | } | 291 | } |
264 | 292 | ||
265 | void EmailClient::setMailAccount() | 293 | void EmailClient::setMailAccount() |
266 | { | 294 | { |
267 | emailHandler->setAccount(*currentAccount); | 295 | emailHandler->setAccount(*currentAccount); |
268 | } | 296 | } |
269 | 297 | ||
270 | void EmailClient::mailSent() | 298 | void EmailClient::mailSent() |
271 | { | 299 | { |
272 | sending = FALSE; | 300 | sending = FALSE; |
273 | sendMailButton->setEnabled(TRUE); | 301 | sendMailButton->setEnabled(TRUE); |
274 | 302 | ||
275 | quedMessages.clear(); | 303 | quedMessages.clear(); |
276 | outboxView->clear(); //should be moved to an sentBox | 304 | outboxView->clear(); //should be moved to an sentBox |
277 | } | 305 | } |
278 | 306 | ||
279 | void EmailClient::getNewMail() { | 307 | void EmailClient::getNewMail() { |
280 | 308 | ||
281 | if (accountList.count() == 0) { | 309 | if (accountList.count() == 0) { |
282 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 310 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
283 | "You must create an account", "OK\n"); | 311 | "You must create an account", "OK\n"); |
284 | return; | 312 | return; |
285 | } | 313 | } |
286 | 314 | ||
287 | setMailAccount(); | 315 | setMailAccount(); |
288 | 316 | ||
289 | receiving = TRUE; | 317 | receiving = TRUE; |
290 | previewingMail = TRUE; | 318 | previewingMail = TRUE; |
291 | getMailButton->setEnabled(FALSE); | 319 | getMailButton->setEnabled(FALSE); |
292 | cancelButton->setEnabled(TRUE); | 320 | cancelButton->setEnabled(TRUE); |
293 | selectAccountMenu->setEnabled(FALSE); | 321 | selectAccountMenu->setEnabled(FALSE); |
294 | 322 | ||
295 | status1Label->setText(currentAccount->accountName + " headers"); | 323 | status1Label->setText(currentAccount->accountName + " headers"); |
296 | progressBar->reset(); | 324 | progressBar->reset(); |
297 | 325 | ||
298 | //get any previous mails not downloaded and add to queue | 326 | //get any previous mails not downloaded and add to queue |
299 | mailDownloadList.clear(); | 327 | /* mailDownloadList.clear(); |
300 | Email *mailPtr; | 328 | Email *mailPtr; |
301 | item = (EmailListItem *) inboxView->firstChild(); | 329 | item = (EmailListItem *) inboxView->firstChild(); |
302 | while (item != NULL) { | 330 | while (item != NULL) { |
303 | mailPtr = item->getMail(); | 331 | mailPtr = item->getMail(); |
304 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 332 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
305 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 333 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
306 | } | 334 | } |
307 | item = (EmailListItem *) item->nextSibling(); | 335 | item = (EmailListItem *) item->nextSibling(); |
308 | } | 336 | }*/ |
309 | 337 | ||
310 | emailHandler->getMailHeaders(); | 338 | emailHandler->getMailHeaders(); |
311 | } | 339 | } |
312 | 340 | ||
313 | void EmailClient::getAllNewMail() | 341 | void EmailClient::getAllNewMail() |
314 | { | 342 | { |
315 | allAccounts = TRUE; | 343 | allAccounts = TRUE; |
316 | currentAccount = accountList.first(); | 344 | currentAccount = accountList.first(); |
317 | getNewMail(); | 345 | getNewMail(); |
318 | } | 346 | } |
319 | 347 | ||
320 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 348 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
321 | { | 349 | { |
322 | Enclosure *ePtr; | 350 | Enclosure *ePtr; |
323 | Email newMail; | 351 | Email newMail; |
324 | int thisMailId; | 352 | int thisMailId; |
325 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 353 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
326 | 354 | ||
327 | mailconf->setGroup(newMail.id); | 355 | mailconf->setGroup(newMail.id); |
328 | 356 | ||
329 | if (fromDisk) { | 357 | if (fromDisk) { |
330 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 358 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
331 | newMail.size = mailconf->readNumEntry("size"); | 359 | newMail.size = mailconf->readNumEntry("size"); |
332 | newMail.serverId = mailconf->readNumEntry("serverid"); | 360 | newMail.serverId = mailconf->readNumEntry("serverid"); |
333 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 361 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
334 | } else { //mail arrived from server | 362 | } else { //mail arrived from server |
335 | newMail.serverId = mail.serverId; | 363 | newMail.serverId = mail.serverId; |
336 | newMail.size = mail.size; | 364 | newMail.size = mail.size; |
337 | newMail.downloaded = mail.downloaded; | 365 | newMail.downloaded = mail.downloaded; |
338 | 366 | ||
339 | newMail.fromAccountId = currentAccount->id; | 367 | newMail.fromAccountId = currentAccount->id; |
340 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 368 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
341 | } | 369 | } |
342 | 370 | ||
343 | //add if read or not | 371 | //add if read or not |
344 | newMail.read = mailconf->readBoolEntry("mailread"); | 372 | newMail.read = mailconf->readBoolEntry("mailread"); |
345 | 373 | ||
346 | //check if new mail | 374 | //check if new mail |
347 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 375 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
348 | thisMailId = mailIdCount; | 376 | thisMailId = mailIdCount; |
349 | mailIdCount++; | 377 | mailIdCount++; |
350 | 378 | ||
351 | //set server count, so that if the user aborts, the new | 379 | //set server count, so that if the user aborts, the new |
352 | //header is not reloaded | 380 | //header is not reloaded |
353 | if (currentAccount->synchronize) | 381 | if (currentAccount->synchronize) |
354 | currentAccount->lastServerMailCount++; | 382 | currentAccount->lastServerMailCount++; |
355 | 383 | ||
356 | mailconf->writeEntry("internalmailid", thisMailId); | 384 | mailconf->writeEntry("internalmailid", thisMailId); |
@@ -370,198 +398,206 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
370 | stringId.setNum(ePtr->id); | 398 | stringId.setNum(ePtr->id); |
371 | 399 | ||
372 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 400 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
373 | if (id != ePtr->id) { //new entry | 401 | if (id != ePtr->id) { //new entry |
374 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 402 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
375 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 403 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
376 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 404 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
377 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 405 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
378 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 406 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
379 | mailconf->writeEntry("installed_" + stringId, FALSE); | 407 | mailconf->writeEntry("installed_" + stringId, FALSE); |
380 | 408 | ||
381 | ePtr->name = stringMailId + "_" + stringId; | 409 | ePtr->name = stringMailId + "_" + stringId; |
382 | ePtr->path = getPath(TRUE); | 410 | ePtr->path = getPath(TRUE); |
383 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 411 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
384 | ePtr->saved = TRUE; | 412 | ePtr->saved = TRUE; |
385 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 413 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
386 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 414 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
387 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 415 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
388 | } else { | 416 | } else { |
389 | ePtr->saved = FALSE; | 417 | ePtr->saved = FALSE; |
390 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 418 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
391 | } | 419 | } |
392 | } else { | 420 | } else { |
393 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 421 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
394 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 422 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
395 | if (ePtr->saved) { | 423 | if (ePtr->saved) { |
396 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 424 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
397 | ePtr->path = mailconf->readEntry("path_" + stringId); | 425 | ePtr->path = mailconf->readEntry("path_" + stringId); |
398 | } | 426 | } |
399 | } | 427 | } |
400 | } | 428 | } |
401 | if (!previewingMail && !fromDisk) { | 429 | if (!previewingMail && !fromDisk) { |
402 | Email *mailPtr; | 430 | Email *mailPtr; |
403 | item = (EmailListItem *) inboxView->firstChild(); | 431 | item = (EmailListItem *) inboxView->firstChild(); |
404 | while (item != NULL) { | 432 | while (item != NULL) { |
405 | mailPtr = item->getMail(); | 433 | mailPtr = item->getMail(); |
406 | if (mailPtr->id == newMail.id) { | 434 | if (mailPtr->id == newMail.id) { |
407 | item->setMail(newMail); | 435 | item->setMail(newMail); |
408 | emit mailUpdated(item->getMail()); | 436 | emit mailUpdated(item->getMail()); |
409 | } | 437 | } |
410 | item = (EmailListItem *) item->nextSibling(); | 438 | item = (EmailListItem *) item->nextSibling(); |
411 | } | 439 | } |
412 | } else { | 440 | } else { |
413 | item = new EmailListItem(inboxView, newMail, TRUE); | 441 | item = new EmailListItem(inboxView, newMail, TRUE); |
414 | if (!newMail.downloaded) | 442 | if (!newMail.downloaded) |
415 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); | 443 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); |
416 | } | 444 | } |
417 | 445 | ||
446 | mailboxView->setCurrentTab(0); | ||
447 | |||
418 | } | 448 | } |
419 | 449 | ||
420 | void EmailClient::allMailArrived(int count) | 450 | void EmailClient::allMailArrived(int count) |
421 | { | 451 | { |
422 | // not previewing means all mailtransfer has been done | 452 | // not previewing means all mailtransfer has been done |
423 | if (!previewingMail) { | 453 | if (!previewingMail) { |
424 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 454 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
425 | emit newCaption("Mailit - " + currentAccount->accountName); | 455 | emit newCaption("Mailit - " + currentAccount->accountName); |
426 | getNewMail(); | 456 | getNewMail(); |
427 | return; | 457 | return; |
428 | } else { | 458 | } else { |
429 | allAccounts = FALSE; | 459 | allAccounts = FALSE; |
430 | receiving = FALSE; | 460 | receiving = FALSE; |
431 | getMailButton->setEnabled(TRUE); | 461 | getMailButton->setEnabled(TRUE); |
432 | cancelButton->setEnabled(FALSE); | 462 | cancelButton->setEnabled(FALSE); |
433 | selectAccountMenu->setEnabled(TRUE); | 463 | selectAccountMenu->setEnabled(TRUE); |
434 | status1Label->setText("Idle"); | 464 | status1Label->setText("Idle"); |
435 | 465 | ||
436 | progressBar->reset(); | 466 | progressBar->reset(); |
437 | return; | 467 | return; |
438 | } | 468 | } |
439 | } | 469 | } |
440 | 470 | ||
441 | // all headers downloaded from server, start downloading remaining mails | 471 | // all headers downloaded from server, start downloading remaining mails |
442 | previewingMail = FALSE; | 472 | previewingMail = FALSE; |
443 | status1Label->setText(currentAccount->accountName); | 473 | status1Label->setText(currentAccount->accountName); |
444 | progressBar->reset(); | 474 | progressBar->reset(); |
445 | 475 | ||
446 | emailHandler->getMailByList(&mailDownloadList); | 476 | emailHandler->getMailByList(&mailDownloadList); |
477 | |||
478 | mailboxView->setCurrentTab(0); | ||
447 | } | 479 | } |
448 | 480 | ||
449 | void EmailClient::moveMailFront(Email *mailPtr) | 481 | void EmailClient::moveMailFront(Email *mailPtr) |
450 | { | 482 | { |
451 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 483 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
452 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 484 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
453 | } | 485 | } |
454 | } | 486 | } |
455 | 487 | ||
456 | void EmailClient::smtpError(int code) | 488 | void EmailClient::smtpError(int code) |
457 | { | 489 | { |
458 | QString temp; | 490 | QString temp; |
459 | 491 | ||
460 | if (code == ErrUnknownResponse) | 492 | if (code == ErrUnknownResponse) |
461 | temp = "Unknown response from server"; | 493 | temp = "Unknown response from server"; |
462 | 494 | ||
463 | if (code == QSocket::ErrHostNotFound) | 495 | if (code == QSocket::ErrHostNotFound) |
464 | temp = "host not found"; | 496 | temp = "host not found"; |
465 | if (code == QSocket::ErrConnectionRefused) | 497 | if (code == QSocket::ErrConnectionRefused) |
466 | temp = "connection refused"; | 498 | temp = "connection refused"; |
467 | if (code == QSocket::ErrSocketRead) | 499 | if (code == QSocket::ErrSocketRead) |
468 | temp = "socket packet error"; | 500 | temp = "socket packet error"; |
469 | 501 | ||
470 | if (code != ErrCancel) { | 502 | if (code != ErrCancel) { |
471 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 503 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
472 | } else { | 504 | } else { |
473 | status2Label->setText("Aborted by user"); | 505 | status2Label->setText("Aborted by user"); |
474 | } | 506 | } |
475 | 507 | ||
476 | sending = FALSE; | 508 | sending = FALSE; |
477 | sendMailButton->setEnabled(TRUE); | 509 | sendMailButton->setEnabled(TRUE); |
478 | cancelButton->setEnabled(FALSE); | 510 | cancelButton->setEnabled(FALSE); |
479 | quedMessages.clear(); | 511 | quedMessages.clear(); |
480 | } | 512 | } |
481 | 513 | ||
482 | void EmailClient::popError(int code) | 514 | void EmailClient::popError(int code) |
483 | { | 515 | { |
484 | QString temp; | 516 | QString temp; |
485 | 517 | ||
486 | if (code == ErrUnknownResponse) | 518 | if (code == ErrUnknownResponse) |
487 | temp = "Unknown response from server"; | 519 | temp = "Unknown response from server"; |
488 | if (code == ErrLoginFailed) | 520 | if (code == ErrLoginFailed) |
489 | temp = "Login failed\nCheck user name and password"; | 521 | temp = "Login failed\nCheck user name and password"; |
490 | 522 | ||
491 | if (code == QSocket::ErrHostNotFound) | 523 | if (code == QSocket::ErrHostNotFound) |
492 | temp = "host not found"; | 524 | temp = "host not found"; |
493 | if (code == QSocket::ErrConnectionRefused) | 525 | if (code == QSocket::ErrConnectionRefused) |
494 | temp = "connection refused"; | 526 | temp = "connection refused"; |
495 | if (code == QSocket::ErrSocketRead) | 527 | if (code == QSocket::ErrSocketRead) |
496 | temp = "socket packet error"; | 528 | temp = "socket packet error"; |
497 | 529 | ||
498 | if (code != ErrCancel) { | 530 | if (code != ErrCancel) { |
499 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 531 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
500 | } else { | 532 | } else { |
501 | status2Label->setText("Aborted by user"); | 533 | status2Label->setText("Aborted by user"); |
502 | } | 534 | } |
503 | 535 | ||
504 | receiving = FALSE; | 536 | receiving = FALSE; |
505 | getMailButton->setEnabled(TRUE); | 537 | getMailButton->setEnabled(TRUE); |
506 | cancelButton->setEnabled(FALSE); | 538 | cancelButton->setEnabled(FALSE); |
507 | selectAccountMenu->setEnabled(TRUE); | 539 | selectAccountMenu->setEnabled(TRUE); |
508 | } | 540 | } |
509 | 541 | ||
510 | void EmailClient::inboxItemSelected() | 542 | void EmailClient::inboxItemSelected() |
511 | { | 543 | { |
544 | killTimer(timerID); | ||
545 | |||
512 | item = (EmailListItem*) inboxView->selectedItem(); | 546 | item = (EmailListItem*) inboxView->selectedItem(); |
513 | if (item != NULL) { | 547 | if (item != NULL) { |
514 | emit viewEmail(inboxView, item->getMail()); | 548 | emit viewEmail(inboxView, item->getMail()); |
515 | } | 549 | } |
516 | } | 550 | } |
517 | 551 | ||
518 | void EmailClient::outboxItemSelected() | 552 | void EmailClient::outboxItemSelected() |
519 | { | 553 | { |
554 | killTimer(timerID); | ||
555 | |||
520 | item = (EmailListItem*) outboxView->selectedItem(); | 556 | item = (EmailListItem*) outboxView->selectedItem(); |
521 | if (item != NULL) { | 557 | if (item != NULL) { |
522 | emit viewEmail(outboxView, item->getMail()); | 558 | emit viewEmail(outboxView, item->getMail()); |
523 | } | 559 | } |
524 | 560 | ||
525 | } | 561 | } |
526 | 562 | ||
527 | void EmailClient::readMail() | 563 | void EmailClient::readMail() |
528 | { | 564 | { |
529 | Email mail; | 565 | Email mail; |
530 | int start, stop; | 566 | int start, stop; |
531 | QString s, del; | 567 | QString s, del; |
532 | 568 | ||
533 | QFile f(getPath(FALSE) + "inbox.txt"); | 569 | QFile f(getPath(FALSE) + "inbox.txt"); |
534 | // QFileInfo fi(f); | 570 | // QFileInfo fi(f); |
535 | //qDebug( f.name()); | 571 | //qDebug( f.name()); |
536 | 572 | ||
537 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 573 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
538 | QTextStream t( &f ); // use a text stream | 574 | QTextStream t( &f ); // use a text stream |
539 | s = t.read(); | 575 | s = t.read(); |
540 | f.close(); | 576 | f.close(); |
541 | 577 | ||
542 | start = 0; | 578 | start = 0; |
543 | del = "\n.\n"; | 579 | del = "\n.\n"; |
544 | while ((uint) start < s.length()) { | 580 | while ((uint) start < s.length()) { |
545 | stop = s.find(del, start); | 581 | stop = s.find(del, start); |
546 | if (stop == -1) | 582 | if (stop == -1) |
547 | stop = s.length() - del.length(); | 583 | stop = s.length() - del.length(); |
548 | 584 | ||
549 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 585 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
550 | start = stop + del.length(); | 586 | start = stop + del.length(); |
551 | mailArrived(mail, TRUE); | 587 | mailArrived(mail, TRUE); |
552 | } | 588 | } |
553 | } | 589 | } |
554 | 590 | ||
555 | QFile fo(getPath(FALSE) + "outbox.txt"); | 591 | QFile fo(getPath(FALSE) + "outbox.txt"); |
556 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 592 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
557 | QTextStream t( &fo ); // use a text stream | 593 | QTextStream t( &fo ); // use a text stream |
558 | s = t.read(); | 594 | s = t.read(); |
559 | fo.close(); | 595 | fo.close(); |
560 | 596 | ||
561 | start = 0; | 597 | start = 0; |
562 | del = "\n.\n"; | 598 | del = "\n.\n"; |
563 | while ((uint) start < s.length()) { | 599 | while ((uint) start < s.length()) { |
564 | stop = s.find(del, start); | 600 | stop = s.find(del, start); |
565 | if (stop == -1) | 601 | if (stop == -1) |
566 | stop = s.length() - del.length(); | 602 | stop = s.length() - del.length(); |
567 | 603 | ||
@@ -647,106 +683,107 @@ void EmailClient::readSettings() | |||
647 | account.name = p->getString(& ++pos, 'z', TRUE); | 683 | account.name = p->getString(& ++pos, 'z', TRUE); |
648 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | 684 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) |
649 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | 685 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); |
650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 686 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 687 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 688 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 689 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 690 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
655 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 691 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 692 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 693 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 694 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
659 | s = p->getString(& ++pos, 'z', TRUE); | 695 | s = p->getString(& ++pos, 'z', TRUE); |
660 | account.id = s.toInt(); | 696 | account.id = s.toInt(); |
661 | } | 697 | } |
662 | 698 | ||
663 | account.lastServerMailCount = 0; | 699 | account.lastServerMailCount = 0; |
664 | account.synchronize = FALSE; | 700 | account.synchronize = FALSE; |
665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 701 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 702 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
667 | account.synchronize = TRUE; | 703 | account.synchronize = TRUE; |
668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 704 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
669 | s = p->getString(& ++pos, 'z', TRUE); | 705 | s = p->getString(& ++pos, 'z', TRUE); |
670 | account.lastServerMailCount = s.toInt(); | 706 | account.lastServerMailCount = s.toInt(); |
671 | } | 707 | } |
672 | } | 708 | } |
673 | } | 709 | } |
674 | 710 | ||
675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | 711 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { |
676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | 712 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); |
677 | } | 713 | } |
678 | 714 | ||
679 | 715 | ||
680 | accountList.append(&account); | 716 | accountList.append(&account); |
681 | } | 717 | } |
682 | delete p; | 718 | delete p; |
683 | } | 719 | } |
684 | mailconf->setGroup("mailitglobal"); | 720 | mailconf->setGroup("mailitglobal"); |
685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 721 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
686 | mailIdCount = y; | 722 | mailIdCount = y; |
687 | } | 723 | } |
688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 724 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
689 | accountIdCount = y; | 725 | accountIdCount = y; |
690 | } | 726 | } |
691 | } | 727 | } |
692 | 728 | ||
693 | void EmailClient::saveSettings() | 729 | void EmailClient::saveSettings() |
694 | { | 730 | { |
731 | |||
695 | QString temp; | 732 | QString temp; |
696 | QFile f( getPath(FALSE) + "settings.txt"); | 733 | QFile f( getPath(FALSE) + "settings.txt"); |
697 | MailAccount *accountPtr; | 734 | MailAccount *accountPtr; |
698 | 735 | ||
699 | if (! f.open(IO_WriteOnly) ) { | 736 | if (! f.open(IO_WriteOnly) ) { |
700 | qWarning("could not save settings file"); | 737 | qWarning("could not save settings file"); |
701 | return; | 738 | return; |
702 | } | 739 | } |
703 | QTextStream t(&f); | 740 | QTextStream t(&f); |
704 | t << "#Settings for QPE Mailit program\n"; | 741 | t << "#Settings for OPIE Mailit program\n"; |
705 | 742 | ||
706 | for (accountPtr = accountList.first(); accountPtr != 0; | 743 | for (accountPtr = accountList.first(); accountPtr != 0; |
707 | accountPtr = accountList.next()) { | 744 | accountPtr = accountList.next()) { |
708 | 745 | ||
709 | t << "accountStart;\n"; | 746 | t << "accountStart;\n"; |
710 | t << "AccountName: " + accountPtr->accountName + "\n"; | 747 | t << "AccountName: " + accountPtr->accountName + "\n"; |
711 | t << "Name: " + accountPtr->name + "\n"; | 748 | t << "Name: " + accountPtr->name + "\n"; |
712 | t << "Email: " + accountPtr->emailAddress + "\n"; | 749 | t << "Email: " + accountPtr->emailAddress + "\n"; |
713 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 750 | t << "POPUser: " + accountPtr->popUserName + "\n"; |
714 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 751 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; |
715 | t << "POPServer: " + accountPtr->popServer + "\n"; | 752 | t << "POPServer: " + accountPtr->popServer + "\n"; |
716 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 753 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; |
717 | t << "AccountId: " << accountPtr->id << "\n"; | 754 | t << "AccountId: " << accountPtr->id << "\n"; |
718 | if (accountPtr->synchronize) { | 755 | if (accountPtr->synchronize) { |
719 | t << "Synchronize: Yes\n"; | 756 | t << "Synchronize: Yes\n"; |
720 | t << "LastServerMailCount: "; | 757 | t << "LastServerMailCount: "; |
721 | t << accountPtr->lastServerMailCount << "\n"; | 758 | t << accountPtr->lastServerMailCount << "\n"; |
722 | } else { | 759 | } else { |
723 | t << "Synchronize: No\n"; | 760 | t << "Synchronize: No\n"; |
724 | } | 761 | } |
725 | t << "SyncLimit: "; | 762 | t << "SyncLimit: "; |
726 | t << accountPtr->syncLimit << "\n"; | 763 | t << accountPtr->syncLimit << "\n"; |
727 | t << "accountEnd;\n"; | 764 | t << "accountEnd;\n"; |
728 | } | 765 | } |
729 | f.close(); | 766 | f.close(); |
730 | 767 | ||
731 | mailconf->setGroup("mailitglobal"); | 768 | mailconf->setGroup("mailitglobal"); |
732 | mailconf->writeEntry("mailidcount", mailIdCount); | 769 | mailconf->writeEntry("mailidcount", mailIdCount); |
733 | mailconf->writeEntry("accountidcount", accountIdCount); | 770 | mailconf->writeEntry("accountidcount", accountIdCount); |
734 | } | 771 | } |
735 | 772 | ||
736 | void EmailClient::selectAccount(int id) | 773 | void EmailClient::selectAccount(int id) |
737 | { | 774 | { |
738 | if (accountList.count() > 0) { | 775 | if (accountList.count() > 0) { |
739 | currentAccount = accountList.at(id); | 776 | currentAccount = accountList.at(id); |
740 | emit newCaption("Mailit - " + currentAccount->accountName); | 777 | emit newCaption("Mailit - " + currentAccount->accountName); |
741 | getNewMail(); | 778 | getNewMail(); |
742 | } else { | 779 | } else { |
743 | emit newCaption("Mailit ! No account defined"); | 780 | emit newCaption("Mailit ! No account defined"); |
744 | } | 781 | } |
745 | } | 782 | } |
746 | 783 | ||
747 | void EmailClient::editAccount(int id) | 784 | void EmailClient::editAccount(int id) |
748 | { | 785 | { |
749 | MailAccount *newAccount; | 786 | MailAccount *newAccount; |
750 | 787 | ||
751 | editAccountView = new EditAccount(this, "account", TRUE); | 788 | editAccountView = new EditAccount(this, "account", TRUE); |
752 | if (id == newAccountId) { //new account | 789 | if (id == newAccountId) { //new account |
@@ -766,107 +803,202 @@ void EmailClient::editAccount(int id) | |||
766 | accountIdCount++; | 803 | accountIdCount++; |
767 | accountList.append(newAccount); | 804 | accountList.append(newAccount); |
768 | updateAccounts(); | 805 | updateAccounts(); |
769 | } else { | 806 | } else { |
770 | updateAccounts(); | 807 | updateAccounts(); |
771 | } | 808 | } |
772 | } | 809 | } |
773 | 810 | ||
774 | delete editAccountView; | 811 | delete editAccountView; |
775 | } | 812 | } |
776 | 813 | ||
777 | void EmailClient::deleteAccount(int id) | 814 | void EmailClient::deleteAccount(int id) |
778 | { | 815 | { |
779 | MailAccount *newAccount; | 816 | MailAccount *newAccount; |
780 | QString message; | 817 | QString message; |
781 | 818 | ||
782 | newAccount = accountList.at(id); | 819 | newAccount = accountList.at(id); |
783 | message = "Delete account:\n" + newAccount->accountName; | 820 | message = "Delete account:\n" + newAccount->accountName; |
784 | switch( QMessageBox::warning( this, "Mailit", message, | 821 | switch( QMessageBox::warning( this, "Mailit", message, |
785 | "Yes", "No", 0, 0, 1 ) ) { | 822 | "Yes", "No", 0, 0, 1 ) ) { |
786 | 823 | ||
787 | case 0: accountList.remove(id); | 824 | case 0: accountList.remove(id); |
788 | updateAccounts(); | 825 | updateAccounts(); |
789 | break; | 826 | break; |
790 | case 1: | 827 | case 1: |
791 | break; | 828 | break; |
792 | } | 829 | } |
793 | } | 830 | } |
794 | 831 | ||
795 | void EmailClient::updateAccounts() | 832 | void EmailClient::updateAccounts() |
796 | { | 833 | { |
797 | MailAccount *accountPtr; | 834 | MailAccount *accountPtr; |
798 | 835 | ||
799 | //rebuild menus, clear all first | 836 | //rebuild menus, clear all first |
800 | editAccountMenu->clear(); | 837 | editAccountMenu->clear(); |
801 | selectAccountMenu->clear(); | 838 | selectAccountMenu->clear(); |
802 | deleteAccountMenu->clear(); | 839 | deleteAccountMenu->clear(); |
803 | 840 | ||
804 | newAccountId = editAccountMenu->insertItem("New", this, | 841 | newAccountId = editAccountMenu->insertItem("New", this, |
805 | SLOT(editAccount(int)) ); | 842 | SLOT(editAccount(int)) ); |
806 | editAccountMenu->insertSeparator(); | 843 | editAccountMenu->insertSeparator(); |
807 | 844 | ||
808 | idCount = 0; | 845 | idCount = 0; |
809 | for (accountPtr = accountList.first(); accountPtr != 0; | 846 | for (accountPtr = accountList.first(); accountPtr != 0; |
810 | accountPtr = accountList.next()) { | 847 | accountPtr = accountList.next()) { |
811 | 848 | ||
812 | editAccountMenu->insertItem(accountPtr->accountName, | 849 | editAccountMenu->insertItem(accountPtr->accountName, |
813 | this, SLOT(editAccount(int)), 0, idCount); | 850 | this, SLOT(editAccount(int)), 0, idCount); |
814 | selectAccountMenu->insertItem(accountPtr->accountName, | 851 | selectAccountMenu->insertItem(accountPtr->accountName, |
815 | this, SLOT(selectAccount(int)), 0, idCount); | 852 | this, SLOT(selectAccount(int)), 0, idCount); |
816 | deleteAccountMenu->insertItem(accountPtr->accountName, | 853 | deleteAccountMenu->insertItem(accountPtr->accountName, |
817 | this, SLOT(deleteAccount(int)), 0, idCount); | 854 | this, SLOT(deleteAccount(int)), 0, idCount); |
818 | idCount++; | 855 | idCount++; |
819 | } | 856 | } |
820 | } | 857 | } |
821 | 858 | ||
822 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 859 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
823 | { | 860 | { |
824 | Email *mPtr; | 861 | Email *mPtr; |
825 | Enclosure *ePtr; | 862 | Enclosure *ePtr; |
826 | 863 | ||
827 | if (inbox) { | 864 | if (inbox) |
865 | { | ||
828 | mPtr = mailItem->getMail(); | 866 | mPtr = mailItem->getMail(); |
829 | 867 | ||
830 | //if mail is in queue for download, remove it from | 868 | //if mail is in queue for download, remove it from |
831 | //queue if possible | 869 | //queue if possible |
832 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 870 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
833 | if ( !mPtr->downloaded ) | 871 | if ( !mPtr->downloaded ) |
834 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 872 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
835 | } | 873 | } |
836 | 874 | ||
837 | mailconf->setGroup(mPtr->id); | 875 | mailconf->setGroup(mPtr->id); |
838 | mailconf->clearGroup(); | 876 | mailconf->clearGroup(); |
839 | 877 | ||
840 | //delete any temporary attatchemnts storing | 878 | //delete any temporary attatchemnts storing |
841 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 879 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
842 | if (ePtr->saved) { | 880 | if (ePtr->saved) { |
843 | QFile::remove( (ePtr->path + ePtr->name) ); | 881 | QFile::remove( (ePtr->path + ePtr->name) ); |
844 | } | 882 | } |
845 | } | 883 | } |
846 | inboxView->takeItem(mailItem); | 884 | inboxView->takeItem(mailItem); |
847 | } else { | 885 | } |
886 | else | ||
887 | { | ||
848 | outboxView->takeItem(mailItem); | 888 | outboxView->takeItem(mailItem); |
849 | } | 889 | } |
850 | } | 890 | } |
851 | 891 | ||
852 | void EmailClient::setMailSize(int size) | 892 | void EmailClient::setMailSize(int size) |
853 | { | 893 | { |
854 | progressBar->reset(); | 894 | progressBar->reset(); |
855 | progressBar->setTotalSteps(size); | 895 | progressBar->setTotalSteps(size); |
856 | } | 896 | } |
857 | 897 | ||
858 | void EmailClient::setTotalSize(int size) | 898 | void EmailClient::setTotalSize(int size) |
859 | { | 899 | { |
860 | 900 | ||
861 | } | 901 | } |
862 | 902 | ||
863 | void EmailClient::setDownloadedSize(int size) | 903 | void EmailClient::setDownloadedSize(int size) |
864 | { | 904 | { |
865 | int total = progressBar->totalSteps(); | 905 | int total = progressBar->totalSteps(); |
866 | 906 | ||
867 | if (size < total) { | 907 | if (size < total) { |
868 | progressBar->setProgress(size); | 908 | progressBar->setProgress(size); |
869 | } else { | 909 | } else { |
870 | progressBar->setProgress(total); | 910 | progressBar->setProgress(total); |
871 | } | 911 | } |
872 | } | 912 | } |
913 | |||
914 | void EmailClient::deleteItem() | ||
915 | { | ||
916 | bool inbox=mailboxView->currentTab()==0; | ||
917 | |||
918 | EmailListItem* eli; | ||
919 | |||
920 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); | ||
921 | |||
922 | if (eli) | ||
923 | deleteMail(eli,(bool&)inbox); | ||
924 | } | ||
925 | |||
926 | void EmailClient::inboxItemPressed() | ||
927 | { | ||
928 | //timerID=startTimer(500); | ||
929 | } | ||
930 | |||
931 | void EmailClient::inboxItemReleased() | ||
932 | { | ||
933 | //killTimer(timerID); | ||
934 | } | ||
935 | |||
936 | void EmailClient::timerEvent(QTimerEvent *e) | ||
937 | { | ||
938 | /*killTimer(timerID); | ||
939 | |||
940 | |||
941 | QPopupMenu *action = new QPopupMenu(this); | ||
942 | |||
943 | int reply=0; | ||
944 | |||
945 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | ||
946 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | ||
947 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | ||
948 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | ||
949 | |||
950 | action->exec(QCursor::pos()); | ||
951 | |||
952 | if (action) delete action; | ||
953 | */ | ||
954 | } | ||
955 | |||
956 | Email* EmailClient::getCurrentMail() | ||
957 | { | ||
958 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | ||
959 | if (eli!=NULL) | ||
960 | return eli->getMail(); | ||
961 | else | ||
962 | return NULL; | ||
963 | } | ||
964 | |||
965 | /* | ||
966 | void EmailClient::reply() | ||
967 | { | ||
968 | Email* mail=getCurrentMail(); | ||
969 | |||
970 | if (mail!=NULL) | ||
971 | { | ||
972 | emit reply(*mail); | ||
973 | } | ||
974 | } | ||
975 | |||
976 | void EmailClient::replyAll() | ||
977 | { | ||
978 | Email* mail=getCurrentMail(); | ||
979 | |||
980 | if (mail!=NULL) | ||
981 | { | ||
982 | emit replyAll(*mail); | ||
983 | } | ||
984 | } | ||
985 | |||
986 | void EmailClient::forward() | ||
987 | { | ||
988 | Email* mail=getCurrentMail(); | ||
989 | |||
990 | if (mail!=NULL) | ||
991 | { | ||
992 | emit reply(*mail); | ||
993 | } | ||
994 | } | ||
995 | |||
996 | void EmailClient::remove() | ||
997 | { | ||
998 | Email* mail=getCurrentMail(); | ||
999 | |||
1000 | if (mail!=NULL) | ||
1001 | { | ||
1002 | emit remove(*mail); | ||
1003 | } | ||
1004 | }*/ \ No newline at end of file | ||
diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h index 80457f9..0890dcf 100644 --- a/noncore/unsupported/mailit/emailclient.h +++ b/noncore/unsupported/mailit/emailclient.h | |||
@@ -1,149 +1,171 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef EMAILCLIENT_H | 20 | #ifndef EMAILCLIENT_H |
21 | #define EMAILCLIENT_H | 21 | #define EMAILCLIENT_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qaction.h> | 32 | #include <qaction.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qtooltip.h> | 34 | #include <qtooltip.h> |
35 | #include <qtoolbutton.h> | ||
35 | #include <qimage.h> | 36 | #include <qimage.h> |
36 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
37 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
38 | #include <qprogressbar.h> | 39 | #include <qprogressbar.h> |
39 | #include <qstatusbar.h> | 40 | #include <qstatusbar.h> |
40 | #include <qdir.h> | 41 | #include <qdir.h> |
41 | #include <stdlib.h> | 42 | #include <stdlib.h> |
42 | #include <opie/otabwidget.h> | 43 | #include <opie/otabwidget.h> |
44 | #include <qtimer.h> | ||
43 | 45 | ||
44 | #include "emailhandler.h" | 46 | #include "emailhandler.h" |
45 | #include "emaillistitem.h" | 47 | #include "emaillistitem.h" |
46 | #include "textparser.h" | 48 | #include "textparser.h" |
47 | #include "editaccount.h" | 49 | #include "editaccount.h" |
48 | #include "maillist.h" | 50 | #include "maillist.h" |
49 | #include "addresslist.h" | 51 | #include "addresslist.h" |
50 | 52 | ||
51 | #include <qpe/config.h> | 53 | #include <qpe/config.h> |
52 | 54 | ||
53 | class AccountList : public QList<MailAccount> | 55 | class AccountList : public QList<MailAccount> |
54 | { | 56 | { |
55 | public: | 57 | public: |
56 | Item newItem(Item d); | 58 | Item newItem(Item d); |
57 | private: | 59 | private: |
58 | MailAccount* dupl(MailAccount *in); | 60 | MailAccount* dupl(MailAccount *in); |
59 | MailAccount *ac; | 61 | MailAccount *ac; |
60 | }; | 62 | }; |
61 | 63 | ||
62 | //class EmailClient : public EmailClientBase | 64 | //class EmailClient : public EmailClientBase |
63 | class EmailClient : public QMainWindow | 65 | class EmailClient : public QMainWindow |
64 | { | 66 | { |
65 | Q_OBJECT | 67 | Q_OBJECT |
66 | 68 | ||
67 | public: | 69 | public: |
68 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); | 70 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); |
69 | ~EmailClient(); | 71 | ~EmailClient(); |
70 | AddressList* getAdrListRef(); | 72 | AddressList* getAdrListRef(); |
71 | 73 | ||
74 | protected: | ||
75 | void timerEvent(QTimerEvent*); | ||
76 | |||
72 | signals: | 77 | signals: |
73 | void composeRequested(); | 78 | void composeRequested(); |
74 | void viewEmail(QListView *, Email *); | 79 | void viewEmail(QListView *, Email *); |
75 | void mailUpdated(Email *); | 80 | void mailUpdated(Email *); |
76 | void newCaption(const QString &); | 81 | void newCaption(const QString &); |
77 | 82 | void replyRequested(Email&, bool&); | |
83 | void forwardRequested(Email&); | ||
84 | void removeItem(EmailListItem*, bool&); | ||
85 | /*void reply(Email&); | ||
86 | void replyAll(Email&); | ||
87 | void remove(Email&); | ||
88 | void forward(Email&);*/ | ||
89 | |||
78 | public slots: | 90 | public slots: |
79 | void compose(); | 91 | void compose(); |
80 | void cancel(); | 92 | void cancel(); |
81 | void enqueMail(const Email &mail); | 93 | void enqueMail(const Email &mail); |
82 | void setMailAccount(); | 94 | void setMailAccount(); |
83 | void sendQuedMail(); | 95 | void sendQuedMail(); |
84 | void mailSent(); | 96 | void mailSent(); |
97 | void deleteItem(); | ||
85 | void getNewMail(); | 98 | void getNewMail(); |
86 | void getAllNewMail(); | 99 | void getAllNewMail(); |
87 | void smtpError(int code); | 100 | void smtpError(int code); |
88 | void popError(int code); | 101 | void popError(int code); |
89 | void inboxItemSelected(); | 102 | void inboxItemSelected(); |
90 | void outboxItemSelected(); | 103 | void outboxItemSelected(); |
104 | void inboxItemPressed(); | ||
105 | void inboxItemReleased(); | ||
91 | void mailArrived(const Email &mail, bool fromDisk); | 106 | void mailArrived(const Email &mail, bool fromDisk); |
92 | void allMailArrived(int); | 107 | void allMailArrived(int); |
93 | void saveMail(QString fileName, QListView *view); | 108 | void saveMail(QString fileName, QListView *view); |
94 | void selectAccount(int); | 109 | void selectAccount(int); |
95 | void editAccount(int); | 110 | void editAccount(int); |
96 | void updateAccounts(); | 111 | void updateAccounts(); |
97 | void deleteAccount(int); | 112 | void deleteAccount(int); |
98 | void deleteMail(EmailListItem *mailItem, bool &inbox); | 113 | void deleteMail(EmailListItem *mailItem, bool &inbox); |
99 | void setTotalSize(int); | 114 | void setTotalSize(int); |
100 | void setMailSize(int); | 115 | void setMailSize(int); |
101 | void setDownloadedSize(int); | 116 | void setDownloadedSize(int); |
102 | void moveMailFront(Email *mailPtr); | 117 | void moveMailFront(Email *mailPtr); |
118 | /* void reply(); | ||
119 | void replyAll(); | ||
120 | void forward(); | ||
121 | void remove();*/ | ||
103 | 122 | ||
104 | private: | 123 | private: |
105 | void init(); | 124 | void init(); |
106 | void readMail(); | 125 | void readMail(); |
107 | QString getPath(bool enclosurePath); | 126 | QString getPath(bool enclosurePath); |
108 | void readSettings(); | 127 | void readSettings(); |
109 | void saveSettings(); | 128 | void saveSettings(); |
110 | 129 | Email* getCurrentMail(); | |
111 | private: | 130 | int timerID; |
112 | Config *mailconf; | 131 | Config *mailconf; |
113 | int newAccountId, idCount, mailIdCount; | 132 | int newAccountId, idCount, mailIdCount; |
114 | int accountIdCount; | 133 | int accountIdCount; |
115 | AccountList accountList; | 134 | AccountList accountList; |
116 | AddressList *addressList; | 135 | AddressList *addressList; |
117 | 136 | ||
118 | EditAccount *editAccountView; | 137 | EditAccount *editAccountView; |
119 | EmailListItem *item; | 138 | EmailListItem *item; |
120 | EmailHandler *emailHandler; | 139 | EmailHandler *emailHandler; |
121 | QList<Email> quedMessages; | 140 | QList<Email> quedMessages; |
122 | MailList mailDownloadList; | 141 | MailList mailDownloadList; |
123 | bool sending, receiving, previewingMail, allAccounts; | 142 | bool sending, receiving, previewingMail, allAccounts; |
124 | QString lineShift; | 143 | QString lineShift; |
125 | MailAccount account, *currentAccount; | 144 | MailAccount account, *currentAccount; |
126 | 145 | ||
127 | QToolBar *bar; | 146 | QToolBar *bar; |
128 | QProgressBar *progressBar; | 147 | QProgressBar *progressBar; |
129 | QStatusBar *statusBar; | 148 | QStatusBar *statusBar; |
130 | QLabel *status1Label, *status2Label; | 149 | QLabel *status1Label, *status2Label; |
131 | QAction *getMailButton; | 150 | QToolButton *getMailButton; |
132 | QAction *sendMailButton; | 151 | QAction *sendMailButton; |
133 | QAction *composeButton; | 152 | QAction *composeButton; |
134 | QAction *cancelButton; | 153 | QAction *cancelButton; |
135 | 154 | QAction *deleteButton; | |
155 | //QToolButton *setAccountButton; | ||
156 | |||
136 | QMenuBar *mb; | 157 | QMenuBar *mb; |
137 | QPopupMenu *selectAccountMenu; | 158 | QPopupMenu *selectAccountMenu; |
138 | QPopupMenu *editAccountMenu; | 159 | QPopupMenu *editAccountMenu; |
139 | QPopupMenu *deleteAccountMenu; | 160 | QPopupMenu *deleteAccountMenu; |
161 | QPopupMenu *setAccountMenu; | ||
140 | 162 | ||
141 | OTabWidget* mailboxView; | 163 | OTabWidget* mailboxView; |
142 | QListView* inboxView; | 164 | QListView* inboxView; |
143 | QListView* outboxView; | 165 | QListView* outboxView; |
144 | 166 | ||
145 | QGridLayout* grid_2; | 167 | QGridLayout* grid_2; |
146 | QGridLayout* grid_3; | 168 | QGridLayout* grid_3; |
147 | }; | 169 | }; |
148 | 170 | ||
149 | #endif // EMAILCLIENT_H | 171 | #endif // EMAILCLIENT_H |
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 03f8a28..f6c6d60 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -155,103 +155,109 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
155 | QString content, contentType, contentAttribute, id, encoding; | 155 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 156 | QString fileName, storedName; |
157 | int enclosureId = 0; | 157 | int enclosureId = 0; |
158 | 158 | ||
159 | mail->rawMail = in; | 159 | mail->rawMail = in; |
160 | mail->received = TRUE; | 160 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 161 | mail->files.setAutoDelete(TRUE); |
162 | 162 | ||
163 | temp = lineShift + "." + lineShift; | 163 | temp = lineShift + "." + lineShift; |
164 | 164 | ||
165 | if (in.right(temp.length()) != temp) { | 165 | if (in.right(temp.length()) != temp) { |
166 | mail->rawMail += temp; | 166 | mail->rawMail += temp; |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
171 | pos = in.find(delimiter, 0, FALSE); | 171 | pos = in.find(delimiter, 0, FALSE); |
172 | header = in.left(pos); | 172 | header = in.left(pos); |
173 | body = in.right(in.length() - pos - delimiter.length()); | 173 | body = in.right(in.length() - pos - delimiter.length()); |
174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
175 | body.truncate(body.length()-2); | 175 | body.truncate(body.length()-2); |
176 | 176 | ||
177 | TextParser p(header, lineShift); | 177 | TextParser p(header, lineShift); |
178 | 178 | ||
179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
180 | pos++; | 180 | pos++; |
181 | if (p.separatorAt(pos) == ' ') { | 181 | if (p.separatorAt(pos) == ' ') { |
182 | mail->from = p.getString(&pos, '<', false); | 182 | mail->from = p.getString(&pos, '<', false); |
183 | mail->from = mail->from.stripWhiteSpace(); | 183 | mail->from = mail->from.stripWhiteSpace(); |
184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
185 | mail->from = mail->from.left(mail->from.length() - 1); | 185 | mail->from = mail->from.left(mail->from.length() - 1); |
186 | mail->from = mail->from.right(mail->from.length() - 1); | 186 | mail->from = mail->from.right(mail->from.length() - 1); |
187 | } | 187 | } |
188 | pos++; | 188 | pos++; |
189 | mail->fromMail = p.getString(&pos, '>', false); | 189 | mail->fromMail = p.getString(&pos, '>', false); |
190 | } else { | 190 | } else { |
191 | if ((p.separatorAt(pos) == '<') | 191 | if ((p.separatorAt(pos) == '<') |
192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
193 | pos++; | 193 | pos++; |
194 | pos++; | 194 | pos++; |
195 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 195 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
197 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 197 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
198 | mail->from=mail->fromMail; | 198 | mail->from=mail->fromMail; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: |
203 | if (pos = p.find("TO",':', pos, TRUE) != -1) | 203 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) |
204 | { | 204 | { |
205 | pos++; | 205 | pos++; |
206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | |
210 | if ((pos = p.find("CC",':', 0, TRUE)) != -1) | ||
211 | { | ||
212 | pos++; | ||
213 | mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); | ||
214 | } | ||
215 | |||
210 | 216 | ||
211 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 217 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
212 | pos++; | 218 | pos++; |
213 | mail->subject = p.getString(&pos, 'z', TRUE); | 219 | mail->subject = p.getString(&pos, 'z', TRUE); |
214 | } | 220 | } |
215 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 221 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
216 | pos++; | 222 | pos++; |
217 | mail->date = p.getString(&pos, 'z', true); | 223 | mail->date = p.getString(&pos, 'z', true); |
218 | } | 224 | } |
219 | 225 | ||
220 | 226 | ||
221 | 227 | ||
222 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 228 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
223 | pos++; | 229 | pos++; |
224 | if ( (p.wordAt(pos).upper() == "ID") && | 230 | if ( (p.wordAt(pos).upper() == "ID") && |
225 | (p.separatorAt(pos) == ':') ) { | 231 | (p.separatorAt(pos) == ':') ) { |
226 | 232 | ||
227 | id = p.getString(&pos, 'z', TRUE); | 233 | id = p.getString(&pos, 'z', TRUE); |
228 | mail->id = id; | 234 | mail->id = id; |
229 | } | 235 | } |
230 | } | 236 | } |
231 | 237 | ||
232 | pos = 0; | 238 | pos = 0; |
233 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 239 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
234 | pos++; | 240 | pos++; |
235 | if ( (p.wordAt(pos).upper() == "VERSION") && | 241 | if ( (p.wordAt(pos).upper() == "VERSION") && |
236 | (p.separatorAt(pos) == ':') ) { | 242 | (p.separatorAt(pos) == ':') ) { |
237 | pos++; | 243 | pos++; |
238 | if (p.getString(&pos, 'z', true) == "1.0") { | 244 | if (p.getString(&pos, 'z', true) == "1.0") { |
239 | mail->mimeType = 1; | 245 | mail->mimeType = 1; |
240 | } | 246 | } |
241 | } | 247 | } |
242 | } | 248 | } |
243 | 249 | ||
244 | if (mail->mimeType == 1) { | 250 | if (mail->mimeType == 1) { |
245 | boundary = ""; | 251 | boundary = ""; |
246 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 252 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
247 | pos++; | 253 | pos++; |
248 | boundary = p.getString(&pos, 'z', true); | 254 | boundary = p.getString(&pos, 'z', true); |
249 | if (boundary[0] == '"') { | 255 | if (boundary[0] == '"') { |
250 | boundary = boundary.left(boundary.length() - 1); //strip " | 256 | boundary = boundary.left(boundary.length() - 1); //strip " |
251 | boundary = boundary.right(boundary.length() - 1); //strip " | 257 | boundary = boundary.right(boundary.length() - 1); //strip " |
252 | } | 258 | } |
253 | boundary = "--" + boundary; //create boundary field | 259 | boundary = "--" + boundary; //create boundary field |
254 | } | 260 | } |
255 | 261 | ||
256 | if (boundary == "") { //fooled by Mime-Version | 262 | if (boundary == "") { //fooled by Mime-Version |
257 | mail->body = body; | 263 | mail->body = body; |
@@ -389,96 +395,103 @@ int EmailHandler::parse64base(char *src, char *bufOut) { | |||
389 | li[x] = (int) c - (int) 'a' + 26; | 395 | li[x] = (int) c - (int) 'a' + 26; |
390 | if ( (int) c >= '0' && (int) c <= '9') | 396 | if ( (int) c >= '0' && (int) c <= '9') |
391 | li[x] = (int) c - (int) '0' + 52; | 397 | li[x] = (int) c - (int) '0' + 52; |
392 | if (c == '+') | 398 | if (c == '+') |
393 | li[x] = 62; | 399 | li[x] = 62; |
394 | if (c == '/') | 400 | if (c == '/') |
395 | li[x] = 63; | 401 | li[x] = 63; |
396 | } | 402 | } |
397 | 403 | ||
398 | processed = 1; | 404 | processed = 1; |
399 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 405 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
400 | bufOut[0] <<= 2; | 406 | bufOut[0] <<= 2; |
401 | z = li[1] >> 4; | 407 | z = li[1] >> 4; |
402 | bufOut[0] = bufOut[0] | z; //first byte retrived | 408 | bufOut[0] = bufOut[0] | z; //first byte retrived |
403 | 409 | ||
404 | if (src[2] != '=') { | 410 | if (src[2] != '=') { |
405 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 411 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
406 | bufOut[1] <<= 4; | 412 | bufOut[1] <<= 4; |
407 | z = li[2] >> 2; | 413 | z = li[2] >> 2; |
408 | bufOut[1] = bufOut[1] | z; //second byte retrived | 414 | bufOut[1] = bufOut[1] | z; //second byte retrived |
409 | processed++; | 415 | processed++; |
410 | 416 | ||
411 | if (src[3] != '=') { | 417 | if (src[3] != '=') { |
412 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 418 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
413 | bufOut[2] <<= 6; | 419 | bufOut[2] <<= 6; |
414 | z = li[3]; | 420 | z = li[3]; |
415 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 421 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
416 | processed++; | 422 | processed++; |
417 | } | 423 | } |
418 | } | 424 | } |
419 | return processed; | 425 | return processed; |
420 | } | 426 | } |
421 | 427 | ||
422 | int EmailHandler::encodeMime(Email *mail) | 428 | int EmailHandler::encodeMime(Email *mail) |
423 | { | 429 | { |
424 | 430 | ||
425 | QString fileName, fileType, contentType, newBody, boundary; | 431 | QString fileName, fileType, contentType, newBody, boundary; |
426 | Enclosure *ePtr; | 432 | Enclosure *ePtr; |
427 | 433 | ||
428 | QString userName = mailAccount.name; | 434 | QString userName = mailAccount.name; |
429 | if (userName.length()>0)//only embrace it if there is a user name | 435 | if (userName.length()>0)//only embrace it if there is a user name |
430 | userName += " <" + mailAccount.emailAddress + ">"; | 436 | userName += " <" + mailAccount.emailAddress + ">"; |
431 | 437 | ||
432 | //add standard headers | 438 | //add standard headers |
433 | newBody = "From: " + userName + "\r\nTo: "; | 439 | newBody = "From: " + userName + "\r\nTo: "; |
434 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 440 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
435 | newBody += *it + " "; | 441 | newBody += *it + " "; |
436 | } | 442 | } |
443 | |||
444 | newBody += "\r\nCC: "; | ||
445 | |||
446 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { | ||
447 | newBody += *it + " "; | ||
448 | } | ||
449 | |||
437 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 450 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
438 | 451 | ||
439 | if (mail->files.count() == 0) { //just a simple mail | 452 | if (mail->files.count() == 0) { //just a simple mail |
440 | newBody += "\r\n" + mail->body; | 453 | newBody += "\r\n" + mail->body; |
441 | mail->rawMail = newBody; | 454 | mail->rawMail = newBody; |
442 | return 0; | 455 | return 0; |
443 | } | 456 | } |
444 | 457 | ||
445 | //Build mime encoded mail | 458 | //Build mime encoded mail |
446 | boundary = "-----4345=next_bound=0495----"; | 459 | boundary = "-----4345=next_bound=0495----"; |
447 | 460 | ||
448 | newBody += "Mime-Version: 1.0\r\n"; | 461 | newBody += "Mime-Version: 1.0\r\n"; |
449 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 462 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
450 | boundary + "\"\r\n\r\n"; | 463 | boundary + "\"\r\n\r\n"; |
451 | 464 | ||
452 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 465 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
453 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 466 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
454 | newBody += mail->body; | 467 | newBody += mail->body; |
455 | 468 | ||
456 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 469 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
457 | fileName = ePtr->originalName; | 470 | fileName = ePtr->originalName; |
458 | fileType = ePtr->contentType; | 471 | fileType = ePtr->contentType; |
459 | QFileInfo fi(fileName); | 472 | QFileInfo fi(fileName); |
460 | 473 | ||
461 | // This specification of contentType is temporary | 474 | // This specification of contentType is temporary |
462 | contentType = ""; | 475 | contentType = ""; |
463 | if (fileType == "Picture") { | 476 | if (fileType == "Picture") { |
464 | contentType = "image/x-image"; | 477 | contentType = "image/x-image"; |
465 | } else if (fileType == "Document") { | 478 | } else if (fileType == "Document") { |
466 | contentType = "text/plain"; | 479 | contentType = "text/plain"; |
467 | } else if (fileType == "Sound") { | 480 | } else if (fileType == "Sound") { |
468 | contentType = "audio/x-wav"; | 481 | contentType = "audio/x-wav"; |
469 | } else if (fileType == "Movie") { | 482 | } else if (fileType == "Movie") { |
470 | contentType = "video/mpeg"; | 483 | contentType = "video/mpeg"; |
471 | } else { | 484 | } else { |
472 | contentType = "application/octet-stream"; | 485 | contentType = "application/octet-stream"; |
473 | } | 486 | } |
474 | 487 | ||
475 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 488 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
476 | newBody += "Content-Type: " + contentType + "; name=\"" + | 489 | newBody += "Content-Type: " + contentType + "; name=\"" + |
477 | fi.fileName() + "\"\r\n"; | 490 | fi.fileName() + "\"\r\n"; |
478 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 491 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
479 | newBody += "Content-Disposition: inline; filename=\"" + | 492 | newBody += "Content-Disposition: inline; filename=\"" + |
480 | fi.fileName() + "\"\r\n\r\n"; | 493 | fi.fileName() + "\"\r\n\r\n"; |
481 | 494 | ||
482 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 495 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
483 | return -1; | 496 | return -1; |
484 | } | 497 | } |
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index 2bf1dcb..ef5fc09 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp | |||
@@ -2,132 +2,164 @@ | |||
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 "mailitwindow.h" | 20 | #include "mailitwindow.h" |
21 | 21 | ||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
23 | : QMainWindow(parent, name, fl) | 23 | : QMainWindow(parent, name, fl) |
24 | { | 24 | { |
25 | currentCaption = "Mailit"; | 25 | currentCaption = "Mailit"; |
26 | setCaption(tr(currentCaption)); | 26 | setCaption(tr(currentCaption)); |
27 | views = new QWidgetStack(this); | 27 | views = new QWidgetStack(this); |
28 | setCentralWidget(views); | 28 | setCentralWidget(views); |
29 | 29 | ||
30 | emailClient = new EmailClient(views, "client"); | 30 | emailClient = new EmailClient(views, "client"); |
31 | writeMail = new WriteMail(views, "writing"); | 31 | writeMail = new WriteMail(views, "writing"); |
32 | readMail = new ReadMail(views, "reading"); | 32 | readMail = new ReadMail(views, "reading"); |
33 | 33 | ||
34 | views->raiseWidget(emailClient); | 34 | views->raiseWidget(emailClient); |
35 | 35 | ||
36 | connect(emailClient, SIGNAL(composeRequested()), | 36 | connect(emailClient, SIGNAL(composeRequested()), |
37 | this, SLOT(compose()) ); | 37 | this, SLOT(compose()) ); |
38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
39 | SLOT(viewMail(QListView *, Email *)) ); | 39 | SLOT(viewMail(QListView *, Email *)) ); |
40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
41 | SLOT(updateMailView(Email *)) ); | 41 | SLOT(updateMailView(Email *)) ); |
42 | 42 | ||
43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
45 | SLOT(showEmailClient()) ); | 45 | SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
47 | SLOT(enqueMail(const Email &)) ); | 47 | SLOT(enqueMail(const Email &)) ); |
48 | 48 | ||
49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
50 | connect(readMail, SIGNAL(replyRequested(Email &)), this, | 50 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, |
51 | SLOT(composeReply(Email &)) ); | 51 | SLOT(composeReply(Email &, bool&)) ); |
52 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, | ||
53 | SLOT(composeForward(Email &)) ); | ||
54 | |||
52 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 55 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
53 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 56 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
54 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 57 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
55 | SLOT(moveMailFront(Email *)) ); | 58 | SLOT(moveMailFront(Email *)) ); |
56 | 59 | ||
57 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 60 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
58 | this, SLOT(updateCaption(const QString &)) ); | 61 | this, SLOT(updateCaption(const QString &)) ); |
59 | viewingMail = FALSE; | 62 | viewingMail = FALSE; |
60 | 63 | ||
61 | } | 64 | } |
62 | 65 | ||
63 | MailItWindow::~MailItWindow() | 66 | MailItWindow::~MailItWindow() |
64 | { | 67 | { |
65 | } | 68 | } |
66 | 69 | ||
67 | void MailItWindow::closeEvent(QCloseEvent *e) | 70 | void MailItWindow::closeEvent(QCloseEvent *e) |
68 | { | 71 | { |
69 | if (views->visibleWidget() == emailClient) { | 72 | if (views->visibleWidget() == emailClient) { |
70 | e->accept(); | 73 | e->accept(); |
71 | } else { | 74 | } else { |
72 | showEmailClient(); | 75 | showEmailClient(); |
73 | } | 76 | } |
74 | } | 77 | } |
75 | 78 | ||
76 | void MailItWindow::compose() | 79 | void MailItWindow::compose() |
77 | { | 80 | { |
78 | viewingMail = FALSE; | 81 | viewingMail = FALSE; |
79 | emailClient->hide(); | 82 | emailClient->hide(); |
80 | readMail->hide(); | 83 | readMail->hide(); |
81 | views->raiseWidget(writeMail); | 84 | views->raiseWidget(writeMail); |
82 | writeMail->setAddressList(emailClient->getAdrListRef()); | 85 | writeMail->setAddressList(emailClient->getAdrListRef()); |
83 | setCaption( tr( "Write mail" ) ); | 86 | setCaption( tr( "Write mail" ) ); |
84 | } | 87 | } |
85 | 88 | ||
86 | void MailItWindow::composeReply(Email &mail) | 89 | void MailItWindow::composeReply(Email &mail, bool& replyAll) |
90 | { | ||
91 | compose(); | ||
92 | writeMail->reply(mail,replyAll) ; | ||
93 | } | ||
94 | |||
95 | void MailItWindow::composeForward(Email &mail) | ||
87 | { | 96 | { |
88 | compose(); | 97 | compose(); |
89 | writeMail->reply(mail); | 98 | writeMail->forward(mail) ; |
90 | } | 99 | } |
91 | 100 | ||
101 | |||
92 | void MailItWindow::showEmailClient() | 102 | void MailItWindow::showEmailClient() |
93 | { | 103 | { |
94 | viewingMail = FALSE; | 104 | viewingMail = FALSE; |
95 | writeMail->hide(); | 105 | writeMail->hide(); |
96 | readMail->hide(); | 106 | readMail->hide(); |
97 | views->raiseWidget(emailClient); | 107 | views->raiseWidget(emailClient); |
98 | setCaption( tr(currentCaption) ); | 108 | setCaption( tr(currentCaption) ); |
99 | } | 109 | } |
100 | 110 | ||
101 | void MailItWindow::viewMail(QListView *view, Email *mail) | 111 | void MailItWindow::viewMail(QListView *view, Email *mail) |
102 | { | 112 | { |
103 | viewingMail = TRUE; | 113 | viewingMail = TRUE; |
104 | emailClient->hide(); | 114 | emailClient->hide(); |
105 | readMail->update(view, mail); | 115 | readMail->update(view, mail); |
106 | views->raiseWidget(readMail); | 116 | views->raiseWidget(readMail); |
107 | setCaption( tr( "Examine mail" ) ); | 117 | setCaption( tr( "Examine mail" ) ); |
108 | } | 118 | } |
109 | 119 | ||
110 | void MailItWindow::updateMailView(Email *mail) | 120 | void MailItWindow::updateMailView(Email *mail) |
111 | { | 121 | { |
112 | if (viewingMail) { | 122 | if (viewingMail) { |
113 | readMail->mailUpdated(mail); | 123 | readMail->mailUpdated(mail); |
114 | } | 124 | } |
115 | } | 125 | } |
116 | 126 | ||
117 | void MailItWindow::updateCaption(const QString &newCaption) | 127 | void MailItWindow::updateCaption(const QString &newCaption) |
118 | { | 128 | { |
119 | currentCaption = newCaption; | 129 | currentCaption = newCaption; |
120 | setCaption(tr(currentCaption)); | 130 | setCaption(tr(currentCaption)); |
121 | } | 131 | } |
122 | 132 | ||
123 | void MailItWindow::setDocument(const QString &_address) | 133 | void MailItWindow::setDocument(const QString &_address) |
124 | { | 134 | { |
125 | // strip leading 'mailto:' | 135 | // strip leading 'mailto:' |
126 | QString address = _address; | 136 | QString address = _address; |
127 | if (address.startsWith("mailto:")) | 137 | if (address.startsWith("mailto:")) |
128 | address = address.mid(6); | 138 | address = address.mid(6); |
129 | 139 | ||
130 | compose(); | 140 | compose(); |
131 | writeMail->setRecipient(address); | 141 | writeMail->setRecipient(address); |
132 | } | 142 | } |
133 | 143 | ||
144 | /*void MailItWindow::reply(Email& mail) | ||
145 | { | ||
146 | qDebug("####EmailClient: 0 reached"); | ||
147 | composeReply(mail,(bool&)FALSE); | ||
148 | } | ||
149 | |||
150 | void MailItWindow::replyAll(Email& mail) | ||
151 | { | ||
152 | qDebug("####EmailClient: 1 reached"); | ||
153 | composeReply(mail,(bool&)TRUE); | ||
154 | } | ||
155 | |||
156 | void MailItWindow::forward(Email& mail) | ||
157 | { | ||
158 | qDebug("####EmailClient: 2 reached"); | ||
159 | } | ||
160 | |||
161 | void MailItWindow::remove(Email&) | ||
162 | { | ||
163 | qDebug("####EmailClient: 3 reached"); | ||
164 | //emit removeItem(eli,(bool&)TRUE); | ||
165 | } */ \ No newline at end of file | ||
diff --git a/noncore/unsupported/mailit/mailitwindow.h b/noncore/unsupported/mailit/mailitwindow.h index 667960b..e818d32 100644 --- a/noncore/unsupported/mailit/mailitwindow.h +++ b/noncore/unsupported/mailit/mailitwindow.h | |||
@@ -1,58 +1,64 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MailItWindow_H | 20 | #ifndef MailItWindow_H |
21 | #define MailItWindow_H | 21 | #define MailItWindow_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qwidgetstack.h> | 24 | #include <qwidgetstack.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | //#include <qlayout.h> | 26 | //#include <qlayout.h> |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | #include "writemail.h" | 28 | #include "writemail.h" |
29 | #include "readmail.h" | 29 | #include "readmail.h" |
30 | #include "addresslist.h" | 30 | #include "addresslist.h" |
31 | 31 | ||
32 | class MailItWindow: public QMainWindow | 32 | class MailItWindow: public QMainWindow |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 36 | MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
37 | ~MailItWindow(); | 37 | ~MailItWindow(); |
38 | 38 | ||
39 | signals: | ||
39 | public slots: | 40 | public slots: |
40 | void compose(); | 41 | void compose(); |
41 | void composeReply(Email &); | 42 | void composeReply(Email &, bool&); |
43 | void composeForward(Email &); | ||
42 | void showEmailClient(); | 44 | void showEmailClient(); |
43 | void viewMail(QListView *, Email *mail); | 45 | void viewMail(QListView *, Email *mail); |
44 | void updateMailView(Email *mail); | 46 | void updateMailView(Email *mail); |
45 | void closeEvent(QCloseEvent *e); | 47 | void closeEvent(QCloseEvent *e); |
46 | void updateCaption(const QString &); | 48 | void updateCaption(const QString &); |
47 | void setDocument(const QString &); | 49 | void setDocument(const QString &); |
50 | /*void reply(Email&); | ||
51 | void replyAll(Email&); | ||
52 | void forward(Email&); | ||
53 | void remove(Email&);*/ | ||
48 | 54 | ||
49 | private: | 55 | private: |
50 | EmailClient *emailClient; | 56 | EmailClient *emailClient; |
51 | WriteMail *writeMail; | 57 | WriteMail *writeMail; |
52 | ReadMail *readMail; | 58 | ReadMail *readMail; |
53 | QWidgetStack *views; | 59 | QWidgetStack *views; |
54 | QString currentCaption; | 60 | QString currentCaption; |
55 | bool viewingMail; | 61 | bool viewingMail; |
56 | }; | 62 | }; |
57 | 63 | ||
58 | #endif | 64 | #endif |
diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp index 7cd3e09..dc98a6f 100644 --- a/noncore/unsupported/mailit/readmail.cpp +++ b/noncore/unsupported/mailit/readmail.cpp | |||
@@ -14,239 +14,263 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | ||
63 | forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), | ||
64 | QString::null, 0, this, 0 ); | ||
65 | connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); | ||
66 | |||
63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 67 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 68 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
65 | previousButton->addTo(bar); | 69 | previousButton->addTo(bar); |
66 | previousButton->addTo(viewMenu); | 70 | previousButton->addTo(viewMenu); |
67 | 71 | ||
68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 72 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 73 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
70 | nextButton->addTo(bar); | 74 | nextButton->addTo(bar); |
71 | nextButton->addTo(viewMenu); | 75 | nextButton->addTo(viewMenu); |
72 | 76 | ||
73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); | 77 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
74 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 78 | connect( attatchmentsButton, SIGNAL( activated() ), this, |
75 | SLOT( viewAttatchments() ) ); | 79 | SLOT( viewAttatchments() ) ); |
76 | attatchmentsButton->addTo(bar); | 80 | attatchmentsButton->addTo(bar); |
77 | attatchmentsButton->addTo(viewMenu); | 81 | attatchmentsButton->addTo(viewMenu); |
78 | 82 | ||
79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); | 83 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 84 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
81 | plainTextButton->addTo(bar); | 85 | plainTextButton->addTo(bar); |
82 | plainTextButton->addTo(viewMenu); | 86 | plainTextButton->addTo(viewMenu); |
83 | 87 | ||
84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 88 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 89 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
86 | deleteButton->addTo(bar); | 90 | deleteButton->addTo(bar); |
87 | deleteButton->addTo(mailMenu); | 91 | deleteButton->addTo(mailMenu); |
88 | 92 | ||
89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 93 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
90 | 94 | ||
91 | emailView = new QTextView( this, "emailView" ); | 95 | emailView = new QTextView( this, "emailView" ); |
92 | 96 | ||
93 | setCentralWidget(emailView); | 97 | setCentralWidget(emailView); |
94 | 98 | ||
95 | mime = new QMimeSourceFactory(); | 99 | mime = new QMimeSourceFactory(); |
96 | emailView->setMimeSourceFactory(mime); | 100 | emailView->setMimeSourceFactory(mime); |
97 | } | 101 | } |
98 | 102 | ||
99 | void ReadMail::updateView() | 103 | void ReadMail::updateView() |
100 | { | 104 | { |
101 | Enclosure *ePtr; | 105 | Enclosure *ePtr; |
102 | QString mailStringSize; | 106 | QString mailStringSize; |
103 | QString text, temp; | 107 | QString text, temp; |
104 | 108 | ||
105 | mail->read = TRUE; //mark as read | 109 | mail->read = TRUE; //mark as read |
106 | inbox = mail->received; | 110 | inbox = mail->received; |
107 | 111 | ||
108 | replyButton->removeFrom(mailMenu); | 112 | replyButton->removeFrom(mailMenu); |
109 | replyButton->removeFrom(bar); | 113 | replyButton->removeFrom(bar); |
114 | forwardButton->removeFrom(mailMenu); | ||
115 | forwardButton->removeFrom(bar); | ||
110 | 116 | ||
111 | if (inbox == TRUE) { | 117 | if (inbox == TRUE) { |
112 | replyButton->addTo(bar); | 118 | replyButton->addTo(bar); |
113 | replyButton->addTo(mailMenu); | 119 | replyButton->addTo(mailMenu); |
114 | 120 | forwardButton->addTo(bar); | |
121 | forwardButton->addTo(mailMenu); | ||
122 | |||
123 | |||
115 | if (!mail->downloaded) { | 124 | if (!mail->downloaded) { |
116 | //report currently viewed mail so that it will be | 125 | //report currently viewed mail so that it will be |
117 | //placed first in the queue of new mails to download | 126 | //placed first in the queue of new mails to download |
118 | emit viewingMail(mail); | 127 | emit viewingMail(mail); |
119 | 128 | ||
120 | double mailSize = (double) mail->size; | 129 | double mailSize = (double) mail->size; |
121 | if (mailSize < 1024) { | 130 | if (mailSize < 1024) { |
122 | mailStringSize.setNum(mailSize); | 131 | mailStringSize.setNum(mailSize); |
123 | mailStringSize += " Bytes"; | 132 | mailStringSize += " Bytes"; |
124 | } else if (mailSize < 1024*1024) { | 133 | } else if (mailSize < 1024*1024) { |
125 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 134 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
126 | mailStringSize += " Kb"; | 135 | mailStringSize += " Kb"; |
127 | } else { | 136 | } else { |
128 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 137 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
129 | mailStringSize += " Mb"; | 138 | mailStringSize += " Mb"; |
130 | } | 139 | } |
131 | } | 140 | } |
132 | } | 141 | } |
133 | 142 | ||
134 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 143 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
135 | 144 | ||
136 | if (! plainTxt) { //use RichText, inline pics etc. | 145 | if (! plainTxt) { //use RichText, inline pics etc. |
137 | emailView->setTextFormat(QTextView::RichText); | 146 | emailView->setTextFormat(QTextView::RichText); |
138 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 147 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
139 | +"</font></center></big></b><br>"; | 148 | +"</font></center></big></b><br>"; |
140 | text += "<b>From: </b>" + mail->from + " <i>" + | 149 | text += "<b>From: </b>" + mail->from + " <i>" + |
141 | mail->fromMail + "</i><br>"; | 150 | mail->fromMail + "</i><br>"; |
142 | 151 | ||
143 | text +="<b>To: </b>"; | 152 | text +="<b>To: </b>"; |
144 | for (QStringList::Iterator it = mail->recipients.begin(); | 153 | for (QStringList::Iterator it = mail->recipients.begin(); |
145 | it != mail->recipients.end(); ++it ) { | 154 | it != mail->recipients.end(); ++it ) { |
146 | text += *it + " "; | 155 | text += *it + " "; |
147 | } | 156 | } |
157 | |||
158 | text +="<br><b>CC: </b>"; | ||
159 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | ||
160 | it != mail->carbonCopies.end(); ++it ) { | ||
161 | text += *it + " "; | ||
162 | } | ||
163 | |||
148 | text += "<br>" + mail->date; | 164 | text += "<br>" + mail->date; |
149 | 165 | ||
150 | if (mail->files.count() > 0) { | 166 | if (mail->files.count() > 0) { |
151 | text += "<br><b>Attatchments: </b>"; | 167 | text += "<br><b>Attatchments: </b>"; |
152 | 168 | ||
153 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 169 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
154 | text += ePtr->originalName + " "; | 170 | text += ePtr->originalName + " "; |
155 | } | 171 | } |
156 | text += "<hr><br>" + mail->body; | 172 | text += "<hr><br>" + mail->body; |
157 | 173 | ||
158 | if (inbox) { | 174 | if (inbox) { |
159 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 175 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
160 | 176 | ||
161 | text += "<br><hr><b>Attatchment: </b>" + | 177 | text += "<br><hr><b>Attatchment: </b>" + |
162 | ePtr->originalName + "<hr>"; | 178 | ePtr->originalName + "<hr>"; |
163 | 179 | ||
164 | if (ePtr->contentType == "TEXT") { | 180 | if (ePtr->contentType == "TEXT") { |
165 | QFile f(ePtr->path + ePtr->name); | 181 | QFile f(ePtr->path + ePtr->name); |
166 | 182 | ||
167 | if (f.open(IO_ReadOnly) ) { | 183 | if (f.open(IO_ReadOnly) ) { |
168 | QTextStream t(&f); | 184 | QTextStream t(&f); |
169 | temp = t.read(); | 185 | temp = t.read(); |
170 | text += temp + "<br>"; | 186 | text += temp + "<br>"; |
171 | f.close(); | 187 | f.close(); |
172 | } else { | 188 | } else { |
173 | text += "<b>Could not locate file</b><br>"; | 189 | text += "<b>Could not locate file</b><br>"; |
174 | } | 190 | } |
175 | 191 | ||
176 | } | 192 | } |
177 | if (ePtr->contentType == "IMAGE") { | 193 | if (ePtr->contentType == "IMAGE") { |
178 | // temp.setNum(emailView->width());//get display width | 194 | // temp.setNum(emailView->width());//get display width |
179 | // text += "<img width=" + temp +" src =""" + | 195 | // text += "<img width=" + temp +" src =""" + |
180 | // ePtr->originalName + """> </img>"; | 196 | // ePtr->originalName + """> </img>"; |
181 | text += "<img src =""" + | 197 | text += "<img src =""" + |
182 | ePtr->originalName + """> </img>"; | 198 | ePtr->originalName + """> </img>"; |
183 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 199 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
184 | } | 200 | } |
185 | } | 201 | } |
186 | } | 202 | } |
187 | } else { | 203 | } else { |
188 | if (mail->downloaded || !inbox) { | 204 | if (mail->downloaded || !inbox) { |
189 | text += "<hr><br>" + mail->body; | 205 | text += "<hr><br>" + mail->body; |
190 | } else { | 206 | } else { |
191 | text += "<hr><br><b> Awaiting download </b><br>"; | 207 | text += "<hr><br><b> Awaiting download </b><br>"; |
192 | text += "Size of mail: " + mailStringSize; | 208 | text += "Size of mail: " + mailStringSize; |
193 | } | 209 | } |
194 | } | 210 | } |
195 | emailView->setText(text); | 211 | emailView->setText(text); |
196 | } else { // show plain txt mail | 212 | } else { // show plain txt mail |
197 | emailView->setTextFormat(QTextView::PlainText); | 213 | emailView->setTextFormat(QTextView::PlainText); |
198 | text = "Subject: " + mail->subject + "\n"; | 214 | text = "Subject: " + mail->subject + "\n"; |
199 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; | 215 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; |
200 | text += "To: "; | 216 | text += "To: "; |
201 | for (QStringList::Iterator it = mail->recipients.begin(); | 217 | for (QStringList::Iterator it = mail->recipients.begin(); |
202 | it != mail->recipients.end(); ++it ) { | 218 | it != mail->recipients.end(); ++it ) { |
203 | text += *it + " "; | 219 | text += *it + " "; |
204 | } | 220 | } |
221 | |||
222 | text += "\nCC: "; | ||
223 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | ||
224 | it != mail->carbonCopies.end(); ++it ) { | ||
225 | text += *it + " "; | ||
226 | } | ||
227 | |||
228 | |||
205 | text += "\nDate: " + mail->date + "\n"; | 229 | text += "\nDate: " + mail->date + "\n"; |
206 | if (mail->files.count() > 0) { | 230 | if (mail->files.count() > 0) { |
207 | text += "Attatchments: "; | 231 | text += "Attatchments: "; |
208 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 232 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
209 | text += ePtr->originalName + " "; | 233 | text += ePtr->originalName + " "; |
210 | } | 234 | } |
211 | text += "\n\n"; | 235 | text += "\n\n"; |
212 | } else text += "\n"; | 236 | } else text += "\n"; |
213 | 237 | ||
214 | if (!inbox) { | 238 | if (!inbox) { |
215 | text += mail->body; | 239 | text += mail->body; |
216 | } else if (mail->downloaded) { | 240 | } else if (mail->downloaded) { |
217 | text += mail->bodyPlain; | 241 | text += mail->bodyPlain; |
218 | } else { | 242 | } else { |
219 | text += "\nAwaiting download\n"; | 243 | text += "\nAwaiting download\n"; |
220 | text += "Size of mail: " + mailStringSize; | 244 | text += "Size of mail: " + mailStringSize; |
221 | } | 245 | } |
222 | 246 | ||
223 | emailView->setText(text); | 247 | emailView->setText(text); |
224 | } | 248 | } |
225 | 249 | ||
226 | if (mail->files.count() == 0) | 250 | if (mail->files.count() == 0) |
227 | attatchmentsButton->setEnabled(FALSE); | 251 | attatchmentsButton->setEnabled(FALSE); |
228 | else attatchmentsButton->setEnabled(TRUE); | 252 | else attatchmentsButton->setEnabled(TRUE); |
229 | 253 | ||
230 | setCaption("Examining mail: " + mail->subject); | 254 | setCaption("Examining mail: " + mail->subject); |
231 | } | 255 | } |
232 | 256 | ||
233 | //update view with current EmailListItem (item) | 257 | //update view with current EmailListItem (item) |
234 | void ReadMail::update(QListView *thisView, Email *mailIn) | 258 | void ReadMail::update(QListView *thisView, Email *mailIn) |
235 | { | 259 | { |
236 | view = thisView; | 260 | view = thisView; |
237 | item = (EmailListItem *) view->selectedItem(); | 261 | item = (EmailListItem *) view->selectedItem(); |
238 | mail = mailIn; | 262 | mail = mailIn; |
239 | updateView(); | 263 | updateView(); |
240 | updateButtons(); | 264 | updateButtons(); |
241 | } | 265 | } |
242 | 266 | ||
243 | void ReadMail::mailUpdated(Email *mailIn) | 267 | void ReadMail::mailUpdated(Email *mailIn) |
244 | { | 268 | { |
245 | if (mailIn == mail) { | 269 | if (mailIn == mail) { |
246 | updateView(); | 270 | updateView(); |
247 | } else { | 271 | } else { |
248 | updateButtons(); | 272 | updateButtons(); |
249 | } | 273 | } |
250 | } | 274 | } |
251 | 275 | ||
252 | void ReadMail::close() | 276 | void ReadMail::close() |
@@ -278,50 +302,56 @@ void ReadMail::previous() | |||
278 | 302 | ||
279 | //deletes item, tries bringing up next or previous, exits if unsucessful | 303 | //deletes item, tries bringing up next or previous, exits if unsucessful |
280 | void ReadMail::deleteItem() | 304 | void ReadMail::deleteItem() |
281 | { | 305 | { |
282 | EmailListItem *temp = item; | 306 | EmailListItem *temp = item; |
283 | temp = (EmailListItem *) item->nextSibling();//trybelow | 307 | temp = (EmailListItem *) item->nextSibling();//trybelow |
284 | if (temp == NULL) | 308 | if (temp == NULL) |
285 | temp = (EmailListItem *) item->itemAbove(); //try above | 309 | temp = (EmailListItem *) item->itemAbove(); //try above |
286 | 310 | ||
287 | emit removeItem(item, inbox); | 311 | emit removeItem(item, inbox); |
288 | 312 | ||
289 | item = temp; | 313 | item = temp; |
290 | if (item != NULL) { //more items in list | 314 | if (item != NULL) { //more items in list |
291 | mail = item->getMail(); | 315 | mail = item->getMail(); |
292 | updateView(); | 316 | updateView(); |
293 | updateButtons(); | 317 | updateButtons(); |
294 | } else close(); //no more items to see | 318 | } else close(); //no more items to see |
295 | } | 319 | } |
296 | 320 | ||
297 | void ReadMail::updateButtons() | 321 | void ReadMail::updateButtons() |
298 | { | 322 | { |
299 | EmailListItem *temp; | 323 | EmailListItem *temp; |
300 | 324 | ||
301 | temp = item; | 325 | temp = item; |
302 | if ((EmailListItem *) temp->nextSibling() == NULL) | 326 | if ((EmailListItem *) temp->nextSibling() == NULL) |
303 | nextButton->setEnabled(FALSE); | 327 | nextButton->setEnabled(FALSE); |
304 | else nextButton->setEnabled(TRUE); | 328 | else nextButton->setEnabled(TRUE); |
305 | 329 | ||
306 | temp = item; | 330 | temp = item; |
307 | if ((EmailListItem *) temp->itemAbove() == NULL) | 331 | if ((EmailListItem *) temp->itemAbove() == NULL) |
308 | previousButton->setEnabled(FALSE); | 332 | previousButton->setEnabled(FALSE); |
309 | else previousButton->setEnabled(TRUE); | 333 | else previousButton->setEnabled(TRUE); |
310 | } | 334 | } |
311 | 335 | ||
312 | void ReadMail::shiftText() | 336 | void ReadMail::shiftText() |
313 | { | 337 | { |
314 | plainTxt = ! plainTxt; | 338 | plainTxt = ! plainTxt; |
315 | updateView(); | 339 | updateView(); |
316 | } | 340 | } |
317 | 341 | ||
318 | void ReadMail::viewAttatchments() | 342 | void ReadMail::viewAttatchments() |
319 | { | 343 | { |
320 | viewAtt->update(mail, inbox); | 344 | viewAtt->update(mail, inbox); |
321 | viewAtt->showMaximized(); | 345 | viewAtt->showMaximized(); |
322 | } | 346 | } |
323 | 347 | ||
324 | void ReadMail::reply() | 348 | void ReadMail::reply() |
325 | { | 349 | { |
326 | emit replyRequested(*mail); | 350 | emit replyRequested(*mail, (bool&)TRUE); |
327 | } | 351 | } |
352 | |||
353 | void ReadMail::forward() | ||
354 | { | ||
355 | emit forwardRequested(*mail); | ||
356 | } | ||
357 | |||
diff --git a/noncore/unsupported/mailit/readmail.h b/noncore/unsupported/mailit/readmail.h index d0bb067..0fe0646 100644 --- a/noncore/unsupported/mailit/readmail.h +++ b/noncore/unsupported/mailit/readmail.h | |||
@@ -1,86 +1,89 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef READMAIL_H | 20 | #ifndef READMAIL_H |
21 | #define READMAIL_H | 21 | #define READMAIL_H |
22 | 22 | ||
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtextview.h> | 30 | #include <qtextview.h> |
31 | 31 | ||
32 | #include "emailhandler.h" | 32 | #include "emailhandler.h" |
33 | #include "emaillistitem.h" | 33 | #include "emaillistitem.h" |
34 | #include "viewatt.h" | 34 | #include "viewatt.h" |
35 | 35 | ||
36 | class ReadMail : public QMainWindow | 36 | class ReadMail : public QMainWindow |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
42 | ~ReadMail(); | 42 | ~ReadMail(); |
43 | void update(QListView *thisView, Email *mailIn); | 43 | void update(QListView *thisView, Email *mailIn); |
44 | void updateView(); | 44 | void updateView(); |
45 | void mailUpdated(Email *mailIn); | 45 | void mailUpdated(Email *mailIn); |
46 | 46 | ||
47 | signals: | 47 | signals: |
48 | void cancelView(); | 48 | void cancelView(); |
49 | void replyRequested(Email &); | 49 | void replyRequested(Email &, bool &); |
50 | void forwardRequested(Email&); | ||
50 | void removeItem(EmailListItem *, bool &); | 51 | void removeItem(EmailListItem *, bool &); |
51 | void viewingMail(Email *); | 52 | void viewingMail(Email *); |
52 | 53 | ||
53 | public slots: | 54 | public slots: |
54 | void close(); | 55 | void close(); |
55 | void next(); | 56 | void next(); |
56 | void previous(); | 57 | void previous(); |
57 | void deleteItem(); | 58 | void deleteItem(); |
58 | void shiftText(); | 59 | void shiftText(); |
59 | void viewAttatchments(); | 60 | void viewAttatchments(); |
60 | void reply(); | 61 | void reply(); |
62 | void forward(); | ||
61 | 63 | ||
62 | private: | 64 | private: |
63 | void init(); | 65 | void init(); |
64 | void updateButtons(); | 66 | void updateButtons(); |
65 | 67 | ||
66 | private: | 68 | private: |
67 | QListView *view; | 69 | QListView *view; |
68 | EmailListItem *item; | 70 | EmailListItem *item; |
69 | bool plainTxt, inbox; | 71 | bool plainTxt, inbox; |
70 | Email *mail; | 72 | Email *mail; |
71 | ViewAtt *viewAtt; | 73 | ViewAtt *viewAtt; |
72 | 74 | ||
73 | QToolBar *bar; | 75 | QToolBar *bar; |
74 | QMenuBar *menu; | 76 | QMenuBar *menu; |
75 | QPopupMenu *viewMenu, *mailMenu; | 77 | QPopupMenu *viewMenu, *mailMenu; |
76 | QAction *deleteButton; | 78 | QAction *deleteButton; |
77 | QMimeSourceFactory *mime; | 79 | QMimeSourceFactory *mime; |
78 | QAction *plainTextButton; | 80 | QAction *plainTextButton; |
79 | QAction *nextButton; | 81 | QAction *nextButton; |
80 | QTextView *emailView; | 82 | QTextView *emailView; |
81 | QAction *attatchmentsButton; | 83 | QAction *attatchmentsButton; |
82 | QAction *previousButton; | 84 | QAction *previousButton; |
83 | QAction *replyButton; | 85 | QAction *replyButton; |
86 | QAction *forwardButton; | ||
84 | }; | 87 | }; |
85 | 88 | ||
86 | #endif // READMAIL_H | 89 | #endif // READMAIL_H |
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index 38a2596..a9dcb02 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp | |||
@@ -38,261 +38,336 @@ WriteMail::~WriteMail() | |||
38 | void WriteMail::setAddressList(AddressList *list) | 38 | void WriteMail::setAddressList(AddressList *list) |
39 | { | 39 | { |
40 | Contact *cPtr; | 40 | Contact *cPtr; |
41 | 41 | ||
42 | addressList = list; | 42 | addressList = list; |
43 | 43 | ||
44 | addressView->clear(); | 44 | addressView->clear(); |
45 | QList<Contact> *cListPtr = addressList->getContactList(); | 45 | QList<Contact> *cListPtr = addressList->getContactList(); |
46 | QListViewItem *item; | 46 | QListViewItem *item; |
47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); | 48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void WriteMail::init() | 52 | void WriteMail::init() |
53 | { | 53 | { |
54 | setToolBarsMovable(FALSE); | 54 | setToolBarsMovable(FALSE); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
58 | 58 | ||
59 | menu = new QMenuBar( bar ); | 59 | menu = new QMenuBar( bar ); |
60 | 60 | ||
61 | mailMenu = new QPopupMenu(menu); | 61 | mailMenu = new QPopupMenu(menu); |
62 | menu->insertItem( tr( "&Mail" ), mailMenu); | 62 | menu->insertItem( tr( "&Mail" ), mailMenu); |
63 | addMenu = new QPopupMenu(menu); | 63 | addMenu = new QPopupMenu(menu); |
64 | menu->insertItem( tr( "&Add" ), addMenu); | 64 | menu->insertItem( tr( "&Add" ), addMenu); |
65 | 65 | ||
66 | bar = new QToolBar(this); | 66 | bar = new QToolBar(this); |
67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); | 67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
68 | attatchButton->addTo(bar); | 68 | attatchButton->addTo(bar); |
69 | attatchButton->addTo(addMenu); | 69 | attatchButton->addTo(addMenu); |
70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); | 70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); |
71 | 71 | ||
72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
73 | confirmButton->addTo(bar); | 73 | confirmButton->addTo(bar); |
74 | confirmButton->addTo(mailMenu); | 74 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
76 | 76 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 78 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 80 | ||
81 | widget = new QWidget(this, "widget"); | 81 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 82 | grid = new QGridLayout( widget ); |
83 | 83 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 85 | recipientsBox->insertItem( tr( "To:" ) ); |
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 86 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 87 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 88 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | ||
90 | |||
89 | 91 | ||
90 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 92 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
91 | subjetLabel->setText( tr( "Subject:" ) ); | 93 | subjetLabel->setText( tr( "Subject:" ) ); |
92 | 94 | ||
93 | grid->addWidget( subjetLabel, 1, 0 ); | 95 | grid->addWidget( subjetLabel, 1, 0 ); |
94 | 96 | ||
95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 97 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
96 | ToolButton13_2->setText( tr( "..." ) ); | 98 | ToolButton13_2->setText( tr( "..." ) ); |
97 | grid->addWidget( ToolButton13_2, 1, 2 ); | 99 | grid->addWidget( ToolButton13_2, 1, 2 ); |
98 | 100 | ||
99 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 101 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
100 | grid->addWidget( subjectInput, 1, 1 ); | 102 | grid->addWidget( subjectInput, 1, 1 ); |
101 | 103 | ||
102 | toInput = new QLineEdit( widget, "toInput" ); | 104 | toInput = new QLineEdit( widget, "toInput" ); |
103 | grid->addWidget( toInput, 0, 1 ); | 105 | grid->addWidget( toInput, 0, 1 ); |
104 | 106 | ||
107 | ccInput = new QLineEdit( widget, "ccInput" ); | ||
108 | ccInput->hide(); | ||
109 | grid->addWidget( ccInput, 0, 1 ); | ||
110 | |||
111 | |||
105 | addressButton = new QToolButton( widget, "addressButton" ); | 112 | addressButton = new QToolButton( widget, "addressButton" ); |
106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 113 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
107 | addressButton->setToggleButton(TRUE); | 114 | addressButton->setToggleButton(TRUE); |
108 | grid->addWidget( addressButton, 0, 2 ); | 115 | grid->addWidget( addressButton, 0, 2 ); |
109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 116 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
110 | 117 | ||
111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 118 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 119 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
113 | 120 | ||
114 | 121 | ||
115 | addressView = new QListView( widget, "addressView"); | 122 | addressView = new QListView( widget, "addressView"); |
116 | addressView->addColumn("Name"); | 123 | addressView->addColumn("Name"); |
117 | addressView->addColumn("EMail"); | 124 | addressView->addColumn("EMail"); |
118 | addressView->setAllColumnsShowFocus(TRUE); | 125 | addressView->setAllColumnsShowFocus(TRUE); |
119 | addressView->setMultiSelection(TRUE); | 126 | addressView->setMultiSelection(TRUE); |
120 | addressView->hide(); | 127 | addressView->hide(); |
121 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 128 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
122 | 129 | ||
123 | okButton = new QToolButton(bar, "ok"); | 130 | okButton = new QToolButton(bar, "ok"); |
124 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 131 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
125 | okButton->hide(); | 132 | okButton->hide(); |
126 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 133 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
127 | 134 | ||
128 | setCentralWidget(widget); | 135 | setCentralWidget(widget); |
129 | } | 136 | } |
130 | 137 | ||
131 | void WriteMail::reject() | 138 | void WriteMail::reject() |
132 | { | 139 | { |
133 | emit cancelMail(); | 140 | emit cancelMail(); |
134 | } | 141 | } |
135 | 142 | ||
136 | // need to insert date | 143 | // need to insert date |
137 | void WriteMail::accept() | 144 | void WriteMail::accept() |
138 | { | 145 | { |
139 | QStringList attatchedFiles, attatchmentsType; | 146 | QStringList attatchedFiles, attatchmentsType; |
140 | int idCount = 0; | 147 | int idCount = 0; |
141 | 148 | ||
142 | if (toInput->text() == "") { | 149 | if (toInput->text() == "") |
143 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); | 150 | { |
151 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | ||
152 | return; | ||
153 | } | ||
154 | |||
155 | if (! getRecipients(false) ) | ||
156 | { | ||
157 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | ||
158 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | ||
144 | return; | 159 | return; |
145 | } | 160 | } |
146 | if (! getRecipients() ) { | 161 | |
147 | QMessageBox::warning(this,"Incorrect recipient separator", | 162 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
148 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); | 163 | { |
164 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | ||
165 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | ||
149 | return; | 166 | return; |
150 | } | 167 | } |
168 | |||
151 | mail.subject = subjectInput->text(); | 169 | mail.subject = subjectInput->text(); |
152 | mail.body = emailInput->text(); | 170 | mail.body = emailInput->text(); |
153 | mail.sent = false; | 171 | mail.sent = false; |
154 | mail.received = false; | 172 | mail.received = false; |
173 | |||
155 | mail.rawMail = "To: "; | 174 | mail.rawMail = "To: "; |
156 | 175 | ||
157 | for (QStringList::Iterator it = mail.recipients.begin(); | 176 | for (QStringList::Iterator it = mail.recipients.begin(); |
158 | it != mail.recipients.end(); ++it) { | 177 | it != mail.recipients.end(); ++it) { |
159 | 178 | ||
160 | mail.rawMail += (*it); | 179 | mail.rawMail += (*it); |
161 | mail.rawMail += ",\n"; | 180 | mail.rawMail += ",\n"; |
162 | } | 181 | } |
182 | |||
163 | mail.rawMail.truncate(mail.rawMail.length()-2); | 183 | mail.rawMail.truncate(mail.rawMail.length()-2); |
184 | |||
185 | mail.rawMail += "\nCC: "; | ||
186 | |||
187 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | ||
188 | it != mail.carbonCopies.end(); ++it) { | ||
189 | |||
190 | mail.rawMail += (*it); | ||
191 | mail.rawMail += ",\n"; | ||
192 | } | ||
193 | |||
164 | mail.rawMail += mail.from; | 194 | mail.rawMail += mail.from; |
165 | mail.rawMail += "\nSubject: "; | 195 | mail.rawMail += "\nSubject: "; |
166 | mail.rawMail += mail.subject; | 196 | mail.rawMail += mail.subject; |
167 | mail.rawMail += "\n\n"; | 197 | mail.rawMail += "\n\n"; |
168 | 198 | ||
169 | attatchedFiles = addAtt->returnAttatchedFiles(); | 199 | attatchedFiles = addAtt->returnAttatchedFiles(); |
170 | attatchmentsType = addAtt->returnFileTypes(); | 200 | attatchmentsType = addAtt->returnFileTypes(); |
171 | 201 | ||
172 | QStringList::Iterator itType = attatchmentsType.begin(); | 202 | QStringList::Iterator itType = attatchmentsType.begin(); |
173 | 203 | ||
174 | Enclosure e; | 204 | Enclosure e; |
175 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { | 205 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { |
176 | e.id = idCount; | 206 | e.id = idCount; |
177 | e.originalName = (*it).latin1(); | 207 | e.originalName = (*it).latin1(); |
178 | e.contentType = (*itType).latin1(); | 208 | e.contentType = (*itType).latin1(); |
179 | e.contentAttribute = (*itType).latin1(); | 209 | e.contentAttribute = (*itType).latin1(); |
180 | e.saved = TRUE; | 210 | e.saved = TRUE; |
181 | mail.addEnclosure(&e); | 211 | mail.addEnclosure(&e); |
182 | 212 | ||
183 | itType++; | 213 | itType++; |
184 | idCount++; | 214 | idCount++; |
185 | } | 215 | } |
186 | mail.rawMail += mail.body; | 216 | mail.rawMail += mail.body; |
187 | mail.rawMail += "\n"; | 217 | mail.rawMail += "\n"; |
188 | mail.rawMail += ".\n"; | 218 | mail.rawMail += ".\n"; |
189 | emit sendMailRequested(mail); | 219 | emit sendMailRequested(mail); |
190 | addAtt->clear(); | 220 | addAtt->clear(); |
191 | } | 221 | } |
192 | 222 | ||
193 | void WriteMail::getAddress() | 223 | void WriteMail::getAddress() |
194 | { | 224 | { |
195 | showingAddressList = !showingAddressList; | 225 | showingAddressList = !showingAddressList; |
196 | 226 | ||
197 | if (showingAddressList) { | 227 | if (showingAddressList) { |
198 | emailInput->hide(); | 228 | emailInput->hide(); |
199 | addressView->show(); | 229 | addressView->show(); |
200 | okButton->show(); | 230 | okButton->show(); |
201 | 231 | ||
202 | } else { | 232 | } else { |
203 | addressView->hide(); | 233 | addressView->hide(); |
204 | okButton->hide(); | 234 | okButton->hide(); |
205 | emailInput->show(); | 235 | emailInput->show(); |
206 | } | 236 | } |
207 | } | 237 | } |
208 | 238 | ||
209 | void WriteMail::attatchFile() | 239 | void WriteMail::attatchFile() |
210 | { | 240 | { |
211 | addAtt->showMaximized(); | 241 | addAtt->showMaximized(); |
212 | } | 242 | } |
213 | 243 | ||
214 | void WriteMail::reply(Email replyMail) | 244 | void WriteMail::reply(Email replyMail, bool replyAll) |
215 | { | 245 | { |
216 | int pos; | 246 | int pos; |
217 | 247 | ||
218 | mail = replyMail; | 248 | mail = replyMail; |
219 | mail.files.clear(); | 249 | mail.files.clear(); |
220 | 250 | ||
221 | toInput->setText(mail.fromMail); | 251 | toInput->setText(mail.fromMail); |
222 | subjectInput->setText("Re: " + mail.subject); | 252 | //replyAll ? ccInput->setText(mail.c) |
253 | |||
254 | addRecipients(replyAll); | ||
255 | |||
256 | subjectInput->setText(tr("Re: ") + mail.subject); | ||
223 | 257 | ||
224 | pos = 0; | 258 | pos = 0; |
225 | mail.body.insert(pos, ">>"); | 259 | mail.body.insert(pos, ">>"); |
226 | while (pos != -1) { | 260 | while (pos != -1) { |
227 | pos = mail.body.find('\n', pos); | 261 | pos = mail.body.find('\n', pos); |
228 | if (pos != -1) | 262 | if (pos != -1) |
229 | mail.body.insert(++pos, ">>"); | 263 | mail.body.insert(++pos, ">>"); |
230 | } | 264 | } |
231 | 265 | ||
232 | emailInput->setText(mail.body); | 266 | emailInput->setText(mail.body); |
233 | } | 267 | } |
234 | 268 | ||
235 | bool WriteMail::getRecipients() | 269 | void WriteMail::forward(Email forwMail) |
270 | { | ||
271 | int pos=0; | ||
272 | |||
273 | QString fwdBody=tr("======forwarded message from "); | ||
274 | fwdBody.append(forwMail.fromMail); | ||
275 | fwdBody.append(tr(" starts======\n\n")); | ||
276 | |||
277 | mail=forwMail; | ||
278 | toInput->setText(""); | ||
279 | ccInput->setText(""); | ||
280 | subjectInput->setText(tr("FWD: ") + mail.subject); | ||
281 | |||
282 | fwdBody+=mail.body; | ||
283 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | ||
284 | |||
285 | emailInput->setText(fwdBody); | ||
286 | } | ||
287 | |||
288 | bool WriteMail::getRecipients(bool ccField) | ||
236 | { | 289 | { |
237 | QString str, temp; | 290 | QString str, temp; |
238 | int pos = 0; | 291 | int pos = 0; |
239 | 292 | ||
240 | mail.recipients.clear(); | 293 | mail.recipients.clear(); |
241 | 294 | ||
242 | temp = toInput->text(); | 295 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
296 | |||
243 | while ( (pos = temp.find(';')) != -1) { | 297 | while ( (pos = temp.find(';')) != -1) { |
244 | str = temp.left(pos).stripWhiteSpace(); | 298 | str = temp.left(pos).stripWhiteSpace(); |
245 | temp = temp.right(temp.length() - (pos + 1)); | 299 | temp = temp.right(temp.length() - (pos + 1)); |
246 | if ( str.find('@') == -1) | 300 | if ( str.find('@') == -1) |
247 | return false; | 301 | return false; |
248 | mail.recipients.append(str); | 302 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
249 | addressList->addContact(str, ""); | 303 | addressList->addContact(str, ""); |
250 | } | 304 | } |
251 | temp = temp.stripWhiteSpace(); | 305 | temp = temp.stripWhiteSpace(); |
252 | if ( temp.find('@') == -1) | 306 | if ( temp.find('@') == -1) |
253 | return false; | 307 | return false; |
254 | mail.recipients.append(temp); | 308 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
255 | addressList->addContact(temp, ""); | 309 | addressList->addContact(temp, ""); |
256 | 310 | ||
257 | return TRUE; | 311 | return TRUE; |
258 | } | 312 | } |
259 | |||
260 | 313 | ||
261 | void WriteMail::addRecipients() | 314 | void WriteMail::addRecipients() |
262 | { | 315 | { |
316 | |||
317 | addRecipients(false); | ||
318 | } | ||
319 | |||
320 | void WriteMail::addRecipients(bool ccField) | ||
321 | { | ||
263 | QString recipients = ""; | 322 | QString recipients = ""; |
264 | 323 | ||
265 | mail.recipients.clear(); | 324 | mail.recipients.clear(); |
325 | |||
266 | QListViewItem *item = addressView->firstChild(); | 326 | QListViewItem *item = addressView->firstChild(); |
267 | while (item != NULL) { | 327 | while (item != NULL) { |
268 | if ( item->isSelected() ) { | 328 | if ( item->isSelected() ) { |
269 | if (recipients == "") { | 329 | if (recipients == "") { |
270 | recipients = item->text(0); | 330 | recipients = item->text(0); |
271 | } else { | 331 | } else { |
272 | recipients += "; " + item->text(0); | 332 | recipients += "; " + item->text(0); |
273 | } | 333 | } |
274 | } | 334 | } |
275 | item = item->nextSibling(); | 335 | item = item->nextSibling(); |
276 | } | 336 | } |
277 | toInput->setText(recipients); | 337 | |
338 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | ||
278 | 339 | ||
279 | addressView->hide(); | 340 | addressView->hide(); |
280 | okButton->hide(); | 341 | okButton->hide(); |
281 | emailInput->show(); | 342 | emailInput->show(); |
282 | addressButton->setOn(FALSE); | 343 | addressButton->setOn(FALSE); |
283 | showingAddressList = !showingAddressList; | 344 | showingAddressList = !showingAddressList; |
284 | } | 345 | } |
285 | 346 | ||
347 | void WriteMail::changeRecipients(int selection) | ||
348 | { | ||
349 | if (selection==0) | ||
350 | { | ||
351 | toInput->show(); | ||
352 | ccInput->hide(); | ||
353 | } | ||
354 | else if (selection==1) | ||
355 | { | ||
356 | toInput->hide(); | ||
357 | ccInput->show(); | ||
358 | } | ||
359 | } | ||
360 | |||
286 | void WriteMail::setRecipient(const QString &recipient) | 361 | void WriteMail::setRecipient(const QString &recipient) |
287 | { | 362 | { |
288 | toInput->setText(recipient); | 363 | toInput->setText(recipient); |
289 | } | 364 | } |
290 | 365 | ||
291 | void WriteMail::newMail() | 366 | void WriteMail::newMail() |
292 | { | 367 | { |
293 | toInput->clear(); | 368 | toInput->clear(); |
294 | subjectInput->clear(); | 369 | subjectInput->clear(); |
295 | emailInput->clear(); | 370 | emailInput->clear(); |
296 | //to clear selected | 371 | //to clear selected |
297 | setAddressList(addressList); | 372 | setAddressList(addressList); |
298 | } | 373 | } |
diff --git a/noncore/unsupported/mailit/writemail.h b/noncore/unsupported/mailit/writemail.h index dd12063..f193b13 100644 --- a/noncore/unsupported/mailit/writemail.h +++ b/noncore/unsupported/mailit/writemail.h | |||
@@ -1,91 +1,96 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef WRITEMAIL_H | 20 | #ifndef WRITEMAIL_H |
21 | #define WRITEMAIL_H | 21 | #define WRITEMAIL_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qmultilineedit.h> | 31 | #include <qmultilineedit.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | 34 | ||
35 | #include "emailhandler.h" | 35 | #include "emailhandler.h" |
36 | #include "addresslist.h" | 36 | #include "addresslist.h" |
37 | #include "addatt.h" | 37 | #include "addatt.h" |
38 | 38 | ||
39 | class WriteMail : public QMainWindow | 39 | class WriteMail : public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); | 44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); |
45 | ~WriteMail(); | 45 | ~WriteMail(); |
46 | void reply(Email replyMail); | 46 | void reply(Email replyMail, bool replyAll); |
47 | void setRecipient(const QString &recipient); | 47 | void setRecipient(const QString &recipient); |
48 | void setAddressList(AddressList *list); | 48 | void setAddressList(AddressList *list); |
49 | void forward(Email forwMail); | ||
49 | 50 | ||
50 | signals: | 51 | signals: |
51 | void sendMailRequested(const Email &mail); | 52 | void sendMailRequested(const Email &mail); |
52 | void cancelMail(); | 53 | void cancelMail(); |
54 | |||
53 | 55 | ||
54 | public slots: | 56 | public slots: |
55 | void getAddress(); | 57 | void getAddress(); |
56 | void attatchFile(); | 58 | void attatchFile(); |
57 | void addRecipients(); | 59 | void addRecipients(); |
58 | void newMail(); | 60 | void newMail(); |
59 | void accept(); | 61 | void accept(); |
60 | void reject(); | 62 | void reject(); |
63 | void changeRecipients(int); | ||
61 | 64 | ||
62 | private: | 65 | private: |
63 | bool getRecipients(); | 66 | bool getRecipients(bool); |
64 | void init(); | 67 | void init(); |
68 | void addRecipients(bool); | ||
65 | 69 | ||
66 | Email mail; | 70 | Email mail; |
67 | AddAtt *addAtt; | 71 | AddAtt *addAtt; |
68 | AddressList *addressList; | 72 | AddressList *addressList; |
69 | bool showingAddressList; | 73 | bool showingAddressList; |
70 | 74 | ||
71 | QToolBar *bar; | 75 | QToolBar *bar; |
72 | QMenuBar *menu; | 76 | QMenuBar *menu; |
73 | QPopupMenu *addMenu, *mailMenu; | 77 | QPopupMenu *addMenu, *mailMenu; |
74 | QListView *addressView; | 78 | QListView *addressView; |
75 | 79 | ||
76 | QToolButton *okButton; | 80 | QToolButton *okButton; |
77 | QWidget *widget; | 81 | QWidget *widget; |
78 | QAction *attatchButton; | 82 | QAction *attatchButton; |
79 | QAction *confirmButton; | 83 | QAction *confirmButton; |
80 | QAction *newButton; | 84 | QAction *newButton; |
81 | QLabel* subjetLabel; | 85 | QLabel* subjetLabel; |
82 | QToolButton* ToolButton13_2; | 86 | QToolButton* ToolButton13_2; |
83 | QComboBox* recipientsBox; | 87 | QComboBox* recipientsBox; |
84 | QLineEdit *subjectInput; | 88 | QLineEdit *subjectInput; |
85 | QLineEdit *toInput; | 89 | QLineEdit *toInput; |
90 | QLineEdit *ccInput; | ||
86 | QToolButton* addressButton; | 91 | QToolButton* addressButton; |
87 | QMultiLineEdit* emailInput; | 92 | QMultiLineEdit* emailInput; |
88 | QGridLayout* grid; | 93 | QGridLayout* grid; |
89 | }; | 94 | }; |
90 | 95 | ||
91 | #endif // WRITEMAIL_H | 96 | #endif // WRITEMAIL_H |