21 files changed, 93 insertions, 48 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 64557ee..4375044 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,170 +1,170 @@ | |||
1 | 1 | ||
2 | #include "accountview.h" | 2 | #include "accountview.h" |
3 | #include "accountitem.h" | 3 | #include "accountitem.h" |
4 | #include "selectstore.h" | 4 | #include "selectstore.h" |
5 | 5 | ||
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <libmailwrapper/settings.h> | 7 | #include <libmailwrapper/settings.h> |
8 | #include <libmailwrapper/mailwrapper.h> | 8 | #include <libmailwrapper/mailwrapper.h> |
9 | #include <libmailwrapper/mailtypes.h> | 9 | #include <libmailwrapper/mailtypes.h> |
10 | #include <libmailwrapper/abstractmail.h> | 10 | #include <libmailwrapper/abstractmail.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | 12 | ||
13 | /* QT */ | 13 | /* QT */ |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | 16 | ||
17 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 17 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
18 | : QListView( parent, name, flags ) | 18 | : QListView( parent, name, flags ) |
19 | { | 19 | { |
20 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 20 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
21 | SLOT( refresh(QListViewItem*) ) ); | 21 | SLOT( refresh(QListViewItem*) ) ); |
22 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 22 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
23 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 23 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
24 | setSorting(0); | 24 | setSorting(0); |
25 | } | 25 | } |
26 | 26 | ||
27 | AccountView::~AccountView() | 27 | AccountView::~AccountView() |
28 | { | 28 | { |
29 | imapAccounts.clear(); | 29 | imapAccounts.clear(); |
30 | mhAccounts.clear(); | 30 | mhAccounts.clear(); |
31 | } | 31 | } |
32 | 32 | ||
33 | void AccountView::slotContextMenu(int id) | 33 | void AccountView::slotContextMenu(int id) |
34 | { | 34 | { |
35 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 35 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
36 | if (!view) return; | 36 | if (!view) return; |
37 | view->contextMenuSelected(id); | 37 | view->contextMenuSelected(id); |
38 | } | 38 | } |
39 | 39 | ||
40 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 40 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
41 | { | 41 | { |
42 | if (button==1) {return;} | 42 | if (button==1) {return;} |
43 | if (!item) return; | 43 | if (!item) return; |
44 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 44 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
45 | QPopupMenu*m = view->getContextMenu(); | 45 | QPopupMenu*m = view->getContextMenu(); |
46 | if (!m) return; | 46 | if (!m) return; |
47 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 47 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
48 | m->setFocus(); | 48 | m->setFocus(); |
49 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 49 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
50 | delete m; | 50 | delete m; |
51 | } | 51 | } |
52 | 52 | ||
53 | void AccountView::populate( QList<Account> list ) | 53 | void AccountView::populate( QList<Account> list ) |
54 | { | 54 | { |
55 | clear(); | 55 | clear(); |
56 | 56 | ||
57 | imapAccounts.clear(); | 57 | imapAccounts.clear(); |
58 | mhAccounts.clear(); | 58 | mhAccounts.clear(); |
59 | 59 | ||
60 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 60 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
61 | 61 | ||
62 | Account *it; | 62 | Account *it; |
63 | for ( it = list.first(); it; it = list.next() ) | 63 | for ( it = list.first(); it; it = list.next() ) |
64 | { | 64 | { |
65 | if ( it->getType().compare( "IMAP" ) == 0 ) | 65 | if ( it->getType() == MAILLIB::A_IMAP ) |
66 | { | 66 | { |
67 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 67 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
68 | qDebug( "added IMAP " + imap->getAccountName() ); | 68 | qDebug( "added IMAP " + imap->getAccountName() ); |
69 | imapAccounts.append(new IMAPviewItem( imap, this )); | 69 | imapAccounts.append(new IMAPviewItem( imap, this )); |
70 | } | 70 | } |
71 | else if ( it->getType().compare( "POP3" ) == 0 ) | 71 | else if ( it->getType() == MAILLIB::A_POP3 ) |
72 | { | 72 | { |
73 | POP3account *pop3 = static_cast<POP3account *>(it); | 73 | POP3account *pop3 = static_cast<POP3account *>(it); |
74 | qDebug( "added POP3 " + pop3->getAccountName() ); | 74 | qDebug( "added POP3 " + pop3->getAccountName() ); |
75 | /* must not be hold 'cause it isn't required */ | 75 | /* must not be hold 'cause it isn't required */ |
76 | (void) new POP3viewItem( pop3, this ); | 76 | (void) new POP3viewItem( pop3, this ); |
77 | } | 77 | } |
78 | else if ( it->getType().compare( "NNTP" ) == 0 ) | 78 | else if ( it->getType() == MAILLIB::A_NNTP ) |
79 | { | 79 | { |
80 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 80 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
81 | qDebug( "added NNTP " + nntp->getAccountName() ); | 81 | qDebug( "added NNTP " + nntp->getAccountName() ); |
82 | /* must not be hold 'cause it isn't required */ | 82 | /* must not be hold 'cause it isn't required */ |
83 | (void) new NNTPviewItem( nntp, this ); | 83 | (void) new NNTPviewItem( nntp, this ); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | void AccountView::refresh(QListViewItem *item) | 88 | void AccountView::refresh(QListViewItem *item) |
89 | { | 89 | { |
90 | 90 | ||
91 | qDebug("AccountView refresh..."); | 91 | qDebug("AccountView refresh..."); |
92 | if ( item ) | 92 | if ( item ) |
93 | { | 93 | { |
94 | m_currentItem = item; | 94 | m_currentItem = item; |
95 | QList<RecMail> headerlist; | 95 | QList<RecMail> headerlist; |
96 | headerlist.setAutoDelete(true); | 96 | headerlist.setAutoDelete(true); |
97 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 97 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
98 | view->refresh(headerlist); | 98 | view->refresh(headerlist); |
99 | emit refreshMailview(&headerlist); | 99 | emit refreshMailview(&headerlist); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | void AccountView::refreshCurrent() | 103 | void AccountView::refreshCurrent() |
104 | { | 104 | { |
105 | m_currentItem = currentItem(); | 105 | m_currentItem = currentItem(); |
106 | if ( !m_currentItem ) return; | 106 | if ( !m_currentItem ) return; |
107 | QList<RecMail> headerlist; | 107 | QList<RecMail> headerlist; |
108 | headerlist.setAutoDelete(true); | 108 | headerlist.setAutoDelete(true); |
109 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 109 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
110 | view->refresh(headerlist); | 110 | view->refresh(headerlist); |
111 | emit refreshMailview(&headerlist); | 111 | emit refreshMailview(&headerlist); |
112 | } | 112 | } |
113 | 113 | ||
114 | void AccountView::refreshAll() | 114 | void AccountView::refreshAll() |
115 | { | 115 | { |
116 | } | 116 | } |
117 | 117 | ||
118 | RecBody AccountView::fetchBody(const RecMail&aMail) | 118 | RecBody AccountView::fetchBody(const RecMail&aMail) |
119 | { | 119 | { |
120 | QListViewItem*item = selectedItem (); | 120 | QListViewItem*item = selectedItem (); |
121 | if (!item) return RecBody(); | 121 | if (!item) return RecBody(); |
122 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 122 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
123 | return view->fetchBody(aMail); | 123 | return view->fetchBody(aMail); |
124 | } | 124 | } |
125 | 125 | ||
126 | void AccountView::setupFolderselect(Selectstore*sels) | 126 | void AccountView::setupFolderselect(Selectstore*sels) |
127 | { | 127 | { |
128 | QPEApplication::showDialog( sels ); | 128 | QPEApplication::showDialog( sels ); |
129 | QStringList sFolders; | 129 | QStringList sFolders; |
130 | unsigned int i = 0; | 130 | unsigned int i = 0; |
131 | for (i=0; i < mhAccounts.count();++i) | 131 | for (i=0; i < mhAccounts.count();++i) |
132 | { | 132 | { |
133 | mhAccounts[i]->refresh(false); | 133 | mhAccounts[i]->refresh(false); |
134 | sFolders = mhAccounts[i]->subFolders(); | 134 | sFolders = mhAccounts[i]->subFolders(); |
135 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 135 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
136 | } | 136 | } |
137 | for (i=0; i < imapAccounts.count();++i) | 137 | for (i=0; i < imapAccounts.count();++i) |
138 | { | 138 | { |
139 | if (imapAccounts[i]->offline()) | 139 | if (imapAccounts[i]->offline()) |
140 | continue; | 140 | continue; |
141 | imapAccounts[i]->refreshFolders(false); | 141 | imapAccounts[i]->refreshFolders(false); |
142 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 142 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | 146 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) |
147 | { | 147 | { |
148 | AbstractMail*targetMail = 0; | 148 | AbstractMail*targetMail = 0; |
149 | QString targetFolder = ""; | 149 | QString targetFolder = ""; |
150 | Selectstore sels; | 150 | Selectstore sels; |
151 | setupFolderselect(&sels); | 151 | setupFolderselect(&sels); |
152 | if (!sels.exec()) return; | 152 | if (!sels.exec()) return; |
153 | targetMail = sels.currentMail(); | 153 | targetMail = sels.currentMail(); |
154 | targetFolder = sels.currentFolder(); | 154 | targetFolder = sels.currentFolder(); |
155 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 155 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
156 | targetFolder.isEmpty()) | 156 | targetFolder.isEmpty()) |
157 | { | 157 | { |
158 | return; | 158 | return; |
159 | } | 159 | } |
160 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 160 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
161 | { | 161 | { |
162 | QMessageBox::critical(0,tr("Error creating new Folder"), | 162 | QMessageBox::critical(0,tr("Error creating new Folder"), |
163 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 163 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | qDebug("Targetfolder: %s",targetFolder.latin1()); | 166 | qDebug("Targetfolder: %s",targetFolder.latin1()); |
167 | qDebug("Fromfolder: %s",fromFolder->getName().latin1()); | 167 | qDebug("Fromfolder: %s",fromFolder->getName().latin1()); |
168 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | 168 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); |
169 | refreshCurrent(); | 169 | refreshCurrent(); |
170 | } | 170 | } |
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index f51a8fe..f8ac76f 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,240 +1,240 @@ | |||
1 | #include <qt.h> | 1 | #include <qt.h> |
2 | 2 | ||
3 | #include <opie2/ofiledialog.h> | 3 | #include <opie2/ofiledialog.h> |
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <qpe/contact.h> | 7 | #include <qpe/contact.h> |
8 | 8 | ||
9 | #include "composemail.h" | 9 | #include "composemail.h" |
10 | 10 | ||
11 | #include <libmailwrapper/smtpwrapper.h> | 11 | #include <libmailwrapper/smtpwrapper.h> |
12 | 12 | ||
13 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 13 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
14 | : ComposeMailUI( parent, name, modal, flags ) | 14 | : ComposeMailUI( parent, name, modal, flags ) |
15 | { | 15 | { |
16 | settings = s; | 16 | settings = s; |
17 | 17 | ||
18 | QString vfilename = Global::applicationFileName("addressbook", | 18 | QString vfilename = Global::applicationFileName("addressbook", |
19 | "businesscard.vcf"); | 19 | "businesscard.vcf"); |
20 | Contact c; | 20 | Contact c; |
21 | if (QFile::exists(vfilename)) { | 21 | if (QFile::exists(vfilename)) { |
22 | c = Contact::readVCard( vfilename )[0]; | 22 | c = Contact::readVCard( vfilename )[0]; |
23 | } | 23 | } |
24 | 24 | ||
25 | QStringList mails = c.emailList(); | 25 | QStringList mails = c.emailList(); |
26 | QString defmail = c.defaultEmail(); | 26 | QString defmail = c.defaultEmail(); |
27 | 27 | ||
28 | if (defmail.length()!=0) { | 28 | if (defmail.length()!=0) { |
29 | fromBox->insertItem(defmail); | 29 | fromBox->insertItem(defmail); |
30 | } | 30 | } |
31 | QStringList::ConstIterator sit = mails.begin(); | 31 | QStringList::ConstIterator sit = mails.begin(); |
32 | for (;sit!=mails.end();++sit) { | 32 | for (;sit!=mails.end();++sit) { |
33 | if ( (*sit)==defmail) | 33 | if ( (*sit)==defmail) |
34 | continue; | 34 | continue; |
35 | fromBox->insertItem((*sit)); | 35 | fromBox->insertItem((*sit)); |
36 | } | 36 | } |
37 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); | 37 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); |
38 | Config cfg( "mail" ); | 38 | Config cfg( "mail" ); |
39 | cfg.setGroup( "Compose" ); | 39 | cfg.setGroup( "Compose" ); |
40 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 40 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
41 | 41 | ||
42 | attList->addColumn( tr( "Name" ) ); | 42 | attList->addColumn( tr( "Name" ) ); |
43 | attList->addColumn( tr( "Size" ) ); | 43 | attList->addColumn( tr( "Size" ) ); |
44 | 44 | ||
45 | QList<Account> accounts = settings->getAccounts(); | 45 | QList<Account> accounts = settings->getAccounts(); |
46 | 46 | ||
47 | Account *it; | 47 | Account *it; |
48 | for ( it = accounts.first(); it; it = accounts.next() ) { | 48 | for ( it = accounts.first(); it; it = accounts.next() ) { |
49 | if ( it->getType().compare( "SMTP" ) == 0 ) { | 49 | if ( it->getType()==MAILLIB::A_SMTP ) { |
50 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 50 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
51 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 51 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
52 | smtpAccounts.append( smtp ); | 52 | smtpAccounts.append( smtp ); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | if ( smtpAccounts.count() > 0 ) { | 56 | if ( smtpAccounts.count() > 0 ) { |
57 | fillValues( smtpAccountBox->currentItem() ); | 57 | fillValues( smtpAccountBox->currentItem() ); |
58 | } else { | 58 | } else { |
59 | QMessageBox::information( this, tr( "Problem" ), | 59 | QMessageBox::information( this, tr( "Problem" ), |
60 | tr( "<p>Please create an SMTP account first.</p>" ), | 60 | tr( "<p>Please create an SMTP account first.</p>" ), |
61 | tr( "Ok" ) ); | 61 | tr( "Ok" ) ); |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | 64 | ||
65 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 65 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
66 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 66 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
67 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 67 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
68 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 68 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
69 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 69 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
70 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 70 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
71 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 71 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void ComposeMail::pickAddress( QLineEdit *line ) | 74 | void ComposeMail::pickAddress( QLineEdit *line ) |
75 | { | 75 | { |
76 | QString names = AddressPicker::getNames(); | 76 | QString names = AddressPicker::getNames(); |
77 | if ( line->text().isEmpty() ) { | 77 | if ( line->text().isEmpty() ) { |
78 | line->setText( names ); | 78 | line->setText( names ); |
79 | } else if ( !names.isEmpty() ) { | 79 | } else if ( !names.isEmpty() ) { |
80 | line->setText( line->text() + ", " + names ); | 80 | line->setText( line->text() + ", " + names ); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | void ComposeMail::setTo( const QString & to ) | 85 | void ComposeMail::setTo( const QString & to ) |
86 | { | 86 | { |
87 | /* QString toline; | 87 | /* QString toline; |
88 | QStringList toEntry = to; | 88 | QStringList toEntry = to; |
89 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { | 89 | for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { |
90 | toline += (*it); | 90 | toline += (*it); |
91 | } | 91 | } |
92 | toLine->setText( toline ); | 92 | toLine->setText( toline ); |
93 | */ | 93 | */ |
94 | toLine->setText( to ); | 94 | toLine->setText( to ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void ComposeMail::setSubject( const QString & subject ) | 97 | void ComposeMail::setSubject( const QString & subject ) |
98 | { | 98 | { |
99 | subjectLine->setText( subject ); | 99 | subjectLine->setText( subject ); |
100 | } | 100 | } |
101 | 101 | ||
102 | void ComposeMail::setInReplyTo( const QString & messageId ) | 102 | void ComposeMail::setInReplyTo( const QString & messageId ) |
103 | { | 103 | { |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | void ComposeMail::setMessage( const QString & text ) | 107 | void ComposeMail::setMessage( const QString & text ) |
108 | { | 108 | { |
109 | message->setText( text ); | 109 | message->setText( text ); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void ComposeMail::pickAddressTo() | 113 | void ComposeMail::pickAddressTo() |
114 | { | 114 | { |
115 | pickAddress( toLine ); | 115 | pickAddress( toLine ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void ComposeMail::pickAddressCC() | 118 | void ComposeMail::pickAddressCC() |
119 | { | 119 | { |
120 | pickAddress( ccLine ); | 120 | pickAddress( ccLine ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void ComposeMail::pickAddressBCC() | 123 | void ComposeMail::pickAddressBCC() |
124 | { | 124 | { |
125 | pickAddress( bccLine ); | 125 | pickAddress( bccLine ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void ComposeMail::pickAddressReply() | 128 | void ComposeMail::pickAddressReply() |
129 | { | 129 | { |
130 | pickAddress( replyLine ); | 130 | pickAddress( replyLine ); |
131 | } | 131 | } |
132 | 132 | ||
133 | void ComposeMail::fillValues( int current ) | 133 | void ComposeMail::fillValues( int current ) |
134 | { | 134 | { |
135 | #if 0 | 135 | #if 0 |
136 | SMTPaccount *smtp = smtpAccounts.at( current ); | 136 | SMTPaccount *smtp = smtpAccounts.at( current ); |
137 | ccLine->clear(); | 137 | ccLine->clear(); |
138 | if ( smtp->getUseCC() ) { | 138 | if ( smtp->getUseCC() ) { |
139 | ccLine->setText( smtp->getCC() ); | 139 | ccLine->setText( smtp->getCC() ); |
140 | } | 140 | } |
141 | bccLine->clear(); | 141 | bccLine->clear(); |
142 | if ( smtp->getUseBCC() ) { | 142 | if ( smtp->getUseBCC() ) { |
143 | bccLine->setText( smtp->getBCC() ); | 143 | bccLine->setText( smtp->getBCC() ); |
144 | } | 144 | } |
145 | replyLine->clear(); | 145 | replyLine->clear(); |
146 | if ( smtp->getUseReply() ) { | 146 | if ( smtp->getUseReply() ) { |
147 | replyLine->setText( smtp->getReply() ); | 147 | replyLine->setText( smtp->getReply() ); |
148 | } | 148 | } |
149 | sigMultiLine->setText( smtp->getSignature() ); | 149 | sigMultiLine->setText( smtp->getSignature() ); |
150 | #endif | 150 | #endif |
151 | } | 151 | } |
152 | 152 | ||
153 | void ComposeMail::slotAdjustColumns() | 153 | void ComposeMail::slotAdjustColumns() |
154 | { | 154 | { |
155 | int currPage = tabWidget->currentPageIndex(); | 155 | int currPage = tabWidget->currentPageIndex(); |
156 | 156 | ||
157 | tabWidget->showPage( attachTab ); | 157 | tabWidget->showPage( attachTab ); |
158 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 158 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
159 | attList->setColumnWidth( 1, 80 ); | 159 | attList->setColumnWidth( 1, 80 ); |
160 | 160 | ||
161 | tabWidget->setCurrentPage( currPage ); | 161 | tabWidget->setCurrentPage( currPage ); |
162 | } | 162 | } |
163 | 163 | ||
164 | void ComposeMail::addAttachment() | 164 | void ComposeMail::addAttachment() |
165 | { | 165 | { |
166 | DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); | 166 | DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); |
167 | if ( !lnk.name().isEmpty() ) { | 167 | if ( !lnk.name().isEmpty() ) { |
168 | Attachment *att = new Attachment( lnk ); | 168 | Attachment *att = new Attachment( lnk ); |
169 | (void) new AttachViewItem( attList, att ); | 169 | (void) new AttachViewItem( attList, att ); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | void ComposeMail::removeAttachment() | 173 | void ComposeMail::removeAttachment() |
174 | { | 174 | { |
175 | if ( !attList->currentItem() ) { | 175 | if ( !attList->currentItem() ) { |
176 | QMessageBox::information( this, tr( "Error" ), | 176 | QMessageBox::information( this, tr( "Error" ), |
177 | tr( "<p>Please select a File.</p>" ), | 177 | tr( "<p>Please select a File.</p>" ), |
178 | tr( "Ok" ) ); | 178 | tr( "Ok" ) ); |
179 | } else { | 179 | } else { |
180 | attList->takeItem( attList->currentItem() ); | 180 | attList->takeItem( attList->currentItem() ); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void ComposeMail::accept() | 184 | void ComposeMail::accept() |
185 | { | 185 | { |
186 | if ( checkBoxLater->isChecked() ) { | 186 | if ( checkBoxLater->isChecked() ) { |
187 | qDebug( "Send later" ); | 187 | qDebug( "Send later" ); |
188 | } | 188 | } |
189 | 189 | ||
190 | #if 0 | 190 | #if 0 |
191 | qDebug( "Sending Mail with " + | 191 | qDebug( "Sending Mail with " + |
192 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); | 192 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
193 | #endif | 193 | #endif |
194 | Mail *mail = new Mail(); | 194 | Mail *mail = new Mail(); |
195 | 195 | ||
196 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 196 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
197 | mail->setMail(fromBox->currentText()); | 197 | mail->setMail(fromBox->currentText()); |
198 | 198 | ||
199 | if ( !toLine->text().isEmpty() ) { | 199 | if ( !toLine->text().isEmpty() ) { |
200 | mail->setTo( toLine->text() ); | 200 | mail->setTo( toLine->text() ); |
201 | } else { | 201 | } else { |
202 | qDebug( "No Reciever spezified -> returning" ); | 202 | qDebug( "No Reciever spezified -> returning" ); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | mail->setName(senderNameEdit->text()); | 205 | mail->setName(senderNameEdit->text()); |
206 | mail->setCC( ccLine->text() ); | 206 | mail->setCC( ccLine->text() ); |
207 | mail->setBCC( bccLine->text() ); | 207 | mail->setBCC( bccLine->text() ); |
208 | mail->setReply( replyLine->text() ); | 208 | mail->setReply( replyLine->text() ); |
209 | mail->setSubject( subjectLine->text() ); | 209 | mail->setSubject( subjectLine->text() ); |
210 | QString txt = message->text(); | 210 | QString txt = message->text(); |
211 | if ( !sigMultiLine->text().isEmpty() ) { | 211 | if ( !sigMultiLine->text().isEmpty() ) { |
212 | txt.append( "\n--\n" ); | 212 | txt.append( "\n--\n" ); |
213 | txt.append( sigMultiLine->text() ); | 213 | txt.append( sigMultiLine->text() ); |
214 | } | 214 | } |
215 | qDebug(txt); | 215 | qDebug(txt); |
216 | mail->setMessage( txt ); | 216 | mail->setMessage( txt ); |
217 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 217 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
218 | while ( it != NULL ) { | 218 | while ( it != NULL ) { |
219 | mail->addAttachment( it->getAttachment() ); | 219 | mail->addAttachment( it->getAttachment() ); |
220 | it = (AttachViewItem *) it->nextSibling(); | 220 | it = (AttachViewItem *) it->nextSibling(); |
221 | } | 221 | } |
222 | 222 | ||
223 | SMTPwrapper wrapper( smtp ); | 223 | SMTPwrapper wrapper( smtp ); |
224 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); | 224 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); |
225 | 225 | ||
226 | QDialog::accept(); | 226 | QDialog::accept(); |
227 | } | 227 | } |
228 | 228 | ||
229 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 229 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
230 | : QListViewItem( parent ) | 230 | : QListViewItem( parent ) |
231 | { | 231 | { |
232 | attachment = att; | 232 | attachment = att; |
233 | qDebug( att->getMimeType() ); | 233 | qDebug( att->getMimeType() ); |
234 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 234 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |
235 | Resource::loadPixmap( "UnknownDocument-14" ) : | 235 | Resource::loadPixmap( "UnknownDocument-14" ) : |
236 | attachment->getDocLnk().pixmap() ); | 236 | attachment->getDocLnk().pixmap() ); |
237 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 237 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
238 | setText( 1, QString::number( att->getSize() ) ); | 238 | setText( 1, QString::number( att->getSize() ) ); |
239 | } | 239 | } |
240 | 240 | ||
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 28d531b..5c4bdf7 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp | |||
@@ -1,557 +1,575 @@ | |||
1 | 1 | ||
2 | #include "defines.h" | 2 | #include "defines.h" |
3 | #include "editaccounts.h" | 3 | #include "editaccounts.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qt.h> | 9 | #include <qt.h> |
10 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
11 | 11 | ||
12 | #include <libmailwrapper/nntpwrapper.h> | 12 | #include <libmailwrapper/nntpwrapper.h> |
13 | 13 | ||
14 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 14 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
15 | : QListViewItem( parent ) | 15 | : QListViewItem( parent ) |
16 | { | 16 | { |
17 | account = a; | 17 | account = a; |
18 | setText( 0, account->getAccountName() ); | 18 | setText( 0, account->getAccountName() ); |
19 | setText( 1, account->getType() ); | 19 | QString ttext = ""; |
20 | switch (account->getType()) { | ||
21 | case MAILLIB::A_NNTP: | ||
22 | ttext="NNTP"; | ||
23 | break; | ||
24 | case MAILLIB::A_POP3: | ||
25 | ttext = "POP3"; | ||
26 | break; | ||
27 | case MAILLIB::A_IMAP: | ||
28 | ttext = "IMAP"; | ||
29 | break; | ||
30 | case MAILLIB::A_SMTP: | ||
31 | ttext = "SMTP"; | ||
32 | break; | ||
33 | default: | ||
34 | ttext = "UNKNOWN"; | ||
35 | break; | ||
36 | } | ||
37 | setText( 1, ttext); | ||
20 | } | 38 | } |
21 | 39 | ||
22 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 40 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
23 | : EditAccountsUI( parent, name, modal, flags ) | 41 | : EditAccountsUI( parent, name, modal, flags ) |
24 | { | 42 | { |
25 | qDebug( "New Account Configuration Widget" ); | 43 | qDebug( "New Account Configuration Widget" ); |
26 | settings = s; | 44 | settings = s; |
27 | 45 | ||
28 | mailList->addColumn( tr( "Account" ) ); | 46 | mailList->addColumn( tr( "Account" ) ); |
29 | mailList->addColumn( tr( "Type" ) ); | 47 | mailList->addColumn( tr( "Type" ) ); |
30 | 48 | ||
31 | newsList->addColumn( tr( "Account" ) ); | 49 | newsList->addColumn( tr( "Account" ) ); |
32 | 50 | ||
33 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 51 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
34 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 52 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
35 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 53 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
36 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 54 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
37 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 55 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
38 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 56 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
39 | 57 | ||
40 | slotFillLists(); | 58 | slotFillLists(); |
41 | } | 59 | } |
42 | 60 | ||
43 | void EditAccounts::slotFillLists() | 61 | void EditAccounts::slotFillLists() |
44 | { | 62 | { |
45 | mailList->clear(); | 63 | mailList->clear(); |
46 | newsList->clear(); | 64 | newsList->clear(); |
47 | 65 | ||
48 | QList<Account> accounts = settings->getAccounts(); | 66 | QList<Account> accounts = settings->getAccounts(); |
49 | Account *it; | 67 | Account *it; |
50 | for ( it = accounts.first(); it; it = accounts.next() ) | 68 | for ( it = accounts.first(); it; it = accounts.next() ) |
51 | { | 69 | { |
52 | if ( it->getType().compare( "NNTP" ) == 0 ) | 70 | if ( it->getType()==MAILLIB::A_NNTP ) |
53 | { | 71 | { |
54 | (void) new AccountListItem( newsList, it ); | 72 | (void) new AccountListItem( newsList, it ); |
55 | } | 73 | } |
56 | else | 74 | else |
57 | { | 75 | { |
58 | (void) new AccountListItem( mailList, it ); | 76 | (void) new AccountListItem( mailList, it ); |
59 | } | 77 | } |
60 | } | 78 | } |
61 | } | 79 | } |
62 | 80 | ||
63 | void EditAccounts::slotNewMail() | 81 | void EditAccounts::slotNewMail() |
64 | { | 82 | { |
65 | qDebug( "New Mail Account" ); | 83 | qDebug( "New Mail Account" ); |
66 | QString *selection = new QString(); | 84 | QString *selection = new QString(); |
67 | SelectMailType selType( selection, this, 0, true ); | 85 | SelectMailType selType( selection, this, 0, true ); |
68 | selType.show(); | 86 | selType.show(); |
69 | if ( QDialog::Accepted == selType.exec() ) | 87 | if ( QDialog::Accepted == selType.exec() ) |
70 | { | 88 | { |
71 | slotNewAccount( *selection ); | 89 | slotNewAccount( *selection ); |
72 | } | 90 | } |
73 | } | 91 | } |
74 | 92 | ||
75 | void EditAccounts::slotNewAccount( const QString &type ) | 93 | void EditAccounts::slotNewAccount( const QString &type ) |
76 | { | 94 | { |
77 | if ( type.compare( "IMAP" ) == 0 ) | 95 | if ( type.compare( "IMAP" ) == 0 ) |
78 | { | 96 | { |
79 | qDebug( "-> config IMAP" ); | 97 | qDebug( "-> config IMAP" ); |
80 | IMAPaccount *account = new IMAPaccount(); | 98 | IMAPaccount *account = new IMAPaccount(); |
81 | IMAPconfig imap( account, this, 0, true ); | 99 | IMAPconfig imap( account, this, 0, true ); |
82 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 100 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
83 | { | 101 | { |
84 | settings->addAccount( account ); | 102 | settings->addAccount( account ); |
85 | account->save(); | 103 | account->save(); |
86 | slotFillLists(); | 104 | slotFillLists(); |
87 | } | 105 | } |
88 | else | 106 | else |
89 | { | 107 | { |
90 | account->remove(); | 108 | account->remove(); |
91 | } | 109 | } |
92 | } | 110 | } |
93 | else if ( type.compare( "POP3" ) == 0 ) | 111 | else if ( type.compare( "POP3" ) == 0 ) |
94 | { | 112 | { |
95 | qDebug( "-> config POP3" ); | 113 | qDebug( "-> config POP3" ); |
96 | POP3account *account = new POP3account(); | 114 | POP3account *account = new POP3account(); |
97 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 115 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
98 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 116 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
99 | { | 117 | { |
100 | settings->addAccount( account ); | 118 | settings->addAccount( account ); |
101 | account->save(); | 119 | account->save(); |
102 | slotFillLists(); | 120 | slotFillLists(); |
103 | } | 121 | } |
104 | else | 122 | else |
105 | { | 123 | { |
106 | account->remove(); | 124 | account->remove(); |
107 | } | 125 | } |
108 | } | 126 | } |
109 | else if ( type.compare( "SMTP" ) == 0 ) | 127 | else if ( type.compare( "SMTP" ) == 0 ) |
110 | { | 128 | { |
111 | qDebug( "-> config SMTP" ); | 129 | qDebug( "-> config SMTP" ); |
112 | SMTPaccount *account = new SMTPaccount(); | 130 | SMTPaccount *account = new SMTPaccount(); |
113 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 131 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
114 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 132 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
115 | { | 133 | { |
116 | settings->addAccount( account ); | 134 | settings->addAccount( account ); |
117 | account->save(); | 135 | account->save(); |
118 | slotFillLists(); | 136 | slotFillLists(); |
119 | 137 | ||
120 | } | 138 | } |
121 | else | 139 | else |
122 | { | 140 | { |
123 | account->remove(); | 141 | account->remove(); |
124 | } | 142 | } |
125 | } | 143 | } |
126 | else if ( type.compare( "NNTP" ) == 0 ) | 144 | else if ( type.compare( "NNTP" ) == 0 ) |
127 | { | 145 | { |
128 | qDebug( "-> config NNTP" ); | 146 | qDebug( "-> config NNTP" ); |
129 | NNTPaccount *account = new NNTPaccount(); | 147 | NNTPaccount *account = new NNTPaccount(); |
130 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 148 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
131 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 149 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
132 | { | 150 | { |
133 | settings->addAccount( account ); | 151 | settings->addAccount( account ); |
134 | account->save(); | 152 | account->save(); |
135 | slotFillLists(); | 153 | slotFillLists(); |
136 | } | 154 | } |
137 | else | 155 | else |
138 | { | 156 | { |
139 | account->remove(); | 157 | account->remove(); |
140 | } | 158 | } |
141 | } | 159 | } |
142 | } | 160 | } |
143 | 161 | ||
144 | void EditAccounts::slotEditAccount( Account *account ) | 162 | void EditAccounts::slotEditAccount( Account *account ) |
145 | { | 163 | { |
146 | if ( account->getType().compare( "IMAP" ) == 0 ) | 164 | if ( account->getType() == MAILLIB::A_IMAP ) |
147 | { | 165 | { |
148 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 166 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
149 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 167 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
150 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 168 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
151 | { | 169 | { |
152 | slotFillLists(); | 170 | slotFillLists(); |
153 | } | 171 | } |
154 | } | 172 | } |
155 | else if ( account->getType().compare( "POP3" ) == 0 ) | 173 | else if ( account->getType()==MAILLIB::A_POP3 ) |
156 | { | 174 | { |
157 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 175 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
158 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 176 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
159 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 177 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
160 | { | 178 | { |
161 | slotFillLists(); | 179 | slotFillLists(); |
162 | } | 180 | } |
163 | } | 181 | } |
164 | else if ( account->getType().compare( "SMTP" ) == 0 ) | 182 | else if ( account->getType()==MAILLIB::A_SMTP ) |
165 | { | 183 | { |
166 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 184 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
167 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 185 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
168 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 186 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
169 | { | 187 | { |
170 | slotFillLists(); | 188 | slotFillLists(); |
171 | } | 189 | } |
172 | } | 190 | } |
173 | else if ( account->getType().compare( "NNTP" ) == 0 ) | 191 | else if ( account->getType()==MAILLIB::A_NNTP) |
174 | { | 192 | { |
175 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 193 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
176 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 194 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
177 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 195 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
178 | { | 196 | { |
179 | slotFillLists(); | 197 | slotFillLists(); |
180 | } | 198 | } |
181 | } | 199 | } |
182 | } | 200 | } |
183 | 201 | ||
184 | void EditAccounts::slotDeleteAccount( Account *account ) | 202 | void EditAccounts::slotDeleteAccount( Account *account ) |
185 | { | 203 | { |
186 | if ( QMessageBox::information( this, tr( "Question" ), | 204 | if ( QMessageBox::information( this, tr( "Question" ), |
187 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 205 | tr( "<p>Do you really want to delete the selected Account?</p>" ), |
188 | tr( "Yes" ), tr( "No" ) ) == 0 ) | 206 | tr( "Yes" ), tr( "No" ) ) == 0 ) |
189 | { | 207 | { |
190 | settings->delAccount( account ); | 208 | settings->delAccount( account ); |
191 | slotFillLists(); | 209 | slotFillLists(); |
192 | } | 210 | } |
193 | } | 211 | } |
194 | 212 | ||
195 | void EditAccounts::slotEditMail() | 213 | void EditAccounts::slotEditMail() |
196 | { | 214 | { |
197 | qDebug( "Edit Mail Account" ); | 215 | qDebug( "Edit Mail Account" ); |
198 | if ( !mailList->currentItem() ) | 216 | if ( !mailList->currentItem() ) |
199 | { | 217 | { |
200 | QMessageBox::information( this, tr( "Error" ), | 218 | QMessageBox::information( this, tr( "Error" ), |
201 | tr( "<p>Please select an account.</p>" ), | 219 | tr( "<p>Please select an account.</p>" ), |
202 | tr( "Ok" ) ); | 220 | tr( "Ok" ) ); |
203 | return; | 221 | return; |
204 | } | 222 | } |
205 | 223 | ||
206 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 224 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
207 | slotEditAccount( a ); | 225 | slotEditAccount( a ); |
208 | } | 226 | } |
209 | 227 | ||
210 | void EditAccounts::slotDeleteMail() | 228 | void EditAccounts::slotDeleteMail() |
211 | { | 229 | { |
212 | if ( !mailList->currentItem() ) | 230 | if ( !mailList->currentItem() ) |
213 | { | 231 | { |
214 | QMessageBox::information( this, tr( "Error" ), | 232 | QMessageBox::information( this, tr( "Error" ), |
215 | tr( "<p>Please select an account.</p>" ), | 233 | tr( "<p>Please select an account.</p>" ), |
216 | tr( "Ok" ) ); | 234 | tr( "Ok" ) ); |
217 | return; | 235 | return; |
218 | } | 236 | } |
219 | 237 | ||
220 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 238 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
221 | slotDeleteAccount( a ); | 239 | slotDeleteAccount( a ); |
222 | } | 240 | } |
223 | 241 | ||
224 | void EditAccounts::slotNewNews() | 242 | void EditAccounts::slotNewNews() |
225 | { | 243 | { |
226 | qDebug( "New News Account" ); | 244 | qDebug( "New News Account" ); |
227 | slotNewAccount( "NNTP" ); | 245 | slotNewAccount( "NNTP" ); |
228 | } | 246 | } |
229 | 247 | ||
230 | void EditAccounts::slotEditNews() | 248 | void EditAccounts::slotEditNews() |
231 | { | 249 | { |
232 | qDebug( "Edit News Account" ); | 250 | qDebug( "Edit News Account" ); |
233 | if ( !newsList->currentItem() ) | 251 | if ( !newsList->currentItem() ) |
234 | { | 252 | { |
235 | QMessageBox::information( this, tr( "Error" ), | 253 | QMessageBox::information( this, tr( "Error" ), |
236 | tr( "<p>Please select an account.</p>" ), | 254 | tr( "<p>Please select an account.</p>" ), |
237 | tr( "Ok" ) ); | 255 | tr( "Ok" ) ); |
238 | return; | 256 | return; |
239 | } | 257 | } |
240 | 258 | ||
241 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 259 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
242 | slotEditAccount( a ); | 260 | slotEditAccount( a ); |
243 | } | 261 | } |
244 | 262 | ||
245 | void EditAccounts::slotDeleteNews() | 263 | void EditAccounts::slotDeleteNews() |
246 | { | 264 | { |
247 | qDebug( "Delete News Account" ); | 265 | qDebug( "Delete News Account" ); |
248 | if ( !newsList->currentItem() ) | 266 | if ( !newsList->currentItem() ) |
249 | { | 267 | { |
250 | QMessageBox::information( this, tr( "Error" ), | 268 | QMessageBox::information( this, tr( "Error" ), |
251 | tr( "<p>Please select an account.</p>" ), | 269 | tr( "<p>Please select an account.</p>" ), |
252 | tr( "Ok" ) ); | 270 | tr( "Ok" ) ); |
253 | return; | 271 | return; |
254 | } | 272 | } |
255 | 273 | ||
256 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 274 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
257 | slotDeleteAccount( a ); | 275 | slotDeleteAccount( a ); |
258 | } | 276 | } |
259 | 277 | ||
260 | void EditAccounts::slotAdjustColumns() | 278 | void EditAccounts::slotAdjustColumns() |
261 | { | 279 | { |
262 | int currPage = configTab->currentPageIndex(); | 280 | int currPage = configTab->currentPageIndex(); |
263 | 281 | ||
264 | configTab->showPage( mailTab ); | 282 | configTab->showPage( mailTab ); |
265 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 283 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
266 | mailList->setColumnWidth( 1, 50 ); | 284 | mailList->setColumnWidth( 1, 50 ); |
267 | 285 | ||
268 | configTab->showPage( newsTab ); | 286 | configTab->showPage( newsTab ); |
269 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 287 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
270 | 288 | ||
271 | configTab->setCurrentPage( currPage ); | 289 | configTab->setCurrentPage( currPage ); |
272 | } | 290 | } |
273 | 291 | ||
274 | void EditAccounts::accept() | 292 | void EditAccounts::accept() |
275 | { | 293 | { |
276 | settings->saveAccounts(); | 294 | settings->saveAccounts(); |
277 | 295 | ||
278 | QDialog::accept(); | 296 | QDialog::accept(); |
279 | } | 297 | } |
280 | 298 | ||
281 | /** | 299 | /** |
282 | * SelectMailType | 300 | * SelectMailType |
283 | */ | 301 | */ |
284 | 302 | ||
285 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 303 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
286 | : SelectMailTypeUI( parent, name, modal, flags ) | 304 | : SelectMailTypeUI( parent, name, modal, flags ) |
287 | { | 305 | { |
288 | selected = selection; | 306 | selected = selection; |
289 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 307 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
290 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); | 308 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); |
291 | } | 309 | } |
292 | 310 | ||
293 | void SelectMailType::slotSelection( const QString &sel ) | 311 | void SelectMailType::slotSelection( const QString &sel ) |
294 | { | 312 | { |
295 | selected->replace( 0, selected->length(), sel ); | 313 | selected->replace( 0, selected->length(), sel ); |
296 | } | 314 | } |
297 | 315 | ||
298 | /** | 316 | /** |
299 | * IMAPconfig | 317 | * IMAPconfig |
300 | */ | 318 | */ |
301 | 319 | ||
302 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 320 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
303 | : IMAPconfigUI( parent, name, modal, flags ) | 321 | : IMAPconfigUI( parent, name, modal, flags ) |
304 | { | 322 | { |
305 | data = account; | 323 | data = account; |
306 | 324 | ||
307 | fillValues(); | 325 | fillValues(); |
308 | 326 | ||
309 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 327 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
310 | ComboBox1->insertItem( "Only if available", 0 ); | 328 | ComboBox1->insertItem( "Only if available", 0 ); |
311 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 329 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
312 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 330 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
313 | ComboBox1->insertItem( "Run command instead", 3 ); | 331 | ComboBox1->insertItem( "Run command instead", 3 ); |
314 | CommandEdit->hide(); | 332 | CommandEdit->hide(); |
315 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 333 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
316 | } | 334 | } |
317 | 335 | ||
318 | void IMAPconfig::slotConnectionToggle( int index ) | 336 | void IMAPconfig::slotConnectionToggle( int index ) |
319 | { | 337 | { |
320 | if ( index == 2 ) | 338 | if ( index == 2 ) |
321 | { | 339 | { |
322 | portLine->setText( IMAP_SSL_PORT ); | 340 | portLine->setText( IMAP_SSL_PORT ); |
323 | } | 341 | } |
324 | else if ( index == 3 ) | 342 | else if ( index == 3 ) |
325 | { | 343 | { |
326 | portLine->setText( IMAP_PORT ); | 344 | portLine->setText( IMAP_PORT ); |
327 | CommandEdit->show(); | 345 | CommandEdit->show(); |
328 | } | 346 | } |
329 | else | 347 | else |
330 | { | 348 | { |
331 | portLine->setText( IMAP_PORT ); | 349 | portLine->setText( IMAP_PORT ); |
332 | } | 350 | } |
333 | } | 351 | } |
334 | 352 | ||
335 | void IMAPconfig::fillValues() | 353 | void IMAPconfig::fillValues() |
336 | { | 354 | { |
337 | accountLine->setText( data->getAccountName() ); | 355 | accountLine->setText( data->getAccountName() ); |
338 | serverLine->setText( data->getServer() ); | 356 | serverLine->setText( data->getServer() ); |
339 | portLine->setText( data->getPort() ); | 357 | portLine->setText( data->getPort() ); |
340 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 358 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
341 | userLine->setText( data->getUser() ); | 359 | userLine->setText( data->getUser() ); |
342 | passLine->setText( data->getPassword() ); | 360 | passLine->setText( data->getPassword() ); |
343 | prefixLine->setText(data->getPrefix()); | 361 | prefixLine->setText(data->getPrefix()); |
344 | } | 362 | } |
345 | 363 | ||
346 | void IMAPconfig::accept() | 364 | void IMAPconfig::accept() |
347 | { | 365 | { |
348 | data->setAccountName( accountLine->text() ); | 366 | data->setAccountName( accountLine->text() ); |
349 | data->setServer( serverLine->text() ); | 367 | data->setServer( serverLine->text() ); |
350 | data->setPort( portLine->text() ); | 368 | data->setPort( portLine->text() ); |
351 | data->setConnectionType( ComboBox1->currentItem() ); | 369 | data->setConnectionType( ComboBox1->currentItem() ); |
352 | data->setUser( userLine->text() ); | 370 | data->setUser( userLine->text() ); |
353 | data->setPassword( passLine->text() ); | 371 | data->setPassword( passLine->text() ); |
354 | data->setPrefix(prefixLine->text()); | 372 | data->setPrefix(prefixLine->text()); |
355 | 373 | ||
356 | QDialog::accept(); | 374 | QDialog::accept(); |
357 | } | 375 | } |
358 | 376 | ||
359 | /** | 377 | /** |
360 | * POP3config | 378 | * POP3config |
361 | */ | 379 | */ |
362 | 380 | ||
363 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 381 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
364 | : POP3configUI( parent, name, modal, flags ) | 382 | : POP3configUI( parent, name, modal, flags ) |
365 | { | 383 | { |
366 | data = account; | 384 | data = account; |
367 | fillValues(); | 385 | fillValues(); |
368 | 386 | ||
369 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 387 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
370 | ComboBox1->insertItem( "Only if available", 0 ); | 388 | ComboBox1->insertItem( "Only if available", 0 ); |
371 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 389 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
372 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 390 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
373 | ComboBox1->insertItem( "Run command instead", 3 ); | 391 | ComboBox1->insertItem( "Run command instead", 3 ); |
374 | CommandEdit->hide(); | 392 | CommandEdit->hide(); |
375 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 393 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
376 | } | 394 | } |
377 | 395 | ||
378 | void POP3config::slotConnectionToggle( int index ) | 396 | void POP3config::slotConnectionToggle( int index ) |
379 | { | 397 | { |
380 | // 2 is ssl connection | 398 | // 2 is ssl connection |
381 | if ( index == 2 ) | 399 | if ( index == 2 ) |
382 | { | 400 | { |
383 | portLine->setText( POP3_SSL_PORT ); | 401 | portLine->setText( POP3_SSL_PORT ); |
384 | } | 402 | } |
385 | else if ( index == 3 ) | 403 | else if ( index == 3 ) |
386 | { | 404 | { |
387 | portLine->setText( POP3_PORT ); | 405 | portLine->setText( POP3_PORT ); |
388 | CommandEdit->show(); | 406 | CommandEdit->show(); |
389 | } | 407 | } |
390 | else | 408 | else |
391 | { | 409 | { |
392 | portLine->setText( POP3_PORT ); | 410 | portLine->setText( POP3_PORT ); |
393 | } | 411 | } |
394 | } | 412 | } |
395 | 413 | ||
396 | void POP3config::fillValues() | 414 | void POP3config::fillValues() |
397 | { | 415 | { |
398 | accountLine->setText( data->getAccountName() ); | 416 | accountLine->setText( data->getAccountName() ); |
399 | serverLine->setText( data->getServer() ); | 417 | serverLine->setText( data->getServer() ); |
400 | portLine->setText( data->getPort() ); | 418 | portLine->setText( data->getPort() ); |
401 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 419 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
402 | userLine->setText( data->getUser() ); | 420 | userLine->setText( data->getUser() ); |
403 | passLine->setText( data->getPassword() ); | 421 | passLine->setText( data->getPassword() ); |
404 | } | 422 | } |
405 | 423 | ||
406 | void POP3config::accept() | 424 | void POP3config::accept() |
407 | { | 425 | { |
408 | data->setAccountName( accountLine->text() ); | 426 | data->setAccountName( accountLine->text() ); |
409 | data->setServer( serverLine->text() ); | 427 | data->setServer( serverLine->text() ); |
410 | data->setPort( portLine->text() ); | 428 | data->setPort( portLine->text() ); |
411 | data->setConnectionType( ComboBox1->currentItem() ); | 429 | data->setConnectionType( ComboBox1->currentItem() ); |
412 | data->setUser( userLine->text() ); | 430 | data->setUser( userLine->text() ); |
413 | data->setPassword( passLine->text() ); | 431 | data->setPassword( passLine->text() ); |
414 | 432 | ||
415 | QDialog::accept(); | 433 | QDialog::accept(); |
416 | } | 434 | } |
417 | 435 | ||
418 | /** | 436 | /** |
419 | * SMTPconfig | 437 | * SMTPconfig |
420 | */ | 438 | */ |
421 | 439 | ||
422 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 440 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
423 | : SMTPconfigUI( parent, name, modal, flags ) | 441 | : SMTPconfigUI( parent, name, modal, flags ) |
424 | { | 442 | { |
425 | data = account; | 443 | data = account; |
426 | 444 | ||
427 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 445 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
428 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 446 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
429 | 447 | ||
430 | fillValues(); | 448 | fillValues(); |
431 | 449 | ||
432 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 450 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
433 | ComboBox1->insertItem( "Only if available", 0 ); | 451 | ComboBox1->insertItem( "Only if available", 0 ); |
434 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 452 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
435 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 453 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
436 | ComboBox1->insertItem( "Run command instead", 3 ); | 454 | ComboBox1->insertItem( "Run command instead", 3 ); |
437 | CommandEdit->hide(); | 455 | CommandEdit->hide(); |
438 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 456 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
439 | } | 457 | } |
440 | 458 | ||
441 | void SMTPconfig::slotConnectionToggle( int index ) | 459 | void SMTPconfig::slotConnectionToggle( int index ) |
442 | { | 460 | { |
443 | // 2 is ssl connection | 461 | // 2 is ssl connection |
444 | if ( index == 2 ) | 462 | if ( index == 2 ) |
445 | { | 463 | { |
446 | portLine->setText( SMTP_SSL_PORT ); | 464 | portLine->setText( SMTP_SSL_PORT ); |
447 | } | 465 | } |
448 | else if ( index == 3 ) | 466 | else if ( index == 3 ) |
449 | { | 467 | { |
450 | portLine->setText( SMTP_PORT ); | 468 | portLine->setText( SMTP_PORT ); |
451 | CommandEdit->show(); | 469 | CommandEdit->show(); |
452 | } | 470 | } |
453 | else | 471 | else |
454 | { | 472 | { |
455 | portLine->setText( SMTP_PORT ); | 473 | portLine->setText( SMTP_PORT ); |
456 | } | 474 | } |
457 | } | 475 | } |
458 | 476 | ||
459 | void SMTPconfig::fillValues() | 477 | void SMTPconfig::fillValues() |
460 | { | 478 | { |
461 | accountLine->setText( data->getAccountName() ); | 479 | accountLine->setText( data->getAccountName() ); |
462 | serverLine->setText( data->getServer() ); | 480 | serverLine->setText( data->getServer() ); |
463 | portLine->setText( data->getPort() ); | 481 | portLine->setText( data->getPort() ); |
464 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 482 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
465 | loginBox->setChecked( data->getLogin() ); | 483 | loginBox->setChecked( data->getLogin() ); |
466 | userLine->setText( data->getUser() ); | 484 | userLine->setText( data->getUser() ); |
467 | passLine->setText( data->getPassword() ); | 485 | passLine->setText( data->getPassword() ); |
468 | } | 486 | } |
469 | 487 | ||
470 | void SMTPconfig::accept() | 488 | void SMTPconfig::accept() |
471 | { | 489 | { |
472 | data->setAccountName( accountLine->text() ); | 490 | data->setAccountName( accountLine->text() ); |
473 | data->setServer( serverLine->text() ); | 491 | data->setServer( serverLine->text() ); |
474 | data->setPort( portLine->text() ); | 492 | data->setPort( portLine->text() ); |
475 | data->setConnectionType( ComboBox1->currentItem() ); | 493 | data->setConnectionType( ComboBox1->currentItem() ); |
476 | data->setLogin( loginBox->isChecked() ); | 494 | data->setLogin( loginBox->isChecked() ); |
477 | data->setUser( userLine->text() ); | 495 | data->setUser( userLine->text() ); |
478 | data->setPassword( passLine->text() ); | 496 | data->setPassword( passLine->text() ); |
479 | 497 | ||
480 | QDialog::accept(); | 498 | QDialog::accept(); |
481 | } | 499 | } |
482 | 500 | ||
483 | /** | 501 | /** |
484 | * NNTPconfig | 502 | * NNTPconfig |
485 | */ | 503 | */ |
486 | 504 | ||
487 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 505 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
488 | : NNTPconfigUI( parent, name, modal, flags ) | 506 | : NNTPconfigUI( parent, name, modal, flags ) |
489 | { | 507 | { |
490 | data = account; | 508 | data = account; |
491 | 509 | ||
492 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 510 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
493 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 511 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
494 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 512 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
495 | fillValues(); | 513 | fillValues(); |
496 | 514 | ||
497 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 515 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
498 | } | 516 | } |
499 | 517 | ||
500 | void NNTPconfig::slotGetNG() { | 518 | void NNTPconfig::slotGetNG() { |
501 | save(); | 519 | save(); |
502 | data->save(); | 520 | data->save(); |
503 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 521 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
504 | QStringList list = tmp->listAllNewsgroups(); | 522 | QStringList list = tmp->listAllNewsgroups(); |
505 | 523 | ||
506 | ListViewGroups->clear(); | 524 | ListViewGroups->clear(); |
507 | 525 | ||
508 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 526 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
509 | QCheckListItem *item; | 527 | QCheckListItem *item; |
510 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 528 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
511 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 529 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
512 | item->setOn( true ); | 530 | item->setOn( true ); |
513 | } | 531 | } |
514 | } | 532 | } |
515 | } | 533 | } |
516 | 534 | ||
517 | void NNTPconfig::slotSSL( bool enabled ) | 535 | void NNTPconfig::slotSSL( bool enabled ) |
518 | { | 536 | { |
519 | if ( enabled ) | 537 | if ( enabled ) |
520 | { | 538 | { |
521 | portLine->setText( NNTP_SSL_PORT ); | 539 | portLine->setText( NNTP_SSL_PORT ); |
522 | } | 540 | } |
523 | else | 541 | else |
524 | { | 542 | { |
525 | portLine->setText( NNTP_PORT ); | 543 | portLine->setText( NNTP_PORT ); |
526 | } | 544 | } |
527 | } | 545 | } |
528 | 546 | ||
529 | void NNTPconfig::fillValues() | 547 | void NNTPconfig::fillValues() |
530 | { | 548 | { |
531 | accountLine->setText( data->getAccountName() ); | 549 | accountLine->setText( data->getAccountName() ); |
532 | serverLine->setText( data->getServer() ); | 550 | serverLine->setText( data->getServer() ); |
533 | portLine->setText( data->getPort() ); | 551 | portLine->setText( data->getPort() ); |
534 | sslBox->setChecked( data->getSSL() ); | 552 | sslBox->setChecked( data->getSSL() ); |
535 | loginBox->setChecked( data->getLogin() ); | 553 | loginBox->setChecked( data->getLogin() ); |
536 | userLine->setText( data->getUser() ); | 554 | userLine->setText( data->getUser() ); |
537 | passLine->setText( data->getPassword() ); | 555 | passLine->setText( data->getPassword() ); |
538 | subscribedGroups = data->getGroups(); | 556 | subscribedGroups = data->getGroups(); |
539 | /* don't forget that - you will overwrite values if user clicks cancel! */ | 557 | /* don't forget that - you will overwrite values if user clicks cancel! */ |
540 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 558 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
541 | QCheckListItem *item; | 559 | QCheckListItem *item; |
542 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 560 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
543 | item->setOn( true ); | 561 | item->setOn( true ); |
544 | } | 562 | } |
545 | } | 563 | } |
546 | 564 | ||
547 | void NNTPconfig::save() | 565 | void NNTPconfig::save() |
548 | { | 566 | { |
549 | data->setAccountName( accountLine->text() ); | 567 | data->setAccountName( accountLine->text() ); |
550 | data->setServer( serverLine->text() ); | 568 | data->setServer( serverLine->text() ); |
551 | data->setPort( portLine->text() ); | 569 | data->setPort( portLine->text() ); |
552 | data->setSSL( sslBox->isChecked() ); | 570 | data->setSSL( sslBox->isChecked() ); |
553 | data->setLogin( loginBox->isChecked() ); | 571 | data->setLogin( loginBox->isChecked() ); |
554 | data->setUser( userLine->text() ); | 572 | data->setUser( userLine->text() ); |
555 | data->setPassword( passLine->text() ); | 573 | data->setPassword( passLine->text() ); |
556 | 574 | ||
557 | QListViewItemIterator list_it( ListViewGroups ); | 575 | QListViewItemIterator list_it( ListViewGroups ); |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index b6e1538..442ebfe 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,66 +1,68 @@ | |||
1 | #ifndef __abstract_mail_ | 1 | #ifndef __abstract_mail_ |
2 | #define __abstract_mail_ | 2 | #define __abstract_mail_ |
3 | 3 | ||
4 | #include "maildefines.h" | ||
5 | |||
4 | #include <qobject.h> | 6 | #include <qobject.h> |
5 | #include "settings.h" | 7 | #include "settings.h" |
6 | 8 | ||
7 | class RecMail; | 9 | class RecMail; |
8 | class RecBody; | 10 | class RecBody; |
9 | class RecPart; | 11 | class RecPart; |
10 | class IMAPwrapper; | 12 | class IMAPwrapper; |
11 | class POP3wrapper; | 13 | class POP3wrapper; |
12 | class Folder; | 14 | class Folder; |
13 | class encodedString; | 15 | class encodedString; |
14 | struct folderStat; | 16 | struct folderStat; |
15 | 17 | ||
16 | class AbstractMail:public QObject | 18 | class AbstractMail:public QObject |
17 | { | 19 | { |
18 | Q_OBJECT | 20 | Q_OBJECT |
19 | public: | 21 | public: |
20 | AbstractMail(){}; | 22 | AbstractMail(){}; |
21 | virtual ~AbstractMail(){} | 23 | virtual ~AbstractMail(){} |
22 | virtual QList<Folder>* listFolders()=0; | 24 | virtual QList<Folder>* listFolders()=0; |
23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 25 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
25 | virtual RecBody fetchBody(const RecMail&mail)=0; | 27 | virtual RecBody fetchBody(const RecMail&mail)=0; |
26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 29 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 30 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
29 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; | 31 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; |
30 | 32 | ||
31 | virtual void deleteMail(const RecMail&mail)=0; | 33 | virtual void deleteMail(const RecMail&mail)=0; |
32 | virtual void answeredMail(const RecMail&mail)=0; | 34 | virtual void answeredMail(const RecMail&mail)=0; |
33 | virtual int deleteAllMail(const Folder*)=0; | 35 | virtual int deleteAllMail(const Folder*)=0; |
34 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 36 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
35 | virtual int deleteMbox(const Folder*)=0; | 37 | virtual int deleteMbox(const Folder*)=0; |
36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 38 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
37 | 39 | ||
38 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 40 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
39 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 41 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
40 | 42 | ||
41 | virtual void cleanMimeCache(){}; | 43 | virtual void cleanMimeCache(){}; |
42 | /* mail box methods */ | 44 | /* mail box methods */ |
43 | /* parameter is the box to create. | 45 | /* parameter is the box to create. |
44 | * if the implementing subclass has prefixes, | 46 | * if the implementing subclass has prefixes, |
45 | * them has to be appended automatic. | 47 | * them has to be appended automatic. |
46 | */ | 48 | */ |
47 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 49 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
48 | virtual void logout()=0; | 50 | virtual void logout()=0; |
49 | 51 | ||
50 | static AbstractMail* getWrapper(IMAPaccount *a); | 52 | static AbstractMail* getWrapper(IMAPaccount *a); |
51 | static AbstractMail* getWrapper(POP3account *a); | 53 | static AbstractMail* getWrapper(POP3account *a); |
52 | static AbstractMail* getWrapper(NNTPaccount *a); | 54 | static AbstractMail* getWrapper(NNTPaccount *a); |
53 | /* mbox only! */ | 55 | /* mbox only! */ |
54 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 56 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
55 | 57 | ||
56 | static QString defaultLocalfolder(); | 58 | static QString defaultLocalfolder(); |
57 | 59 | ||
58 | virtual const QString&getType()const=0; | 60 | virtual MAILLIB::ATYPE getType()const=0; |
59 | virtual const QString&getName()const=0; | 61 | virtual const QString&getName()const=0; |
60 | 62 | ||
61 | protected: | 63 | protected: |
62 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 64 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
63 | static QString convert_String(const char*text); | 65 | static QString convert_String(const char*text); |
64 | static QString gen_attachment_id(); | 66 | static QString gen_attachment_id(); |
65 | }; | 67 | }; |
66 | #endif | 68 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 350808a..3fe319b 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -63,450 +63,454 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | |||
63 | target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 63 | target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
64 | } | 64 | } |
65 | break; | 65 | break; |
66 | } | 66 | } |
67 | if (type->ct_parameters) { | 67 | if (type->ct_parameters) { |
68 | fillParameters(target,type->ct_parameters); | 68 | fillParameters(target,type->ct_parameters); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 71 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
72 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 72 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
73 | field = (mailmime_field*)current->data; | 73 | field = (mailmime_field*)current->data; |
74 | switch(field->fld_type) { | 74 | switch(field->fld_type) { |
75 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 75 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
76 | target.setEncoding(getencoding(field->fld_data.fld_encoding)); | 76 | target.setEncoding(getencoding(field->fld_data.fld_encoding)); |
77 | break; | 77 | break; |
78 | case MAILMIME_FIELD_ID: | 78 | case MAILMIME_FIELD_ID: |
79 | target.setIdentifier(field->fld_data.fld_id); | 79 | target.setIdentifier(field->fld_data.fld_id); |
80 | break; | 80 | break; |
81 | case MAILMIME_FIELD_DESCRIPTION: | 81 | case MAILMIME_FIELD_DESCRIPTION: |
82 | target.setDescription(field->fld_data.fld_description); | 82 | target.setDescription(field->fld_data.fld_description); |
83 | break; | 83 | break; |
84 | default: | 84 | default: |
85 | break; | 85 | break; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Genericwrapper::fillParameters(RecPart&target,clist*parameters) | 91 | void Genericwrapper::fillParameters(RecPart&target,clist*parameters) |
92 | { | 92 | { |
93 | if (!parameters) {return;} | 93 | if (!parameters) {return;} |
94 | clistcell*current=0; | 94 | clistcell*current=0; |
95 | mailmime_parameter*param; | 95 | mailmime_parameter*param; |
96 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 96 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
97 | param = (mailmime_parameter*)current->data; | 97 | param = (mailmime_parameter*)current->data; |
98 | if (param) { | 98 | if (param) { |
99 | target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 99 | target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 104 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
105 | { | 105 | { |
106 | QString enc="7bit"; | 106 | QString enc="7bit"; |
107 | if (!aEnc) return enc; | 107 | if (!aEnc) return enc; |
108 | switch(aEnc->enc_type) { | 108 | switch(aEnc->enc_type) { |
109 | case MAILMIME_MECHANISM_7BIT: | 109 | case MAILMIME_MECHANISM_7BIT: |
110 | enc = "7bit"; | 110 | enc = "7bit"; |
111 | break; | 111 | break; |
112 | case MAILMIME_MECHANISM_8BIT: | 112 | case MAILMIME_MECHANISM_8BIT: |
113 | enc = "8bit"; | 113 | enc = "8bit"; |
114 | break; | 114 | break; |
115 | case MAILMIME_MECHANISM_BINARY: | 115 | case MAILMIME_MECHANISM_BINARY: |
116 | enc = "binary"; | 116 | enc = "binary"; |
117 | break; | 117 | break; |
118 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 118 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
119 | enc = "quoted-printable"; | 119 | enc = "quoted-printable"; |
120 | break; | 120 | break; |
121 | case MAILMIME_MECHANISM_BASE64: | 121 | case MAILMIME_MECHANISM_BASE64: |
122 | enc = "base64"; | 122 | enc = "base64"; |
123 | break; | 123 | break; |
124 | case MAILMIME_MECHANISM_TOKEN: | 124 | case MAILMIME_MECHANISM_TOKEN: |
125 | default: | 125 | default: |
126 | if (aEnc->enc_token) { | 126 | if (aEnc->enc_token) { |
127 | enc = QString(aEnc->enc_token); | 127 | enc = QString(aEnc->enc_token); |
128 | } | 128 | } |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | return enc; | 131 | return enc; |
132 | } | 132 | } |
133 | 133 | ||
134 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 134 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
135 | { | 135 | { |
136 | if (current_rec >= 10) { | 136 | if (current_rec >= 10) { |
137 | qDebug("too deep recursion!"); | 137 | qDebug("too deep recursion!"); |
138 | } | 138 | } |
139 | if (!message || !mime) { | 139 | if (!message || !mime) { |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | int r; | 142 | int r; |
143 | char*data = 0; | 143 | char*data = 0; |
144 | size_t len; | 144 | size_t len; |
145 | clistiter * cur = 0; | 145 | clistiter * cur = 0; |
146 | QString b; | 146 | QString b; |
147 | RecPart part; | 147 | RecPart part; |
148 | 148 | ||
149 | switch (mime->mm_type) { | 149 | switch (mime->mm_type) { |
150 | case MAILMIME_SINGLE: | 150 | case MAILMIME_SINGLE: |
151 | { | 151 | { |
152 | QValueList<int>countlist = recList; | 152 | QValueList<int>countlist = recList; |
153 | countlist.append(current_count); | 153 | countlist.append(current_count); |
154 | r = mailmessage_fetch_section(message,mime,&data,&len); | 154 | r = mailmessage_fetch_section(message,mime,&data,&len); |
155 | part.setSize(len); | 155 | part.setSize(len); |
156 | part.setPositionlist(countlist); | 156 | part.setPositionlist(countlist); |
157 | b = gen_attachment_id(); | 157 | b = gen_attachment_id(); |
158 | part.setIdentifier(b); | 158 | part.setIdentifier(b); |
159 | fillSingleBody(part,message,mime); | 159 | fillSingleBody(part,message,mime); |
160 | if (part.Type()=="text" && target.Bodytext().isNull()) { | 160 | if (part.Type()=="text" && target.Bodytext().isNull()) { |
161 | encodedString*r = new encodedString(); | 161 | encodedString*r = new encodedString(); |
162 | r->setContent(data,len); | 162 | r->setContent(data,len); |
163 | encodedString*res = decode_String(r,part.Encoding()); | 163 | encodedString*res = decode_String(r,part.Encoding()); |
164 | if (countlist.count()>2) { | 164 | if (countlist.count()>2) { |
165 | bodyCache[b]=r; | 165 | bodyCache[b]=r; |
166 | target.addPart(part); | 166 | target.addPart(part); |
167 | } else { | 167 | } else { |
168 | delete r; | 168 | delete r; |
169 | } | 169 | } |
170 | b = QString(res->Content()); | 170 | b = QString(res->Content()); |
171 | delete res; | 171 | delete res; |
172 | target.setBodytext(b); | 172 | target.setBodytext(b); |
173 | target.setDescription(part); | 173 | target.setDescription(part); |
174 | } else { | 174 | } else { |
175 | bodyCache[b]=new encodedString(data,len); | 175 | bodyCache[b]=new encodedString(data,len); |
176 | target.addPart(part); | 176 | target.addPart(part); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | break; | 179 | break; |
180 | case MAILMIME_MULTIPLE: | 180 | case MAILMIME_MULTIPLE: |
181 | { | 181 | { |
182 | unsigned int ccount = 1; | 182 | unsigned int ccount = 1; |
183 | mailmime*cbody=0; | 183 | mailmime*cbody=0; |
184 | QValueList<int>countlist = recList; | 184 | QValueList<int>countlist = recList; |
185 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 185 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
186 | cbody = (mailmime*)clist_content(cur); | 186 | cbody = (mailmime*)clist_content(cur); |
187 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 187 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
188 | RecPart targetPart; | 188 | RecPart targetPart; |
189 | targetPart.setType("multipart"); | 189 | targetPart.setType("multipart"); |
190 | countlist.append(current_count); | 190 | countlist.append(current_count); |
191 | targetPart.setPositionlist(countlist); | 191 | targetPart.setPositionlist(countlist); |
192 | target.addPart(targetPart); | 192 | target.addPart(targetPart); |
193 | } | 193 | } |
194 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 194 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
195 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 195 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
196 | countlist = recList; | 196 | countlist = recList; |
197 | } | 197 | } |
198 | ++ccount; | 198 | ++ccount; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | break; | 201 | break; |
202 | case MAILMIME_MESSAGE: | 202 | case MAILMIME_MESSAGE: |
203 | { | 203 | { |
204 | QValueList<int>countlist = recList; | 204 | QValueList<int>countlist = recList; |
205 | countlist.append(current_count); | 205 | countlist.append(current_count); |
206 | /* the own header is always at recursion 0 - we don't need that */ | 206 | /* the own header is always at recursion 0 - we don't need that */ |
207 | if (current_rec > 0) { | 207 | if (current_rec > 0) { |
208 | part.setPositionlist(countlist); | 208 | part.setPositionlist(countlist); |
209 | r = mailmessage_fetch_section(message,mime,&data,&len); | 209 | r = mailmessage_fetch_section(message,mime,&data,&len); |
210 | part.setSize(len); | 210 | part.setSize(len); |
211 | part.setPositionlist(countlist); | 211 | part.setPositionlist(countlist); |
212 | b = gen_attachment_id(); | 212 | b = gen_attachment_id(); |
213 | part.setIdentifier(b); | 213 | part.setIdentifier(b); |
214 | part.setType("message"); | 214 | part.setType("message"); |
215 | part.setSubtype("rfc822"); | 215 | part.setSubtype("rfc822"); |
216 | bodyCache[b]=new encodedString(data,len); | 216 | bodyCache[b]=new encodedString(data,len); |
217 | target.addPart(part); | 217 | target.addPart(part); |
218 | } | 218 | } |
219 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 219 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
220 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 220 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | break; | 223 | break; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | RecBody Genericwrapper::parseMail( mailmessage * msg ) | 227 | RecBody Genericwrapper::parseMail( mailmessage * msg ) |
228 | { | 228 | { |
229 | int err = MAILIMF_NO_ERROR; | 229 | int err = MAILIMF_NO_ERROR; |
230 | mailmime_single_fields fields; | 230 | mailmime_single_fields fields; |
231 | /* is bound to msg and will be freed there */ | 231 | /* is bound to msg and will be freed there */ |
232 | mailmime * mime=0; | 232 | mailmime * mime=0; |
233 | RecBody body; | 233 | RecBody body; |
234 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 234 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
235 | err = mailmessage_get_bodystructure(msg,&mime); | 235 | err = mailmessage_get_bodystructure(msg,&mime); |
236 | QValueList<int>recList; | 236 | QValueList<int>recList; |
237 | traverseBody(body,msg,mime,recList); | 237 | traverseBody(body,msg,mime,recList); |
238 | return body; | 238 | return body; |
239 | } | 239 | } |
240 | 240 | ||
241 | RecMail *Genericwrapper::parseHeader( const char *header ) | 241 | RecMail *Genericwrapper::parseHeader( const char *header ) |
242 | { | 242 | { |
243 | int err = MAILIMF_NO_ERROR; | 243 | int err = MAILIMF_NO_ERROR; |
244 | size_t curTok = 0; | 244 | size_t curTok = 0; |
245 | RecMail *mail = new RecMail(); | 245 | RecMail *mail = new RecMail(); |
246 | mailimf_fields *fields = 0; | 246 | mailimf_fields *fields = 0; |
247 | mailimf_references * refs = 0; | 247 | mailimf_references * refs = 0; |
248 | mailimf_keywords*keys = 0; | 248 | mailimf_keywords*keys = 0; |
249 | QString status; | 249 | QString status; |
250 | QString value; | 250 | QString value; |
251 | QBitArray mFlags(7); | 251 | QBitArray mFlags(7); |
252 | 252 | ||
253 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 253 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
254 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { | 254 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { |
255 | mailimf_field *field = (mailimf_field *) current->data; | 255 | mailimf_field *field = (mailimf_field *) current->data; |
256 | switch ( field->fld_type ) { | 256 | switch ( field->fld_type ) { |
257 | case MAILIMF_FIELD_FROM: | 257 | case MAILIMF_FIELD_FROM: |
258 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); | 258 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); |
259 | break; | 259 | break; |
260 | case MAILIMF_FIELD_TO: | 260 | case MAILIMF_FIELD_TO: |
261 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); | 261 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); |
262 | break; | 262 | break; |
263 | case MAILIMF_FIELD_CC: | 263 | case MAILIMF_FIELD_CC: |
264 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); | 264 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); |
265 | break; | 265 | break; |
266 | case MAILIMF_FIELD_BCC: | 266 | case MAILIMF_FIELD_BCC: |
267 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); | 267 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); |
268 | break; | 268 | break; |
269 | case MAILIMF_FIELD_SUBJECT: | 269 | case MAILIMF_FIELD_SUBJECT: |
270 | mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) ); | 270 | mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) ); |
271 | break; | 271 | break; |
272 | case MAILIMF_FIELD_ORIG_DATE: | 272 | case MAILIMF_FIELD_ORIG_DATE: |
273 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); | 273 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); |
274 | break; | 274 | break; |
275 | case MAILIMF_FIELD_MESSAGE_ID: | 275 | case MAILIMF_FIELD_MESSAGE_ID: |
276 | mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); | 276 | mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); |
277 | break; | 277 | break; |
278 | case MAILIMF_FIELD_REFERENCES: | 278 | case MAILIMF_FIELD_REFERENCES: |
279 | refs = field->fld_data.fld_references; | 279 | refs = field->fld_data.fld_references; |
280 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 280 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
281 | char * text = (char*)refs->mid_list->first->data; | 281 | char * text = (char*)refs->mid_list->first->data; |
282 | mail->setReplyto(QString(text)); | 282 | mail->setReplyto(QString(text)); |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | case MAILIMF_FIELD_KEYWORDS: | 285 | case MAILIMF_FIELD_KEYWORDS: |
286 | keys = field->fld_data.fld_keywords; | 286 | keys = field->fld_data.fld_keywords; |
287 | for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { | 287 | for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { |
288 | qDebug("Keyword: %s",(char*)cur->data); | 288 | qDebug("Keyword: %s",(char*)cur->data); |
289 | } | 289 | } |
290 | break; | 290 | break; |
291 | case MAILIMF_FIELD_OPTIONAL_FIELD: | 291 | case MAILIMF_FIELD_OPTIONAL_FIELD: |
292 | status = field->fld_data.fld_optional_field->fld_name; | 292 | status = field->fld_data.fld_optional_field->fld_name; |
293 | value = field->fld_data.fld_optional_field->fld_value; | 293 | value = field->fld_data.fld_optional_field->fld_value; |
294 | if (status.lower()=="status") { | 294 | if (status.lower()=="status") { |
295 | if (value.lower()=="ro") { | 295 | if (value.lower()=="ro") { |
296 | mFlags.setBit(FLAG_SEEN); | 296 | mFlags.setBit(FLAG_SEEN); |
297 | } | 297 | } |
298 | } else if (status.lower()=="x-status") { | 298 | } else if (status.lower()=="x-status") { |
299 | qDebug("X-Status: %s",value.latin1()); | 299 | qDebug("X-Status: %s",value.latin1()); |
300 | if (value.lower()=="a") { | 300 | if (value.lower()=="a") { |
301 | mFlags.setBit(FLAG_ANSWERED); | 301 | mFlags.setBit(FLAG_ANSWERED); |
302 | } | 302 | } |
303 | } else { | 303 | } else { |
304 | // qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, | 304 | // qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, |
305 | // field->fld_data.fld_optional_field->fld_value); | 305 | // field->fld_data.fld_optional_field->fld_value); |
306 | } | 306 | } |
307 | break; | 307 | break; |
308 | default: | 308 | default: |
309 | qDebug("Non parsed field"); | 309 | qDebug("Non parsed field"); |
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | if (fields) mailimf_fields_free(fields); | 313 | if (fields) mailimf_fields_free(fields); |
314 | mail->setFlags(mFlags); | 314 | mail->setFlags(mFlags); |
315 | return mail; | 315 | return mail; |
316 | } | 316 | } |
317 | 317 | ||
318 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 318 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
319 | { | 319 | { |
320 | char tmp[23]; | 320 | char tmp[23]; |
321 | 321 | ||
322 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 322 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
323 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 323 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
324 | 324 | ||
325 | return QString( tmp ); | 325 | return QString( tmp ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 328 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
329 | { | 329 | { |
330 | QString result( "" ); | 330 | QString result( "" ); |
331 | 331 | ||
332 | bool first = true; | 332 | bool first = true; |
333 | if (list == 0) return result; | 333 | if (list == 0) return result; |
334 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 334 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
335 | mailimf_address *addr = (mailimf_address *) current->data; | 335 | mailimf_address *addr = (mailimf_address *) current->data; |
336 | 336 | ||
337 | if ( !first ) { | 337 | if ( !first ) { |
338 | result.append( "," ); | 338 | result.append( "," ); |
339 | } else { | 339 | } else { |
340 | first = false; | 340 | first = false; |
341 | } | 341 | } |
342 | 342 | ||
343 | switch ( addr->ad_type ) { | 343 | switch ( addr->ad_type ) { |
344 | case MAILIMF_ADDRESS_MAILBOX: | 344 | case MAILIMF_ADDRESS_MAILBOX: |
345 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 345 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
346 | break; | 346 | break; |
347 | case MAILIMF_ADDRESS_GROUP: | 347 | case MAILIMF_ADDRESS_GROUP: |
348 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 348 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
349 | break; | 349 | break; |
350 | default: | 350 | default: |
351 | qDebug( "Generic: unkown mailimf address type" ); | 351 | qDebug( "Generic: unkown mailimf address type" ); |
352 | break; | 352 | break; |
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | return result; | 356 | return result; |
357 | } | 357 | } |
358 | 358 | ||
359 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 359 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
360 | { | 360 | { |
361 | QString result( "" ); | 361 | QString result( "" ); |
362 | 362 | ||
363 | result.append( group->grp_display_name ); | 363 | result.append( group->grp_display_name ); |
364 | result.append( ": " ); | 364 | result.append( ": " ); |
365 | 365 | ||
366 | if ( group->grp_mb_list != NULL ) { | 366 | if ( group->grp_mb_list != NULL ) { |
367 | result.append( parseMailboxList( group->grp_mb_list ) ); | 367 | result.append( parseMailboxList( group->grp_mb_list ) ); |
368 | } | 368 | } |
369 | 369 | ||
370 | result.append( ";" ); | 370 | result.append( ";" ); |
371 | 371 | ||
372 | return result; | 372 | return result; |
373 | } | 373 | } |
374 | 374 | ||
375 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 375 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
376 | { | 376 | { |
377 | QString result( "" ); | 377 | QString result( "" ); |
378 | 378 | ||
379 | if ( box->mb_display_name == NULL ) { | 379 | if ( box->mb_display_name == NULL ) { |
380 | result.append( box->mb_addr_spec ); | 380 | result.append( box->mb_addr_spec ); |
381 | } else { | 381 | } else { |
382 | result.append( convert_String(box->mb_display_name).latin1() ); | 382 | result.append( convert_String(box->mb_display_name).latin1() ); |
383 | result.append( " <" ); | 383 | result.append( " <" ); |
384 | result.append( box->mb_addr_spec ); | 384 | result.append( box->mb_addr_spec ); |
385 | result.append( ">" ); | 385 | result.append( ">" ); |
386 | } | 386 | } |
387 | 387 | ||
388 | return result; | 388 | return result; |
389 | } | 389 | } |
390 | 390 | ||
391 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 391 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
392 | { | 392 | { |
393 | QString result( "" ); | 393 | QString result( "" ); |
394 | 394 | ||
395 | bool first = true; | 395 | bool first = true; |
396 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 396 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
397 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 397 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
398 | 398 | ||
399 | if ( !first ) { | 399 | if ( !first ) { |
400 | result.append( "," ); | 400 | result.append( "," ); |
401 | } else { | 401 | } else { |
402 | first = false; | 402 | first = false; |
403 | } | 403 | } |
404 | 404 | ||
405 | result.append( parseMailbox( box ) ); | 405 | result.append( parseMailbox( box ) ); |
406 | } | 406 | } |
407 | 407 | ||
408 | return result; | 408 | return result; |
409 | } | 409 | } |
410 | 410 | ||
411 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) | 411 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) |
412 | { | 412 | { |
413 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 413 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
414 | if (it==bodyCache.end()) return new encodedString(); | 414 | if (it==bodyCache.end()) return new encodedString(); |
415 | encodedString*t = decode_String(it.data(),part.Encoding()); | 415 | encodedString*t = decode_String(it.data(),part.Encoding()); |
416 | return t; | 416 | return t; |
417 | } | 417 | } |
418 | 418 | ||
419 | encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 419 | encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
420 | { | 420 | { |
421 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 421 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
422 | if (it==bodyCache.end()) return new encodedString(); | 422 | if (it==bodyCache.end()) return new encodedString(); |
423 | encodedString*t = it.data(); | 423 | encodedString*t = it.data(); |
424 | return t; | 424 | return t; |
425 | } | 425 | } |
426 | 426 | ||
427 | QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 427 | QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) |
428 | { | 428 | { |
429 | encodedString*t = fetchDecodedPart(mail,part); | 429 | encodedString*t = fetchDecodedPart(mail,part); |
430 | QString text=t->Content(); | 430 | QString text=t->Content(); |
431 | delete t; | 431 | delete t; |
432 | return text; | 432 | return text; |
433 | } | 433 | } |
434 | 434 | ||
435 | void Genericwrapper::cleanMimeCache() | 435 | void Genericwrapper::cleanMimeCache() |
436 | { | 436 | { |
437 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 437 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
438 | for (;it!=bodyCache.end();++it) { | 438 | for (;it!=bodyCache.end();++it) { |
439 | encodedString*t = it.data(); | 439 | encodedString*t = it.data(); |
440 | //it.setValue(0); | 440 | //it.setValue(0); |
441 | if (t) delete t; | 441 | if (t) delete t; |
442 | } | 442 | } |
443 | bodyCache.clear(); | 443 | bodyCache.clear(); |
444 | qDebug("Genericwrapper: cache cleaned"); | 444 | qDebug("Genericwrapper: cache cleaned"); |
445 | } | 445 | } |
446 | 446 | ||
447 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox) | 447 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
448 | { | 448 | { |
449 | int r; | 449 | int r; |
450 | mailmessage_list * env_list = 0; | 450 | mailmessage_list * env_list = 0; |
451 | r = mailsession_get_messages_list(session,&env_list); | 451 | r = mailsession_get_messages_list(session,&env_list); |
452 | if (r != MAIL_NO_ERROR) { | 452 | if (r != MAIL_NO_ERROR) { |
453 | qDebug("Error message list"); | 453 | qDebug("Error message list"); |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | r = mailsession_get_envelopes_list(session, env_list); | 456 | r = mailsession_get_envelopes_list(session, env_list); |
457 | if (r != MAIL_NO_ERROR) { | 457 | if (r != MAIL_NO_ERROR) { |
458 | qDebug("Error filling message list"); | 458 | qDebug("Error filling message list"); |
459 | if (env_list) { | 459 | if (env_list) { |
460 | mailmessage_list_free(env_list); | 460 | mailmessage_list_free(env_list); |
461 | } | 461 | } |
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | mailimf_references * refs; | 464 | mailimf_references * refs; |
465 | uint32_t i = 0; | 465 | uint32_t i = 0; |
466 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 466 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
467 | mailmessage * msg; | 467 | mailmessage * msg; |
468 | QBitArray mFlags(7); | 468 | QBitArray mFlags(7); |
469 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 469 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
470 | if (msg->msg_fields == NULL) { | 470 | if (msg->msg_fields == NULL) { |
471 | //qDebug("could not fetch envelope of message %i", i); | 471 | //qDebug("could not fetch envelope of message %i", i); |
472 | continue; | 472 | continue; |
473 | } | 473 | } |
474 | RecMail * mail = new RecMail(); | 474 | RecMail * mail = new RecMail(); |
475 | mail->setWrapper(this); | 475 | mail->setWrapper(this); |
476 | mail_flags * flag_result = 0; | 476 | mail_flags * flag_result = 0; |
477 | r = mailmessage_get_flags(msg,&flag_result); | 477 | r = mailmessage_get_flags(msg,&flag_result); |
478 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 478 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
479 | mFlags.setBit(FLAG_SEEN); | 479 | mFlags.setBit(FLAG_SEEN); |
480 | } | 480 | } |
481 | mailimf_single_fields single_fields; | 481 | mailimf_single_fields single_fields; |
482 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 482 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
483 | mail->setMsgsize(msg->msg_size); | 483 | mail->setMsgsize(msg->msg_size); |
484 | mail->setFlags(mFlags); | 484 | mail->setFlags(mFlags); |
485 | mail->setMbox(mailbox); | 485 | mail->setMbox(mailbox); |
486 | mail->setNumber(msg->msg_index); | 486 | mail->setNumber(msg->msg_index); |
487 | if (single_fields.fld_subject) | 487 | if (single_fields.fld_subject) |
488 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 488 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
489 | if (single_fields.fld_from) | 489 | if (single_fields.fld_from) |
490 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 490 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
491 | if (single_fields.fld_to) | 491 | if (!mbox_as_to) { |
492 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 492 | if (single_fields.fld_to) |
493 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | ||
494 | } else { | ||
495 | mail->setTo(mailbox); | ||
496 | } | ||
493 | if (single_fields.fld_cc) | 497 | if (single_fields.fld_cc) |
494 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 498 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
495 | if (single_fields.fld_bcc) | 499 | if (single_fields.fld_bcc) |
496 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 500 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
497 | if (single_fields.fld_orig_date) | 501 | if (single_fields.fld_orig_date) |
498 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 502 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
499 | // crashes when accessing pop3 account | 503 | // crashes when accessing pop3 account |
500 | // if (single_fields.fld_message_id->mid_value) | 504 | // if (single_fields.fld_message_id->mid_value) |
501 | // mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 505 | // mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
502 | refs = single_fields.fld_references; | 506 | refs = single_fields.fld_references; |
503 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 507 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
504 | char * text = (char*)refs->mid_list->first->data; | 508 | char * text = (char*)refs->mid_list->first->data; |
505 | mail->setReplyto(QString(text)); | 509 | mail->setReplyto(QString(text)); |
506 | } | 510 | } |
507 | target.append(mail); | 511 | target.append(mail); |
508 | } | 512 | } |
509 | if (env_list) { | 513 | if (env_list) { |
510 | mailmessage_list_free(env_list); | 514 | mailmessage_list_free(env_list); |
511 | } | 515 | } |
512 | } | 516 | } |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index e471dc8..b451416 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -1,66 +1,66 @@ | |||
1 | #ifndef __GENERIC_WRAPPER_H | 1 | #ifndef __GENERIC_WRAPPER_H |
2 | #define __GENERIC_WRAPPER_H | 2 | #define __GENERIC_WRAPPER_H |
3 | 3 | ||
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class encodedString; | 11 | class encodedString; |
12 | struct mailpop3; | 12 | struct mailpop3; |
13 | struct mailmessage; | 13 | struct mailmessage; |
14 | struct mailmime; | 14 | struct mailmime; |
15 | struct mailmime_mechanism; | 15 | struct mailmime_mechanism; |
16 | struct mailimf_mailbox_list; | 16 | struct mailimf_mailbox_list; |
17 | struct mailimf_mailbox; | 17 | struct mailimf_mailbox; |
18 | struct mailimf_date_time; | 18 | struct mailimf_date_time; |
19 | struct mailimf_group; | 19 | struct mailimf_group; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | struct mailsession; | 21 | struct mailsession; |
22 | struct mailstorage; | 22 | struct mailstorage; |
23 | struct mailfolder; | 23 | struct mailfolder; |
24 | 24 | ||
25 | /* this class hold just the funs shared between | 25 | /* this class hold just the funs shared between |
26 | * mbox and pop3 (later mh, too) mail access. | 26 | * mbox and pop3 (later mh, too) mail access. |
27 | * it is not desigend to make a instance of it! | 27 | * it is not desigend to make a instance of it! |
28 | */ | 28 | */ |
29 | class Genericwrapper : public AbstractMail | 29 | class Genericwrapper : public AbstractMail |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | Genericwrapper(); | 33 | Genericwrapper(); |
34 | virtual ~Genericwrapper(); | 34 | virtual ~Genericwrapper(); |
35 | 35 | ||
36 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 36 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
37 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
38 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 38 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
39 | virtual void cleanMimeCache(); | 39 | virtual void cleanMimeCache(); |
40 | virtual int deleteMbox(const Folder*){return 1;} | 40 | virtual int deleteMbox(const Folder*){return 1;} |
41 | virtual void logout(){}; | 41 | virtual void logout(){}; |
42 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 42 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
43 | 43 | ||
44 | protected: | 44 | protected: |
45 | RecMail *parseHeader( const char *header ); | 45 | RecMail *parseHeader( const char *header ); |
46 | RecBody parseMail( mailmessage * msg ); | 46 | RecBody parseMail( mailmessage * msg ); |
47 | QString parseMailboxList( mailimf_mailbox_list *list ); | 47 | QString parseMailboxList( mailimf_mailbox_list *list ); |
48 | QString parseMailbox( mailimf_mailbox *box ); | 48 | QString parseMailbox( mailimf_mailbox *box ); |
49 | QString parseGroup( mailimf_group *group ); | 49 | QString parseGroup( mailimf_group *group ); |
50 | QString parseAddressList( mailimf_address_list *list ); | 50 | QString parseAddressList( mailimf_address_list *list ); |
51 | QString parseDateTime( mailimf_date_time *date ); | 51 | QString parseDateTime( mailimf_date_time *date ); |
52 | 52 | ||
53 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 53 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
54 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 54 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
55 | static void fillParameters(RecPart&target,clist*parameters); | 55 | static void fillParameters(RecPart&target,clist*parameters); |
56 | static QString getencoding(mailmime_mechanism*aEnc); | 56 | static QString getencoding(mailmime_mechanism*aEnc); |
57 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); | 57 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); |
58 | 58 | ||
59 | QString msgTempName; | 59 | QString msgTempName; |
60 | unsigned int last_msg_id; | 60 | unsigned int last_msg_id; |
61 | QMap<QString,encodedString*> bodyCache; | 61 | QMap<QString,encodedString*> bodyCache; |
62 | mailstorage * m_storage; | 62 | mailstorage * m_storage; |
63 | mailfolder*m_folder; | 63 | mailfolder*m_folder; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | #endif | 66 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 1dfcc4c..3375e69 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -709,462 +709,462 @@ void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*De | |||
709 | } | 709 | } |
710 | switch (Description->bd_type) { | 710 | switch (Description->bd_type) { |
711 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 711 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
712 | target_part.setType("text"); | 712 | target_part.setType("text"); |
713 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 713 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
714 | break; | 714 | break; |
715 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 715 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
716 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 716 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
717 | break; | 717 | break; |
718 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 718 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
719 | target_part.setType("message"); | 719 | target_part.setType("message"); |
720 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 720 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
721 | break; | 721 | break; |
722 | default: | 722 | default: |
723 | break; | 723 | break; |
724 | } | 724 | } |
725 | } | 725 | } |
726 | 726 | ||
727 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 727 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
728 | { | 728 | { |
729 | if (!which) { | 729 | if (!which) { |
730 | return; | 730 | return; |
731 | } | 731 | } |
732 | QString sub; | 732 | QString sub; |
733 | sub = which->bd_media_text; | 733 | sub = which->bd_media_text; |
734 | qDebug("Type= text/%s",which->bd_media_text); | 734 | qDebug("Type= text/%s",which->bd_media_text); |
735 | target_part.setSubtype(sub.lower()); | 735 | target_part.setSubtype(sub.lower()); |
736 | target_part.setLines(which->bd_lines); | 736 | target_part.setLines(which->bd_lines); |
737 | fillBodyFields(target_part,which->bd_fields); | 737 | fillBodyFields(target_part,which->bd_fields); |
738 | } | 738 | } |
739 | 739 | ||
740 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | 740 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) |
741 | { | 741 | { |
742 | if (!which) { | 742 | if (!which) { |
743 | return; | 743 | return; |
744 | } | 744 | } |
745 | target_part.setSubtype("rfc822"); | 745 | target_part.setSubtype("rfc822"); |
746 | qDebug("Message part"); | 746 | qDebug("Message part"); |
747 | /* we set this type to text/plain */ | 747 | /* we set this type to text/plain */ |
748 | target_part.setLines(which->bd_lines); | 748 | target_part.setLines(which->bd_lines); |
749 | fillBodyFields(target_part,which->bd_fields); | 749 | fillBodyFields(target_part,which->bd_fields); |
750 | } | 750 | } |
751 | 751 | ||
752 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) | 752 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) |
753 | { | 753 | { |
754 | if (!which) return; | 754 | if (!which) return; |
755 | QString sub = which->bd_media_subtype; | 755 | QString sub = which->bd_media_subtype; |
756 | target_part.setSubtype(sub.lower()); | 756 | target_part.setSubtype(sub.lower()); |
757 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 757 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
758 | clistcell*cur = 0; | 758 | clistcell*cur = 0; |
759 | mailimap_single_body_fld_param*param=0; | 759 | mailimap_single_body_fld_param*param=0; |
760 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 760 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
761 | param = (mailimap_single_body_fld_param*)cur->data; | 761 | param = (mailimap_single_body_fld_param*)cur->data; |
762 | if (param) { | 762 | if (param) { |
763 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 763 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
764 | } | 764 | } |
765 | } | 765 | } |
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 769 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
770 | { | 770 | { |
771 | if (!which) { | 771 | if (!which) { |
772 | return; | 772 | return; |
773 | } | 773 | } |
774 | QString type,sub; | 774 | QString type,sub; |
775 | switch (which->bd_media_basic->med_type) { | 775 | switch (which->bd_media_basic->med_type) { |
776 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 776 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
777 | type = "application"; | 777 | type = "application"; |
778 | break; | 778 | break; |
779 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 779 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
780 | type = "audio"; | 780 | type = "audio"; |
781 | break; | 781 | break; |
782 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 782 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
783 | type = "image"; | 783 | type = "image"; |
784 | break; | 784 | break; |
785 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 785 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
786 | type = "message"; | 786 | type = "message"; |
787 | break; | 787 | break; |
788 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 788 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
789 | type = "video"; | 789 | type = "video"; |
790 | break; | 790 | break; |
791 | case MAILIMAP_MEDIA_BASIC_OTHER: | 791 | case MAILIMAP_MEDIA_BASIC_OTHER: |
792 | default: | 792 | default: |
793 | if (which->bd_media_basic->med_basic_type) { | 793 | if (which->bd_media_basic->med_basic_type) { |
794 | type = which->bd_media_basic->med_basic_type; | 794 | type = which->bd_media_basic->med_basic_type; |
795 | } else { | 795 | } else { |
796 | type = ""; | 796 | type = ""; |
797 | } | 797 | } |
798 | break; | 798 | break; |
799 | } | 799 | } |
800 | if (which->bd_media_basic->med_subtype) { | 800 | if (which->bd_media_basic->med_subtype) { |
801 | sub = which->bd_media_basic->med_subtype; | 801 | sub = which->bd_media_basic->med_subtype; |
802 | } else { | 802 | } else { |
803 | sub = ""; | 803 | sub = ""; |
804 | } | 804 | } |
805 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); | 805 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); |
806 | target_part.setType(type.lower()); | 806 | target_part.setType(type.lower()); |
807 | target_part.setSubtype(sub.lower()); | 807 | target_part.setSubtype(sub.lower()); |
808 | fillBodyFields(target_part,which->bd_fields); | 808 | fillBodyFields(target_part,which->bd_fields); |
809 | } | 809 | } |
810 | 810 | ||
811 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | 811 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) |
812 | { | 812 | { |
813 | if (!which) return; | 813 | if (!which) return; |
814 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 814 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
815 | clistcell*cur; | 815 | clistcell*cur; |
816 | mailimap_single_body_fld_param*param=0; | 816 | mailimap_single_body_fld_param*param=0; |
817 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 817 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
818 | param = (mailimap_single_body_fld_param*)cur->data; | 818 | param = (mailimap_single_body_fld_param*)cur->data; |
819 | if (param) { | 819 | if (param) { |
820 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 820 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
821 | } | 821 | } |
822 | } | 822 | } |
823 | } | 823 | } |
824 | mailimap_body_fld_enc*enc = which->bd_encoding; | 824 | mailimap_body_fld_enc*enc = which->bd_encoding; |
825 | QString encoding(""); | 825 | QString encoding(""); |
826 | switch (enc->enc_type) { | 826 | switch (enc->enc_type) { |
827 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 827 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
828 | encoding = "7bit"; | 828 | encoding = "7bit"; |
829 | break; | 829 | break; |
830 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 830 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
831 | encoding = "8bit"; | 831 | encoding = "8bit"; |
832 | break; | 832 | break; |
833 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 833 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
834 | encoding="binary"; | 834 | encoding="binary"; |
835 | break; | 835 | break; |
836 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 836 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
837 | encoding="base64"; | 837 | encoding="base64"; |
838 | break; | 838 | break; |
839 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 839 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
840 | encoding="quoted-printable"; | 840 | encoding="quoted-printable"; |
841 | break; | 841 | break; |
842 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 842 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
843 | default: | 843 | default: |
844 | if (enc->enc_value) { | 844 | if (enc->enc_value) { |
845 | char*t=enc->enc_value; | 845 | char*t=enc->enc_value; |
846 | encoding=QString(enc->enc_value); | 846 | encoding=QString(enc->enc_value); |
847 | enc->enc_value=0L; | 847 | enc->enc_value=0L; |
848 | free(t); | 848 | free(t); |
849 | } | 849 | } |
850 | } | 850 | } |
851 | if (which->bd_description) { | 851 | if (which->bd_description) { |
852 | target_part.setDescription(QString(which->bd_description)); | 852 | target_part.setDescription(QString(which->bd_description)); |
853 | } | 853 | } |
854 | target_part.setEncoding(encoding); | 854 | target_part.setEncoding(encoding); |
855 | target_part.setSize(which->bd_size); | 855 | target_part.setSize(which->bd_size); |
856 | } | 856 | } |
857 | 857 | ||
858 | void IMAPwrapper::deleteMail(const RecMail&mail) | 858 | void IMAPwrapper::deleteMail(const RecMail&mail) |
859 | { | 859 | { |
860 | mailimap_flag_list*flist; | 860 | mailimap_flag_list*flist; |
861 | mailimap_set *set; | 861 | mailimap_set *set; |
862 | mailimap_store_att_flags * store_flags; | 862 | mailimap_store_att_flags * store_flags; |
863 | int err; | 863 | int err; |
864 | login(); | 864 | login(); |
865 | if (!m_imap) { | 865 | if (!m_imap) { |
866 | return; | 866 | return; |
867 | } | 867 | } |
868 | err = selectMbox(mail.getMbox()); | 868 | err = selectMbox(mail.getMbox()); |
869 | if ( err != MAILIMAP_NO_ERROR ) { | 869 | if ( err != MAILIMAP_NO_ERROR ) { |
870 | return; | 870 | return; |
871 | } | 871 | } |
872 | flist = mailimap_flag_list_new_empty(); | 872 | flist = mailimap_flag_list_new_empty(); |
873 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 873 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
874 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 874 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
875 | set = mailimap_set_new_single(mail.getNumber()); | 875 | set = mailimap_set_new_single(mail.getNumber()); |
876 | err = mailimap_store(m_imap,set,store_flags); | 876 | err = mailimap_store(m_imap,set,store_flags); |
877 | mailimap_set_free( set ); | 877 | mailimap_set_free( set ); |
878 | mailimap_store_att_flags_free(store_flags); | 878 | mailimap_store_att_flags_free(store_flags); |
879 | 879 | ||
880 | if (err != MAILIMAP_NO_ERROR) { | 880 | if (err != MAILIMAP_NO_ERROR) { |
881 | qDebug("error deleting mail: %s",m_imap->imap_response); | 881 | qDebug("error deleting mail: %s",m_imap->imap_response); |
882 | return; | 882 | return; |
883 | } | 883 | } |
884 | qDebug("deleting mail: %s",m_imap->imap_response); | 884 | qDebug("deleting mail: %s",m_imap->imap_response); |
885 | /* should we realy do that at this moment? */ | 885 | /* should we realy do that at this moment? */ |
886 | err = mailimap_expunge(m_imap); | 886 | err = mailimap_expunge(m_imap); |
887 | if (err != MAILIMAP_NO_ERROR) { | 887 | if (err != MAILIMAP_NO_ERROR) { |
888 | qDebug("error deleting mail: %s",m_imap->imap_response); | 888 | qDebug("error deleting mail: %s",m_imap->imap_response); |
889 | } | 889 | } |
890 | qDebug("Delete successfull %s",m_imap->imap_response); | 890 | qDebug("Delete successfull %s",m_imap->imap_response); |
891 | } | 891 | } |
892 | 892 | ||
893 | void IMAPwrapper::answeredMail(const RecMail&mail) | 893 | void IMAPwrapper::answeredMail(const RecMail&mail) |
894 | { | 894 | { |
895 | mailimap_flag_list*flist; | 895 | mailimap_flag_list*flist; |
896 | mailimap_set *set; | 896 | mailimap_set *set; |
897 | mailimap_store_att_flags * store_flags; | 897 | mailimap_store_att_flags * store_flags; |
898 | int err; | 898 | int err; |
899 | login(); | 899 | login(); |
900 | if (!m_imap) { | 900 | if (!m_imap) { |
901 | return; | 901 | return; |
902 | } | 902 | } |
903 | err = selectMbox(mail.getMbox()); | 903 | err = selectMbox(mail.getMbox()); |
904 | if ( err != MAILIMAP_NO_ERROR ) { | 904 | if ( err != MAILIMAP_NO_ERROR ) { |
905 | return; | 905 | return; |
906 | } | 906 | } |
907 | flist = mailimap_flag_list_new_empty(); | 907 | flist = mailimap_flag_list_new_empty(); |
908 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 908 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
909 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 909 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
910 | set = mailimap_set_new_single(mail.getNumber()); | 910 | set = mailimap_set_new_single(mail.getNumber()); |
911 | err = mailimap_store(m_imap,set,store_flags); | 911 | err = mailimap_store(m_imap,set,store_flags); |
912 | mailimap_set_free( set ); | 912 | mailimap_set_free( set ); |
913 | mailimap_store_att_flags_free(store_flags); | 913 | mailimap_store_att_flags_free(store_flags); |
914 | 914 | ||
915 | if (err != MAILIMAP_NO_ERROR) { | 915 | if (err != MAILIMAP_NO_ERROR) { |
916 | qDebug("error marking mail: %s",m_imap->imap_response); | 916 | qDebug("error marking mail: %s",m_imap->imap_response); |
917 | return; | 917 | return; |
918 | } | 918 | } |
919 | } | 919 | } |
920 | 920 | ||
921 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 921 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
922 | { | 922 | { |
923 | QString body(""); | 923 | QString body(""); |
924 | encodedString*res = fetchRawPart(mail,path,internal_call); | 924 | encodedString*res = fetchRawPart(mail,path,internal_call); |
925 | encodedString*r = decode_String(res,enc); | 925 | encodedString*r = decode_String(res,enc); |
926 | delete res; | 926 | delete res; |
927 | if (r) { | 927 | if (r) { |
928 | if (r->Length()>0) { | 928 | if (r->Length()>0) { |
929 | body = r->Content(); | 929 | body = r->Content(); |
930 | } | 930 | } |
931 | delete r; | 931 | delete r; |
932 | } | 932 | } |
933 | return body; | 933 | return body; |
934 | } | 934 | } |
935 | 935 | ||
936 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 936 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) |
937 | { | 937 | { |
938 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | 938 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); |
939 | } | 939 | } |
940 | 940 | ||
941 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 941 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) |
942 | { | 942 | { |
943 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 943 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
944 | encodedString*r = decode_String(res,part.Encoding()); | 944 | encodedString*r = decode_String(res,part.Encoding()); |
945 | delete res; | 945 | delete res; |
946 | return r; | 946 | return r; |
947 | } | 947 | } |
948 | 948 | ||
949 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 949 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
950 | { | 950 | { |
951 | return fetchRawPart(mail,part.Positionlist(),false); | 951 | return fetchRawPart(mail,part.Positionlist(),false); |
952 | } | 952 | } |
953 | 953 | ||
954 | int IMAPwrapper::deleteAllMail(const Folder*folder) | 954 | int IMAPwrapper::deleteAllMail(const Folder*folder) |
955 | { | 955 | { |
956 | login(); | 956 | login(); |
957 | if (!m_imap) { | 957 | if (!m_imap) { |
958 | return 0; | 958 | return 0; |
959 | } | 959 | } |
960 | mailimap_flag_list*flist; | 960 | mailimap_flag_list*flist; |
961 | mailimap_set *set; | 961 | mailimap_set *set; |
962 | mailimap_store_att_flags * store_flags; | 962 | mailimap_store_att_flags * store_flags; |
963 | int err = selectMbox(folder->getName()); | 963 | int err = selectMbox(folder->getName()); |
964 | if ( err != MAILIMAP_NO_ERROR ) { | 964 | if ( err != MAILIMAP_NO_ERROR ) { |
965 | return 0; | 965 | return 0; |
966 | } | 966 | } |
967 | 967 | ||
968 | int last = m_imap->imap_selection_info->sel_exists; | 968 | int last = m_imap->imap_selection_info->sel_exists; |
969 | if (last == 0) { | 969 | if (last == 0) { |
970 | Global::statusMessage(tr("Mailbox has no mails!")); | 970 | Global::statusMessage(tr("Mailbox has no mails!")); |
971 | return 0; | 971 | return 0; |
972 | } | 972 | } |
973 | flist = mailimap_flag_list_new_empty(); | 973 | flist = mailimap_flag_list_new_empty(); |
974 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 974 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
975 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 975 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
976 | set = mailimap_set_new_interval( 1, last ); | 976 | set = mailimap_set_new_interval( 1, last ); |
977 | err = mailimap_store(m_imap,set,store_flags); | 977 | err = mailimap_store(m_imap,set,store_flags); |
978 | mailimap_set_free( set ); | 978 | mailimap_set_free( set ); |
979 | mailimap_store_att_flags_free(store_flags); | 979 | mailimap_store_att_flags_free(store_flags); |
980 | if (err != MAILIMAP_NO_ERROR) { | 980 | if (err != MAILIMAP_NO_ERROR) { |
981 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 981 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
982 | return 0; | 982 | return 0; |
983 | } | 983 | } |
984 | qDebug("deleting mail: %s",m_imap->imap_response); | 984 | qDebug("deleting mail: %s",m_imap->imap_response); |
985 | /* should we realy do that at this moment? */ | 985 | /* should we realy do that at this moment? */ |
986 | err = mailimap_expunge(m_imap); | 986 | err = mailimap_expunge(m_imap); |
987 | if (err != MAILIMAP_NO_ERROR) { | 987 | if (err != MAILIMAP_NO_ERROR) { |
988 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 988 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
989 | return 0; | 989 | return 0; |
990 | } | 990 | } |
991 | qDebug("Delete successfull %s",m_imap->imap_response); | 991 | qDebug("Delete successfull %s",m_imap->imap_response); |
992 | return 1; | 992 | return 1; |
993 | } | 993 | } |
994 | 994 | ||
995 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) | 995 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) |
996 | { | 996 | { |
997 | if (folder.length()==0) return 0; | 997 | if (folder.length()==0) return 0; |
998 | login(); | 998 | login(); |
999 | if (!m_imap) {return 0;} | 999 | if (!m_imap) {return 0;} |
1000 | QString pre = account->getPrefix(); | 1000 | QString pre = account->getPrefix(); |
1001 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1001 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1002 | pre+=delemiter; | 1002 | pre+=delemiter; |
1003 | } | 1003 | } |
1004 | if (parentfolder) { | 1004 | if (parentfolder) { |
1005 | pre += parentfolder->getDisplayName()+delemiter; | 1005 | pre += parentfolder->getDisplayName()+delemiter; |
1006 | } | 1006 | } |
1007 | pre+=folder; | 1007 | pre+=folder; |
1008 | if (getsubfolder) { | 1008 | if (getsubfolder) { |
1009 | if (delemiter.length()>0) { | 1009 | if (delemiter.length()>0) { |
1010 | pre+=delemiter; | 1010 | pre+=delemiter; |
1011 | } else { | 1011 | } else { |
1012 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1012 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
1013 | return 0; | 1013 | return 0; |
1014 | } | 1014 | } |
1015 | } | 1015 | } |
1016 | qDebug("Creating %s",pre.latin1()); | 1016 | qDebug("Creating %s",pre.latin1()); |
1017 | int res = mailimap_create(m_imap,pre.latin1()); | 1017 | int res = mailimap_create(m_imap,pre.latin1()); |
1018 | if (res != MAILIMAP_NO_ERROR) { | 1018 | if (res != MAILIMAP_NO_ERROR) { |
1019 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1019 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1020 | return 0; | 1020 | return 0; |
1021 | } | 1021 | } |
1022 | return 1; | 1022 | return 1; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | int IMAPwrapper::deleteMbox(const Folder*folder) | 1025 | int IMAPwrapper::deleteMbox(const Folder*folder) |
1026 | { | 1026 | { |
1027 | if (!folder) return 0; | 1027 | if (!folder) return 0; |
1028 | login(); | 1028 | login(); |
1029 | if (!m_imap) {return 0;} | 1029 | if (!m_imap) {return 0;} |
1030 | int res = mailimap_delete(m_imap,folder->getName()); | 1030 | int res = mailimap_delete(m_imap,folder->getName()); |
1031 | if (res != MAILIMAP_NO_ERROR) { | 1031 | if (res != MAILIMAP_NO_ERROR) { |
1032 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1032 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1033 | return 0; | 1033 | return 0; |
1034 | } | 1034 | } |
1035 | return 1; | 1035 | return 1; |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1038 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1039 | { | 1039 | { |
1040 | mailimap_status_att_list * att_list =0; | 1040 | mailimap_status_att_list * att_list =0; |
1041 | mailimap_mailbox_data_status * status=0; | 1041 | mailimap_mailbox_data_status * status=0; |
1042 | clistiter * cur = 0; | 1042 | clistiter * cur = 0; |
1043 | int r = 0; | 1043 | int r = 0; |
1044 | int res = 0; | 1044 | int res = 0; |
1045 | target_stat.message_count = 0; | 1045 | target_stat.message_count = 0; |
1046 | target_stat.message_unseen = 0; | 1046 | target_stat.message_unseen = 0; |
1047 | target_stat.message_recent = 0; | 1047 | target_stat.message_recent = 0; |
1048 | login(); | 1048 | login(); |
1049 | if (!m_imap) { | 1049 | if (!m_imap) { |
1050 | return; | 1050 | return; |
1051 | } | 1051 | } |
1052 | att_list = mailimap_status_att_list_new_empty(); | 1052 | att_list = mailimap_status_att_list_new_empty(); |
1053 | if (!att_list) return; | 1053 | if (!att_list) return; |
1054 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1054 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1055 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1055 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1056 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1056 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1057 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1057 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1058 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1058 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1059 | for (cur = clist_begin(status->st_info_list); | 1059 | for (cur = clist_begin(status->st_info_list); |
1060 | cur != NULL ; cur = clist_next(cur)) { | 1060 | cur != NULL ; cur = clist_next(cur)) { |
1061 | mailimap_status_info * status_info; | 1061 | mailimap_status_info * status_info; |
1062 | status_info = (mailimap_status_info *)clist_content(cur); | 1062 | status_info = (mailimap_status_info *)clist_content(cur); |
1063 | switch (status_info->st_att) { | 1063 | switch (status_info->st_att) { |
1064 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1064 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1065 | target_stat.message_count = status_info->st_value; | 1065 | target_stat.message_count = status_info->st_value; |
1066 | break; | 1066 | break; |
1067 | case MAILIMAP_STATUS_ATT_RECENT: | 1067 | case MAILIMAP_STATUS_ATT_RECENT: |
1068 | target_stat.message_recent = status_info->st_value; | 1068 | target_stat.message_recent = status_info->st_value; |
1069 | break; | 1069 | break; |
1070 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1070 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1071 | target_stat.message_unseen = status_info->st_value; | 1071 | target_stat.message_unseen = status_info->st_value; |
1072 | break; | 1072 | break; |
1073 | } | 1073 | } |
1074 | } | 1074 | } |
1075 | } else { | 1075 | } else { |
1076 | qDebug("Error retrieving status"); | 1076 | qDebug("Error retrieving status"); |
1077 | } | 1077 | } |
1078 | if (status) mailimap_mailbox_data_status_free(status); | 1078 | if (status) mailimap_mailbox_data_status_free(status); |
1079 | if (att_list) mailimap_status_att_list_free(att_list); | 1079 | if (att_list) mailimap_status_att_list_free(att_list); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1082 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1083 | { | 1083 | { |
1084 | login(); | 1084 | login(); |
1085 | if (!m_imap) return; | 1085 | if (!m_imap) return; |
1086 | if (!msg) return; | 1086 | if (!msg) return; |
1087 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1087 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1088 | if (r != MAILIMAP_NO_ERROR) { | 1088 | if (r != MAILIMAP_NO_ERROR) { |
1089 | Global::statusMessage("Error storing mail!"); | 1089 | Global::statusMessage("Error storing mail!"); |
1090 | } | 1090 | } |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | const QString&IMAPwrapper::getType()const | 1093 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1094 | { | 1094 | { |
1095 | return account->getType(); | 1095 | return account->getType(); |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | const QString&IMAPwrapper::getName()const | 1098 | const QString&IMAPwrapper::getName()const |
1099 | { | 1099 | { |
1100 | qDebug("Get name: %s",account->getAccountName().latin1()); | 1100 | qDebug("Get name: %s",account->getAccountName().latin1()); |
1101 | return account->getAccountName(); | 1101 | return account->getAccountName(); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1104 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) |
1105 | { | 1105 | { |
1106 | // dummy | 1106 | // dummy |
1107 | QValueList<int> path; | 1107 | QValueList<int> path; |
1108 | return fetchRawPart(mail,path,false); | 1108 | return fetchRawPart(mail,path,false); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1111 | void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1112 | { | 1112 | { |
1113 | if (targetWrapper != this) { | 1113 | if (targetWrapper != this) { |
1114 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1114 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1115 | qDebug("Using generic"); | 1115 | qDebug("Using generic"); |
1116 | return; | 1116 | return; |
1117 | } | 1117 | } |
1118 | mailimap_set *set = 0; | 1118 | mailimap_set *set = 0; |
1119 | login(); | 1119 | login(); |
1120 | if (!m_imap) { | 1120 | if (!m_imap) { |
1121 | return; | 1121 | return; |
1122 | } | 1122 | } |
1123 | int err = selectMbox(fromFolder->getName()); | 1123 | int err = selectMbox(fromFolder->getName()); |
1124 | if ( err != MAILIMAP_NO_ERROR ) { | 1124 | if ( err != MAILIMAP_NO_ERROR ) { |
1125 | return; | 1125 | return; |
1126 | } | 1126 | } |
1127 | int last = m_imap->imap_selection_info->sel_exists; | 1127 | int last = m_imap->imap_selection_info->sel_exists; |
1128 | set = mailimap_set_new_interval( 1, last ); | 1128 | set = mailimap_set_new_interval( 1, last ); |
1129 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1129 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1130 | mailimap_set_free( set ); | 1130 | mailimap_set_free( set ); |
1131 | if ( err != MAILIMAP_NO_ERROR ) { | 1131 | if ( err != MAILIMAP_NO_ERROR ) { |
1132 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1132 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1133 | Global::statusMessage(error_msg); | 1133 | Global::statusMessage(error_msg); |
1134 | qDebug(error_msg); | 1134 | qDebug(error_msg); |
1135 | return; | 1135 | return; |
1136 | } | 1136 | } |
1137 | if (moveit) { | 1137 | if (moveit) { |
1138 | deleteAllMail(fromFolder); | 1138 | deleteAllMail(fromFolder); |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1142 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1143 | { | 1143 | { |
1144 | if (targetWrapper != this) { | 1144 | if (targetWrapper != this) { |
1145 | qDebug("Using generic"); | 1145 | qDebug("Using generic"); |
1146 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1146 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1147 | return; | 1147 | return; |
1148 | } | 1148 | } |
1149 | mailimap_set *set = 0; | 1149 | mailimap_set *set = 0; |
1150 | login(); | 1150 | login(); |
1151 | if (!m_imap) { | 1151 | if (!m_imap) { |
1152 | return; | 1152 | return; |
1153 | } | 1153 | } |
1154 | int err = selectMbox(mail.getMbox()); | 1154 | int err = selectMbox(mail.getMbox()); |
1155 | if ( err != MAILIMAP_NO_ERROR ) { | 1155 | if ( err != MAILIMAP_NO_ERROR ) { |
1156 | return; | 1156 | return; |
1157 | } | 1157 | } |
1158 | set = mailimap_set_new_single(mail.getNumber()); | 1158 | set = mailimap_set_new_single(mail.getNumber()); |
1159 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1159 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1160 | mailimap_set_free( set ); | 1160 | mailimap_set_free( set ); |
1161 | if ( err != MAILIMAP_NO_ERROR ) { | 1161 | if ( err != MAILIMAP_NO_ERROR ) { |
1162 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1162 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1163 | Global::statusMessage(error_msg); | 1163 | Global::statusMessage(error_msg); |
1164 | qDebug(error_msg); | 1164 | qDebug(error_msg); |
1165 | return; | 1165 | return; |
1166 | } | 1166 | } |
1167 | if (moveit) { | 1167 | if (moveit) { |
1168 | deleteMail(mail); | 1168 | deleteMail(mail); |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 0a1fe2c..2623725 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,78 +1,78 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "abstractmail.h" | 6 | #include "abstractmail.h" |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | struct mailimap; | 9 | struct mailimap; |
10 | struct mailimap_body; | 10 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 11 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 12 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 13 | struct mailimap_body_type_basic; |
14 | struct mailimap_body_type_msg; | 14 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QList<Folder>* listFolders(); | 26 | virtual QList<Folder>* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
32 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
35 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 35 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
36 | 36 | ||
37 | virtual RecBody fetchBody(const RecMail&mail); | 37 | virtual RecBody fetchBody(const RecMail&mail); |
38 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 38 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
39 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 39 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
40 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 40 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
41 | virtual encodedString* fetchRawBody(const RecMail&mail); | 41 | virtual encodedString* fetchRawBody(const RecMail&mail); |
42 | 42 | ||
43 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 43 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
44 | virtual int deleteMbox(const Folder*folder); | 44 | virtual int deleteMbox(const Folder*folder); |
45 | 45 | ||
46 | static void imap_progress( size_t current, size_t maximum ); | 46 | static void imap_progress( size_t current, size_t maximum ); |
47 | 47 | ||
48 | virtual void logout(); | 48 | virtual void logout(); |
49 | virtual const QString&getType()const; | 49 | virtual MAILLIB::ATYPE getType()const; |
50 | virtual const QString&getName()const; | 50 | virtual const QString&getName()const; |
51 | 51 | ||
52 | protected: | 52 | protected: |
53 | RecMail*parse_list_result(mailimap_msg_att*); | 53 | RecMail*parse_list_result(mailimap_msg_att*); |
54 | void login(); | 54 | void login(); |
55 | bool start_tls(bool force=true); | 55 | bool start_tls(bool force=true); |
56 | 56 | ||
57 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 57 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
58 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 58 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
59 | int selectMbox(const QString&mbox); | 59 | int selectMbox(const QString&mbox); |
60 | 60 | ||
61 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 61 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
62 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 62 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
63 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 63 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
64 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 64 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
65 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 65 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
66 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 66 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
67 | 67 | ||
68 | /* just helpers */ | 68 | /* just helpers */ |
69 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 69 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
70 | static QStringList address_list_to_stringlist(clist*list); | 70 | static QStringList address_list_to_stringlist(clist*list); |
71 | 71 | ||
72 | 72 | ||
73 | IMAPaccount *account; | 73 | IMAPaccount *account; |
74 | mailimap *m_imap; | 74 | mailimap *m_imap; |
75 | QString m_Lastmbox; | 75 | QString m_Lastmbox; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | #endif | 78 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/maildefines.h b/noncore/net/mail/libmailwrapper/maildefines.h new file mode 100644 index 0000000..431f9ea --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/maildefines.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef __MAILDEFINES_H | ||
2 | #define __MAILDEFINES_H | ||
3 | |||
4 | namespace MAILLIB { | ||
5 | enum ATYPE { | ||
6 | A_UNDEFINED, | ||
7 | A_IMAP, | ||
8 | A_POP3, | ||
9 | A_SMTP, | ||
10 | A_MH, | ||
11 | A_MBOX, | ||
12 | A_NNTP, | ||
13 | }; | ||
14 | } | ||
15 | |||
16 | #endif | ||
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 97f301e..11ffd92 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,337 +1,337 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | const QString MBOXwrapper::wrapperType="MBOX"; | 9 | const MAILLIB::ATYPE MBOXwrapper::wrapperType=MAILLIB::MBOX; |
10 | 10 | ||
11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
12 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 12 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
13 | { | 13 | { |
14 | QDir dir(MBOXPath); | 14 | QDir dir(MBOXPath); |
15 | if (!dir.exists()) { | 15 | if (!dir.exists()) { |
16 | dir.mkdir(MBOXPath); | 16 | dir.mkdir(MBOXPath); |
17 | } | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | MBOXwrapper::~MBOXwrapper() | 20 | MBOXwrapper::~MBOXwrapper() |
21 | { | 21 | { |
22 | } | 22 | } |
23 | 23 | ||
24 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 24 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
25 | { | 25 | { |
26 | mailstorage*storage = mailstorage_new(NULL); | 26 | mailstorage*storage = mailstorage_new(NULL); |
27 | QString p = MBOXPath+"/"; | 27 | QString p = MBOXPath+"/"; |
28 | p+=mailbox; | 28 | p+=mailbox; |
29 | 29 | ||
30 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 30 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
31 | mailfolder*folder; | 31 | mailfolder*folder; |
32 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 32 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
33 | r = mailfolder_connect(folder); | 33 | r = mailfolder_connect(folder); |
34 | if (r != MAIL_NO_ERROR) { | 34 | if (r != MAIL_NO_ERROR) { |
35 | qDebug("Error initializing mbox"); | 35 | qDebug("Error initializing mbox"); |
36 | mailfolder_free(folder); | 36 | mailfolder_free(folder); |
37 | mailstorage_free(storage); | 37 | mailstorage_free(storage); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | parseList(target,folder->fld_session,mailbox); | 41 | parseList(target,folder->fld_session,mailbox); |
42 | 42 | ||
43 | mailfolder_disconnect(folder); | 43 | mailfolder_disconnect(folder); |
44 | mailfolder_free(folder); | 44 | mailfolder_free(folder); |
45 | mailstorage_free(storage); | 45 | mailstorage_free(storage); |
46 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 46 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
47 | } | 47 | } |
48 | 48 | ||
49 | QList<Folder>* MBOXwrapper::listFolders() | 49 | QList<Folder>* MBOXwrapper::listFolders() |
50 | { | 50 | { |
51 | QList<Folder> * folders = new QList<Folder>(); | 51 | QList<Folder> * folders = new QList<Folder>(); |
52 | folders->setAutoDelete( false ); | 52 | folders->setAutoDelete( false ); |
53 | QDir dir(MBOXPath); | 53 | QDir dir(MBOXPath); |
54 | if (!dir.exists()) return folders; | 54 | if (!dir.exists()) return folders; |
55 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 55 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
56 | QStringList entries = dir.entryList(); | 56 | QStringList entries = dir.entryList(); |
57 | QStringList::ConstIterator it = entries.begin(); | 57 | QStringList::ConstIterator it = entries.begin(); |
58 | for (;it!=entries.end();++it) { | 58 | for (;it!=entries.end();++it) { |
59 | Folder*inb=new Folder(*it,"/"); | 59 | Folder*inb=new Folder(*it,"/"); |
60 | folders->append(inb); | 60 | folders->append(inb); |
61 | } | 61 | } |
62 | return folders; | 62 | return folders; |
63 | } | 63 | } |
64 | 64 | ||
65 | void MBOXwrapper::deleteMail(const RecMail&mail) | 65 | void MBOXwrapper::deleteMail(const RecMail&mail) |
66 | { | 66 | { |
67 | mailstorage*storage = mailstorage_new(NULL); | 67 | mailstorage*storage = mailstorage_new(NULL); |
68 | QString p = MBOXPath+"/"; | 68 | QString p = MBOXPath+"/"; |
69 | p+=mail.getMbox(); | 69 | p+=mail.getMbox(); |
70 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 70 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
71 | mailfolder*folder; | 71 | mailfolder*folder; |
72 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 72 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
73 | r = mailfolder_connect(folder); | 73 | r = mailfolder_connect(folder); |
74 | if (r != MAIL_NO_ERROR) { | 74 | if (r != MAIL_NO_ERROR) { |
75 | qDebug("Error initializing mbox"); | 75 | qDebug("Error initializing mbox"); |
76 | mailfolder_free(folder); | 76 | mailfolder_free(folder); |
77 | mailstorage_free(storage); | 77 | mailstorage_free(storage); |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 80 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
81 | if (r != MAIL_NO_ERROR) { | 81 | if (r != MAIL_NO_ERROR) { |
82 | qDebug("error deleting mail"); | 82 | qDebug("error deleting mail"); |
83 | } | 83 | } |
84 | mailfolder_free(folder); | 84 | mailfolder_free(folder); |
85 | mailstorage_free(storage); | 85 | mailstorage_free(storage); |
86 | } | 86 | } |
87 | 87 | ||
88 | void MBOXwrapper::answeredMail(const RecMail&) | 88 | void MBOXwrapper::answeredMail(const RecMail&) |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 92 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) |
93 | { | 93 | { |
94 | RecBody body; | 94 | RecBody body; |
95 | mailstorage*storage = mailstorage_new(NULL); | 95 | mailstorage*storage = mailstorage_new(NULL); |
96 | QString p = MBOXPath+"/"; | 96 | QString p = MBOXPath+"/"; |
97 | p+=mail.getMbox(); | 97 | p+=mail.getMbox(); |
98 | mailmessage * msg; | 98 | mailmessage * msg; |
99 | char*data=0; | 99 | char*data=0; |
100 | size_t size; | 100 | size_t size; |
101 | 101 | ||
102 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 102 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
103 | mailfolder*folder; | 103 | mailfolder*folder; |
104 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 104 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
105 | r = mailfolder_connect(folder); | 105 | r = mailfolder_connect(folder); |
106 | if (r != MAIL_NO_ERROR) { | 106 | if (r != MAIL_NO_ERROR) { |
107 | qDebug("Error initializing mbox"); | 107 | qDebug("Error initializing mbox"); |
108 | mailfolder_free(folder); | 108 | mailfolder_free(folder); |
109 | mailstorage_free(storage); | 109 | mailstorage_free(storage); |
110 | return body; | 110 | return body; |
111 | } | 111 | } |
112 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 112 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
113 | if (r != MAIL_NO_ERROR) { | 113 | if (r != MAIL_NO_ERROR) { |
114 | qDebug("Error fetching mail %i",mail.getNumber()); | 114 | qDebug("Error fetching mail %i",mail.getNumber()); |
115 | mailfolder_free(folder); | 115 | mailfolder_free(folder); |
116 | mailstorage_free(storage); | 116 | mailstorage_free(storage); |
117 | return body; | 117 | return body; |
118 | } | 118 | } |
119 | r = mailmessage_fetch(msg,&data,&size); | 119 | r = mailmessage_fetch(msg,&data,&size); |
120 | if (r != MAIL_NO_ERROR) { | 120 | if (r != MAIL_NO_ERROR) { |
121 | qDebug("Error fetching mail %i",mail.getNumber()); | 121 | qDebug("Error fetching mail %i",mail.getNumber()); |
122 | mailfolder_free(folder); | 122 | mailfolder_free(folder); |
123 | mailstorage_free(storage); | 123 | mailstorage_free(storage); |
124 | mailmessage_free(msg); | 124 | mailmessage_free(msg); |
125 | return body; | 125 | return body; |
126 | } | 126 | } |
127 | body = parseMail(msg); | 127 | body = parseMail(msg); |
128 | mailmessage_fetch_result_free(msg,data); | 128 | mailmessage_fetch_result_free(msg,data); |
129 | mailfolder_free(folder); | 129 | mailfolder_free(folder); |
130 | mailstorage_free(storage); | 130 | mailstorage_free(storage); |
131 | 131 | ||
132 | return body; | 132 | return body; |
133 | } | 133 | } |
134 | 134 | ||
135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
136 | { | 136 | { |
137 | qDebug("MBOX %i von %i",current,maximum); | 137 | qDebug("MBOX %i von %i",current,maximum); |
138 | } | 138 | } |
139 | 139 | ||
140 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) | 140 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) |
141 | { | 141 | { |
142 | QString p = MBOXPath+"/"; | 142 | QString p = MBOXPath+"/"; |
143 | p+=folder; | 143 | p+=folder; |
144 | QFileInfo fi(p); | 144 | QFileInfo fi(p); |
145 | if (fi.exists()) { | 145 | if (fi.exists()) { |
146 | Global::statusMessage(tr("Mailbox exists.")); | 146 | Global::statusMessage(tr("Mailbox exists.")); |
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | mailmbox_folder*f = 0; | 149 | mailmbox_folder*f = 0; |
150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
151 | Global::statusMessage(tr("Error init folder")); | 151 | Global::statusMessage(tr("Error init folder")); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | if (f) mailmbox_done(f); | 154 | if (f) mailmbox_done(f); |
155 | return 1; | 155 | return 1; |
156 | } | 156 | } |
157 | 157 | ||
158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
159 | { | 159 | { |
160 | QString p = MBOXPath+"/"; | 160 | QString p = MBOXPath+"/"; |
161 | p+=folder; | 161 | p+=folder; |
162 | mailmbox_folder*f = 0; | 162 | mailmbox_folder*f = 0; |
163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
164 | if (r != MAIL_NO_ERROR) { | 164 | if (r != MAIL_NO_ERROR) { |
165 | Global::statusMessage(tr("Error init folder")); | 165 | Global::statusMessage(tr("Error init folder")); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | r = mailmbox_append_message(f,msg,length); | 168 | r = mailmbox_append_message(f,msg,length); |
169 | if (r != MAIL_NO_ERROR) { | 169 | if (r != MAIL_NO_ERROR) { |
170 | Global::statusMessage(tr("Error writing to message folder")); | 170 | Global::statusMessage(tr("Error writing to message folder")); |
171 | } | 171 | } |
172 | mailmbox_done(f); | 172 | mailmbox_done(f); |
173 | } | 173 | } |
174 | 174 | ||
175 | encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) | 175 | encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) |
176 | { | 176 | { |
177 | RecBody body; | 177 | RecBody body; |
178 | mailstorage*storage = mailstorage_new(NULL); | 178 | mailstorage*storage = mailstorage_new(NULL); |
179 | QString p = MBOXPath+"/"; | 179 | QString p = MBOXPath+"/"; |
180 | p+=mail.getMbox(); | 180 | p+=mail.getMbox(); |
181 | mailmessage * msg; | 181 | mailmessage * msg; |
182 | char*data=0; | 182 | char*data=0; |
183 | size_t size; | 183 | size_t size; |
184 | 184 | ||
185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
186 | mailfolder*folder; | 186 | mailfolder*folder; |
187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
188 | r = mailfolder_connect(folder); | 188 | r = mailfolder_connect(folder); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | Global::statusMessage(tr("Error initializing mbox")); | 190 | Global::statusMessage(tr("Error initializing mbox")); |
191 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
192 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
196 | if (r != MAIL_NO_ERROR) { | 196 | if (r != MAIL_NO_ERROR) { |
197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
198 | mailfolder_free(folder); | 198 | mailfolder_free(folder); |
199 | mailstorage_free(storage); | 199 | mailstorage_free(storage); |
200 | return 0; | 200 | return 0; |
201 | } | 201 | } |
202 | r = mailmessage_fetch(msg,&data,&size); | 202 | r = mailmessage_fetch(msg,&data,&size); |
203 | if (r != MAIL_NO_ERROR) { | 203 | if (r != MAIL_NO_ERROR) { |
204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
205 | mailfolder_free(folder); | 205 | mailfolder_free(folder); |
206 | mailstorage_free(storage); | 206 | mailstorage_free(storage); |
207 | mailmessage_free(msg); | 207 | mailmessage_free(msg); |
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
210 | encodedString*result = new encodedString(data,size); | 210 | encodedString*result = new encodedString(data,size); |
211 | 211 | ||
212 | mailfolder_free(folder); | 212 | mailfolder_free(folder); |
213 | mailstorage_free(storage); | 213 | mailstorage_free(storage); |
214 | mailmessage_free(msg); | 214 | mailmessage_free(msg); |
215 | return result; | 215 | return result; |
216 | } | 216 | } |
217 | 217 | ||
218 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 218 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
219 | { | 219 | { |
220 | QString p = MBOXPath+"/"; | 220 | QString p = MBOXPath+"/"; |
221 | p+=mailbox; | 221 | p+=mailbox; |
222 | mailmbox_folder*f = 0; | 222 | mailmbox_folder*f = 0; |
223 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 223 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
224 | if (r != MAIL_NO_ERROR) { | 224 | if (r != MAIL_NO_ERROR) { |
225 | qDebug("Error init folder"); | 225 | qDebug("Error init folder"); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | deleteMails(f,target); | 228 | deleteMails(f,target); |
229 | mailmbox_done(f); | 229 | mailmbox_done(f); |
230 | } | 230 | } |
231 | 231 | ||
232 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 232 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) |
233 | { | 233 | { |
234 | if (!f) return; | 234 | if (!f) return; |
235 | int r; | 235 | int r; |
236 | for (unsigned int i=0; i < target.count();++i) { | 236 | for (unsigned int i=0; i < target.count();++i) { |
237 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 237 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
238 | if (r!=MAILMBOX_NO_ERROR) { | 238 | if (r!=MAILMBOX_NO_ERROR) { |
239 | qDebug("error delete mail"); | 239 | qDebug("error delete mail"); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | r = mailmbox_expunge(f); | 242 | r = mailmbox_expunge(f); |
243 | if (r != MAILMBOX_NO_ERROR) { | 243 | if (r != MAILMBOX_NO_ERROR) { |
244 | qDebug("error expunge mailbox"); | 244 | qDebug("error expunge mailbox"); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | 248 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) |
249 | { | 249 | { |
250 | if (!tfolder) return 0; | 250 | if (!tfolder) return 0; |
251 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 251 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
252 | int res = 1; | 252 | int res = 1; |
253 | 253 | ||
254 | mailfolder*folder = 0; | 254 | mailfolder*folder = 0; |
255 | mailmessage_list*l=0; | 255 | mailmessage_list*l=0; |
256 | mailstorage*storage = mailstorage_new(NULL); | 256 | mailstorage*storage = mailstorage_new(NULL); |
257 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 257 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
258 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
259 | Global::statusMessage(tr("Error initializing mbox")); | 259 | Global::statusMessage(tr("Error initializing mbox")); |
260 | res = 0; | 260 | res = 0; |
261 | } | 261 | } |
262 | if (res) { | 262 | if (res) { |
263 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 263 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
264 | r = mailfolder_connect(folder); | 264 | r = mailfolder_connect(folder); |
265 | if (r != MAIL_NO_ERROR) { | 265 | if (r != MAIL_NO_ERROR) { |
266 | Global::statusMessage(tr("Error initializing mbox")); | 266 | Global::statusMessage(tr("Error initializing mbox")); |
267 | res = 0; | 267 | res = 0; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | if (res) { | 270 | if (res) { |
271 | r = mailsession_get_messages_list(folder->fld_session,&l); | 271 | r = mailsession_get_messages_list(folder->fld_session,&l); |
272 | if (r != MAIL_NO_ERROR) { | 272 | if (r != MAIL_NO_ERROR) { |
273 | qDebug("Error message list"); | 273 | qDebug("Error message list"); |
274 | res=0; | 274 | res=0; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 277 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
278 | r = mailsession_remove_message(folder->fld_session,i+1); | 278 | r = mailsession_remove_message(folder->fld_session,i+1); |
279 | if (r != MAIL_NO_ERROR) { | 279 | if (r != MAIL_NO_ERROR) { |
280 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 280 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
281 | res = 0; | 281 | res = 0; |
282 | break; | 282 | break; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | if (l) mailmessage_list_free(l); | 285 | if (l) mailmessage_list_free(l); |
286 | if (folder) mailfolder_free(folder); | 286 | if (folder) mailfolder_free(folder); |
287 | if (storage) mailstorage_free(storage); | 287 | if (storage) mailstorage_free(storage); |
288 | return res; | 288 | return res; |
289 | } | 289 | } |
290 | 290 | ||
291 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | 291 | int MBOXwrapper::deleteMbox(const Folder*tfolder) |
292 | { | 292 | { |
293 | if (!tfolder) return 0; | 293 | if (!tfolder) return 0; |
294 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 294 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
295 | QFile fi(p); | 295 | QFile fi(p); |
296 | if (!fi.exists()) { | 296 | if (!fi.exists()) { |
297 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 297 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
298 | return 0; | 298 | return 0; |
299 | } | 299 | } |
300 | if (!fi.remove()) { | 300 | if (!fi.remove()) { |
301 | Global::statusMessage(tr("Error deleting Mailbox.")); | 301 | Global::statusMessage(tr("Error deleting Mailbox.")); |
302 | return 0; | 302 | return 0; |
303 | } | 303 | } |
304 | return 1; | 304 | return 1; |
305 | } | 305 | } |
306 | 306 | ||
307 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 307 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
308 | { | 308 | { |
309 | mailfolder*folder = 0; | 309 | mailfolder*folder = 0; |
310 | mailstorage*storage = mailstorage_new(NULL); | 310 | mailstorage*storage = mailstorage_new(NULL); |
311 | target_stat.message_count = 0; | 311 | target_stat.message_count = 0; |
312 | target_stat.message_unseen = 0; | 312 | target_stat.message_unseen = 0; |
313 | target_stat.message_recent = 0; | 313 | target_stat.message_recent = 0; |
314 | QString p = MBOXPath+"/"+mailbox; | 314 | QString p = MBOXPath+"/"+mailbox; |
315 | QFile fi(p); | 315 | QFile fi(p); |
316 | if (!fi.exists()) { | 316 | if (!fi.exists()) { |
317 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 317 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
318 | return; | 318 | return; |
319 | } | 319 | } |
320 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 320 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
321 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 321 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
322 | r = mailfolder_connect(folder); | 322 | r = mailfolder_connect(folder); |
323 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 323 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
324 | &target_stat.message_recent,&target_stat.message_unseen); | 324 | &target_stat.message_recent,&target_stat.message_unseen); |
325 | if (folder) mailfolder_free(folder); | 325 | if (folder) mailfolder_free(folder); |
326 | if (storage) mailstorage_free(storage); | 326 | if (storage) mailstorage_free(storage); |
327 | } | 327 | } |
328 | 328 | ||
329 | const QString&MBOXwrapper::getType()const | 329 | MAILLIB::ATYPE MBOXwrapper::getType()const |
330 | { | 330 | { |
331 | return wrapperType; | 331 | return wrapperType; |
332 | } | 332 | } |
333 | 333 | ||
334 | const QString&MBOXwrapper::getName()const | 334 | const QString&MBOXwrapper::getName()const |
335 | { | 335 | { |
336 | return MBOXName; | 336 | return MBOXName; |
337 | } | 337 | } |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index a579a3d..a12a1dd 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,48 +1,48 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
11 | 11 | ||
12 | class MBOXwrapper : public Genericwrapper | 12 | class MBOXwrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | MBOXwrapper(const QString & dir,const QString&name); | 17 | MBOXwrapper(const QString & dir,const QString&name); |
18 | virtual ~MBOXwrapper(); | 18 | virtual ~MBOXwrapper(); |
19 | 19 | ||
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
21 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 23 | ||
24 | virtual void deleteMail(const RecMail&mail); | 24 | virtual void deleteMail(const RecMail&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 25 | virtual void answeredMail(const RecMail&mail); |
26 | 26 | ||
27 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 27 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
28 | virtual int deleteMbox(const Folder*); | 28 | virtual int deleteMbox(const Folder*); |
29 | 29 | ||
30 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 30 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
31 | 31 | ||
32 | virtual RecBody fetchBody( const RecMail &mail ); | 32 | virtual RecBody fetchBody( const RecMail &mail ); |
33 | static void mbox_progress( size_t current, size_t maximum ); | 33 | static void mbox_progress( size_t current, size_t maximum ); |
34 | 34 | ||
35 | virtual encodedString* fetchRawBody(const RecMail&mail); | 35 | virtual encodedString* fetchRawBody(const RecMail&mail); |
36 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 36 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
37 | virtual int deleteAllMail(const Folder*); | 37 | virtual int deleteAllMail(const Folder*); |
38 | virtual const QString&getType()const; | 38 | virtual MAILLIB::ATYPE getType()const; |
39 | virtual const QString&getName()const; | 39 | virtual const QString&getName()const; |
40 | 40 | ||
41 | protected: | 41 | protected: |
42 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 42 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
43 | QString MBOXPath; | 43 | QString MBOXPath; |
44 | QString MBOXName; | 44 | QString MBOXName; |
45 | static const QString wrapperType; | 45 | static const MAILLIB::ATYPE wrapperType; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #endif | 48 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index df7f773..179bd34 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,445 +1,445 @@ | |||
1 | #include "mhwrapper.h" | 1 | #include "mhwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie2/oprocess.h> | 9 | #include <opie2/oprocess.h> |
10 | 10 | ||
11 | const QString MHwrapper::wrapperType="MH"; | 11 | const MAILLIB::ATYPE MHwrapper::wrapperType=MAILLIB::A_MH; |
12 | 12 | ||
13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
15 | { | 15 | { |
16 | if (MHPath.length()>0) { | 16 | if (MHPath.length()>0) { |
17 | if (MHPath[MHPath.length()-1]=='/') { | 17 | if (MHPath[MHPath.length()-1]=='/') { |
18 | MHPath=MHPath.left(MHPath.length()-1); | 18 | MHPath=MHPath.left(MHPath.length()-1); |
19 | } | 19 | } |
20 | qDebug(MHPath); | 20 | qDebug(MHPath); |
21 | QDir dir(MHPath); | 21 | QDir dir(MHPath); |
22 | if (!dir.exists()) { | 22 | if (!dir.exists()) { |
23 | dir.mkdir(MHPath); | 23 | dir.mkdir(MHPath); |
24 | } | 24 | } |
25 | init_storage(); | 25 | init_storage(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void MHwrapper::init_storage() | 29 | void MHwrapper::init_storage() |
30 | { | 30 | { |
31 | int r; | 31 | int r; |
32 | QString pre = MHPath; | 32 | QString pre = MHPath; |
33 | if (!m_storage) { | 33 | if (!m_storage) { |
34 | m_storage = mailstorage_new(NULL); | 34 | m_storage = mailstorage_new(NULL); |
35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
36 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
37 | qDebug("error initializing storage"); | 37 | qDebug("error initializing storage"); |
38 | mailstorage_free(m_storage); | 38 | mailstorage_free(m_storage); |
39 | m_storage = 0; | 39 | m_storage = 0; |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | r = mailstorage_connect(m_storage); | 43 | r = mailstorage_connect(m_storage); |
44 | if (r!=MAIL_NO_ERROR) { | 44 | if (r!=MAIL_NO_ERROR) { |
45 | qDebug("error connecting storage"); | 45 | qDebug("error connecting storage"); |
46 | mailstorage_free(m_storage); | 46 | mailstorage_free(m_storage); |
47 | m_storage = 0; | 47 | m_storage = 0; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void MHwrapper::clean_storage() | 51 | void MHwrapper::clean_storage() |
52 | { | 52 | { |
53 | if (m_storage) { | 53 | if (m_storage) { |
54 | mailstorage_disconnect(m_storage); | 54 | mailstorage_disconnect(m_storage); |
55 | mailstorage_free(m_storage); | 55 | mailstorage_free(m_storage); |
56 | m_storage = 0; | 56 | m_storage = 0; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | MHwrapper::~MHwrapper() | 60 | MHwrapper::~MHwrapper() |
61 | { | 61 | { |
62 | clean_storage(); | 62 | clean_storage(); |
63 | } | 63 | } |
64 | 64 | ||
65 | void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 65 | void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
66 | { | 66 | { |
67 | init_storage(); | 67 | init_storage(); |
68 | if (!m_storage) { | 68 | if (!m_storage) { |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | QString f = buildPath(mailbox); | 71 | QString f = buildPath(mailbox); |
72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
73 | if (r!=MAIL_NO_ERROR) { | 73 | if (r!=MAIL_NO_ERROR) { |
74 | qDebug("listMessages: error selecting folder!"); | 74 | qDebug("listMessages: error selecting folder!"); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | parseList(target,m_storage->sto_session,f); | 77 | parseList(target,m_storage->sto_session,f); |
78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
79 | } | 79 | } |
80 | 80 | ||
81 | QList<Folder>* MHwrapper::listFolders() | 81 | QList<Folder>* MHwrapper::listFolders() |
82 | { | 82 | { |
83 | QList<Folder> * folders = new QList<Folder>(); | 83 | QList<Folder> * folders = new QList<Folder>(); |
84 | folders->setAutoDelete( false ); | 84 | folders->setAutoDelete( false ); |
85 | /* this is needed! */ | 85 | /* this is needed! */ |
86 | if (m_storage) mailstorage_disconnect(m_storage); | 86 | if (m_storage) mailstorage_disconnect(m_storage); |
87 | init_storage(); | 87 | init_storage(); |
88 | if (!m_storage) { | 88 | if (!m_storage) { |
89 | return folders; | 89 | return folders; |
90 | } | 90 | } |
91 | mail_list*flist = 0; | 91 | mail_list*flist = 0; |
92 | clistcell*current=0; | 92 | clistcell*current=0; |
93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
94 | if (r != MAIL_NO_ERROR || !flist) { | 94 | if (r != MAIL_NO_ERROR || !flist) { |
95 | qDebug("error getting folder list"); | 95 | qDebug("error getting folder list"); |
96 | return folders; | 96 | return folders; |
97 | } | 97 | } |
98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
99 | QString t = (char*)current->data; | 99 | QString t = (char*)current->data; |
100 | t.replace(0,MHPath.length(),""); | 100 | t.replace(0,MHPath.length(),""); |
101 | folders->append(new MHFolder(t,MHPath)); | 101 | folders->append(new MHFolder(t,MHPath)); |
102 | } | 102 | } |
103 | mail_list_free(flist); | 103 | mail_list_free(flist); |
104 | return folders; | 104 | return folders; |
105 | } | 105 | } |
106 | 106 | ||
107 | void MHwrapper::deleteMail(const RecMail&mail) | 107 | void MHwrapper::deleteMail(const RecMail&mail) |
108 | { | 108 | { |
109 | init_storage(); | 109 | init_storage(); |
110 | if (!m_storage) { | 110 | if (!m_storage) { |
111 | return; | 111 | return; |
112 | } | 112 | } |
113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 113 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
114 | if (r!=MAIL_NO_ERROR) { | 114 | if (r!=MAIL_NO_ERROR) { |
115 | qDebug("error selecting folder!"); | 115 | qDebug("error selecting folder!"); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | r = mailsession_remove_message(m_storage->sto_session,mail.getNumber()); | 118 | r = mailsession_remove_message(m_storage->sto_session,mail.getNumber()); |
119 | if (r != MAIL_NO_ERROR) { | 119 | if (r != MAIL_NO_ERROR) { |
120 | qDebug("error deleting mail"); | 120 | qDebug("error deleting mail"); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | void MHwrapper::answeredMail(const RecMail&) | 124 | void MHwrapper::answeredMail(const RecMail&) |
125 | { | 125 | { |
126 | } | 126 | } |
127 | 127 | ||
128 | RecBody MHwrapper::fetchBody( const RecMail &mail ) | 128 | RecBody MHwrapper::fetchBody( const RecMail &mail ) |
129 | { | 129 | { |
130 | RecBody body; | 130 | RecBody body; |
131 | init_storage(); | 131 | init_storage(); |
132 | if (!m_storage) { | 132 | if (!m_storage) { |
133 | return body; | 133 | return body; |
134 | } | 134 | } |
135 | mailmessage * msg; | 135 | mailmessage * msg; |
136 | char*data=0; | 136 | char*data=0; |
137 | size_t size; | 137 | size_t size; |
138 | 138 | ||
139 | /* mail should hold the complete path! */ | 139 | /* mail should hold the complete path! */ |
140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
141 | if (r != MAIL_NO_ERROR) { | 141 | if (r != MAIL_NO_ERROR) { |
142 | return body; | 142 | return body; |
143 | } | 143 | } |
144 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 144 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); |
145 | if (r != MAIL_NO_ERROR) { | 145 | if (r != MAIL_NO_ERROR) { |
146 | qDebug("Error fetching mail %i",mail.getNumber()); | 146 | qDebug("Error fetching mail %i",mail.getNumber()); |
147 | return body; | 147 | return body; |
148 | } | 148 | } |
149 | body = parseMail(msg); | 149 | body = parseMail(msg); |
150 | mailmessage_fetch_result_free(msg,data); | 150 | mailmessage_fetch_result_free(msg,data); |
151 | return body; | 151 | return body; |
152 | } | 152 | } |
153 | 153 | ||
154 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 154 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
155 | { | 155 | { |
156 | qDebug("MH %i von %i",current,maximum); | 156 | qDebug("MH %i von %i",current,maximum); |
157 | } | 157 | } |
158 | 158 | ||
159 | QString MHwrapper::buildPath(const QString&p) | 159 | QString MHwrapper::buildPath(const QString&p) |
160 | { | 160 | { |
161 | QString f=""; | 161 | QString f=""; |
162 | if (p.length()==0||p=="/") | 162 | if (p.length()==0||p=="/") |
163 | return MHPath; | 163 | return MHPath; |
164 | if (!p.startsWith(MHPath)) { | 164 | if (!p.startsWith(MHPath)) { |
165 | f+=MHPath; | 165 | f+=MHPath; |
166 | } | 166 | } |
167 | if (!p.startsWith("/")) { | 167 | if (!p.startsWith("/")) { |
168 | f+="/"; | 168 | f+="/"; |
169 | } | 169 | } |
170 | f+=p; | 170 | f+=p; |
171 | return f; | 171 | return f; |
172 | } | 172 | } |
173 | 173 | ||
174 | int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool ) | 174 | int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool ) |
175 | { | 175 | { |
176 | init_storage(); | 176 | init_storage(); |
177 | if (!m_storage) { | 177 | if (!m_storage) { |
178 | return 0; | 178 | return 0; |
179 | } | 179 | } |
180 | QString f; | 180 | QString f; |
181 | if (!pfolder) { | 181 | if (!pfolder) { |
182 | // toplevel folder | 182 | // toplevel folder |
183 | f = buildPath(folder); | 183 | f = buildPath(folder); |
184 | } else { | 184 | } else { |
185 | f = pfolder->getName(); | 185 | f = pfolder->getName(); |
186 | f+="/"; | 186 | f+="/"; |
187 | f+=folder; | 187 | f+=folder; |
188 | } | 188 | } |
189 | qDebug(f); | 189 | qDebug(f); |
190 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 190 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
191 | if (r != MAIL_NO_ERROR) { | 191 | if (r != MAIL_NO_ERROR) { |
192 | qDebug("error creating folder %i",r); | 192 | qDebug("error creating folder %i",r); |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | qDebug("Folder created"); | 195 | qDebug("Folder created"); |
196 | return 1; | 196 | return 1; |
197 | } | 197 | } |
198 | 198 | ||
199 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 199 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
200 | { | 200 | { |
201 | init_storage(); | 201 | init_storage(); |
202 | if (!m_storage) { | 202 | if (!m_storage) { |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | QString f = buildPath(Folder); | 205 | QString f = buildPath(Folder); |
206 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 206 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
207 | if (r!=MAIL_NO_ERROR) { | 207 | if (r!=MAIL_NO_ERROR) { |
208 | qDebug("error selecting folder!"); | 208 | qDebug("error selecting folder!"); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 211 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
212 | if (r!=MAIL_NO_ERROR) { | 212 | if (r!=MAIL_NO_ERROR) { |
213 | qDebug("error storing mail"); | 213 | qDebug("error storing mail"); |
214 | } | 214 | } |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | encodedString* MHwrapper::fetchRawBody(const RecMail&mail) | 218 | encodedString* MHwrapper::fetchRawBody(const RecMail&mail) |
219 | { | 219 | { |
220 | encodedString*result = 0; | 220 | encodedString*result = 0; |
221 | init_storage(); | 221 | init_storage(); |
222 | if (!m_storage) { | 222 | if (!m_storage) { |
223 | return result; | 223 | return result; |
224 | } | 224 | } |
225 | mailmessage * msg = 0; | 225 | mailmessage * msg = 0; |
226 | char*data=0; | 226 | char*data=0; |
227 | size_t size; | 227 | size_t size; |
228 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 228 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
229 | if (r!=MAIL_NO_ERROR) { | 229 | if (r!=MAIL_NO_ERROR) { |
230 | qDebug("error selecting folder!"); | 230 | qDebug("error selecting folder!"); |
231 | return result; | 231 | return result; |
232 | } | 232 | } |
233 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 233 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); |
234 | if (r != MAIL_NO_ERROR) { | 234 | if (r != MAIL_NO_ERROR) { |
235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 235 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | r = mailmessage_fetch(msg,&data,&size); | 238 | r = mailmessage_fetch(msg,&data,&size); |
239 | if (r != MAIL_NO_ERROR) { | 239 | if (r != MAIL_NO_ERROR) { |
240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 240 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
241 | if (msg) mailmessage_free(msg); | 241 | if (msg) mailmessage_free(msg); |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | result = new encodedString(data,size); | 244 | result = new encodedString(data,size); |
245 | if (msg) mailmessage_free(msg); | 245 | if (msg) mailmessage_free(msg); |
246 | return result; | 246 | return result; |
247 | } | 247 | } |
248 | 248 | ||
249 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 249 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
250 | { | 250 | { |
251 | QString f = buildPath(mailbox); | 251 | QString f = buildPath(mailbox); |
252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 252 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
253 | if (r!=MAIL_NO_ERROR) { | 253 | if (r!=MAIL_NO_ERROR) { |
254 | qDebug("deleteMails: error selecting folder!"); | 254 | qDebug("deleteMails: error selecting folder!"); |
255 | return; | 255 | return; |
256 | } | 256 | } |
257 | RecMail*c = 0; | 257 | RecMail*c = 0; |
258 | for (unsigned int i=0; i < target.count();++i) { | 258 | for (unsigned int i=0; i < target.count();++i) { |
259 | c = target.at(i); | 259 | c = target.at(i); |
260 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); | 260 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); |
261 | if (r != MAIL_NO_ERROR) { | 261 | if (r != MAIL_NO_ERROR) { |
262 | qDebug("error deleting mail"); | 262 | qDebug("error deleting mail"); |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | int MHwrapper::deleteAllMail(const Folder*tfolder) | 268 | int MHwrapper::deleteAllMail(const Folder*tfolder) |
269 | { | 269 | { |
270 | init_storage(); | 270 | init_storage(); |
271 | if (!m_storage) { | 271 | if (!m_storage) { |
272 | return 0; | 272 | return 0; |
273 | } | 273 | } |
274 | int res = 1; | 274 | int res = 1; |
275 | if (!tfolder) return 0; | 275 | if (!tfolder) return 0; |
276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
277 | if (r!=MAIL_NO_ERROR) { | 277 | if (r!=MAIL_NO_ERROR) { |
278 | qDebug("error selecting folder!"); | 278 | qDebug("error selecting folder!"); |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | mailmessage_list*l=0; | 281 | mailmessage_list*l=0; |
282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
283 | if (r != MAIL_NO_ERROR) { | 283 | if (r != MAIL_NO_ERROR) { |
284 | qDebug("Error message list"); | 284 | qDebug("Error message list"); |
285 | res = 0; | 285 | res = 0; |
286 | } | 286 | } |
287 | unsigned j = 0; | 287 | unsigned j = 0; |
288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
289 | mailmessage * msg; | 289 | mailmessage * msg; |
290 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 290 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
291 | j = msg->msg_index; | 291 | j = msg->msg_index; |
292 | r = mailsession_remove_message(m_storage->sto_session,j); | 292 | r = mailsession_remove_message(m_storage->sto_session,j); |
293 | if (r != MAIL_NO_ERROR) { | 293 | if (r != MAIL_NO_ERROR) { |
294 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 294 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
295 | res = 0; | 295 | res = 0; |
296 | break; | 296 | break; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | if (l) mailmessage_list_free(l); | 299 | if (l) mailmessage_list_free(l); |
300 | return res; | 300 | return res; |
301 | } | 301 | } |
302 | 302 | ||
303 | int MHwrapper::deleteMbox(const Folder*tfolder) | 303 | int MHwrapper::deleteMbox(const Folder*tfolder) |
304 | { | 304 | { |
305 | init_storage(); | 305 | init_storage(); |
306 | if (!m_storage) { | 306 | if (!m_storage) { |
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | if (!tfolder) return 0; | 309 | if (!tfolder) return 0; |
310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
311 | 311 | ||
312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
313 | 313 | ||
314 | if (r != MAIL_NO_ERROR) { | 314 | if (r != MAIL_NO_ERROR) { |
315 | qDebug("error deleting mail box"); | 315 | qDebug("error deleting mail box"); |
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | QString cmd = "rm -rf "+tfolder->getName(); | 318 | QString cmd = "rm -rf "+tfolder->getName(); |
319 | QStringList command; | 319 | QStringList command; |
320 | command << "/bin/sh"; | 320 | command << "/bin/sh"; |
321 | command << "-c"; | 321 | command << "-c"; |
322 | command << cmd.latin1(); | 322 | command << cmd.latin1(); |
323 | OProcess *process = new OProcess(); | 323 | OProcess *process = new OProcess(); |
324 | 324 | ||
325 | connect(process, SIGNAL(processExited(OProcess*)), | 325 | connect(process, SIGNAL(processExited(OProcess*)), |
326 | this, SLOT( processEnded(OProcess*))); | 326 | this, SLOT( processEnded(OProcess*))); |
327 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), | 327 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), |
328 | this, SLOT( oprocessStderr(OProcess*,char*,int))); | 328 | this, SLOT( oprocessStderr(OProcess*,char*,int))); |
329 | 329 | ||
330 | *process << command; | 330 | *process << command; |
331 | removeMboxfailed = false; | 331 | removeMboxfailed = false; |
332 | if(!process->start(OProcess::Block, OProcess::All) ) { | 332 | if(!process->start(OProcess::Block, OProcess::All) ) { |
333 | qDebug("could not start process"); | 333 | qDebug("could not start process"); |
334 | return 0; | 334 | return 0; |
335 | } | 335 | } |
336 | qDebug("mail box deleted"); | 336 | qDebug("mail box deleted"); |
337 | return 1; | 337 | return 1; |
338 | } | 338 | } |
339 | 339 | ||
340 | void MHwrapper::processEnded(OProcess *p) | 340 | void MHwrapper::processEnded(OProcess *p) |
341 | { | 341 | { |
342 | if (p) delete p; | 342 | if (p) delete p; |
343 | } | 343 | } |
344 | 344 | ||
345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
346 | { | 346 | { |
347 | QString lineStr = buffer; | 347 | QString lineStr = buffer; |
348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
349 | removeMboxfailed = true; | 349 | removeMboxfailed = true; |
350 | } | 350 | } |
351 | 351 | ||
352 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 352 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
353 | { | 353 | { |
354 | init_storage(); | 354 | init_storage(); |
355 | if (!m_storage) { | 355 | if (!m_storage) { |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | target_stat.message_count = 0; | 358 | target_stat.message_count = 0; |
359 | target_stat.message_unseen = 0; | 359 | target_stat.message_unseen = 0; |
360 | target_stat.message_recent = 0; | 360 | target_stat.message_recent = 0; |
361 | QString f = buildPath(mailbox); | 361 | QString f = buildPath(mailbox); |
362 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 362 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
363 | &target_stat.message_recent,&target_stat.message_unseen); | 363 | &target_stat.message_recent,&target_stat.message_unseen); |
364 | if (r != MAIL_NO_ERROR) { | 364 | if (r != MAIL_NO_ERROR) { |
365 | Global::statusMessage(tr("Error retrieving status")); | 365 | Global::statusMessage(tr("Error retrieving status")); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | const QString&MHwrapper::getType()const | 369 | MAILLIB::ATYPE MHwrapper::getType()const |
370 | { | 370 | { |
371 | return wrapperType; | 371 | return wrapperType; |
372 | } | 372 | } |
373 | 373 | ||
374 | const QString&MHwrapper::getName()const | 374 | const QString&MHwrapper::getName()const |
375 | { | 375 | { |
376 | return MHName; | 376 | return MHName; |
377 | } | 377 | } |
378 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 378 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
379 | { | 379 | { |
380 | init_storage(); | 380 | init_storage(); |
381 | if (!m_storage) { | 381 | if (!m_storage) { |
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | if (targetWrapper != this) { | 384 | if (targetWrapper != this) { |
385 | qDebug("Using generic"); | 385 | qDebug("Using generic"); |
386 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 386 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | qDebug("Using internal routines for move/copy"); | 389 | qDebug("Using internal routines for move/copy"); |
390 | QString tf = buildPath(targetFolder); | 390 | QString tf = buildPath(targetFolder); |
391 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 391 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
392 | if (r != MAIL_NO_ERROR) { | 392 | if (r != MAIL_NO_ERROR) { |
393 | qDebug("Error selecting source mailbox"); | 393 | qDebug("Error selecting source mailbox"); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | if (moveit) { | 396 | if (moveit) { |
397 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 397 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
398 | } else { | 398 | } else { |
399 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 399 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
400 | } | 400 | } |
401 | if (r != MAIL_NO_ERROR) { | 401 | if (r != MAIL_NO_ERROR) { |
402 | qDebug("Error copy/moving mail internal (%i)",r); | 402 | qDebug("Error copy/moving mail internal (%i)",r); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | 405 | ||
406 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 406 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
407 | { | 407 | { |
408 | init_storage(); | 408 | init_storage(); |
409 | if (!m_storage) { | 409 | if (!m_storage) { |
410 | return; | 410 | return; |
411 | } | 411 | } |
412 | if (targetWrapper != this) { | 412 | if (targetWrapper != this) { |
413 | qDebug("Using generic"); | 413 | qDebug("Using generic"); |
414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 414 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | if (!fromFolder) return; | 417 | if (!fromFolder) return; |
418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 418 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
419 | if (r!=MAIL_NO_ERROR) { | 419 | if (r!=MAIL_NO_ERROR) { |
420 | qDebug("error selecting source folder!"); | 420 | qDebug("error selecting source folder!"); |
421 | return; | 421 | return; |
422 | } | 422 | } |
423 | QString tf = buildPath(targetFolder); | 423 | QString tf = buildPath(targetFolder); |
424 | mailmessage_list*l=0; | 424 | mailmessage_list*l=0; |
425 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 425 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
426 | if (r != MAIL_NO_ERROR) { | 426 | if (r != MAIL_NO_ERROR) { |
427 | qDebug("Error message list"); | 427 | qDebug("Error message list"); |
428 | } | 428 | } |
429 | unsigned j = 0; | 429 | unsigned j = 0; |
430 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 430 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
431 | mailmessage * msg; | 431 | mailmessage * msg; |
432 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 432 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
433 | j = msg->msg_index; | 433 | j = msg->msg_index; |
434 | if (moveit) { | 434 | if (moveit) { |
435 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 435 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
436 | } else { | 436 | } else { |
437 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 437 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
438 | } | 438 | } |
439 | if (r != MAIL_NO_ERROR) { | 439 | if (r != MAIL_NO_ERROR) { |
440 | qDebug("Error copy/moving mail internal (%i)",r); | 440 | qDebug("Error copy/moving mail internal (%i)",r); |
441 | break; | 441 | break; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | if (l) mailmessage_list_free(l); | 444 | if (l) mailmessage_list_free(l); |
445 | } | 445 | } |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index b8e380c..c1ba78d 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h | |||
@@ -1,59 +1,61 @@ | |||
1 | #ifndef __MH_WRAPPER_H | 1 | #ifndef __MH_WRAPPER_H |
2 | #define __MH_WRAPPER_H | 2 | #define __MH_WRAPPER_H |
3 | 3 | ||
4 | #include "maildefines.h" | ||
5 | |||
4 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 7 | #include <qstring.h> |
6 | 8 | ||
7 | class RecMail; | 9 | class RecMail; |
8 | class RecBody; | 10 | class RecBody; |
9 | class encodedString; | 11 | class encodedString; |
10 | struct mailmbox_folder; | 12 | struct mailmbox_folder; |
11 | class OProcess; | 13 | class OProcess; |
12 | 14 | ||
13 | class MHwrapper : public Genericwrapper | 15 | class MHwrapper : public Genericwrapper |
14 | { | 16 | { |
15 | Q_OBJECT | 17 | Q_OBJECT |
16 | public: | 18 | public: |
17 | MHwrapper(const QString & dir,const QString&name); | 19 | MHwrapper(const QString & dir,const QString&name); |
18 | virtual ~MHwrapper(); | 20 | virtual ~MHwrapper(); |
19 | 21 | ||
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 22 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
21 | virtual QList<Folder>* listFolders(); | 23 | virtual QList<Folder>* listFolders(); |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 25 | ||
24 | virtual void deleteMail(const RecMail&mail); | 26 | virtual void deleteMail(const RecMail&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 27 | virtual void answeredMail(const RecMail&mail); |
26 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 28 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
27 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 29 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
28 | 30 | ||
29 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 31 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
30 | virtual int deleteMbox(const Folder*); | 32 | virtual int deleteMbox(const Folder*); |
31 | 33 | ||
32 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
33 | 35 | ||
34 | virtual RecBody fetchBody( const RecMail &mail ); | 36 | virtual RecBody fetchBody( const RecMail &mail ); |
35 | static void mbox_progress( size_t current, size_t maximum ); | 37 | static void mbox_progress( size_t current, size_t maximum ); |
36 | 38 | ||
37 | virtual encodedString* fetchRawBody(const RecMail&mail); | 39 | virtual encodedString* fetchRawBody(const RecMail&mail); |
38 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 40 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
39 | virtual int deleteAllMail(const Folder*); | 41 | virtual int deleteAllMail(const Folder*); |
40 | virtual const QString&getType()const; | 42 | virtual MAILLIB::ATYPE getType()const; |
41 | virtual const QString&getName()const; | 43 | virtual const QString&getName()const; |
42 | 44 | ||
43 | public slots: | 45 | public slots: |
44 | /* for deleting maildirs we are using a system call */ | 46 | /* for deleting maildirs we are using a system call */ |
45 | virtual void oprocessStderr(OProcess*, char *buffer, int ); | 47 | virtual void oprocessStderr(OProcess*, char *buffer, int ); |
46 | virtual void processEnded(OProcess *); | 48 | virtual void processEnded(OProcess *); |
47 | protected: | 49 | protected: |
48 | QString buildPath(const QString&p); | 50 | QString buildPath(const QString&p); |
49 | QString MHPath; | 51 | QString MHPath; |
50 | QString MHName; | 52 | QString MHName; |
51 | static const QString wrapperType; | 53 | static const MAILLIB::ATYPE wrapperType; |
52 | 54 | ||
53 | void init_storage(); | 55 | void init_storage(); |
54 | void clean_storage(); | 56 | void clean_storage(); |
55 | 57 | ||
56 | bool removeMboxfailed; | 58 | bool removeMboxfailed; |
57 | }; | 59 | }; |
58 | 60 | ||
59 | #endif | 61 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 5a8c224..1956c61 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,284 +1,284 @@ | |||
1 | #include "nntpwrapper.h" | 1 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 2 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | 8 | ||
9 | #include <libetpan/libetpan.h> | 9 | #include <libetpan/libetpan.h> |
10 | 10 | ||
11 | 11 | ||
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 12 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 13 | ||
14 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 14 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
15 | : Genericwrapper() { | 15 | : Genericwrapper() { |
16 | account = a; | 16 | account = a; |
17 | m_nntp = NULL; | 17 | m_nntp = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 18 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 19 | last_msg_id = 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | NNTPwrapper::~NNTPwrapper() { | 22 | NNTPwrapper::~NNTPwrapper() { |
23 | logout(); | 23 | logout(); |
24 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 26 | msg_cache.remove(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
31 | qDebug( "NNTP: %i of %i", current, maximum ); | 31 | qDebug( "NNTP: %i of %i", current, maximum ); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | 35 | RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { |
36 | int err = NEWSNNTP_NO_ERROR; | 36 | int err = NEWSNNTP_NO_ERROR; |
37 | char *message = 0; | 37 | char *message = 0; |
38 | size_t length = 0; | 38 | size_t length = 0; |
39 | 39 | ||
40 | login(); | 40 | login(); |
41 | if ( !m_nntp ) { | 41 | if ( !m_nntp ) { |
42 | return RecBody(); | 42 | return RecBody(); |
43 | } | 43 | } |
44 | 44 | ||
45 | RecBody body; | 45 | RecBody body; |
46 | mailmessage * mailmsg; | 46 | mailmessage * mailmsg; |
47 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 47 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { |
48 | qDebug("Message to large: %i",mail.Msgsize()); | 48 | qDebug("Message to large: %i",mail.Msgsize()); |
49 | return body; | 49 | return body; |
50 | } | 50 | } |
51 | 51 | ||
52 | QFile msg_cache(msgTempName); | 52 | QFile msg_cache(msgTempName); |
53 | 53 | ||
54 | cleanMimeCache(); | 54 | cleanMimeCache(); |
55 | 55 | ||
56 | if (mail.getNumber()!=last_msg_id) { | 56 | if (mail.getNumber()!=last_msg_id) { |
57 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
58 | msg_cache.remove(); | 58 | msg_cache.remove(); |
59 | } | 59 | } |
60 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
61 | last_msg_id = mail.getNumber(); | 61 | last_msg_id = mail.getNumber(); |
62 | err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 62 | err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); |
63 | err = mailmessage_fetch(mailmsg,&message,&length); | 63 | err = mailmessage_fetch(mailmsg,&message,&length); |
64 | msg_cache.writeBlock(message,length); | 64 | msg_cache.writeBlock(message,length); |
65 | } else { | 65 | } else { |
66 | QString msg=""; | 66 | QString msg=""; |
67 | msg_cache.open(IO_ReadOnly); | 67 | msg_cache.open(IO_ReadOnly); |
68 | message = new char[4096]; | 68 | message = new char[4096]; |
69 | memset(message,0,4096); | 69 | memset(message,0,4096); |
70 | while (msg_cache.readBlock(message,4095)>0) { | 70 | while (msg_cache.readBlock(message,4095)>0) { |
71 | msg+=message; | 71 | msg+=message; |
72 | memset(message,0,4096); | 72 | memset(message,0,4096); |
73 | } | 73 | } |
74 | delete message; | 74 | delete message; |
75 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 75 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
76 | memset(message,0,msg.length()+1); | 76 | memset(message,0,msg.length()+1); |
77 | memcpy(message,msg.latin1(),msg.length()); | 77 | memcpy(message,msg.latin1(),msg.length()); |
78 | /* transform to libetpan stuff */ | 78 | /* transform to libetpan stuff */ |
79 | mailmsg = mailmessage_new(); | 79 | mailmsg = mailmessage_new(); |
80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
81 | generic_message_t * msg_data; | 81 | generic_message_t * msg_data; |
82 | msg_data = (generic_message_t *)mailmsg->msg_data; | 82 | msg_data = (generic_message_t *)mailmsg->msg_data; |
83 | msg_data->msg_fetched = 1; | 83 | msg_data->msg_fetched = 1; |
84 | msg_data->msg_message = message; | 84 | msg_data->msg_message = message; |
85 | msg_data->msg_length = strlen(message); | 85 | msg_data->msg_length = strlen(message); |
86 | } | 86 | } |
87 | body = parseMail(mailmsg); | 87 | body = parseMail(mailmsg); |
88 | 88 | ||
89 | /* clean up */ | 89 | /* clean up */ |
90 | if (mailmsg) | 90 | if (mailmsg) |
91 | mailmessage_free(mailmsg); | 91 | mailmessage_free(mailmsg); |
92 | if (message) | 92 | if (message) |
93 | free(message); | 93 | free(message); |
94 | 94 | ||
95 | return body; | 95 | return body; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target ) | 99 | void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target ) |
100 | { | 100 | { |
101 | login(); | 101 | login(); |
102 | if (!m_nntp) | 102 | if (!m_nntp) |
103 | return; | 103 | return; |
104 | uint32_t res_messages,res_recent,res_unseen; | 104 | uint32_t res_messages,res_recent,res_unseen; |
105 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 105 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
106 | parseList(target,m_nntp->sto_session,which); | 106 | parseList(target,m_nntp->sto_session,which,true); |
107 | } | 107 | } |
108 | 108 | ||
109 | void NNTPwrapper::login() | 109 | void NNTPwrapper::login() |
110 | { | 110 | { |
111 | if (account->getOffline()) | 111 | if (account->getOffline()) |
112 | return; | 112 | return; |
113 | /* we'll hold the line */ | 113 | /* we'll hold the line */ |
114 | if ( m_nntp != NULL ) | 114 | if ( m_nntp != NULL ) |
115 | return; | 115 | return; |
116 | 116 | ||
117 | const char *server, *user, *pass; | 117 | const char *server, *user, *pass; |
118 | QString User,Pass; | 118 | QString User,Pass; |
119 | uint16_t port; | 119 | uint16_t port; |
120 | int err = NEWSNNTP_NO_ERROR; | 120 | int err = NEWSNNTP_NO_ERROR; |
121 | 121 | ||
122 | server = account->getServer().latin1(); | 122 | server = account->getServer().latin1(); |
123 | port = account->getPort().toUInt(); | 123 | port = account->getPort().toUInt(); |
124 | 124 | ||
125 | user = pass = 0; | 125 | user = pass = 0; |
126 | 126 | ||
127 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 127 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
128 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 128 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
129 | login.show(); | 129 | login.show(); |
130 | if ( QDialog::Accepted == login.exec() ) { | 130 | if ( QDialog::Accepted == login.exec() ) { |
131 | // ok | 131 | // ok |
132 | User = login.getUser().latin1(); | 132 | User = login.getUser().latin1(); |
133 | Pass = login.getPassword().latin1(); | 133 | Pass = login.getPassword().latin1(); |
134 | } else { | 134 | } else { |
135 | // cancel | 135 | // cancel |
136 | qDebug( "NNTP: Login canceled" ); | 136 | qDebug( "NNTP: Login canceled" ); |
137 | return; | 137 | return; |
138 | } | 138 | } |
139 | } else { | 139 | } else { |
140 | User = account->getUser().latin1(); | 140 | User = account->getUser().latin1(); |
141 | Pass = account->getPassword().latin1(); | 141 | Pass = account->getPassword().latin1(); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (User.isEmpty()) { | 144 | if (User.isEmpty()) { |
145 | user=0; | 145 | user=0; |
146 | pass = 0; | 146 | pass = 0; |
147 | } else { | 147 | } else { |
148 | user=User.latin1(); | 148 | user=User.latin1(); |
149 | pass=Pass.latin1(); | 149 | pass=Pass.latin1(); |
150 | } | 150 | } |
151 | // bool ssl = account->getSSL(); | 151 | // bool ssl = account->getSSL(); |
152 | 152 | ||
153 | m_nntp=mailstorage_new(NULL); | 153 | m_nntp=mailstorage_new(NULL); |
154 | 154 | ||
155 | int conntypeset = account->ConnectionType(); | 155 | int conntypeset = account->ConnectionType(); |
156 | int conntype = 0; | 156 | int conntype = 0; |
157 | if ( conntypeset == 3 ) { | 157 | if ( conntypeset == 3 ) { |
158 | conntype = CONNECTION_TYPE_COMMAND; | 158 | conntype = CONNECTION_TYPE_COMMAND; |
159 | } else if ( conntypeset == 2 ) { | 159 | } else if ( conntypeset == 2 ) { |
160 | conntype = CONNECTION_TYPE_TLS; | 160 | conntype = CONNECTION_TYPE_TLS; |
161 | } else if ( conntypeset == 1 ) { | 161 | } else if ( conntypeset == 1 ) { |
162 | conntype = CONNECTION_TYPE_STARTTLS; | 162 | conntype = CONNECTION_TYPE_STARTTLS; |
163 | } else if ( conntypeset == 0 ) { | 163 | } else if ( conntypeset == 0 ) { |
164 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 164 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
165 | } | 165 | } |
166 | 166 | ||
167 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 167 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
168 | (char*)user,(char*)pass,0,0,0); | 168 | (char*)user,(char*)pass,0,0,0); |
169 | 169 | ||
170 | err = mailstorage_connect( m_nntp ); | 170 | err = mailstorage_connect( m_nntp ); |
171 | 171 | ||
172 | if (err != NEWSNNTP_NO_ERROR) { | 172 | if (err != NEWSNNTP_NO_ERROR) { |
173 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 173 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
174 | // Global::statusMessage(tr("Error initializing folder")); | 174 | // Global::statusMessage(tr("Error initializing folder")); |
175 | mailstorage_free(m_nntp); | 175 | mailstorage_free(m_nntp); |
176 | m_nntp = 0; | 176 | m_nntp = 0; |
177 | 177 | ||
178 | } | 178 | } |
179 | 179 | ||
180 | } | 180 | } |
181 | 181 | ||
182 | void NNTPwrapper::logout() | 182 | void NNTPwrapper::logout() |
183 | { | 183 | { |
184 | int err = NEWSNNTP_NO_ERROR; | 184 | int err = NEWSNNTP_NO_ERROR; |
185 | if ( m_nntp == NULL ) | 185 | if ( m_nntp == NULL ) |
186 | return; | 186 | return; |
187 | mailstorage_free(m_nntp); | 187 | mailstorage_free(m_nntp); |
188 | m_nntp = 0; | 188 | m_nntp = 0; |
189 | } | 189 | } |
190 | 190 | ||
191 | QList<Folder>* NNTPwrapper::listFolders() { | 191 | QList<Folder>* NNTPwrapper::listFolders() { |
192 | 192 | ||
193 | QList<Folder> * folders = new QList<Folder>(); | 193 | QList<Folder> * folders = new QList<Folder>(); |
194 | folders->setAutoDelete( false ); | 194 | folders->setAutoDelete( false ); |
195 | QStringList groups; | 195 | QStringList groups; |
196 | if (account) { | 196 | if (account) { |
197 | groups = account->getGroups(); | 197 | groups = account->getGroups(); |
198 | } | 198 | } |
199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
200 | folders->append(new Folder((*it),".")); | 200 | folders->append(new Folder((*it),".")); |
201 | } | 201 | } |
202 | return folders; | 202 | return folders; |
203 | } | 203 | } |
204 | 204 | ||
205 | /* we made this method in raw nntp access of etpan and not via generic interface | 205 | /* we made this method in raw nntp access of etpan and not via generic interface |
206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
207 | * copy that stuff into its own structures and we must copy it into useable c++ | 207 | * copy that stuff into its own structures and we must copy it into useable c++ |
208 | * structures for our frontend. this would not make sense, so it is better to reimplement | 208 | * structures for our frontend. this would not make sense, so it is better to reimplement |
209 | * the stuff from generic interface of etpan but copy it direct to qt classes. | 209 | * the stuff from generic interface of etpan but copy it direct to qt classes. |
210 | */ | 210 | */ |
211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | 211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { |
212 | login(); | 212 | login(); |
213 | QStringList res; | 213 | QStringList res; |
214 | clist *result = 0; | 214 | clist *result = 0; |
215 | clistcell *current = 0; | 215 | clistcell *current = 0; |
216 | newsnntp_group_description *group; | 216 | newsnntp_group_description *group; |
217 | 217 | ||
218 | if ( m_nntp ) { | 218 | if ( m_nntp ) { |
219 | mailsession * session = m_nntp->sto_session; | 219 | mailsession * session = m_nntp->sto_session; |
220 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 220 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
221 | int err = NEWSNNTP_NO_ERROR; | 221 | int err = NEWSNNTP_NO_ERROR; |
222 | if (mask.isEmpty()) { | 222 | if (mask.isEmpty()) { |
223 | err = newsnntp_list(news, &result); | 223 | err = newsnntp_list(news, &result); |
224 | } else { | 224 | } else { |
225 | /* taken from generic wrapper of etpan */ | 225 | /* taken from generic wrapper of etpan */ |
226 | QString nmask = mask+".*"; | 226 | QString nmask = mask+".*"; |
227 | err = newsnntp_list_active(news, nmask.latin1(), &result); | 227 | err = newsnntp_list_active(news, nmask.latin1(), &result); |
228 | } | 228 | } |
229 | if ( err == NEWSNNTP_NO_ERROR && result) { | 229 | if ( err == NEWSNNTP_NO_ERROR && result) { |
230 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { | 230 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { |
231 | group = ( newsnntp_group_description* ) current->data; | 231 | group = ( newsnntp_group_description* ) current->data; |
232 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; | 232 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; |
233 | res.append(group->grp_name); | 233 | res.append(group->grp_name); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | } | 236 | } |
237 | if (result) { | 237 | if (result) { |
238 | newsnntp_list_free(result); | 238 | newsnntp_list_free(result); |
239 | } | 239 | } |
240 | return res; | 240 | return res; |
241 | } | 241 | } |
242 | 242 | ||
243 | void NNTPwrapper::answeredMail(const RecMail&) {} | 243 | void NNTPwrapper::answeredMail(const RecMail&) {} |
244 | 244 | ||
245 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { | 245 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { |
246 | login(); | 246 | login(); |
247 | target_stat.message_count = 0; | 247 | target_stat.message_count = 0; |
248 | target_stat.message_unseen = 0; | 248 | target_stat.message_unseen = 0; |
249 | target_stat.message_recent = 0; | 249 | target_stat.message_recent = 0; |
250 | if (!m_nntp) | 250 | if (!m_nntp) |
251 | return; | 251 | return; |
252 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, | 252 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, |
253 | &target_stat.message_recent,&target_stat.message_unseen); | 253 | &target_stat.message_recent,&target_stat.message_unseen); |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { | 257 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { |
258 | char*target=0; | 258 | char*target=0; |
259 | size_t length=0; | 259 | size_t length=0; |
260 | encodedString*res = 0; | 260 | encodedString*res = 0; |
261 | mailmessage * mailmsg = 0; | 261 | mailmessage * mailmsg = 0; |
262 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 262 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); |
263 | err = mailmessage_fetch(mailmsg,&target,&length); | 263 | err = mailmessage_fetch(mailmsg,&target,&length); |
264 | if (mailmsg) | 264 | if (mailmsg) |
265 | mailmessage_free(mailmsg); | 265 | mailmessage_free(mailmsg); |
266 | if (target) { | 266 | if (target) { |
267 | res = new encodedString(target,length); | 267 | res = new encodedString(target,length); |
268 | } | 268 | } |
269 | return res; | 269 | return res; |
270 | } | 270 | } |
271 | 271 | ||
272 | const QString&NNTPwrapper::getType()const { | 272 | MAILLIB::ATYPE NNTPwrapper::getType()const { |
273 | return account->getType(); | 273 | return account->getType(); |
274 | } | 274 | } |
275 | 275 | ||
276 | const QString&NNTPwrapper::getName()const{ | 276 | const QString&NNTPwrapper::getName()const{ |
277 | return account->getAccountName(); | 277 | return account->getAccountName(); |
278 | } | 278 | } |
279 | 279 | ||
280 | void NNTPwrapper::deleteMail(const RecMail&mail) { | 280 | void NNTPwrapper::deleteMail(const RecMail&) { |
281 | } | 281 | } |
282 | 282 | ||
283 | int NNTPwrapper::deleteAllMail(const Folder*) { | 283 | int NNTPwrapper::deleteAllMail(const Folder*) { |
284 | } | 284 | } |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h index d51c955..955b9f1 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.h +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h | |||
@@ -1,48 +1,48 @@ | |||
1 | #ifndef __NNTPWRAPPER | 1 | #ifndef __NNTPWRAPPER |
2 | #define __NNTPWRAPPER | 2 | #define __NNTPWRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailstorage; | 10 | struct mailstorage; |
11 | struct mailfolder; | 11 | struct mailfolder; |
12 | 12 | ||
13 | class NNTPwrapper : public Genericwrapper | 13 | class NNTPwrapper : public Genericwrapper |
14 | { | 14 | { |
15 | 15 | ||
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | NNTPwrapper( NNTPaccount *a ); | 19 | NNTPwrapper( NNTPaccount *a ); |
20 | virtual ~NNTPwrapper(); | 20 | virtual ~NNTPwrapper(); |
21 | 21 | ||
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 23 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
24 | /* should only get the subscribed one */ | 24 | /* should only get the subscribed one */ |
25 | virtual QList<Folder>* listFolders(); | 25 | virtual QList<Folder>* listFolders(); |
26 | /* mailbox will be ignored */ | 26 | /* mailbox will be ignored */ |
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
28 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 28 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
29 | virtual void deleteMail(const RecMail&mail); | 29 | virtual void deleteMail(const RecMail&mail); |
30 | virtual void answeredMail(const RecMail&mail); | 30 | virtual void answeredMail(const RecMail&mail); |
31 | virtual int deleteAllMail(const Folder*); | 31 | virtual int deleteAllMail(const Folder*); |
32 | 32 | ||
33 | virtual RecBody fetchBody( const RecMail &mail ); | 33 | virtual RecBody fetchBody( const RecMail &mail ); |
34 | virtual encodedString* fetchRawBody(const RecMail&mail); | 34 | virtual encodedString* fetchRawBody(const RecMail&mail); |
35 | virtual void logout(); | 35 | virtual void logout(); |
36 | virtual const QString&getType()const; | 36 | virtual MAILLIB::ATYPE getType()const; |
37 | virtual const QString&getName()const; | 37 | virtual const QString&getName()const; |
38 | static void nntp_progress( size_t current, size_t maximum ); | 38 | static void nntp_progress( size_t current, size_t maximum ); |
39 | 39 | ||
40 | protected: | 40 | protected: |
41 | void login(); | 41 | void login(); |
42 | NNTPaccount *account; | 42 | NNTPaccount *account; |
43 | mailstorage* m_nntp; | 43 | mailstorage* m_nntp; |
44 | 44 | ||
45 | 45 | ||
46 | }; | 46 | }; |
47 | 47 | ||
48 | #endif | 48 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 6fab401..0939b22 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,255 +1,255 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | //#include <qstring.h> | 8 | //#include <qstring.h> |
9 | 9 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 10 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 11 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 12 | ||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 13 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() { | 14 | : Genericwrapper() { |
15 | account = a; | 15 | account = a; |
16 | m_pop3 = NULL; | 16 | m_pop3 = NULL; |
17 | msgTempName = a->getFileName()+"_msg_cache"; | 17 | msgTempName = a->getFileName()+"_msg_cache"; |
18 | last_msg_id = 0; | 18 | last_msg_id = 0; |
19 | } | 19 | } |
20 | 20 | ||
21 | POP3wrapper::~POP3wrapper() { | 21 | POP3wrapper::~POP3wrapper() { |
22 | logout(); | 22 | logout(); |
23 | QFile msg_cache(msgTempName); | 23 | QFile msg_cache(msgTempName); |
24 | if (msg_cache.exists()) { | 24 | if (msg_cache.exists()) { |
25 | msg_cache.remove(); | 25 | msg_cache.remove(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 29 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
30 | qDebug( "POP3: %i of %i", current, maximum ); | 30 | qDebug( "POP3: %i of %i", current, maximum ); |
31 | } | 31 | } |
32 | 32 | ||
33 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) { | 33 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) { |
34 | int err = MAILPOP3_NO_ERROR; | 34 | int err = MAILPOP3_NO_ERROR; |
35 | char *message = 0; | 35 | char *message = 0; |
36 | size_t length = 0; | 36 | size_t length = 0; |
37 | 37 | ||
38 | login(); | 38 | login(); |
39 | if ( !m_pop3 ) { | 39 | if ( !m_pop3 ) { |
40 | return RecBody(); | 40 | return RecBody(); |
41 | } | 41 | } |
42 | 42 | ||
43 | RecBody body; | 43 | RecBody body; |
44 | mailmessage * mailmsg; | 44 | mailmessage * mailmsg; |
45 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 45 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { |
46 | qDebug("Message to large: %i",mail.Msgsize()); | 46 | qDebug("Message to large: %i",mail.Msgsize()); |
47 | return body; | 47 | return body; |
48 | } | 48 | } |
49 | 49 | ||
50 | QFile msg_cache(msgTempName); | 50 | QFile msg_cache(msgTempName); |
51 | 51 | ||
52 | cleanMimeCache(); | 52 | cleanMimeCache(); |
53 | 53 | ||
54 | if (mail.getNumber()!=last_msg_id) { | 54 | if (mail.getNumber()!=last_msg_id) { |
55 | if (msg_cache.exists()) { | 55 | if (msg_cache.exists()) { |
56 | msg_cache.remove(); | 56 | msg_cache.remove(); |
57 | } | 57 | } |
58 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 58 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
59 | last_msg_id = mail.getNumber(); | 59 | last_msg_id = mail.getNumber(); |
60 | err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); | 60 | err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); |
61 | err = mailmessage_fetch(mailmsg,&message,&length); | 61 | err = mailmessage_fetch(mailmsg,&message,&length); |
62 | msg_cache.writeBlock(message,length); | 62 | msg_cache.writeBlock(message,length); |
63 | } else { | 63 | } else { |
64 | QString msg=""; | 64 | QString msg=""; |
65 | msg_cache.open(IO_ReadOnly); | 65 | msg_cache.open(IO_ReadOnly); |
66 | message = new char[4096]; | 66 | message = new char[4096]; |
67 | memset(message,0,4096); | 67 | memset(message,0,4096); |
68 | while (msg_cache.readBlock(message,4095)>0) { | 68 | while (msg_cache.readBlock(message,4095)>0) { |
69 | msg+=message; | 69 | msg+=message; |
70 | memset(message,0,4096); | 70 | memset(message,0,4096); |
71 | } | 71 | } |
72 | delete message; | 72 | delete message; |
73 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 73 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
74 | memset(message,0,msg.length()+1); | 74 | memset(message,0,msg.length()+1); |
75 | memcpy(message,msg.latin1(),msg.length()); | 75 | memcpy(message,msg.latin1(),msg.length()); |
76 | /* transform to libetpan stuff */ | 76 | /* transform to libetpan stuff */ |
77 | mailmsg = mailmessage_new(); | 77 | mailmsg = mailmessage_new(); |
78 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 78 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
79 | generic_message_t * msg_data; | 79 | generic_message_t * msg_data; |
80 | msg_data = (generic_message_t *)mailmsg->msg_data; | 80 | msg_data = (generic_message_t *)mailmsg->msg_data; |
81 | msg_data->msg_fetched = 1; | 81 | msg_data->msg_fetched = 1; |
82 | msg_data->msg_message = message; | 82 | msg_data->msg_message = message; |
83 | msg_data->msg_length = strlen(message); | 83 | msg_data->msg_length = strlen(message); |
84 | } | 84 | } |
85 | body = parseMail(mailmsg); | 85 | body = parseMail(mailmsg); |
86 | 86 | ||
87 | /* clean up */ | 87 | /* clean up */ |
88 | if (mailmsg) | 88 | if (mailmsg) |
89 | mailmessage_free(mailmsg); | 89 | mailmessage_free(mailmsg); |
90 | if (message) | 90 | if (message) |
91 | free(message); | 91 | free(message); |
92 | 92 | ||
93 | return body; | 93 | return body; |
94 | } | 94 | } |
95 | 95 | ||
96 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 96 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
97 | { | 97 | { |
98 | login(); | 98 | login(); |
99 | if (!m_pop3) | 99 | if (!m_pop3) |
100 | return; | 100 | return; |
101 | uint32_t res_messages,res_recent,res_unseen; | 101 | uint32_t res_messages,res_recent,res_unseen; |
102 | mailsession_status_folder(m_pop3->sto_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_pop3->sto_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)); |
105 | } | 105 | } |
106 | 106 | ||
107 | void POP3wrapper::login() | 107 | void POP3wrapper::login() |
108 | { | 108 | { |
109 | if (account->getOffline()) | 109 | if (account->getOffline()) |
110 | return; | 110 | return; |
111 | /* we'll hold the line */ | 111 | /* we'll hold the line */ |
112 | if ( m_pop3 != NULL ) | 112 | if ( m_pop3 != NULL ) |
113 | return; | 113 | return; |
114 | 114 | ||
115 | const char *server, *user, *pass; | 115 | const char *server, *user, *pass; |
116 | uint16_t port; | 116 | uint16_t port; |
117 | int err = MAILPOP3_NO_ERROR; | 117 | int err = MAILPOP3_NO_ERROR; |
118 | 118 | ||
119 | server = account->getServer().latin1(); | 119 | server = account->getServer().latin1(); |
120 | port = account->getPort().toUInt(); | 120 | port = account->getPort().toUInt(); |
121 | 121 | ||
122 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 122 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
123 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 123 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
124 | login.show(); | 124 | login.show(); |
125 | if ( QDialog::Accepted == login.exec() ) { | 125 | if ( QDialog::Accepted == login.exec() ) { |
126 | // ok | 126 | // ok |
127 | user = login.getUser().latin1(); | 127 | user = login.getUser().latin1(); |
128 | pass = login.getPassword().latin1(); | 128 | pass = login.getPassword().latin1(); |
129 | } else { | 129 | } else { |
130 | // cancel | 130 | // cancel |
131 | qDebug( "POP3: Login canceled" ); | 131 | qDebug( "POP3: Login canceled" ); |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | } else { | 134 | } else { |
135 | user = account->getUser().latin1(); | 135 | user = account->getUser().latin1(); |
136 | pass = account->getPassword().latin1(); | 136 | pass = account->getPassword().latin1(); |
137 | } | 137 | } |
138 | 138 | ||
139 | // bool ssl = account->getSSL(); | 139 | // bool ssl = account->getSSL(); |
140 | 140 | ||
141 | m_pop3=mailstorage_new(NULL); | 141 | m_pop3=mailstorage_new(NULL); |
142 | 142 | ||
143 | int conntypeset = account->ConnectionType(); | 143 | int conntypeset = account->ConnectionType(); |
144 | int conntype = 0; | 144 | int conntype = 0; |
145 | if ( conntypeset == 3 ) { | 145 | if ( conntypeset == 3 ) { |
146 | conntype = CONNECTION_TYPE_COMMAND; | 146 | conntype = CONNECTION_TYPE_COMMAND; |
147 | } else if ( conntypeset == 2 ) { | 147 | } else if ( conntypeset == 2 ) { |
148 | conntype = CONNECTION_TYPE_TLS; | 148 | conntype = CONNECTION_TYPE_TLS; |
149 | } else if ( conntypeset == 1 ) { | 149 | } else if ( conntypeset == 1 ) { |
150 | conntype = CONNECTION_TYPE_STARTTLS; | 150 | conntype = CONNECTION_TYPE_STARTTLS; |
151 | } else if ( conntypeset == 0 ) { | 151 | } else if ( conntypeset == 0 ) { |
152 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 152 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
153 | } | 153 | } |
154 | 154 | ||
155 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 155 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
156 | 156 | ||
157 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 157 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
158 | (char*)user,(char*)pass,0,0,0); | 158 | (char*)user,(char*)pass,0,0,0); |
159 | 159 | ||
160 | 160 | ||
161 | err = mailstorage_connect(m_pop3); | 161 | err = mailstorage_connect(m_pop3); |
162 | if (err != MAIL_NO_ERROR) { | 162 | if (err != MAIL_NO_ERROR) { |
163 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 163 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
164 | Global::statusMessage(tr("Error initializing folder")); | 164 | Global::statusMessage(tr("Error initializing folder")); |
165 | mailstorage_free(m_pop3); | 165 | mailstorage_free(m_pop3); |
166 | m_pop3 = 0; | 166 | m_pop3 = 0; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | void POP3wrapper::logout() | 170 | void POP3wrapper::logout() |
171 | { | 171 | { |
172 | int err = MAILPOP3_NO_ERROR; | 172 | int err = MAILPOP3_NO_ERROR; |
173 | if ( m_pop3 == NULL ) | 173 | if ( m_pop3 == NULL ) |
174 | return; | 174 | return; |
175 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
176 | m_pop3 = 0; | 176 | m_pop3 = 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | QList<Folder>* POP3wrapper::listFolders() { | 180 | QList<Folder>* POP3wrapper::listFolders() { |
181 | QList<Folder> * folders = new QList<Folder>(); | 181 | QList<Folder> * folders = new QList<Folder>(); |
182 | folders->setAutoDelete( false ); | 182 | folders->setAutoDelete( false ); |
183 | Folder*inb=new Folder("INBOX","/"); | 183 | Folder*inb=new Folder("INBOX","/"); |
184 | folders->append(inb); | 184 | folders->append(inb); |
185 | return folders; | 185 | return folders; |
186 | } | 186 | } |
187 | 187 | ||
188 | void POP3wrapper::deleteMail(const RecMail&mail) { | 188 | void POP3wrapper::deleteMail(const RecMail&mail) { |
189 | login(); | 189 | login(); |
190 | if (!m_pop3) | 190 | if (!m_pop3) |
191 | return; | 191 | return; |
192 | int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); | 192 | int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); |
193 | if (err != MAIL_NO_ERROR) { | 193 | if (err != MAIL_NO_ERROR) { |
194 | Global::statusMessage(tr("error deleting mail")); | 194 | Global::statusMessage(tr("error deleting mail")); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | void POP3wrapper::answeredMail(const RecMail&) {} | 198 | void POP3wrapper::answeredMail(const RecMail&) {} |
199 | 199 | ||
200 | int POP3wrapper::deleteAllMail(const Folder*) { | 200 | int POP3wrapper::deleteAllMail(const Folder*) { |
201 | login(); | 201 | login(); |
202 | if (!m_pop3) | 202 | if (!m_pop3) |
203 | return 0; | 203 | return 0; |
204 | int res = 1; | 204 | int res = 1; |
205 | 205 | ||
206 | uint32_t result = 0; | 206 | uint32_t result = 0; |
207 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 207 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
208 | if (err != MAIL_NO_ERROR) { | 208 | if (err != MAIL_NO_ERROR) { |
209 | Global::statusMessage(tr("Error getting folder info")); | 209 | Global::statusMessage(tr("Error getting folder info")); |
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | for (unsigned int i = 0; i < result; ++i) { | 212 | for (unsigned int i = 0; i < result; ++i) { |
213 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 213 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
214 | if (err != MAIL_NO_ERROR) { | 214 | if (err != MAIL_NO_ERROR) { |
215 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 215 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
216 | res=0; | 216 | res=0; |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | } | 219 | } |
220 | return res; | 220 | return res; |
221 | } | 221 | } |
222 | 222 | ||
223 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 223 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
224 | login(); | 224 | login(); |
225 | target_stat.message_count = 0; | 225 | target_stat.message_count = 0; |
226 | target_stat.message_unseen = 0; | 226 | target_stat.message_unseen = 0; |
227 | target_stat.message_recent = 0; | 227 | target_stat.message_recent = 0; |
228 | if (!m_pop3) | 228 | if (!m_pop3) |
229 | return; | 229 | return; |
230 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 230 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
231 | &target_stat.message_recent,&target_stat.message_unseen); | 231 | &target_stat.message_recent,&target_stat.message_unseen); |
232 | } | 232 | } |
233 | 233 | ||
234 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { | 234 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { |
235 | char*target=0; | 235 | char*target=0; |
236 | size_t length=0; | 236 | size_t length=0; |
237 | encodedString*res = 0; | 237 | encodedString*res = 0; |
238 | mailmessage * mailmsg = 0; | 238 | mailmessage * mailmsg = 0; |
239 | int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); | 239 | int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); |
240 | err = mailmessage_fetch(mailmsg,&target,&length); | 240 | err = mailmessage_fetch(mailmsg,&target,&length); |
241 | if (mailmsg) | 241 | if (mailmsg) |
242 | mailmessage_free(mailmsg); | 242 | mailmessage_free(mailmsg); |
243 | if (target) { | 243 | if (target) { |
244 | res = new encodedString(target,length); | 244 | res = new encodedString(target,length); |
245 | } | 245 | } |
246 | return res; | 246 | return res; |
247 | } | 247 | } |
248 | 248 | ||
249 | const QString&POP3wrapper::getType()const { | 249 | MAILLIB::ATYPE POP3wrapper::getType()const { |
250 | return account->getType(); | 250 | return account->getType(); |
251 | } | 251 | } |
252 | 252 | ||
253 | const QString&POP3wrapper::getName()const{ | 253 | const QString&POP3wrapper::getName()const{ |
254 | return account->getAccountName(); | 254 | return account->getAccountName(); |
255 | } | 255 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index a24b9cf..391c841 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,42 +1,42 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | class encodedString; | 8 | class encodedString; |
9 | struct mailstorage; | 9 | struct mailstorage; |
10 | struct mailfolder; | 10 | struct mailfolder; |
11 | 11 | ||
12 | class POP3wrapper : public Genericwrapper | 12 | class POP3wrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | POP3wrapper( POP3account *a ); | 17 | POP3wrapper( POP3account *a ); |
18 | virtual ~POP3wrapper(); | 18 | virtual ~POP3wrapper(); |
19 | /* mailbox will be ignored */ | 19 | /* mailbox will be ignored */ |
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
21 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
24 | 24 | ||
25 | virtual void deleteMail(const RecMail&mail); | 25 | virtual void deleteMail(const RecMail&mail); |
26 | virtual void answeredMail(const RecMail&mail); | 26 | virtual void answeredMail(const RecMail&mail); |
27 | virtual int deleteAllMail(const Folder*); | 27 | virtual int deleteAllMail(const Folder*); |
28 | 28 | ||
29 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMail&mail); | 30 | virtual encodedString* fetchRawBody(const RecMail&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual const QString&getType()const; | 32 | virtual MAILLIB::ATYPE getType()const; |
33 | virtual const QString&getName()const; | 33 | virtual const QString&getName()const; |
34 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
35 | 35 | ||
36 | protected: | 36 | protected: |
37 | void login(); | 37 | void login(); |
38 | POP3account *account; | 38 | POP3account *account; |
39 | mailstorage*m_pop3; | 39 | mailstorage*m_pop3; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 0d34fd5..2c81963 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -1,440 +1,440 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | 5 | ||
6 | #include "settings.h" | 6 | #include "settings.h" |
7 | //#include "defines.h" | 7 | //#include "defines.h" |
8 | 8 | ||
9 | #define IMAP_PORT "143" | 9 | #define IMAP_PORT "143" |
10 | #define IMAP_SSL_PORT "993" | 10 | #define IMAP_SSL_PORT "993" |
11 | #define SMTP_PORT "25" | 11 | #define SMTP_PORT "25" |
12 | #define SMTP_SSL_PORT "465" | 12 | #define SMTP_SSL_PORT "465" |
13 | #define POP3_PORT "110" | 13 | #define POP3_PORT "110" |
14 | #define POP3_SSL_PORT "995" | 14 | #define POP3_SSL_PORT "995" |
15 | #define NNTP_PORT "119" | 15 | #define NNTP_PORT "119" |
16 | #define NNTP_SSL_PORT "563" | 16 | #define NNTP_SSL_PORT "563" |
17 | 17 | ||
18 | 18 | ||
19 | Settings::Settings() | 19 | Settings::Settings() |
20 | : QObject() | 20 | : QObject() |
21 | { | 21 | { |
22 | updateAccounts(); | 22 | updateAccounts(); |
23 | } | 23 | } |
24 | 24 | ||
25 | void Settings::checkDirectory() | 25 | void Settings::checkDirectory() |
26 | { | 26 | { |
27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
28 | system( "mkdir -p $HOME/Applications/opiemail" ); | 28 | system( "mkdir -p $HOME/Applications/opiemail" ); |
29 | qDebug( "$HOME/Applications/opiemail created" ); | 29 | qDebug( "$HOME/Applications/opiemail created" ); |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | QList<Account> Settings::getAccounts() | 33 | QList<Account> Settings::getAccounts() |
34 | { | 34 | { |
35 | return accounts; | 35 | return accounts; |
36 | } | 36 | } |
37 | 37 | ||
38 | void Settings::addAccount( Account *account ) | 38 | void Settings::addAccount( Account *account ) |
39 | { | 39 | { |
40 | accounts.append( account ); | 40 | accounts.append( account ); |
41 | } | 41 | } |
42 | 42 | ||
43 | void Settings::delAccount( Account *account ) | 43 | void Settings::delAccount( Account *account ) |
44 | { | 44 | { |
45 | accounts.remove( account ); | 45 | accounts.remove( account ); |
46 | account->remove(); | 46 | account->remove(); |
47 | } | 47 | } |
48 | 48 | ||
49 | void Settings::updateAccounts() | 49 | void Settings::updateAccounts() |
50 | { | 50 | { |
51 | accounts.clear(); | 51 | accounts.clear(); |
52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
53 | QStringList::Iterator it; | 53 | QStringList::Iterator it; |
54 | 54 | ||
55 | QStringList imap = dir.entryList( "imap-*" ); | 55 | QStringList imap = dir.entryList( "imap-*" ); |
56 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 56 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
57 | qDebug( "Added IMAP account" ); | 57 | qDebug( "Added IMAP account" ); |
58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
59 | accounts.append( account ); | 59 | accounts.append( account ); |
60 | } | 60 | } |
61 | 61 | ||
62 | QStringList pop3 = dir.entryList( "pop3-*" ); | 62 | QStringList pop3 = dir.entryList( "pop3-*" ); |
63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
64 | qDebug( "Added POP account" ); | 64 | qDebug( "Added POP account" ); |
65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
66 | accounts.append( account ); | 66 | accounts.append( account ); |
67 | } | 67 | } |
68 | 68 | ||
69 | QStringList smtp = dir.entryList( "smtp-*" ); | 69 | QStringList smtp = dir.entryList( "smtp-*" ); |
70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
71 | qDebug( "Added SMTP account" ); | 71 | qDebug( "Added SMTP account" ); |
72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
73 | accounts.append( account ); | 73 | accounts.append( account ); |
74 | } | 74 | } |
75 | 75 | ||
76 | QStringList nntp = dir.entryList( "nntp-*" ); | 76 | QStringList nntp = dir.entryList( "nntp-*" ); |
77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
78 | qDebug( "Added NNTP account" ); | 78 | qDebug( "Added NNTP account" ); |
79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
80 | accounts.append( account ); | 80 | accounts.append( account ); |
81 | } | 81 | } |
82 | 82 | ||
83 | readAccounts(); | 83 | readAccounts(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void Settings::saveAccounts() | 86 | void Settings::saveAccounts() |
87 | { | 87 | { |
88 | checkDirectory(); | 88 | checkDirectory(); |
89 | Account *it; | 89 | Account *it; |
90 | 90 | ||
91 | for ( it = accounts.first(); it; it = accounts.next() ) { | 91 | for ( it = accounts.first(); it; it = accounts.next() ) { |
92 | it->save(); | 92 | it->save(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void Settings::readAccounts() | 96 | void Settings::readAccounts() |
97 | { | 97 | { |
98 | checkDirectory(); | 98 | checkDirectory(); |
99 | Account *it; | 99 | Account *it; |
100 | 100 | ||
101 | for ( it = accounts.first(); it; it = accounts.next() ) { | 101 | for ( it = accounts.first(); it; it = accounts.next() ) { |
102 | it->read(); | 102 | it->read(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | Account::Account() | 106 | Account::Account() |
107 | { | 107 | { |
108 | accountName = "changeMe"; | 108 | accountName = "changeMe"; |
109 | type = "changeMe"; | 109 | type = MAILLIB::A_UNDEFINED; |
110 | ssl = false; | 110 | ssl = false; |
111 | connectionType = 1; | 111 | connectionType = 1; |
112 | offline = false; | 112 | offline = false; |
113 | } | 113 | } |
114 | 114 | ||
115 | void Account::remove() | 115 | void Account::remove() |
116 | { | 116 | { |
117 | QFile file( getFileName() ); | 117 | QFile file( getFileName() ); |
118 | file.remove(); | 118 | file.remove(); |
119 | } | 119 | } |
120 | 120 | ||
121 | IMAPaccount::IMAPaccount() | 121 | IMAPaccount::IMAPaccount() |
122 | : Account() | 122 | : Account() |
123 | { | 123 | { |
124 | file = IMAPaccount::getUniqueFileName(); | 124 | file = IMAPaccount::getUniqueFileName(); |
125 | accountName = "New IMAP Account"; | 125 | accountName = "New IMAP Account"; |
126 | ssl = false; | 126 | ssl = false; |
127 | connectionType = 1; | 127 | connectionType = 1; |
128 | type = "IMAP"; | 128 | type = MAILLIB::A_IMAP; |
129 | port = IMAP_PORT; | 129 | port = IMAP_PORT; |
130 | } | 130 | } |
131 | 131 | ||
132 | IMAPaccount::IMAPaccount( QString filename ) | 132 | IMAPaccount::IMAPaccount( QString filename ) |
133 | : Account() | 133 | : Account() |
134 | { | 134 | { |
135 | file = filename; | 135 | file = filename; |
136 | accountName = "New IMAP Account"; | 136 | accountName = "New IMAP Account"; |
137 | ssl = false; | 137 | ssl = false; |
138 | connectionType = 1; | 138 | connectionType = 1; |
139 | type = "IMAP"; | 139 | type = MAILLIB::A_IMAP; |
140 | port = IMAP_PORT; | 140 | port = IMAP_PORT; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString IMAPaccount::getUniqueFileName() | 143 | QString IMAPaccount::getUniqueFileName() |
144 | { | 144 | { |
145 | int num = 0; | 145 | int num = 0; |
146 | QString unique; | 146 | QString unique; |
147 | 147 | ||
148 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 148 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
149 | 149 | ||
150 | QStringList imap = dir.entryList( "imap-*" ); | 150 | QStringList imap = dir.entryList( "imap-*" ); |
151 | do { | 151 | do { |
152 | unique.setNum( num++ ); | 152 | unique.setNum( num++ ); |
153 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 153 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
154 | 154 | ||
155 | return unique; | 155 | return unique; |
156 | } | 156 | } |
157 | 157 | ||
158 | void IMAPaccount::read() | 158 | void IMAPaccount::read() |
159 | { | 159 | { |
160 | Config *conf = new Config( getFileName(), Config::File ); | 160 | Config *conf = new Config( getFileName(), Config::File ); |
161 | conf->setGroup( "IMAP Account" ); | 161 | conf->setGroup( "IMAP Account" ); |
162 | accountName = conf->readEntry( "Account","" ); | 162 | accountName = conf->readEntry( "Account","" ); |
163 | if (accountName.isNull()) accountName = ""; | 163 | if (accountName.isNull()) accountName = ""; |
164 | server = conf->readEntry( "Server","" ); | 164 | server = conf->readEntry( "Server","" ); |
165 | if (server.isNull()) server=""; | 165 | if (server.isNull()) server=""; |
166 | port = conf->readEntry( "Port","" ); | 166 | port = conf->readEntry( "Port","" ); |
167 | if (port.isNull()) port="143"; | 167 | if (port.isNull()) port="143"; |
168 | connectionType = conf->readNumEntry( "ConnectionType" ); | 168 | connectionType = conf->readNumEntry( "ConnectionType" ); |
169 | ssl = conf->readBoolEntry( "SSL",false ); | 169 | ssl = conf->readBoolEntry( "SSL",false ); |
170 | user = conf->readEntry( "User","" ); | 170 | user = conf->readEntry( "User","" ); |
171 | if (user.isNull()) user = ""; | 171 | if (user.isNull()) user = ""; |
172 | password = conf->readEntryCrypt( "Password","" ); | 172 | password = conf->readEntryCrypt( "Password","" ); |
173 | if (password.isNull()) password = ""; | 173 | if (password.isNull()) password = ""; |
174 | prefix = conf->readEntry("MailPrefix",""); | 174 | prefix = conf->readEntry("MailPrefix",""); |
175 | if (prefix.isNull()) prefix = ""; | 175 | if (prefix.isNull()) prefix = ""; |
176 | offline = conf->readBoolEntry("Offline",false); | 176 | offline = conf->readBoolEntry("Offline",false); |
177 | delete conf; | 177 | delete conf; |
178 | } | 178 | } |
179 | 179 | ||
180 | void IMAPaccount::save() | 180 | void IMAPaccount::save() |
181 | { | 181 | { |
182 | qDebug( "saving " + getFileName() ); | 182 | qDebug( "saving " + getFileName() ); |
183 | Settings::checkDirectory(); | 183 | Settings::checkDirectory(); |
184 | 184 | ||
185 | Config *conf = new Config( getFileName(), Config::File ); | 185 | Config *conf = new Config( getFileName(), Config::File ); |
186 | conf->setGroup( "IMAP Account" ); | 186 | conf->setGroup( "IMAP Account" ); |
187 | conf->writeEntry( "Account", accountName ); | 187 | conf->writeEntry( "Account", accountName ); |
188 | conf->writeEntry( "Server", server ); | 188 | conf->writeEntry( "Server", server ); |
189 | conf->writeEntry( "Port", port ); | 189 | conf->writeEntry( "Port", port ); |
190 | conf->writeEntry( "SSL", ssl ); | 190 | conf->writeEntry( "SSL", ssl ); |
191 | conf->writeEntry( "ConnectionType", connectionType ); | 191 | conf->writeEntry( "ConnectionType", connectionType ); |
192 | conf->writeEntry( "User", user ); | 192 | conf->writeEntry( "User", user ); |
193 | conf->writeEntryCrypt( "Password", password ); | 193 | conf->writeEntryCrypt( "Password", password ); |
194 | conf->writeEntry( "MailPrefix",prefix); | 194 | conf->writeEntry( "MailPrefix",prefix); |
195 | conf->writeEntry( "Offline",offline); | 195 | conf->writeEntry( "Offline",offline); |
196 | conf->write(); | 196 | conf->write(); |
197 | delete conf; | 197 | delete conf; |
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | QString IMAPaccount::getFileName() | 201 | QString IMAPaccount::getFileName() |
202 | { | 202 | { |
203 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 203 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
204 | } | 204 | } |
205 | 205 | ||
206 | POP3account::POP3account() | 206 | POP3account::POP3account() |
207 | : Account() | 207 | : Account() |
208 | { | 208 | { |
209 | file = POP3account::getUniqueFileName(); | 209 | file = POP3account::getUniqueFileName(); |
210 | accountName = "New POP3 Account"; | 210 | accountName = "New POP3 Account"; |
211 | ssl = false; | 211 | ssl = false; |
212 | connectionType = 1; | 212 | connectionType = 1; |
213 | type = "POP3"; | 213 | type = MAILLIB::A_POP3; |
214 | port = POP3_PORT; | 214 | port = POP3_PORT; |
215 | } | 215 | } |
216 | 216 | ||
217 | POP3account::POP3account( QString filename ) | 217 | POP3account::POP3account( QString filename ) |
218 | : Account() | 218 | : Account() |
219 | { | 219 | { |
220 | file = filename; | 220 | file = filename; |
221 | accountName = "New POP3 Account"; | 221 | accountName = "New POP3 Account"; |
222 | ssl = false; | 222 | ssl = false; |
223 | connectionType = 1; | 223 | connectionType = 1; |
224 | type = "POP3"; | 224 | type = MAILLIB::A_POP3; |
225 | port = POP3_PORT; | 225 | port = POP3_PORT; |
226 | } | 226 | } |
227 | 227 | ||
228 | QString POP3account::getUniqueFileName() | 228 | QString POP3account::getUniqueFileName() |
229 | { | 229 | { |
230 | int num = 0; | 230 | int num = 0; |
231 | QString unique; | 231 | QString unique; |
232 | 232 | ||
233 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 233 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
234 | 234 | ||
235 | QStringList imap = dir.entryList( "pop3-*" ); | 235 | QStringList imap = dir.entryList( "pop3-*" ); |
236 | do { | 236 | do { |
237 | unique.setNum( num++ ); | 237 | unique.setNum( num++ ); |
238 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 238 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
239 | 239 | ||
240 | return unique; | 240 | return unique; |
241 | } | 241 | } |
242 | 242 | ||
243 | void POP3account::read() | 243 | void POP3account::read() |
244 | { | 244 | { |
245 | Config *conf = new Config( getFileName(), Config::File ); | 245 | Config *conf = new Config( getFileName(), Config::File ); |
246 | conf->setGroup( "POP3 Account" ); | 246 | conf->setGroup( "POP3 Account" ); |
247 | accountName = conf->readEntry( "Account" ); | 247 | accountName = conf->readEntry( "Account" ); |
248 | server = conf->readEntry( "Server" ); | 248 | server = conf->readEntry( "Server" ); |
249 | port = conf->readEntry( "Port" ); | 249 | port = conf->readEntry( "Port" ); |
250 | ssl = conf->readBoolEntry( "SSL" ); | 250 | ssl = conf->readBoolEntry( "SSL" ); |
251 | connectionType = conf->readNumEntry( "ConnectionType" ); | 251 | connectionType = conf->readNumEntry( "ConnectionType" ); |
252 | user = conf->readEntry( "User" ); | 252 | user = conf->readEntry( "User" ); |
253 | password = conf->readEntryCrypt( "Password" ); | 253 | password = conf->readEntryCrypt( "Password" ); |
254 | offline = conf->readBoolEntry("Offline",false); | 254 | offline = conf->readBoolEntry("Offline",false); |
255 | delete conf; | 255 | delete conf; |
256 | } | 256 | } |
257 | 257 | ||
258 | void POP3account::save() | 258 | void POP3account::save() |
259 | { | 259 | { |
260 | qDebug( "saving " + getFileName() ); | 260 | qDebug( "saving " + getFileName() ); |
261 | Settings::checkDirectory(); | 261 | Settings::checkDirectory(); |
262 | 262 | ||
263 | Config *conf = new Config( getFileName(), Config::File ); | 263 | Config *conf = new Config( getFileName(), Config::File ); |
264 | conf->setGroup( "POP3 Account" ); | 264 | conf->setGroup( "POP3 Account" ); |
265 | conf->writeEntry( "Account", accountName ); | 265 | conf->writeEntry( "Account", accountName ); |
266 | conf->writeEntry( "Server", server ); | 266 | conf->writeEntry( "Server", server ); |
267 | conf->writeEntry( "Port", port ); | 267 | conf->writeEntry( "Port", port ); |
268 | conf->writeEntry( "SSL", ssl ); | 268 | conf->writeEntry( "SSL", ssl ); |
269 | conf->writeEntry( "ConnectionType", connectionType ); | 269 | conf->writeEntry( "ConnectionType", connectionType ); |
270 | conf->writeEntry( "User", user ); | 270 | conf->writeEntry( "User", user ); |
271 | conf->writeEntryCrypt( "Password", password ); | 271 | conf->writeEntryCrypt( "Password", password ); |
272 | conf->writeEntry( "Offline",offline); | 272 | conf->writeEntry( "Offline",offline); |
273 | conf->write(); | 273 | conf->write(); |
274 | delete conf; | 274 | delete conf; |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | QString POP3account::getFileName() | 278 | QString POP3account::getFileName() |
279 | { | 279 | { |
280 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 280 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
281 | } | 281 | } |
282 | 282 | ||
283 | SMTPaccount::SMTPaccount() | 283 | SMTPaccount::SMTPaccount() |
284 | : Account() | 284 | : Account() |
285 | { | 285 | { |
286 | file = SMTPaccount::getUniqueFileName(); | 286 | file = SMTPaccount::getUniqueFileName(); |
287 | accountName = "New SMTP Account"; | 287 | accountName = "New SMTP Account"; |
288 | ssl = false; | 288 | ssl = false; |
289 | connectionType = 1; | 289 | connectionType = 1; |
290 | login = false; | 290 | login = false; |
291 | useCC = false; | 291 | useCC = false; |
292 | useBCC = false; | 292 | useBCC = false; |
293 | useReply = false; | 293 | useReply = false; |
294 | type = "SMTP"; | 294 | type = MAILLIB::A_SMTP; |
295 | port = SMTP_PORT; | 295 | port = SMTP_PORT; |
296 | } | 296 | } |
297 | 297 | ||
298 | SMTPaccount::SMTPaccount( QString filename ) | 298 | SMTPaccount::SMTPaccount( QString filename ) |
299 | : Account() | 299 | : Account() |
300 | { | 300 | { |
301 | file = filename; | 301 | file = filename; |
302 | accountName = "New SMTP Account"; | 302 | accountName = "New SMTP Account"; |
303 | ssl = false; | 303 | ssl = false; |
304 | connectionType = 1; | 304 | connectionType = 1; |
305 | login = false; | 305 | login = false; |
306 | type = "SMTP"; | 306 | type = MAILLIB::A_SMTP; |
307 | port = SMTP_PORT; | 307 | port = SMTP_PORT; |
308 | } | 308 | } |
309 | 309 | ||
310 | QString SMTPaccount::getUniqueFileName() | 310 | QString SMTPaccount::getUniqueFileName() |
311 | { | 311 | { |
312 | int num = 0; | 312 | int num = 0; |
313 | QString unique; | 313 | QString unique; |
314 | 314 | ||
315 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 315 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
316 | 316 | ||
317 | QStringList imap = dir.entryList( "smtp-*" ); | 317 | QStringList imap = dir.entryList( "smtp-*" ); |
318 | do { | 318 | do { |
319 | unique.setNum( num++ ); | 319 | unique.setNum( num++ ); |
320 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 320 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
321 | 321 | ||
322 | return unique; | 322 | return unique; |
323 | } | 323 | } |
324 | 324 | ||
325 | void SMTPaccount::read() | 325 | void SMTPaccount::read() |
326 | { | 326 | { |
327 | Config *conf = new Config( getFileName(), Config::File ); | 327 | Config *conf = new Config( getFileName(), Config::File ); |
328 | conf->setGroup( "SMTP Account" ); | 328 | conf->setGroup( "SMTP Account" ); |
329 | accountName = conf->readEntry( "Account" ); | 329 | accountName = conf->readEntry( "Account" ); |
330 | server = conf->readEntry( "Server" ); | 330 | server = conf->readEntry( "Server" ); |
331 | port = conf->readEntry( "Port" ); | 331 | port = conf->readEntry( "Port" ); |
332 | ssl = conf->readBoolEntry( "SSL" ); | 332 | ssl = conf->readBoolEntry( "SSL" ); |
333 | connectionType = conf->readNumEntry( "ConnectionType" ); | 333 | connectionType = conf->readNumEntry( "ConnectionType" ); |
334 | login = conf->readBoolEntry( "Login" ); | 334 | login = conf->readBoolEntry( "Login" ); |
335 | user = conf->readEntry( "User" ); | 335 | user = conf->readEntry( "User" ); |
336 | password = conf->readEntryCrypt( "Password" ); | 336 | password = conf->readEntryCrypt( "Password" ); |
337 | delete conf; | 337 | delete conf; |
338 | } | 338 | } |
339 | 339 | ||
340 | void SMTPaccount::save() | 340 | void SMTPaccount::save() |
341 | { | 341 | { |
342 | qDebug( "saving " + getFileName() ); | 342 | qDebug( "saving " + getFileName() ); |
343 | Settings::checkDirectory(); | 343 | Settings::checkDirectory(); |
344 | 344 | ||
345 | Config *conf = new Config( getFileName(), Config::File ); | 345 | Config *conf = new Config( getFileName(), Config::File ); |
346 | conf->setGroup( "SMTP Account" ); | 346 | conf->setGroup( "SMTP Account" ); |
347 | conf->writeEntry( "Account", accountName ); | 347 | conf->writeEntry( "Account", accountName ); |
348 | conf->writeEntry( "Server", server ); | 348 | conf->writeEntry( "Server", server ); |
349 | conf->writeEntry( "Port", port ); | 349 | conf->writeEntry( "Port", port ); |
350 | conf->writeEntry( "SSL", ssl ); | 350 | conf->writeEntry( "SSL", ssl ); |
351 | conf->writeEntry( "ConnectionType", connectionType ); | 351 | conf->writeEntry( "ConnectionType", connectionType ); |
352 | conf->writeEntry( "Login", login ); | 352 | conf->writeEntry( "Login", login ); |
353 | conf->writeEntry( "User", user ); | 353 | conf->writeEntry( "User", user ); |
354 | conf->writeEntryCrypt( "Password", password ); | 354 | conf->writeEntryCrypt( "Password", password ); |
355 | conf->write(); | 355 | conf->write(); |
356 | delete conf; | 356 | delete conf; |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | QString SMTPaccount::getFileName() | 360 | QString SMTPaccount::getFileName() |
361 | { | 361 | { |
362 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; | 362 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; |
363 | } | 363 | } |
364 | 364 | ||
365 | NNTPaccount::NNTPaccount() | 365 | NNTPaccount::NNTPaccount() |
366 | : Account() | 366 | : Account() |
367 | { | 367 | { |
368 | file = NNTPaccount::getUniqueFileName(); | 368 | file = NNTPaccount::getUniqueFileName(); |
369 | accountName = "New NNTP Account"; | 369 | accountName = "New NNTP Account"; |
370 | ssl = false; | 370 | ssl = false; |
371 | login = false; | 371 | login = false; |
372 | type = "NNTP"; | 372 | type = MAILLIB::A_NNTP; |
373 | port = NNTP_PORT; | 373 | port = NNTP_PORT; |
374 | } | 374 | } |
375 | 375 | ||
376 | NNTPaccount::NNTPaccount( QString filename ) | 376 | NNTPaccount::NNTPaccount( QString filename ) |
377 | : Account() | 377 | : Account() |
378 | { | 378 | { |
379 | file = filename; | 379 | file = filename; |
380 | accountName = "New NNTP Account"; | 380 | accountName = "New NNTP Account"; |
381 | ssl = false; | 381 | ssl = false; |
382 | login = false; | 382 | login = false; |
383 | type = "NNTP"; | 383 | type = MAILLIB::A_NNTP; |
384 | port = NNTP_PORT; | 384 | port = NNTP_PORT; |
385 | } | 385 | } |
386 | 386 | ||
387 | QString NNTPaccount::getUniqueFileName() | 387 | QString NNTPaccount::getUniqueFileName() |
388 | { | 388 | { |
389 | int num = 0; | 389 | int num = 0; |
390 | QString unique; | 390 | QString unique; |
391 | 391 | ||
392 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 392 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
393 | 393 | ||
394 | QStringList imap = dir.entryList( "nntp-*" ); | 394 | QStringList imap = dir.entryList( "nntp-*" ); |
395 | do { | 395 | do { |
396 | unique.setNum( num++ ); | 396 | unique.setNum( num++ ); |
397 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 397 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
398 | 398 | ||
399 | return unique; | 399 | return unique; |
400 | } | 400 | } |
401 | 401 | ||
402 | void NNTPaccount::read() | 402 | void NNTPaccount::read() |
403 | { | 403 | { |
404 | Config *conf = new Config( getFileName(), Config::File ); | 404 | Config *conf = new Config( getFileName(), Config::File ); |
405 | conf->setGroup( "NNTP Account" ); | 405 | conf->setGroup( "NNTP Account" ); |
406 | accountName = conf->readEntry( "Account" ); | 406 | accountName = conf->readEntry( "Account" ); |
407 | server = conf->readEntry( "Server" ); | 407 | server = conf->readEntry( "Server" ); |
408 | port = conf->readEntry( "Port" ); | 408 | port = conf->readEntry( "Port" ); |
409 | ssl = conf->readBoolEntry( "SSL" ); | 409 | ssl = conf->readBoolEntry( "SSL" ); |
410 | login = conf->readBoolEntry( "Login" ); | 410 | login = conf->readBoolEntry( "Login" ); |
411 | user = conf->readEntry( "User" ); | 411 | user = conf->readEntry( "User" ); |
412 | password = conf->readEntryCrypt( "Password" ); | 412 | password = conf->readEntryCrypt( "Password" ); |
413 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); | 413 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); |
414 | delete conf; | 414 | delete conf; |
415 | } | 415 | } |
416 | 416 | ||
417 | void NNTPaccount::save() | 417 | void NNTPaccount::save() |
418 | { | 418 | { |
419 | qDebug( "saving " + getFileName() ); | 419 | qDebug( "saving " + getFileName() ); |
420 | Settings::checkDirectory(); | 420 | Settings::checkDirectory(); |
421 | 421 | ||
422 | Config *conf = new Config( getFileName(), Config::File ); | 422 | Config *conf = new Config( getFileName(), Config::File ); |
423 | conf->setGroup( "NNTP Account" ); | 423 | conf->setGroup( "NNTP Account" ); |
424 | conf->writeEntry( "Account", accountName ); | 424 | conf->writeEntry( "Account", accountName ); |
425 | conf->writeEntry( "Server", server ); | 425 | conf->writeEntry( "Server", server ); |
426 | conf->writeEntry( "Port", port ); | 426 | conf->writeEntry( "Port", port ); |
427 | conf->writeEntry( "SSL", ssl ); | 427 | conf->writeEntry( "SSL", ssl ); |
428 | conf->writeEntry( "Login", login ); | 428 | conf->writeEntry( "Login", login ); |
429 | conf->writeEntry( "User", user ); | 429 | conf->writeEntry( "User", user ); |
430 | conf->writeEntryCrypt( "Password", password ); | 430 | conf->writeEntryCrypt( "Password", password ); |
431 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); | 431 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); |
432 | conf->write(); | 432 | conf->write(); |
433 | delete conf; | 433 | delete conf; |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | QString NNTPaccount::getFileName() | 437 | QString NNTPaccount::getFileName() |
438 | { | 438 | { |
439 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; | 439 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; |
440 | } | 440 | } |
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index 1feedbf..27e2823 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h | |||
@@ -1,158 +1,161 @@ | |||
1 | #ifndef SETTINGS_H | 1 | #ifndef SETTINGS_H |
2 | #define SETTINGS_H | 2 | #define SETTINGS_H |
3 | 3 | ||
4 | #include "maildefines.h" | ||
5 | |||
4 | #include <qobject.h> | 6 | #include <qobject.h> |
5 | #include <qlist.h> | 7 | #include <qlist.h> |
6 | 8 | ||
7 | class Account | 9 | class Account |
8 | { | 10 | { |
9 | 11 | ||
10 | public: | 12 | public: |
11 | Account(); | 13 | Account(); |
12 | virtual ~Account() {} | 14 | virtual ~Account() {} |
13 | 15 | ||
14 | void remove(); | 16 | void remove(); |
15 | void setAccountName( QString name ) { accountName = name; } | 17 | void setAccountName( QString name ) { accountName = name; } |
16 | const QString&getAccountName()const{ return accountName; } | 18 | const QString&getAccountName()const{ return accountName; } |
17 | const QString&getType()const{ return type; } | 19 | MAILLIB::ATYPE getType()const{ return type; } |
18 | 20 | ||
19 | void setServer(const QString&str){ server = str; } | 21 | void setServer(const QString&str){ server = str; } |
20 | const QString&getServer()const{ return server; } | 22 | const QString&getServer()const{ return server; } |
21 | 23 | ||
22 | void setPort(const QString&str) { port = str; } | 24 | void setPort(const QString&str) { port = str; } |
23 | const QString&getPort()const{ return port; } | 25 | const QString&getPort()const{ return port; } |
24 | 26 | ||
25 | void setUser(const QString&str){ user = str; } | 27 | void setUser(const QString&str){ user = str; } |
26 | const QString&getUser()const{ return user; } | 28 | const QString&getUser()const{ return user; } |
27 | 29 | ||
28 | void setPassword(const QString&str) { password = str; } | 30 | void setPassword(const QString&str) { password = str; } |
29 | const QString&getPassword()const { return password; } | 31 | const QString&getPassword()const { return password; } |
30 | 32 | ||
31 | void setSSL( bool b ) { ssl = b; } | 33 | void setSSL( bool b ) { ssl = b; } |
32 | bool getSSL() { return ssl; } | 34 | bool getSSL() { return ssl; } |
33 | 35 | ||
34 | void setConnectionType( int x ) { connectionType = x; } | 36 | void setConnectionType( int x ) { connectionType = x; } |
35 | int ConnectionType() { return connectionType; } | 37 | int ConnectionType() { return connectionType; } |
36 | 38 | ||
37 | 39 | ||
38 | void setOffline(bool b) {offline = b;} | 40 | void setOffline(bool b) {offline = b;} |
39 | bool getOffline()const{return offline;} | 41 | bool getOffline()const{return offline;} |
40 | 42 | ||
41 | virtual QString getFileName() { return accountName; } | 43 | virtual QString getFileName() { return accountName; } |
42 | virtual void read() { qDebug( "base reading..." ); } | 44 | virtual void read() { qDebug( "base reading..." ); } |
43 | virtual void save() { qDebug( "base saving..." ); } | 45 | virtual void save() { qDebug( "base saving..." ); } |
44 | 46 | ||
45 | protected: | 47 | protected: |
46 | QString accountName, type, server, port, user, password; | 48 | QString accountName, server, port, user, password; |
47 | bool ssl; | 49 | bool ssl; |
48 | int connectionType; | 50 | int connectionType; |
49 | bool offline; | 51 | bool offline; |
52 | MAILLIB::ATYPE type; | ||
50 | }; | 53 | }; |
51 | 54 | ||
52 | class IMAPaccount : public Account | 55 | class IMAPaccount : public Account |
53 | { | 56 | { |
54 | 57 | ||
55 | public: | 58 | public: |
56 | IMAPaccount(); | 59 | IMAPaccount(); |
57 | IMAPaccount( QString filename ); | 60 | IMAPaccount( QString filename ); |
58 | 61 | ||
59 | static QString getUniqueFileName(); | 62 | static QString getUniqueFileName(); |
60 | 63 | ||
61 | virtual void read(); | 64 | virtual void read(); |
62 | virtual void save(); | 65 | virtual void save(); |
63 | virtual QString getFileName(); | 66 | virtual QString getFileName(); |
64 | 67 | ||
65 | void setPrefix(const QString&str) {prefix=str;} | 68 | void setPrefix(const QString&str) {prefix=str;} |
66 | const QString&getPrefix()const{return prefix;} | 69 | const QString&getPrefix()const{return prefix;} |
67 | 70 | ||
68 | private: | 71 | private: |
69 | QString file,prefix; | 72 | QString file,prefix; |
70 | 73 | ||
71 | }; | 74 | }; |
72 | 75 | ||
73 | class POP3account : public Account | 76 | class POP3account : public Account |
74 | { | 77 | { |
75 | 78 | ||
76 | public: | 79 | public: |
77 | POP3account(); | 80 | POP3account(); |
78 | POP3account( QString filename ); | 81 | POP3account( QString filename ); |
79 | 82 | ||
80 | static QString getUniqueFileName(); | 83 | static QString getUniqueFileName(); |
81 | 84 | ||
82 | virtual void read(); | 85 | virtual void read(); |
83 | virtual void save(); | 86 | virtual void save(); |
84 | virtual QString getFileName(); | 87 | virtual QString getFileName(); |
85 | 88 | ||
86 | private: | 89 | private: |
87 | QString file; | 90 | QString file; |
88 | 91 | ||
89 | }; | 92 | }; |
90 | 93 | ||
91 | class SMTPaccount : public Account | 94 | class SMTPaccount : public Account |
92 | { | 95 | { |
93 | 96 | ||
94 | public: | 97 | public: |
95 | SMTPaccount(); | 98 | SMTPaccount(); |
96 | SMTPaccount( QString filename ); | 99 | SMTPaccount( QString filename ); |
97 | 100 | ||
98 | static QString getUniqueFileName(); | 101 | static QString getUniqueFileName(); |
99 | 102 | ||
100 | virtual void read(); | 103 | virtual void read(); |
101 | virtual void save(); | 104 | virtual void save(); |
102 | virtual QString getFileName(); | 105 | virtual QString getFileName(); |
103 | 106 | ||
104 | void setLogin( bool b ) { login = b; } | 107 | void setLogin( bool b ) { login = b; } |
105 | bool getLogin() { return login; } | 108 | bool getLogin() { return login; } |
106 | 109 | ||
107 | private: | 110 | private: |
108 | QString file, name, mail, org, cc, bcc, reply, signature; | 111 | QString file, name, mail, org, cc, bcc, reply, signature; |
109 | bool useCC, useBCC, useReply, login; | 112 | bool useCC, useBCC, useReply, login; |
110 | 113 | ||
111 | }; | 114 | }; |
112 | 115 | ||
113 | class NNTPaccount : public Account | 116 | class NNTPaccount : public Account |
114 | { | 117 | { |
115 | 118 | ||
116 | public: | 119 | public: |
117 | NNTPaccount(); | 120 | NNTPaccount(); |
118 | NNTPaccount( QString filename ); | 121 | NNTPaccount( QString filename ); |
119 | 122 | ||
120 | static QString getUniqueFileName(); | 123 | static QString getUniqueFileName(); |
121 | 124 | ||
122 | virtual void read(); | 125 | virtual void read(); |
123 | virtual void save(); | 126 | virtual void save(); |
124 | virtual QString getFileName(); | 127 | virtual QString getFileName(); |
125 | 128 | ||
126 | void setLogin( bool b ) { login = b; } | 129 | void setLogin( bool b ) { login = b; } |
127 | bool getLogin() { return login; } | 130 | bool getLogin() { return login; } |
128 | 131 | ||
129 | void setGroups( QStringList list ) { subscribedGroups = list; } | 132 | void setGroups( QStringList list ) { subscribedGroups = list; } |
130 | QStringList getGroups() { return subscribedGroups; } | 133 | QStringList getGroups() { return subscribedGroups; } |
131 | 134 | ||
132 | private: | 135 | private: |
133 | QString file; | 136 | QString file; |
134 | bool login; | 137 | bool login; |
135 | QStringList subscribedGroups; | 138 | QStringList subscribedGroups; |
136 | 139 | ||
137 | }; | 140 | }; |
138 | 141 | ||
139 | class Settings : public QObject | 142 | class Settings : public QObject |
140 | { | 143 | { |
141 | Q_OBJECT | 144 | Q_OBJECT |
142 | 145 | ||
143 | public: | 146 | public: |
144 | Settings(); | 147 | Settings(); |
145 | QList<Account> getAccounts(); | 148 | QList<Account> getAccounts(); |
146 | void addAccount(Account *account); | 149 | void addAccount(Account *account); |
147 | void delAccount(Account *account); | 150 | void delAccount(Account *account); |
148 | void saveAccounts(); | 151 | void saveAccounts(); |
149 | void readAccounts(); | 152 | void readAccounts(); |
150 | static void checkDirectory(); | 153 | static void checkDirectory(); |
151 | 154 | ||
152 | private: | 155 | private: |
153 | void updateAccounts(); | 156 | void updateAccounts(); |
154 | QList<Account> accounts; | 157 | QList<Account> accounts; |
155 | 158 | ||
156 | }; | 159 | }; |
157 | 160 | ||
158 | #endif | 161 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 4134e79..b78244d 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp | |||
@@ -1,90 +1,90 @@ | |||
1 | #include "statusmail.h" | 1 | #include "statusmail.h" |
2 | 2 | ||
3 | StatusMail::StatusMail(QList<Account>&list) | 3 | StatusMail::StatusMail(QList<Account>&list) |
4 | { | 4 | { |
5 | currentImapStat.message_count=0; | 5 | currentImapStat.message_count=0; |
6 | currentImapStat.message_unseen=0; | 6 | currentImapStat.message_unseen=0; |
7 | currentImapStat.message_recent=0; | 7 | currentImapStat.message_recent=0; |
8 | lastPop3Stat = currentImapStat; | 8 | lastPop3Stat = currentImapStat; |
9 | currentPop3Stat = currentImapStat; | 9 | currentPop3Stat = currentImapStat; |
10 | connectionList.setAutoDelete(true); | 10 | connectionList.setAutoDelete(true); |
11 | connectionList.clear(); | 11 | connectionList.clear(); |
12 | initAccounts(list); | 12 | initAccounts(list); |
13 | } | 13 | } |
14 | 14 | ||
15 | StatusMail::~StatusMail() | 15 | StatusMail::~StatusMail() |
16 | { | 16 | { |
17 | } | 17 | } |
18 | 18 | ||
19 | void StatusMail::initAccounts(QList<Account>&accounts) | 19 | void StatusMail::initAccounts(QList<Account>&accounts) |
20 | { | 20 | { |
21 | 21 | ||
22 | Account *it; | 22 | Account *it; |
23 | folderStat currentStat; | 23 | folderStat currentStat; |
24 | AbstractMail * current = 0; | 24 | AbstractMail * current = 0; |
25 | currentPop3Stat.message_count=0; | 25 | currentPop3Stat.message_count=0; |
26 | currentPop3Stat.message_recent=0; | 26 | currentPop3Stat.message_recent=0; |
27 | currentPop3Stat.message_unseen=0; | 27 | currentPop3Stat.message_unseen=0; |
28 | for ( it = accounts.first(); it; it = accounts.next() ) { | 28 | for ( it = accounts.first(); it; it = accounts.next() ) { |
29 | if ( it->getType().compare( "IMAP" ) == 0 && !it->getOffline() ) { | 29 | if ( it->getType()==MAILLIB::A_IMAP && !it->getOffline() ) { |
30 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); | 30 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); |
31 | current = AbstractMail::getWrapper(ima); | 31 | current = AbstractMail::getWrapper(ima); |
32 | connectionList.append(current); | 32 | connectionList.append(current); |
33 | current->statusFolder(currentStat); | 33 | current->statusFolder(currentStat); |
34 | currentImapStat.message_count+=currentStat.message_unseen; | 34 | currentImapStat.message_count+=currentStat.message_unseen; |
35 | currentImapStat.message_count+=currentStat.message_recent; | 35 | currentImapStat.message_count+=currentStat.message_recent; |
36 | currentImapStat.message_count+=currentStat.message_count; | 36 | currentImapStat.message_count+=currentStat.message_count; |
37 | } else if ( it->getType().compare( "POP3" ) == 0 && !it->getOffline() ) { | 37 | } else if ( it->getType() == MAILLIB::A_POP3 && !it->getOffline() ) { |
38 | POP3account *pop3 = static_cast<POP3account *>(it); | 38 | POP3account *pop3 = static_cast<POP3account *>(it); |
39 | current = AbstractMail::getWrapper(pop3); | 39 | current = AbstractMail::getWrapper(pop3); |
40 | connectionList.append(current); | 40 | connectionList.append(current); |
41 | current->statusFolder(currentStat); | 41 | current->statusFolder(currentStat); |
42 | currentPop3Stat.message_count+=currentStat.message_count; | 42 | currentPop3Stat.message_count+=currentStat.message_count; |
43 | } | 43 | } |
44 | current->logout(); | 44 | current->logout(); |
45 | } | 45 | } |
46 | qDebug("Pop3 init count: %i",currentPop3Stat.message_count); | 46 | qDebug("Pop3 init count: %i",currentPop3Stat.message_count); |
47 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | 47 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; |
48 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; | 48 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; |
49 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; | 49 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; |
50 | lastPop3Stat.message_count = currentPop3Stat.message_count; | 50 | lastPop3Stat.message_count = currentPop3Stat.message_count; |
51 | } | 51 | } |
52 | 52 | ||
53 | void StatusMail::reset_status() | 53 | void StatusMail::reset_status() |
54 | { | 54 | { |
55 | lastPop3Stat = currentPop3Stat; | 55 | lastPop3Stat = currentPop3Stat; |
56 | } | 56 | } |
57 | 57 | ||
58 | void StatusMail::check_current_stat(folderStat&targetStat) | 58 | void StatusMail::check_current_stat(folderStat&targetStat) |
59 | { | 59 | { |
60 | AbstractMail*it = 0; | 60 | AbstractMail*it = 0; |
61 | folderStat currentStat; | 61 | folderStat currentStat; |
62 | currentPop3Stat.message_recent = 0; | 62 | currentPop3Stat.message_recent = 0; |
63 | currentPop3Stat.message_count = 0; | 63 | currentPop3Stat.message_count = 0; |
64 | currentPop3Stat.message_unseen = 0; | 64 | currentPop3Stat.message_unseen = 0; |
65 | currentImapStat = currentPop3Stat; | 65 | currentImapStat = currentPop3Stat; |
66 | for ( it = connectionList.first(); it; it = connectionList.next() ) { | 66 | for ( it = connectionList.first(); it; it = connectionList.next() ) { |
67 | it->statusFolder(currentStat); | 67 | it->statusFolder(currentStat); |
68 | it->logout(); | 68 | it->logout(); |
69 | if (it->getType().lower()=="imap") { | 69 | if (it->getType() == MAILLIB::A_IMAP) { |
70 | currentImapStat.message_unseen+=currentStat.message_unseen; | 70 | currentImapStat.message_unseen+=currentStat.message_unseen; |
71 | currentImapStat.message_recent+=currentStat.message_recent; | 71 | currentImapStat.message_recent+=currentStat.message_recent; |
72 | currentImapStat.message_count+=currentStat.message_count; | 72 | currentImapStat.message_count+=currentStat.message_count; |
73 | } else if (it->getType().lower()=="pop3") { | 73 | } else if (it->getType() == MAILLIB::A_POP3) { |
74 | currentPop3Stat.message_count+=currentStat.message_count; | 74 | currentPop3Stat.message_count+=currentStat.message_count; |
75 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); | 75 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); | 78 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); |
79 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { | 79 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { |
80 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; | 80 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; |
81 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; | 81 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; |
82 | } else { | 82 | } else { |
83 | lastPop3Stat.message_count = currentPop3Stat.message_count; | 83 | lastPop3Stat.message_count = currentPop3Stat.message_count; |
84 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | 84 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; |
85 | } | 85 | } |
86 | targetStat = currentImapStat; | 86 | targetStat = currentImapStat; |
87 | targetStat.message_unseen+=currentPop3Stat.message_unseen; | 87 | targetStat.message_unseen+=currentPop3Stat.message_unseen; |
88 | targetStat.message_recent+=currentPop3Stat.message_recent; | 88 | targetStat.message_recent+=currentPop3Stat.message_recent; |
89 | targetStat.message_count+=currentPop3Stat.message_count; | 89 | targetStat.message_count+=currentPop3Stat.message_count; |
90 | } | 90 | } |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 6bfc824..d8b58b6 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -1,254 +1,254 @@ | |||
1 | 1 | ||
2 | #include "settingsdialog.h" | 2 | #include "settingsdialog.h" |
3 | #include "opiemail.h" | 3 | #include "opiemail.h" |
4 | #include "editaccounts.h" | 4 | #include "editaccounts.h" |
5 | #include "composemail.h" | 5 | #include "composemail.h" |
6 | #include "mailistviewitem.h" | 6 | #include "mailistviewitem.h" |
7 | #include "viewmail.h" | 7 | #include "viewmail.h" |
8 | #include "selectstore.h" | 8 | #include "selectstore.h" |
9 | #include "selectsmtp.h" | 9 | #include "selectsmtp.h" |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <libmailwrapper/smtpwrapper.h> | 12 | #include <libmailwrapper/smtpwrapper.h> |
13 | #include <libmailwrapper/mailtypes.h> | 13 | #include <libmailwrapper/mailtypes.h> |
14 | #include <libmailwrapper/abstractmail.h> | 14 | #include <libmailwrapper/abstractmail.h> |
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | 17 | ||
18 | /* QT */ | 18 | /* QT */ |
19 | 19 | ||
20 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 20 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) |
21 | : MainWindow( parent, name, WStyle_ContextHelp ) | 21 | : MainWindow( parent, name, WStyle_ContextHelp ) |
22 | { | 22 | { |
23 | settings = new Settings(); | 23 | settings = new Settings(); |
24 | 24 | ||
25 | folderView->populate( settings->getAccounts() ); | 25 | folderView->populate( settings->getAccounts() ); |
26 | } | 26 | } |
27 | 27 | ||
28 | OpieMail::~OpieMail() | 28 | OpieMail::~OpieMail() |
29 | { | 29 | { |
30 | if (settings) delete settings; | 30 | if (settings) delete settings; |
31 | } | 31 | } |
32 | 32 | ||
33 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 33 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
34 | { | 34 | { |
35 | // copied from old mail2 | 35 | // copied from old mail2 |
36 | if (msg == "writeMail(QString,QString)") | 36 | if (msg == "writeMail(QString,QString)") |
37 | { | 37 | { |
38 | QDataStream stream(data,IO_ReadOnly); | 38 | QDataStream stream(data,IO_ReadOnly); |
39 | QString name, email; | 39 | QString name, email; |
40 | stream >> name >> email; | 40 | stream >> name >> email; |
41 | // removing the whitespaces at beginning and end is needed! | 41 | // removing the whitespaces at beginning and end is needed! |
42 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 42 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
43 | } | 43 | } |
44 | else if (msg == "newMail()") | 44 | else if (msg == "newMail()") |
45 | { | 45 | { |
46 | slotComposeMail(); | 46 | slotComposeMail(); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 50 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
51 | { | 51 | { |
52 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 52 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
53 | if (!email.isEmpty()) | 53 | if (!email.isEmpty()) |
54 | { | 54 | { |
55 | if (!name.isEmpty()) | 55 | if (!name.isEmpty()) |
56 | { | 56 | { |
57 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 57 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
58 | } | 58 | } |
59 | else | 59 | else |
60 | { | 60 | { |
61 | compose.setTo(email); | 61 | compose.setTo(email); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | compose.slotAdjustColumns(); | 64 | compose.slotAdjustColumns(); |
65 | QPEApplication::execDialog( &compose ); | 65 | QPEApplication::execDialog( &compose ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void OpieMail::slotComposeMail() | 68 | void OpieMail::slotComposeMail() |
69 | { | 69 | { |
70 | qDebug( "Compose Mail" ); | 70 | qDebug( "Compose Mail" ); |
71 | slotwriteMail(0l,0l); | 71 | slotwriteMail(0l,0l); |
72 | } | 72 | } |
73 | 73 | ||
74 | void OpieMail::slotSendQueued() | 74 | void OpieMail::slotSendQueued() |
75 | { | 75 | { |
76 | qDebug( "Send Queued" ); | 76 | qDebug( "Send Queued" ); |
77 | SMTPaccount *smtp = 0; | 77 | SMTPaccount *smtp = 0; |
78 | 78 | ||
79 | QList<Account> list = settings->getAccounts(); | 79 | QList<Account> list = settings->getAccounts(); |
80 | QList<SMTPaccount> smtpList; | 80 | QList<SMTPaccount> smtpList; |
81 | smtpList.setAutoDelete(false); | 81 | smtpList.setAutoDelete(false); |
82 | Account *it; | 82 | Account *it; |
83 | for ( it = list.first(); it; it = list.next() ) | 83 | for ( it = list.first(); it; it = list.next() ) |
84 | { | 84 | { |
85 | if ( it->getType().compare( "SMTP" ) == 0 ) | 85 | if ( it->getType() == MAILLIB::A_SMTP ) |
86 | { | 86 | { |
87 | smtp = static_cast<SMTPaccount *>(it); | 87 | smtp = static_cast<SMTPaccount *>(it); |
88 | smtpList.append(smtp); | 88 | smtpList.append(smtp); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | if (smtpList.count()==0) | 91 | if (smtpList.count()==0) |
92 | { | 92 | { |
93 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 93 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | if (smtpList.count()==1) | 96 | if (smtpList.count()==1) |
97 | { | 97 | { |
98 | smtp = smtpList.at(0); | 98 | smtp = smtpList.at(0); |
99 | } | 99 | } |
100 | else | 100 | else |
101 | { | 101 | { |
102 | smtp = 0; | 102 | smtp = 0; |
103 | selectsmtp selsmtp; | 103 | selectsmtp selsmtp; |
104 | selsmtp.setSelectionlist(&smtpList); | 104 | selsmtp.setSelectionlist(&smtpList); |
105 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 105 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
106 | { | 106 | { |
107 | smtp = selsmtp.selected_smtp(); | 107 | smtp = selsmtp.selected_smtp(); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | if (smtp) | 110 | if (smtp) |
111 | { | 111 | { |
112 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 112 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
113 | if ( wrap->flushOutbox() ) | 113 | if ( wrap->flushOutbox() ) |
114 | { | 114 | { |
115 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 115 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
116 | } | 116 | } |
117 | delete wrap; | 117 | delete wrap; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void OpieMail::slotSearchMails() | 121 | void OpieMail::slotSearchMails() |
122 | { | 122 | { |
123 | qDebug( "Search Mails" ); | 123 | qDebug( "Search Mails" ); |
124 | } | 124 | } |
125 | 125 | ||
126 | void OpieMail::slotEditSettings() | 126 | void OpieMail::slotEditSettings() |
127 | { | 127 | { |
128 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 128 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
129 | QPEApplication::execDialog( &settingsDialog ); | 129 | QPEApplication::execDialog( &settingsDialog ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void OpieMail::slotEditAccounts() | 132 | void OpieMail::slotEditAccounts() |
133 | { | 133 | { |
134 | qDebug( "Edit Accounts" ); | 134 | qDebug( "Edit Accounts" ); |
135 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 135 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
136 | eaDialog.slotAdjustColumns(); | 136 | eaDialog.slotAdjustColumns(); |
137 | QPEApplication::execDialog( &eaDialog ); | 137 | QPEApplication::execDialog( &eaDialog ); |
138 | if ( settings ) delete settings; | 138 | if ( settings ) delete settings; |
139 | settings = new Settings(); | 139 | settings = new Settings(); |
140 | 140 | ||
141 | folderView->populate( settings->getAccounts() ); | 141 | folderView->populate( settings->getAccounts() ); |
142 | } | 142 | } |
143 | 143 | ||
144 | void OpieMail::displayMail() | 144 | void OpieMail::displayMail() |
145 | { | 145 | { |
146 | QListViewItem*item = mailView->currentItem(); | 146 | QListViewItem*item = mailView->currentItem(); |
147 | if (!item) return; | 147 | if (!item) return; |
148 | RecMail mail = ((MailListViewItem*)item)->data(); | 148 | RecMail mail = ((MailListViewItem*)item)->data(); |
149 | RecBody body = folderView->fetchBody(mail); | 149 | RecBody body = folderView->fetchBody(mail); |
150 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 150 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
151 | readMail.setBody( body ); | 151 | readMail.setBody( body ); |
152 | readMail.setMail( mail ); | 152 | readMail.setMail( mail ); |
153 | readMail.showMaximized(); | 153 | readMail.showMaximized(); |
154 | readMail.exec(); | 154 | readMail.exec(); |
155 | 155 | ||
156 | if ( readMail.deleted ) | 156 | if ( readMail.deleted ) |
157 | { | 157 | { |
158 | folderView->refreshCurrent(); | 158 | folderView->refreshCurrent(); |
159 | } | 159 | } |
160 | else | 160 | else |
161 | { | 161 | { |
162 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 162 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | void OpieMail::slotDeleteMail() | 166 | void OpieMail::slotDeleteMail() |
167 | { | 167 | { |
168 | if (!mailView->currentItem()) return; | 168 | if (!mailView->currentItem()) return; |
169 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 169 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
170 | 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 ) | 170 | 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 ) |
171 | { | 171 | { |
172 | mail.Wrapper()->deleteMail( mail ); | 172 | mail.Wrapper()->deleteMail( mail ); |
173 | folderView->refreshCurrent(); | 173 | folderView->refreshCurrent(); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 177 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
178 | { | 178 | { |
179 | /* just the RIGHT button - or hold on pda */ | 179 | /* just the RIGHT button - or hold on pda */ |
180 | if (button!=2) {return;} | 180 | if (button!=2) {return;} |
181 | qDebug("Event right/hold"); | 181 | qDebug("Event right/hold"); |
182 | if (!item) return; | 182 | if (!item) return; |
183 | QPopupMenu *m = new QPopupMenu(0); | 183 | QPopupMenu *m = new QPopupMenu(0); |
184 | if (m) | 184 | if (m) |
185 | { | 185 | { |
186 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 186 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
187 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 187 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
188 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 188 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); |
189 | m->setFocus(); | 189 | m->setFocus(); |
190 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 190 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
191 | delete m; | 191 | delete m; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | void OpieMail::slotShowFolders( bool show ) | 195 | void OpieMail::slotShowFolders( bool show ) |
196 | { | 196 | { |
197 | qDebug( "Show Folders" ); | 197 | qDebug( "Show Folders" ); |
198 | if ( show && folderView->isHidden() ) | 198 | if ( show && folderView->isHidden() ) |
199 | { | 199 | { |
200 | qDebug( "-> showing" ); | 200 | qDebug( "-> showing" ); |
201 | folderView->show(); | 201 | folderView->show(); |
202 | } | 202 | } |
203 | else if ( !show && !folderView->isHidden() ) | 203 | else if ( !show && !folderView->isHidden() ) |
204 | { | 204 | { |
205 | qDebug( "-> hiding" ); | 205 | qDebug( "-> hiding" ); |
206 | folderView->hide(); | 206 | folderView->hide(); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void OpieMail::refreshMailView(QList<RecMail>*list) | 210 | void OpieMail::refreshMailView(QList<RecMail>*list) |
211 | { | 211 | { |
212 | MailListViewItem*item = 0; | 212 | MailListViewItem*item = 0; |
213 | mailView->clear(); | 213 | mailView->clear(); |
214 | for (unsigned int i = 0; i < list->count();++i) | 214 | for (unsigned int i = 0; i < list->count();++i) |
215 | { | 215 | { |
216 | item = new MailListViewItem(mailView,item); | 216 | item = new MailListViewItem(mailView,item); |
217 | item->storeData(*(list->at(i))); | 217 | item->storeData(*(list->at(i))); |
218 | item->showEntry(); | 218 | item->showEntry(); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 222 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
223 | { | 223 | { |
224 | /* just LEFT button - or tap with stylus on pda */ | 224 | /* just LEFT button - or tap with stylus on pda */ |
225 | if (button!=1) return; | 225 | if (button!=1) return; |
226 | if (!item) return; | 226 | if (!item) return; |
227 | displayMail(); | 227 | displayMail(); |
228 | } | 228 | } |
229 | 229 | ||
230 | void OpieMail::slotMoveCopyMail() | 230 | void OpieMail::slotMoveCopyMail() |
231 | { | 231 | { |
232 | if (!mailView->currentItem()) return; | 232 | if (!mailView->currentItem()) return; |
233 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 233 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
234 | AbstractMail*targetMail = 0; | 234 | AbstractMail*targetMail = 0; |
235 | QString targetFolder = ""; | 235 | QString targetFolder = ""; |
236 | Selectstore sels; | 236 | Selectstore sels; |
237 | folderView->setupFolderselect(&sels); | 237 | folderView->setupFolderselect(&sels); |
238 | if (!sels.exec()) return; | 238 | if (!sels.exec()) return; |
239 | targetMail = sels.currentMail(); | 239 | targetMail = sels.currentMail(); |
240 | targetFolder = sels.currentFolder(); | 240 | targetFolder = sels.currentFolder(); |
241 | if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || | 241 | if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || |
242 | targetFolder.isEmpty()) | 242 | targetFolder.isEmpty()) |
243 | { | 243 | { |
244 | return; | 244 | return; |
245 | } | 245 | } |
246 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 246 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
247 | { | 247 | { |
248 | QMessageBox::critical(0,tr("Error creating new Folder"), | 248 | QMessageBox::critical(0,tr("Error creating new Folder"), |
249 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 249 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 252 | mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
253 | folderView->refreshCurrent(); | 253 | folderView->refreshCurrent(); |
254 | } | 254 | } |