author | alwin <alwin> | 2004-01-09 01:16:31 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-09 01:16:31 (UTC) |
commit | d3a4757e062ffc5ce5840cb1c52215435a468ff0 (patch) (side-by-side diff) | |
tree | df5fdfdf42909e31c112b8e147e9e80c9bc0e94d | |
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 | 75 | ||||
-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 | 41 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 |
6 files changed, 155 insertions, 38 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() } - } @@ -708,3 +707,4 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) */ - +/* MH is a little bit different - the top folder can contains messages other than in IMAP and + POP3 and MBOX */ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) @@ -718,2 +718,3 @@ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) setOpen( true ); + folder = 0; } @@ -723,2 +724,3 @@ MHviewItem::~MHviewItem() delete wrapper; + if (folder) delete folder; } @@ -730,11 +732,10 @@ AbstractMail *MHviewItem::getWrapper() -void MHviewItem::refresh( QList<RecMail> & ) +void MHviewItem::refresh( QList<RecMail> & target) { refresh(false); + getWrapper()->listMessages( "",target ); } -void MHviewItem::refresh(bool force) +void MHviewItem::removeChilds() { - if (childCount()>0 && force==false) return; - QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); @@ -745,6 +746,25 @@ void MHviewItem::refresh(bool force) } +} + +void MHviewItem::refresh(bool force) +{ + if (childCount()>0 && force==false) return; + removeChilds(); + QList<Folder> *folders = wrapper->listFolders(); Folder *it; - QListViewItem*item = 0; + MHfolderItem*item = 0; + MHfolderItem*pmaster = 0; + QString fname = ""; for ( it = folders->first(); it; it = folders->next() ) { + fname = it->getDisplayName(); + /* this folder itself */ + if (fname=="/") { + folder = it; + continue; + } + if (pmaster) { + item = new MHfolderItem( it, pmaster, item, this ); + } else { item = new MHfolderItem( it, this , item ); + } item->setSelectable(it->may_select()); @@ -768,2 +788,4 @@ QPopupMenu * MHviewItem::getContextMenu() m->insertItem(QObject::tr("Create new folder",contextName),1); + m->insertItem(QObject::tr("Delete all mails",contextName),2); + m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); } @@ -784,2 +806,9 @@ void MHviewItem::createFolder() +void MHviewItem::downloadMails() +{ + AccountView*bl = accountView(); + if (!bl) return; + bl->downloadMails(folder,getWrapper()); +} + QStringList MHviewItem::subFolders() @@ -788,2 +817,3 @@ QStringList MHviewItem::subFolders() QListViewItem *child = firstChild(); + result.append("/"); while ( child ) { @@ -806,2 +836,8 @@ void MHviewItem::contextMenuSelected(int which) break; + case 2: + deleteAllMail(getWrapper(),folder); + break; + case 3: + downloadMails(); + break; default: @@ -821,5 +857,22 @@ MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewIt mbox = parent; - if (folder->getDisplayName().lower() == "outgoing") { + initName(); +} + +MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) + : AccountViewItem( parent,after ) +{ + folder = folderInit; + mbox = master; + initName(); +} + +void MHfolderItem::initName() +{ + QString bName = folder->getDisplayName(); + if (bName.startsWith("/")&&bName.length()>1) { + bName.replace(0,1,""); + } + if (bName.lower() == "outgoing") { setPixmap( 0, PIXMAP_OUTBOXFOLDER ); - } else if (folder->getDisplayName().lower() == "inbox") { + } else if (bName.lower() == "inbox") { setPixmap( 0, PIXMAP_INBOXFOLDER); @@ -828,3 +881,3 @@ MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewIt } - setText( 0, folder->getDisplayName() ); + setText( 0, bName ); } @@ -875,2 +928,3 @@ QPopupMenu * MHfolderItem::getContextMenu() m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); + m->insertItem(QObject::tr("Create new folder",contextName),3); } @@ -902 +956,2 @@ void MHfolderItem::contextMenuSelected(int which) } + 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: protected: + void downloadMails(); + void removeChilds(); virtual void createFolder(); @@ -139,3 +141,3 @@ protected: AbstractMail *wrapper; - + Folder *folder; }; @@ -147,2 +149,3 @@ public: MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); + MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); virtual ~MHfolderItem(); @@ -157,2 +160,3 @@ protected: virtual void deleteFolder(); + void initName(); 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 } +void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) +{ + init_storage(); + if (!m_storage) { + return; + } + if (targetWrapper != this) { + qDebug("Using generic"); + Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); + return; + } + qDebug("Using internal routines for move/copy"); + QString tf = buildPath(targetFolder); + int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); + if (r != MAIL_NO_ERROR) { + qDebug("Error selecting source mailbox"); + return; + } + if (moveit) { + r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); + } else { + r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); + } + if (r != MAIL_NO_ERROR) { + qDebug("Error copy/moving mail internal (%i)",r); + } +} + +void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) +{ + init_storage(); + if (!m_storage) { + return; + } + if (targetWrapper != this) { + qDebug("Using generic"); + Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); + return; + } + if (!fromFolder) return; + int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); + if (r!=MAIL_NO_ERROR) { + qDebug("error selecting source folder!"); + return; + } + QString tf = buildPath(targetFolder); + mailmessage_list*l=0; + r = mailsession_get_messages_list(m_storage->sto_session,&l); + if (r != MAIL_NO_ERROR) { + qDebug("Error message list"); + } + unsigned j = 0; + for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { + mailmessage * msg; + msg = (mailmessage*)carray_get(l->msg_tab, i); + j = msg->msg_index; + if (moveit) { + r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); + } else { + r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); + } + if (r != MAIL_NO_ERROR) { + qDebug("Error copy/moving mail internal (%i)",r); + break; + } + } + if (l) mailmessage_list_free(l); +} 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: virtual void answeredMail(const RecMail&mail); + virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); + virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 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 ) m_pop3 = NULL; - m_folder = NULL; msgTempName = a->getFileName()+"_msg_cache"; @@ -60,3 +59,3 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) { last_msg_id = mail.getNumber(); - err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); + err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); err = mailmessage_fetch(mailmsg,&message,&length); @@ -96,3 +95,4 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) { -void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { +void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) +{ login(); @@ -101,4 +101,4 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { uint32_t res_messages,res_recent,res_unseen; - mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); - parseList(target,m_folder->fld_session,"INBOX"); + mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); + parseList(target,m_pop3->sto_session,"INBOX"); Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); @@ -106,3 +106,4 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { -void POP3wrapper::login() { +void POP3wrapper::login() +{ if (account->getOffline()) @@ -159,12 +160,3 @@ void POP3wrapper::login() { - - m_folder = mailfolder_new(m_pop3, NULL, NULL); - - if (m_folder==0) { - Global::statusMessage(tr("Error initializing folder")); - mailstorage_free(m_pop3); - m_pop3 = NULL; - return; - } - err = mailfolder_connect(m_folder); + err = mailstorage_connect(m_pop3); if (err != MAIL_NO_ERROR) { @@ -172,4 +164,2 @@ void POP3wrapper::login() { Global::statusMessage(tr("Error initializing folder")); - mailfolder_free(m_folder); - m_folder = 0; mailstorage_free(m_pop3); @@ -179,3 +169,4 @@ void POP3wrapper::login() { -void POP3wrapper::logout() { +void POP3wrapper::logout() +{ int err = MAILPOP3_NO_ERROR; @@ -183,4 +174,2 @@ void POP3wrapper::logout() { return; - mailfolder_free(m_folder); - m_folder = 0; mailstorage_free(m_pop3); @@ -202,3 +191,3 @@ void POP3wrapper::deleteMail(const RecMail&mail) { return; - int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); + int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); if (err != MAIL_NO_ERROR) { @@ -217,3 +206,3 @@ int POP3wrapper::deleteAllMail(const Folder*) { uint32_t result = 0; - int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); + int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); if (err != MAIL_NO_ERROR) { @@ -223,3 +212,3 @@ int POP3wrapper::deleteAllMail(const Folder*) { for (unsigned int i = 0; i < result; ++i) { - err = mailsession_remove_message(m_folder->fld_session,i+1); + err = mailsession_remove_message(m_pop3->sto_session,i+1); if (err != MAIL_NO_ERROR) { @@ -240,3 +229,3 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { return; - int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, + int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); @@ -249,3 +238,3 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { mailmessage * mailmsg = 0; - int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); + int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); err = mailmessage_fetch(mailmsg,&target,&length); 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: mailstorage*m_pop3; - mailfolder*m_folder; }; |