-rw-r--r-- | kmicromail/accountitem.cpp | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 35 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 17 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 20 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 4 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 5 |
8 files changed, 63 insertions, 28 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 7795055..49d86fc 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -241,129 +241,129 @@ NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | |||
241 | { | 241 | { |
242 | setPixmap( 0, ); | 242 | setPixmap( 0, ); |
243 | } | 243 | } |
244 | else | 244 | else |
245 | { | 245 | { |
246 | setPixmap( 0, PIXMAP_OFFLINE ); | 246 | setPixmap( 0, PIXMAP_OFFLINE ); |
247 | } | 247 | } |
248 | #endif | 248 | #endif |
249 | setText( 0, account->getAccountName() ); | 249 | setText( 0, account->getAccountName() ); |
250 | setOpen( true ); | 250 | setOpen( true ); |
251 | } | 251 | } |
252 | 252 | ||
253 | NNTPviewItem::~NNTPviewItem() | 253 | NNTPviewItem::~NNTPviewItem() |
254 | { | 254 | { |
255 | delete wrapper; | 255 | delete wrapper; |
256 | } | 256 | } |
257 | 257 | ||
258 | AbstractMail *NNTPviewItem::getWrapper() | 258 | AbstractMail *NNTPviewItem::getWrapper() |
259 | { | 259 | { |
260 | return wrapper; | 260 | return wrapper; |
261 | } | 261 | } |
262 | 262 | ||
263 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 263 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
264 | { | 264 | { |
265 | refresh(); | 265 | refresh(); |
266 | } | 266 | } |
267 | 267 | ||
268 | void NNTPviewItem::refresh() | 268 | void NNTPviewItem::refresh() |
269 | { | 269 | { |
270 | if (account->getOffline()) return; | 270 | if (account->getOffline()) return; |
271 | QValueList<FolderP> *folders = wrapper->listFolders(); | 271 | QValueList<FolderP> *folders = wrapper->listFolders(); |
272 | 272 | ||
273 | QListViewItem *child = firstChild(); | 273 | QListViewItem *child = firstChild(); |
274 | while ( child ) | 274 | while ( child ) |
275 | { | 275 | { |
276 | QListViewItem *tmp = child; | 276 | QListViewItem *tmp = child; |
277 | child = child->nextSibling(); | 277 | child = child->nextSibling(); |
278 | delete tmp; | 278 | delete tmp; |
279 | } | 279 | } |
280 | QValueList<FolderP>::ConstIterator it; | 280 | QValueList<FolderP>::ConstIterator it; |
281 | QListViewItem*item = 0; | 281 | QListViewItem*item = 0; |
282 | for ( it = folders->begin(); it!=folders->end(); ++it) | 282 | for ( it = folders->begin(); it!=folders->end(); ++it) |
283 | { | 283 | { |
284 | item = new NNTPfolderItem( (*it), this , item ); | 284 | item = new NNTPfolderItem( (*it), this , item ); |
285 | item->setSelectable( (*it)->may_select()); | 285 | item->setSelectable( (*it)->may_select()); |
286 | } | 286 | } |
287 | delete folders; | 287 | delete folders; |
288 | } | 288 | } |
289 | 289 | ||
290 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 290 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
291 | { | 291 | { |
292 | 292 | ||
293 | return wrapper->fetchBody( mail ); | 293 | return wrapper->fetchBody( mail ); |
294 | } | 294 | } |
295 | 295 | ||
296 | QPopupMenu * NNTPviewItem::getContextMenu() | 296 | QPopupMenu * NNTPviewItem::getContextMenu() |
297 | { | 297 | { |
298 | QPopupMenu *m = new QPopupMenu(0); | 298 | QPopupMenu *m = new QPopupMenu(0); |
299 | if (m) | 299 | if (m) |
300 | { | 300 | { |
301 | if (!account->getOffline()) | 301 | if (!account->getOffline()) |
302 | { | 302 | { |
303 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 303 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
304 | m->insertItem(QObject::tr("Set offline",contextName),1); | 304 | m->insertItem(QObject::tr("Set offline",contextName),1); |
305 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 305 | //m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); |
306 | } | 306 | } |
307 | else | 307 | else |
308 | { | 308 | { |
309 | m->insertItem(QObject::tr("Set online",contextName),1); | 309 | m->insertItem(QObject::tr("Set online",contextName),1); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | return m; | 312 | return m; |
313 | } | 313 | } |
314 | 314 | ||
315 | void NNTPviewItem::subscribeGroups() | 315 | void NNTPviewItem::subscribeGroups() |
316 | { | 316 | { |
317 | NNTPGroupsDlg dlg(account); | 317 | NNTPGroupsDlg dlg(account); |
318 | dlg.showMaximized(); | 318 | dlg.showMaximized(); |
319 | if ( dlg.exec()== QDialog::Accepted ){ | 319 | if ( dlg.exec()== QDialog::Accepted ){ |
320 | refresh(); | 320 | refresh(); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void NNTPviewItem::disconnect() | 324 | void NNTPviewItem::disconnect() |
325 | { | 325 | { |
326 | QListViewItem *child = firstChild(); | 326 | QListViewItem *child = firstChild(); |
327 | while ( child ) | 327 | while ( child ) |
328 | { | 328 | { |
329 | QListViewItem *tmp = child; | 329 | QListViewItem *tmp = child; |
330 | child = child->nextSibling(); | 330 | child = child->nextSibling(); |
331 | delete tmp; | 331 | delete tmp; |
332 | } | 332 | } |
333 | wrapper->logout(); | 333 | wrapper->logout(); |
334 | } | 334 | } |
335 | 335 | ||
336 | void NNTPviewItem::setOnOffline() | 336 | void NNTPviewItem::setOnOffline() |
337 | { | 337 | { |
338 | if (!account->getOffline()) | 338 | if (!account->getOffline()) |
339 | { | 339 | { |
340 | disconnect(); | 340 | disconnect(); |
341 | } | 341 | } |
342 | account->setOffline(!account->getOffline()); | 342 | account->setOffline(!account->getOffline()); |
343 | account->save(); | 343 | account->save(); |
344 | //FIXME | 344 | //FIXME |
345 | SETPIX(PIXMAP_POP3FOLDER); | 345 | SETPIX(PIXMAP_POP3FOLDER); |
346 | refresh(); | 346 | refresh(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void NNTPviewItem::contextMenuSelected(int which) | 349 | void NNTPviewItem::contextMenuSelected(int which) |
350 | { | 350 | { |
351 | switch (which) | 351 | switch (which) |
352 | { | 352 | { |
353 | case 0: | 353 | case 0: |
354 | disconnect(); | 354 | disconnect(); |
355 | break; | 355 | break; |
356 | case 1: | 356 | case 1: |
357 | setOnOffline(); | 357 | setOnOffline(); |
358 | break; | 358 | break; |
359 | case 2: | 359 | case 2: |
360 | subscribeGroups(); | 360 | subscribeGroups(); |
361 | break; | 361 | break; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | NNTPfolderItem::~NNTPfolderItem() | 365 | NNTPfolderItem::~NNTPfolderItem() |
366 | {} | 366 | {} |
367 | 367 | ||
368 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 368 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
369 | : AccountViewItem( folderInit, parent,after ) | 369 | : AccountViewItem( folderInit, parent,after ) |
@@ -698,131 +698,130 @@ void IMAPfolderItem::createNewFolder() | |||
698 | QString ndir = ndirdlg.Newdir(); | 698 | QString ndir = ndirdlg.Newdir(); |
699 | bool makesubs = ndirdlg.subpossible(); | 699 | bool makesubs = ndirdlg.subpossible(); |
700 | QString delemiter = Delemiter(); | 700 | QString delemiter = Delemiter(); |
701 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 701 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
702 | { | 702 | { |
703 | imap->refreshFolders(true); | 703 | imap->refreshFolders(true); |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | 707 | ||
708 | void IMAPfolderItem::deleteFolder() | 708 | void IMAPfolderItem::deleteFolder() |
709 | { | 709 | { |
710 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 710 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
711 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 711 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
712 | QObject::tr("Yes",contextName), | 712 | QObject::tr("Yes",contextName), |
713 | QObject::tr("No",contextName),QString::null,1,1); | 713 | QObject::tr("No",contextName),QString::null,1,1); |
714 | 714 | ||
715 | if (yesno == 0) | 715 | if (yesno == 0) |
716 | { | 716 | { |
717 | if (imap->getWrapper()->deleteMbox(folder)) | 717 | if (imap->getWrapper()->deleteMbox(folder)) |
718 | { | 718 | { |
719 | QListView*v=listView(); | 719 | QListView*v=listView(); |
720 | IMAPviewItem * box = imap; | 720 | IMAPviewItem * box = imap; |
721 | /* be carefull - after that this object is destroyd so don't use | 721 | /* be carefull - after that this object is destroyd so don't use |
722 | * any member of it after that call!!*/ | 722 | * any member of it after that call!!*/ |
723 | imap->refreshFolders(true); | 723 | imap->refreshFolders(true); |
724 | if (v) | 724 | if (v) |
725 | { | 725 | { |
726 | v->setSelected(box,true); | 726 | v->setSelected(box,true); |
727 | } | 727 | } |
728 | } | 728 | } |
729 | } | 729 | } |
730 | } | 730 | } |
731 | 731 | ||
732 | void IMAPfolderItem::downloadMails() | 732 | void IMAPfolderItem::downloadMails() |
733 | { | 733 | { |
734 | AccountView*bl = imap->accountView(); | 734 | AccountView*bl = imap->accountView(); |
735 | if (!bl) return; | 735 | if (!bl) return; |
736 | bl->downloadMails(folder,imap->getWrapper()); | 736 | bl->downloadMails(folder,imap->getWrapper()); |
737 | } | 737 | } |
738 | 738 | ||
739 | void IMAPfolderItem::contextMenuSelected(int id) | 739 | void IMAPfolderItem::contextMenuSelected(int id) |
740 | { | 740 | { |
741 | 741 | ||
742 | AccountView * view = (AccountView*)listView(); | 742 | AccountView * view = (AccountView*)listView(); |
743 | switch(id) | 743 | switch(id) |
744 | { | 744 | { |
745 | case 0: | 745 | case 0: |
746 | view->refreshCurrent(); | 746 | view->refreshCurrent(); |
747 | break; | 747 | break; |
748 | case 1: | 748 | case 1: |
749 | deleteAllMail(imap->getWrapper(),folder); | 749 | deleteAllMail(imap->getWrapper(),folder); |
750 | break; | 750 | break; |
751 | case 2: | 751 | case 2: |
752 | createNewFolder(); | 752 | createNewFolder(); |
753 | break; | 753 | break; |
754 | case 3: | 754 | case 3: |
755 | deleteFolder(); | 755 | deleteFolder(); |
756 | break; | 756 | break; |
757 | case 4: | 757 | case 4: |
758 | downloadMails(); | 758 | downloadMails(); |
759 | break; | 759 | break; |
760 | case GET_NEW_MAILS: // daunlood | 760 | case GET_NEW_MAILS: // daunlood |
761 | { | 761 | { |
762 | AccountView*bl = accountView(); | 762 | if (!view) return; |
763 | if (!bl) return; | 763 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); |
764 | bl->downloadMailsInbox(getFolder(),imap->getWrapper()); | ||
765 | } | 764 | } |
766 | break; | 765 | break; |
767 | default: | 766 | default: |
768 | break; | 767 | break; |
769 | } | 768 | } |
770 | } | 769 | } |
771 | 770 | ||
772 | /** | 771 | /** |
773 | * MH Account stuff | 772 | * MH Account stuff |
774 | */ | 773 | */ |
775 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 774 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
776 | POP3 and MBOX */ | 775 | POP3 and MBOX */ |
777 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 776 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
778 | : AccountViewItem( parent ) | 777 | : AccountViewItem( parent ) |
779 | { | 778 | { |
780 | m_Path = aPath; | 779 | m_Path = aPath; |
781 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 780 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
782 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 781 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
783 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 782 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
784 | setText( 0, " Local Folders" ); | 783 | setText( 0, " Local Folders" ); |
785 | setOpen( true ); | 784 | setOpen( true ); |
786 | folder = 0; | 785 | folder = 0; |
787 | } | 786 | } |
788 | 787 | ||
789 | MHviewItem::~MHviewItem() | 788 | MHviewItem::~MHviewItem() |
790 | { | 789 | { |
791 | delete wrapper; | 790 | delete wrapper; |
792 | } | 791 | } |
793 | 792 | ||
794 | AbstractMail *MHviewItem::getWrapper() | 793 | AbstractMail *MHviewItem::getWrapper() |
795 | { | 794 | { |
796 | return wrapper; | 795 | return wrapper; |
797 | } | 796 | } |
798 | 797 | ||
799 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 798 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
800 | { | 799 | { |
801 | refresh(false); | 800 | refresh(false); |
802 | getWrapper()->listMessages( "",target ); | 801 | getWrapper()->listMessages( "",target ); |
803 | } | 802 | } |
804 | 803 | ||
805 | void MHviewItem::refresh(bool force) | 804 | void MHviewItem::refresh(bool force) |
806 | { | 805 | { |
807 | if (childCount()>0 && force==false) return; | 806 | if (childCount()>0 && force==false) return; |
808 | removeChilds(); | 807 | removeChilds(); |
809 | currentFolders.clear(); | 808 | currentFolders.clear(); |
810 | QValueList<FolderP> *folders = wrapper->listFolders(); | 809 | QValueList<FolderP> *folders = wrapper->listFolders(); |
811 | QValueList<FolderP>::ConstIterator it; | 810 | QValueList<FolderP>::ConstIterator it; |
812 | MHfolderItem*item = 0; | 811 | MHfolderItem*item = 0; |
813 | MHfolderItem*pmaster = 0; | 812 | MHfolderItem*pmaster = 0; |
814 | QString fname = ""; | 813 | QString fname = ""; |
815 | int pos; | 814 | int pos; |
816 | for ( it = folders->begin(); it!=folders->end(); ++it) | 815 | for ( it = folders->begin(); it!=folders->end(); ++it) |
817 | { | 816 | { |
818 | fname = (*it)->getDisplayName(); | 817 | fname = (*it)->getDisplayName(); |
819 | /* this folder itself */ | 818 | /* this folder itself */ |
820 | if (fname=="/") | 819 | if (fname=="/") |
821 | { | 820 | { |
822 | currentFolders.append(fname); | 821 | currentFolders.append(fname); |
823 | folder = (*it); | 822 | folder = (*it); |
824 | continue; | 823 | continue; |
825 | } | 824 | } |
826 | currentFolders.append(fname); | 825 | currentFolders.append(fname); |
827 | pos = fname.findRev("/"); | 826 | pos = fname.findRev("/"); |
828 | if (pos > 0) | 827 | if (pos > 0) |
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 8f67566..88545f8 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -143,128 +143,129 @@ void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSma | |||
143 | { | 143 | { |
144 | } | 144 | } |
145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 145 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
146 | { | 146 | { |
147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 147 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
148 | // this is currently re-implemented in pop3wrapper and imapwrapper | 148 | // this is currently re-implemented in pop3wrapper and imapwrapper |
149 | int iii = 0; | 149 | int iii = 0; |
150 | int count = target.count(); | 150 | int count = target.count(); |
151 | QProgressBar wid ( count ); | 151 | QProgressBar wid ( count ); |
152 | wid.setCaption( tr("Deleting ...")); | 152 | wid.setCaption( tr("Deleting ...")); |
153 | wid.show(); | 153 | wid.show(); |
154 | while (iii < count ) { | 154 | while (iii < count ) { |
155 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 155 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
156 | wid.setProgress( iii ); | 156 | wid.setProgress( iii ); |
157 | wid.raise(); | 157 | wid.raise(); |
158 | qApp->processEvents(); | 158 | qApp->processEvents(); |
159 | RecMailP mail = (*target.at( iii )); | 159 | RecMailP mail = (*target.at( iii )); |
160 | deleteMail(mail); | 160 | deleteMail(mail); |
161 | ++iii; | 161 | ++iii; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | 165 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) |
166 | { | 166 | { |
167 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | 167 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); |
168 | // get local folder | 168 | // get local folder |
169 | Account * acc = getAccount(); | 169 | Account * acc = getAccount(); |
170 | if ( !acc ) return; | 170 | if ( !acc ) return; |
171 | QString lfName = acc->getLocalFolder(); | 171 | QString lfName = acc->getLocalFolder(); |
172 | if ( lfName.isEmpty() ) | 172 | if ( lfName.isEmpty() ) |
173 | lfName = acc->getAccountName(); | 173 | lfName = acc->getAccountName(); |
174 | // create local folder | 174 | // create local folder |
175 | if ( !targetMail->createMbox(lfName)) | 175 | if ( !targetMail->createMbox(lfName)) |
176 | { | 176 | { |
177 | QMessageBox::critical(0,tr("Error creating new Folder"), | 177 | QMessageBox::critical(0,tr("Error creating new Folder"), |
178 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | 178 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); |
179 | return; | 179 | return; |
180 | } | 180 | } |
181 | QValueList<RecMailP> t; | 181 | QValueList<RecMailP> t; |
182 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | 182 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); |
183 | if ( t.count() == 0 ) { | 183 | if ( t.count() == 0 ) { |
184 | Global::statusMessage(tr("There are no new messages")); | 184 | Global::statusMessage(tr("There are no new messages")); |
185 | return; | 185 | return; |
186 | } | 186 | } |
187 | QValueList<RecMailP> e; | 187 | QValueList<RecMailP> e; |
188 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | 188 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); |
189 | //qDebug("target has mails %d ", e.count()); | 189 | //qDebug("target has mails %d ", e.count()); |
190 | QValueList<RecMailP> n; | 190 | QValueList<RecMailP> n; |
191 | int iii = 0; | 191 | int iii = 0; |
192 | int count = t.count(); | 192 | int count = t.count(); |
193 | while (iii < count ) { | 193 | while (iii < count ) { |
194 | RecMailP r = (*t.at( iii )); | 194 | RecMailP r = (*t.at( iii )); |
195 | bool found = false; | 195 | bool found = false; |
196 | int jjj = 0; | 196 | int jjj = 0; |
197 | int countE = e.count(); | 197 | int countE = e.count(); |
198 | while (jjj < countE ) { | 198 | while (jjj < countE ) { |
199 | RecMailP re = (*e.at( jjj )); | 199 | RecMailP re = (*e.at( jjj )); |
200 | if ( re->isEqual(r) ) { | 200 | if ( re->isEqual(r) ) { |
201 | found = true; | 201 | found = true; |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | ++jjj; | 204 | ++jjj; |
205 | } | 205 | } |
206 | if ( !found ) { | 206 | if ( !found ) { |
207 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); | ||
207 | n.append( r ); | 208 | n.append( r ); |
208 | } | 209 | } |
209 | ++iii; | 210 | ++iii; |
210 | } | 211 | } |
211 | if ( n.count() == 0 ) { | 212 | if ( n.count() == 0 ) { |
212 | Global::statusMessage(tr("There are no new messages")); | 213 | Global::statusMessage(tr("There are no new messages")); |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | 216 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); |
216 | Global::statusMessage(tr("Downloaded %1 messages").arg(n.count())); | 217 | Global::statusMessage(tr("Downloaded %1 messages").arg(n.count())); |
217 | 218 | ||
218 | #if 0 | 219 | #if 0 |
219 | QValueList<RecMailP> t; | 220 | QValueList<RecMailP> t; |
220 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 221 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
221 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 222 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
222 | #endif | 223 | #endif |
223 | 224 | ||
224 | } | 225 | } |
225 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 226 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
226 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 227 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
227 | { | 228 | { |
228 | QValueList<RecMailP> t; | 229 | QValueList<RecMailP> t; |
229 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 230 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
230 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 231 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
231 | 232 | ||
232 | } | 233 | } |
233 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 234 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
234 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 235 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
235 | { | 236 | { |
236 | encodedString*st = 0; | 237 | encodedString*st = 0; |
237 | int iii = 0; | 238 | int iii = 0; |
238 | int count = t.count(); | 239 | int count = t.count(); |
239 | if ( count == 0 ) | 240 | if ( count == 0 ) |
240 | return; | 241 | return; |
241 | // wel, processevents is qite strange, we need a widget for getting | 242 | // wel, processevents is qite strange, we need a widget for getting |
242 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displaye | 243 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displaye |
243 | 244 | ||
244 | QProgressBar wid ( count ); | 245 | QProgressBar wid ( count ); |
245 | wid.setCaption( tr("Copying ...")); | 246 | wid.setCaption( tr("Copying ...")); |
246 | wid.show(); | 247 | wid.show(); |
247 | while (iii < count ) { | 248 | while (iii < count ) { |
248 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); | 249 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); |
249 | wid.setProgress( iii ); | 250 | wid.setProgress( iii ); |
250 | wid.raise(); | 251 | wid.raise(); |
251 | qApp->processEvents(); | 252 | qApp->processEvents(); |
252 | RecMailP r = (*t.at( iii )); | 253 | RecMailP r = (*t.at( iii )); |
253 | st = fetchRawBody(r); | 254 | st = fetchRawBody(r); |
254 | if (st) { | 255 | if (st) { |
255 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 256 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
256 | delete st; | 257 | delete st; |
257 | } | 258 | } |
258 | ++iii; | 259 | ++iii; |
259 | } | 260 | } |
260 | if (moveit) { | 261 | if (moveit) { |
261 | deleteMailList( t ); | 262 | deleteMailList( t ); |
262 | //deleteAllMail(fromFolder); | 263 | //deleteAllMail(fromFolder); |
263 | } | 264 | } |
264 | } | 265 | } |
265 | 266 | ||
266 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 267 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
267 | { | 268 | { |
268 | encodedString*st = 0; | 269 | encodedString*st = 0; |
269 | st = fetchRawBody(mail); | 270 | st = fetchRawBody(mail); |
270 | if (st) { | 271 | if (st) { |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index c3a1627..d99c6a3 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,146 +1,154 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | 9 | ||
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | bodyCache.clear(); | 15 | bodyCache.clear(); |
16 | m_storage = 0; | 16 | m_storage = 0; |
17 | m_folder = 0; | 17 | m_folder = 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
21 | { | 21 | { |
22 | if (m_folder) { | 22 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
24 | } | 24 | } |
25 | if (m_storage) { | 25 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
27 | } | 27 | } |
28 | cleanMimeCache(); | 28 | cleanMimeCache(); |
29 | } | 29 | } |
30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 31 | { |
32 | static bool init = false ; | 32 | static bool init = false ; |
33 | if ( ! init ) { | 33 | if ( ! init ) { |
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | 34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); |
35 | kon.setGroup("Locale"); | 35 | kon.setGroup("Locale"); |
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | 36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); |
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | 37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); |
38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | 38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); |
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
40 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); | 40 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); |
41 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 41 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
42 | kon.setGroup("Time & Date"); | 42 | kon.setGroup("Time & Date"); |
43 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | 43 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), |
44 | kon.readNumEntry( "DaylightsavingStart", 90), | 44 | kon.readNumEntry( "DaylightsavingStart", 90), |
45 | kon.readNumEntry( "DaylightsavingEnd",304) ); | 45 | kon.readNumEntry( "DaylightsavingEnd",304) ); |
46 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | 46 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); |
47 | 47 | ||
48 | init = true; | 48 | init = true; |
49 | 49 | ||
50 | } | 50 | } |
51 | QDate da (date->dt_year,date->dt_month, date->dt_day ); | 51 | QDate da (date->dt_year,date->dt_month, date->dt_day ); |
52 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); | 52 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); |
53 | QDateTime dt ( da ,ti ); | 53 | QDateTime dt ( da ,ti ); |
54 | int addsec = -date->dt_zone*36; | ||
55 | //qDebug("adsec1 %d ",addsec ); | ||
56 | dt = dt.addSecs( addsec ); | ||
54 | int off = KGlobal::locale()->localTimeOffset( dt ); | 57 | int off = KGlobal::locale()->localTimeOffset( dt ); |
55 | //dt = dt.addSecs( off*60 ); | 58 | //qDebug("adsec2 %d ",off*60 ); |
59 | |||
60 | dt = dt.addSecs( off*60 ); | ||
61 | return dt; | ||
62 | #if 0 | ||
56 | QString ret; | 63 | QString ret; |
57 | if ( da == QDate::currentDate () ) | 64 | if ( dt.date() == QDate::currentDate () ) |
58 | ret = KGlobal::locale()->formatTime( ti,true); | 65 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
59 | 66 | ||
60 | else { | 67 | else { |
61 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 68 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
62 | } | 69 | } |
70 | #endif | ||
63 | #if 0 | 71 | #if 0 |
64 | if ( off < 0 ) | 72 | if ( off < 0 ) |
65 | ret += " -"; | 73 | ret += " -"; |
66 | else | 74 | else |
67 | ret += " +"; | 75 | ret += " +"; |
68 | ret += QString::number( off / 60 ); | 76 | ret += QString::number( off / 60 ); |
69 | ret += "h"; | 77 | ret += "h"; |
70 | #endif | 78 | #endif |
71 | #if 0 | 79 | #if 0 |
72 | char tmp[23]; | 80 | char tmp[23]; |
73 | 81 | ||
74 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 82 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
75 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 83 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
76 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 84 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
77 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 85 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
78 | 86 | ||
79 | 87 | ||
80 | return QString( tmp ); | 88 | return QString( tmp ); |
81 | #endif | 89 | #endif |
82 | return ret; | 90 | //return ret; |
83 | } | 91 | } |
84 | 92 | ||
85 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 93 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
86 | { | 94 | { |
87 | if (!mime) { | 95 | if (!mime) { |
88 | return; | 96 | return; |
89 | } | 97 | } |
90 | mailmime_field*field = 0; | 98 | mailmime_field*field = 0; |
91 | mailmime_single_fields fields; | 99 | mailmime_single_fields fields; |
92 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 100 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
93 | if (mime->mm_mime_fields != NULL) { | 101 | if (mime->mm_mime_fields != NULL) { |
94 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 102 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
95 | mime->mm_content_type); | 103 | mime->mm_content_type); |
96 | } | 104 | } |
97 | 105 | ||
98 | mailmime_content*type = fields.fld_content; | 106 | mailmime_content*type = fields.fld_content; |
99 | clistcell*current; | 107 | clistcell*current; |
100 | if (!type) { | 108 | if (!type) { |
101 | target->setType("text"); | 109 | target->setType("text"); |
102 | target->setSubtype("plain"); | 110 | target->setSubtype("plain"); |
103 | } else { | 111 | } else { |
104 | target->setSubtype(type->ct_subtype); | 112 | target->setSubtype(type->ct_subtype); |
105 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 113 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
106 | case MAILMIME_DISCRETE_TYPE_TEXT: | 114 | case MAILMIME_DISCRETE_TYPE_TEXT: |
107 | target->setType("text"); | 115 | target->setType("text"); |
108 | break; | 116 | break; |
109 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 117 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
110 | target->setType("image"); | 118 | target->setType("image"); |
111 | break; | 119 | break; |
112 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 120 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
113 | target->setType("audio"); | 121 | target->setType("audio"); |
114 | break; | 122 | break; |
115 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 123 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
116 | target->setType("video"); | 124 | target->setType("video"); |
117 | break; | 125 | break; |
118 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 126 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
119 | target->setType("application"); | 127 | target->setType("application"); |
120 | break; | 128 | break; |
121 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 129 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
122 | default: | 130 | default: |
123 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 131 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
124 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 132 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
125 | } | 133 | } |
126 | break; | 134 | break; |
127 | } | 135 | } |
128 | if (type->ct_parameters) { | 136 | if (type->ct_parameters) { |
129 | fillParameters(target,type->ct_parameters); | 137 | fillParameters(target,type->ct_parameters); |
130 | } | 138 | } |
131 | } | 139 | } |
132 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 140 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
133 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 141 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
134 | field = (mailmime_field*)current->data; | 142 | field = (mailmime_field*)current->data; |
135 | switch(field->fld_type) { | 143 | switch(field->fld_type) { |
136 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 144 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
137 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 145 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
138 | break; | 146 | break; |
139 | case MAILMIME_FIELD_ID: | 147 | case MAILMIME_FIELD_ID: |
140 | target->setIdentifier(field->fld_data.fld_id); | 148 | target->setIdentifier(field->fld_data.fld_id); |
141 | break; | 149 | break; |
142 | case MAILMIME_FIELD_DESCRIPTION: | 150 | case MAILMIME_FIELD_DESCRIPTION: |
143 | target->setDescription(field->fld_data.fld_description); | 151 | target->setDescription(field->fld_data.fld_description); |
144 | break; | 152 | break; |
145 | default: | 153 | default: |
146 | break; | 154 | break; |
@@ -434,100 +442,107 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | |||
434 | } | 442 | } |
435 | if (h.length()>0) { | 443 | if (h.length()>0) { |
436 | res.append(h); | 444 | res.append(h); |
437 | } | 445 | } |
438 | } | 446 | } |
439 | return res; | 447 | return res; |
440 | } | 448 | } |
441 | 449 | ||
442 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) | 450 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) |
443 | { | 451 | { |
444 | int r; | 452 | int r; |
445 | mailmessage_list * env_list = 0; | 453 | mailmessage_list * env_list = 0; |
446 | r = mailsession_get_messages_list(session,&env_list); | 454 | r = mailsession_get_messages_list(session,&env_list); |
447 | if (r != MAIL_NO_ERROR) { | 455 | if (r != MAIL_NO_ERROR) { |
448 | ; // odebug << "Error message list" << oendl; | 456 | ; // odebug << "Error message list" << oendl; |
449 | return; | 457 | return; |
450 | } | 458 | } |
451 | r = mailsession_get_envelopes_list(session, env_list); | 459 | r = mailsession_get_envelopes_list(session, env_list); |
452 | if (r != MAIL_NO_ERROR) { | 460 | if (r != MAIL_NO_ERROR) { |
453 | ; // odebug << "Error filling message list" << oendl; | 461 | ; // odebug << "Error filling message list" << oendl; |
454 | if (env_list) { | 462 | if (env_list) { |
455 | mailmessage_list_free(env_list); | 463 | mailmessage_list_free(env_list); |
456 | } | 464 | } |
457 | return; | 465 | return; |
458 | } | 466 | } |
459 | mailimf_references * refs = 0; | 467 | mailimf_references * refs = 0; |
460 | mailimf_in_reply_to * in_replies = 0; | 468 | mailimf_in_reply_to * in_replies = 0; |
461 | uint32_t i = 0; | 469 | uint32_t i = 0; |
462 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 470 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
463 | mailmessage * msg; | 471 | mailmessage * msg; |
464 | QBitArray mFlags(7); | 472 | QBitArray mFlags(7); |
465 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 473 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
466 | if (msg->msg_fields == NULL) { | 474 | if (msg->msg_fields == NULL) { |
467 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; | 475 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; |
468 | continue; | 476 | continue; |
469 | } | 477 | } |
470 | RecMailP mail = new RecMail(); | 478 | RecMailP mail = new RecMail(); |
471 | mail->setWrapper(this); | 479 | mail->setWrapper(this); |
472 | mail_flags * flag_result = 0; | 480 | mail_flags * flag_result = 0; |
473 | r = mailmessage_get_flags(msg,&flag_result); | 481 | r = mailmessage_get_flags(msg,&flag_result); |
474 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 482 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
475 | mFlags.setBit(FLAG_SEEN); | 483 | mFlags.setBit(FLAG_SEEN); |
476 | } | 484 | } |
477 | mailimf_single_fields single_fields; | 485 | mailimf_single_fields single_fields; |
478 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 486 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
479 | mail->setMsgsize(msg->msg_size); | 487 | mail->setMsgsize(msg->msg_size); |
480 | mail->setFlags(mFlags); | 488 | mail->setFlags(mFlags); |
481 | mail->setMbox(mailbox); | 489 | mail->setMbox(mailbox); |
482 | mail->setNumber(msg->msg_index); | 490 | mail->setNumber(msg->msg_index); |
483 | if (single_fields.fld_subject) | 491 | if (single_fields.fld_subject) |
484 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 492 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
485 | if (single_fields.fld_from) | 493 | if (single_fields.fld_from) |
486 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 494 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
487 | if (!mbox_as_to) { | 495 | if (!mbox_as_to) { |
488 | if (single_fields.fld_to) | 496 | if (single_fields.fld_to) |
489 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 497 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
490 | } else { | 498 | } else { |
491 | mail->setTo(mailbox); | 499 | mail->setTo(mailbox); |
492 | } | 500 | } |
493 | if (single_fields.fld_cc) | 501 | if (single_fields.fld_cc) |
494 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 502 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
495 | if (single_fields.fld_bcc) | 503 | if (single_fields.fld_bcc) |
496 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 504 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
497 | if (single_fields.fld_orig_date) { | 505 | if (single_fields.fld_orig_date) { |
498 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 506 | QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); |
499 | char tmp[23]; | 507 | QString ret; |
500 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; | 508 | if ( dt.date() == QDate::currentDate () ) |
501 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | 509 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
502 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 510 | else { |
511 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | ||
512 | } | ||
513 | mail->setDate( ret ); | ||
514 | char tmp[20]; | ||
515 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | ||
516 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | ||
517 | //qDebug(" iso %s ", tmp); | ||
503 | mail->setIsoDate( QString( tmp ) ); | 518 | mail->setIsoDate( QString( tmp ) ); |
504 | } | 519 | } |
505 | // crashes when accessing pop3 account? | 520 | // crashes when accessing pop3 account? |
506 | if (single_fields.fld_message_id) { | 521 | if (single_fields.fld_message_id) { |
507 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 522 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
508 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 523 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
509 | } | 524 | } |
510 | if (single_fields.fld_reply_to) { | 525 | if (single_fields.fld_reply_to) { |
511 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 526 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
512 | if (t.count()>0) { | 527 | if (t.count()>0) { |
513 | mail->setReplyto(t[0]); | 528 | mail->setReplyto(t[0]); |
514 | } | 529 | } |
515 | } | 530 | } |
516 | #if 0 | 531 | #if 0 |
517 | refs = single_fields.fld_references; | 532 | refs = single_fields.fld_references; |
518 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 533 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
519 | char * text = (char*)refs->mid_list->first->data; | 534 | char * text = (char*)refs->mid_list->first->data; |
520 | mail->setReplyto(QString(text)); | 535 | mail->setReplyto(QString(text)); |
521 | } | 536 | } |
522 | #endif | 537 | #endif |
523 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 538 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
524 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 539 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
525 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 540 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
526 | } | 541 | } |
527 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) | 542 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) |
528 | target.append(mail); | 543 | target.append(mail); |
529 | } | 544 | } |
530 | if (env_list) { | 545 | if (env_list) { |
531 | mailmessage_list_free(env_list); | 546 | mailmessage_list_free(env_list); |
532 | } | 547 | } |
533 | } | 548 | } |
diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h index 244212f..c35a6da 100644 --- a/kmicromail/libmailwrapper/genericwrapper.h +++ b/kmicromail/libmailwrapper/genericwrapper.h | |||
@@ -1,68 +1,68 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __GENERIC_WRAPPER_H | 2 | #ifndef __GENERIC_WRAPPER_H |
3 | #define __GENERIC_WRAPPER_H | 3 | #define __GENERIC_WRAPPER_H |
4 | 4 | ||
5 | #include "abstractmail.h" | 5 | #include "abstractmail.h" |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | class RecMail; | 10 | class RecMail; |
11 | class RecBody; | 11 | class RecBody; |
12 | class encodedString; | 12 | class encodedString; |
13 | struct mailpop3; | 13 | struct mailpop3; |
14 | struct mailmessage; | 14 | struct mailmessage; |
15 | struct mailmime; | 15 | struct mailmime; |
16 | struct mailmime_mechanism; | 16 | struct mailmime_mechanism; |
17 | struct mailimf_mailbox_list; | 17 | struct mailimf_mailbox_list; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailimf_date_time; | 19 | struct mailimf_date_time; |
20 | struct mailimf_group; | 20 | struct mailimf_group; |
21 | struct mailimf_address_list; | 21 | struct mailimf_address_list; |
22 | struct mailsession; | 22 | struct mailsession; |
23 | struct mailstorage; | 23 | struct mailstorage; |
24 | struct mailfolder; | 24 | struct mailfolder; |
25 | struct mailimf_in_reply_to; | 25 | struct mailimf_in_reply_to; |
26 | 26 | ||
27 | /* this class hold just the funs shared between | 27 | /* this class hold just the funs shared between |
28 | * mbox and pop3 (later mh, too) mail access. | 28 | * mbox and pop3 (later mh, too) mail access. |
29 | * it is not desigend to make a instance of it! | 29 | * it is not desigend to make a instance of it! |
30 | */ | 30 | */ |
31 | class Genericwrapper : public AbstractMail | 31 | class Genericwrapper : public AbstractMail |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | Genericwrapper(); | 35 | Genericwrapper(); |
36 | virtual ~Genericwrapper(); | 36 | virtual ~Genericwrapper(); |
37 | 37 | ||
38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 38 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 39 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
41 | virtual void cleanMimeCache(); | 41 | virtual void cleanMimeCache(); |
42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} | 42 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} |
43 | virtual void logout(){}; | 43 | virtual void logout(){}; |
44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 44 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
45 | static QString parseDateTime( mailimf_date_time *date ); | 45 | static const QDateTime parseDateTime( mailimf_date_time *date ); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | RecBodyP parseMail( mailmessage * msg ); | 48 | RecBodyP parseMail( mailmessage * msg ); |
49 | QString parseMailboxList( mailimf_mailbox_list *list ); | 49 | QString parseMailboxList( mailimf_mailbox_list *list ); |
50 | QString parseMailbox( mailimf_mailbox *box ); | 50 | QString parseMailbox( mailimf_mailbox *box ); |
51 | QString parseGroup( mailimf_group *group ); | 51 | QString parseGroup( mailimf_group *group ); |
52 | QString parseAddressList( mailimf_address_list *list ); | 52 | QString parseAddressList( mailimf_address_list *list ); |
53 | 53 | ||
54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 54 | void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); | 55 | static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); |
56 | static void fillParameters(RecPartP&target,clist*parameters); | 56 | static void fillParameters(RecPartP&target,clist*parameters); |
57 | static QString getencoding(mailmime_mechanism*aEnc); | 57 | static QString getencoding(mailmime_mechanism*aEnc); |
58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); | 58 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); |
59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 59 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); |
60 | 60 | ||
61 | QString msgTempName; | 61 | QString msgTempName; |
62 | unsigned int last_msg_id; | 62 | unsigned int last_msg_id; |
63 | QMap<QString,encodedString*> bodyCache; | 63 | QMap<QString,encodedString*> bodyCache; |
64 | mailstorage * m_storage; | 64 | mailstorage * m_storage; |
65 | mailfolder*m_folder; | 65 | mailfolder*m_folder; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | #endif | 68 | #endif |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index d79df4f..b0dd1b8 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,74 +1,75 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | ||
11 | 12 | ||
12 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
13 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
14 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
15 | 16 | ||
16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
17 | : AbstractMail() | 18 | : AbstractMail() |
18 | { | 19 | { |
19 | account = a; | 20 | account = a; |
20 | m_imap = 0; | 21 | m_imap = 0; |
21 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
22 | mCurrent = 0; | 23 | mCurrent = 0; |
23 | mMax = 0; | 24 | mMax = 0; |
24 | } | 25 | } |
25 | 26 | ||
26 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
27 | { | 28 | { |
28 | logout(); | 29 | logout(); |
29 | } | 30 | } |
30 | 31 | ||
31 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
32 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
33 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
34 | { | 35 | { |
35 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
36 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
37 | } | 38 | } |
38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
39 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
40 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
41 | return err; | 42 | return err; |
42 | } | 43 | } |
43 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
44 | return err; | 45 | return err; |
45 | } | 46 | } |
46 | 47 | ||
47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
48 | { | 49 | { |
49 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
51 | //qApp->processEvents() | 52 | //qApp->processEvents() |
52 | static int last = 0; | 53 | static int last = 0; |
53 | if ( last != current ) | 54 | if ( last != current ) |
54 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
55 | last = current; | 56 | last = current; |
56 | } | 57 | } |
57 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
58 | { | 59 | { |
59 | 60 | ||
60 | static QString mProgrMess; | 61 | static QString mProgrMess; |
61 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
62 | mProgrMess = m; | 63 | mProgrMess = m; |
63 | mCurrent = 0; | 64 | mCurrent = 0; |
64 | return; | 65 | return; |
65 | } | 66 | } |
66 | QString mess; | 67 | QString mess; |
67 | //qDebug("progress "); | 68 | //qDebug("progress "); |
68 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); |
69 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); |
70 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
71 | qApp->processEvents(); | 72 | qApp->processEvents(); |
72 | } | 73 | } |
73 | bool IMAPwrapper::start_tls(bool force_tls) | 74 | bool IMAPwrapper::start_tls(bool force_tls) |
74 | { | 75 | { |
@@ -404,132 +405,140 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
404 | return m; | 405 | return m; |
405 | } | 406 | } |
406 | m = new RecMail(); | 407 | m = new RecMail(); |
407 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 408 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
408 | current = c; | 409 | current = c; |
409 | size = 0; | 410 | size = 0; |
410 | item = (mailimap_msg_att_item*)current->data; | 411 | item = (mailimap_msg_att_item*)current->data; |
411 | if ( !item ) | 412 | if ( !item ) |
412 | continue; | 413 | continue; |
413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 414 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 415 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
415 | if (!flist || !flist->att_list) { | 416 | if (!flist || !flist->att_list) { |
416 | continue; | 417 | continue; |
417 | } | 418 | } |
418 | cf = flist->att_list->first; | 419 | cf = flist->att_list->first; |
419 | if( ! cf ) | 420 | if( ! cf ) |
420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 421 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
421 | cflag = (mailimap_flag_fetch*)cf->data; | 422 | cflag = (mailimap_flag_fetch*)cf->data; |
422 | if( ! cflag ) | 423 | if( ! cflag ) |
423 | qDebug("imap:not cflag "); | 424 | qDebug("imap:not cflag "); |
424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 425 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
425 | switch (cflag->fl_flag->fl_type) { | 426 | switch (cflag->fl_flag->fl_type) { |
426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 427 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
427 | mFlags.setBit(FLAG_ANSWERED); | 428 | mFlags.setBit(FLAG_ANSWERED); |
428 | break; | 429 | break; |
429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 430 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
430 | mFlags.setBit(FLAG_FLAGGED); | 431 | mFlags.setBit(FLAG_FLAGGED); |
431 | break; | 432 | break; |
432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 433 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
433 | mFlags.setBit(FLAG_DELETED); | 434 | mFlags.setBit(FLAG_DELETED); |
434 | break; | 435 | break; |
435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 436 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
436 | mFlags.setBit(FLAG_SEEN); | 437 | mFlags.setBit(FLAG_SEEN); |
437 | break; | 438 | break; |
438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 439 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
439 | mFlags.setBit(FLAG_DRAFT); | 440 | mFlags.setBit(FLAG_DRAFT); |
440 | break; | 441 | break; |
441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 442 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
442 | break; | 443 | break; |
443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 444 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
444 | break; | 445 | break; |
445 | default: | 446 | default: |
446 | break; | 447 | break; |
447 | } | 448 | } |
448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 449 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
449 | mFlags.setBit(FLAG_RECENT); | 450 | mFlags.setBit(FLAG_RECENT); |
450 | } | 451 | } |
451 | } | 452 | } |
452 | continue; | 453 | continue; |
453 | } | 454 | } |
454 | if ( item->att_data.att_static == NULL ) | 455 | if ( item->att_data.att_static == NULL ) |
455 | continue; | 456 | continue; |
456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 457 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 458 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
458 | if ( head == NULL ) | 459 | if ( head == NULL ) |
459 | continue; | 460 | continue; |
460 | if ( head->env_date != NULL ) { | 461 | if ( head->env_date != NULL ) { |
461 | m->setDate(head->env_date); | 462 | m->setDate(head->env_date); |
462 | struct mailimf_date_time result; | 463 | struct mailimf_date_time result; |
463 | struct mailimf_date_time* date = &result; | 464 | struct mailimf_date_time* date = &result; |
464 | struct mailimf_date_time **re = &date; | 465 | struct mailimf_date_time **re = &date; |
465 | size_t length = m->getDate().length(); | 466 | size_t length = m->getDate().length(); |
466 | size_t index = 0; | 467 | size_t index = 0; |
467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 468 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
468 | m->setDate( Genericwrapper::parseDateTime( date ) ); | 469 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
469 | char tmp[23]; | 470 | QString ret; |
470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | 471 | if ( dt.date() == QDate::currentDate () ) |
471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 472 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
473 | else { | ||
474 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | ||
475 | } | ||
476 | m->setDate( ret ); | ||
477 | char tmp[20]; | ||
478 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | ||
479 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | ||
480 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | ||
472 | m->setIsoDate( QString( tmp ) ); | 481 | m->setIsoDate( QString( tmp ) ); |
473 | } else { | 482 | } else { |
474 | m->setIsoDate(head->env_date); | 483 | m->setIsoDate(head->env_date); |
475 | } | 484 | } |
476 | } | 485 | } |
477 | if ( head->env_subject != NULL ) | 486 | if ( head->env_subject != NULL ) |
478 | m->setSubject(convert_String((const char*)head->env_subject)); | 487 | m->setSubject(convert_String((const char*)head->env_subject)); |
479 | //m->setSubject(head->env_subject); | 488 | //m->setSubject(head->env_subject); |
480 | if (head->env_from!=NULL) { | 489 | if (head->env_from!=NULL) { |
481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 490 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
482 | if (addresslist.count()) { | 491 | if (addresslist.count()) { |
483 | m->setFrom(addresslist.first()); | 492 | m->setFrom(addresslist.first()); |
484 | } | 493 | } |
485 | } | 494 | } |
486 | if (head->env_to!=NULL) { | 495 | if (head->env_to!=NULL) { |
487 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 496 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
488 | m->setTo(addresslist); | 497 | m->setTo(addresslist); |
489 | } | 498 | } |
490 | if (head->env_cc!=NULL) { | 499 | if (head->env_cc!=NULL) { |
491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 500 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
492 | m->setCC(addresslist); | 501 | m->setCC(addresslist); |
493 | } | 502 | } |
494 | if (head->env_bcc!=NULL) { | 503 | if (head->env_bcc!=NULL) { |
495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 504 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
496 | m->setBcc(addresslist); | 505 | m->setBcc(addresslist); |
497 | } | 506 | } |
498 | /* reply to address, eg. email. */ | 507 | /* reply to address, eg. email. */ |
499 | if (head->env_reply_to!=NULL) { | 508 | if (head->env_reply_to!=NULL) { |
500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 509 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
501 | if (addresslist.count()) { | 510 | if (addresslist.count()) { |
502 | m->setReplyto(addresslist.first()); | 511 | m->setReplyto(addresslist.first()); |
503 | } | 512 | } |
504 | } | 513 | } |
505 | if (head->env_in_reply_to!=NULL) { | 514 | if (head->env_in_reply_to!=NULL) { |
506 | QString h(head->env_in_reply_to); | 515 | QString h(head->env_in_reply_to); |
507 | while (h.length()>0 && h[0]=='<') { | 516 | while (h.length()>0 && h[0]=='<') { |
508 | h.remove(0,1); | 517 | h.remove(0,1); |
509 | } | 518 | } |
510 | while (h.length()>0 && h[h.length()-1]=='>') { | 519 | while (h.length()>0 && h[h.length()-1]=='>') { |
511 | h.remove(h.length()-1,1); | 520 | h.remove(h.length()-1,1); |
512 | } | 521 | } |
513 | if (h.length()>0) { | 522 | if (h.length()>0) { |
514 | m->setInreply(QStringList(h)); | 523 | m->setInreply(QStringList(h)); |
515 | } | 524 | } |
516 | } | 525 | } |
517 | if (head->env_message_id != NULL) { | 526 | if (head->env_message_id != NULL) { |
518 | m->setMsgid(QString(head->env_message_id)); | 527 | m->setMsgid(QString(head->env_message_id)); |
519 | } | 528 | } |
520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 529 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
521 | #if 0 | 530 | #if 0 |
522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 531 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 532 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
524 | qDebug("time %s ",da.toString().latin1() ); | 533 | qDebug("time %s ",da.toString().latin1() ); |
525 | #endif | 534 | #endif |
526 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 535 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
527 | size = item->att_data.att_static->att_data.att_rfc822_size; | 536 | size = item->att_data.att_static->att_data.att_rfc822_size; |
528 | } | 537 | } |
529 | } | 538 | } |
530 | /* msg is already deleted */ | 539 | /* msg is already deleted */ |
531 | if (mFlags.testBit(FLAG_DELETED) && m) { | 540 | if (mFlags.testBit(FLAG_DELETED) && m) { |
532 | delete m; | 541 | delete m; |
533 | m = 0; | 542 | m = 0; |
534 | } | 543 | } |
535 | if (m) { | 544 | if (m) { |
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index 1a4ffd1..af3b9d0 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -1,109 +1,115 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | //#include <opie2/odebug.h> | 3 | //#include <opie2/odebug.h> |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | 6 | ||
7 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 8 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
10 | { | 10 | { |
11 | init(); | 11 | init(); |
12 | } | 12 | } |
13 | 13 | ||
14 | RecMail::RecMail(const RecMail&old) | 14 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
16 | { | 16 | { |
17 | init(); | 17 | init(); |
18 | copy_old(old); | 18 | copy_old(old); |
19 | // odebug << "Copy constructor RecMail" << oendl; | 19 | // odebug << "Copy constructor RecMail" << oendl; |
20 | } | 20 | } |
21 | 21 | ||
22 | RecMail::~RecMail() | 22 | RecMail::~RecMail() |
23 | { | 23 | { |
24 | wrapper = 0; | 24 | wrapper = 0; |
25 | } | 25 | } |
26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) | 26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) |
27 | { | 27 | { |
28 | if ( s1.isEmpty() && s2.isEmpty() ) | 28 | if ( s1.isEmpty() && s2.isEmpty() ) |
29 | return true; | 29 | return true; |
30 | return s1 == s2; | 30 | return s1 == s2; |
31 | } | 31 | } |
32 | 32 | ||
33 | bool RecMail::isEqual( RecMail* r1 ) | 33 | bool RecMail::isEqual( RecMail* r1 ) |
34 | { | 34 | { |
35 | if ( !stringCompareRec( isodate, r1->isodate ) ) { | 35 | if ( !stringCompareRec( isodate, r1->isodate ) ) { |
36 | // qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | 36 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); |
37 | return false; | 37 | return false; |
38 | } | 38 | } |
39 | if ( !stringCompareRec( from, r1->from ) ) { | 39 | if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { |
40 | //qDebug("from *%s* *%s* ", from.latin1(), r1->from.latin1()); | 40 | //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); |
41 | return false; | 41 | return false; |
42 | } | 42 | } |
43 | if ( !stringCompareRec( subject, r1->subject ) ) { | 43 | |
44 | //qDebug("sub "); | 44 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); |
45 | return false; | 45 | if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { |
46 | if ( r1->from.find ( from ) < 0 ) { | ||
47 | if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { | ||
48 | //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); | ||
49 | return false; | ||
50 | } | ||
51 | } | ||
46 | } | 52 | } |
47 | 53 | ||
48 | return true; | 54 | return true; |
49 | } | 55 | } |
50 | void RecMail::copy_old(const RecMail&old) | 56 | void RecMail::copy_old(const RecMail&old) |
51 | { | 57 | { |
52 | subject = old.subject; | 58 | subject = old.subject; |
53 | date = old.date; | 59 | date = old.date; |
54 | mbox = old.mbox; | 60 | mbox = old.mbox; |
55 | msg_id = old.msg_id; | 61 | msg_id = old.msg_id; |
56 | msg_size = old.msg_size; | 62 | msg_size = old.msg_size; |
57 | msg_number = old.msg_number; | 63 | msg_number = old.msg_number; |
58 | from = old.from; | 64 | from = old.from; |
59 | msg_flags = old.msg_flags; | 65 | msg_flags = old.msg_flags; |
60 | to = old.to; | 66 | to = old.to; |
61 | cc = old.cc; | 67 | cc = old.cc; |
62 | bcc = old.bcc; | 68 | bcc = old.bcc; |
63 | wrapper = old.wrapper; | 69 | wrapper = old.wrapper; |
64 | in_reply_to = old.in_reply_to; | 70 | in_reply_to = old.in_reply_to; |
65 | references = old.references; | 71 | references = old.references; |
66 | replyto = old.replyto; | 72 | replyto = old.replyto; |
67 | } | 73 | } |
68 | 74 | ||
69 | void RecMail::init() | 75 | void RecMail::init() |
70 | { | 76 | { |
71 | to.clear(); | 77 | to.clear(); |
72 | cc.clear(); | 78 | cc.clear(); |
73 | bcc.clear(); | 79 | bcc.clear(); |
74 | in_reply_to.clear(); | 80 | in_reply_to.clear(); |
75 | references.clear(); | 81 | references.clear(); |
76 | wrapper = 0; | 82 | wrapper = 0; |
77 | } | 83 | } |
78 | 84 | ||
79 | void RecMail::setWrapper(AbstractMail*awrapper) | 85 | void RecMail::setWrapper(AbstractMail*awrapper) |
80 | { | 86 | { |
81 | wrapper = awrapper; | 87 | wrapper = awrapper; |
82 | } | 88 | } |
83 | 89 | ||
84 | AbstractMail* RecMail::Wrapper() | 90 | AbstractMail* RecMail::Wrapper() |
85 | { | 91 | { |
86 | return wrapper; | 92 | return wrapper; |
87 | } | 93 | } |
88 | 94 | ||
89 | void RecMail::setTo(const QStringList&list) | 95 | void RecMail::setTo(const QStringList&list) |
90 | { | 96 | { |
91 | to = list; | 97 | to = list; |
92 | } | 98 | } |
93 | 99 | ||
94 | const QStringList&RecMail::To()const | 100 | const QStringList&RecMail::To()const |
95 | { | 101 | { |
96 | return to; | 102 | return to; |
97 | } | 103 | } |
98 | 104 | ||
99 | void RecMail::setCC(const QStringList&list) | 105 | void RecMail::setCC(const QStringList&list) |
100 | { | 106 | { |
101 | cc = list; | 107 | cc = list; |
102 | } | 108 | } |
103 | 109 | ||
104 | const QStringList&RecMail::CC()const | 110 | const QStringList&RecMail::CC()const |
105 | { | 111 | { |
106 | return cc; | 112 | return cc; |
107 | } | 113 | } |
108 | 114 | ||
109 | void RecMail::setBcc(const QStringList&list) | 115 | void RecMail::setBcc(const QStringList&list) |
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index 020278d..c1c1a74 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h | |||
@@ -12,131 +12,133 @@ | |||
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | 18 | ||
19 | class AbstractMail; | 19 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 21 | /* Attention! |
22 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 28 | So there is no interface "const QString&body()" but you should |
29 | make a request to the mailwrapper with this class as parameter to | 29 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
31 | */ | 31 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 32 | class RecMail:public Opie::Core::ORefCount |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RecMail(); | 35 | RecMail(); |
36 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
38 | bool isEqual( RecMail* r1 ); | 38 | bool isEqual( RecMail* r1 ); |
39 | 39 | ||
40 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
41 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
42 | const QString&getDate()const{ return date; } | 42 | const QString&getDate()const{ return date; } |
43 | void setDate( const QString&a ) { date = a; } | 43 | void setDate( const QString&a ) { date = a; } |
44 | const QString&getIsoDate()const{ return isodate; } | 44 | const QString&getIsoDate()const{ return isodate; } |
45 | void setIsoDate( const QString&a ) { isodate = a; } | 45 | void setIsoDate( const QString&a ) { isodate = a; } |
46 | const QString&getFrom()const{ return from; } | 46 | const QString&getFrom()const{ return from; } |
47 | void setFrom( const QString&a ) { from = a; } | 47 | void setFrom( const QString&a ) { from = a; } |
48 | const QString&getSubject()const { return subject; } | 48 | const QString&getSubject()const { return subject; } |
49 | void setSubject( const QString&s ) { subject = s; } | 49 | void setSubject( const QString&s ) { subject = s; } |
50 | const QString&getMbox()const{return mbox;} | 50 | const QString&getMbox()const{return mbox;} |
51 | void setMbox(const QString&box){mbox = box;} | 51 | void setMbox(const QString&box){mbox = box;} |
52 | void setMsgid(const QString&id){msg_id=id;} | 52 | void setMsgid(const QString&id){msg_id=id;} |
53 | const QString&Msgid()const{return msg_id;} | 53 | const QString&Msgid()const{return msg_id;} |
54 | void setReplyto(const QString&reply){replyto=reply;} | 54 | void setReplyto(const QString&reply){replyto=reply;} |
55 | const QString&Replyto()const{return replyto;} | 55 | const QString&Replyto()const{return replyto;} |
56 | void setMsgsize(unsigned int size){msg_size = size;} | 56 | void setMsgsize(unsigned int size){msg_size = size;} |
57 | const unsigned int Msgsize()const{return msg_size;} | 57 | const unsigned int Msgsize()const{return msg_size;} |
58 | 58 | ||
59 | 59 | ||
60 | void setTo(const QStringList&list); | 60 | void setTo(const QStringList&list); |
61 | const QStringList&To()const; | 61 | const QStringList&To()const; |
62 | void setCC(const QStringList&list); | 62 | void setCC(const QStringList&list); |
63 | const QStringList&CC()const; | 63 | const QStringList&CC()const; |
64 | void setBcc(const QStringList&list); | 64 | void setBcc(const QStringList&list); |
65 | const QStringList&Bcc()const; | 65 | const QStringList&Bcc()const; |
66 | void setInreply(const QStringList&list); | 66 | void setInreply(const QStringList&list); |
67 | const QStringList&Inreply()const; | 67 | const QStringList&Inreply()const; |
68 | void setReferences(const QStringList&list); | 68 | void setReferences(const QStringList&list); |
69 | const QStringList&References()const; | 69 | const QStringList&References()const; |
70 | 70 | ||
71 | const QBitArray&getFlags()const{return msg_flags;} | 71 | const QBitArray&getFlags()const{return msg_flags;} |
72 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 72 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
73 | 73 | ||
74 | void setWrapper(AbstractMail*wrapper); | 74 | void setWrapper(AbstractMail*wrapper); |
75 | AbstractMail* Wrapper(); | 75 | AbstractMail* Wrapper(); |
76 | // public for debugging | ||
77 | QString subject,date,isodate,from,mbox,msg_id,replyto; | ||
76 | 78 | ||
77 | protected: | 79 | protected: |
78 | QString subject,date,isodate,from,mbox,msg_id,replyto; | 80 | //QString subject,date,isodate,from,mbox,msg_id,replyto; |
79 | unsigned int msg_number,msg_size; | 81 | unsigned int msg_number,msg_size; |
80 | QBitArray msg_flags; | 82 | QBitArray msg_flags; |
81 | QStringList to,cc,bcc,in_reply_to,references; | 83 | QStringList to,cc,bcc,in_reply_to,references; |
82 | AbstractMail*wrapper; | 84 | AbstractMail*wrapper; |
83 | void init(); | 85 | void init(); |
84 | void copy_old(const RecMail&old); | 86 | void copy_old(const RecMail&old); |
85 | }; | 87 | }; |
86 | 88 | ||
87 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 89 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
88 | typedef QMap<QString,QString> part_plist_t; | 90 | typedef QMap<QString,QString> part_plist_t; |
89 | 91 | ||
90 | class RecPart:public Opie::Core::ORefCount | 92 | class RecPart:public Opie::Core::ORefCount |
91 | { | 93 | { |
92 | protected: | 94 | protected: |
93 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 95 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
94 | unsigned int m_lines,m_size; | 96 | unsigned int m_lines,m_size; |
95 | part_plist_t m_Parameters; | 97 | part_plist_t m_Parameters; |
96 | /* describes the position in the mail */ | 98 | /* describes the position in the mail */ |
97 | QValueList<int> m_poslist; | 99 | QValueList<int> m_poslist; |
98 | 100 | ||
99 | public: | 101 | public: |
100 | RecPart(); | 102 | RecPart(); |
101 | RecPart(const RecPart&); | 103 | RecPart(const RecPart&); |
102 | virtual ~RecPart(); | 104 | virtual ~RecPart(); |
103 | 105 | ||
104 | const QString&Type()const; | 106 | const QString&Type()const; |
105 | void setType(const QString&type); | 107 | void setType(const QString&type); |
106 | const QString&Subtype()const; | 108 | const QString&Subtype()const; |
107 | void setSubtype(const QString&subtype); | 109 | void setSubtype(const QString&subtype); |
108 | const QString&Identifier()const; | 110 | const QString&Identifier()const; |
109 | void setIdentifier(const QString&identifier); | 111 | void setIdentifier(const QString&identifier); |
110 | const QString&Encoding()const; | 112 | const QString&Encoding()const; |
111 | void setEncoding(const QString&encoding); | 113 | void setEncoding(const QString&encoding); |
112 | const QString&Description()const; | 114 | const QString&Description()const; |
113 | void setDescription(const QString&desc); | 115 | void setDescription(const QString&desc); |
114 | void setLines(unsigned int lines); | 116 | void setLines(unsigned int lines); |
115 | const unsigned int Lines()const; | 117 | const unsigned int Lines()const; |
116 | void setSize(unsigned int size); | 118 | void setSize(unsigned int size); |
117 | const unsigned int Size()const; | 119 | const unsigned int Size()const; |
118 | 120 | ||
119 | 121 | ||
120 | void setParameters(const part_plist_t&list); | 122 | void setParameters(const part_plist_t&list); |
121 | const part_plist_t&Parameters()const; | 123 | const part_plist_t&Parameters()const; |
122 | void addParameter(const QString&key,const QString&value); | 124 | void addParameter(const QString&key,const QString&value); |
123 | const QString searchParamter(const QString&key)const; | 125 | const QString searchParamter(const QString&key)const; |
124 | void setPositionlist(const QValueList<int>&poslist); | 126 | void setPositionlist(const QValueList<int>&poslist); |
125 | const QValueList<int>& Positionlist()const; | 127 | const QValueList<int>& Positionlist()const; |
126 | }; | 128 | }; |
127 | 129 | ||
128 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; | 130 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; |
129 | 131 | ||
130 | class RecBody:public Opie::Core::ORefCount | 132 | class RecBody:public Opie::Core::ORefCount |
131 | { | 133 | { |
132 | protected: | 134 | protected: |
133 | QString m_BodyText; | 135 | QString m_BodyText; |
134 | QValueList<RecPartP> m_PartsList; | 136 | QValueList<RecPartP> m_PartsList; |
135 | RecPartP m_description; | 137 | RecPartP m_description; |
136 | 138 | ||
137 | public: | 139 | public: |
138 | RecBody(); | 140 | RecBody(); |
139 | RecBody(const RecBody&old); | 141 | RecBody(const RecBody&old); |
140 | virtual ~RecBody(); | 142 | virtual ~RecBody(); |
141 | void setBodytext(const QString&); | 143 | void setBodytext(const QString&); |
142 | const QString& Bodytext()const; | 144 | const QString& Bodytext()const; |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 7ccfb65..3cbac8e 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -260,129 +260,132 @@ void OpieMail::slotGetAllMail() | |||
260 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 260 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
261 | item = item->nextSibling (); | 261 | item = item->nextSibling (); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | void OpieMail::slotGetMail() | 264 | void OpieMail::slotGetMail() |
265 | { | 265 | { |
266 | QListViewItem * item = folderView->currentItem(); | 266 | QListViewItem * item = folderView->currentItem(); |
267 | if ( ! item ) return; | 267 | if ( ! item ) return; |
268 | while ( item->parent () ) | 268 | while ( item->parent () ) |
269 | item = item->parent (); | 269 | item = item->parent (); |
270 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 270 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
271 | } | 271 | } |
272 | void OpieMail::slotDeleteMail() | 272 | void OpieMail::slotDeleteMail() |
273 | { | 273 | { |
274 | if (!mailView->currentItem()) return; | 274 | if (!mailView->currentItem()) return; |
275 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 275 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
276 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 276 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
277 | { | 277 | { |
278 | mail->Wrapper()->deleteMail( mail ); | 278 | mail->Wrapper()->deleteMail( mail ); |
279 | folderView->refreshCurrent(); | 279 | folderView->refreshCurrent(); |
280 | } | 280 | } |
281 | } | 281 | } |
282 | void OpieMail::slotDeleteAllMail() | 282 | void OpieMail::slotDeleteAllMail() |
283 | { | 283 | { |
284 | 284 | ||
285 | QValueList<RecMailP> t; | 285 | QValueList<RecMailP> t; |
286 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 286 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
287 | { | 287 | { |
288 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 288 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
289 | while ( item ) { | 289 | while ( item ) { |
290 | if ( item->isSelected() ) { | 290 | if ( item->isSelected() ) { |
291 | t.append( item->data() ); | 291 | t.append( item->data() ); |
292 | } | 292 | } |
293 | item = (MailListViewItem*)item->nextSibling(); | 293 | item = (MailListViewItem*)item->nextSibling(); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | else | 296 | else |
297 | return; | 297 | return; |
298 | if ( t.count() == 0 ) | 298 | if ( t.count() == 0 ) |
299 | return; | 299 | return; |
300 | RecMailP mail = t.first(); | 300 | RecMailP mail = t.first(); |
301 | mail->Wrapper()->deleteMailList(t); | 301 | mail->Wrapper()->deleteMailList(t); |
302 | folderView->refreshCurrent(); | 302 | folderView->refreshCurrent(); |
303 | 303 | ||
304 | 304 | ||
305 | } | 305 | } |
306 | void OpieMail::clearSelection() | 306 | void OpieMail::clearSelection() |
307 | { | 307 | { |
308 | mailView->clearSelection(); | 308 | mailView->clearSelection(); |
309 | 309 | ||
310 | } | 310 | } |
311 | 311 | ||
312 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 312 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
313 | { | 313 | { |
314 | if (!mailView->currentItem()) return; | 314 | if (!mailView->currentItem()) return; |
315 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 315 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
316 | /* just the RIGHT button - or hold on pda */ | 316 | /* just the RIGHT button - or hold on pda */ |
317 | if (button!=2) {return;} | 317 | if (button!=2) {return;} |
318 | if (!item) return; | 318 | if (!item) return; |
319 | QPopupMenu *m = new QPopupMenu(0); | 319 | QPopupMenu *m = new QPopupMenu(0); |
320 | if (m) | 320 | if (m) |
321 | { | 321 | { |
322 | if (mailtype==MAILLIB::A_NNTP) { | 322 | if (mailtype==MAILLIB::A_NNTP) { |
323 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 323 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
324 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 324 | m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
325 | m->insertSeparator(); | ||
326 | m->insertItem(tr("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | ||
327 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); | ||
325 | } else { | 328 | } else { |
326 | if (folderView->currentisDraft()) { | 329 | if (folderView->currentisDraft()) { |
327 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 330 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
328 | } | 331 | } |
329 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 332 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
330 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 333 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
331 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 334 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
332 | m->insertSeparator(); | 335 | m->insertSeparator(); |
333 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 336 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
334 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 337 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
335 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); | 338 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); |
336 | } | 339 | } |
337 | m->setFocus(); | 340 | m->setFocus(); |
338 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 341 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
339 | delete m; | 342 | delete m; |
340 | } | 343 | } |
341 | } | 344 | } |
342 | 345 | ||
343 | void OpieMail::slotShowFolders( bool show ) | 346 | void OpieMail::slotShowFolders( bool show ) |
344 | { | 347 | { |
345 | if ( show && folderView->isHidden() ) | 348 | if ( show && folderView->isHidden() ) |
346 | { | 349 | { |
347 | folderView->show(); | 350 | folderView->show(); |
348 | } | 351 | } |
349 | else if ( !show && !folderView->isHidden() ) | 352 | else if ( !show && !folderView->isHidden() ) |
350 | { | 353 | { |
351 | folderView->hide(); | 354 | folderView->hide(); |
352 | } | 355 | } |
353 | } | 356 | } |
354 | 357 | ||
355 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 358 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
356 | { | 359 | { |
357 | MailListViewItem*item = 0; | 360 | MailListViewItem*item = 0; |
358 | mailView->clear(); | 361 | mailView->clear(); |
359 | 362 | ||
360 | QValueList<RecMailP>::ConstIterator it; | 363 | QValueList<RecMailP>::ConstIterator it; |
361 | for (it = list.begin(); it != list.end();++it) | 364 | for (it = list.begin(); it != list.end();++it) |
362 | { | 365 | { |
363 | item = new MailListViewItem(mailView,item); | 366 | item = new MailListViewItem(mailView,item); |
364 | item->storeData((*it)); | 367 | item->storeData((*it)); |
365 | item->showEntry(); | 368 | item->showEntry(); |
366 | } | 369 | } |
367 | } | 370 | } |
368 | 371 | ||
369 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 372 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
370 | { | 373 | { |
371 | mailView->clearSelection(); | 374 | mailView->clearSelection(); |
372 | /* just LEFT button - or tap with stylus on pda */ | 375 | /* just LEFT button - or tap with stylus on pda */ |
373 | //if (button!=1) return; | 376 | //if (button!=1) return; |
374 | if (!item) return; | 377 | if (!item) return; |
375 | if (folderView->currentisDraft()) { | 378 | if (folderView->currentisDraft()) { |
376 | reEditMail(); | 379 | reEditMail(); |
377 | } else { | 380 | } else { |
378 | displayMail(); | 381 | displayMail(); |
379 | } | 382 | } |
380 | } | 383 | } |
381 | 384 | ||
382 | void OpieMail::slotMoveCopyMail() | 385 | void OpieMail::slotMoveCopyMail() |
383 | { | 386 | { |
384 | if (!mailView->currentItem()) return; | 387 | if (!mailView->currentItem()) return; |
385 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 388 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
386 | AbstractMail*targetMail = 0; | 389 | AbstractMail*targetMail = 0; |
387 | QString targetFolder = ""; | 390 | QString targetFolder = ""; |
388 | Selectstore sels; | 391 | Selectstore sels; |