author | alwin <alwin> | 2004-01-09 01:16:31 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-09 01:16:31 (UTC) |
commit | d3a4757e062ffc5ce5840cb1c52215435a468ff0 (patch) (unidiff) | |
tree | df5fdfdf42909e31c112b8e147e9e80c9bc0e94d /noncore | |
parent | 9fc7d401f1445c5f3d3d74e173dea6de2ea4784a (diff) | |
download | opie-d3a4757e062ffc5ce5840cb1c52215435a468ff0.zip opie-d3a4757e062ffc5ce5840cb1c52215435a468ff0.tar.gz opie-d3a4757e062ffc5ce5840cb1c52215435a468ff0.tar.bz2 |
- MHfolder in accountview enhanced
- mv/cp mails has special methods when copy between folder inside a
mh storage
- removed obsolete vars inside pop3wrapper
-rw-r--r-- | noncore/net/mail/accountview.cpp | 77 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 68 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 43 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 |
6 files changed, 157 insertions, 40 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 62cbf62..3048e49 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -244,3 +244,2 @@ void IMAPviewItem::removeChilds() | |||
244 | } | 244 | } |
245 | |||
246 | } | 245 | } |
@@ -708,3 +707,4 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | |||
708 | */ | 707 | */ |
709 | 708 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | |
709 | POP3 and MBOX */ | ||
710 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 710 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
@@ -718,2 +718,3 @@ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | |||
718 | setOpen( true ); | 718 | setOpen( true ); |
719 | folder = 0; | ||
719 | } | 720 | } |
@@ -723,2 +724,3 @@ MHviewItem::~MHviewItem() | |||
723 | delete wrapper; | 724 | delete wrapper; |
725 | if (folder) delete folder; | ||
724 | } | 726 | } |
@@ -730,11 +732,10 @@ AbstractMail *MHviewItem::getWrapper() | |||
730 | 732 | ||
731 | void MHviewItem::refresh( QList<RecMail> & ) | 733 | void MHviewItem::refresh( QList<RecMail> & target) |
732 | { | 734 | { |
733 | refresh(false); | 735 | refresh(false); |
736 | getWrapper()->listMessages( "",target ); | ||
734 | } | 737 | } |
735 | 738 | ||
736 | void MHviewItem::refresh(bool force) | 739 | void MHviewItem::removeChilds() |
737 | { | 740 | { |
738 | if (childCount()>0 && force==false) return; | ||
739 | QList<Folder> *folders = wrapper->listFolders(); | ||
740 | QListViewItem *child = firstChild(); | 741 | QListViewItem *child = firstChild(); |
@@ -745,6 +746,25 @@ void MHviewItem::refresh(bool force) | |||
745 | } | 746 | } |
747 | } | ||
748 | |||
749 | void MHviewItem::refresh(bool force) | ||
750 | { | ||
751 | if (childCount()>0 && force==false) return; | ||
752 | removeChilds(); | ||
753 | QList<Folder> *folders = wrapper->listFolders(); | ||
746 | Folder *it; | 754 | Folder *it; |
747 | QListViewItem*item = 0; | 755 | MHfolderItem*item = 0; |
756 | MHfolderItem*pmaster = 0; | ||
757 | QString fname = ""; | ||
748 | for ( it = folders->first(); it; it = folders->next() ) { | 758 | for ( it = folders->first(); it; it = folders->next() ) { |
749 | item = new MHfolderItem( it, this , item ); | 759 | fname = it->getDisplayName(); |
760 | /* this folder itself */ | ||
761 | if (fname=="/") { | ||
762 | folder = it; | ||
763 | continue; | ||
764 | } | ||
765 | if (pmaster) { | ||
766 | item = new MHfolderItem( it, pmaster, item, this ); | ||
767 | } else { | ||
768 | item = new MHfolderItem( it, this , item ); | ||
769 | } | ||
750 | item->setSelectable(it->may_select()); | 770 | item->setSelectable(it->may_select()); |
@@ -768,2 +788,4 @@ QPopupMenu * MHviewItem::getContextMenu() | |||
768 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 788 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
789 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | ||
790 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | ||
769 | } | 791 | } |
@@ -784,2 +806,9 @@ void MHviewItem::createFolder() | |||
784 | 806 | ||
807 | void MHviewItem::downloadMails() | ||
808 | { | ||
809 | AccountView*bl = accountView(); | ||
810 | if (!bl) return; | ||
811 | bl->downloadMails(folder,getWrapper()); | ||
812 | } | ||
813 | |||
785 | QStringList MHviewItem::subFolders() | 814 | QStringList MHviewItem::subFolders() |
@@ -788,2 +817,3 @@ QStringList MHviewItem::subFolders() | |||
788 | QListViewItem *child = firstChild(); | 817 | QListViewItem *child = firstChild(); |
818 | result.append("/"); | ||
789 | while ( child ) { | 819 | while ( child ) { |
@@ -806,2 +836,8 @@ void MHviewItem::contextMenuSelected(int which) | |||
806 | break; | 836 | break; |
837 | case 2: | ||
838 | deleteAllMail(getWrapper(),folder); | ||
839 | break; | ||
840 | case 3: | ||
841 | downloadMails(); | ||
842 | break; | ||
807 | default: | 843 | default: |
@@ -821,5 +857,22 @@ MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewIt | |||
821 | mbox = parent; | 857 | mbox = parent; |
822 | if (folder->getDisplayName().lower() == "outgoing") { | 858 | initName(); |
859 | } | ||
860 | |||
861 | MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | ||
862 | : AccountViewItem( parent,after ) | ||
863 | { | ||
864 | folder = folderInit; | ||
865 | mbox = master; | ||
866 | initName(); | ||
867 | } | ||
868 | |||
869 | void MHfolderItem::initName() | ||
870 | { | ||
871 | QString bName = folder->getDisplayName(); | ||
872 | if (bName.startsWith("/")&&bName.length()>1) { | ||
873 | bName.replace(0,1,""); | ||
874 | } | ||
875 | if (bName.lower() == "outgoing") { | ||
823 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 876 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
824 | } else if (folder->getDisplayName().lower() == "inbox") { | 877 | } else if (bName.lower() == "inbox") { |
825 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 878 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
@@ -828,3 +881,3 @@ MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewIt | |||
828 | } | 881 | } |
829 | setText( 0, folder->getDisplayName() ); | 882 | setText( 0, bName ); |
830 | } | 883 | } |
@@ -875,2 +928,3 @@ QPopupMenu * MHfolderItem::getContextMenu() | |||
875 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 928 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
929 | m->insertItem(QObject::tr("Create new folder",contextName),3); | ||
876 | } | 930 | } |
@@ -902 +956,2 @@ void MHfolderItem::contextMenuSelected(int which) | |||
902 | } | 956 | } |
957 | |||
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index f5a2973..60e2b4b 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -136,2 +136,4 @@ public: | |||
136 | protected: | 136 | protected: |
137 | void downloadMails(); | ||
138 | void removeChilds(); | ||
137 | virtual void createFolder(); | 139 | virtual void createFolder(); |
@@ -139,3 +141,3 @@ protected: | |||
139 | AbstractMail *wrapper; | 141 | AbstractMail *wrapper; |
140 | 142 | Folder *folder; | |
141 | }; | 143 | }; |
@@ -147,2 +149,3 @@ public: | |||
147 | MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); | 149 | MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); |
150 | MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); | ||
148 | virtual ~MHfolderItem(); | 151 | virtual ~MHfolderItem(); |
@@ -157,2 +160,3 @@ protected: | |||
157 | virtual void deleteFolder(); | 160 | virtual void deleteFolder(); |
161 | void initName(); | ||
158 | Folder *folder; | 162 | Folder *folder; |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 5adba55..512f778 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -333 +333,69 @@ const QString&MHwrapper::getName()const | |||
333 | } | 333 | } |
334 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
335 | { | ||
336 | init_storage(); | ||
337 | if (!m_storage) { | ||
338 | return; | ||
339 | } | ||
340 | if (targetWrapper != this) { | ||
341 | qDebug("Using generic"); | ||
342 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | ||
343 | return; | ||
344 | } | ||
345 | qDebug("Using internal routines for move/copy"); | ||
346 | QString tf = buildPath(targetFolder); | ||
347 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | ||
348 | if (r != MAIL_NO_ERROR) { | ||
349 | qDebug("Error selecting source mailbox"); | ||
350 | return; | ||
351 | } | ||
352 | if (moveit) { | ||
353 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | ||
354 | } else { | ||
355 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | ||
356 | } | ||
357 | if (r != MAIL_NO_ERROR) { | ||
358 | qDebug("Error copy/moving mail internal (%i)",r); | ||
359 | } | ||
360 | } | ||
361 | |||
362 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
363 | { | ||
364 | init_storage(); | ||
365 | if (!m_storage) { | ||
366 | return; | ||
367 | } | ||
368 | if (targetWrapper != this) { | ||
369 | qDebug("Using generic"); | ||
370 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | ||
371 | return; | ||
372 | } | ||
373 | if (!fromFolder) return; | ||
374 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | ||
375 | if (r!=MAIL_NO_ERROR) { | ||
376 | qDebug("error selecting source folder!"); | ||
377 | return; | ||
378 | } | ||
379 | QString tf = buildPath(targetFolder); | ||
380 | mailmessage_list*l=0; | ||
381 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | ||
382 | if (r != MAIL_NO_ERROR) { | ||
383 | qDebug("Error message list"); | ||
384 | } | ||
385 | unsigned j = 0; | ||
386 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | ||
387 | mailmessage * msg; | ||
388 | msg = (mailmessage*)carray_get(l->msg_tab, i); | ||
389 | j = msg->msg_index; | ||
390 | if (moveit) { | ||
391 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | ||
392 | } else { | ||
393 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | ||
394 | } | ||
395 | if (r != MAIL_NO_ERROR) { | ||
396 | qDebug("Error copy/moving mail internal (%i)",r); | ||
397 | break; | ||
398 | } | ||
399 | } | ||
400 | if (l) mailmessage_list_free(l); | ||
401 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index 7f028b4..79dec30 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h | |||
@@ -24,2 +24,4 @@ public: | |||
24 | virtual void answeredMail(const RecMail&mail); | 24 | virtual void answeredMail(const RecMail&mail); |
25 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
26 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
25 | 27 | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index f5eca4a..14c2059 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -16,3 +16,2 @@ POP3wrapper::POP3wrapper( POP3account *a ) | |||
16 | m_pop3 = NULL; | 16 | m_pop3 = NULL; |
17 | m_folder = NULL; | ||
18 | msgTempName = a->getFileName()+"_msg_cache"; | 17 | msgTempName = a->getFileName()+"_msg_cache"; |
@@ -60,3 +59,3 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) { | |||
60 | last_msg_id = mail.getNumber(); | 59 | last_msg_id = mail.getNumber(); |
61 | err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); | 60 | err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); |
62 | err = mailmessage_fetch(mailmsg,&message,&length); | 61 | err = mailmessage_fetch(mailmsg,&message,&length); |
@@ -96,3 +95,4 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) { | |||
96 | 95 | ||
97 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { | 96 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
97 | { | ||
98 | login(); | 98 | login(); |
@@ -101,4 +101,4 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { | |||
101 | uint32_t res_messages,res_recent,res_unseen; | 101 | uint32_t res_messages,res_recent,res_unseen; |
102 | mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 102 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
103 | parseList(target,m_folder->fld_session,"INBOX"); | 103 | parseList(target,m_pop3->sto_session,"INBOX"); |
104 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 104 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
@@ -106,3 +106,4 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { | |||
106 | 106 | ||
107 | void POP3wrapper::login() { | 107 | void POP3wrapper::login() |
108 | { | ||
108 | if (account->getOffline()) | 109 | if (account->getOffline()) |
@@ -159,12 +160,3 @@ void POP3wrapper::login() { | |||
159 | 160 | ||
160 | 161 | err = mailstorage_connect(m_pop3); | |
161 | m_folder = mailfolder_new(m_pop3, NULL, NULL); | ||
162 | |||
163 | if (m_folder==0) { | ||
164 | Global::statusMessage(tr("Error initializing folder")); | ||
165 | mailstorage_free(m_pop3); | ||
166 | m_pop3 = NULL; | ||
167 | return; | ||
168 | } | ||
169 | err = mailfolder_connect(m_folder); | ||
170 | if (err != MAIL_NO_ERROR) { | 162 | if (err != MAIL_NO_ERROR) { |
@@ -172,4 +164,2 @@ void POP3wrapper::login() { | |||
172 | Global::statusMessage(tr("Error initializing folder")); | 164 | Global::statusMessage(tr("Error initializing folder")); |
173 | mailfolder_free(m_folder); | ||
174 | m_folder = 0; | ||
175 | mailstorage_free(m_pop3); | 165 | mailstorage_free(m_pop3); |
@@ -179,3 +169,4 @@ void POP3wrapper::login() { | |||
179 | 169 | ||
180 | void POP3wrapper::logout() { | 170 | void POP3wrapper::logout() |
171 | { | ||
181 | int err = MAILPOP3_NO_ERROR; | 172 | int err = MAILPOP3_NO_ERROR; |
@@ -183,4 +174,2 @@ void POP3wrapper::logout() { | |||
183 | return; | 174 | return; |
184 | mailfolder_free(m_folder); | ||
185 | m_folder = 0; | ||
186 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
@@ -202,3 +191,3 @@ void POP3wrapper::deleteMail(const RecMail&mail) { | |||
202 | return; | 191 | return; |
203 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); | 192 | int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); |
204 | if (err != MAIL_NO_ERROR) { | 193 | if (err != MAIL_NO_ERROR) { |
@@ -217,3 +206,3 @@ int POP3wrapper::deleteAllMail(const Folder*) { | |||
217 | uint32_t result = 0; | 206 | uint32_t result = 0; |
218 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); | 207 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
219 | if (err != MAIL_NO_ERROR) { | 208 | if (err != MAIL_NO_ERROR) { |
@@ -223,3 +212,3 @@ int POP3wrapper::deleteAllMail(const Folder*) { | |||
223 | for (unsigned int i = 0; i < result; ++i) { | 212 | for (unsigned int i = 0; i < result; ++i) { |
224 | err = mailsession_remove_message(m_folder->fld_session,i+1); | 213 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
225 | if (err != MAIL_NO_ERROR) { | 214 | if (err != MAIL_NO_ERROR) { |
@@ -240,3 +229,3 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | |||
240 | return; | 229 | return; |
241 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | 230 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
242 | &target_stat.message_recent,&target_stat.message_unseen); | 231 | &target_stat.message_recent,&target_stat.message_unseen); |
@@ -249,3 +238,3 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { | |||
249 | mailmessage * mailmsg = 0; | 238 | mailmessage * mailmsg = 0; |
250 | int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); | 239 | int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); |
251 | err = mailmessage_fetch(mailmsg,&target,&length); | 240 | err = mailmessage_fetch(mailmsg,&target,&length); |
@@ -263,3 +252,3 @@ const QString&POP3wrapper::getType()const { | |||
263 | 252 | ||
264 | const QString&POP3wrapper::getName()const { | 253 | const QString&POP3wrapper::getName()const{ |
265 | return account->getAccountName(); | 254 | return account->getAccountName(); |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index d2b708d..a24b9cf 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -39,3 +39,2 @@ protected: | |||
39 | mailstorage*m_pop3; | 39 | mailstorage*m_pop3; |
40 | mailfolder*m_folder; | ||
41 | }; | 40 | }; |