author | alwin <alwin> | 2004-03-08 01:00:18 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-08 01:00:18 (UTC) |
commit | eddc5184f5be6a067b077d18e240a1fe982bbcf4 (patch) (unidiff) | |
tree | 0d9458a10520ca23e1d5d041d9d2ca4150bd8f1c | |
parent | eedafdf1a1d973c083cb108a913005d14a78a9ae (diff) | |
download | opie-eddc5184f5be6a067b077d18e240a1fe982bbcf4.zip opie-eddc5184f5be6a067b077d18e240a1fe982bbcf4.tar.gz opie-eddc5184f5be6a067b077d18e240a1fe982bbcf4.tar.bz2 |
type of mail account will be defined by a enum not with string - comparing
strings all the time makes no sense.
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,142 +1,142 @@ | |||
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()); |
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,113 +1,113 @@ | |||
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() |
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,237 +1,255 @@ | |||
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" ) ); |
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 | |||
@@ -383,130 +383,134 @@ QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | |||
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 | |||
@@ -1029,129 +1029,129 @@ int IMAPwrapper::deleteMbox(const Folder*folder) | |||
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 | } |
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,73 +1,73 @@ | |||
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); |
@@ -265,73 +265,73 @@ int MBOXwrapper::deleteAllMail(const Folder*tfolder) | |||
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,75 +1,75 @@ | |||
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; |
@@ -305,129 +305,129 @@ int MHwrapper::deleteMbox(const Folder*tfolder) | |||
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; |
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 | |||
@@ -42,129 +42,129 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | |||
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 ); |
@@ -208,77 +208,77 @@ QList<Folder>* NNTPwrapper::listFolders() { | |||
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 | |||
@@ -185,71 +185,71 @@ QList<Folder>* POP3wrapper::listFolders() { | |||
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 | |||
@@ -45,396 +45,396 @@ void Settings::delAccount( Account *account ) | |||
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,113 +1,116 @@ | |||
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 |
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 | |||
@@ -21,129 +21,129 @@ 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); |