-rw-r--r-- | noncore/net/mail/accountview.cpp | 31 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 86 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 60 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/pop3configui.ui | 68 |
10 files changed, 238 insertions, 125 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 662e555..0fe8475 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -2,177 +2,172 @@ | |||
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 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <opie2/odebug.h> | 12 | #include <opie2/odebug.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qpopupmenu.h> | 17 | #include <qpopupmenu.h> |
18 | 18 | ||
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
21 | : QListView( parent, name, flags ) | 21 | : QListView( parent, name, flags ) |
22 | { | 22 | { |
23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
24 | SLOT( refresh(QListViewItem*) ) ); | 24 | SLOT( refresh(QListViewItem*) ) ); |
25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
27 | setSorting(0); | 27 | setSorting(0); |
28 | } | 28 | } |
29 | 29 | ||
30 | AccountView::~AccountView() | 30 | AccountView::~AccountView() |
31 | { | 31 | { |
32 | imapAccounts.clear(); | 32 | imapAccounts.clear(); |
33 | mhAccounts.clear(); | 33 | mhAccounts.clear(); |
34 | } | 34 | } |
35 | 35 | ||
36 | void AccountView::slotContextMenu(int id) | 36 | void AccountView::slotContextMenu(int id) |
37 | { | 37 | { |
38 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 38 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
39 | if (!view) return; | 39 | if (!view) return; |
40 | view->contextMenuSelected(id); | 40 | view->contextMenuSelected(id); |
41 | } | 41 | } |
42 | 42 | ||
43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
44 | { | 44 | { |
45 | if (button==1) {return;} | 45 | if (button==1) {return;} |
46 | if (!item) return; | 46 | if (!item) return; |
47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
48 | QPopupMenu*m = view->getContextMenu(); | 48 | QPopupMenu*m = view->getContextMenu(); |
49 | if (!m) return; | 49 | if (!m) return; |
50 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 50 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
51 | m->setFocus(); | 51 | m->setFocus(); |
52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
53 | delete m; | 53 | delete m; |
54 | } | 54 | } |
55 | 55 | ||
56 | void AccountView::populate( QList<Account> list ) | 56 | void AccountView::populate( QList<Account> list ) |
57 | { | 57 | { |
58 | clear(); | 58 | clear(); |
59 | 59 | ||
60 | imapAccounts.clear(); | 60 | imapAccounts.clear(); |
61 | mhAccounts.clear(); | 61 | mhAccounts.clear(); |
62 | 62 | ||
63 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 63 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
64 | 64 | ||
65 | Account *it; | 65 | Account *it; |
66 | for ( it = list.first(); it; it = list.next() ) | 66 | for ( it = list.first(); it; it = list.next() ) { |
67 | { | 67 | if ( it->getType() == MAILLIB::A_IMAP ) { |
68 | if ( it->getType() == MAILLIB::A_IMAP ) | ||
69 | { | ||
70 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 68 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
71 | odebug << "added IMAP " + imap->getAccountName() << oendl; | 69 | odebug << "added IMAP " + imap->getAccountName() << oendl; |
72 | imapAccounts.append(new IMAPviewItem( imap, this )); | 70 | imapAccounts.append(new IMAPviewItem( imap, this )); |
73 | } | 71 | } else if ( it->getType() == MAILLIB::A_POP3 ) { |
74 | else if ( it->getType() == MAILLIB::A_POP3 ) | ||
75 | { | ||
76 | POP3account *pop3 = static_cast<POP3account *>(it); | 72 | POP3account *pop3 = static_cast<POP3account *>(it); |
77 | odebug << "added POP3 " + pop3->getAccountName() << oendl; | 73 | odebug << "added POP3 " + pop3->getAccountName() << oendl; |
78 | /* must not be hold 'cause it isn't required */ | 74 | /* must not be hold 'cause it isn't required */ |
79 | (void) new POP3viewItem( pop3, this ); | 75 | (void) new POP3viewItem( pop3, this ); |
80 | } | 76 | } else if ( it->getType() == MAILLIB::A_NNTP ) { |
81 | else if ( it->getType() == MAILLIB::A_NNTP ) | ||
82 | { | ||
83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 77 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
84 | odebug << "added NNTP " + nntp->getAccountName() << oendl; | 78 | odebug << "added NNTP " + nntp->getAccountName() << oendl; |
85 | /* must not be hold 'cause it isn't required */ | 79 | /* must not be hold 'cause it isn't required */ |
86 | (void) new NNTPviewItem( nntp, this ); | 80 | (void) new NNTPviewItem( nntp, this ); |
87 | } | 81 | } else if ( it->getType() == MAILLIB::A_MH ) { |
88 | } | 82 | } |
83 | } | ||
89 | } | 84 | } |
90 | 85 | ||
91 | void AccountView::refresh(QListViewItem *item) | 86 | void AccountView::refresh(QListViewItem *item) |
92 | { | 87 | { |
93 | 88 | ||
94 | odebug << "AccountView refresh..." << oendl; | 89 | odebug << "AccountView refresh..." << oendl; |
95 | if ( item ) | 90 | if ( item ) |
96 | { | 91 | { |
97 | m_currentItem = item; | 92 | m_currentItem = item; |
98 | QValueList<RecMailP> headerlist; | 93 | QValueList<RecMailP> headerlist; |
99 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 94 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
100 | view->refresh(headerlist); | 95 | view->refresh(headerlist); |
101 | emit refreshMailview(headerlist); | 96 | emit refreshMailview(headerlist); |
102 | } | 97 | } |
103 | } | 98 | } |
104 | 99 | ||
105 | void AccountView::refreshCurrent() | 100 | void AccountView::refreshCurrent() |
106 | { | 101 | { |
107 | m_currentItem = currentItem(); | 102 | m_currentItem = currentItem(); |
108 | if ( !m_currentItem ) return; | 103 | if ( !m_currentItem ) return; |
109 | QValueList<RecMailP> headerlist; | 104 | QValueList<RecMailP> headerlist; |
110 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 105 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
111 | view->refresh(headerlist); | 106 | view->refresh(headerlist); |
112 | emit refreshMailview(headerlist); | 107 | emit refreshMailview(headerlist); |
113 | } | 108 | } |
114 | 109 | ||
115 | void AccountView::refreshAll() | 110 | void AccountView::refreshAll() |
116 | { | 111 | { |
117 | } | 112 | } |
118 | 113 | ||
119 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 114 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
120 | { | 115 | { |
121 | QListViewItem*item = selectedItem (); | 116 | QListViewItem*item = selectedItem (); |
122 | if (!item) return new RecBody(); | 117 | if (!item) return new RecBody(); |
123 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 118 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
124 | return view->fetchBody(aMail); | 119 | return view->fetchBody(aMail); |
125 | } | 120 | } |
126 | 121 | ||
127 | void AccountView::setupFolderselect(Selectstore*sels) | 122 | void AccountView::setupFolderselect(Selectstore*sels) |
128 | { | 123 | { |
129 | QPEApplication::showDialog( sels ); | 124 | QPEApplication::showDialog( sels ); |
130 | QStringList sFolders; | 125 | QStringList sFolders; |
131 | unsigned int i = 0; | 126 | unsigned int i = 0; |
132 | for (i=0; i < mhAccounts.count();++i) | 127 | for (i=0; i < mhAccounts.count();++i) |
133 | { | 128 | { |
134 | mhAccounts[i]->refresh(false); | 129 | mhAccounts[i]->refresh(false); |
135 | sFolders = mhAccounts[i]->subFolders(); | 130 | sFolders = mhAccounts[i]->subFolders(); |
136 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 131 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
137 | } | 132 | } |
138 | for (i=0; i < imapAccounts.count();++i) | 133 | for (i=0; i < imapAccounts.count();++i) |
139 | { | 134 | { |
140 | if (imapAccounts[i]->offline()) | 135 | if (imapAccounts[i]->offline()) |
141 | continue; | 136 | continue; |
142 | imapAccounts[i]->refreshFolders(false); | 137 | imapAccounts[i]->refreshFolders(false); |
143 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 138 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
144 | } | 139 | } |
145 | } | 140 | } |
146 | 141 | ||
147 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 142 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
148 | { | 143 | { |
149 | AbstractMail*targetMail = 0; | 144 | AbstractMail*targetMail = 0; |
150 | QString targetFolder = ""; | 145 | QString targetFolder = ""; |
151 | Selectstore sels; | 146 | Selectstore sels; |
152 | setupFolderselect(&sels); | 147 | setupFolderselect(&sels); |
153 | if (!sels.exec()) return; | 148 | if (!sels.exec()) return; |
154 | targetMail = sels.currentMail(); | 149 | targetMail = sels.currentMail(); |
155 | targetFolder = sels.currentFolder(); | 150 | targetFolder = sels.currentFolder(); |
156 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 151 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
157 | targetFolder.isEmpty()) | 152 | targetFolder.isEmpty()) |
158 | { | 153 | { |
159 | return; | 154 | return; |
160 | } | 155 | } |
161 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 156 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
162 | { | 157 | { |
163 | QMessageBox::critical(0,tr("Error creating new Folder"), | 158 | QMessageBox::critical(0,tr("Error creating new Folder"), |
164 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 159 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
165 | return; | 160 | return; |
166 | } | 161 | } |
167 | odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; | 162 | odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; |
168 | odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; | 163 | odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; |
169 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | 164 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); |
170 | refreshCurrent(); | 165 | refreshCurrent(); |
171 | } | 166 | } |
172 | 167 | ||
173 | bool AccountView::currentisDraft() | 168 | bool AccountView::currentisDraft() |
174 | { | 169 | { |
175 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 170 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
176 | if (!view) return false; | 171 | if (!view) return false; |
177 | return view->isDraftfolder(); | 172 | return view->isDraftfolder(); |
178 | } | 173 | } |
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index b0ce57d..b7c137d 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp | |||
@@ -1,332 +1,332 @@ | |||
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 <opie2/odebug.h> | 6 | #include <opie2/odebug.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qt.h> | 10 | #include <qt.h> |
11 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
12 | 12 | ||
13 | #include <libmailwrapper/nntpwrapper.h> | 13 | #include <libmailwrapper/nntpwrapper.h> |
14 | 14 | ||
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | ||
17 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 17 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
18 | : QListViewItem( parent ) | 18 | : QListViewItem( parent ) |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | setText( 0, account->getAccountName() ); | 21 | setText( 0, account->getAccountName() ); |
22 | QString ttext = ""; | 22 | QString ttext = ""; |
23 | switch (account->getType()) { | 23 | switch (account->getType()) { |
24 | case MAILLIB::A_NNTP: | 24 | case MAILLIB::A_NNTP: |
25 | ttext="NNTP"; | 25 | ttext="NNTP"; |
26 | break; | 26 | break; |
27 | case MAILLIB::A_POP3: | 27 | case MAILLIB::A_POP3: |
28 | ttext = "POP3"; | 28 | ttext = "POP3"; |
29 | break; | 29 | break; |
30 | case MAILLIB::A_IMAP: | 30 | case MAILLIB::A_IMAP: |
31 | ttext = "IMAP"; | 31 | ttext = "IMAP"; |
32 | break; | 32 | break; |
33 | case MAILLIB::A_SMTP: | 33 | case MAILLIB::A_SMTP: |
34 | ttext = "SMTP"; | 34 | ttext = "SMTP"; |
35 | break; | 35 | break; |
36 | default: | 36 | default: |
37 | ttext = "UNKNOWN"; | 37 | ttext = "UNKNOWN"; |
38 | break; | 38 | break; |
39 | } | 39 | } |
40 | setText( 1, ttext); | 40 | setText( 1, ttext); |
41 | } | 41 | } |
42 | 42 | ||
43 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 43 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
44 | : EditAccountsUI( parent, name, modal, flags ) | 44 | : EditAccountsUI( parent, name, modal, flags ) |
45 | { | 45 | { |
46 | odebug << "New Account Configuration Widget" << oendl; | 46 | odebug << "New Account Configuration Widget" << oendl; |
47 | settings = s; | 47 | settings = s; |
48 | 48 | ||
49 | mailList->addColumn( tr( "Account" ) ); | 49 | mailList->addColumn( tr( "Account" ) ); |
50 | mailList->addColumn( tr( "Type" ) ); | 50 | mailList->addColumn( tr( "Type" ) ); |
51 | 51 | ||
52 | newsList->addColumn( tr( "Account" ) ); | 52 | newsList->addColumn( tr( "Account" ) ); |
53 | 53 | ||
54 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 54 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
55 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 55 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
56 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 56 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
57 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 57 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
58 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 58 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
59 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 59 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
60 | 60 | ||
61 | slotFillLists(); | 61 | slotFillLists(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void EditAccounts::slotFillLists() | 64 | void EditAccounts::slotFillLists() |
65 | { | 65 | { |
66 | mailList->clear(); | 66 | mailList->clear(); |
67 | newsList->clear(); | 67 | newsList->clear(); |
68 | 68 | ||
69 | QList<Account> accounts = settings->getAccounts(); | 69 | QList<Account> accounts = settings->getAccounts(); |
70 | Account *it; | 70 | Account *it; |
71 | for ( it = accounts.first(); it; it = accounts.next() ) | 71 | for ( it = accounts.first(); it; it = accounts.next() ) |
72 | { | 72 | { |
73 | if ( it->getType()==MAILLIB::A_NNTP ) | 73 | if ( it->getType()==MAILLIB::A_NNTP ) |
74 | { | 74 | { |
75 | (void) new AccountListItem( newsList, it ); | 75 | (void) new AccountListItem( newsList, it ); |
76 | } | 76 | } |
77 | else | 77 | else |
78 | { | 78 | { |
79 | (void) new AccountListItem( mailList, it ); | 79 | (void) new AccountListItem( mailList, it ); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | void EditAccounts::slotNewMail() | 84 | void EditAccounts::slotNewMail() |
85 | { | 85 | { |
86 | odebug << "New Mail Account" << oendl; | 86 | odebug << "New Mail Account" << oendl; |
87 | QString *selection = new QString(); | 87 | QString *selection = new QString(); |
88 | SelectMailType selType( selection, this, 0, true ); | 88 | SelectMailType selType( selection, this, 0, true ); |
89 | selType.show(); | 89 | selType.show(); |
90 | if ( QDialog::Accepted == selType.exec() ) | 90 | if ( QDialog::Accepted == selType.exec() ) |
91 | { | 91 | { |
92 | slotNewAccount( *selection ); | 92 | slotNewAccount( *selection ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void EditAccounts::slotNewAccount( const QString &type ) | 96 | void EditAccounts::slotNewAccount( const QString &type ) |
97 | { | 97 | { |
98 | if ( type.compare( "IMAP" ) == 0 ) | 98 | if ( type.compare( "IMAP" ) == 0 ) |
99 | { | 99 | { |
100 | odebug << "-> config IMAP" << oendl; | 100 | odebug << "-> config IMAP" << oendl; |
101 | IMAPaccount *account = new IMAPaccount(); | 101 | IMAPaccount *account = new IMAPaccount(); |
102 | IMAPconfig imap( account, this, 0, true ); | 102 | IMAPconfig imap( account, this, 0, true ); |
103 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 103 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
104 | { | 104 | { |
105 | settings->addAccount( account ); | 105 | settings->addAccount( account ); |
106 | account->save(); | 106 | account->save(); |
107 | slotFillLists(); | 107 | slotFillLists(); |
108 | } | 108 | } |
109 | else | 109 | else |
110 | { | 110 | { |
111 | account->remove(); | 111 | account->remove(); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | else if ( type.compare( "POP3" ) == 0 ) | 114 | else if ( type.compare( "POP3" ) == 0 ) |
115 | { | 115 | { |
116 | odebug << "-> config POP3" << oendl; | 116 | odebug << "-> config POP3" << oendl; |
117 | POP3account *account = new POP3account(); | 117 | POP3account *account = new POP3account(); |
118 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 118 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
119 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 119 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
120 | { | 120 | { |
121 | settings->addAccount( account ); | 121 | settings->addAccount( account ); |
122 | account->save(); | 122 | account->save(); |
123 | slotFillLists(); | 123 | slotFillLists(); |
124 | } | 124 | } |
125 | else | 125 | else |
126 | { | 126 | { |
127 | account->remove(); | 127 | account->remove(); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | else if ( type.compare( "SMTP" ) == 0 ) | 130 | else if ( type.compare( "SMTP" ) == 0 ) |
131 | { | 131 | { |
132 | odebug << "-> config SMTP" << oendl; | 132 | odebug << "-> config SMTP" << oendl; |
133 | SMTPaccount *account = new SMTPaccount(); | 133 | SMTPaccount *account = new SMTPaccount(); |
134 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 134 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
135 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 135 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
136 | { | 136 | { |
137 | settings->addAccount( account ); | 137 | settings->addAccount( account ); |
138 | account->save(); | 138 | account->save(); |
139 | slotFillLists(); | 139 | slotFillLists(); |
140 | 140 | ||
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
144 | account->remove(); | 144 | account->remove(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | else if ( type.compare( "NNTP" ) == 0 ) | 147 | else if ( type.compare( "NNTP" ) == 0 ) |
148 | { | 148 | { |
149 | odebug << "-> config NNTP" << oendl; | 149 | odebug << "-> config NNTP" << oendl; |
150 | NNTPaccount *account = new NNTPaccount(); | 150 | NNTPaccount *account = new NNTPaccount(); |
151 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 151 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
152 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 152 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
153 | { | 153 | { |
154 | settings->addAccount( account ); | 154 | settings->addAccount( account ); |
155 | account->save(); | 155 | account->save(); |
156 | slotFillLists(); | 156 | slotFillLists(); |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | account->remove(); | 160 | account->remove(); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void EditAccounts::slotEditAccount( Account *account ) | 165 | void EditAccounts::slotEditAccount( Account *account ) |
166 | { | 166 | { |
167 | if ( account->getType() == MAILLIB::A_IMAP ) | 167 | if ( account->getType() == MAILLIB::A_IMAP ) |
168 | { | 168 | { |
169 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 169 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
170 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 170 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
171 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 171 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
172 | { | 172 | { |
173 | slotFillLists(); | 173 | slotFillLists(); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | else if ( account->getType()==MAILLIB::A_POP3 ) | 176 | else if ( account->getType()==MAILLIB::A_POP3 ) |
177 | { | 177 | { |
178 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 178 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
179 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 179 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
180 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 180 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
181 | { | 181 | { |
182 | slotFillLists(); | 182 | slotFillLists(); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | else if ( account->getType()==MAILLIB::A_SMTP ) | 185 | else if ( account->getType()==MAILLIB::A_SMTP ) |
186 | { | 186 | { |
187 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 187 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
188 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 188 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
189 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 189 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
190 | { | 190 | { |
191 | slotFillLists(); | 191 | slotFillLists(); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | else if ( account->getType()==MAILLIB::A_NNTP) | 194 | else if ( account->getType()==MAILLIB::A_NNTP) |
195 | { | 195 | { |
196 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 196 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
197 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 197 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
198 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 198 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
199 | { | 199 | { |
200 | slotFillLists(); | 200 | slotFillLists(); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void EditAccounts::slotDeleteAccount( Account *account ) | 205 | void EditAccounts::slotDeleteAccount( Account *account ) |
206 | { | 206 | { |
207 | if ( QMessageBox::information( this, tr( "Question" ), | 207 | if ( QMessageBox::information( this, tr( "Question" ), |
208 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 208 | tr( "<p>Do you really want to delete the selected Account?</p>" ), |
209 | tr( "Yes" ), tr( "No" ) ) == 0 ) | 209 | tr( "Yes" ), tr( "No" ) ) == 0 ) |
210 | { | 210 | { |
211 | settings->delAccount( account ); | 211 | settings->delAccount( account ); |
212 | slotFillLists(); | 212 | slotFillLists(); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void EditAccounts::slotEditMail() | 216 | void EditAccounts::slotEditMail() |
217 | { | 217 | { |
218 | odebug << "Edit Mail Account" << oendl; | 218 | odebug << "Edit Mail Account" << oendl; |
219 | if ( !mailList->currentItem() ) | 219 | if ( !mailList->currentItem() ) |
220 | { | 220 | { |
221 | QMessageBox::information( this, tr( "Error" ), | 221 | QMessageBox::information( this, tr( "Error" ), |
222 | tr( "<p>Please select an account.</p>" ), | 222 | tr( "<p>Please select an account.</p>" ), |
223 | tr( "Ok" ) ); | 223 | tr( "Ok" ) ); |
224 | return; | 224 | return; |
225 | } | 225 | } |
226 | 226 | ||
227 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 227 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
228 | slotEditAccount( a ); | 228 | slotEditAccount( a ); |
229 | } | 229 | } |
230 | 230 | ||
231 | void EditAccounts::slotDeleteMail() | 231 | void EditAccounts::slotDeleteMail() |
232 | { | 232 | { |
233 | if ( !mailList->currentItem() ) | 233 | if ( !mailList->currentItem() ) |
234 | { | 234 | { |
235 | QMessageBox::information( this, tr( "Error" ), | 235 | QMessageBox::information( this, tr( "Error" ), |
236 | tr( "<p>Please select an account.</p>" ), | 236 | tr( "<p>Please select an account.</p>" ), |
237 | tr( "Ok" ) ); | 237 | tr( "Ok" ) ); |
238 | return; | 238 | return; |
239 | } | 239 | } |
240 | 240 | ||
241 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 241 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
242 | slotDeleteAccount( a ); | 242 | slotDeleteAccount( a ); |
243 | } | 243 | } |
244 | 244 | ||
245 | void EditAccounts::slotNewNews() | 245 | void EditAccounts::slotNewNews() |
246 | { | 246 | { |
247 | odebug << "New News Account" << oendl; | 247 | odebug << "New News Account" << oendl; |
248 | slotNewAccount( "NNTP" ); | 248 | slotNewAccount( "NNTP" ); |
249 | } | 249 | } |
250 | 250 | ||
251 | void EditAccounts::slotEditNews() | 251 | void EditAccounts::slotEditNews() |
252 | { | 252 | { |
253 | odebug << "Edit News Account" << oendl; | 253 | odebug << "Edit News Account" << oendl; |
254 | if ( !newsList->currentItem() ) | 254 | if ( !newsList->currentItem() ) |
255 | { | 255 | { |
256 | QMessageBox::information( this, tr( "Error" ), | 256 | QMessageBox::information( this, tr( "Error" ), |
257 | tr( "<p>Please select an account.</p>" ), | 257 | tr( "<p>Please select an account.</p>" ), |
258 | tr( "Ok" ) ); | 258 | tr( "Ok" ) ); |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | 261 | ||
262 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 262 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
263 | slotEditAccount( a ); | 263 | slotEditAccount( a ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void EditAccounts::slotDeleteNews() | 266 | void EditAccounts::slotDeleteNews() |
267 | { | 267 | { |
268 | odebug << "Delete News Account" << oendl; | 268 | odebug << "Delete News Account" << oendl; |
269 | if ( !newsList->currentItem() ) | 269 | if ( !newsList->currentItem() ) |
270 | { | 270 | { |
271 | QMessageBox::information( this, tr( "Error" ), | 271 | QMessageBox::information( this, tr( "Error" ), |
272 | tr( "<p>Please select an account.</p>" ), | 272 | tr( "<p>Please select an account.</p>" ), |
273 | tr( "Ok" ) ); | 273 | tr( "Ok" ) ); |
274 | return; | 274 | return; |
275 | } | 275 | } |
276 | 276 | ||
277 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 277 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
278 | slotDeleteAccount( a ); | 278 | slotDeleteAccount( a ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void EditAccounts::slotAdjustColumns() | 281 | void EditAccounts::slotAdjustColumns() |
282 | { | 282 | { |
283 | int currPage = configTab->currentPageIndex(); | 283 | int currPage = configTab->currentPageIndex(); |
284 | 284 | ||
285 | configTab->showPage( mailTab ); | 285 | configTab->showPage( mailTab ); |
286 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 286 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
287 | mailList->setColumnWidth( 1, 50 ); | 287 | mailList->setColumnWidth( 1, 50 ); |
288 | 288 | ||
289 | configTab->showPage( newsTab ); | 289 | configTab->showPage( newsTab ); |
290 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 290 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
291 | 291 | ||
292 | configTab->setCurrentPage( currPage ); | 292 | configTab->setCurrentPage( currPage ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void EditAccounts::accept() | 295 | void EditAccounts::accept() |
296 | { | 296 | { |
297 | settings->saveAccounts(); | 297 | settings->saveAccounts(); |
298 | 298 | ||
299 | QDialog::accept(); | 299 | QDialog::accept(); |
300 | } | 300 | } |
301 | 301 | ||
302 | /** | 302 | /** |
303 | * SelectMailType | 303 | * SelectMailType |
304 | */ | 304 | */ |
305 | 305 | ||
306 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 306 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
307 | : SelectMailTypeUI( parent, name, modal, flags ) | 307 | : SelectMailTypeUI( parent, name, modal, flags ) |
308 | { | 308 | { |
309 | selected = selection; | 309 | selected = selection; |
310 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 310 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
311 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); | 311 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); |
312 | } | 312 | } |
313 | 313 | ||
314 | void SelectMailType::slotSelection( const QString &sel ) | 314 | void SelectMailType::slotSelection( const QString &sel ) |
315 | { | 315 | { |
316 | selected->replace( 0, selected->length(), sel ); | 316 | selected->replace( 0, selected->length(), sel ); |
317 | } | 317 | } |
318 | 318 | ||
319 | /** | 319 | /** |
320 | * IMAPconfig | 320 | * IMAPconfig |
321 | */ | 321 | */ |
322 | 322 | ||
323 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 323 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
324 | : IMAPconfigUI( parent, name, modal, flags ) | 324 | : IMAPconfigUI( parent, name, modal, flags ) |
325 | { | 325 | { |
326 | data = account; | 326 | data = account; |
327 | 327 | ||
328 | fillValues(); | 328 | fillValues(); |
329 | 329 | ||
330 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 330 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
331 | ComboBox1->insertItem( "Only if available", 0 ); | 331 | ComboBox1->insertItem( "Only if available", 0 ); |
332 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 332 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
@@ -361,237 +361,241 @@ void IMAPconfig::fillValues() | |||
361 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 361 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
362 | userLine->setText( data->getUser() ); | 362 | userLine->setText( data->getUser() ); |
363 | passLine->setText( data->getPassword() ); | 363 | passLine->setText( data->getPassword() ); |
364 | prefixLine->setText(data->getPrefix()); | 364 | prefixLine->setText(data->getPrefix()); |
365 | } | 365 | } |
366 | 366 | ||
367 | void IMAPconfig::accept() | 367 | void IMAPconfig::accept() |
368 | { | 368 | { |
369 | data->setAccountName( accountLine->text() ); | 369 | data->setAccountName( accountLine->text() ); |
370 | data->setServer( serverLine->text() ); | 370 | data->setServer( serverLine->text() ); |
371 | data->setPort( portLine->text() ); | 371 | data->setPort( portLine->text() ); |
372 | data->setConnectionType( ComboBox1->currentItem() ); | 372 | data->setConnectionType( ComboBox1->currentItem() ); |
373 | data->setUser( userLine->text() ); | 373 | data->setUser( userLine->text() ); |
374 | data->setPassword( passLine->text() ); | 374 | data->setPassword( passLine->text() ); |
375 | data->setPrefix(prefixLine->text()); | 375 | data->setPrefix(prefixLine->text()); |
376 | 376 | ||
377 | QDialog::accept(); | 377 | QDialog::accept(); |
378 | } | 378 | } |
379 | 379 | ||
380 | /** | 380 | /** |
381 | * POP3config | 381 | * POP3config |
382 | */ | 382 | */ |
383 | 383 | ||
384 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 384 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
385 | : POP3configUI( parent, name, modal, flags ) | 385 | : POP3configUI( parent, name, modal, flags ) |
386 | { | 386 | { |
387 | data = account; | 387 | data = account; |
388 | fillValues(); | 388 | fillValues(); |
389 | 389 | ||
390 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 390 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
391 | ComboBox1->insertItem( "Only if available", 0 ); | 391 | ComboBox1->insertItem( "Only if available", 0 ); |
392 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 392 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
393 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 393 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
394 | ComboBox1->insertItem( "Run command instead", 3 ); | 394 | ComboBox1->insertItem( "Run command instead", 3 ); |
395 | CommandEdit->hide(); | 395 | CommandEdit->hide(); |
396 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 396 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void POP3config::slotConnectionToggle( int index ) | 399 | void POP3config::slotConnectionToggle( int index ) |
400 | { | 400 | { |
401 | // 2 is ssl connection | 401 | // 2 is ssl connection |
402 | if ( index == 2 ) | 402 | if ( index == 2 ) |
403 | { | 403 | { |
404 | portLine->setText( POP3_SSL_PORT ); | 404 | portLine->setText( POP3_SSL_PORT ); |
405 | } | 405 | } |
406 | else if ( index == 3 ) | 406 | else if ( index == 3 ) |
407 | { | 407 | { |
408 | portLine->setText( POP3_PORT ); | 408 | portLine->setText( POP3_PORT ); |
409 | CommandEdit->show(); | 409 | CommandEdit->show(); |
410 | } | 410 | } |
411 | else | 411 | else |
412 | { | 412 | { |
413 | portLine->setText( POP3_PORT ); | 413 | portLine->setText( POP3_PORT ); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | void POP3config::fillValues() | 417 | void POP3config::fillValues() |
418 | { | 418 | { |
419 | accountLine->setText( data->getAccountName() ); | 419 | accountLine->setText( data->getAccountName() ); |
420 | serverLine->setText( data->getServer() ); | 420 | serverLine->setText( data->getServer() ); |
421 | portLine->setText( data->getPort() ); | 421 | portLine->setText( data->getPort() ); |
422 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 422 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
423 | userLine->setText( data->getUser() ); | 423 | userLine->setText( data->getUser() ); |
424 | passLine->setText( data->getPassword() ); | 424 | passLine->setText( data->getPassword() ); |
425 | m_CheckSize->setChecked(data->getCheckMaxSize()); | ||
426 | m_MailLimitBox->setValue(data->getMaxSize()); | ||
425 | } | 427 | } |
426 | 428 | ||
427 | void POP3config::accept() | 429 | void POP3config::accept() |
428 | { | 430 | { |
429 | data->setAccountName( accountLine->text() ); | 431 | data->setAccountName( accountLine->text() ); |
430 | data->setServer( serverLine->text() ); | 432 | data->setServer( serverLine->text() ); |
431 | data->setPort( portLine->text() ); | 433 | data->setPort( portLine->text() ); |
432 | data->setConnectionType( ComboBox1->currentItem() ); | 434 | data->setConnectionType( ComboBox1->currentItem() ); |
433 | data->setUser( userLine->text() ); | 435 | data->setUser( userLine->text() ); |
434 | data->setPassword( passLine->text() ); | 436 | data->setPassword( passLine->text() ); |
437 | data->setMaxSize(m_MailLimitBox->value()); | ||
438 | data->setCheckMaxSize(m_CheckSize->isChecked()); | ||
435 | 439 | ||
436 | QDialog::accept(); | 440 | QDialog::accept(); |
437 | } | 441 | } |
438 | 442 | ||
439 | /** | 443 | /** |
440 | * SMTPconfig | 444 | * SMTPconfig |
441 | */ | 445 | */ |
442 | 446 | ||
443 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 447 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
444 | : SMTPconfigUI( parent, name, modal, flags ) | 448 | : SMTPconfigUI( parent, name, modal, flags ) |
445 | { | 449 | { |
446 | data = account; | 450 | data = account; |
447 | 451 | ||
448 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 452 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
449 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 453 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
450 | 454 | ||
451 | fillValues(); | 455 | fillValues(); |
452 | 456 | ||
453 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 457 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
454 | ComboBox1->insertItem( "Only if available", 0 ); | 458 | ComboBox1->insertItem( "Only if available", 0 ); |
455 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 459 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
456 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 460 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
457 | ComboBox1->insertItem( "Run command instead", 3 ); | 461 | ComboBox1->insertItem( "Run command instead", 3 ); |
458 | CommandEdit->hide(); | 462 | CommandEdit->hide(); |
459 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 463 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
460 | } | 464 | } |
461 | 465 | ||
462 | void SMTPconfig::slotConnectionToggle( int index ) | 466 | void SMTPconfig::slotConnectionToggle( int index ) |
463 | { | 467 | { |
464 | // 2 is ssl connection | 468 | // 2 is ssl connection |
465 | if ( index == 2 ) | 469 | if ( index == 2 ) |
466 | { | 470 | { |
467 | portLine->setText( SMTP_SSL_PORT ); | 471 | portLine->setText( SMTP_SSL_PORT ); |
468 | } | 472 | } |
469 | else if ( index == 3 ) | 473 | else if ( index == 3 ) |
470 | { | 474 | { |
471 | portLine->setText( SMTP_PORT ); | 475 | portLine->setText( SMTP_PORT ); |
472 | CommandEdit->show(); | 476 | CommandEdit->show(); |
473 | } | 477 | } |
474 | else | 478 | else |
475 | { | 479 | { |
476 | portLine->setText( SMTP_PORT ); | 480 | portLine->setText( SMTP_PORT ); |
477 | } | 481 | } |
478 | } | 482 | } |
479 | 483 | ||
480 | void SMTPconfig::fillValues() | 484 | void SMTPconfig::fillValues() |
481 | { | 485 | { |
482 | accountLine->setText( data->getAccountName() ); | 486 | accountLine->setText( data->getAccountName() ); |
483 | serverLine->setText( data->getServer() ); | 487 | serverLine->setText( data->getServer() ); |
484 | portLine->setText( data->getPort() ); | 488 | portLine->setText( data->getPort() ); |
485 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 489 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
486 | loginBox->setChecked( data->getLogin() ); | 490 | loginBox->setChecked( data->getLogin() ); |
487 | userLine->setText( data->getUser() ); | 491 | userLine->setText( data->getUser() ); |
488 | passLine->setText( data->getPassword() ); | 492 | passLine->setText( data->getPassword() ); |
489 | } | 493 | } |
490 | 494 | ||
491 | void SMTPconfig::accept() | 495 | void SMTPconfig::accept() |
492 | { | 496 | { |
493 | data->setAccountName( accountLine->text() ); | 497 | data->setAccountName( accountLine->text() ); |
494 | data->setServer( serverLine->text() ); | 498 | data->setServer( serverLine->text() ); |
495 | data->setPort( portLine->text() ); | 499 | data->setPort( portLine->text() ); |
496 | data->setConnectionType( ComboBox1->currentItem() ); | 500 | data->setConnectionType( ComboBox1->currentItem() ); |
497 | data->setLogin( loginBox->isChecked() ); | 501 | data->setLogin( loginBox->isChecked() ); |
498 | data->setUser( userLine->text() ); | 502 | data->setUser( userLine->text() ); |
499 | data->setPassword( passLine->text() ); | 503 | data->setPassword( passLine->text() ); |
500 | 504 | ||
501 | QDialog::accept(); | 505 | QDialog::accept(); |
502 | } | 506 | } |
503 | 507 | ||
504 | /** | 508 | /** |
505 | * NNTPconfig | 509 | * NNTPconfig |
506 | */ | 510 | */ |
507 | 511 | ||
508 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 512 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
509 | : NNTPconfigUI( parent, name, modal, flags ) | 513 | : NNTPconfigUI( parent, name, modal, flags ) |
510 | { | 514 | { |
511 | data = account; | 515 | data = account; |
512 | 516 | ||
513 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 517 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
514 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 518 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
515 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 519 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
516 | fillValues(); | 520 | fillValues(); |
517 | 521 | ||
518 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 522 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
519 | } | 523 | } |
520 | 524 | ||
521 | void NNTPconfig::slotGetNG() { | 525 | void NNTPconfig::slotGetNG() { |
522 | save(); | 526 | save(); |
523 | data->save(); | 527 | data->save(); |
524 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 528 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
525 | QStringList list = tmp->listAllNewsgroups(); | 529 | QStringList list = tmp->listAllNewsgroups(); |
526 | 530 | ||
527 | ListViewGroups->clear(); | 531 | ListViewGroups->clear(); |
528 | 532 | ||
529 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 533 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
530 | QCheckListItem *item; | 534 | QCheckListItem *item; |
531 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 535 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
532 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 536 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
533 | item->setOn( true ); | 537 | item->setOn( true ); |
534 | } | 538 | } |
535 | } | 539 | } |
536 | } | 540 | } |
537 | 541 | ||
538 | void NNTPconfig::slotSSL( bool enabled ) | 542 | void NNTPconfig::slotSSL( bool enabled ) |
539 | { | 543 | { |
540 | if ( enabled ) | 544 | if ( enabled ) |
541 | { | 545 | { |
542 | portLine->setText( NNTP_SSL_PORT ); | 546 | portLine->setText( NNTP_SSL_PORT ); |
543 | } | 547 | } |
544 | else | 548 | else |
545 | { | 549 | { |
546 | portLine->setText( NNTP_PORT ); | 550 | portLine->setText( NNTP_PORT ); |
547 | } | 551 | } |
548 | } | 552 | } |
549 | 553 | ||
550 | void NNTPconfig::fillValues() | 554 | void NNTPconfig::fillValues() |
551 | { | 555 | { |
552 | accountLine->setText( data->getAccountName() ); | 556 | accountLine->setText( data->getAccountName() ); |
553 | serverLine->setText( data->getServer() ); | 557 | serverLine->setText( data->getServer() ); |
554 | portLine->setText( data->getPort() ); | 558 | portLine->setText( data->getPort() ); |
555 | sslBox->setChecked( data->getSSL() ); | 559 | sslBox->setChecked( data->getSSL() ); |
556 | loginBox->setChecked( data->getLogin() ); | 560 | loginBox->setChecked( data->getLogin() ); |
557 | userLine->setText( data->getUser() ); | 561 | userLine->setText( data->getUser() ); |
558 | passLine->setText( data->getPassword() ); | 562 | passLine->setText( data->getPassword() ); |
559 | subscribedGroups = data->getGroups(); | 563 | subscribedGroups = data->getGroups(); |
560 | /* don't forget that - you will overwrite values if user clicks cancel! */ | 564 | /* don't forget that - you will overwrite values if user clicks cancel! */ |
561 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 565 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
562 | QCheckListItem *item; | 566 | QCheckListItem *item; |
563 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 567 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
564 | item->setOn( true ); | 568 | item->setOn( true ); |
565 | } | 569 | } |
566 | } | 570 | } |
567 | 571 | ||
568 | void NNTPconfig::save() | 572 | void NNTPconfig::save() |
569 | { | 573 | { |
570 | data->setAccountName( accountLine->text() ); | 574 | data->setAccountName( accountLine->text() ); |
571 | data->setServer( serverLine->text() ); | 575 | data->setServer( serverLine->text() ); |
572 | data->setPort( portLine->text() ); | 576 | data->setPort( portLine->text() ); |
573 | data->setSSL( sslBox->isChecked() ); | 577 | data->setSSL( sslBox->isChecked() ); |
574 | data->setLogin( loginBox->isChecked() ); | 578 | data->setLogin( loginBox->isChecked() ); |
575 | data->setUser( userLine->text() ); | 579 | data->setUser( userLine->text() ); |
576 | data->setPassword( passLine->text() ); | 580 | data->setPassword( passLine->text() ); |
577 | 581 | ||
578 | QListViewItemIterator list_it( ListViewGroups ); | 582 | QListViewItemIterator list_it( ListViewGroups ); |
579 | 583 | ||
580 | QStringList groupList; | 584 | QStringList groupList; |
581 | for ( ; list_it.current(); ++list_it ) { | 585 | for ( ; list_it.current(); ++list_it ) { |
582 | 586 | ||
583 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | 587 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { |
584 | odebug << list_it.current()->text(0) << oendl; | 588 | odebug << list_it.current()->text(0) << oendl; |
585 | groupList.append( list_it.current()->text(0) ); | 589 | groupList.append( list_it.current()->text(0) ); |
586 | } | 590 | } |
587 | 591 | ||
588 | } | 592 | } |
589 | data->setGroups( groupList ); | 593 | data->setGroups( groupList ); |
590 | } | 594 | } |
591 | 595 | ||
592 | void NNTPconfig::accept() | 596 | void NNTPconfig::accept() |
593 | { | 597 | { |
594 | save(); | 598 | save(); |
595 | QDialog::accept(); | 599 | QDialog::accept(); |
596 | } | 600 | } |
597 | 601 | ||
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 1caa375..5ec9415 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,69 +1,71 @@ | |||
1 | #include "genericwrapper.h" | 1 | #include "genericwrapper.h" |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
6 | #include <qpe/timestring.h> | ||
7 | #include <qdatetime.h> | ||
6 | 8 | ||
7 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
8 | Genericwrapper::Genericwrapper() | 10 | Genericwrapper::Genericwrapper() |
9 | : AbstractMail() | 11 | : AbstractMail() |
10 | { | 12 | { |
11 | bodyCache.clear(); | 13 | bodyCache.clear(); |
12 | m_storage = 0; | 14 | m_storage = 0; |
13 | m_folder = 0; | 15 | m_folder = 0; |
14 | } | 16 | } |
15 | 17 | ||
16 | Genericwrapper::~Genericwrapper() | 18 | Genericwrapper::~Genericwrapper() |
17 | { | 19 | { |
18 | if (m_folder) { | 20 | if (m_folder) { |
19 | mailfolder_free(m_folder); | 21 | mailfolder_free(m_folder); |
20 | } | 22 | } |
21 | if (m_storage) { | 23 | if (m_storage) { |
22 | mailstorage_free(m_storage); | 24 | mailstorage_free(m_storage); |
23 | } | 25 | } |
24 | cleanMimeCache(); | 26 | cleanMimeCache(); |
25 | } | 27 | } |
26 | 28 | ||
27 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 29 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
28 | { | 30 | { |
29 | if (!mime) { | 31 | if (!mime) { |
30 | return; | 32 | return; |
31 | } | 33 | } |
32 | mailmime_field*field = 0; | 34 | mailmime_field*field = 0; |
33 | mailmime_single_fields fields; | 35 | mailmime_single_fields fields; |
34 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 36 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
35 | if (mime->mm_mime_fields != NULL) { | 37 | if (mime->mm_mime_fields != NULL) { |
36 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 38 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
37 | mime->mm_content_type); | 39 | mime->mm_content_type); |
38 | } | 40 | } |
39 | 41 | ||
40 | mailmime_content*type = fields.fld_content; | 42 | mailmime_content*type = fields.fld_content; |
41 | clistcell*current; | 43 | clistcell*current; |
42 | if (!type) { | 44 | if (!type) { |
43 | target->setType("text"); | 45 | target->setType("text"); |
44 | target->setSubtype("plain"); | 46 | target->setSubtype("plain"); |
45 | } else { | 47 | } else { |
46 | target->setSubtype(type->ct_subtype); | 48 | target->setSubtype(type->ct_subtype); |
47 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 49 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
48 | case MAILMIME_DISCRETE_TYPE_TEXT: | 50 | case MAILMIME_DISCRETE_TYPE_TEXT: |
49 | target->setType("text"); | 51 | target->setType("text"); |
50 | break; | 52 | break; |
51 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 53 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
52 | target->setType("image"); | 54 | target->setType("image"); |
53 | break; | 55 | break; |
54 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 56 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
55 | target->setType("audio"); | 57 | target->setType("audio"); |
56 | break; | 58 | break; |
57 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 59 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
58 | target->setType("video"); | 60 | target->setType("video"); |
59 | break; | 61 | break; |
60 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 62 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
61 | target->setType("application"); | 63 | target->setType("application"); |
62 | break; | 64 | break; |
63 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 65 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
64 | default: | 66 | default: |
65 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 67 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
66 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 68 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
67 | } | 69 | } |
68 | break; | 70 | break; |
69 | } | 71 | } |
@@ -182,134 +184,133 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m | |||
182 | break; | 184 | break; |
183 | case MAILMIME_MULTIPLE: | 185 | case MAILMIME_MULTIPLE: |
184 | { | 186 | { |
185 | unsigned int ccount = 1; | 187 | unsigned int ccount = 1; |
186 | mailmime*cbody=0; | 188 | mailmime*cbody=0; |
187 | QValueList<int>countlist = recList; | 189 | QValueList<int>countlist = recList; |
188 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 190 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
189 | cbody = (mailmime*)clist_content(cur); | 191 | cbody = (mailmime*)clist_content(cur); |
190 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 192 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
191 | RecPartP targetPart = new RecPart(); | 193 | RecPartP targetPart = new RecPart(); |
192 | targetPart->setType("multipart"); | 194 | targetPart->setType("multipart"); |
193 | countlist.append(current_count); | 195 | countlist.append(current_count); |
194 | targetPart->setPositionlist(countlist); | 196 | targetPart->setPositionlist(countlist); |
195 | target->addPart(targetPart); | 197 | target->addPart(targetPart); |
196 | } | 198 | } |
197 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 199 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
198 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 200 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
199 | countlist = recList; | 201 | countlist = recList; |
200 | } | 202 | } |
201 | ++ccount; | 203 | ++ccount; |
202 | } | 204 | } |
203 | } | 205 | } |
204 | break; | 206 | break; |
205 | case MAILMIME_MESSAGE: | 207 | case MAILMIME_MESSAGE: |
206 | { | 208 | { |
207 | QValueList<int>countlist = recList; | 209 | QValueList<int>countlist = recList; |
208 | countlist.append(current_count); | 210 | countlist.append(current_count); |
209 | /* the own header is always at recursion 0 - we don't need that */ | 211 | /* the own header is always at recursion 0 - we don't need that */ |
210 | if (current_rec > 0) { | 212 | if (current_rec > 0) { |
211 | part->setPositionlist(countlist); | 213 | part->setPositionlist(countlist); |
212 | r = mailmessage_fetch_section(message,mime,&data,&len); | 214 | r = mailmessage_fetch_section(message,mime,&data,&len); |
213 | part->setSize(len); | 215 | part->setSize(len); |
214 | part->setPositionlist(countlist); | 216 | part->setPositionlist(countlist); |
215 | b = gen_attachment_id(); | 217 | b = gen_attachment_id(); |
216 | part->setIdentifier(b); | 218 | part->setIdentifier(b); |
217 | part->setType("message"); | 219 | part->setType("message"); |
218 | part->setSubtype("rfc822"); | 220 | part->setSubtype("rfc822"); |
219 | bodyCache[b]=new encodedString(data,len); | 221 | bodyCache[b]=new encodedString(data,len); |
220 | target->addPart(part); | 222 | target->addPart(part); |
221 | } | 223 | } |
222 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 224 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
223 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 225 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
224 | } | 226 | } |
225 | } | 227 | } |
226 | break; | 228 | break; |
227 | } | 229 | } |
228 | } | 230 | } |
229 | 231 | ||
230 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 232 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
231 | { | 233 | { |
232 | int err = MAILIMF_NO_ERROR; | 234 | int err = MAILIMF_NO_ERROR; |
233 | mailmime_single_fields fields; | 235 | mailmime_single_fields fields; |
234 | /* is bound to msg and will be freed there */ | 236 | /* is bound to msg and will be freed there */ |
235 | mailmime * mime=0; | 237 | mailmime * mime=0; |
236 | RecBodyP body = new RecBody(); | 238 | RecBodyP body = new RecBody(); |
237 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 239 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
238 | err = mailmessage_get_bodystructure(msg,&mime); | 240 | err = mailmessage_get_bodystructure(msg,&mime); |
239 | QValueList<int>recList; | 241 | QValueList<int>recList; |
240 | traverseBody(body,msg,mime,recList); | 242 | traverseBody(body,msg,mime,recList); |
241 | return body; | 243 | return body; |
242 | } | 244 | } |
243 | 245 | ||
244 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 246 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
245 | { | 247 | { |
246 | char tmp[23]; | 248 | QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); |
247 | 249 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | |
248 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 250 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; |
249 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 251 | timestring.sprintf(timestring+" %+05i",date->dt_zone); |
250 | 252 | return timestring; | |
251 | return QString( tmp ); | ||
252 | } | 253 | } |
253 | 254 | ||
254 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 255 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
255 | { | 256 | { |
256 | QString result( "" ); | 257 | QString result( "" ); |
257 | 258 | ||
258 | bool first = true; | 259 | bool first = true; |
259 | if (list == 0) return result; | 260 | if (list == 0) return result; |
260 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 261 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
261 | mailimf_address *addr = (mailimf_address *) current->data; | 262 | mailimf_address *addr = (mailimf_address *) current->data; |
262 | 263 | ||
263 | if ( !first ) { | 264 | if ( !first ) { |
264 | result.append( "," ); | 265 | result.append( "," ); |
265 | } else { | 266 | } else { |
266 | first = false; | 267 | first = false; |
267 | } | 268 | } |
268 | 269 | ||
269 | switch ( addr->ad_type ) { | 270 | switch ( addr->ad_type ) { |
270 | case MAILIMF_ADDRESS_MAILBOX: | 271 | case MAILIMF_ADDRESS_MAILBOX: |
271 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 272 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
272 | break; | 273 | break; |
273 | case MAILIMF_ADDRESS_GROUP: | 274 | case MAILIMF_ADDRESS_GROUP: |
274 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 275 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
275 | break; | 276 | break; |
276 | default: | 277 | default: |
277 | odebug << "Generic: unkown mailimf address type" << oendl; | 278 | odebug << "Generic: unkown mailimf address type" << oendl; |
278 | break; | 279 | break; |
279 | } | 280 | } |
280 | } | 281 | } |
281 | 282 | ||
282 | return result; | 283 | return result; |
283 | } | 284 | } |
284 | 285 | ||
285 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 286 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
286 | { | 287 | { |
287 | QString result( "" ); | 288 | QString result( "" ); |
288 | 289 | ||
289 | result.append( group->grp_display_name ); | 290 | result.append( group->grp_display_name ); |
290 | result.append( ": " ); | 291 | result.append( ": " ); |
291 | 292 | ||
292 | if ( group->grp_mb_list != NULL ) { | 293 | if ( group->grp_mb_list != NULL ) { |
293 | result.append( parseMailboxList( group->grp_mb_list ) ); | 294 | result.append( parseMailboxList( group->grp_mb_list ) ); |
294 | } | 295 | } |
295 | 296 | ||
296 | result.append( ";" ); | 297 | result.append( ";" ); |
297 | 298 | ||
298 | return result; | 299 | return result; |
299 | } | 300 | } |
300 | 301 | ||
301 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 302 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
302 | { | 303 | { |
303 | QString result( "" ); | 304 | QString result( "" ); |
304 | 305 | ||
305 | if ( box->mb_display_name == NULL ) { | 306 | if ( box->mb_display_name == NULL ) { |
306 | result.append( box->mb_addr_spec ); | 307 | result.append( box->mb_addr_spec ); |
307 | } else { | 308 | } else { |
308 | result.append( convert_String(box->mb_display_name).latin1() ); | 309 | result.append( convert_String(box->mb_display_name).latin1() ); |
309 | result.append( " <" ); | 310 | result.append( " <" ); |
310 | result.append( box->mb_addr_spec ); | 311 | result.append( box->mb_addr_spec ); |
311 | result.append( ">" ); | 312 | result.append( ">" ); |
312 | } | 313 | } |
313 | 314 | ||
314 | return result; | 315 | return result; |
315 | } | 316 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 9b7c0e0..fe75a15 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,1188 +1,1198 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | #include <opie2/oapplication.h> | 4 | #include <opie2/oapplication.h> |
5 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
6 | 6 | ||
7 | #include "imapwrapper.h" | 7 | #include "imapwrapper.h" |
8 | #include "mailtypes.h" | 8 | #include "mailtypes.h" |
9 | #include "logindialog.h" | 9 | #include "logindialog.h" |
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | account = a; | 15 | account = a; |
16 | m_imap = 0; | 16 | m_imap = 0; |
17 | m_Lastmbox = ""; | 17 | m_Lastmbox = ""; |
18 | } | 18 | } |
19 | 19 | ||
20 | IMAPwrapper::~IMAPwrapper() | 20 | IMAPwrapper::~IMAPwrapper() |
21 | { | 21 | { |
22 | logout(); | 22 | logout(); |
23 | } | 23 | } |
24 | 24 | ||
25 | /* to avoid to often select statements in loops etc. | 25 | /* to avoid to often select statements in loops etc. |
26 | we trust that we are logged in and connection is established!*/ | 26 | we trust that we are logged in and connection is established!*/ |
27 | int IMAPwrapper::selectMbox(const QString&mbox) | 27 | int IMAPwrapper::selectMbox(const QString&mbox) |
28 | { | 28 | { |
29 | if (mbox == m_Lastmbox) { | 29 | if (mbox == m_Lastmbox) { |
30 | return MAILIMAP_NO_ERROR; | 30 | return MAILIMAP_NO_ERROR; |
31 | } | 31 | } |
32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
33 | if ( err != MAILIMAP_NO_ERROR ) { | 33 | if ( err != MAILIMAP_NO_ERROR ) { |
34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; | 34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; |
35 | m_Lastmbox = ""; | 35 | m_Lastmbox = ""; |
36 | return err; | 36 | return err; |
37 | } | 37 | } |
38 | m_Lastmbox = mbox; | 38 | m_Lastmbox = mbox; |
39 | return err; | 39 | return err; |
40 | } | 40 | } |
41 | 41 | ||
42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
43 | { | 43 | { |
44 | qApp->processEvents(); | 44 | qApp->processEvents(); |
45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; | 45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; |
46 | } | 46 | } |
47 | 47 | ||
48 | bool IMAPwrapper::start_tls(bool force_tls) | 48 | bool IMAPwrapper::start_tls(bool force_tls) |
49 | { | 49 | { |
50 | int err; | 50 | int err; |
51 | bool try_tls; | 51 | bool try_tls; |
52 | mailimap_capability_data * cap_data = 0; | 52 | mailimap_capability_data * cap_data = 0; |
53 | 53 | ||
54 | err = mailimap_capability(m_imap,&cap_data); | 54 | err = mailimap_capability(m_imap,&cap_data); |
55 | if (err != MAILIMAP_NO_ERROR) { | 55 | if (err != MAILIMAP_NO_ERROR) { |
56 | Global::statusMessage("error getting capabilities!"); | 56 | Global::statusMessage("error getting capabilities!"); |
57 | odebug << "error getting capabilities!" << oendl; | 57 | odebug << "error getting capabilities!" << oendl; |
58 | return false; | 58 | return false; |
59 | } | 59 | } |
60 | clistiter * cur; | 60 | clistiter * cur; |
61 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 61 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
62 | struct mailimap_capability * cap; | 62 | struct mailimap_capability * cap; |
63 | cap = (struct mailimap_capability *)clist_content(cur); | 63 | cap = (struct mailimap_capability *)clist_content(cur); |
64 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 64 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
65 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 65 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
66 | try_tls = true; | 66 | try_tls = true; |
67 | break; | 67 | break; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | if (cap_data) { | 71 | if (cap_data) { |
72 | mailimap_capability_data_free(cap_data); | 72 | mailimap_capability_data_free(cap_data); |
73 | } | 73 | } |
74 | if (try_tls) { | 74 | if (try_tls) { |
75 | err = mailimap_starttls(m_imap); | 75 | err = mailimap_starttls(m_imap); |
76 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 76 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
77 | Global::statusMessage(tr("Server has no TLS support!")); | 77 | Global::statusMessage(tr("Server has no TLS support!")); |
78 | odebug << "Server has no TLS support!" << oendl; | 78 | odebug << "Server has no TLS support!" << oendl; |
79 | try_tls = false; | 79 | try_tls = false; |
80 | } else { | 80 | } else { |
81 | mailstream_low * low; | 81 | mailstream_low * low; |
82 | mailstream_low * new_low; | 82 | mailstream_low * new_low; |
83 | low = mailstream_get_low(m_imap->imap_stream); | 83 | low = mailstream_get_low(m_imap->imap_stream); |
84 | if (!low) { | 84 | if (!low) { |
85 | try_tls = false; | 85 | try_tls = false; |
86 | } else { | 86 | } else { |
87 | int fd = mailstream_low_get_fd(low); | 87 | int fd = mailstream_low_get_fd(low); |
88 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 88 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
89 | mailstream_low_free(low); | 89 | mailstream_low_free(low); |
90 | mailstream_set_low(m_imap->imap_stream, new_low); | 90 | mailstream_set_low(m_imap->imap_stream, new_low); |
91 | } else { | 91 | } else { |
92 | try_tls = false; | 92 | try_tls = false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | return try_tls; | 97 | return try_tls; |
98 | } | 98 | } |
99 | 99 | ||
100 | void IMAPwrapper::login() | 100 | void IMAPwrapper::login() |
101 | { | 101 | { |
102 | const char *server, *user, *pass; | 102 | const char *server, *user, *pass; |
103 | uint16_t port; | 103 | uint16_t port; |
104 | int err = MAILIMAP_NO_ERROR; | 104 | int err = MAILIMAP_NO_ERROR; |
105 | 105 | ||
106 | if (account->getOffline()) return; | 106 | if (account->getOffline()) return; |
107 | /* we are connected this moment */ | 107 | /* we are connected this moment */ |
108 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 108 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
109 | if (m_imap) { | 109 | if (m_imap) { |
110 | err = mailimap_noop(m_imap); | 110 | err = mailimap_noop(m_imap); |
111 | if (err!=MAILIMAP_NO_ERROR) { | 111 | if (err!=MAILIMAP_NO_ERROR) { |
112 | logout(); | 112 | logout(); |
113 | } else { | 113 | } else { |
114 | mailstream_flush(m_imap->imap_stream); | 114 | mailstream_flush(m_imap->imap_stream); |
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | server = account->getServer().latin1(); | 118 | server = account->getServer().latin1(); |
119 | port = account->getPort().toUInt(); | 119 | port = account->getPort().toUInt(); |
120 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 120 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
121 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 121 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
122 | login.show(); | 122 | login.show(); |
123 | if ( QDialog::Accepted == login.exec() ) { | 123 | if ( QDialog::Accepted == login.exec() ) { |
124 | // ok | 124 | // ok |
125 | user = login.getUser().latin1(); | 125 | user = login.getUser().latin1(); |
126 | pass = login.getPassword().latin1(); | 126 | pass = login.getPassword().latin1(); |
127 | } else { | 127 | } else { |
128 | // cancel | 128 | // cancel |
129 | odebug << "IMAP: Login canceled" << oendl; | 129 | odebug << "IMAP: Login canceled" << oendl; |
130 | return; | 130 | return; |
131 | } | 131 | } |
132 | } else { | 132 | } else { |
133 | user = account->getUser().latin1(); | 133 | user = account->getUser().latin1(); |
134 | pass = account->getPassword().latin1(); | 134 | pass = account->getPassword().latin1(); |
135 | } | 135 | } |
136 | 136 | ||
137 | m_imap = mailimap_new( 20, &imap_progress ); | 137 | m_imap = mailimap_new( 20, &imap_progress ); |
138 | 138 | ||
139 | /* connect */ | 139 | /* connect */ |
140 | bool ssl = false; | 140 | bool ssl = false; |
141 | bool try_tls = false; | 141 | bool try_tls = false; |
142 | bool force_tls = false; | 142 | bool force_tls = false; |
143 | 143 | ||
144 | if ( account->ConnectionType() == 2 ) { | 144 | if ( account->ConnectionType() == 2 ) { |
145 | ssl = true; | 145 | ssl = true; |
146 | } | 146 | } |
147 | if (account->ConnectionType()==1) { | 147 | if (account->ConnectionType()==1) { |
148 | force_tls = true; | 148 | force_tls = true; |
149 | } | 149 | } |
150 | 150 | ||
151 | if ( ssl ) { | 151 | if ( ssl ) { |
152 | odebug << "using ssl" << oendl; | 152 | odebug << "using ssl" << oendl; |
153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
154 | } else { | 154 | } else { |
155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
156 | } | 156 | } |
157 | 157 | ||
158 | if ( err != MAILIMAP_NO_ERROR && | 158 | if ( err != MAILIMAP_NO_ERROR && |
159 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 159 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
160 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 160 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
161 | QString failure = ""; | 161 | QString failure = ""; |
162 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 162 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
163 | failure="Connection refused"; | 163 | failure="Connection refused"; |
164 | } else { | 164 | } else { |
165 | failure="Unknown failure"; | 165 | failure="Unknown failure"; |
166 | } | 166 | } |
167 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 167 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
168 | mailimap_free( m_imap ); | 168 | mailimap_free( m_imap ); |
169 | m_imap = 0; | 169 | m_imap = 0; |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | 172 | ||
173 | if (!ssl) { | 173 | if (!ssl) { |
174 | try_tls = start_tls(force_tls); | 174 | try_tls = start_tls(force_tls); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool ok = true; | 177 | bool ok = true; |
178 | if (force_tls && !try_tls) { | 178 | if (force_tls && !try_tls) { |
179 | Global::statusMessage(tr("Server has no TLS support!")); | 179 | Global::statusMessage(tr("Server has no TLS support!")); |
180 | odebug << "Server has no TLS support!" << oendl; | 180 | odebug << "Server has no TLS support!" << oendl; |
181 | ok = false; | 181 | ok = false; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | /* login */ | 185 | /* login */ |
186 | 186 | ||
187 | if (ok) { | 187 | if (ok) { |
188 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 188 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
189 | if ( err != MAILIMAP_NO_ERROR ) { | 189 | if ( err != MAILIMAP_NO_ERROR ) { |
190 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 190 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
191 | ok = false; | 191 | ok = false; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | if (!ok) { | 194 | if (!ok) { |
195 | err = mailimap_close( m_imap ); | 195 | err = mailimap_close( m_imap ); |
196 | mailimap_free( m_imap ); | 196 | mailimap_free( m_imap ); |
197 | m_imap = 0; | 197 | m_imap = 0; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void IMAPwrapper::logout() | 201 | void IMAPwrapper::logout() |
202 | { | 202 | { |
203 | int err = MAILIMAP_NO_ERROR; | 203 | int err = MAILIMAP_NO_ERROR; |
204 | if (!m_imap) return; | 204 | if (!m_imap) return; |
205 | err = mailimap_logout( m_imap ); | 205 | err = mailimap_logout( m_imap ); |
206 | err = mailimap_close( m_imap ); | 206 | err = mailimap_close( m_imap ); |
207 | mailimap_free( m_imap ); | 207 | mailimap_free( m_imap ); |
208 | m_imap = 0; | 208 | m_imap = 0; |
209 | m_Lastmbox = ""; | 209 | m_Lastmbox = ""; |
210 | } | 210 | } |
211 | 211 | ||
212 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 212 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
213 | { | 213 | { |
214 | int err = MAILIMAP_NO_ERROR; | 214 | int err = MAILIMAP_NO_ERROR; |
215 | clist *result = 0; | 215 | clist *result = 0; |
216 | clistcell *current; | 216 | clistcell *current; |
217 | mailimap_fetch_type *fetchType = 0; | 217 | mailimap_fetch_type *fetchType = 0; |
218 | mailimap_set *set = 0; | 218 | mailimap_set *set = 0; |
219 | 219 | ||
220 | login(); | 220 | login(); |
221 | if (!m_imap) { | 221 | if (!m_imap) { |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | /* select mailbox READONLY for operations */ | 224 | /* select mailbox READONLY for operations */ |
225 | err = selectMbox(mailbox); | 225 | err = selectMbox(mailbox); |
226 | if ( err != MAILIMAP_NO_ERROR ) { | 226 | if ( err != MAILIMAP_NO_ERROR ) { |
227 | return; | 227 | return; |
228 | } | 228 | } |
229 | 229 | ||
230 | int last = m_imap->imap_selection_info->sel_exists; | 230 | int last = m_imap->imap_selection_info->sel_exists; |
231 | 231 | ||
232 | if (last == 0) { | 232 | if (last == 0) { |
233 | Global::statusMessage(tr("Mailbox has no mails")); | 233 | Global::statusMessage(tr("Mailbox has no mails")); |
234 | return; | 234 | return; |
235 | } else { | 235 | } else { |
236 | } | 236 | } |
237 | 237 | ||
238 | /* the range has to start at 1!!! not with 0!!!! */ | 238 | /* the range has to start at 1!!! not with 0!!!! */ |
239 | set = mailimap_set_new_interval( 1, last ); | 239 | set = mailimap_set_new_interval( 1, last ); |
240 | |||
241 | |||
242 | fetchType = mailimap_fetch_type_new_all(); | ||
243 | /* | ||
240 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 244 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
241 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 245 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
242 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 246 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
243 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 247 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
244 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 248 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
245 | 249 | */ | |
246 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 250 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
247 | mailimap_set_free( set ); | 251 | mailimap_set_free( set ); |
248 | mailimap_fetch_type_free( fetchType ); | 252 | mailimap_fetch_type_free( fetchType ); |
249 | 253 | ||
250 | QString date,subject,from; | 254 | QString date,subject,from; |
251 | 255 | ||
252 | if ( err == MAILIMAP_NO_ERROR ) { | 256 | if ( err == MAILIMAP_NO_ERROR ) { |
253 | mailimap_msg_att * msg_att; | 257 | mailimap_msg_att * msg_att; |
254 | int i = 0; | 258 | int i = 0; |
255 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 259 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
256 | ++i; | 260 | ++i; |
257 | msg_att = (mailimap_msg_att*)current->data; | 261 | msg_att = (mailimap_msg_att*)current->data; |
258 | RecMail*m = parse_list_result(msg_att); | 262 | RecMail*m = parse_list_result(msg_att); |
259 | if (m) { | 263 | if (m) { |
260 | m->setNumber(i); | 264 | m->setNumber(i); |
261 | m->setMbox(mailbox); | 265 | m->setMbox(mailbox); |
262 | m->setWrapper(this); | 266 | m->setWrapper(this); |
263 | target.append(m); | 267 | target.append(m); |
264 | } | 268 | } |
265 | } | 269 | } |
266 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 270 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
267 | } else { | 271 | } else { |
268 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 272 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
269 | } | 273 | } |
270 | if (result) mailimap_fetch_list_free(result); | 274 | if (result) mailimap_fetch_list_free(result); |
271 | } | 275 | } |
272 | 276 | ||
273 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 277 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
274 | { | 278 | { |
275 | const char *path, *mask; | 279 | const char *path, *mask; |
276 | int err = MAILIMAP_NO_ERROR; | 280 | int err = MAILIMAP_NO_ERROR; |
277 | clist *result = 0; | 281 | clist *result = 0; |
278 | clistcell *current = 0; | 282 | clistcell *current = 0; |
279 | clistcell*cur_flag = 0; | 283 | clistcell*cur_flag = 0; |
280 | mailimap_mbx_list_flags*bflags = 0; | 284 | mailimap_mbx_list_flags*bflags = 0; |
281 | 285 | ||
282 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 286 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
283 | login(); | 287 | login(); |
284 | if (!m_imap) { | 288 | if (!m_imap) { |
285 | return folders; | 289 | return folders; |
286 | } | 290 | } |
287 | 291 | ||
288 | /* | 292 | /* |
289 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 293 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
290 | * We must not forget to filter them out in next loop! | 294 | * We must not forget to filter them out in next loop! |
291 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 295 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
292 | */ | 296 | */ |
293 | QString temp; | 297 | QString temp; |
294 | mask = "INBOX" ; | 298 | mask = "INBOX" ; |
295 | mailimap_mailbox_list *list; | 299 | mailimap_mailbox_list *list; |
296 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 300 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
297 | QString del; | 301 | QString del; |
298 | bool selectable = true; | 302 | bool selectable = true; |
299 | bool no_inferiors = false; | 303 | bool no_inferiors = false; |
300 | if ( err == MAILIMAP_NO_ERROR ) { | 304 | if ( err == MAILIMAP_NO_ERROR ) { |
301 | current = result->first; | 305 | current = result->first; |
302 | for ( int i = result->count; i > 0; i-- ) { | 306 | for ( int i = result->count; i > 0; i-- ) { |
303 | list = (mailimap_mailbox_list *) current->data; | 307 | list = (mailimap_mailbox_list *) current->data; |
304 | // it is better use the deep copy mechanism of qt itself | 308 | // it is better use the deep copy mechanism of qt itself |
305 | // instead of using strdup! | 309 | // instead of using strdup! |
306 | temp = list->mb_name; | 310 | temp = list->mb_name; |
307 | del = list->mb_delimiter; | 311 | del = list->mb_delimiter; |
308 | current = current->next; | 312 | current = current->next; |
309 | if ( (bflags = list->mb_flag) ) { | 313 | if ( (bflags = list->mb_flag) ) { |
310 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 314 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
311 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 315 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
312 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 316 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
313 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 317 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
314 | no_inferiors = true; | 318 | no_inferiors = true; |
315 | } | 319 | } |
316 | } | 320 | } |
317 | } | 321 | } |
318 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 322 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
319 | } | 323 | } |
320 | } else { | 324 | } else { |
321 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; | 325 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; |
322 | } | 326 | } |
323 | mailimap_list_result_free( result ); | 327 | mailimap_list_result_free( result ); |
324 | 328 | ||
325 | /* | 329 | /* |
326 | * second stage - get the other then inbox folders | 330 | * second stage - get the other then inbox folders |
327 | */ | 331 | */ |
328 | mask = "*" ; | 332 | mask = "*" ; |
329 | path = account->getPrefix().latin1(); | 333 | path = account->getPrefix().latin1(); |
330 | if (!path) path = ""; | 334 | if (!path) path = ""; |
331 | odebug << path << oendl; | 335 | odebug << path << oendl; |
332 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 336 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
333 | if ( err == MAILIMAP_NO_ERROR ) { | 337 | if ( err == MAILIMAP_NO_ERROR ) { |
334 | current = result->first; | 338 | current = result->first; |
335 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 339 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
336 | no_inferiors = false; | 340 | no_inferiors = false; |
337 | list = (mailimap_mailbox_list *) current->data; | 341 | list = (mailimap_mailbox_list *) current->data; |
338 | // it is better use the deep copy mechanism of qt itself | 342 | // it is better use the deep copy mechanism of qt itself |
339 | // instead of using strdup! | 343 | // instead of using strdup! |
340 | temp = list->mb_name; | 344 | temp = list->mb_name; |
341 | if (temp.lower()=="inbox") | 345 | if (temp.lower()=="inbox") |
342 | continue; | 346 | continue; |
343 | if (temp.lower()==account->getPrefix().lower()) | 347 | if (temp.lower()==account->getPrefix().lower()) |
344 | continue; | 348 | continue; |
345 | if ( (bflags = list->mb_flag) ) { | 349 | if ( (bflags = list->mb_flag) ) { |
346 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 350 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
347 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 351 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
348 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 352 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
349 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 353 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
350 | no_inferiors = true; | 354 | no_inferiors = true; |
351 | } | 355 | } |
352 | } | 356 | } |
353 | } | 357 | } |
354 | del = list->mb_delimiter; | 358 | del = list->mb_delimiter; |
355 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 359 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
356 | } | 360 | } |
357 | } else { | 361 | } else { |
358 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; | 362 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; |
359 | } | 363 | } |
360 | if (result) mailimap_list_result_free( result ); | 364 | if (result) mailimap_list_result_free( result ); |
361 | return folders; | 365 | return folders; |
362 | } | 366 | } |
363 | 367 | ||
364 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
365 | { | 369 | { |
366 | RecMail * m = 0; | 370 | RecMail * m = 0; |
367 | mailimap_msg_att_item *item=0; | 371 | mailimap_msg_att_item *item=0; |
368 | clistcell *current,*c,*cf; | 372 | clistcell *current,*c,*cf; |
369 | mailimap_msg_att_dynamic*flist; | 373 | mailimap_msg_att_dynamic*flist; |
370 | mailimap_flag_fetch*cflag; | 374 | mailimap_flag_fetch*cflag; |
371 | int size; | 375 | int size; |
372 | QBitArray mFlags(7); | 376 | QBitArray mFlags(7); |
373 | QStringList addresslist; | 377 | QStringList addresslist; |
374 | 378 | ||
375 | if (!m_att) { | 379 | if (!m_att) { |
376 | return m; | 380 | return m; |
377 | } | 381 | } |
382 | size = 0; | ||
378 | m = new RecMail(); | 383 | m = new RecMail(); |
379 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
380 | current = c; | 385 | current = c; |
381 | size = 0; | ||
382 | item = (mailimap_msg_att_item*)current->data; | 386 | item = (mailimap_msg_att_item*)current->data; |
383 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
384 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 388 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
385 | if (!flist->att_list) { | 389 | if (!flist->att_list) { |
386 | continue; | 390 | continue; |
387 | } | 391 | } |
388 | cf = flist->att_list->first; | 392 | cf = flist->att_list->first; |
389 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 393 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
390 | cflag = (mailimap_flag_fetch*)cf->data; | 394 | cflag = (mailimap_flag_fetch*)cf->data; |
391 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 395 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
392 | switch (cflag->fl_flag->fl_type) { | 396 | switch (cflag->fl_flag->fl_type) { |
393 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 397 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
394 | mFlags.setBit(FLAG_ANSWERED); | 398 | mFlags.setBit(FLAG_ANSWERED); |
395 | break; | 399 | break; |
396 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 400 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
397 | mFlags.setBit(FLAG_FLAGGED); | 401 | mFlags.setBit(FLAG_FLAGGED); |
398 | break; | 402 | break; |
399 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 403 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
400 | mFlags.setBit(FLAG_DELETED); | 404 | mFlags.setBit(FLAG_DELETED); |
401 | break; | 405 | break; |
402 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 406 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
403 | mFlags.setBit(FLAG_SEEN); | 407 | mFlags.setBit(FLAG_SEEN); |
404 | break; | 408 | break; |
405 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 409 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
406 | mFlags.setBit(FLAG_DRAFT); | 410 | mFlags.setBit(FLAG_DRAFT); |
407 | break; | 411 | break; |
408 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 412 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
409 | break; | 413 | break; |
410 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 414 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
411 | break; | 415 | break; |
412 | default: | 416 | default: |
413 | break; | 417 | break; |
414 | } | 418 | } |
415 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 419 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
416 | mFlags.setBit(FLAG_RECENT); | 420 | mFlags.setBit(FLAG_RECENT); |
417 | } | 421 | } |
418 | } | 422 | } |
419 | continue; | 423 | continue; |
420 | } | 424 | } |
421 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 425 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
422 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 426 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
423 | m->setDate(head->env_date); | 427 | m->setDate(head->env_date); |
424 | m->setSubject(convert_String((const char*)head->env_subject)); | 428 | m->setSubject(convert_String((const char*)head->env_subject)); |
425 | //m->setSubject(head->env_subject); | 429 | //m->setSubject(head->env_subject); |
426 | if (head->env_from!=NULL) { | 430 | if (head->env_from!=NULL) { |
427 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 431 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
428 | if (addresslist.count()) { | 432 | if (addresslist.count()) { |
429 | m->setFrom(addresslist.first()); | 433 | m->setFrom(addresslist.first()); |
430 | } | 434 | } |
431 | } | 435 | } |
432 | if (head->env_to!=NULL) { | 436 | if (head->env_to!=NULL) { |
433 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 437 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
434 | m->setTo(addresslist); | 438 | m->setTo(addresslist); |
435 | } | 439 | } |
436 | if (head->env_cc!=NULL) { | 440 | if (head->env_cc!=NULL) { |
437 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 441 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
438 | m->setCC(addresslist); | 442 | m->setCC(addresslist); |
439 | } | 443 | } |
440 | if (head->env_bcc!=NULL) { | 444 | if (head->env_bcc!=NULL) { |
441 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 445 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
442 | m->setBcc(addresslist); | 446 | m->setBcc(addresslist); |
443 | } | 447 | } |
444 | /* reply to address, eg. email. */ | 448 | /* reply to address, eg. email. */ |
445 | if (head->env_reply_to!=NULL) { | 449 | if (head->env_reply_to!=NULL) { |
446 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 450 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
447 | if (addresslist.count()) { | 451 | if (addresslist.count()) { |
448 | m->setReplyto(addresslist.first()); | 452 | m->setReplyto(addresslist.first()); |
449 | } | 453 | } |
450 | } | 454 | } |
451 | if (head->env_in_reply_to!=NULL) { | 455 | if (head->env_in_reply_to!=NULL) { |
452 | QString h(head->env_in_reply_to); | 456 | QString h(head->env_in_reply_to); |
453 | while (h.length()>0 && h[0]=='<') { | 457 | while (h.length()>0 && h[0]=='<') { |
454 | h.remove(0,1); | 458 | h.remove(0,1); |
455 | } | 459 | } |
456 | while (h.length()>0 && h[h.length()-1]=='>') { | 460 | while (h.length()>0 && h[h.length()-1]=='>') { |
457 | h.remove(h.length()-1,1); | 461 | h.remove(h.length()-1,1); |
458 | } | 462 | } |
459 | if (h.length()>0) { | 463 | if (h.length()>0) { |
460 | m->setInreply(QStringList(h)); | 464 | m->setInreply(QStringList(h)); |
461 | } | 465 | } |
462 | } | 466 | } |
463 | if (head->env_message_id) { | 467 | if (head->env_message_id) { |
464 | m->setMsgid(QString(head->env_message_id)); | 468 | m->setMsgid(QString(head->env_message_id)); |
465 | } | 469 | } |
466 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
467 | #if 0 | 471 | #if 0 |
468 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 472 | mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date; |
473 | if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0; | ||
474 | //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); | ||
475 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | ||
476 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; | ||
477 | timestring.sprintf(timestring+" %+05i",date->dt_zone); | ||
478 | m->setDate(timestring); | ||
469 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 479 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
470 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; | 480 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; |
471 | odebug << da.toString() << oendl; | 481 | odebug << da.toString() << oendl; |
472 | #endif | 482 | #endif |
473 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 483 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
474 | size = item->att_data.att_static->att_data.att_rfc822_size; | 484 | //size = item->att_data.att_static->att_data.att_rfc822_size; |
485 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); | ||
475 | } | 486 | } |
476 | } | 487 | } |
477 | /* msg is already deleted */ | 488 | /* msg is already deleted */ |
478 | if (mFlags.testBit(FLAG_DELETED) && m) { | 489 | if (mFlags.testBit(FLAG_DELETED) && m) { |
479 | delete m; | 490 | delete m; |
480 | m = 0; | 491 | m = 0; |
481 | } | 492 | } |
482 | if (m) { | 493 | if (m) { |
483 | m->setFlags(mFlags); | 494 | m->setFlags(mFlags); |
484 | m->setMsgsize(size); | ||
485 | } | 495 | } |
486 | return m; | 496 | return m; |
487 | } | 497 | } |
488 | 498 | ||
489 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 499 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
490 | { | 500 | { |
491 | RecBodyP body = new RecBody(); | 501 | RecBodyP body = new RecBody(); |
492 | const char *mb; | 502 | const char *mb; |
493 | int err = MAILIMAP_NO_ERROR; | 503 | int err = MAILIMAP_NO_ERROR; |
494 | clist *result = 0; | 504 | clist *result = 0; |
495 | clistcell *current; | 505 | clistcell *current; |
496 | mailimap_fetch_att *fetchAtt = 0; | 506 | mailimap_fetch_att *fetchAtt = 0; |
497 | mailimap_fetch_type *fetchType = 0; | 507 | mailimap_fetch_type *fetchType = 0; |
498 | mailimap_set *set = 0; | 508 | mailimap_set *set = 0; |
499 | mailimap_body*body_desc = 0; | 509 | mailimap_body*body_desc = 0; |
500 | 510 | ||
501 | mb = mail->getMbox().latin1(); | 511 | mb = mail->getMbox().latin1(); |
502 | 512 | ||
503 | login(); | 513 | login(); |
504 | if (!m_imap) { | 514 | if (!m_imap) { |
505 | return body; | 515 | return body; |
506 | } | 516 | } |
507 | err = selectMbox(mail->getMbox()); | 517 | err = selectMbox(mail->getMbox()); |
508 | if ( err != MAILIMAP_NO_ERROR ) { | 518 | if ( err != MAILIMAP_NO_ERROR ) { |
509 | return body; | 519 | return body; |
510 | } | 520 | } |
511 | 521 | ||
512 | /* the range has to start at 1!!! not with 0!!!! */ | 522 | /* the range has to start at 1!!! not with 0!!!! */ |
513 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 523 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
514 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 524 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
515 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 525 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
516 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 526 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
517 | mailimap_set_free( set ); | 527 | mailimap_set_free( set ); |
518 | mailimap_fetch_type_free( fetchType ); | 528 | mailimap_fetch_type_free( fetchType ); |
519 | 529 | ||
520 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 530 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
521 | mailimap_msg_att * msg_att; | 531 | mailimap_msg_att * msg_att; |
522 | msg_att = (mailimap_msg_att*)current->data; | 532 | msg_att = (mailimap_msg_att*)current->data; |
523 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 533 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
524 | QValueList<int> path; | 534 | QValueList<int> path; |
525 | body_desc = item->att_data.att_static->att_data.att_body; | 535 | body_desc = item->att_data.att_static->att_data.att_body; |
526 | traverseBody(mail,body_desc,body,0,path); | 536 | traverseBody(mail,body_desc,body,0,path); |
527 | } else { | 537 | } else { |
528 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 538 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
529 | } | 539 | } |
530 | if (result) mailimap_fetch_list_free(result); | 540 | if (result) mailimap_fetch_list_free(result); |
531 | return body; | 541 | return body; |
532 | } | 542 | } |
533 | 543 | ||
534 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 544 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
535 | { | 545 | { |
536 | QStringList l; | 546 | QStringList l; |
537 | QString from; | 547 | QString from; |
538 | bool named_from; | 548 | bool named_from; |
539 | clistcell *current = NULL; | 549 | clistcell *current = NULL; |
540 | mailimap_address * current_address=NULL; | 550 | mailimap_address * current_address=NULL; |
541 | if (!list) { | 551 | if (!list) { |
542 | return l; | 552 | return l; |
543 | } | 553 | } |
544 | unsigned int count = 0; | 554 | unsigned int count = 0; |
545 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 555 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
546 | from = ""; | 556 | from = ""; |
547 | named_from = false; | 557 | named_from = false; |
548 | current_address=(mailimap_address*)current->data; | 558 | current_address=(mailimap_address*)current->data; |
549 | if (current_address->ad_personal_name){ | 559 | if (current_address->ad_personal_name){ |
550 | from+=convert_String((const char*)current_address->ad_personal_name); | 560 | from+=convert_String((const char*)current_address->ad_personal_name); |
551 | from+=" "; | 561 | from+=" "; |
552 | named_from = true; | 562 | named_from = true; |
553 | } | 563 | } |
554 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 564 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
555 | from+="<"; | 565 | from+="<"; |
556 | } | 566 | } |
557 | if (current_address->ad_mailbox_name) { | 567 | if (current_address->ad_mailbox_name) { |
558 | from+=QString(current_address->ad_mailbox_name); | 568 | from+=QString(current_address->ad_mailbox_name); |
559 | from+="@"; | 569 | from+="@"; |
560 | } | 570 | } |
561 | if (current_address->ad_host_name) { | 571 | if (current_address->ad_host_name) { |
562 | from+=QString(current_address->ad_host_name); | 572 | from+=QString(current_address->ad_host_name); |
563 | } | 573 | } |
564 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 574 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
565 | from+=">"; | 575 | from+=">"; |
566 | } | 576 | } |
567 | l.append(QString(from)); | 577 | l.append(QString(from)); |
568 | if (++count > 99) { | 578 | if (++count > 99) { |
569 | break; | 579 | break; |
570 | } | 580 | } |
571 | } | 581 | } |
572 | return l; | 582 | return l; |
573 | } | 583 | } |
574 | 584 | ||
575 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 585 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
576 | { | 586 | { |
577 | encodedString*res=new encodedString; | 587 | encodedString*res=new encodedString; |
578 | int err; | 588 | int err; |
579 | mailimap_fetch_type *fetchType; | 589 | mailimap_fetch_type *fetchType; |
580 | mailimap_set *set; | 590 | mailimap_set *set; |
581 | clistcell*current,*cur; | 591 | clistcell*current,*cur; |
582 | mailimap_section_part * section_part = 0; | 592 | mailimap_section_part * section_part = 0; |
583 | mailimap_section_spec * section_spec = 0; | 593 | mailimap_section_spec * section_spec = 0; |
584 | mailimap_section * section = 0; | 594 | mailimap_section * section = 0; |
585 | mailimap_fetch_att * fetch_att = 0; | 595 | mailimap_fetch_att * fetch_att = 0; |
586 | 596 | ||
587 | login(); | 597 | login(); |
588 | if (!m_imap) { | 598 | if (!m_imap) { |
589 | return res; | 599 | return res; |
590 | } | 600 | } |
591 | if (!internal_call) { | 601 | if (!internal_call) { |
592 | err = selectMbox(mail->getMbox()); | 602 | err = selectMbox(mail->getMbox()); |
593 | if ( err != MAILIMAP_NO_ERROR ) { | 603 | if ( err != MAILIMAP_NO_ERROR ) { |
594 | return res; | 604 | return res; |
595 | } | 605 | } |
596 | } | 606 | } |
597 | set = mailimap_set_new_single(mail->getNumber()); | 607 | set = mailimap_set_new_single(mail->getNumber()); |
598 | 608 | ||
599 | clist*id_list = 0; | 609 | clist*id_list = 0; |
600 | 610 | ||
601 | /* if path == empty then its a request for the whole rfc822 mail and generates | 611 | /* if path == empty then its a request for the whole rfc822 mail and generates |
602 | a "fetch <id> (body[])" statement on imap server */ | 612 | a "fetch <id> (body[])" statement on imap server */ |
603 | if (path.count()>0 ) { | 613 | if (path.count()>0 ) { |
604 | id_list = clist_new(); | 614 | id_list = clist_new(); |
605 | for (unsigned j=0; j < path.count();++j) { | 615 | for (unsigned j=0; j < path.count();++j) { |
606 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 616 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
607 | *p_id = path[j]; | 617 | *p_id = path[j]; |
608 | clist_append(id_list,p_id); | 618 | clist_append(id_list,p_id); |
609 | } | 619 | } |
610 | section_part = mailimap_section_part_new(id_list); | 620 | section_part = mailimap_section_part_new(id_list); |
611 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 621 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
612 | } | 622 | } |
613 | 623 | ||
614 | section = mailimap_section_new(section_spec); | 624 | section = mailimap_section_new(section_spec); |
615 | fetch_att = mailimap_fetch_att_new_body_section(section); | 625 | fetch_att = mailimap_fetch_att_new_body_section(section); |
616 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 626 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
617 | 627 | ||
618 | clist*result = 0; | 628 | clist*result = 0; |
619 | 629 | ||
620 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 630 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
621 | mailimap_set_free( set ); | 631 | mailimap_set_free( set ); |
622 | mailimap_fetch_type_free( fetchType ); | 632 | mailimap_fetch_type_free( fetchType ); |
623 | 633 | ||
624 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 634 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
625 | mailimap_msg_att * msg_att; | 635 | mailimap_msg_att * msg_att; |
626 | msg_att = (mailimap_msg_att*)current->data; | 636 | msg_att = (mailimap_msg_att*)current->data; |
627 | mailimap_msg_att_item*msg_att_item; | 637 | mailimap_msg_att_item*msg_att_item; |
628 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 638 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
629 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 639 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
630 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 640 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
631 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 641 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
632 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 642 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
633 | /* detach - we take over the content */ | 643 | /* detach - we take over the content */ |
634 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 644 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
635 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 645 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
636 | } | 646 | } |
637 | } | 647 | } |
638 | } | 648 | } |
639 | } else { | 649 | } else { |
640 | odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 650 | odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
641 | } | 651 | } |
642 | if (result) mailimap_fetch_list_free(result); | 652 | if (result) mailimap_fetch_list_free(result); |
643 | return res; | 653 | return res; |
644 | } | 654 | } |
645 | 655 | ||
646 | /* current_recursion is for recursive calls. | 656 | /* current_recursion is for recursive calls. |
647 | current_count means the position inside the internal loop! */ | 657 | current_count means the position inside the internal loop! */ |
648 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 658 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
649 | int current_recursion,QValueList<int>recList,int current_count) | 659 | int current_recursion,QValueList<int>recList,int current_count) |
650 | { | 660 | { |
651 | if (!body || current_recursion>=10) { | 661 | if (!body || current_recursion>=10) { |
652 | return; | 662 | return; |
653 | } | 663 | } |
654 | switch (body->bd_type) { | 664 | switch (body->bd_type) { |
655 | case MAILIMAP_BODY_1PART: | 665 | case MAILIMAP_BODY_1PART: |
656 | { | 666 | { |
657 | QValueList<int>countlist = recList; | 667 | QValueList<int>countlist = recList; |
658 | countlist.append(current_count); | 668 | countlist.append(current_count); |
659 | RecPartP currentPart = new RecPart(); | 669 | RecPartP currentPart = new RecPart(); |
660 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 670 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
661 | QString id(""); | 671 | QString id(""); |
662 | currentPart->setPositionlist(countlist); | 672 | currentPart->setPositionlist(countlist); |
663 | for (unsigned int j = 0; j < countlist.count();++j) { | 673 | for (unsigned int j = 0; j < countlist.count();++j) { |
664 | id+=(j>0?" ":""); | 674 | id+=(j>0?" ":""); |
665 | id+=QString("%1").arg(countlist[j]); | 675 | id+=QString("%1").arg(countlist[j]); |
666 | } | 676 | } |
667 | odebug << "ID = " << id.latin1() << "" << oendl; | 677 | odebug << "ID = " << id.latin1() << "" << oendl; |
668 | currentPart->setIdentifier(id); | 678 | currentPart->setIdentifier(id); |
669 | fillSinglePart(currentPart,part1); | 679 | fillSinglePart(currentPart,part1); |
670 | /* important: Check for is NULL 'cause a body can be empty! | 680 | /* important: Check for is NULL 'cause a body can be empty! |
671 | And we put it only into the mail if it is the FIRST part */ | 681 | And we put it only into the mail if it is the FIRST part */ |
672 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 682 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
673 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 683 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
674 | target_body->setDescription(currentPart); | 684 | target_body->setDescription(currentPart); |
675 | target_body->setBodytext(body_text); | 685 | target_body->setBodytext(body_text); |
676 | if (countlist.count()>1) { | 686 | if (countlist.count()>1) { |
677 | target_body->addPart(currentPart); | 687 | target_body->addPart(currentPart); |
678 | } | 688 | } |
679 | } else { | 689 | } else { |
680 | target_body->addPart(currentPart); | 690 | target_body->addPart(currentPart); |
681 | } | 691 | } |
682 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 692 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
683 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 693 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
684 | } | 694 | } |
685 | } | 695 | } |
686 | break; | 696 | break; |
687 | case MAILIMAP_BODY_MPART: | 697 | case MAILIMAP_BODY_MPART: |
688 | { | 698 | { |
689 | QValueList<int>countlist = recList; | 699 | QValueList<int>countlist = recList; |
690 | clistcell*current=0; | 700 | clistcell*current=0; |
691 | mailimap_body*current_body=0; | 701 | mailimap_body*current_body=0; |
692 | unsigned int ccount = 1; | 702 | unsigned int ccount = 1; |
693 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 703 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
694 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 704 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
695 | current_body = (mailimap_body*)current->data; | 705 | current_body = (mailimap_body*)current->data; |
696 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 706 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
697 | RecPartP targetPart = new RecPart(); | 707 | RecPartP targetPart = new RecPart(); |
698 | targetPart->setType("multipart"); | 708 | targetPart->setType("multipart"); |
699 | fillMultiPart(targetPart,mailDescription); | 709 | fillMultiPart(targetPart,mailDescription); |
700 | countlist.append(current_count); | 710 | countlist.append(current_count); |
701 | targetPart->setPositionlist(countlist); | 711 | targetPart->setPositionlist(countlist); |
702 | target_body->addPart(targetPart); | 712 | target_body->addPart(targetPart); |
703 | QString id(""); | 713 | QString id(""); |
704 | for (unsigned int j = 0; j < countlist.count();++j) { | 714 | for (unsigned int j = 0; j < countlist.count();++j) { |
705 | id+=(j>0?" ":""); | 715 | id+=(j>0?" ":""); |
706 | id+=QString("%1").arg(countlist[j]); | 716 | id+=QString("%1").arg(countlist[j]); |
707 | } | 717 | } |
708 | odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 718 | odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
709 | } | 719 | } |
710 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 720 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
711 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 721 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
712 | countlist = recList; | 722 | countlist = recList; |
713 | } | 723 | } |
714 | ++ccount; | 724 | ++ccount; |
715 | } | 725 | } |
716 | } | 726 | } |
717 | break; | 727 | break; |
718 | default: | 728 | default: |
719 | break; | 729 | break; |
720 | } | 730 | } |
721 | } | 731 | } |
722 | 732 | ||
723 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 733 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
724 | { | 734 | { |
725 | if (!Description) { | 735 | if (!Description) { |
726 | return; | 736 | return; |
727 | } | 737 | } |
728 | switch (Description->bd_type) { | 738 | switch (Description->bd_type) { |
729 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 739 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
730 | target_part->setType("text"); | 740 | target_part->setType("text"); |
731 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 741 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
732 | break; | 742 | break; |
733 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 743 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
734 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 744 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
735 | break; | 745 | break; |
736 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 746 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
737 | target_part->setType("message"); | 747 | target_part->setType("message"); |
738 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 748 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
739 | break; | 749 | break; |
740 | default: | 750 | default: |
741 | break; | 751 | break; |
742 | } | 752 | } |
743 | } | 753 | } |
744 | 754 | ||
745 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 755 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
746 | { | 756 | { |
747 | if (!which) { | 757 | if (!which) { |
748 | return; | 758 | return; |
749 | } | 759 | } |
750 | QString sub; | 760 | QString sub; |
751 | sub = which->bd_media_text; | 761 | sub = which->bd_media_text; |
752 | odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 762 | odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
753 | target_part->setSubtype(sub.lower()); | 763 | target_part->setSubtype(sub.lower()); |
754 | target_part->setLines(which->bd_lines); | 764 | target_part->setLines(which->bd_lines); |
755 | fillBodyFields(target_part,which->bd_fields); | 765 | fillBodyFields(target_part,which->bd_fields); |
756 | } | 766 | } |
757 | 767 | ||
758 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 768 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
759 | { | 769 | { |
760 | if (!which) { | 770 | if (!which) { |
761 | return; | 771 | return; |
762 | } | 772 | } |
763 | target_part->setSubtype("rfc822"); | 773 | target_part->setSubtype("rfc822"); |
764 | odebug << "Message part" << oendl; | 774 | odebug << "Message part" << oendl; |
765 | /* we set this type to text/plain */ | 775 | /* we set this type to text/plain */ |
766 | target_part->setLines(which->bd_lines); | 776 | target_part->setLines(which->bd_lines); |
767 | fillBodyFields(target_part,which->bd_fields); | 777 | fillBodyFields(target_part,which->bd_fields); |
768 | } | 778 | } |
769 | 779 | ||
770 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 780 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
771 | { | 781 | { |
772 | if (!which) return; | 782 | if (!which) return; |
773 | QString sub = which->bd_media_subtype; | 783 | QString sub = which->bd_media_subtype; |
774 | target_part->setSubtype(sub.lower()); | 784 | target_part->setSubtype(sub.lower()); |
775 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 785 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
776 | clistcell*cur = 0; | 786 | clistcell*cur = 0; |
777 | mailimap_single_body_fld_param*param=0; | 787 | mailimap_single_body_fld_param*param=0; |
778 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 788 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
779 | param = (mailimap_single_body_fld_param*)cur->data; | 789 | param = (mailimap_single_body_fld_param*)cur->data; |
780 | if (param) { | 790 | if (param) { |
781 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 791 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
782 | } | 792 | } |
783 | } | 793 | } |
784 | } | 794 | } |
785 | } | 795 | } |
786 | 796 | ||
787 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 797 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
788 | { | 798 | { |
789 | if (!which) { | 799 | if (!which) { |
790 | return; | 800 | return; |
791 | } | 801 | } |
792 | QString type,sub; | 802 | QString type,sub; |
793 | switch (which->bd_media_basic->med_type) { | 803 | switch (which->bd_media_basic->med_type) { |
794 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 804 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
795 | type = "application"; | 805 | type = "application"; |
796 | break; | 806 | break; |
797 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 807 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
798 | type = "audio"; | 808 | type = "audio"; |
799 | break; | 809 | break; |
800 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 810 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
801 | type = "image"; | 811 | type = "image"; |
802 | break; | 812 | break; |
803 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 813 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
804 | type = "message"; | 814 | type = "message"; |
805 | break; | 815 | break; |
806 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 816 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
807 | type = "video"; | 817 | type = "video"; |
808 | break; | 818 | break; |
809 | case MAILIMAP_MEDIA_BASIC_OTHER: | 819 | case MAILIMAP_MEDIA_BASIC_OTHER: |
810 | default: | 820 | default: |
811 | if (which->bd_media_basic->med_basic_type) { | 821 | if (which->bd_media_basic->med_basic_type) { |
812 | type = which->bd_media_basic->med_basic_type; | 822 | type = which->bd_media_basic->med_basic_type; |
813 | } else { | 823 | } else { |
814 | type = ""; | 824 | type = ""; |
815 | } | 825 | } |
816 | break; | 826 | break; |
817 | } | 827 | } |
818 | if (which->bd_media_basic->med_subtype) { | 828 | if (which->bd_media_basic->med_subtype) { |
819 | sub = which->bd_media_basic->med_subtype; | 829 | sub = which->bd_media_basic->med_subtype; |
820 | } else { | 830 | } else { |
821 | sub = ""; | 831 | sub = ""; |
822 | } | 832 | } |
823 | odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 833 | odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
824 | target_part->setType(type.lower()); | 834 | target_part->setType(type.lower()); |
825 | target_part->setSubtype(sub.lower()); | 835 | target_part->setSubtype(sub.lower()); |
826 | fillBodyFields(target_part,which->bd_fields); | 836 | fillBodyFields(target_part,which->bd_fields); |
827 | } | 837 | } |
828 | 838 | ||
829 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 839 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
830 | { | 840 | { |
831 | if (!which) return; | 841 | if (!which) return; |
832 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 842 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
833 | clistcell*cur; | 843 | clistcell*cur; |
834 | mailimap_single_body_fld_param*param=0; | 844 | mailimap_single_body_fld_param*param=0; |
835 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 845 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
836 | param = (mailimap_single_body_fld_param*)cur->data; | 846 | param = (mailimap_single_body_fld_param*)cur->data; |
837 | if (param) { | 847 | if (param) { |
838 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 848 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
839 | } | 849 | } |
840 | } | 850 | } |
841 | } | 851 | } |
842 | mailimap_body_fld_enc*enc = which->bd_encoding; | 852 | mailimap_body_fld_enc*enc = which->bd_encoding; |
843 | QString encoding(""); | 853 | QString encoding(""); |
844 | switch (enc->enc_type) { | 854 | switch (enc->enc_type) { |
845 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 855 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
846 | encoding = "7bit"; | 856 | encoding = "7bit"; |
847 | break; | 857 | break; |
848 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 858 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
849 | encoding = "8bit"; | 859 | encoding = "8bit"; |
850 | break; | 860 | break; |
851 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 861 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
852 | encoding="binary"; | 862 | encoding="binary"; |
853 | break; | 863 | break; |
854 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 864 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
855 | encoding="base64"; | 865 | encoding="base64"; |
856 | break; | 866 | break; |
857 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 867 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
858 | encoding="quoted-printable"; | 868 | encoding="quoted-printable"; |
859 | break; | 869 | break; |
860 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 870 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
861 | default: | 871 | default: |
862 | if (enc->enc_value) { | 872 | if (enc->enc_value) { |
863 | char*t=enc->enc_value; | 873 | char*t=enc->enc_value; |
864 | encoding=QString(enc->enc_value); | 874 | encoding=QString(enc->enc_value); |
865 | enc->enc_value=0L; | 875 | enc->enc_value=0L; |
866 | free(t); | 876 | free(t); |
867 | } | 877 | } |
868 | } | 878 | } |
869 | if (which->bd_description) { | 879 | if (which->bd_description) { |
870 | target_part->setDescription(QString(which->bd_description)); | 880 | target_part->setDescription(QString(which->bd_description)); |
871 | } | 881 | } |
872 | target_part->setEncoding(encoding); | 882 | target_part->setEncoding(encoding); |
873 | target_part->setSize(which->bd_size); | 883 | target_part->setSize(which->bd_size); |
874 | } | 884 | } |
875 | 885 | ||
876 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 886 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
877 | { | 887 | { |
878 | mailimap_flag_list*flist; | 888 | mailimap_flag_list*flist; |
879 | mailimap_set *set; | 889 | mailimap_set *set; |
880 | mailimap_store_att_flags * store_flags; | 890 | mailimap_store_att_flags * store_flags; |
881 | int err; | 891 | int err; |
882 | login(); | 892 | login(); |
883 | if (!m_imap) { | 893 | if (!m_imap) { |
884 | return; | 894 | return; |
885 | } | 895 | } |
886 | err = selectMbox(mail->getMbox()); | 896 | err = selectMbox(mail->getMbox()); |
887 | if ( err != MAILIMAP_NO_ERROR ) { | 897 | if ( err != MAILIMAP_NO_ERROR ) { |
888 | return; | 898 | return; |
889 | } | 899 | } |
890 | flist = mailimap_flag_list_new_empty(); | 900 | flist = mailimap_flag_list_new_empty(); |
891 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 901 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
892 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 902 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
893 | set = mailimap_set_new_single(mail->getNumber()); | 903 | set = mailimap_set_new_single(mail->getNumber()); |
894 | err = mailimap_store(m_imap,set,store_flags); | 904 | err = mailimap_store(m_imap,set,store_flags); |
895 | mailimap_set_free( set ); | 905 | mailimap_set_free( set ); |
896 | mailimap_store_att_flags_free(store_flags); | 906 | mailimap_store_att_flags_free(store_flags); |
897 | 907 | ||
898 | if (err != MAILIMAP_NO_ERROR) { | 908 | if (err != MAILIMAP_NO_ERROR) { |
899 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 909 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
900 | return; | 910 | return; |
901 | } | 911 | } |
902 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 912 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
903 | /* should we realy do that at this moment? */ | 913 | /* should we realy do that at this moment? */ |
904 | err = mailimap_expunge(m_imap); | 914 | err = mailimap_expunge(m_imap); |
905 | if (err != MAILIMAP_NO_ERROR) { | 915 | if (err != MAILIMAP_NO_ERROR) { |
906 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 916 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
907 | } | 917 | } |
908 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 918 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
909 | } | 919 | } |
910 | 920 | ||
911 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 921 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
912 | { | 922 | { |
913 | mailimap_flag_list*flist; | 923 | mailimap_flag_list*flist; |
914 | mailimap_set *set; | 924 | mailimap_set *set; |
915 | mailimap_store_att_flags * store_flags; | 925 | mailimap_store_att_flags * store_flags; |
916 | int err; | 926 | int err; |
917 | login(); | 927 | login(); |
918 | if (!m_imap) { | 928 | if (!m_imap) { |
919 | return; | 929 | return; |
920 | } | 930 | } |
921 | err = selectMbox(mail->getMbox()); | 931 | err = selectMbox(mail->getMbox()); |
922 | if ( err != MAILIMAP_NO_ERROR ) { | 932 | if ( err != MAILIMAP_NO_ERROR ) { |
923 | return; | 933 | return; |
924 | } | 934 | } |
925 | flist = mailimap_flag_list_new_empty(); | 935 | flist = mailimap_flag_list_new_empty(); |
926 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 936 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
927 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 937 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
928 | set = mailimap_set_new_single(mail->getNumber()); | 938 | set = mailimap_set_new_single(mail->getNumber()); |
929 | err = mailimap_store(m_imap,set,store_flags); | 939 | err = mailimap_store(m_imap,set,store_flags); |
930 | mailimap_set_free( set ); | 940 | mailimap_set_free( set ); |
931 | mailimap_store_att_flags_free(store_flags); | 941 | mailimap_store_att_flags_free(store_flags); |
932 | 942 | ||
933 | if (err != MAILIMAP_NO_ERROR) { | 943 | if (err != MAILIMAP_NO_ERROR) { |
934 | odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 944 | odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
935 | return; | 945 | return; |
936 | } | 946 | } |
937 | } | 947 | } |
938 | 948 | ||
939 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 949 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
940 | { | 950 | { |
941 | QString body(""); | 951 | QString body(""); |
942 | encodedString*res = fetchRawPart(mail,path,internal_call); | 952 | encodedString*res = fetchRawPart(mail,path,internal_call); |
943 | encodedString*r = decode_String(res,enc); | 953 | encodedString*r = decode_String(res,enc); |
944 | delete res; | 954 | delete res; |
945 | if (r) { | 955 | if (r) { |
946 | if (r->Length()>0) { | 956 | if (r->Length()>0) { |
947 | body = r->Content(); | 957 | body = r->Content(); |
948 | } | 958 | } |
949 | delete r; | 959 | delete r; |
950 | } | 960 | } |
951 | return body; | 961 | return body; |
952 | } | 962 | } |
953 | 963 | ||
954 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 964 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
955 | { | 965 | { |
956 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 966 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
957 | } | 967 | } |
958 | 968 | ||
959 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 969 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
960 | { | 970 | { |
961 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 971 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
962 | encodedString*r = decode_String(res,part->Encoding()); | 972 | encodedString*r = decode_String(res,part->Encoding()); |
963 | delete res; | 973 | delete res; |
964 | return r; | 974 | return r; |
965 | } | 975 | } |
966 | 976 | ||
967 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 977 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
968 | { | 978 | { |
969 | return fetchRawPart(mail,part->Positionlist(),false); | 979 | return fetchRawPart(mail,part->Positionlist(),false); |
970 | } | 980 | } |
971 | 981 | ||
972 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 982 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
973 | { | 983 | { |
974 | login(); | 984 | login(); |
975 | if (!m_imap) { | 985 | if (!m_imap) { |
976 | return 0; | 986 | return 0; |
977 | } | 987 | } |
978 | mailimap_flag_list*flist; | 988 | mailimap_flag_list*flist; |
979 | mailimap_set *set; | 989 | mailimap_set *set; |
980 | mailimap_store_att_flags * store_flags; | 990 | mailimap_store_att_flags * store_flags; |
981 | int err = selectMbox(folder->getName()); | 991 | int err = selectMbox(folder->getName()); |
982 | if ( err != MAILIMAP_NO_ERROR ) { | 992 | if ( err != MAILIMAP_NO_ERROR ) { |
983 | return 0; | 993 | return 0; |
984 | } | 994 | } |
985 | 995 | ||
986 | int last = m_imap->imap_selection_info->sel_exists; | 996 | int last = m_imap->imap_selection_info->sel_exists; |
987 | if (last == 0) { | 997 | if (last == 0) { |
988 | Global::statusMessage(tr("Mailbox has no mails!")); | 998 | Global::statusMessage(tr("Mailbox has no mails!")); |
989 | return 0; | 999 | return 0; |
990 | } | 1000 | } |
991 | flist = mailimap_flag_list_new_empty(); | 1001 | flist = mailimap_flag_list_new_empty(); |
992 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1002 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
993 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1003 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
994 | set = mailimap_set_new_interval( 1, last ); | 1004 | set = mailimap_set_new_interval( 1, last ); |
995 | err = mailimap_store(m_imap,set,store_flags); | 1005 | err = mailimap_store(m_imap,set,store_flags); |
996 | mailimap_set_free( set ); | 1006 | mailimap_set_free( set ); |
997 | mailimap_store_att_flags_free(store_flags); | 1007 | mailimap_store_att_flags_free(store_flags); |
998 | if (err != MAILIMAP_NO_ERROR) { | 1008 | if (err != MAILIMAP_NO_ERROR) { |
999 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1009 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1000 | return 0; | 1010 | return 0; |
1001 | } | 1011 | } |
1002 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1012 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1003 | /* should we realy do that at this moment? */ | 1013 | /* should we realy do that at this moment? */ |
1004 | err = mailimap_expunge(m_imap); | 1014 | err = mailimap_expunge(m_imap); |
1005 | if (err != MAILIMAP_NO_ERROR) { | 1015 | if (err != MAILIMAP_NO_ERROR) { |
1006 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1016 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1007 | return 0; | 1017 | return 0; |
1008 | } | 1018 | } |
1009 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1019 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1010 | return 1; | 1020 | return 1; |
1011 | } | 1021 | } |
1012 | 1022 | ||
1013 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1023 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1014 | { | 1024 | { |
1015 | if (folder.length()==0) return 0; | 1025 | if (folder.length()==0) return 0; |
1016 | login(); | 1026 | login(); |
1017 | if (!m_imap) {return 0;} | 1027 | if (!m_imap) {return 0;} |
1018 | QString pre = account->getPrefix(); | 1028 | QString pre = account->getPrefix(); |
1019 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1029 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1020 | pre+=delemiter; | 1030 | pre+=delemiter; |
1021 | } | 1031 | } |
1022 | if (parentfolder) { | 1032 | if (parentfolder) { |
1023 | pre += parentfolder->getDisplayName()+delemiter; | 1033 | pre += parentfolder->getDisplayName()+delemiter; |
1024 | } | 1034 | } |
1025 | pre+=folder; | 1035 | pre+=folder; |
1026 | if (getsubfolder) { | 1036 | if (getsubfolder) { |
1027 | if (delemiter.length()>0) { | 1037 | if (delemiter.length()>0) { |
1028 | pre+=delemiter; | 1038 | pre+=delemiter; |
1029 | } else { | 1039 | } else { |
1030 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1040 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
1031 | return 0; | 1041 | return 0; |
1032 | } | 1042 | } |
1033 | } | 1043 | } |
1034 | odebug << "Creating " << pre.latin1() << "" << oendl; | 1044 | odebug << "Creating " << pre.latin1() << "" << oendl; |
1035 | int res = mailimap_create(m_imap,pre.latin1()); | 1045 | int res = mailimap_create(m_imap,pre.latin1()); |
1036 | if (res != MAILIMAP_NO_ERROR) { | 1046 | if (res != MAILIMAP_NO_ERROR) { |
1037 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1047 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1038 | return 0; | 1048 | return 0; |
1039 | } | 1049 | } |
1040 | return 1; | 1050 | return 1; |
1041 | } | 1051 | } |
1042 | 1052 | ||
1043 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1053 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1044 | { | 1054 | { |
1045 | if (!folder) return 0; | 1055 | if (!folder) return 0; |
1046 | login(); | 1056 | login(); |
1047 | if (!m_imap) {return 0;} | 1057 | if (!m_imap) {return 0;} |
1048 | int res = mailimap_delete(m_imap,folder->getName()); | 1058 | int res = mailimap_delete(m_imap,folder->getName()); |
1049 | if (res != MAILIMAP_NO_ERROR) { | 1059 | if (res != MAILIMAP_NO_ERROR) { |
1050 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1060 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1051 | return 0; | 1061 | return 0; |
1052 | } | 1062 | } |
1053 | return 1; | 1063 | return 1; |
1054 | } | 1064 | } |
1055 | 1065 | ||
1056 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1066 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1057 | { | 1067 | { |
1058 | mailimap_status_att_list * att_list =0; | 1068 | mailimap_status_att_list * att_list =0; |
1059 | mailimap_mailbox_data_status * status=0; | 1069 | mailimap_mailbox_data_status * status=0; |
1060 | clistiter * cur = 0; | 1070 | clistiter * cur = 0; |
1061 | int r = 0; | 1071 | int r = 0; |
1062 | target_stat.message_count = 0; | 1072 | target_stat.message_count = 0; |
1063 | target_stat.message_unseen = 0; | 1073 | target_stat.message_unseen = 0; |
1064 | target_stat.message_recent = 0; | 1074 | target_stat.message_recent = 0; |
1065 | login(); | 1075 | login(); |
1066 | if (!m_imap) { | 1076 | if (!m_imap) { |
1067 | return; | 1077 | return; |
1068 | } | 1078 | } |
1069 | att_list = mailimap_status_att_list_new_empty(); | 1079 | att_list = mailimap_status_att_list_new_empty(); |
1070 | if (!att_list) return; | 1080 | if (!att_list) return; |
1071 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1081 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1072 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1082 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1073 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1083 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1074 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1084 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1075 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1085 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1076 | for (cur = clist_begin(status->st_info_list); | 1086 | for (cur = clist_begin(status->st_info_list); |
1077 | cur != NULL ; cur = clist_next(cur)) { | 1087 | cur != NULL ; cur = clist_next(cur)) { |
1078 | mailimap_status_info * status_info; | 1088 | mailimap_status_info * status_info; |
1079 | status_info = (mailimap_status_info *)clist_content(cur); | 1089 | status_info = (mailimap_status_info *)clist_content(cur); |
1080 | switch (status_info->st_att) { | 1090 | switch (status_info->st_att) { |
1081 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1091 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1082 | target_stat.message_count = status_info->st_value; | 1092 | target_stat.message_count = status_info->st_value; |
1083 | break; | 1093 | break; |
1084 | case MAILIMAP_STATUS_ATT_RECENT: | 1094 | case MAILIMAP_STATUS_ATT_RECENT: |
1085 | target_stat.message_recent = status_info->st_value; | 1095 | target_stat.message_recent = status_info->st_value; |
1086 | break; | 1096 | break; |
1087 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1097 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1088 | target_stat.message_unseen = status_info->st_value; | 1098 | target_stat.message_unseen = status_info->st_value; |
1089 | break; | 1099 | break; |
1090 | } | 1100 | } |
1091 | } | 1101 | } |
1092 | } else { | 1102 | } else { |
1093 | odebug << "Error retrieving status" << oendl; | 1103 | odebug << "Error retrieving status" << oendl; |
1094 | } | 1104 | } |
1095 | if (status) mailimap_mailbox_data_status_free(status); | 1105 | if (status) mailimap_mailbox_data_status_free(status); |
1096 | if (att_list) mailimap_status_att_list_free(att_list); | 1106 | if (att_list) mailimap_status_att_list_free(att_list); |
1097 | } | 1107 | } |
1098 | 1108 | ||
1099 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1109 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1100 | { | 1110 | { |
1101 | login(); | 1111 | login(); |
1102 | if (!m_imap) return; | 1112 | if (!m_imap) return; |
1103 | if (!msg) return; | 1113 | if (!msg) return; |
1104 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1114 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1105 | if (r != MAILIMAP_NO_ERROR) { | 1115 | if (r != MAILIMAP_NO_ERROR) { |
1106 | Global::statusMessage("Error storing mail!"); | 1116 | Global::statusMessage("Error storing mail!"); |
1107 | } | 1117 | } |
1108 | } | 1118 | } |
1109 | 1119 | ||
1110 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1120 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1111 | { | 1121 | { |
1112 | return account->getType(); | 1122 | return account->getType(); |
1113 | } | 1123 | } |
1114 | 1124 | ||
1115 | const QString&IMAPwrapper::getName()const | 1125 | const QString&IMAPwrapper::getName()const |
1116 | { | 1126 | { |
1117 | odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1127 | odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1118 | return account->getAccountName(); | 1128 | return account->getAccountName(); |
1119 | } | 1129 | } |
1120 | 1130 | ||
1121 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1131 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1122 | { | 1132 | { |
1123 | // dummy | 1133 | // dummy |
1124 | QValueList<int> path; | 1134 | QValueList<int> path; |
1125 | return fetchRawPart(mail,path,false); | 1135 | return fetchRawPart(mail,path,false); |
1126 | } | 1136 | } |
1127 | 1137 | ||
1128 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1138 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1129 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1139 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1130 | { | 1140 | { |
1131 | if (targetWrapper != this) { | 1141 | if (targetWrapper != this) { |
1132 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1142 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1133 | odebug << "Using generic" << oendl; | 1143 | odebug << "Using generic" << oendl; |
1134 | return; | 1144 | return; |
1135 | } | 1145 | } |
1136 | mailimap_set *set = 0; | 1146 | mailimap_set *set = 0; |
1137 | login(); | 1147 | login(); |
1138 | if (!m_imap) { | 1148 | if (!m_imap) { |
1139 | return; | 1149 | return; |
1140 | } | 1150 | } |
1141 | int err = selectMbox(fromFolder->getName()); | 1151 | int err = selectMbox(fromFolder->getName()); |
1142 | if ( err != MAILIMAP_NO_ERROR ) { | 1152 | if ( err != MAILIMAP_NO_ERROR ) { |
1143 | return; | 1153 | return; |
1144 | } | 1154 | } |
1145 | int last = m_imap->imap_selection_info->sel_exists; | 1155 | int last = m_imap->imap_selection_info->sel_exists; |
1146 | set = mailimap_set_new_interval( 1, last ); | 1156 | set = mailimap_set_new_interval( 1, last ); |
1147 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1157 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1148 | mailimap_set_free( set ); | 1158 | mailimap_set_free( set ); |
1149 | if ( err != MAILIMAP_NO_ERROR ) { | 1159 | if ( err != MAILIMAP_NO_ERROR ) { |
1150 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1160 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1151 | Global::statusMessage(error_msg); | 1161 | Global::statusMessage(error_msg); |
1152 | odebug << error_msg << oendl; | 1162 | odebug << error_msg << oendl; |
1153 | return; | 1163 | return; |
1154 | } | 1164 | } |
1155 | if (moveit) { | 1165 | if (moveit) { |
1156 | deleteAllMail(fromFolder); | 1166 | deleteAllMail(fromFolder); |
1157 | } | 1167 | } |
1158 | } | 1168 | } |
1159 | 1169 | ||
1160 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1170 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1161 | { | 1171 | { |
1162 | if (targetWrapper != this) { | 1172 | if (targetWrapper != this) { |
1163 | odebug << "Using generic" << oendl; | 1173 | odebug << "Using generic" << oendl; |
1164 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1174 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1165 | return; | 1175 | return; |
1166 | } | 1176 | } |
1167 | mailimap_set *set = 0; | 1177 | mailimap_set *set = 0; |
1168 | login(); | 1178 | login(); |
1169 | if (!m_imap) { | 1179 | if (!m_imap) { |
1170 | return; | 1180 | return; |
1171 | } | 1181 | } |
1172 | int err = selectMbox(mail->getMbox()); | 1182 | int err = selectMbox(mail->getMbox()); |
1173 | if ( err != MAILIMAP_NO_ERROR ) { | 1183 | if ( err != MAILIMAP_NO_ERROR ) { |
1174 | return; | 1184 | return; |
1175 | } | 1185 | } |
1176 | set = mailimap_set_new_single(mail->getNumber()); | 1186 | set = mailimap_set_new_single(mail->getNumber()); |
1177 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1187 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1178 | mailimap_set_free( set ); | 1188 | mailimap_set_free( set ); |
1179 | if ( err != MAILIMAP_NO_ERROR ) { | 1189 | if ( err != MAILIMAP_NO_ERROR ) { |
1180 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1190 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1181 | Global::statusMessage(error_msg); | 1191 | Global::statusMessage(error_msg); |
1182 | odebug << error_msg << oendl; | 1192 | odebug << error_msg << oendl; |
1183 | return; | 1193 | return; |
1184 | } | 1194 | } |
1185 | if (moveit) { | 1195 | if (moveit) { |
1186 | deleteMail(mail); | 1196 | deleteMail(mail); |
1187 | } | 1197 | } |
1188 | } | 1198 | } |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 403afcf..765a21c 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,443 +1,443 @@ | |||
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 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | 11 | ||
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
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 | odebug << MHPath << oendl; | 20 | odebug << MHPath << oendl; |
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 | odebug << "error initializing storage" << oendl; | 37 | odebug << "error initializing storage" << oendl; |
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 | odebug << "error connecting storage" << oendl; | 45 | odebug << "error connecting storage" << oendl; |
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, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 65 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<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 | odebug << "listMessages: error selecting folder!" << oendl; | 74 | odebug << "listMessages: error selecting folder!" << oendl; |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | parseList(target,m_storage->sto_session,f); | 77 | parseList(target,m_storage->sto_session,f); |
78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
79 | } | 79 | } |
80 | 80 | ||
81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
82 | { | 82 | { |
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
84 | /* this is needed! */ | 84 | /* this is needed! */ |
85 | if (m_storage) mailstorage_disconnect(m_storage); | 85 | if (m_storage) mailstorage_disconnect(m_storage); |
86 | init_storage(); | 86 | init_storage(); |
87 | if (!m_storage) { | 87 | if (!m_storage) { |
88 | return folders; | 88 | return folders; |
89 | } | 89 | } |
90 | mail_list*flist = 0; | 90 | mail_list*flist = 0; |
91 | clistcell*current=0; | 91 | clistcell*current=0; |
92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
93 | if (r != MAIL_NO_ERROR || !flist) { | 93 | if (r != MAIL_NO_ERROR || !flist) { |
94 | odebug << "error getting folder list" << oendl; | 94 | odebug << "error getting folder list" << oendl; |
95 | return folders; | 95 | return folders; |
96 | } | 96 | } |
97 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 97 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
98 | QString t = (char*)current->data; | 98 | QString t = (char*)current->data; |
99 | t.replace(0,MHPath.length(),""); | 99 | t.replace(0,MHPath.length(),""); |
100 | folders->append(new MHFolder(t,MHPath)); | 100 | folders->append(new MHFolder(t,MHPath)); |
101 | } | 101 | } |
102 | mail_list_free(flist); | 102 | mail_list_free(flist); |
103 | return folders; | 103 | return folders; |
104 | } | 104 | } |
105 | 105 | ||
106 | void MHwrapper::deleteMail(const RecMailP&mail) | 106 | void MHwrapper::deleteMail(const RecMailP&mail) |
107 | { | 107 | { |
108 | init_storage(); | 108 | init_storage(); |
109 | if (!m_storage) { | 109 | if (!m_storage) { |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
113 | if (r!=MAIL_NO_ERROR) { | 113 | if (r!=MAIL_NO_ERROR) { |
114 | odebug << "error selecting folder!" << oendl; | 114 | odebug << "error selecting folder!" << oendl; |
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
118 | if (r != MAIL_NO_ERROR) { | 118 | if (r != MAIL_NO_ERROR) { |
119 | odebug << "error deleting mail" << oendl; | 119 | odebug << "error deleting mail" << oendl; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void MHwrapper::answeredMail(const RecMailP&) | 123 | void MHwrapper::answeredMail(const RecMailP&) |
124 | { | 124 | { |
125 | } | 125 | } |
126 | 126 | ||
127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
128 | { | 128 | { |
129 | RecBodyP body = new RecBody(); | 129 | RecBodyP body = new RecBody(); |
130 | init_storage(); | 130 | init_storage(); |
131 | if (!m_storage) { | 131 | if (!m_storage) { |
132 | return body; | 132 | return body; |
133 | } | 133 | } |
134 | mailmessage * msg; | 134 | mailmessage * msg; |
135 | char*data=0; | 135 | char*data=0; |
136 | 136 | ||
137 | /* mail should hold the complete path! */ | 137 | /* mail should hold the complete path! */ |
138 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 138 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
139 | if (r != MAIL_NO_ERROR) { | 139 | if (r != MAIL_NO_ERROR) { |
140 | return body; | 140 | return body; |
141 | } | 141 | } |
142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
143 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; | 144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; |
145 | return body; | 145 | return body; |
146 | } | 146 | } |
147 | body = parseMail(msg); | 147 | body = parseMail(msg); |
148 | mailmessage_fetch_result_free(msg,data); | 148 | mailmessage_fetch_result_free(msg,data); |
149 | return body; | 149 | return body; |
150 | } | 150 | } |
151 | 151 | ||
152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
153 | { | 153 | { |
154 | odebug << "MH " << current << " von " << maximum << "" << oendl; | 154 | odebug << "MH " << current << " von " << maximum << "" << oendl; |
155 | } | 155 | } |
156 | 156 | ||
157 | QString MHwrapper::buildPath(const QString&p) | 157 | QString MHwrapper::buildPath(const QString&p) |
158 | { | 158 | { |
159 | QString f=""; | 159 | QString f=""; |
160 | if (p.length()==0||p=="/") | 160 | if (p.length()==0||p=="/") |
161 | return MHPath; | 161 | return MHPath; |
162 | if (!p.startsWith(MHPath)) { | 162 | if (!p.startsWith(MHPath)) { |
163 | f+=MHPath; | 163 | f+=MHPath; |
164 | } | 164 | } |
165 | if (!p.startsWith("/")) { | 165 | if (!p.startsWith("/")) { |
166 | f+="/"; | 166 | f+="/"; |
167 | } | 167 | } |
168 | f+=p; | 168 | f+=p; |
169 | return f; | 169 | return f; |
170 | } | 170 | } |
171 | 171 | ||
172 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) | 172 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
173 | { | 173 | { |
174 | init_storage(); | 174 | init_storage(); |
175 | if (!m_storage) { | 175 | if (!m_storage) { |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | QString f; | 178 | QString f; |
179 | if (!pfolder) { | 179 | if (!pfolder) { |
180 | // toplevel folder | 180 | // toplevel folder |
181 | f = buildPath(folder); | 181 | f = buildPath(folder); |
182 | } else { | 182 | } else { |
183 | f = pfolder->getName(); | 183 | f = pfolder->getName(); |
184 | f+="/"; | 184 | f+="/"; |
185 | f+=folder; | 185 | f+=folder; |
186 | } | 186 | } |
187 | odebug << f << oendl; | 187 | odebug << f << oendl; |
188 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 188 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | odebug << "error creating folder " << r << "" << oendl; | 190 | odebug << "error creating folder " << r << "" << oendl; |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | odebug << "Folder created" << oendl; | 193 | odebug << "Folder created" << oendl; |
194 | return 1; | 194 | return 1; |
195 | } | 195 | } |
196 | 196 | ||
197 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 197 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
198 | { | 198 | { |
199 | init_storage(); | 199 | init_storage(); |
200 | if (!m_storage) { | 200 | if (!m_storage) { |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | QString f = buildPath(Folder); | 203 | QString f = buildPath(Folder); |
204 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 204 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
205 | if (r!=MAIL_NO_ERROR) { | 205 | if (r!=MAIL_NO_ERROR) { |
206 | odebug << "error selecting folder!" << oendl; | 206 | odebug << "error selecting folder!" << oendl; |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 209 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
210 | if (r!=MAIL_NO_ERROR) { | 210 | if (r!=MAIL_NO_ERROR) { |
211 | odebug << "error storing mail" << oendl; | 211 | odebug << "error storing mail" << oendl; |
212 | } | 212 | } |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 216 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
217 | { | 217 | { |
218 | encodedString*result = 0; | 218 | encodedString*result = 0; |
219 | init_storage(); | 219 | init_storage(); |
220 | if (!m_storage) { | 220 | if (!m_storage) { |
221 | return result; | 221 | return result; |
222 | } | 222 | } |
223 | mailmessage * msg = 0; | 223 | mailmessage * msg = 0; |
224 | char*data=0; | 224 | char*data=0; |
225 | size_t size; | 225 | size_t size; |
226 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 226 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
227 | if (r!=MAIL_NO_ERROR) { | 227 | if (r!=MAIL_NO_ERROR) { |
228 | odebug << "error selecting folder!" << oendl; | 228 | odebug << "error selecting folder!" << oendl; |
229 | return result; | 229 | return result; |
230 | } | 230 | } |
231 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 231 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
232 | if (r != MAIL_NO_ERROR) { | 232 | if (r != MAIL_NO_ERROR) { |
233 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 233 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | r = mailmessage_fetch(msg,&data,&size); | 236 | r = mailmessage_fetch(msg,&data,&size); |
237 | if (r != MAIL_NO_ERROR) { | 237 | if (r != MAIL_NO_ERROR) { |
238 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 238 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
239 | if (msg) mailmessage_free(msg); | 239 | if (msg) mailmessage_free(msg); |
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | result = new encodedString(data,size); | 242 | result = new encodedString(data,size); |
243 | if (msg) mailmessage_free(msg); | 243 | if (msg) mailmessage_free(msg); |
244 | return result; | 244 | return result; |
245 | } | 245 | } |
246 | 246 | ||
247 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 247 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
248 | { | 248 | { |
249 | QString f = buildPath(mailbox); | 249 | QString f = buildPath(mailbox); |
250 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 250 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
251 | if (r!=MAIL_NO_ERROR) { | 251 | if (r!=MAIL_NO_ERROR) { |
252 | odebug << "deleteMails: error selecting folder!" << oendl; | 252 | odebug << "deleteMails: error selecting folder!" << oendl; |
253 | return; | 253 | return; |
254 | } | 254 | } |
255 | QValueList<RecMailP>::ConstIterator it; | 255 | QValueList<RecMailP>::ConstIterator it; |
256 | for (it=target.begin(); it!=target.end();++it) { | 256 | for (it=target.begin(); it!=target.end();++it) { |
257 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 257 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
258 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
259 | odebug << "error deleting mail" << oendl; | 259 | odebug << "error deleting mail" << oendl; |
260 | break; | 260 | break; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
266 | { | 266 | { |
267 | init_storage(); | 267 | init_storage(); |
268 | if (!m_storage) { | 268 | if (!m_storage) { |
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | int res = 1; | 271 | int res = 1; |
272 | if (!tfolder) return 0; | 272 | if (!tfolder) return 0; |
273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
274 | if (r!=MAIL_NO_ERROR) { | 274 | if (r!=MAIL_NO_ERROR) { |
275 | odebug << "error selecting folder!" << oendl; | 275 | odebug << "error selecting folder!" << oendl; |
276 | return 0; | 276 | return 0; |
277 | } | 277 | } |
278 | mailmessage_list*l=0; | 278 | mailmessage_list*l=0; |
279 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 279 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
280 | if (r != MAIL_NO_ERROR) { | 280 | if (r != MAIL_NO_ERROR) { |
281 | odebug << "Error message list" << oendl; | 281 | odebug << "Error message list" << oendl; |
282 | res = 0; | 282 | res = 0; |
283 | } | 283 | } |
284 | unsigned j = 0; | 284 | unsigned j = 0; |
285 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 285 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
286 | mailmessage * msg; | 286 | mailmessage * msg; |
287 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 287 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
288 | j = msg->msg_index; | 288 | j = msg->msg_index; |
289 | r = mailsession_remove_message(m_storage->sto_session,j); | 289 | r = mailsession_remove_message(m_storage->sto_session,j); |
290 | if (r != MAIL_NO_ERROR) { | 290 | if (r != MAIL_NO_ERROR) { |
291 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 291 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
292 | res = 0; | 292 | res = 0; |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | if (l) mailmessage_list_free(l); | 296 | if (l) mailmessage_list_free(l); |
297 | return res; | 297 | return res; |
298 | } | 298 | } |
299 | 299 | ||
300 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 300 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
301 | { | 301 | { |
302 | init_storage(); | 302 | init_storage(); |
303 | if (!m_storage) { | 303 | if (!m_storage) { |
304 | return 0; | 304 | return 0; |
305 | } | 305 | } |
306 | if (!tfolder) return 0; | 306 | if (!tfolder) return 0; |
307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
308 | 308 | ||
309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
310 | 310 | ||
311 | if (r != MAIL_NO_ERROR) { | 311 | if (r != MAIL_NO_ERROR) { |
312 | odebug << "error deleting mail box" << oendl; | 312 | odebug << "error deleting mail box" << oendl; |
313 | return 0; | 313 | return 0; |
314 | } | 314 | } |
315 | QString cmd = "rm -rf "+tfolder->getName(); | 315 | QString cmd = "rm -rf "+tfolder->getName(); |
316 | QStringList command; | 316 | QStringList command; |
317 | command << "/bin/sh"; | 317 | command << "/bin/sh"; |
318 | command << "-c"; | 318 | command << "-c"; |
319 | command << cmd.latin1(); | 319 | command << cmd.latin1(); |
320 | OProcess *process = new OProcess(); | 320 | OProcess *process = new OProcess(); |
321 | 321 | ||
322 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 322 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
323 | this, SLOT( processEnded(Opie::Core::OProcess*))); | 323 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
324 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 324 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
325 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 325 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
326 | 326 | ||
327 | *process << command; | 327 | *process << command; |
328 | removeMboxfailed = false; | 328 | removeMboxfailed = false; |
329 | if(!process->start(OProcess::Block, OProcess::All) ) { | 329 | if(!process->start(OProcess::Block, OProcess::All) ) { |
330 | odebug << "could not start process" << oendl; | 330 | odebug << "could not start process" << oendl; |
331 | return 0; | 331 | return 0; |
332 | } | 332 | } |
333 | odebug << "mail box deleted" << oendl; | 333 | odebug << "mail box deleted" << oendl; |
334 | return 1; | 334 | return 1; |
335 | } | 335 | } |
336 | 336 | ||
337 | void MHwrapper::processEnded(OProcess *p) | 337 | void MHwrapper::processEnded(OProcess *p) |
338 | { | 338 | { |
339 | if (p) delete p; | 339 | if (p) delete p; |
340 | } | 340 | } |
341 | 341 | ||
342 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 342 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
343 | { | 343 | { |
344 | QString lineStr = buffer; | 344 | QString lineStr = buffer; |
345 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 345 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
346 | removeMboxfailed = true; | 346 | removeMboxfailed = true; |
347 | } | 347 | } |
348 | 348 | ||
349 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 349 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
350 | { | 350 | { |
351 | init_storage(); | 351 | init_storage(); |
352 | if (!m_storage) { | 352 | if (!m_storage) { |
353 | return; | 353 | return; |
354 | } | 354 | } |
355 | target_stat.message_count = 0; | 355 | target_stat.message_count = 0; |
356 | target_stat.message_unseen = 0; | 356 | target_stat.message_unseen = 0; |
357 | target_stat.message_recent = 0; | 357 | target_stat.message_recent = 0; |
358 | QString f = buildPath(mailbox); | 358 | QString f = buildPath(mailbox); |
359 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 359 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
360 | &target_stat.message_recent,&target_stat.message_unseen); | 360 | &target_stat.message_recent,&target_stat.message_unseen); |
361 | if (r != MAIL_NO_ERROR) { | 361 | if (r != MAIL_NO_ERROR) { |
362 | Global::statusMessage(tr("Error retrieving status")); | 362 | Global::statusMessage(tr("Error retrieving status")); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | MAILLIB::ATYPE MHwrapper::getType()const | 366 | MAILLIB::ATYPE MHwrapper::getType()const |
367 | { | 367 | { |
368 | return MAILLIB::A_MH; | 368 | return MAILLIB::A_MH; |
369 | } | 369 | } |
370 | 370 | ||
371 | const QString&MHwrapper::getName()const | 371 | const QString&MHwrapper::getName()const |
372 | { | 372 | { |
373 | return MHName; | 373 | return MHName; |
374 | } | 374 | } |
375 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 375 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
376 | { | 376 | { |
377 | init_storage(); | 377 | init_storage(); |
378 | if (!m_storage) { | 378 | if (!m_storage) { |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | if (targetWrapper != this) { | 381 | if (targetWrapper != this) { |
382 | odebug << "Using generic" << oendl; | 382 | odebug << "Using generic" << oendl; |
383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | odebug << "Using internal routines for move/copy" << oendl; | 386 | odebug << "Using internal routines for move/copy" << oendl; |
387 | QString tf = buildPath(targetFolder); | 387 | QString tf = buildPath(targetFolder); |
388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
389 | if (r != MAIL_NO_ERROR) { | 389 | if (r != MAIL_NO_ERROR) { |
390 | odebug << "Error selecting source mailbox" << oendl; | 390 | odebug << "Error selecting source mailbox" << oendl; |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | if (moveit) { | 393 | if (moveit) { |
394 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 394 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
395 | } else { | 395 | } else { |
396 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 396 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
397 | } | 397 | } |
398 | if (r != MAIL_NO_ERROR) { | 398 | if (r != MAIL_NO_ERROR) { |
399 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; | 399 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
405 | { | 405 | { |
406 | init_storage(); | 406 | init_storage(); |
407 | if (!m_storage) { | 407 | if (!m_storage) { |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (targetWrapper != this) { | 410 | if (targetWrapper != this) { |
411 | odebug << "Using generic" << oendl; | 411 | odebug << "Using generic" << oendl; |
412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | if (!fromFolder) return; | 415 | if (!fromFolder) return; |
416 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 416 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
417 | if (r!=MAIL_NO_ERROR) { | 417 | if (r!=MAIL_NO_ERROR) { |
418 | odebug << "error selecting source folder!" << oendl; | 418 | odebug << "error selecting source folder!" << oendl; |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | QString tf = buildPath(targetFolder); | 421 | QString tf = buildPath(targetFolder); |
422 | mailmessage_list*l=0; | 422 | mailmessage_list*l=0; |
423 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 423 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
424 | if (r != MAIL_NO_ERROR) { | 424 | if (r != MAIL_NO_ERROR) { |
425 | odebug << "Error message list" << oendl; | 425 | odebug << "Error message list" << oendl; |
426 | } | 426 | } |
427 | unsigned j = 0; | 427 | unsigned j = 0; |
428 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 428 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
429 | mailmessage * msg; | 429 | mailmessage * msg; |
430 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 430 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
431 | j = msg->msg_index; | 431 | j = msg->msg_index; |
432 | if (moveit) { | 432 | if (moveit) { |
433 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 433 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
434 | } else { | 434 | } else { |
435 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 435 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
436 | } | 436 | } |
437 | if (r != MAIL_NO_ERROR) { | 437 | if (r != MAIL_NO_ERROR) { |
438 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; | 438 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | if (l) mailmessage_list_free(l); | 442 | if (l) mailmessage_list_free(l); |
443 | } | 443 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 3cfd1ee..2d66fc9 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,265 +1,272 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qmessagebox.h> | ||
10 | 11 | ||
11 | /* we don't fetch messages larger than 5 MB */ | 12 | /* we don't fetch messages larger than 5 MB */ |
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 13 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 14 | ||
14 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
15 | POP3wrapper::POP3wrapper( POP3account *a ) | 16 | POP3wrapper::POP3wrapper( POP3account *a ) |
16 | : Genericwrapper() { | 17 | : Genericwrapper() { |
17 | account = a; | 18 | account = a; |
18 | m_pop3 = NULL; | 19 | m_pop3 = NULL; |
19 | msgTempName = a->getFileName()+"_msg_cache"; | 20 | msgTempName = a->getFileName()+"_msg_cache"; |
20 | last_msg_id = 0; | 21 | last_msg_id = 0; |
22 | m_maxsize = account->getMaxSize(); | ||
23 | m_checksize = account->getCheckMaxSize(); | ||
21 | } | 24 | } |
22 | 25 | ||
23 | POP3wrapper::~POP3wrapper() { | 26 | POP3wrapper::~POP3wrapper() { |
24 | logout(); | 27 | logout(); |
25 | QFile msg_cache(msgTempName); | 28 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 29 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 30 | msg_cache.remove(); |
28 | } | 31 | } |
29 | } | 32 | } |
30 | 33 | ||
31 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 34 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
32 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; | 35 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; |
33 | } | 36 | } |
34 | 37 | ||
35 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | 38 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { |
36 | int err = MAILPOP3_NO_ERROR; | 39 | int err = MAILPOP3_NO_ERROR; |
37 | char *message = 0; | 40 | char *message = 0; |
38 | size_t length = 0; | 41 | size_t length = 0; |
39 | 42 | ||
40 | RecBodyP body = new RecBody(); | 43 | RecBodyP body = new RecBody(); |
41 | 44 | ||
42 | login(); | 45 | login(); |
43 | if ( !m_pop3 ) { | 46 | if ( !m_pop3 ) { |
44 | return body; | 47 | return body; |
45 | } | 48 | } |
46 | 49 | ||
47 | mailmessage * mailmsg; | 50 | mailmessage * mailmsg; |
48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 51 | if (mail->Msgsize()/1024>m_maxsize && m_checksize && mail->getNumber()!=last_msg_id) { |
49 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 52 | QString quest = QString(tr("Download mail?\nIt is %1 kByte but your limit is %2 kByte")).arg(mail->Msgsize()/1024).arg(m_maxsize); |
50 | return body; | 53 | int yesno = QMessageBox::warning(0,tr("Download message"), |
54 | quest,tr("Yes"),tr("No"),QString::null,0,1); | ||
55 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | ||
56 | if (yesno==1) | ||
57 | return body; | ||
51 | } | 58 | } |
52 | 59 | ||
53 | QFile msg_cache(msgTempName); | 60 | QFile msg_cache(msgTempName); |
54 | 61 | ||
55 | cleanMimeCache(); | 62 | cleanMimeCache(); |
56 | 63 | ||
57 | if (mail->getNumber()!=last_msg_id) { | 64 | if (mail->getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 65 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 66 | msg_cache.remove(); |
60 | } | 67 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 68 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail->getNumber(); | 69 | last_msg_id = mail->getNumber(); |
63 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 70 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
64 | err = mailmessage_fetch(mailmsg,&message,&length); | 71 | err = mailmessage_fetch(mailmsg,&message,&length); |
65 | msg_cache.writeBlock(message,length); | 72 | msg_cache.writeBlock(message,length); |
66 | } else { | 73 | } else { |
67 | QString msg=""; | 74 | QString msg=""; |
68 | msg_cache.open(IO_ReadOnly); | 75 | msg_cache.open(IO_ReadOnly); |
69 | message = new char[4096]; | 76 | message = new char[4096]; |
70 | memset(message,0,4096); | 77 | memset(message,0,4096); |
71 | while (msg_cache.readBlock(message,4095)>0) { | 78 | while (msg_cache.readBlock(message,4095)>0) { |
72 | msg+=message; | 79 | msg+=message; |
73 | memset(message,0,4096); | 80 | memset(message,0,4096); |
74 | } | 81 | } |
75 | delete message; | 82 | delete message; |
76 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 83 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
77 | memset(message,0,msg.length()+1); | 84 | memset(message,0,msg.length()+1); |
78 | memcpy(message,msg.latin1(),msg.length()); | 85 | memcpy(message,msg.latin1(),msg.length()); |
79 | /* transform to libetpan stuff */ | 86 | /* transform to libetpan stuff */ |
80 | mailmsg = mailmessage_new(); | 87 | mailmsg = mailmessage_new(); |
81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 88 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
82 | generic_message_t * msg_data; | 89 | generic_message_t * msg_data; |
83 | msg_data = (generic_message_t *)mailmsg->msg_data; | 90 | msg_data = (generic_message_t *)mailmsg->msg_data; |
84 | msg_data->msg_fetched = 1; | 91 | msg_data->msg_fetched = 1; |
85 | msg_data->msg_message = message; | 92 | msg_data->msg_message = message; |
86 | msg_data->msg_length = strlen(message); | 93 | msg_data->msg_length = strlen(message); |
87 | } | 94 | } |
88 | body = parseMail(mailmsg); | 95 | body = parseMail(mailmsg); |
89 | 96 | ||
90 | /* clean up */ | 97 | /* clean up */ |
91 | if (mailmsg) | 98 | if (mailmsg) |
92 | mailmessage_free(mailmsg); | 99 | mailmessage_free(mailmsg); |
93 | if (message) | 100 | if (message) |
94 | free(message); | 101 | free(message); |
95 | 102 | ||
96 | return body; | 103 | return body; |
97 | } | 104 | } |
98 | 105 | ||
99 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 106 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
100 | { | 107 | { |
101 | login(); | 108 | login(); |
102 | if (!m_pop3) | 109 | if (!m_pop3) |
103 | return; | 110 | return; |
104 | uint32_t res_messages,res_recent,res_unseen; | 111 | uint32_t res_messages,res_recent,res_unseen; |
105 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 112 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
106 | parseList(target,m_pop3->sto_session,"INBOX"); | 113 | parseList(target,m_pop3->sto_session,"INBOX"); |
107 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 114 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
108 | } | 115 | } |
109 | 116 | ||
110 | void POP3wrapper::login() | 117 | void POP3wrapper::login() |
111 | { | 118 | { |
112 | if (account->getOffline()) | 119 | if (account->getOffline()) |
113 | return; | 120 | return; |
114 | /* we'll hold the line */ | 121 | /* we'll hold the line */ |
115 | if ( m_pop3 != NULL ) | 122 | if ( m_pop3 != NULL ) |
116 | return; | 123 | return; |
117 | 124 | ||
118 | const char *server, *user, *pass; | 125 | const char *server, *user, *pass; |
119 | uint16_t port; | 126 | uint16_t port; |
120 | int err = MAILPOP3_NO_ERROR; | 127 | int err = MAILPOP3_NO_ERROR; |
121 | 128 | ||
122 | server = account->getServer().latin1(); | 129 | server = account->getServer().latin1(); |
123 | port = account->getPort().toUInt(); | 130 | port = account->getPort().toUInt(); |
124 | 131 | ||
125 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 132 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
126 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 133 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
127 | login.show(); | 134 | login.show(); |
128 | if ( QDialog::Accepted == login.exec() ) { | 135 | if ( QDialog::Accepted == login.exec() ) { |
129 | // ok | 136 | // ok |
130 | user = login.getUser().latin1(); | 137 | user = login.getUser().latin1(); |
131 | pass = login.getPassword().latin1(); | 138 | pass = login.getPassword().latin1(); |
132 | } else { | 139 | } else { |
133 | // cancel | 140 | // cancel |
134 | odebug << "POP3: Login canceled" << oendl; | 141 | odebug << "POP3: Login canceled" << oendl; |
135 | return; | 142 | return; |
136 | } | 143 | } |
137 | } else { | 144 | } else { |
138 | user = account->getUser().latin1(); | 145 | user = account->getUser().latin1(); |
139 | pass = account->getPassword().latin1(); | 146 | pass = account->getPassword().latin1(); |
140 | } | 147 | } |
141 | 148 | ||
142 | // bool ssl = account->getSSL(); | 149 | // bool ssl = account->getSSL(); |
143 | 150 | ||
144 | m_pop3=mailstorage_new(NULL); | 151 | m_pop3=mailstorage_new(NULL); |
145 | 152 | ||
146 | int conntypeset = account->ConnectionType(); | 153 | int conntypeset = account->ConnectionType(); |
147 | int conntype = 0; | 154 | int conntype = 0; |
148 | if ( conntypeset == 3 ) { | 155 | if ( conntypeset == 3 ) { |
149 | conntype = CONNECTION_TYPE_COMMAND; | 156 | conntype = CONNECTION_TYPE_COMMAND; |
150 | } else if ( conntypeset == 2 ) { | 157 | } else if ( conntypeset == 2 ) { |
151 | conntype = CONNECTION_TYPE_TLS; | 158 | conntype = CONNECTION_TYPE_TLS; |
152 | } else if ( conntypeset == 1 ) { | 159 | } else if ( conntypeset == 1 ) { |
153 | conntype = CONNECTION_TYPE_STARTTLS; | 160 | conntype = CONNECTION_TYPE_STARTTLS; |
154 | } else if ( conntypeset == 0 ) { | 161 | } else if ( conntypeset == 0 ) { |
155 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 162 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
156 | } | 163 | } |
157 | 164 | ||
158 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 165 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
159 | 166 | ||
160 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 167 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
161 | (char*)user,(char*)pass,0,0,0); | 168 | (char*)user,(char*)pass,0,0,0); |
162 | 169 | ||
163 | 170 | ||
164 | err = mailstorage_connect(m_pop3); | 171 | err = mailstorage_connect(m_pop3); |
165 | if (err != MAIL_NO_ERROR) { | 172 | if (err != MAIL_NO_ERROR) { |
166 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 173 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
167 | Global::statusMessage(tr("Error initializing folder")); | 174 | Global::statusMessage(tr("Error initializing folder")); |
168 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
169 | m_pop3 = 0; | 176 | m_pop3 = 0; |
170 | } else { | 177 | } else { |
171 | mailsession * session = m_pop3->sto_session; | 178 | mailsession * session = m_pop3->sto_session; |
172 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 179 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
173 | if (mail) { | 180 | if (mail) { |
174 | mail->pop3_progr_fun = &pop3_progress; | 181 | mail->pop3_progr_fun = &pop3_progress; |
175 | } | 182 | } |
176 | } | 183 | } |
177 | } | 184 | } |
178 | 185 | ||
179 | void POP3wrapper::logout() | 186 | void POP3wrapper::logout() |
180 | { | 187 | { |
181 | if ( m_pop3 == NULL ) | 188 | if ( m_pop3 == NULL ) |
182 | return; | 189 | return; |
183 | mailstorage_free(m_pop3); | 190 | mailstorage_free(m_pop3); |
184 | m_pop3 = 0; | 191 | m_pop3 = 0; |
185 | } | 192 | } |
186 | 193 | ||
187 | 194 | ||
188 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 195 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 196 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
190 | FolderP inb=new Folder("INBOX","/"); | 197 | FolderP inb=new Folder("INBOX","/"); |
191 | folders->append(inb); | 198 | folders->append(inb); |
192 | return folders; | 199 | return folders; |
193 | } | 200 | } |
194 | 201 | ||
195 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 202 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
196 | login(); | 203 | login(); |
197 | if (!m_pop3) | 204 | if (!m_pop3) |
198 | return; | 205 | return; |
199 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 206 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
200 | if (err != MAIL_NO_ERROR) { | 207 | if (err != MAIL_NO_ERROR) { |
201 | Global::statusMessage(tr("error deleting mail")); | 208 | Global::statusMessage(tr("error deleting mail")); |
202 | } | 209 | } |
203 | } | 210 | } |
204 | 211 | ||
205 | void POP3wrapper::answeredMail(const RecMailP&) {} | 212 | void POP3wrapper::answeredMail(const RecMailP&) {} |
206 | 213 | ||
207 | int POP3wrapper::deleteAllMail(const FolderP&) { | 214 | int POP3wrapper::deleteAllMail(const FolderP&) { |
208 | login(); | 215 | login(); |
209 | if (!m_pop3) | 216 | if (!m_pop3) |
210 | return 0; | 217 | return 0; |
211 | int res = 1; | 218 | int res = 1; |
212 | 219 | ||
213 | uint32_t result = 0; | 220 | uint32_t result = 0; |
214 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 221 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
215 | if (err != MAIL_NO_ERROR) { | 222 | if (err != MAIL_NO_ERROR) { |
216 | Global::statusMessage(tr("Error getting folder info")); | 223 | Global::statusMessage(tr("Error getting folder info")); |
217 | return 0; | 224 | return 0; |
218 | } | 225 | } |
219 | for (unsigned int i = 0; i < result; ++i) { | 226 | for (unsigned int i = 0; i < result; ++i) { |
220 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 227 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
221 | if (err != MAIL_NO_ERROR) { | 228 | if (err != MAIL_NO_ERROR) { |
222 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 229 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
223 | res=0; | 230 | res=0; |
224 | } | 231 | } |
225 | break; | 232 | break; |
226 | } | 233 | } |
227 | return res; | 234 | return res; |
228 | } | 235 | } |
229 | 236 | ||
230 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 237 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
231 | login(); | 238 | login(); |
232 | target_stat.message_count = 0; | 239 | target_stat.message_count = 0; |
233 | target_stat.message_unseen = 0; | 240 | target_stat.message_unseen = 0; |
234 | target_stat.message_recent = 0; | 241 | target_stat.message_recent = 0; |
235 | if (!m_pop3) | 242 | if (!m_pop3) |
236 | return; | 243 | return; |
237 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 244 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
238 | &target_stat.message_recent,&target_stat.message_unseen); | 245 | &target_stat.message_recent,&target_stat.message_unseen); |
239 | if (r != MAIL_NO_ERROR) { | 246 | if (r != MAIL_NO_ERROR) { |
240 | odebug << "error getting folter status." << oendl; | 247 | odebug << "error getting folter status." << oendl; |
241 | } | 248 | } |
242 | } | 249 | } |
243 | 250 | ||
244 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { | 251 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
245 | char*target=0; | 252 | char*target=0; |
246 | size_t length=0; | 253 | size_t length=0; |
247 | encodedString*res = 0; | 254 | encodedString*res = 0; |
248 | mailmessage * mailmsg = 0; | 255 | mailmessage * mailmsg = 0; |
249 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 256 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
250 | err = mailmessage_fetch(mailmsg,&target,&length); | 257 | err = mailmessage_fetch(mailmsg,&target,&length); |
251 | if (mailmsg) | 258 | if (mailmsg) |
252 | mailmessage_free(mailmsg); | 259 | mailmessage_free(mailmsg); |
253 | if (target) { | 260 | if (target) { |
254 | res = new encodedString(target,length); | 261 | res = new encodedString(target,length); |
255 | } | 262 | } |
256 | return res; | 263 | return res; |
257 | } | 264 | } |
258 | 265 | ||
259 | MAILLIB::ATYPE POP3wrapper::getType()const { | 266 | MAILLIB::ATYPE POP3wrapper::getType()const { |
260 | return account->getType(); | 267 | return account->getType(); |
261 | } | 268 | } |
262 | 269 | ||
263 | const QString&POP3wrapper::getName()const{ | 270 | const QString&POP3wrapper::getName()const{ |
264 | return account->getAccountName(); | 271 | return account->getAccountName(); |
265 | } | 272 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 5101fa5..8c36cf9 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,42 +1,44 @@ | |||
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, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
21 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::Core::OSmartPointer<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 RecMailP&mail); | 25 | virtual void deleteMail(const RecMailP&mail); |
26 | virtual void answeredMail(const RecMailP&mail); | 26 | virtual void answeredMail(const RecMailP&mail); |
27 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 27 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 29 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 30 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual MAILLIB::ATYPE 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 | int m_maxsize; | ||
41 | bool m_checksize; | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | #endif | 44 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 3c9b25c..09be91b 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -1,441 +1,468 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | //#include "defines.h" | 8 | //#include "defines.h" |
9 | 9 | ||
10 | #define IMAP_PORT "143" | 10 | #define IMAP_PORT "143" |
11 | #define IMAP_SSL_PORT "993" | 11 | #define IMAP_SSL_PORT "993" |
12 | #define SMTP_PORT "25" | 12 | #define SMTP_PORT "25" |
13 | #define SMTP_SSL_PORT "465" | 13 | #define SMTP_SSL_PORT "465" |
14 | #define POP3_PORT "110" | 14 | #define POP3_PORT "110" |
15 | #define POP3_SSL_PORT "995" | 15 | #define POP3_SSL_PORT "995" |
16 | #define NNTP_PORT "119" | 16 | #define NNTP_PORT "119" |
17 | #define NNTP_SSL_PORT "563" | 17 | #define NNTP_SSL_PORT "563" |
18 | 18 | ||
19 | |||
20 | Settings::Settings() | 19 | Settings::Settings() |
21 | : QObject() | 20 | : QObject() |
22 | { | 21 | { |
23 | updateAccounts(); | 22 | updateAccounts(); |
24 | } | 23 | } |
25 | 24 | ||
26 | void Settings::checkDirectory() | 25 | void Settings::checkDirectory() |
27 | { | 26 | { |
28 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
29 | system( "mkdir -p $HOME/Applications/opiemail" ); | 28 | system( "mkdir -p $HOME/Applications/opiemail" ); |
30 | odebug << "$HOME/Applications/opiemail created" << oendl; | 29 | odebug << "$HOME/Applications/opiemail created" << oendl; |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
34 | QList<Account> Settings::getAccounts() | 33 | QList<Account> Settings::getAccounts() |
35 | { | 34 | { |
36 | return accounts; | 35 | return accounts; |
37 | } | 36 | } |
38 | 37 | ||
39 | void Settings::addAccount( Account *account ) | 38 | void Settings::addAccount( Account *account ) |
40 | { | 39 | { |
41 | accounts.append( account ); | 40 | accounts.append( account ); |
42 | } | 41 | } |
43 | 42 | ||
44 | void Settings::delAccount( Account *account ) | 43 | void Settings::delAccount( Account *account ) |
45 | { | 44 | { |
46 | accounts.remove( account ); | 45 | accounts.remove( account ); |
47 | account->remove(); | 46 | account->remove(); |
48 | } | 47 | } |
49 | 48 | ||
50 | void Settings::updateAccounts() | 49 | void Settings::updateAccounts() |
51 | { | 50 | { |
52 | accounts.clear(); | 51 | accounts.clear(); |
53 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
54 | QStringList::Iterator it; | 53 | QStringList::Iterator it; |
55 | 54 | ||
56 | QStringList imap = dir.entryList( "imap-*" ); | 55 | QStringList imap = dir.entryList( "imap-*" ); |
57 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 56 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
58 | odebug << "Added IMAP account" << oendl; | 57 | odebug << "Added IMAP account" << oendl; |
59 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
60 | accounts.append( account ); | 59 | accounts.append( account ); |
61 | } | 60 | } |
62 | 61 | ||
63 | QStringList pop3 = dir.entryList( "pop3-*" ); | 62 | QStringList pop3 = dir.entryList( "pop3-*" ); |
64 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
65 | odebug << "Added POP account" << oendl; | 64 | odebug << "Added POP account" << oendl; |
66 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
67 | accounts.append( account ); | 66 | accounts.append( account ); |
68 | } | 67 | } |
69 | 68 | ||
70 | QStringList smtp = dir.entryList( "smtp-*" ); | 69 | QStringList smtp = dir.entryList( "smtp-*" ); |
71 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
72 | odebug << "Added SMTP account" << oendl; | 71 | odebug << "Added SMTP account" << oendl; |
73 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
74 | accounts.append( account ); | 73 | accounts.append( account ); |
75 | } | 74 | } |
76 | 75 | ||
77 | QStringList nntp = dir.entryList( "nntp-*" ); | 76 | QStringList nntp = dir.entryList( "nntp-*" ); |
78 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
79 | odebug << "Added NNTP account" << oendl; | 78 | odebug << "Added NNTP account" << oendl; |
80 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
81 | accounts.append( account ); | 80 | accounts.append( account ); |
82 | } | 81 | } |
83 | 82 | ||
84 | readAccounts(); | 83 | readAccounts(); |
85 | } | 84 | } |
86 | 85 | ||
87 | void Settings::saveAccounts() | 86 | void Settings::saveAccounts() |
88 | { | 87 | { |
89 | checkDirectory(); | 88 | checkDirectory(); |
90 | Account *it; | 89 | Account *it; |
91 | 90 | ||
92 | for ( it = accounts.first(); it; it = accounts.next() ) { | 91 | for ( it = accounts.first(); it; it = accounts.next() ) { |
93 | it->save(); | 92 | it->save(); |
94 | } | 93 | } |
95 | } | 94 | } |
96 | 95 | ||
97 | void Settings::readAccounts() | 96 | void Settings::readAccounts() |
98 | { | 97 | { |
99 | checkDirectory(); | 98 | checkDirectory(); |
100 | Account *it; | 99 | Account *it; |
101 | 100 | ||
102 | for ( it = accounts.first(); it; it = accounts.next() ) { | 101 | for ( it = accounts.first(); it; it = accounts.next() ) { |
103 | it->read(); | 102 | it->read(); |
104 | } | 103 | } |
105 | } | 104 | } |
106 | 105 | ||
107 | Account::Account() | 106 | Account::Account() |
108 | { | 107 | { |
109 | accountName = "changeMe"; | 108 | accountName = "changeMe"; |
110 | type = MAILLIB::A_UNDEFINED; | 109 | type = MAILLIB::A_UNDEFINED; |
111 | ssl = false; | 110 | ssl = false; |
112 | connectionType = 1; | 111 | connectionType = 1; |
113 | offline = false; | 112 | offline = false; |
114 | } | 113 | } |
115 | 114 | ||
116 | void Account::remove() | 115 | void Account::remove() |
117 | { | 116 | { |
118 | QFile file( getFileName() ); | 117 | QFile file( getFileName() ); |
119 | file.remove(); | 118 | file.remove(); |
120 | } | 119 | } |
121 | 120 | ||
122 | IMAPaccount::IMAPaccount() | 121 | IMAPaccount::IMAPaccount() |
123 | : Account() | 122 | : Account() |
124 | { | 123 | { |
125 | file = IMAPaccount::getUniqueFileName(); | 124 | file = IMAPaccount::getUniqueFileName(); |
126 | accountName = "New IMAP Account"; | 125 | accountName = "New IMAP Account"; |
127 | ssl = false; | 126 | ssl = false; |
128 | connectionType = 1; | 127 | connectionType = 1; |
129 | type = MAILLIB::A_IMAP; | 128 | type = MAILLIB::A_IMAP; |
130 | port = IMAP_PORT; | 129 | port = IMAP_PORT; |
131 | } | 130 | } |
132 | 131 | ||
133 | IMAPaccount::IMAPaccount( QString filename ) | 132 | IMAPaccount::IMAPaccount( QString filename ) |
134 | : Account() | 133 | : Account() |
135 | { | 134 | { |
136 | file = filename; | 135 | file = filename; |
137 | accountName = "New IMAP Account"; | 136 | accountName = "New IMAP Account"; |
138 | ssl = false; | 137 | ssl = false; |
139 | connectionType = 1; | 138 | connectionType = 1; |
140 | type = MAILLIB::A_IMAP; | 139 | type = MAILLIB::A_IMAP; |
141 | port = IMAP_PORT; | 140 | port = IMAP_PORT; |
142 | } | 141 | } |
143 | 142 | ||
144 | QString IMAPaccount::getUniqueFileName() | 143 | QString IMAPaccount::getUniqueFileName() |
145 | { | 144 | { |
146 | int num = 0; | 145 | int num = 0; |
147 | QString unique; | 146 | QString unique; |
148 | 147 | ||
149 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 148 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
150 | 149 | ||
151 | QStringList imap = dir.entryList( "imap-*" ); | 150 | QStringList imap = dir.entryList( "imap-*" ); |
152 | do { | 151 | do { |
153 | unique.setNum( num++ ); | 152 | unique.setNum( num++ ); |
154 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 153 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
155 | 154 | ||
156 | return unique; | 155 | return unique; |
157 | } | 156 | } |
158 | 157 | ||
159 | void IMAPaccount::read() | 158 | void IMAPaccount::read() |
160 | { | 159 | { |
161 | Config *conf = new Config( getFileName(), Config::File ); | 160 | Config *conf = new Config( getFileName(), Config::File ); |
162 | conf->setGroup( "IMAP Account" ); | 161 | conf->setGroup( "IMAP Account" ); |
163 | accountName = conf->readEntry( "Account","" ); | 162 | accountName = conf->readEntry( "Account","" ); |
164 | if (accountName.isNull()) accountName = ""; | 163 | if (accountName.isNull()) accountName = ""; |
165 | server = conf->readEntry( "Server","" ); | 164 | server = conf->readEntry( "Server","" ); |
166 | if (server.isNull()) server=""; | 165 | if (server.isNull()) server=""; |
167 | port = conf->readEntry( "Port","" ); | 166 | port = conf->readEntry( "Port","" ); |
168 | if (port.isNull()) port="143"; | 167 | if (port.isNull()) port="143"; |
169 | connectionType = conf->readNumEntry( "ConnectionType" ); | 168 | connectionType = conf->readNumEntry( "ConnectionType" ); |
170 | ssl = conf->readBoolEntry( "SSL",false ); | 169 | ssl = conf->readBoolEntry( "SSL",false ); |
171 | user = conf->readEntry( "User","" ); | 170 | user = conf->readEntry( "User","" ); |
172 | if (user.isNull()) user = ""; | 171 | if (user.isNull()) user = ""; |
173 | password = conf->readEntryCrypt( "Password","" ); | 172 | password = conf->readEntryCrypt( "Password","" ); |
174 | if (password.isNull()) password = ""; | 173 | if (password.isNull()) password = ""; |
175 | prefix = conf->readEntry("MailPrefix",""); | 174 | prefix = conf->readEntry("MailPrefix",""); |
176 | if (prefix.isNull()) prefix = ""; | 175 | if (prefix.isNull()) prefix = ""; |
177 | offline = conf->readBoolEntry("Offline",false); | 176 | offline = conf->readBoolEntry("Offline",false); |
178 | delete conf; | 177 | delete conf; |
179 | } | 178 | } |
180 | 179 | ||
181 | void IMAPaccount::save() | 180 | void IMAPaccount::save() |
182 | { | 181 | { |
183 | odebug << "saving " + getFileName() << oendl; | 182 | odebug << "saving " + getFileName() << oendl; |
184 | Settings::checkDirectory(); | 183 | Settings::checkDirectory(); |
185 | 184 | ||
186 | Config *conf = new Config( getFileName(), Config::File ); | 185 | Config *conf = new Config( getFileName(), Config::File ); |
187 | conf->setGroup( "IMAP Account" ); | 186 | conf->setGroup( "IMAP Account" ); |
188 | conf->writeEntry( "Account", accountName ); | 187 | conf->writeEntry( "Account", accountName ); |
189 | conf->writeEntry( "Server", server ); | 188 | conf->writeEntry( "Server", server ); |
190 | conf->writeEntry( "Port", port ); | 189 | conf->writeEntry( "Port", port ); |
191 | conf->writeEntry( "SSL", ssl ); | 190 | conf->writeEntry( "SSL", ssl ); |
192 | conf->writeEntry( "ConnectionType", connectionType ); | 191 | conf->writeEntry( "ConnectionType", connectionType ); |
193 | conf->writeEntry( "User", user ); | 192 | conf->writeEntry( "User", user ); |
194 | conf->writeEntryCrypt( "Password", password ); | 193 | conf->writeEntryCrypt( "Password", password ); |
195 | conf->writeEntry( "MailPrefix",prefix); | 194 | conf->writeEntry( "MailPrefix",prefix); |
196 | conf->writeEntry( "Offline",offline); | 195 | conf->writeEntry( "Offline",offline); |
197 | conf->write(); | 196 | conf->write(); |
198 | delete conf; | 197 | delete conf; |
199 | } | 198 | } |
200 | 199 | ||
201 | 200 | ||
202 | QString IMAPaccount::getFileName() | 201 | QString IMAPaccount::getFileName() |
203 | { | 202 | { |
204 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 203 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
205 | } | 204 | } |
206 | 205 | ||
207 | POP3account::POP3account() | 206 | POP3account::POP3account() |
208 | : Account() | 207 | : Account() |
209 | { | 208 | { |
210 | file = POP3account::getUniqueFileName(); | 209 | file = POP3account::getUniqueFileName(); |
211 | accountName = "New POP3 Account"; | 210 | accountName = "New POP3 Account"; |
212 | ssl = false; | 211 | ssl = false; |
213 | connectionType = 1; | 212 | connectionType = 1; |
214 | type = MAILLIB::A_POP3; | 213 | type = MAILLIB::A_POP3; |
215 | port = POP3_PORT; | 214 | port = POP3_PORT; |
215 | m_CheckSize = true; | ||
216 | m_MaxSize = 1024; | ||
216 | } | 217 | } |
217 | 218 | ||
218 | POP3account::POP3account( QString filename ) | 219 | POP3account::POP3account( QString filename ) |
219 | : Account() | 220 | : Account() |
220 | { | 221 | { |
221 | file = filename; | 222 | file = filename; |
222 | accountName = "New POP3 Account"; | 223 | accountName = "New POP3 Account"; |
223 | ssl = false; | 224 | ssl = false; |
224 | connectionType = 1; | 225 | connectionType = 1; |
225 | type = MAILLIB::A_POP3; | 226 | type = MAILLIB::A_POP3; |
226 | port = POP3_PORT; | 227 | port = POP3_PORT; |
228 | m_CheckSize = true; | ||
229 | m_MaxSize = 1024; | ||
227 | } | 230 | } |
228 | 231 | ||
229 | QString POP3account::getUniqueFileName() | 232 | QString POP3account::getUniqueFileName() |
230 | { | 233 | { |
231 | int num = 0; | 234 | int num = 0; |
232 | QString unique; | 235 | QString unique; |
233 | 236 | ||
234 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 237 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
235 | 238 | ||
236 | QStringList imap = dir.entryList( "pop3-*" ); | 239 | QStringList imap = dir.entryList( "pop3-*" ); |
237 | do { | 240 | do { |
238 | unique.setNum( num++ ); | 241 | unique.setNum( num++ ); |
239 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 242 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
240 | 243 | ||
241 | return unique; | 244 | return unique; |
242 | } | 245 | } |
243 | 246 | ||
244 | void POP3account::read() | 247 | void POP3account::read() |
245 | { | 248 | { |
246 | Config *conf = new Config( getFileName(), Config::File ); | 249 | Config *conf = new Config( getFileName(), Config::File ); |
247 | conf->setGroup( "POP3 Account" ); | 250 | conf->setGroup( "POP3 Account" ); |
248 | accountName = conf->readEntry( "Account" ); | 251 | accountName = conf->readEntry( "Account" ); |
249 | server = conf->readEntry( "Server" ); | 252 | server = conf->readEntry( "Server" ); |
250 | port = conf->readEntry( "Port" ); | 253 | port = conf->readEntry( "Port" ); |
251 | ssl = conf->readBoolEntry( "SSL" ); | 254 | ssl = conf->readBoolEntry( "SSL" ); |
252 | connectionType = conf->readNumEntry( "ConnectionType" ); | 255 | connectionType = conf->readNumEntry( "ConnectionType" ); |
253 | user = conf->readEntry( "User" ); | 256 | user = conf->readEntry( "User" ); |
254 | password = conf->readEntryCrypt( "Password" ); | 257 | password = conf->readEntryCrypt( "Password" ); |
255 | offline = conf->readBoolEntry("Offline",false); | 258 | offline = conf->readBoolEntry("Offline",false); |
259 | m_CheckSize = conf->readBoolEntry("Checkmaxsize",true); | ||
260 | m_MaxSize = conf->readNumEntry("Maxsize",1024); | ||
256 | delete conf; | 261 | delete conf; |
257 | } | 262 | } |
258 | 263 | ||
259 | void POP3account::save() | 264 | void POP3account::save() |
260 | { | 265 | { |
261 | odebug << "saving " + getFileName() << oendl; | 266 | odebug << "saving " + getFileName() << oendl; |
262 | Settings::checkDirectory(); | 267 | Settings::checkDirectory(); |
263 | 268 | ||
264 | Config *conf = new Config( getFileName(), Config::File ); | 269 | Config *conf = new Config( getFileName(), Config::File ); |
265 | conf->setGroup( "POP3 Account" ); | 270 | conf->setGroup( "POP3 Account" ); |
266 | conf->writeEntry( "Account", accountName ); | 271 | conf->writeEntry( "Account", accountName ); |
267 | conf->writeEntry( "Server", server ); | 272 | conf->writeEntry( "Server", server ); |
268 | conf->writeEntry( "Port", port ); | 273 | conf->writeEntry( "Port", port ); |
269 | conf->writeEntry( "SSL", ssl ); | 274 | conf->writeEntry( "SSL", ssl ); |
270 | conf->writeEntry( "ConnectionType", connectionType ); | 275 | conf->writeEntry( "ConnectionType", connectionType ); |
271 | conf->writeEntry( "User", user ); | 276 | conf->writeEntry( "User", user ); |
272 | conf->writeEntryCrypt( "Password", password ); | 277 | conf->writeEntryCrypt( "Password", password ); |
273 | conf->writeEntry( "Offline",offline); | 278 | conf->writeEntry( "Offline",offline); |
279 | conf->writeEntry("Checkmaxsize",m_CheckSize); | ||
280 | conf->writeEntry("Maxsize",m_MaxSize); | ||
274 | conf->write(); | 281 | conf->write(); |
275 | delete conf; | 282 | delete conf; |
276 | } | 283 | } |
277 | 284 | ||
278 | 285 | ||
279 | QString POP3account::getFileName() | 286 | QString POP3account::getFileName() |
280 | { | 287 | { |
281 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 288 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
282 | } | 289 | } |
283 | 290 | ||
291 | bool POP3account::getCheckMaxSize()const | ||
292 | { | ||
293 | return m_CheckSize; | ||
294 | } | ||
295 | |||
296 | void POP3account::setCheckMaxSize(bool aValue) | ||
297 | { | ||
298 | m_CheckSize = aValue; | ||
299 | } | ||
300 | |||
301 | int POP3account::getMaxSize()const | ||
302 | { | ||
303 | return m_MaxSize; | ||
304 | } | ||
305 | |||
306 | void POP3account::setMaxSize(int aValue) | ||
307 | { | ||
308 | m_MaxSize = aValue; | ||
309 | } | ||
310 | |||
284 | SMTPaccount::SMTPaccount() | 311 | SMTPaccount::SMTPaccount() |
285 | : Account() | 312 | : Account() |
286 | { | 313 | { |
287 | file = SMTPaccount::getUniqueFileName(); | 314 | file = SMTPaccount::getUniqueFileName(); |
288 | accountName = "New SMTP Account"; | 315 | accountName = "New SMTP Account"; |
289 | ssl = false; | 316 | ssl = false; |
290 | connectionType = 1; | 317 | connectionType = 1; |
291 | login = false; | 318 | login = false; |
292 | useCC = false; | 319 | useCC = false; |
293 | useBCC = false; | 320 | useBCC = false; |
294 | useReply = false; | 321 | useReply = false; |
295 | type = MAILLIB::A_SMTP; | 322 | type = MAILLIB::A_SMTP; |
296 | port = SMTP_PORT; | 323 | port = SMTP_PORT; |
297 | } | 324 | } |
298 | 325 | ||
299 | SMTPaccount::SMTPaccount( QString filename ) | 326 | SMTPaccount::SMTPaccount( QString filename ) |
300 | : Account() | 327 | : Account() |
301 | { | 328 | { |
302 | file = filename; | 329 | file = filename; |
303 | accountName = "New SMTP Account"; | 330 | accountName = "New SMTP Account"; |
304 | ssl = false; | 331 | ssl = false; |
305 | connectionType = 1; | 332 | connectionType = 1; |
306 | login = false; | 333 | login = false; |
307 | type = MAILLIB::A_SMTP; | 334 | type = MAILLIB::A_SMTP; |
308 | port = SMTP_PORT; | 335 | port = SMTP_PORT; |
309 | } | 336 | } |
310 | 337 | ||
311 | QString SMTPaccount::getUniqueFileName() | 338 | QString SMTPaccount::getUniqueFileName() |
312 | { | 339 | { |
313 | int num = 0; | 340 | int num = 0; |
314 | QString unique; | 341 | QString unique; |
315 | 342 | ||
316 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 343 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
317 | 344 | ||
318 | QStringList imap = dir.entryList( "smtp-*" ); | 345 | QStringList imap = dir.entryList( "smtp-*" ); |
319 | do { | 346 | do { |
320 | unique.setNum( num++ ); | 347 | unique.setNum( num++ ); |
321 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 348 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
322 | 349 | ||
323 | return unique; | 350 | return unique; |
324 | } | 351 | } |
325 | 352 | ||
326 | void SMTPaccount::read() | 353 | void SMTPaccount::read() |
327 | { | 354 | { |
328 | Config *conf = new Config( getFileName(), Config::File ); | 355 | Config *conf = new Config( getFileName(), Config::File ); |
329 | conf->setGroup( "SMTP Account" ); | 356 | conf->setGroup( "SMTP Account" ); |
330 | accountName = conf->readEntry( "Account" ); | 357 | accountName = conf->readEntry( "Account" ); |
331 | server = conf->readEntry( "Server" ); | 358 | server = conf->readEntry( "Server" ); |
332 | port = conf->readEntry( "Port" ); | 359 | port = conf->readEntry( "Port" ); |
333 | ssl = conf->readBoolEntry( "SSL" ); | 360 | ssl = conf->readBoolEntry( "SSL" ); |
334 | connectionType = conf->readNumEntry( "ConnectionType" ); | 361 | connectionType = conf->readNumEntry( "ConnectionType" ); |
335 | login = conf->readBoolEntry( "Login" ); | 362 | login = conf->readBoolEntry( "Login" ); |
336 | user = conf->readEntry( "User" ); | 363 | user = conf->readEntry( "User" ); |
337 | password = conf->readEntryCrypt( "Password" ); | 364 | password = conf->readEntryCrypt( "Password" ); |
338 | delete conf; | 365 | delete conf; |
339 | } | 366 | } |
340 | 367 | ||
341 | void SMTPaccount::save() | 368 | void SMTPaccount::save() |
342 | { | 369 | { |
343 | odebug << "saving " + getFileName() << oendl; | 370 | odebug << "saving " + getFileName() << oendl; |
344 | Settings::checkDirectory(); | 371 | Settings::checkDirectory(); |
345 | 372 | ||
346 | Config *conf = new Config( getFileName(), Config::File ); | 373 | Config *conf = new Config( getFileName(), Config::File ); |
347 | conf->setGroup( "SMTP Account" ); | 374 | conf->setGroup( "SMTP Account" ); |
348 | conf->writeEntry( "Account", accountName ); | 375 | conf->writeEntry( "Account", accountName ); |
349 | conf->writeEntry( "Server", server ); | 376 | conf->writeEntry( "Server", server ); |
350 | conf->writeEntry( "Port", port ); | 377 | conf->writeEntry( "Port", port ); |
351 | conf->writeEntry( "SSL", ssl ); | 378 | conf->writeEntry( "SSL", ssl ); |
352 | conf->writeEntry( "ConnectionType", connectionType ); | 379 | conf->writeEntry( "ConnectionType", connectionType ); |
353 | conf->writeEntry( "Login", login ); | 380 | conf->writeEntry( "Login", login ); |
354 | conf->writeEntry( "User", user ); | 381 | conf->writeEntry( "User", user ); |
355 | conf->writeEntryCrypt( "Password", password ); | 382 | conf->writeEntryCrypt( "Password", password ); |
356 | conf->write(); | 383 | conf->write(); |
357 | delete conf; | 384 | delete conf; |
358 | } | 385 | } |
359 | 386 | ||
360 | 387 | ||
361 | QString SMTPaccount::getFileName() | 388 | QString SMTPaccount::getFileName() |
362 | { | 389 | { |
363 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; | 390 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; |
364 | } | 391 | } |
365 | 392 | ||
366 | NNTPaccount::NNTPaccount() | 393 | NNTPaccount::NNTPaccount() |
367 | : Account() | 394 | : Account() |
368 | { | 395 | { |
369 | file = NNTPaccount::getUniqueFileName(); | 396 | file = NNTPaccount::getUniqueFileName(); |
370 | accountName = "New NNTP Account"; | 397 | accountName = "New NNTP Account"; |
371 | ssl = false; | 398 | ssl = false; |
372 | login = false; | 399 | login = false; |
373 | type = MAILLIB::A_NNTP; | 400 | type = MAILLIB::A_NNTP; |
374 | port = NNTP_PORT; | 401 | port = NNTP_PORT; |
375 | } | 402 | } |
376 | 403 | ||
377 | NNTPaccount::NNTPaccount( QString filename ) | 404 | NNTPaccount::NNTPaccount( QString filename ) |
378 | : Account() | 405 | : Account() |
379 | { | 406 | { |
380 | file = filename; | 407 | file = filename; |
381 | accountName = "New NNTP Account"; | 408 | accountName = "New NNTP Account"; |
382 | ssl = false; | 409 | ssl = false; |
383 | login = false; | 410 | login = false; |
384 | type = MAILLIB::A_NNTP; | 411 | type = MAILLIB::A_NNTP; |
385 | port = NNTP_PORT; | 412 | port = NNTP_PORT; |
386 | } | 413 | } |
387 | 414 | ||
388 | QString NNTPaccount::getUniqueFileName() | 415 | QString NNTPaccount::getUniqueFileName() |
389 | { | 416 | { |
390 | int num = 0; | 417 | int num = 0; |
391 | QString unique; | 418 | QString unique; |
392 | 419 | ||
393 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 420 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
394 | 421 | ||
395 | QStringList imap = dir.entryList( "nntp-*" ); | 422 | QStringList imap = dir.entryList( "nntp-*" ); |
396 | do { | 423 | do { |
397 | unique.setNum( num++ ); | 424 | unique.setNum( num++ ); |
398 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 425 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
399 | 426 | ||
400 | return unique; | 427 | return unique; |
401 | } | 428 | } |
402 | 429 | ||
403 | void NNTPaccount::read() | 430 | void NNTPaccount::read() |
404 | { | 431 | { |
405 | Config *conf = new Config( getFileName(), Config::File ); | 432 | Config *conf = new Config( getFileName(), Config::File ); |
406 | conf->setGroup( "NNTP Account" ); | 433 | conf->setGroup( "NNTP Account" ); |
407 | accountName = conf->readEntry( "Account" ); | 434 | accountName = conf->readEntry( "Account" ); |
408 | server = conf->readEntry( "Server" ); | 435 | server = conf->readEntry( "Server" ); |
409 | port = conf->readEntry( "Port" ); | 436 | port = conf->readEntry( "Port" ); |
410 | ssl = conf->readBoolEntry( "SSL" ); | 437 | ssl = conf->readBoolEntry( "SSL" ); |
411 | login = conf->readBoolEntry( "Login" ); | 438 | login = conf->readBoolEntry( "Login" ); |
412 | user = conf->readEntry( "User" ); | 439 | user = conf->readEntry( "User" ); |
413 | password = conf->readEntryCrypt( "Password" ); | 440 | password = conf->readEntryCrypt( "Password" ); |
414 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); | 441 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); |
415 | delete conf; | 442 | delete conf; |
416 | } | 443 | } |
417 | 444 | ||
418 | void NNTPaccount::save() | 445 | void NNTPaccount::save() |
419 | { | 446 | { |
420 | odebug << "saving " + getFileName() << oendl; | 447 | odebug << "saving " + getFileName() << oendl; |
421 | Settings::checkDirectory(); | 448 | Settings::checkDirectory(); |
422 | 449 | ||
423 | Config *conf = new Config( getFileName(), Config::File ); | 450 | Config *conf = new Config( getFileName(), Config::File ); |
424 | conf->setGroup( "NNTP Account" ); | 451 | conf->setGroup( "NNTP Account" ); |
425 | conf->writeEntry( "Account", accountName ); | 452 | conf->writeEntry( "Account", accountName ); |
426 | conf->writeEntry( "Server", server ); | 453 | conf->writeEntry( "Server", server ); |
427 | conf->writeEntry( "Port", port ); | 454 | conf->writeEntry( "Port", port ); |
428 | conf->writeEntry( "SSL", ssl ); | 455 | conf->writeEntry( "SSL", ssl ); |
429 | conf->writeEntry( "Login", login ); | 456 | conf->writeEntry( "Login", login ); |
430 | conf->writeEntry( "User", user ); | 457 | conf->writeEntry( "User", user ); |
431 | conf->writeEntryCrypt( "Password", password ); | 458 | conf->writeEntryCrypt( "Password", password ); |
432 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); | 459 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); |
433 | conf->write(); | 460 | conf->write(); |
434 | delete conf; | 461 | delete conf; |
435 | } | 462 | } |
436 | 463 | ||
437 | 464 | ||
438 | QString NNTPaccount::getFileName() | 465 | QString NNTPaccount::getFileName() |
439 | { | 466 | { |
440 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; | 467 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; |
441 | } | 468 | } |
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index bf27b97..8683a05 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h | |||
@@ -28,132 +28,137 @@ public: | |||
28 | void setPort(const QString&str) { port = str; } | 28 | void setPort(const QString&str) { port = str; } |
29 | const QString&getPort()const{ return port; } | 29 | const QString&getPort()const{ return port; } |
30 | 30 | ||
31 | void setUser(const QString&str){ user = str; } | 31 | void setUser(const QString&str){ user = str; } |
32 | const QString&getUser()const{ return user; } | 32 | const QString&getUser()const{ return user; } |
33 | 33 | ||
34 | void setPassword(const QString&str) { password = str; } | 34 | void setPassword(const QString&str) { password = str; } |
35 | const QString&getPassword()const { return password; } | 35 | const QString&getPassword()const { return password; } |
36 | 36 | ||
37 | void setSSL( bool b ) { ssl = b; } | 37 | void setSSL( bool b ) { ssl = b; } |
38 | bool getSSL() { return ssl; } | 38 | bool getSSL() { return ssl; } |
39 | 39 | ||
40 | void setConnectionType( int x ) { connectionType = x; } | 40 | void setConnectionType( int x ) { connectionType = x; } |
41 | int ConnectionType() { return connectionType; } | 41 | int ConnectionType() { return connectionType; } |
42 | 42 | ||
43 | 43 | ||
44 | void setOffline(bool b) {offline = b;} | 44 | void setOffline(bool b) {offline = b;} |
45 | bool getOffline()const{return offline;} | 45 | bool getOffline()const{return offline;} |
46 | 46 | ||
47 | virtual QString getFileName() { return accountName; } | 47 | virtual QString getFileName() { return accountName; } |
48 | virtual void read() { odebug << "base reading..." << oendl; } | 48 | virtual void read() { odebug << "base reading..." << oendl; } |
49 | virtual void save() { odebug << "base saving..." << oendl; } | 49 | virtual void save() { odebug << "base saving..." << oendl; } |
50 | 50 | ||
51 | protected: | 51 | protected: |
52 | QString accountName, server, port, user, password; | 52 | QString accountName, server, port, user, password; |
53 | bool ssl; | 53 | bool ssl; |
54 | int connectionType; | 54 | int connectionType; |
55 | bool offline; | 55 | bool offline; |
56 | MAILLIB::ATYPE type; | 56 | MAILLIB::ATYPE type; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | class IMAPaccount : public Account | 59 | class IMAPaccount : public Account |
60 | { | 60 | { |
61 | 61 | ||
62 | public: | 62 | public: |
63 | IMAPaccount(); | 63 | IMAPaccount(); |
64 | IMAPaccount( QString filename ); | 64 | IMAPaccount( QString filename ); |
65 | 65 | ||
66 | static QString getUniqueFileName(); | 66 | static QString getUniqueFileName(); |
67 | 67 | ||
68 | virtual void read(); | 68 | virtual void read(); |
69 | virtual void save(); | 69 | virtual void save(); |
70 | virtual QString getFileName(); | 70 | virtual QString getFileName(); |
71 | 71 | ||
72 | void setPrefix(const QString&str) {prefix=str;} | 72 | void setPrefix(const QString&str) {prefix=str;} |
73 | const QString&getPrefix()const{return prefix;} | 73 | const QString&getPrefix()const{return prefix;} |
74 | 74 | ||
75 | private: | 75 | private: |
76 | QString file,prefix; | 76 | QString file,prefix; |
77 | 77 | ||
78 | }; | 78 | }; |
79 | 79 | ||
80 | class POP3account : public Account | 80 | class POP3account : public Account |
81 | { | 81 | { |
82 | 82 | ||
83 | public: | 83 | public: |
84 | POP3account(); | 84 | POP3account(); |
85 | POP3account( QString filename ); | 85 | POP3account( QString filename ); |
86 | 86 | ||
87 | static QString getUniqueFileName(); | 87 | static QString getUniqueFileName(); |
88 | 88 | ||
89 | virtual void read(); | 89 | virtual void read(); |
90 | virtual void save(); | 90 | virtual void save(); |
91 | virtual QString getFileName(); | 91 | virtual QString getFileName(); |
92 | virtual bool getCheckMaxSize()const; | ||
93 | virtual void setCheckMaxSize(bool); | ||
94 | virtual int getMaxSize()const; | ||
95 | virtual void setMaxSize(int); | ||
92 | 96 | ||
93 | private: | 97 | private: |
94 | QString file; | 98 | QString file; |
95 | 99 | bool m_CheckSize; | |
100 | int m_MaxSize; | ||
96 | }; | 101 | }; |
97 | 102 | ||
98 | class SMTPaccount : public Account | 103 | class SMTPaccount : public Account |
99 | { | 104 | { |
100 | 105 | ||
101 | public: | 106 | public: |
102 | SMTPaccount(); | 107 | SMTPaccount(); |
103 | SMTPaccount( QString filename ); | 108 | SMTPaccount( QString filename ); |
104 | 109 | ||
105 | static QString getUniqueFileName(); | 110 | static QString getUniqueFileName(); |
106 | 111 | ||
107 | virtual void read(); | 112 | virtual void read(); |
108 | virtual void save(); | 113 | virtual void save(); |
109 | virtual QString getFileName(); | 114 | virtual QString getFileName(); |
110 | 115 | ||
111 | void setLogin( bool b ) { login = b; } | 116 | void setLogin( bool b ) { login = b; } |
112 | bool getLogin() { return login; } | 117 | bool getLogin() { return login; } |
113 | 118 | ||
114 | private: | 119 | private: |
115 | QString file, name, mail, org, cc, bcc, reply, signature; | 120 | QString file, name, mail, org, cc, bcc, reply, signature; |
116 | bool useCC, useBCC, useReply, login; | 121 | bool useCC, useBCC, useReply, login; |
117 | 122 | ||
118 | }; | 123 | }; |
119 | 124 | ||
120 | class NNTPaccount : public Account | 125 | class NNTPaccount : public Account |
121 | { | 126 | { |
122 | 127 | ||
123 | public: | 128 | public: |
124 | NNTPaccount(); | 129 | NNTPaccount(); |
125 | NNTPaccount( QString filename ); | 130 | NNTPaccount( QString filename ); |
126 | 131 | ||
127 | static QString getUniqueFileName(); | 132 | static QString getUniqueFileName(); |
128 | 133 | ||
129 | virtual void read(); | 134 | virtual void read(); |
130 | virtual void save(); | 135 | virtual void save(); |
131 | virtual QString getFileName(); | 136 | virtual QString getFileName(); |
132 | 137 | ||
133 | void setLogin( bool b ) { login = b; } | 138 | void setLogin( bool b ) { login = b; } |
134 | bool getLogin() { return login; } | 139 | bool getLogin() { return login; } |
135 | 140 | ||
136 | void setGroups( QStringList list ) { subscribedGroups = list; } | 141 | void setGroups( QStringList list ) { subscribedGroups = list; } |
137 | QStringList getGroups() { return subscribedGroups; } | 142 | QStringList getGroups() { return subscribedGroups; } |
138 | 143 | ||
139 | private: | 144 | private: |
140 | QString file; | 145 | QString file; |
141 | bool login; | 146 | bool login; |
142 | QStringList subscribedGroups; | 147 | QStringList subscribedGroups; |
143 | 148 | ||
144 | }; | 149 | }; |
145 | 150 | ||
146 | class Settings : public QObject | 151 | class Settings : public QObject |
147 | { | 152 | { |
148 | Q_OBJECT | 153 | Q_OBJECT |
149 | 154 | ||
150 | public: | 155 | public: |
151 | Settings(); | 156 | Settings(); |
152 | QList<Account> getAccounts(); | 157 | QList<Account> getAccounts(); |
153 | void addAccount(Account *account); | 158 | void addAccount(Account *account); |
154 | void delAccount(Account *account); | 159 | void delAccount(Account *account); |
155 | void saveAccounts(); | 160 | void saveAccounts(); |
156 | void readAccounts(); | 161 | void readAccounts(); |
157 | static void checkDirectory(); | 162 | static void checkDirectory(); |
158 | 163 | ||
159 | private: | 164 | private: |
diff --git a/noncore/net/mail/pop3configui.ui b/noncore/net/mail/pop3configui.ui index 1014ef4..e560661 100644 --- a/noncore/net/mail/pop3configui.ui +++ b/noncore/net/mail/pop3configui.ui | |||
@@ -1,99 +1,99 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>POP3configUI</class> | 2 | <class>POP3configUI</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>POP3configUI</cstring> | 7 | <cstring>POP3configUI</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>314</width> | 14 | <width>302</width> |
15 | <height>410</height> | 15 | <height>410</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Configure POP3</string> | 20 | <string>Configure POP3</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <vbox> | 28 | <vbox> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>3</number> | 31 | <number>11</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>3</number> | 35 | <number>6</number> |
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget> |
38 | <class>QLayoutWidget</class> | 38 | <class>QLayoutWidget</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>Layout12</cstring> | 41 | <cstring>Layout12</cstring> |
42 | </property> | 42 | </property> |
43 | <hbox> | 43 | <hbox> |
44 | <property stdset="1"> | 44 | <property stdset="1"> |
45 | <name>margin</name> | 45 | <name>margin</name> |
46 | <number>0</number> | 46 | <number>0</number> |
47 | </property> | 47 | </property> |
48 | <property stdset="1"> | 48 | <property stdset="1"> |
49 | <name>spacing</name> | 49 | <name>spacing</name> |
50 | <number>6</number> | 50 | <number>6</number> |
51 | </property> | 51 | </property> |
52 | <widget> | 52 | <widget> |
53 | <class>QLabel</class> | 53 | <class>QLabel</class> |
54 | <property stdset="1"> | 54 | <property stdset="1"> |
55 | <name>name</name> | 55 | <name>name</name> |
56 | <cstring>accountLabel</cstring> | 56 | <cstring>accountLabel</cstring> |
57 | </property> | 57 | </property> |
58 | <property stdset="1"> | 58 | <property stdset="1"> |
59 | <name>text</name> | 59 | <name>text</name> |
60 | <string>Account</string> | 60 | <string>Account</string> |
61 | </property> | 61 | </property> |
62 | </widget> | 62 | </widget> |
63 | <widget> | 63 | <widget> |
64 | <class>QLineEdit</class> | 64 | <class>QLineEdit</class> |
65 | <property stdset="1"> | 65 | <property stdset="1"> |
66 | <name>name</name> | 66 | <name>name</name> |
67 | <cstring>accountLine</cstring> | 67 | <cstring>accountLine</cstring> |
68 | </property> | 68 | </property> |
69 | <property> | 69 | <property> |
70 | <name>toolTip</name> | 70 | <name>toolTip</name> |
71 | <string>Name of the Account</string> | 71 | <string>Name of the Account</string> |
72 | </property> | 72 | </property> |
73 | </widget> | 73 | </widget> |
74 | </hbox> | 74 | </hbox> |
75 | </widget> | 75 | </widget> |
76 | <widget> | 76 | <widget> |
77 | <class>Line</class> | 77 | <class>Line</class> |
78 | <property stdset="1"> | 78 | <property stdset="1"> |
79 | <name>name</name> | 79 | <name>name</name> |
80 | <cstring>line1</cstring> | 80 | <cstring>line1</cstring> |
81 | </property> | 81 | </property> |
82 | <property stdset="1"> | 82 | <property stdset="1"> |
83 | <name>orientation</name> | 83 | <name>orientation</name> |
84 | <enum>Horizontal</enum> | 84 | <enum>Horizontal</enum> |
85 | </property> | 85 | </property> |
86 | </widget> | 86 | </widget> |
87 | <widget> | 87 | <widget> |
88 | <class>QLayoutWidget</class> | 88 | <class>QLayoutWidget</class> |
89 | <property stdset="1"> | 89 | <property stdset="1"> |
90 | <name>name</name> | 90 | <name>name</name> |
91 | <cstring>Layout11</cstring> | 91 | <cstring>Layout11</cstring> |
92 | </property> | 92 | </property> |
93 | <hbox> | 93 | <hbox> |
94 | <property stdset="1"> | 94 | <property stdset="1"> |
95 | <name>margin</name> | 95 | <name>margin</name> |
96 | <number>0</number> | 96 | <number>0</number> |
97 | </property> | 97 | </property> |
98 | <property stdset="1"> | 98 | <property stdset="1"> |
99 | <name>spacing</name> | 99 | <name>spacing</name> |
@@ -258,95 +258,157 @@ | |||
258 | <name>spacing</name> | 258 | <name>spacing</name> |
259 | <number>6</number> | 259 | <number>6</number> |
260 | </property> | 260 | </property> |
261 | <widget> | 261 | <widget> |
262 | <class>QLabel</class> | 262 | <class>QLabel</class> |
263 | <property stdset="1"> | 263 | <property stdset="1"> |
264 | <name>name</name> | 264 | <name>name</name> |
265 | <cstring>userLabel</cstring> | 265 | <cstring>userLabel</cstring> |
266 | </property> | 266 | </property> |
267 | <property stdset="1"> | 267 | <property stdset="1"> |
268 | <name>text</name> | 268 | <name>text</name> |
269 | <string>User</string> | 269 | <string>User</string> |
270 | </property> | 270 | </property> |
271 | </widget> | 271 | </widget> |
272 | <widget> | 272 | <widget> |
273 | <class>QLabel</class> | 273 | <class>QLabel</class> |
274 | <property stdset="1"> | 274 | <property stdset="1"> |
275 | <name>name</name> | 275 | <name>name</name> |
276 | <cstring>passLabel</cstring> | 276 | <cstring>passLabel</cstring> |
277 | </property> | 277 | </property> |
278 | <property stdset="1"> | 278 | <property stdset="1"> |
279 | <name>text</name> | 279 | <name>text</name> |
280 | <string>Password</string> | 280 | <string>Password</string> |
281 | </property> | 281 | </property> |
282 | </widget> | 282 | </widget> |
283 | </vbox> | 283 | </vbox> |
284 | </widget> | 284 | </widget> |
285 | <widget> | 285 | <widget> |
286 | <class>QLayoutWidget</class> | 286 | <class>QLayoutWidget</class> |
287 | <property stdset="1"> | 287 | <property stdset="1"> |
288 | <name>name</name> | 288 | <name>name</name> |
289 | <cstring>Layout5</cstring> | 289 | <cstring>Layout5</cstring> |
290 | </property> | 290 | </property> |
291 | <vbox> | 291 | <vbox> |
292 | <property stdset="1"> | 292 | <property stdset="1"> |
293 | <name>margin</name> | 293 | <name>margin</name> |
294 | <number>0</number> | 294 | <number>0</number> |
295 | </property> | 295 | </property> |
296 | <property stdset="1"> | 296 | <property stdset="1"> |
297 | <name>spacing</name> | 297 | <name>spacing</name> |
298 | <number>6</number> | 298 | <number>6</number> |
299 | </property> | 299 | </property> |
300 | <widget> | 300 | <widget> |
301 | <class>QLineEdit</class> | 301 | <class>QLineEdit</class> |
302 | <property stdset="1"> | 302 | <property stdset="1"> |
303 | <name>name</name> | 303 | <name>name</name> |
304 | <cstring>userLine</cstring> | 304 | <cstring>userLine</cstring> |
305 | </property> | 305 | </property> |
306 | </widget> | 306 | </widget> |
307 | <widget> | 307 | <widget> |
308 | <class>QLineEdit</class> | 308 | <class>QLineEdit</class> |
309 | <property stdset="1"> | 309 | <property stdset="1"> |
310 | <name>name</name> | 310 | <name>name</name> |
311 | <cstring>passLine</cstring> | 311 | <cstring>passLine</cstring> |
312 | </property> | 312 | </property> |
313 | <property stdset="1"> | 313 | <property stdset="1"> |
314 | <name>echoMode</name> | 314 | <name>echoMode</name> |
315 | <enum>Password</enum> | 315 | <enum>Password</enum> |
316 | </property> | 316 | </property> |
317 | </widget> | 317 | </widget> |
318 | </vbox> | 318 | </vbox> |
319 | </widget> | 319 | </widget> |
320 | </hbox> | 320 | </hbox> |
321 | </widget> | 321 | </widget> |
322 | <widget> | ||
323 | <class>QCheckBox</class> | ||
324 | <property stdset="1"> | ||
325 | <name>name</name> | ||
326 | <cstring>m_CheckSize</cstring> | ||
327 | </property> | ||
328 | <property stdset="1"> | ||
329 | <name>text</name> | ||
330 | <string>ask before downloading large mails</string> | ||
331 | </property> | ||
332 | </widget> | ||
333 | <widget> | ||
334 | <class>QLayoutWidget</class> | ||
335 | <property stdset="1"> | ||
336 | <name>name</name> | ||
337 | <cstring>Layout9</cstring> | ||
338 | </property> | ||
339 | <grid> | ||
340 | <property stdset="1"> | ||
341 | <name>margin</name> | ||
342 | <number>0</number> | ||
343 | </property> | ||
344 | <property stdset="1"> | ||
345 | <name>spacing</name> | ||
346 | <number>6</number> | ||
347 | </property> | ||
348 | <widget row="0" column="0" > | ||
349 | <class>QLabel</class> | ||
350 | <property stdset="1"> | ||
351 | <name>name</name> | ||
352 | <cstring>m_MailLimitLabel</cstring> | ||
353 | </property> | ||
354 | <property stdset="1"> | ||
355 | <name>text</name> | ||
356 | <string>Large mail size (kb):</string> | ||
357 | </property> | ||
358 | </widget> | ||
359 | <widget row="0" column="1" > | ||
360 | <class>QSpinBox</class> | ||
361 | <property stdset="1"> | ||
362 | <name>name</name> | ||
363 | <cstring>m_MailLimitBox</cstring> | ||
364 | </property> | ||
365 | <property stdset="1"> | ||
366 | <name>suffix</name> | ||
367 | <string> kB</string> | ||
368 | </property> | ||
369 | <property stdset="1"> | ||
370 | <name>maxValue</name> | ||
371 | <number>5120</number> | ||
372 | </property> | ||
373 | <property stdset="1"> | ||
374 | <name>minValue</name> | ||
375 | <number>1</number> | ||
376 | </property> | ||
377 | </widget> | ||
378 | </grid> | ||
379 | </widget> | ||
322 | <spacer> | 380 | <spacer> |
323 | <property> | 381 | <property> |
324 | <name>name</name> | 382 | <name>name</name> |
325 | <cstring>spacer</cstring> | 383 | <cstring>spacer</cstring> |
326 | </property> | 384 | </property> |
327 | <property stdset="1"> | 385 | <property stdset="1"> |
328 | <name>orientation</name> | 386 | <name>orientation</name> |
329 | <enum>Vertical</enum> | 387 | <enum>Vertical</enum> |
330 | </property> | 388 | </property> |
331 | <property stdset="1"> | 389 | <property stdset="1"> |
332 | <name>sizeType</name> | 390 | <name>sizeType</name> |
333 | <enum>Expanding</enum> | 391 | <enum>Expanding</enum> |
334 | </property> | 392 | </property> |
335 | <property> | 393 | <property> |
336 | <name>sizeHint</name> | 394 | <name>sizeHint</name> |
337 | <size> | 395 | <size> |
338 | <width>20</width> | 396 | <width>20</width> |
339 | <height>20</height> | 397 | <height>20</height> |
340 | </size> | 398 | </size> |
341 | </property> | 399 | </property> |
342 | </spacer> | 400 | </spacer> |
343 | </vbox> | 401 | </vbox> |
344 | </widget> | 402 | </widget> |
345 | <tabstops> | 403 | <tabstops> |
346 | <tabstop>accountLine</tabstop> | 404 | <tabstop>accountLine</tabstop> |
347 | <tabstop>serverLine</tabstop> | 405 | <tabstop>serverLine</tabstop> |
348 | <tabstop>portLine</tabstop> | 406 | <tabstop>portLine</tabstop> |
407 | <tabstop>ComboBox1</tabstop> | ||
408 | <tabstop>CommandEdit</tabstop> | ||
349 | <tabstop>userLine</tabstop> | 409 | <tabstop>userLine</tabstop> |
350 | <tabstop>passLine</tabstop> | 410 | <tabstop>passLine</tabstop> |
411 | <tabstop>m_CheckSize</tabstop> | ||
412 | <tabstop>m_MailLimitBox</tabstop> | ||
351 | </tabstops> | 413 | </tabstops> |
352 | </UI> | 414 | </UI> |