author | alwin <alwin> | 2004-01-08 12:26:29 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-08 12:26:29 (UTC) |
commit | b85bc4484bcc0a53557b4759c3e9e58dc9059138 (patch) (unidiff) | |
tree | 16fa84076bc8f2e3125db815db3c2628286e62f1 /noncore/net/mail/libmailwrapper | |
parent | 3cb4363abdb17d2898b4792390672375ffcd2493 (diff) | |
download | opie-b85bc4484bcc0a53557b4759c3e9e58dc9059138.zip opie-b85bc4484bcc0a53557b4759c3e9e58dc9059138.tar.gz opie-b85bc4484bcc0a53557b4759c3e9e58dc9059138.tar.bz2 |
last selected mbox will hold so it will not called so often in outside loops
(it could cause segmentation faults, too - there is another bug in libetpan
I didn't found yet)
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 63 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 2 |
2 files changed, 37 insertions, 28 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 23c678b..98634a3 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -13,2 +13,3 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | |||
13 | m_imap = 0; | 13 | m_imap = 0; |
14 | m_Lastmbox = ""; | ||
14 | } | 15 | } |
@@ -20,2 +21,19 @@ IMAPwrapper::~IMAPwrapper() | |||
20 | 21 | ||
22 | /* to avoid to often select statements in loops etc. | ||
23 | we trust that we are logged in and connection is established!*/ | ||
24 | int IMAPwrapper::selectMbox(const QString&mbox) | ||
25 | { | ||
26 | if (mbox == m_Lastmbox) { | ||
27 | return MAILIMAP_NO_ERROR; | ||
28 | } | ||
29 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | ||
30 | if ( err != MAILIMAP_NO_ERROR ) { | ||
31 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | ||
32 | m_Lastmbox = ""; | ||
33 | return err; | ||
34 | } | ||
35 | m_Lastmbox = mbox; | ||
36 | return err; | ||
37 | } | ||
38 | |||
21 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 39 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
@@ -104,2 +122,3 @@ void IMAPwrapper::logout() | |||
104 | m_imap = 0; | 122 | m_imap = 0; |
123 | m_Lastmbox = ""; | ||
105 | } | 124 | } |
@@ -108,3 +127,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
108 | { | 127 | { |
109 | const char *mb = 0; | ||
110 | int err = MAILIMAP_NO_ERROR; | 128 | int err = MAILIMAP_NO_ERROR; |
@@ -112,3 +130,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
112 | clistcell *current; | 130 | clistcell *current; |
113 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | ||
114 | mailimap_fetch_type *fetchType = 0; | 131 | mailimap_fetch_type *fetchType = 0; |
@@ -116,3 +133,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
116 | 133 | ||
117 | mb = mailbox.latin1(); | ||
118 | login(); | 134 | login(); |
@@ -122,5 +138,4 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
122 | /* select mailbox READONLY for operations */ | 138 | /* select mailbox READONLY for operations */ |
123 | err = mailimap_examine( m_imap, (char*)mb); | 139 | err = selectMbox(mailbox); |
124 | if ( err != MAILIMAP_NO_ERROR ) { | 140 | if ( err != MAILIMAP_NO_ERROR ) { |
125 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | ||
126 | return; | 141 | return; |
@@ -391,6 +406,4 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
391 | } | 406 | } |
392 | 407 | err = selectMbox(mail.getMbox()); | |
393 | err = mailimap_select( m_imap, (char*)mb); | ||
394 | if ( err != MAILIMAP_NO_ERROR ) { | 408 | if ( err != MAILIMAP_NO_ERROR ) { |
395 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | ||
396 | return body; | 409 | return body; |
@@ -464,3 +477,2 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
464 | encodedString*res=new encodedString; | 477 | encodedString*res=new encodedString; |
465 | const char*mb; | ||
466 | int err; | 478 | int err; |
@@ -479,6 +491,4 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
479 | if (!internal_call) { | 491 | if (!internal_call) { |
480 | mb = mail.getMbox().latin1(); | 492 | err = selectMbox(mail.getMbox()); |
481 | err = mailimap_select( m_imap, (char*)mb); | ||
482 | if ( err != MAILIMAP_NO_ERROR ) { | 493 | if ( err != MAILIMAP_NO_ERROR ) { |
483 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | ||
484 | return res; | 494 | return res; |
@@ -775,6 +785,4 @@ void IMAPwrapper::deleteMail(const RecMail&mail) | |||
775 | } | 785 | } |
776 | const char *mb = mail.getMbox().latin1(); | 786 | err = selectMbox(mail.getMbox()); |
777 | err = mailimap_select( m_imap, (char*)mb); | ||
778 | if ( err != MAILIMAP_NO_ERROR ) { | 787 | if ( err != MAILIMAP_NO_ERROR ) { |
779 | qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); | ||
780 | return; | 788 | return; |
@@ -812,6 +820,4 @@ void IMAPwrapper::answeredMail(const RecMail&mail) | |||
812 | } | 820 | } |
813 | const char *mb = mail.getMbox().latin1(); | 821 | err = selectMbox(mail.getMbox()); |
814 | err = mailimap_select( m_imap, (char*)mb); | ||
815 | if ( err != MAILIMAP_NO_ERROR ) { | 822 | if ( err != MAILIMAP_NO_ERROR ) { |
816 | qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); | ||
817 | return; | 823 | return; |
@@ -874,7 +880,7 @@ int IMAPwrapper::deleteAllMail(const Folder*folder) | |||
874 | mailimap_store_att_flags * store_flags; | 880 | mailimap_store_att_flags * store_flags; |
875 | int err = mailimap_select( m_imap, folder->getName().latin1()); | 881 | int err = selectMbox(folder->getName()); |
876 | if ( err != MAILIMAP_NO_ERROR ) { | 882 | if ( err != MAILIMAP_NO_ERROR ) { |
877 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | ||
878 | return 0; | 883 | return 0; |
879 | } | 884 | } |
885 | |||
880 | int last = m_imap->imap_selection_info->sel_exists; | 886 | int last = m_imap->imap_selection_info->sel_exists; |
@@ -1024,3 +1030,2 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst | |||
1024 | { | 1030 | { |
1025 | qDebug("mvcp mail imap"); | ||
1026 | if (targetWrapper != this) { | 1031 | if (targetWrapper != this) { |
@@ -1030,11 +1035,11 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst | |||
1030 | } | 1035 | } |
1031 | qDebug("Using internal"); | ||
1032 | mailimap_set *set = 0; | 1036 | mailimap_set *set = 0; |
1033 | 1037 | login(); | |
1034 | int err = mailimap_select( m_imap, fromFolder->getName().latin1()); | 1038 | if (!m_imap) { |
1039 | return; | ||
1040 | } | ||
1041 | int err = selectMbox(fromFolder->getName()); | ||
1035 | if ( err != MAILIMAP_NO_ERROR ) { | 1042 | if ( err != MAILIMAP_NO_ERROR ) { |
1036 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | ||
1037 | return; | 1043 | return; |
1038 | } | 1044 | } |
1039 | |||
1040 | int last = m_imap->imap_selection_info->sel_exists; | 1045 | int last = m_imap->imap_selection_info->sel_exists; |
@@ -1042,7 +1047,9 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst | |||
1042 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1047 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1048 | mailimap_set_free( set ); | ||
1043 | if ( err != MAILIMAP_NO_ERROR ) { | 1049 | if ( err != MAILIMAP_NO_ERROR ) { |
1044 | Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response)); | 1050 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1051 | Global::statusMessage(error_msg); | ||
1052 | qDebug(error_msg); | ||
1045 | return; | 1053 | return; |
1046 | } | 1054 | } |
1047 | mailimap_set_free( set ); | ||
1048 | if (moveit) { | 1055 | if (moveit) { |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 07c6210..99986c2 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -56,2 +56,3 @@ protected: | |||
56 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 56 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
57 | int selectMbox(const QString&mbox); | ||
57 | 58 | ||
@@ -71,2 +72,3 @@ protected: | |||
71 | mailimap *m_imap; | 72 | mailimap *m_imap; |
73 | QString m_Lastmbox; | ||
72 | }; | 74 | }; |