23 files changed, 49 insertions, 7 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index ae28313..c1574fd 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -1,203 +1,204 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | /* OPIE */ | ||
9 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
10 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
11 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | ||
12 | #include <opie2/odebug.h> | ||
12 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
13 | 14 | ||
14 | /* QT */ | 15 | /* QT */ |
15 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
17 | 18 | ||
18 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
19 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
20 | /** | 21 | /** |
21 | * POP3 Account stuff | 22 | * POP3 Account stuff |
22 | */ | 23 | */ |
23 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
24 | : AccountViewItem( parent ) | 25 | : AccountViewItem( parent ) |
25 | { | 26 | { |
26 | account = a; | 27 | account = a; |
27 | wrapper = AbstractMail::getWrapper( account ); | 28 | wrapper = AbstractMail::getWrapper( account ); |
28 | SETPIX(PIXMAP_POP3FOLDER); | 29 | SETPIX(PIXMAP_POP3FOLDER); |
29 | #if 0 | 30 | #if 0 |
30 | if (!account->getOffline()) | 31 | if (!account->getOffline()) |
31 | { | 32 | { |
32 | setPixmap( 0, ); | 33 | setPixmap( 0, ); |
33 | } | 34 | } |
34 | else | 35 | else |
35 | { | 36 | { |
36 | setPixmap( 0, PIXMAP_OFFLINE ); | 37 | setPixmap( 0, PIXMAP_OFFLINE ); |
37 | } | 38 | } |
38 | #endif | 39 | #endif |
39 | setText( 0, account->getAccountName() ); | 40 | setText( 0, account->getAccountName() ); |
40 | setOpen( true ); | 41 | setOpen( true ); |
41 | } | 42 | } |
42 | 43 | ||
43 | POP3viewItem::~POP3viewItem() | 44 | POP3viewItem::~POP3viewItem() |
44 | { | 45 | { |
45 | delete wrapper; | 46 | delete wrapper; |
46 | } | 47 | } |
47 | 48 | ||
48 | AbstractMail *POP3viewItem::getWrapper() | 49 | AbstractMail *POP3viewItem::getWrapper() |
49 | { | 50 | { |
50 | return wrapper; | 51 | return wrapper; |
51 | } | 52 | } |
52 | 53 | ||
53 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
54 | { | 55 | { |
55 | refresh(); | 56 | refresh(); |
56 | } | 57 | } |
57 | 58 | ||
58 | void POP3viewItem::refresh() | 59 | void POP3viewItem::refresh() |
59 | { | 60 | { |
60 | if (account->getOffline()) return; | 61 | if (account->getOffline()) return; |
61 | QValueList<FolderP> *folders = wrapper->listFolders(); | 62 | QValueList<FolderP> *folders = wrapper->listFolders(); |
62 | QListViewItem *child = firstChild(); | 63 | QListViewItem *child = firstChild(); |
63 | while ( child ) | 64 | while ( child ) |
64 | { | 65 | { |
65 | QListViewItem *tmp = child; | 66 | QListViewItem *tmp = child; |
66 | child = child->nextSibling(); | 67 | child = child->nextSibling(); |
67 | delete tmp; | 68 | delete tmp; |
68 | } | 69 | } |
69 | QValueList<FolderP>::ConstIterator it; | 70 | QValueList<FolderP>::ConstIterator it; |
70 | QListViewItem*item = 0; | 71 | QListViewItem*item = 0; |
71 | for ( it = folders->begin(); it!=folders->end(); ++it) | 72 | for ( it = folders->begin(); it!=folders->end(); ++it) |
72 | { | 73 | { |
73 | item = new POP3folderItem( (*it), this , item ); | 74 | item = new POP3folderItem( (*it), this , item ); |
74 | item->setSelectable( (*it)->may_select()); | 75 | item->setSelectable( (*it)->may_select()); |
75 | } | 76 | } |
76 | delete folders; | 77 | delete folders; |
77 | } | 78 | } |
78 | 79 | ||
79 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
80 | { | 81 | { |
81 | odebug << "POP3 fetchBody" << oendl; | 82 | odebug << "POP3 fetchBody" << oendl; |
82 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
83 | } | 84 | } |
84 | 85 | ||
85 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
86 | { | 87 | { |
87 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
88 | if (m) | 89 | if (m) |
89 | { | 90 | { |
90 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
91 | { | 92 | { |
92 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
93 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),1); |
94 | } | 95 | } |
95 | else | 96 | else |
96 | { | 97 | { |
97 | m->insertItem(QObject::tr("Set online",contextName),1); | 98 | m->insertItem(QObject::tr("Set online",contextName),1); |
98 | } | 99 | } |
99 | } | 100 | } |
100 | return m; | 101 | return m; |
101 | } | 102 | } |
102 | 103 | ||
103 | void POP3viewItem::disconnect() | 104 | void POP3viewItem::disconnect() |
104 | { | 105 | { |
105 | QListViewItem *child = firstChild(); | 106 | QListViewItem *child = firstChild(); |
106 | while ( child ) | 107 | while ( child ) |
107 | { | 108 | { |
108 | QListViewItem *tmp = child; | 109 | QListViewItem *tmp = child; |
109 | child = child->nextSibling(); | 110 | child = child->nextSibling(); |
110 | delete tmp; | 111 | delete tmp; |
111 | } | 112 | } |
112 | wrapper->logout(); | 113 | wrapper->logout(); |
113 | } | 114 | } |
114 | 115 | ||
115 | void POP3viewItem::setOnOffline() | 116 | void POP3viewItem::setOnOffline() |
116 | { | 117 | { |
117 | if (!account->getOffline()) | 118 | if (!account->getOffline()) |
118 | { | 119 | { |
119 | disconnect(); | 120 | disconnect(); |
120 | } | 121 | } |
121 | account->setOffline(!account->getOffline()); | 122 | account->setOffline(!account->getOffline()); |
122 | account->save(); | 123 | account->save(); |
123 | SETPIX(PIXMAP_POP3FOLDER); | 124 | SETPIX(PIXMAP_POP3FOLDER); |
124 | refresh(); | 125 | refresh(); |
125 | } | 126 | } |
126 | 127 | ||
127 | void POP3viewItem::contextMenuSelected(int which) | 128 | void POP3viewItem::contextMenuSelected(int which) |
128 | { | 129 | { |
129 | switch (which) | 130 | switch (which) |
130 | { | 131 | { |
131 | case 0: | 132 | case 0: |
132 | disconnect(); | 133 | disconnect(); |
133 | break; | 134 | break; |
134 | case 1: | 135 | case 1: |
135 | setOnOffline(); | 136 | setOnOffline(); |
136 | break; | 137 | break; |
137 | } | 138 | } |
138 | } | 139 | } |
139 | 140 | ||
140 | POP3folderItem::~POP3folderItem() | 141 | POP3folderItem::~POP3folderItem() |
141 | {} | 142 | {} |
142 | 143 | ||
143 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 144 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
144 | : AccountViewItem(folderInit,parent,after ) | 145 | : AccountViewItem(folderInit,parent,after ) |
145 | { | 146 | { |
146 | pop3 = parent; | 147 | pop3 = parent; |
147 | if (folder->getDisplayName().lower()!="inbox") | 148 | if (folder->getDisplayName().lower()!="inbox") |
148 | { | 149 | { |
149 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 150 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
150 | } | 151 | } |
151 | else | 152 | else |
152 | { | 153 | { |
153 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 154 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
154 | } | 155 | } |
155 | setText( 0, folder->getDisplayName() ); | 156 | setText( 0, folder->getDisplayName() ); |
156 | } | 157 | } |
157 | 158 | ||
158 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 159 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
159 | { | 160 | { |
160 | if (folder->may_select()) | 161 | if (folder->may_select()) |
161 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 162 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
162 | } | 163 | } |
163 | 164 | ||
164 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 165 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
165 | { | 166 | { |
166 | return pop3->getWrapper()->fetchBody(aMail); | 167 | return pop3->getWrapper()->fetchBody(aMail); |
167 | } | 168 | } |
168 | 169 | ||
169 | QPopupMenu * POP3folderItem::getContextMenu() | 170 | QPopupMenu * POP3folderItem::getContextMenu() |
170 | { | 171 | { |
171 | QPopupMenu *m = new QPopupMenu(0); | 172 | QPopupMenu *m = new QPopupMenu(0); |
172 | if (m) | 173 | if (m) |
173 | { | 174 | { |
174 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 175 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
175 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 176 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
176 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
177 | } | 178 | } |
178 | return m; | 179 | return m; |
179 | } | 180 | } |
180 | 181 | ||
181 | void POP3folderItem::downloadMails() | 182 | void POP3folderItem::downloadMails() |
182 | { | 183 | { |
183 | AccountView*bl = pop3->accountView(); | 184 | AccountView*bl = pop3->accountView(); |
184 | if (!bl) return; | 185 | if (!bl) return; |
185 | bl->downloadMails(folder,pop3->getWrapper()); | 186 | bl->downloadMails(folder,pop3->getWrapper()); |
186 | } | 187 | } |
187 | 188 | ||
188 | void POP3folderItem::contextMenuSelected(int which) | 189 | void POP3folderItem::contextMenuSelected(int which) |
189 | { | 190 | { |
190 | AccountView * view = (AccountView*)listView(); | 191 | AccountView * view = (AccountView*)listView(); |
191 | switch (which) | 192 | switch (which) |
192 | { | 193 | { |
193 | case 0: | 194 | case 0: |
194 | /* must be 'cause pop3 lists are cached */ | 195 | /* must be 'cause pop3 lists are cached */ |
195 | pop3->getWrapper()->logout(); | 196 | pop3->getWrapper()->logout(); |
196 | view->refreshCurrent(); | 197 | view->refreshCurrent(); |
197 | break; | 198 | break; |
198 | case 1: | 199 | case 1: |
199 | deleteAllMail(pop3->getWrapper(),folder); | 200 | deleteAllMail(pop3->getWrapper(),folder); |
200 | break; | 201 | break; |
201 | case 2: | 202 | case 2: |
202 | downloadMails(); | 203 | downloadMails(); |
203 | break; | 204 | break; |
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 0052061..662e555 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,176 +1,178 @@ | |||
1 | 1 | ||
2 | #include "accountview.h" | 2 | #include "accountview.h" |
3 | #include "accountitem.h" | 3 | #include "accountitem.h" |
4 | #include "selectstore.h" | 4 | #include "selectstore.h" |
5 | 5 | ||
6 | /* OPIE */ | ||
7 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
8 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
9 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
10 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | |||
11 | /* OPIE */ | ||
12 | #include <opie2/odebug.h> | ||
11 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
12 | 14 | ||
13 | /* QT */ | 15 | /* QT */ |
14 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
15 | #include <qpopupmenu.h> | 17 | #include <qpopupmenu.h> |
16 | 18 | ||
17 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
18 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
19 | : QListView( parent, name, flags ) | 21 | : QListView( parent, name, flags ) |
20 | { | 22 | { |
21 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
22 | SLOT( refresh(QListViewItem*) ) ); | 24 | SLOT( refresh(QListViewItem*) ) ); |
23 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
24 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
25 | setSorting(0); | 27 | setSorting(0); |
26 | } | 28 | } |
27 | 29 | ||
28 | AccountView::~AccountView() | 30 | AccountView::~AccountView() |
29 | { | 31 | { |
30 | imapAccounts.clear(); | 32 | imapAccounts.clear(); |
31 | mhAccounts.clear(); | 33 | mhAccounts.clear(); |
32 | } | 34 | } |
33 | 35 | ||
34 | void AccountView::slotContextMenu(int id) | 36 | void AccountView::slotContextMenu(int id) |
35 | { | 37 | { |
36 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 38 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
37 | if (!view) return; | 39 | if (!view) return; |
38 | view->contextMenuSelected(id); | 40 | view->contextMenuSelected(id); |
39 | } | 41 | } |
40 | 42 | ||
41 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
42 | { | 44 | { |
43 | if (button==1) {return;} | 45 | if (button==1) {return;} |
44 | if (!item) return; | 46 | if (!item) return; |
45 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
46 | QPopupMenu*m = view->getContextMenu(); | 48 | QPopupMenu*m = view->getContextMenu(); |
47 | if (!m) return; | 49 | if (!m) return; |
48 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 50 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
49 | m->setFocus(); | 51 | m->setFocus(); |
50 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
51 | delete m; | 53 | delete m; |
52 | } | 54 | } |
53 | 55 | ||
54 | void AccountView::populate( QList<Account> list ) | 56 | void AccountView::populate( QList<Account> list ) |
55 | { | 57 | { |
56 | clear(); | 58 | clear(); |
57 | 59 | ||
58 | imapAccounts.clear(); | 60 | imapAccounts.clear(); |
59 | mhAccounts.clear(); | 61 | mhAccounts.clear(); |
60 | 62 | ||
61 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 63 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
62 | 64 | ||
63 | Account *it; | 65 | Account *it; |
64 | for ( it = list.first(); it; it = list.next() ) | 66 | for ( it = list.first(); it; it = list.next() ) |
65 | { | 67 | { |
66 | if ( it->getType() == MAILLIB::A_IMAP ) | 68 | if ( it->getType() == MAILLIB::A_IMAP ) |
67 | { | 69 | { |
68 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 70 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
69 | odebug << "added IMAP " + imap->getAccountName() << oendl; | 71 | odebug << "added IMAP " + imap->getAccountName() << oendl; |
70 | imapAccounts.append(new IMAPviewItem( imap, this )); | 72 | imapAccounts.append(new IMAPviewItem( imap, this )); |
71 | } | 73 | } |
72 | else if ( it->getType() == MAILLIB::A_POP3 ) | 74 | else if ( it->getType() == MAILLIB::A_POP3 ) |
73 | { | 75 | { |
74 | POP3account *pop3 = static_cast<POP3account *>(it); | 76 | POP3account *pop3 = static_cast<POP3account *>(it); |
75 | odebug << "added POP3 " + pop3->getAccountName() << oendl; | 77 | odebug << "added POP3 " + pop3->getAccountName() << oendl; |
76 | /* must not be hold 'cause it isn't required */ | 78 | /* must not be hold 'cause it isn't required */ |
77 | (void) new POP3viewItem( pop3, this ); | 79 | (void) new POP3viewItem( pop3, this ); |
78 | } | 80 | } |
79 | else if ( it->getType() == MAILLIB::A_NNTP ) | 81 | else if ( it->getType() == MAILLIB::A_NNTP ) |
80 | { | 82 | { |
81 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
82 | odebug << "added NNTP " + nntp->getAccountName() << oendl; | 84 | odebug << "added NNTP " + nntp->getAccountName() << oendl; |
83 | /* must not be hold 'cause it isn't required */ | 85 | /* must not be hold 'cause it isn't required */ |
84 | (void) new NNTPviewItem( nntp, this ); | 86 | (void) new NNTPviewItem( nntp, this ); |
85 | } | 87 | } |
86 | } | 88 | } |
87 | } | 89 | } |
88 | 90 | ||
89 | void AccountView::refresh(QListViewItem *item) | 91 | void AccountView::refresh(QListViewItem *item) |
90 | { | 92 | { |
91 | 93 | ||
92 | odebug << "AccountView refresh..." << oendl; | 94 | odebug << "AccountView refresh..." << oendl; |
93 | if ( item ) | 95 | if ( item ) |
94 | { | 96 | { |
95 | m_currentItem = item; | 97 | m_currentItem = item; |
96 | QValueList<RecMailP> headerlist; | 98 | QValueList<RecMailP> headerlist; |
97 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 99 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
98 | view->refresh(headerlist); | 100 | view->refresh(headerlist); |
99 | emit refreshMailview(headerlist); | 101 | emit refreshMailview(headerlist); |
100 | } | 102 | } |
101 | } | 103 | } |
102 | 104 | ||
103 | void AccountView::refreshCurrent() | 105 | void AccountView::refreshCurrent() |
104 | { | 106 | { |
105 | m_currentItem = currentItem(); | 107 | m_currentItem = currentItem(); |
106 | if ( !m_currentItem ) return; | 108 | if ( !m_currentItem ) return; |
107 | QValueList<RecMailP> headerlist; | 109 | QValueList<RecMailP> headerlist; |
108 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 110 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
109 | view->refresh(headerlist); | 111 | view->refresh(headerlist); |
110 | emit refreshMailview(headerlist); | 112 | emit refreshMailview(headerlist); |
111 | } | 113 | } |
112 | 114 | ||
113 | void AccountView::refreshAll() | 115 | void AccountView::refreshAll() |
114 | { | 116 | { |
115 | } | 117 | } |
116 | 118 | ||
117 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 119 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
118 | { | 120 | { |
119 | QListViewItem*item = selectedItem (); | 121 | QListViewItem*item = selectedItem (); |
120 | if (!item) return new RecBody(); | 122 | if (!item) return new RecBody(); |
121 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 123 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
122 | return view->fetchBody(aMail); | 124 | return view->fetchBody(aMail); |
123 | } | 125 | } |
124 | 126 | ||
125 | void AccountView::setupFolderselect(Selectstore*sels) | 127 | void AccountView::setupFolderselect(Selectstore*sels) |
126 | { | 128 | { |
127 | QPEApplication::showDialog( sels ); | 129 | QPEApplication::showDialog( sels ); |
128 | QStringList sFolders; | 130 | QStringList sFolders; |
129 | unsigned int i = 0; | 131 | unsigned int i = 0; |
130 | for (i=0; i < mhAccounts.count();++i) | 132 | for (i=0; i < mhAccounts.count();++i) |
131 | { | 133 | { |
132 | mhAccounts[i]->refresh(false); | 134 | mhAccounts[i]->refresh(false); |
133 | sFolders = mhAccounts[i]->subFolders(); | 135 | sFolders = mhAccounts[i]->subFolders(); |
134 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 136 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
135 | } | 137 | } |
136 | for (i=0; i < imapAccounts.count();++i) | 138 | for (i=0; i < imapAccounts.count();++i) |
137 | { | 139 | { |
138 | if (imapAccounts[i]->offline()) | 140 | if (imapAccounts[i]->offline()) |
139 | continue; | 141 | continue; |
140 | imapAccounts[i]->refreshFolders(false); | 142 | imapAccounts[i]->refreshFolders(false); |
141 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 143 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
142 | } | 144 | } |
143 | } | 145 | } |
144 | 146 | ||
145 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 147 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
146 | { | 148 | { |
147 | AbstractMail*targetMail = 0; | 149 | AbstractMail*targetMail = 0; |
148 | QString targetFolder = ""; | 150 | QString targetFolder = ""; |
149 | Selectstore sels; | 151 | Selectstore sels; |
150 | setupFolderselect(&sels); | 152 | setupFolderselect(&sels); |
151 | if (!sels.exec()) return; | 153 | if (!sels.exec()) return; |
152 | targetMail = sels.currentMail(); | 154 | targetMail = sels.currentMail(); |
153 | targetFolder = sels.currentFolder(); | 155 | targetFolder = sels.currentFolder(); |
154 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 156 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
155 | targetFolder.isEmpty()) | 157 | targetFolder.isEmpty()) |
156 | { | 158 | { |
157 | return; | 159 | return; |
158 | } | 160 | } |
159 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 161 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
160 | { | 162 | { |
161 | QMessageBox::critical(0,tr("Error creating new Folder"), | 163 | QMessageBox::critical(0,tr("Error creating new Folder"), |
162 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 164 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
163 | return; | 165 | return; |
164 | } | 166 | } |
165 | odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; | 167 | odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; |
166 | odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; | 168 | odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; |
167 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | 169 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); |
168 | refreshCurrent(); | 170 | refreshCurrent(); |
169 | } | 171 | } |
170 | 172 | ||
171 | bool AccountView::currentisDraft() | 173 | bool AccountView::currentisDraft() |
172 | { | 174 | { |
173 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 175 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
174 | if (!view) return false; | 176 | if (!view) return false; |
175 | return view->isDraftfolder(); | 177 | return view->isDraftfolder(); |
176 | } | 178 | } |
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index fa703c4..b15e692 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -1,195 +1,196 @@ | |||
1 | #include <qt.h> | 1 | #include <qt.h> |
2 | 2 | ||
3 | #include <opie2/ofiledialog.h> | 3 | #include <opie2/ofiledialog.h> |
4 | #include <opie2/odebug.h> | ||
4 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
5 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
6 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
7 | #include <qpe/contact.h> | 8 | #include <qpe/contact.h> |
8 | 9 | ||
9 | #include "composemail.h" | 10 | #include "composemail.h" |
10 | 11 | ||
11 | #include <libmailwrapper/smtpwrapper.h> | 12 | #include <libmailwrapper/smtpwrapper.h> |
12 | #include <libmailwrapper/storemail.h> | 13 | #include <libmailwrapper/storemail.h> |
13 | #include <libmailwrapper/abstractmail.h> | 14 | #include <libmailwrapper/abstractmail.h> |
14 | #include <libmailwrapper/mailtypes.h> | 15 | #include <libmailwrapper/mailtypes.h> |
15 | 16 | ||
16 | using namespace Opie::Core; | 17 | using namespace Opie::Core; |
17 | using namespace Opie::Ui; | 18 | using namespace Opie::Ui; |
18 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 19 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
19 | : ComposeMailUI( parent, name, modal, flags ) | 20 | : ComposeMailUI( parent, name, modal, flags ) |
20 | { | 21 | { |
21 | settings = s; | 22 | settings = s; |
22 | m_replyid = ""; | 23 | m_replyid = ""; |
23 | 24 | ||
24 | QString vfilename = Global::applicationFileName("addressbook", | 25 | QString vfilename = Global::applicationFileName("addressbook", |
25 | "businesscard.vcf"); | 26 | "businesscard.vcf"); |
26 | Contact c; | 27 | Contact c; |
27 | if (QFile::exists(vfilename)) { | 28 | if (QFile::exists(vfilename)) { |
28 | c = Contact::readVCard( vfilename )[0]; | 29 | c = Contact::readVCard( vfilename )[0]; |
29 | } | 30 | } |
30 | 31 | ||
31 | QStringList mails = c.emailList(); | 32 | QStringList mails = c.emailList(); |
32 | QString defmail = c.defaultEmail(); | 33 | QString defmail = c.defaultEmail(); |
33 | 34 | ||
34 | if (defmail.length()!=0) { | 35 | if (defmail.length()!=0) { |
35 | fromBox->insertItem(defmail); | 36 | fromBox->insertItem(defmail); |
36 | } | 37 | } |
37 | QStringList::ConstIterator sit = mails.begin(); | 38 | QStringList::ConstIterator sit = mails.begin(); |
38 | for (;sit!=mails.end();++sit) { | 39 | for (;sit!=mails.end();++sit) { |
39 | if ( (*sit)==defmail) | 40 | if ( (*sit)==defmail) |
40 | continue; | 41 | continue; |
41 | fromBox->insertItem((*sit)); | 42 | fromBox->insertItem((*sit)); |
42 | } | 43 | } |
43 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); | 44 | senderNameEdit->setText(c.firstName()+" "+c.lastName()); |
44 | Config cfg( "mail" ); | 45 | Config cfg( "mail" ); |
45 | cfg.setGroup( "Compose" ); | 46 | cfg.setGroup( "Compose" ); |
46 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 47 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
47 | 48 | ||
48 | attList->addColumn( tr( "Name" ) ); | 49 | attList->addColumn( tr( "Name" ) ); |
49 | attList->addColumn( tr( "Size" ) ); | 50 | attList->addColumn( tr( "Size" ) ); |
50 | 51 | ||
51 | QList<Account> accounts = settings->getAccounts(); | 52 | QList<Account> accounts = settings->getAccounts(); |
52 | 53 | ||
53 | Account *it; | 54 | Account *it; |
54 | for ( it = accounts.first(); it; it = accounts.next() ) { | 55 | for ( it = accounts.first(); it; it = accounts.next() ) { |
55 | if ( it->getType()==MAILLIB::A_SMTP ) { | 56 | if ( it->getType()==MAILLIB::A_SMTP ) { |
56 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 57 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
57 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 58 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
58 | smtpAccounts.append( smtp ); | 59 | smtpAccounts.append( smtp ); |
59 | } | 60 | } |
60 | } | 61 | } |
61 | 62 | ||
62 | if ( smtpAccounts.count() > 0 ) { | 63 | if ( smtpAccounts.count() > 0 ) { |
63 | fillValues( smtpAccountBox->currentItem() ); | 64 | fillValues( smtpAccountBox->currentItem() ); |
64 | } else { | 65 | } else { |
65 | QMessageBox::information( this, tr( "Problem" ), | 66 | QMessageBox::information( this, tr( "Problem" ), |
66 | tr( "<p>Please create an SMTP account first.</p>" ), | 67 | tr( "<p>Please create an SMTP account first.</p>" ), |
67 | tr( "Ok" ) ); | 68 | tr( "Ok" ) ); |
68 | return; | 69 | return; |
69 | } | 70 | } |
70 | 71 | ||
71 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 72 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
72 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 73 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
73 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 74 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
74 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 75 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
75 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 76 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
76 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 77 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
77 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 78 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
78 | } | 79 | } |
79 | 80 | ||
80 | void ComposeMail::pickAddress( QLineEdit *line ) | 81 | void ComposeMail::pickAddress( QLineEdit *line ) |
81 | { | 82 | { |
82 | QString names = AddressPicker::getNames(); | 83 | QString names = AddressPicker::getNames(); |
83 | if ( line->text().isEmpty() ) { | 84 | if ( line->text().isEmpty() ) { |
84 | line->setText( names ); | 85 | line->setText( names ); |
85 | } else if ( !names.isEmpty() ) { | 86 | } else if ( !names.isEmpty() ) { |
86 | line->setText( line->text() + ", " + names ); | 87 | line->setText( line->text() + ", " + names ); |
87 | } | 88 | } |
88 | } | 89 | } |
89 | 90 | ||
90 | 91 | ||
91 | void ComposeMail::setTo( const QString & to ) | 92 | void ComposeMail::setTo( const QString & to ) |
92 | { | 93 | { |
93 | toLine->setText( to ); | 94 | toLine->setText( to ); |
94 | } | 95 | } |
95 | 96 | ||
96 | void ComposeMail::setSubject( const QString & subject ) | 97 | void ComposeMail::setSubject( const QString & subject ) |
97 | { | 98 | { |
98 | subjectLine->setText( subject ); | 99 | subjectLine->setText( subject ); |
99 | } | 100 | } |
100 | 101 | ||
101 | void ComposeMail::setInReplyTo( const QString & messageId ) | 102 | void ComposeMail::setInReplyTo( const QString & messageId ) |
102 | { | 103 | { |
103 | m_replyid = messageId; | 104 | m_replyid = messageId; |
104 | } | 105 | } |
105 | 106 | ||
106 | void ComposeMail::setMessage( const QString & text ) | 107 | void ComposeMail::setMessage( const QString & text ) |
107 | { | 108 | { |
108 | message->setText( text ); | 109 | message->setText( text ); |
109 | } | 110 | } |
110 | 111 | ||
111 | 112 | ||
112 | void ComposeMail::pickAddressTo() | 113 | void ComposeMail::pickAddressTo() |
113 | { | 114 | { |
114 | pickAddress( toLine ); | 115 | pickAddress( toLine ); |
115 | } | 116 | } |
116 | 117 | ||
117 | void ComposeMail::pickAddressCC() | 118 | void ComposeMail::pickAddressCC() |
118 | { | 119 | { |
119 | pickAddress( ccLine ); | 120 | pickAddress( ccLine ); |
120 | } | 121 | } |
121 | 122 | ||
122 | void ComposeMail::pickAddressBCC() | 123 | void ComposeMail::pickAddressBCC() |
123 | { | 124 | { |
124 | pickAddress( bccLine ); | 125 | pickAddress( bccLine ); |
125 | } | 126 | } |
126 | 127 | ||
127 | void ComposeMail::pickAddressReply() | 128 | void ComposeMail::pickAddressReply() |
128 | { | 129 | { |
129 | pickAddress( replyLine ); | 130 | pickAddress( replyLine ); |
130 | } | 131 | } |
131 | 132 | ||
132 | void ComposeMail::fillValues( int ) | 133 | void ComposeMail::fillValues( int ) |
133 | { | 134 | { |
134 | #if 0 | 135 | #if 0 |
135 | SMTPaccount *smtp = smtpAccounts.at( current ); | 136 | SMTPaccount *smtp = smtpAccounts.at( current ); |
136 | ccLine->clear(); | 137 | ccLine->clear(); |
137 | if ( smtp->getUseCC() ) { | 138 | if ( smtp->getUseCC() ) { |
138 | ccLine->setText( smtp->getCC() ); | 139 | ccLine->setText( smtp->getCC() ); |
139 | } | 140 | } |
140 | bccLine->clear(); | 141 | bccLine->clear(); |
141 | if ( smtp->getUseBCC() ) { | 142 | if ( smtp->getUseBCC() ) { |
142 | bccLine->setText( smtp->getBCC() ); | 143 | bccLine->setText( smtp->getBCC() ); |
143 | } | 144 | } |
144 | replyLine->clear(); | 145 | replyLine->clear(); |
145 | if ( smtp->getUseReply() ) { | 146 | if ( smtp->getUseReply() ) { |
146 | replyLine->setText( smtp->getReply() ); | 147 | replyLine->setText( smtp->getReply() ); |
147 | } | 148 | } |
148 | sigMultiLine->setText( smtp->getSignature() ); | 149 | sigMultiLine->setText( smtp->getSignature() ); |
149 | #endif | 150 | #endif |
150 | } | 151 | } |
151 | 152 | ||
152 | void ComposeMail::slotAdjustColumns() | 153 | void ComposeMail::slotAdjustColumns() |
153 | { | 154 | { |
154 | int currPage = tabWidget->currentPageIndex(); | 155 | int currPage = tabWidget->currentPageIndex(); |
155 | 156 | ||
156 | tabWidget->showPage( attachTab ); | 157 | tabWidget->showPage( attachTab ); |
157 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 158 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
158 | attList->setColumnWidth( 1, 80 ); | 159 | attList->setColumnWidth( 1, 80 ); |
159 | 160 | ||
160 | tabWidget->setCurrentPage( currPage ); | 161 | tabWidget->setCurrentPage( currPage ); |
161 | } | 162 | } |
162 | 163 | ||
163 | void ComposeMail::addAttachment() | 164 | void ComposeMail::addAttachment() |
164 | { | 165 | { |
165 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); | 166 | DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); |
166 | if ( !lnk.name().isEmpty() ) { | 167 | if ( !lnk.name().isEmpty() ) { |
167 | Attachment *att = new Attachment( lnk ); | 168 | Attachment *att = new Attachment( lnk ); |
168 | (void) new AttachViewItem( attList, att ); | 169 | (void) new AttachViewItem( attList, att ); |
169 | } | 170 | } |
170 | } | 171 | } |
171 | 172 | ||
172 | void ComposeMail::removeAttachment() | 173 | void ComposeMail::removeAttachment() |
173 | { | 174 | { |
174 | if ( !attList->currentItem() ) { | 175 | if ( !attList->currentItem() ) { |
175 | QMessageBox::information( this, tr( "Error" ), | 176 | QMessageBox::information( this, tr( "Error" ), |
176 | tr( "<p>Please select a File.</p>" ), | 177 | tr( "<p>Please select a File.</p>" ), |
177 | tr( "Ok" ) ); | 178 | tr( "Ok" ) ); |
178 | } else { | 179 | } else { |
179 | attList->takeItem( attList->currentItem() ); | 180 | attList->takeItem( attList->currentItem() ); |
180 | } | 181 | } |
181 | } | 182 | } |
182 | 183 | ||
183 | void ComposeMail::accept() | 184 | void ComposeMail::accept() |
184 | { | 185 | { |
185 | if ( checkBoxLater->isChecked() ) { | 186 | if ( checkBoxLater->isChecked() ) { |
186 | odebug << "Send later" << oendl; | 187 | odebug << "Send later" << oendl; |
187 | } | 188 | } |
188 | 189 | ||
189 | #if 0 | 190 | #if 0 |
190 | qDebug( "Sending Mail with " + | 191 | qDebug( "Sending Mail with " + |
191 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); | 192 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
192 | #endif | 193 | #endif |
193 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 194 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
194 | 195 | ||
195 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 196 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index de064ca..b0ce57d 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp | |||
@@ -1,205 +1,208 @@ | |||
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 <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
7 | 8 | ||
8 | /* QT */ | 9 | /* QT */ |
9 | #include <qt.h> | 10 | #include <qt.h> |
10 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
11 | 12 | ||
12 | #include <libmailwrapper/nntpwrapper.h> | 13 | #include <libmailwrapper/nntpwrapper.h> |
13 | 14 | ||
15 | using namespace Opie::Core; | ||
16 | |||
14 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 17 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
15 | : QListViewItem( parent ) | 18 | : QListViewItem( parent ) |
16 | { | 19 | { |
17 | account = a; | 20 | account = a; |
18 | setText( 0, account->getAccountName() ); | 21 | setText( 0, account->getAccountName() ); |
19 | QString ttext = ""; | 22 | QString ttext = ""; |
20 | switch (account->getType()) { | 23 | switch (account->getType()) { |
21 | case MAILLIB::A_NNTP: | 24 | case MAILLIB::A_NNTP: |
22 | ttext="NNTP"; | 25 | ttext="NNTP"; |
23 | break; | 26 | break; |
24 | case MAILLIB::A_POP3: | 27 | case MAILLIB::A_POP3: |
25 | ttext = "POP3"; | 28 | ttext = "POP3"; |
26 | break; | 29 | break; |
27 | case MAILLIB::A_IMAP: | 30 | case MAILLIB::A_IMAP: |
28 | ttext = "IMAP"; | 31 | ttext = "IMAP"; |
29 | break; | 32 | break; |
30 | case MAILLIB::A_SMTP: | 33 | case MAILLIB::A_SMTP: |
31 | ttext = "SMTP"; | 34 | ttext = "SMTP"; |
32 | break; | 35 | break; |
33 | default: | 36 | default: |
34 | ttext = "UNKNOWN"; | 37 | ttext = "UNKNOWN"; |
35 | break; | 38 | break; |
36 | } | 39 | } |
37 | setText( 1, ttext); | 40 | setText( 1, ttext); |
38 | } | 41 | } |
39 | 42 | ||
40 | 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 ) |
41 | : EditAccountsUI( parent, name, modal, flags ) | 44 | : EditAccountsUI( parent, name, modal, flags ) |
42 | { | 45 | { |
43 | odebug << "New Account Configuration Widget" << oendl; | 46 | odebug << "New Account Configuration Widget" << oendl; |
44 | settings = s; | 47 | settings = s; |
45 | 48 | ||
46 | mailList->addColumn( tr( "Account" ) ); | 49 | mailList->addColumn( tr( "Account" ) ); |
47 | mailList->addColumn( tr( "Type" ) ); | 50 | mailList->addColumn( tr( "Type" ) ); |
48 | 51 | ||
49 | newsList->addColumn( tr( "Account" ) ); | 52 | newsList->addColumn( tr( "Account" ) ); |
50 | 53 | ||
51 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 54 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
52 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 55 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
53 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 56 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
54 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 57 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
55 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 58 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
56 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 59 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
57 | 60 | ||
58 | slotFillLists(); | 61 | slotFillLists(); |
59 | } | 62 | } |
60 | 63 | ||
61 | void EditAccounts::slotFillLists() | 64 | void EditAccounts::slotFillLists() |
62 | { | 65 | { |
63 | mailList->clear(); | 66 | mailList->clear(); |
64 | newsList->clear(); | 67 | newsList->clear(); |
65 | 68 | ||
66 | QList<Account> accounts = settings->getAccounts(); | 69 | QList<Account> accounts = settings->getAccounts(); |
67 | Account *it; | 70 | Account *it; |
68 | for ( it = accounts.first(); it; it = accounts.next() ) | 71 | for ( it = accounts.first(); it; it = accounts.next() ) |
69 | { | 72 | { |
70 | if ( it->getType()==MAILLIB::A_NNTP ) | 73 | if ( it->getType()==MAILLIB::A_NNTP ) |
71 | { | 74 | { |
72 | (void) new AccountListItem( newsList, it ); | 75 | (void) new AccountListItem( newsList, it ); |
73 | } | 76 | } |
74 | else | 77 | else |
75 | { | 78 | { |
76 | (void) new AccountListItem( mailList, it ); | 79 | (void) new AccountListItem( mailList, it ); |
77 | } | 80 | } |
78 | } | 81 | } |
79 | } | 82 | } |
80 | 83 | ||
81 | void EditAccounts::slotNewMail() | 84 | void EditAccounts::slotNewMail() |
82 | { | 85 | { |
83 | odebug << "New Mail Account" << oendl; | 86 | odebug << "New Mail Account" << oendl; |
84 | QString *selection = new QString(); | 87 | QString *selection = new QString(); |
85 | SelectMailType selType( selection, this, 0, true ); | 88 | SelectMailType selType( selection, this, 0, true ); |
86 | selType.show(); | 89 | selType.show(); |
87 | if ( QDialog::Accepted == selType.exec() ) | 90 | if ( QDialog::Accepted == selType.exec() ) |
88 | { | 91 | { |
89 | slotNewAccount( *selection ); | 92 | slotNewAccount( *selection ); |
90 | } | 93 | } |
91 | } | 94 | } |
92 | 95 | ||
93 | void EditAccounts::slotNewAccount( const QString &type ) | 96 | void EditAccounts::slotNewAccount( const QString &type ) |
94 | { | 97 | { |
95 | if ( type.compare( "IMAP" ) == 0 ) | 98 | if ( type.compare( "IMAP" ) == 0 ) |
96 | { | 99 | { |
97 | odebug << "-> config IMAP" << oendl; | 100 | odebug << "-> config IMAP" << oendl; |
98 | IMAPaccount *account = new IMAPaccount(); | 101 | IMAPaccount *account = new IMAPaccount(); |
99 | IMAPconfig imap( account, this, 0, true ); | 102 | IMAPconfig imap( account, this, 0, true ); |
100 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 103 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
101 | { | 104 | { |
102 | settings->addAccount( account ); | 105 | settings->addAccount( account ); |
103 | account->save(); | 106 | account->save(); |
104 | slotFillLists(); | 107 | slotFillLists(); |
105 | } | 108 | } |
106 | else | 109 | else |
107 | { | 110 | { |
108 | account->remove(); | 111 | account->remove(); |
109 | } | 112 | } |
110 | } | 113 | } |
111 | else if ( type.compare( "POP3" ) == 0 ) | 114 | else if ( type.compare( "POP3" ) == 0 ) |
112 | { | 115 | { |
113 | odebug << "-> config POP3" << oendl; | 116 | odebug << "-> config POP3" << oendl; |
114 | POP3account *account = new POP3account(); | 117 | POP3account *account = new POP3account(); |
115 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 118 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
116 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 119 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
117 | { | 120 | { |
118 | settings->addAccount( account ); | 121 | settings->addAccount( account ); |
119 | account->save(); | 122 | account->save(); |
120 | slotFillLists(); | 123 | slotFillLists(); |
121 | } | 124 | } |
122 | else | 125 | else |
123 | { | 126 | { |
124 | account->remove(); | 127 | account->remove(); |
125 | } | 128 | } |
126 | } | 129 | } |
127 | else if ( type.compare( "SMTP" ) == 0 ) | 130 | else if ( type.compare( "SMTP" ) == 0 ) |
128 | { | 131 | { |
129 | odebug << "-> config SMTP" << oendl; | 132 | odebug << "-> config SMTP" << oendl; |
130 | SMTPaccount *account = new SMTPaccount(); | 133 | SMTPaccount *account = new SMTPaccount(); |
131 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 134 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
132 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 135 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
133 | { | 136 | { |
134 | settings->addAccount( account ); | 137 | settings->addAccount( account ); |
135 | account->save(); | 138 | account->save(); |
136 | slotFillLists(); | 139 | slotFillLists(); |
137 | 140 | ||
138 | } | 141 | } |
139 | else | 142 | else |
140 | { | 143 | { |
141 | account->remove(); | 144 | account->remove(); |
142 | } | 145 | } |
143 | } | 146 | } |
144 | else if ( type.compare( "NNTP" ) == 0 ) | 147 | else if ( type.compare( "NNTP" ) == 0 ) |
145 | { | 148 | { |
146 | odebug << "-> config NNTP" << oendl; | 149 | odebug << "-> config NNTP" << oendl; |
147 | NNTPaccount *account = new NNTPaccount(); | 150 | NNTPaccount *account = new NNTPaccount(); |
148 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 151 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
149 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 152 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
150 | { | 153 | { |
151 | settings->addAccount( account ); | 154 | settings->addAccount( account ); |
152 | account->save(); | 155 | account->save(); |
153 | slotFillLists(); | 156 | slotFillLists(); |
154 | } | 157 | } |
155 | else | 158 | else |
156 | { | 159 | { |
157 | account->remove(); | 160 | account->remove(); |
158 | } | 161 | } |
159 | } | 162 | } |
160 | } | 163 | } |
161 | 164 | ||
162 | void EditAccounts::slotEditAccount( Account *account ) | 165 | void EditAccounts::slotEditAccount( Account *account ) |
163 | { | 166 | { |
164 | if ( account->getType() == MAILLIB::A_IMAP ) | 167 | if ( account->getType() == MAILLIB::A_IMAP ) |
165 | { | 168 | { |
166 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 169 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
167 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 170 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
168 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) | 171 | if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) |
169 | { | 172 | { |
170 | slotFillLists(); | 173 | slotFillLists(); |
171 | } | 174 | } |
172 | } | 175 | } |
173 | else if ( account->getType()==MAILLIB::A_POP3 ) | 176 | else if ( account->getType()==MAILLIB::A_POP3 ) |
174 | { | 177 | { |
175 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 178 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
176 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 179 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
177 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) | 180 | if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) |
178 | { | 181 | { |
179 | slotFillLists(); | 182 | slotFillLists(); |
180 | } | 183 | } |
181 | } | 184 | } |
182 | else if ( account->getType()==MAILLIB::A_SMTP ) | 185 | else if ( account->getType()==MAILLIB::A_SMTP ) |
183 | { | 186 | { |
184 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 187 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
185 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 188 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
186 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) | 189 | if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) |
187 | { | 190 | { |
188 | slotFillLists(); | 191 | slotFillLists(); |
189 | } | 192 | } |
190 | } | 193 | } |
191 | else if ( account->getType()==MAILLIB::A_NNTP) | 194 | else if ( account->getType()==MAILLIB::A_NNTP) |
192 | { | 195 | { |
193 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 196 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
194 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 197 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
195 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) | 198 | if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) |
196 | { | 199 | { |
197 | slotFillLists(); | 200 | slotFillLists(); |
198 | } | 201 | } |
199 | } | 202 | } |
200 | } | 203 | } |
201 | 204 | ||
202 | void EditAccounts::slotDeleteAccount( Account *account ) | 205 | void EditAccounts::slotDeleteAccount( Account *account ) |
203 | { | 206 | { |
204 | if ( QMessageBox::information( this, tr( "Question" ), | 207 | if ( QMessageBox::information( this, tr( "Question" ), |
205 | 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>" ), |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 1a26351..7c1c0e4 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,168 +1,170 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "nntpwrapper.h" | 4 | #include "nntpwrapper.h" |
5 | #include "mhwrapper.h" | 5 | #include "mhwrapper.h" |
6 | #include "mailtypes.h" | 6 | #include "mailtypes.h" |
7 | 7 | ||
8 | #include <opie2/odebug.h> | ||
9 | |||
8 | #include <qfile.h> | 10 | #include <qfile.h> |
9 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
10 | #include <stdlib.h> | 12 | #include <stdlib.h> |
11 | #include <libetpan/mailmime_content.h> | 13 | #include <libetpan/mailmime_content.h> |
12 | #include <libetpan/mailmime.h> | 14 | #include <libetpan/mailmime.h> |
13 | 15 | ||
14 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
15 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 17 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
16 | { | 18 | { |
17 | return new IMAPwrapper(a); | 19 | return new IMAPwrapper(a); |
18 | } | 20 | } |
19 | 21 | ||
20 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 22 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
21 | { | 23 | { |
22 | return new POP3wrapper(a); | 24 | return new POP3wrapper(a); |
23 | } | 25 | } |
24 | 26 | ||
25 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 27 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
26 | { | 28 | { |
27 | return new NNTPwrapper(a); | 29 | return new NNTPwrapper(a); |
28 | } | 30 | } |
29 | 31 | ||
30 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 32 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
31 | { | 33 | { |
32 | return new MHwrapper(a,name); | 34 | return new MHwrapper(a,name); |
33 | } | 35 | } |
34 | 36 | ||
35 | AbstractMail* AbstractMail::getWrapper(Account*a) | 37 | AbstractMail* AbstractMail::getWrapper(Account*a) |
36 | { | 38 | { |
37 | if (!a) return 0; | 39 | if (!a) return 0; |
38 | switch (a->getType()) { | 40 | switch (a->getType()) { |
39 | case MAILLIB::A_IMAP: | 41 | case MAILLIB::A_IMAP: |
40 | return new IMAPwrapper((IMAPaccount*)a); | 42 | return new IMAPwrapper((IMAPaccount*)a); |
41 | break; | 43 | break; |
42 | case MAILLIB::A_POP3: | 44 | case MAILLIB::A_POP3: |
43 | return new POP3wrapper((POP3account*)a); | 45 | return new POP3wrapper((POP3account*)a); |
44 | break; | 46 | break; |
45 | case MAILLIB::A_NNTP: | 47 | case MAILLIB::A_NNTP: |
46 | return new NNTPwrapper((NNTPaccount*)a); | 48 | return new NNTPwrapper((NNTPaccount*)a); |
47 | break; | 49 | break; |
48 | default: | 50 | default: |
49 | return 0; | 51 | return 0; |
50 | } | 52 | } |
51 | } | 53 | } |
52 | 54 | ||
53 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 55 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
54 | { | 56 | { |
55 | odebug << "Decode string start" << oendl; | 57 | odebug << "Decode string start" << oendl; |
56 | char*result_text; | 58 | char*result_text; |
57 | size_t index = 0; | 59 | size_t index = 0; |
58 | /* reset for recursive use! */ | 60 | /* reset for recursive use! */ |
59 | size_t target_length = 0; | 61 | size_t target_length = 0; |
60 | result_text = 0; | 62 | result_text = 0; |
61 | int mimetype = MAILMIME_MECHANISM_7BIT; | 63 | int mimetype = MAILMIME_MECHANISM_7BIT; |
62 | if (enc.lower()=="quoted-printable") { | 64 | if (enc.lower()=="quoted-printable") { |
63 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 65 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
64 | } else if (enc.lower()=="base64") { | 66 | } else if (enc.lower()=="base64") { |
65 | mimetype = MAILMIME_MECHANISM_BASE64; | 67 | mimetype = MAILMIME_MECHANISM_BASE64; |
66 | } else if (enc.lower()=="8bit") { | 68 | } else if (enc.lower()=="8bit") { |
67 | mimetype = MAILMIME_MECHANISM_8BIT; | 69 | mimetype = MAILMIME_MECHANISM_8BIT; |
68 | } else if (enc.lower()=="binary") { | 70 | } else if (enc.lower()=="binary") { |
69 | mimetype = MAILMIME_MECHANISM_BINARY; | 71 | mimetype = MAILMIME_MECHANISM_BINARY; |
70 | } | 72 | } |
71 | 73 | ||
72 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 74 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
73 | &result_text,&target_length); | 75 | &result_text,&target_length); |
74 | 76 | ||
75 | encodedString* result = new encodedString(); | 77 | encodedString* result = new encodedString(); |
76 | if (err == MAILIMF_NO_ERROR) { | 78 | if (err == MAILIMF_NO_ERROR) { |
77 | result->setContent(result_text,target_length); | 79 | result->setContent(result_text,target_length); |
78 | } | 80 | } |
79 | odebug << "Decode string finished" << oendl; | 81 | odebug << "Decode string finished" << oendl; |
80 | return result; | 82 | return result; |
81 | } | 83 | } |
82 | 84 | ||
83 | QString AbstractMail::convert_String(const char*text) | 85 | QString AbstractMail::convert_String(const char*text) |
84 | { | 86 | { |
85 | //size_t index = 0; | 87 | //size_t index = 0; |
86 | char*res = 0; | 88 | char*res = 0; |
87 | int err = MAILIMF_NO_ERROR; | 89 | int err = MAILIMF_NO_ERROR; |
88 | 90 | ||
89 | QString result(text); | 91 | QString result(text); |
90 | 92 | ||
91 | /* due a bug in libetpan it isn't usable this moment */ | 93 | /* due a bug in libetpan it isn't usable this moment */ |
92 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", | 94 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", |
93 | text, strlen(text),&index, "iso-8859-1",&res);*/ | 95 | text, strlen(text),&index, "iso-8859-1",&res);*/ |
94 | //odebug << "Input: " << text << "" << oendl; | 96 | //odebug << "Input: " << text << "" << oendl; |
95 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 97 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
96 | // result = QString(res); | 98 | // result = QString(res); |
97 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; | 99 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; |
98 | } | 100 | } |
99 | if (res) free(res); | 101 | if (res) free(res); |
100 | return result; | 102 | return result; |
101 | } | 103 | } |
102 | 104 | ||
103 | /* cp & paste from launcher */ | 105 | /* cp & paste from launcher */ |
104 | QString AbstractMail::gen_attachment_id() | 106 | QString AbstractMail::gen_attachment_id() |
105 | { | 107 | { |
106 | QFile file( "/proc/sys/kernel/random/uuid" ); | 108 | QFile file( "/proc/sys/kernel/random/uuid" ); |
107 | if (!file.open(IO_ReadOnly ) ) | 109 | if (!file.open(IO_ReadOnly ) ) |
108 | return QString::null; | 110 | return QString::null; |
109 | 111 | ||
110 | QTextStream stream(&file); | 112 | QTextStream stream(&file); |
111 | 113 | ||
112 | return "{" + stream.read().stripWhiteSpace() + "}"; | 114 | return "{" + stream.read().stripWhiteSpace() + "}"; |
113 | } | 115 | } |
114 | 116 | ||
115 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 117 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
116 | { | 118 | { |
117 | return 0; | 119 | return 0; |
118 | } | 120 | } |
119 | 121 | ||
120 | QString AbstractMail::defaultLocalfolder() | 122 | QString AbstractMail::defaultLocalfolder() |
121 | { | 123 | { |
122 | QString f = getenv( "HOME" ); | 124 | QString f = getenv( "HOME" ); |
123 | f += "/Applications/opiemail/localmail"; | 125 | f += "/Applications/opiemail/localmail"; |
124 | return f; | 126 | return f; |
125 | } | 127 | } |
126 | 128 | ||
127 | QString AbstractMail::draftFolder() | 129 | QString AbstractMail::draftFolder() |
128 | { | 130 | { |
129 | return QString("Drafts"); | 131 | return QString("Drafts"); |
130 | } | 132 | } |
131 | 133 | ||
132 | /* temporary - will be removed when implemented in all classes */ | 134 | /* temporary - will be removed when implemented in all classes */ |
133 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 135 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
134 | { | 136 | { |
135 | } | 137 | } |
136 | 138 | ||
137 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 139 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
138 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 140 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
139 | { | 141 | { |
140 | QValueList<RecMailP> t; | 142 | QValueList<RecMailP> t; |
141 | listMessages(fromFolder->getName(),t); | 143 | listMessages(fromFolder->getName(),t); |
142 | encodedString*st = 0; | 144 | encodedString*st = 0; |
143 | while (t.count()>0) { | 145 | while (t.count()>0) { |
144 | RecMailP r = (*t.begin()); | 146 | RecMailP r = (*t.begin()); |
145 | st = fetchRawBody(r); | 147 | st = fetchRawBody(r); |
146 | if (st) { | 148 | if (st) { |
147 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 149 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
148 | delete st; | 150 | delete st; |
149 | } | 151 | } |
150 | t.remove(t.begin()); | 152 | t.remove(t.begin()); |
151 | } | 153 | } |
152 | if (moveit) { | 154 | if (moveit) { |
153 | deleteAllMail(fromFolder); | 155 | deleteAllMail(fromFolder); |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 159 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
158 | { | 160 | { |
159 | encodedString*st = 0; | 161 | encodedString*st = 0; |
160 | st = fetchRawBody(mail); | 162 | st = fetchRawBody(mail); |
161 | if (st) { | 163 | if (st) { |
162 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 164 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
163 | delete st; | 165 | delete st; |
164 | } | 166 | } |
165 | if (moveit) { | 167 | if (moveit) { |
166 | deleteMail(mail); | 168 | deleteMail(mail); |
167 | } | 169 | } |
168 | } | 170 | } |
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index 36ec232..eb322a7 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -1,197 +1,199 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | #include <opie2/odebug.h> | ||
7 | |||
6 | #include <qt.h> | 8 | #include <qt.h> |
7 | 9 | ||
8 | using namespace Opie::Core; | 10 | using namespace Opie::Core; |
9 | const char* Generatemail::USER_AGENT="OpieMail v0.6"; | 11 | const char* Generatemail::USER_AGENT="OpieMail v0.6"; |
10 | 12 | ||
11 | Generatemail::Generatemail() | 13 | Generatemail::Generatemail() |
12 | { | 14 | { |
13 | } | 15 | } |
14 | 16 | ||
15 | Generatemail::~Generatemail() | 17 | Generatemail::~Generatemail() |
16 | { | 18 | { |
17 | } | 19 | } |
18 | 20 | ||
19 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 21 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
20 | clistiter *it, *it2; | 22 | clistiter *it, *it2; |
21 | 23 | ||
22 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 24 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
23 | mailimf_address *addr; | 25 | mailimf_address *addr; |
24 | addr = (mailimf_address *) it->data; | 26 | addr = (mailimf_address *) it->data; |
25 | 27 | ||
26 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 28 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
27 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 29 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
28 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 30 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
29 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 31 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
30 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 32 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
31 | mailimf_mailbox *mbox; | 33 | mailimf_mailbox *mbox; |
32 | mbox = (mailimf_mailbox *) it2->data; | 34 | mbox = (mailimf_mailbox *) it2->data; |
33 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 35 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
34 | } | 36 | } |
35 | } | 37 | } |
36 | } | 38 | } |
37 | } | 39 | } |
38 | 40 | ||
39 | char *Generatemail::getFrom( mailimf_field *ffrom) { | 41 | char *Generatemail::getFrom( mailimf_field *ffrom) { |
40 | char *from = NULL; | 42 | char *from = NULL; |
41 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) | 43 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) |
42 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { | 44 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { |
43 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; | 45 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; |
44 | clistiter *it; | 46 | clistiter *it; |
45 | for ( it = clist_begin( cl ); it; it = it->next ) { | 47 | for ( it = clist_begin( cl ); it; it = it->next ) { |
46 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 48 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
47 | from = strdup( mb->mb_addr_spec ); | 49 | from = strdup( mb->mb_addr_spec ); |
48 | } | 50 | } |
49 | } | 51 | } |
50 | 52 | ||
51 | return from; | 53 | return from; |
52 | } | 54 | } |
53 | 55 | ||
54 | char *Generatemail::getFrom( mailmime *mail ) { | 56 | char *Generatemail::getFrom( mailmime *mail ) { |
55 | /* no need to delete - its just a pointer to structure content */ | 57 | /* no need to delete - its just a pointer to structure content */ |
56 | mailimf_field *ffrom = 0; | 58 | mailimf_field *ffrom = 0; |
57 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 59 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
58 | return getFrom(ffrom); | 60 | return getFrom(ffrom); |
59 | } | 61 | } |
60 | 62 | ||
61 | mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { | 63 | mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { |
62 | mailimf_field *field; | 64 | mailimf_field *field; |
63 | clistiter *it; | 65 | clistiter *it; |
64 | 66 | ||
65 | it = clist_begin( fields->fld_list ); | 67 | it = clist_begin( fields->fld_list ); |
66 | while ( it ) { | 68 | while ( it ) { |
67 | field = (mailimf_field *) it->data; | 69 | field = (mailimf_field *) it->data; |
68 | if ( field->fld_type == type ) { | 70 | if ( field->fld_type == type ) { |
69 | return field; | 71 | return field; |
70 | } | 72 | } |
71 | it = it->next; | 73 | it = it->next; |
72 | } | 74 | } |
73 | 75 | ||
74 | return NULL; | 76 | return NULL; |
75 | } | 77 | } |
76 | 78 | ||
77 | mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { | 79 | mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { |
78 | mailimf_address_list *addresses; | 80 | mailimf_address_list *addresses; |
79 | 81 | ||
80 | if ( addr.isEmpty() ) | 82 | if ( addr.isEmpty() ) |
81 | return NULL; | 83 | return NULL; |
82 | 84 | ||
83 | addresses = mailimf_address_list_new_empty(); | 85 | addresses = mailimf_address_list_new_empty(); |
84 | 86 | ||
85 | bool literal_open = false; | 87 | bool literal_open = false; |
86 | unsigned int startpos = 0; | 88 | unsigned int startpos = 0; |
87 | QStringList list; | 89 | QStringList list; |
88 | QString s; | 90 | QString s; |
89 | unsigned int i = 0; | 91 | unsigned int i = 0; |
90 | for (; i < addr.length();++i) { | 92 | for (; i < addr.length();++i) { |
91 | switch (addr[i]) { | 93 | switch (addr[i]) { |
92 | case '\"': | 94 | case '\"': |
93 | literal_open = !literal_open; | 95 | literal_open = !literal_open; |
94 | break; | 96 | break; |
95 | case ',': | 97 | case ',': |
96 | if (!literal_open) { | 98 | if (!literal_open) { |
97 | s = addr.mid(startpos,i-startpos); | 99 | s = addr.mid(startpos,i-startpos); |
98 | if (!s.isEmpty()) { | 100 | if (!s.isEmpty()) { |
99 | list.append(s); | 101 | list.append(s); |
100 | odebug << "Appended " << s.latin1() << "" << oendl; | 102 | odebug << "Appended " << s.latin1() << "" << oendl; |
101 | } | 103 | } |
102 | // !!!! this is a MUST BE! | 104 | // !!!! this is a MUST BE! |
103 | startpos = ++i; | 105 | startpos = ++i; |
104 | } | 106 | } |
105 | break; | 107 | break; |
106 | default: | 108 | default: |
107 | break; | 109 | break; |
108 | } | 110 | } |
109 | } | 111 | } |
110 | s = addr.mid(startpos,i-startpos); | 112 | s = addr.mid(startpos,i-startpos); |
111 | if (!s.isEmpty()) { | 113 | if (!s.isEmpty()) { |
112 | list.append(s); | 114 | list.append(s); |
113 | odebug << "Appended " << s.latin1() << "" << oendl; | 115 | odebug << "Appended " << s.latin1() << "" << oendl; |
114 | } | 116 | } |
115 | QStringList::Iterator it; | 117 | QStringList::Iterator it; |
116 | for ( it = list.begin(); it != list.end(); it++ ) { | 118 | for ( it = list.begin(); it != list.end(); it++ ) { |
117 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); | 119 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); |
118 | if ( err != MAILIMF_NO_ERROR ) { | 120 | if ( err != MAILIMF_NO_ERROR ) { |
119 | odebug << "Error parsing" << oendl; | 121 | odebug << "Error parsing" << oendl; |
120 | odebug << *it << oendl; | 122 | odebug << *it << oendl; |
121 | } else { | 123 | } else { |
122 | odebug << "Parse success! " << (*it).latin1() << "" << oendl; | 124 | odebug << "Parse success! " << (*it).latin1() << "" << oendl; |
123 | } | 125 | } |
124 | } | 126 | } |
125 | return addresses; | 127 | return addresses; |
126 | } | 128 | } |
127 | 129 | ||
128 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { | 130 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { |
129 | mailmime * filePart = 0; | 131 | mailmime * filePart = 0; |
130 | mailmime_fields * fields = 0; | 132 | mailmime_fields * fields = 0; |
131 | mailmime_content * content = 0; | 133 | mailmime_content * content = 0; |
132 | mailmime_parameter * param = 0; | 134 | mailmime_parameter * param = 0; |
133 | char*name = 0; | 135 | char*name = 0; |
134 | char*file = 0; | 136 | char*file = 0; |
135 | int err; | 137 | int err; |
136 | 138 | ||
137 | int pos = filename.findRev( '/' ); | 139 | int pos = filename.findRev( '/' ); |
138 | 140 | ||
139 | if (filename.length()>0) { | 141 | if (filename.length()>0) { |
140 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 142 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
141 | name = strdup( tmp.latin1() ); // just filename | 143 | name = strdup( tmp.latin1() ); // just filename |
142 | file = strdup( filename.latin1() ); // full name with path | 144 | file = strdup( filename.latin1() ); // full name with path |
143 | } | 145 | } |
144 | 146 | ||
145 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 147 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
146 | int mechanism = MAILMIME_MECHANISM_BASE64; | 148 | int mechanism = MAILMIME_MECHANISM_BASE64; |
147 | 149 | ||
148 | if ( mimetype.startsWith( "text/" ) ) { | 150 | if ( mimetype.startsWith( "text/" ) ) { |
149 | param = mailmime_parameter_new( strdup( "charset" ), | 151 | param = mailmime_parameter_new( strdup( "charset" ), |
150 | strdup( "iso-8859-1" ) ); | 152 | strdup( "iso-8859-1" ) ); |
151 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 153 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
152 | } | 154 | } |
153 | 155 | ||
154 | fields = mailmime_fields_new_filename( | 156 | fields = mailmime_fields_new_filename( |
155 | disptype, name, | 157 | disptype, name, |
156 | mechanism ); | 158 | mechanism ); |
157 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); | 159 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); |
158 | if (content!=0 && fields != 0) { | 160 | if (content!=0 && fields != 0) { |
159 | if (param) { | 161 | if (param) { |
160 | clist_append(content->ct_parameters,param); | 162 | clist_append(content->ct_parameters,param); |
161 | param = 0; | 163 | param = 0; |
162 | } | 164 | } |
163 | if (filename.length()>0) { | 165 | if (filename.length()>0) { |
164 | QFileInfo f(filename); | 166 | QFileInfo f(filename); |
165 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 167 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
166 | clist_append(content->ct_parameters,param); | 168 | clist_append(content->ct_parameters,param); |
167 | param = 0; | 169 | param = 0; |
168 | } | 170 | } |
169 | filePart = mailmime_new_empty( content, fields ); | 171 | filePart = mailmime_new_empty( content, fields ); |
170 | } | 172 | } |
171 | if (filePart) { | 173 | if (filePart) { |
172 | if (filename.length()>0) { | 174 | if (filename.length()>0) { |
173 | err = mailmime_set_body_file( filePart, file ); | 175 | err = mailmime_set_body_file( filePart, file ); |
174 | } else { | 176 | } else { |
175 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); | 177 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); |
176 | } | 178 | } |
177 | if (err != MAILIMF_NO_ERROR) { | 179 | if (err != MAILIMF_NO_ERROR) { |
178 | odebug << "Error setting body with file " << file << "" << oendl; | 180 | odebug << "Error setting body with file " << file << "" << oendl; |
179 | mailmime_free( filePart ); | 181 | mailmime_free( filePart ); |
180 | filePart = 0; | 182 | filePart = 0; |
181 | } | 183 | } |
182 | } | 184 | } |
183 | 185 | ||
184 | if (!filePart) { | 186 | if (!filePart) { |
185 | if ( param != NULL ) { | 187 | if ( param != NULL ) { |
186 | mailmime_parameter_free( param ); | 188 | mailmime_parameter_free( param ); |
187 | } | 189 | } |
188 | if (content) { | 190 | if (content) { |
189 | mailmime_content_free( content ); | 191 | mailmime_content_free( content ); |
190 | } | 192 | } |
191 | if (fields) { | 193 | if (fields) { |
192 | mailmime_fields_free( fields ); | 194 | mailmime_fields_free( fields ); |
193 | } else { | 195 | } else { |
194 | if (name) { | 196 | if (name) { |
195 | free( name ); | 197 | free( name ); |
196 | } | 198 | } |
197 | if (file) { | 199 | if (file) { |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index fae4c99..3e4293b 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,196 +1,198 @@ | |||
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> | ||
6 | |||
5 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
6 | Genericwrapper::Genericwrapper() | 8 | Genericwrapper::Genericwrapper() |
7 | : AbstractMail() | 9 | : AbstractMail() |
8 | { | 10 | { |
9 | bodyCache.clear(); | 11 | bodyCache.clear(); |
10 | m_storage = 0; | 12 | m_storage = 0; |
11 | m_folder = 0; | 13 | m_folder = 0; |
12 | } | 14 | } |
13 | 15 | ||
14 | Genericwrapper::~Genericwrapper() | 16 | Genericwrapper::~Genericwrapper() |
15 | { | 17 | { |
16 | if (m_folder) { | 18 | if (m_folder) { |
17 | mailfolder_free(m_folder); | 19 | mailfolder_free(m_folder); |
18 | } | 20 | } |
19 | if (m_storage) { | 21 | if (m_storage) { |
20 | mailstorage_free(m_storage); | 22 | mailstorage_free(m_storage); |
21 | } | 23 | } |
22 | cleanMimeCache(); | 24 | cleanMimeCache(); |
23 | } | 25 | } |
24 | 26 | ||
25 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 27 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
26 | { | 28 | { |
27 | if (!mime) { | 29 | if (!mime) { |
28 | return; | 30 | return; |
29 | } | 31 | } |
30 | mailmime_field*field = 0; | 32 | mailmime_field*field = 0; |
31 | mailmime_single_fields fields; | 33 | mailmime_single_fields fields; |
32 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 34 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
33 | if (mime->mm_mime_fields != NULL) { | 35 | if (mime->mm_mime_fields != NULL) { |
34 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 36 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
35 | mime->mm_content_type); | 37 | mime->mm_content_type); |
36 | } | 38 | } |
37 | 39 | ||
38 | mailmime_content*type = fields.fld_content; | 40 | mailmime_content*type = fields.fld_content; |
39 | clistcell*current; | 41 | clistcell*current; |
40 | if (!type) { | 42 | if (!type) { |
41 | target->setType("text"); | 43 | target->setType("text"); |
42 | target->setSubtype("plain"); | 44 | target->setSubtype("plain"); |
43 | } else { | 45 | } else { |
44 | target->setSubtype(type->ct_subtype); | 46 | target->setSubtype(type->ct_subtype); |
45 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 47 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
46 | case MAILMIME_DISCRETE_TYPE_TEXT: | 48 | case MAILMIME_DISCRETE_TYPE_TEXT: |
47 | target->setType("text"); | 49 | target->setType("text"); |
48 | break; | 50 | break; |
49 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 51 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
50 | target->setType("image"); | 52 | target->setType("image"); |
51 | break; | 53 | break; |
52 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 54 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
53 | target->setType("audio"); | 55 | target->setType("audio"); |
54 | break; | 56 | break; |
55 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 57 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
56 | target->setType("video"); | 58 | target->setType("video"); |
57 | break; | 59 | break; |
58 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 60 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
59 | target->setType("application"); | 61 | target->setType("application"); |
60 | break; | 62 | break; |
61 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 63 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
62 | default: | 64 | default: |
63 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 65 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
64 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 66 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
65 | } | 67 | } |
66 | break; | 68 | break; |
67 | } | 69 | } |
68 | if (type->ct_parameters) { | 70 | if (type->ct_parameters) { |
69 | fillParameters(target,type->ct_parameters); | 71 | fillParameters(target,type->ct_parameters); |
70 | } | 72 | } |
71 | } | 73 | } |
72 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 74 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
73 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 75 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
74 | field = (mailmime_field*)current->data; | 76 | field = (mailmime_field*)current->data; |
75 | switch(field->fld_type) { | 77 | switch(field->fld_type) { |
76 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 78 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
77 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 79 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
78 | break; | 80 | break; |
79 | case MAILMIME_FIELD_ID: | 81 | case MAILMIME_FIELD_ID: |
80 | target->setIdentifier(field->fld_data.fld_id); | 82 | target->setIdentifier(field->fld_data.fld_id); |
81 | break; | 83 | break; |
82 | case MAILMIME_FIELD_DESCRIPTION: | 84 | case MAILMIME_FIELD_DESCRIPTION: |
83 | target->setDescription(field->fld_data.fld_description); | 85 | target->setDescription(field->fld_data.fld_description); |
84 | break; | 86 | break; |
85 | default: | 87 | default: |
86 | break; | 88 | break; |
87 | } | 89 | } |
88 | } | 90 | } |
89 | } | 91 | } |
90 | } | 92 | } |
91 | 93 | ||
92 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) | 94 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
93 | { | 95 | { |
94 | if (!parameters) {return;} | 96 | if (!parameters) {return;} |
95 | clistcell*current=0; | 97 | clistcell*current=0; |
96 | mailmime_parameter*param; | 98 | mailmime_parameter*param; |
97 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 99 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
98 | param = (mailmime_parameter*)current->data; | 100 | param = (mailmime_parameter*)current->data; |
99 | if (param) { | 101 | if (param) { |
100 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 102 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
101 | } | 103 | } |
102 | } | 104 | } |
103 | } | 105 | } |
104 | 106 | ||
105 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 107 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
106 | { | 108 | { |
107 | QString enc="7bit"; | 109 | QString enc="7bit"; |
108 | if (!aEnc) return enc; | 110 | if (!aEnc) return enc; |
109 | switch(aEnc->enc_type) { | 111 | switch(aEnc->enc_type) { |
110 | case MAILMIME_MECHANISM_7BIT: | 112 | case MAILMIME_MECHANISM_7BIT: |
111 | enc = "7bit"; | 113 | enc = "7bit"; |
112 | break; | 114 | break; |
113 | case MAILMIME_MECHANISM_8BIT: | 115 | case MAILMIME_MECHANISM_8BIT: |
114 | enc = "8bit"; | 116 | enc = "8bit"; |
115 | break; | 117 | break; |
116 | case MAILMIME_MECHANISM_BINARY: | 118 | case MAILMIME_MECHANISM_BINARY: |
117 | enc = "binary"; | 119 | enc = "binary"; |
118 | break; | 120 | break; |
119 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 121 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
120 | enc = "quoted-printable"; | 122 | enc = "quoted-printable"; |
121 | break; | 123 | break; |
122 | case MAILMIME_MECHANISM_BASE64: | 124 | case MAILMIME_MECHANISM_BASE64: |
123 | enc = "base64"; | 125 | enc = "base64"; |
124 | break; | 126 | break; |
125 | case MAILMIME_MECHANISM_TOKEN: | 127 | case MAILMIME_MECHANISM_TOKEN: |
126 | default: | 128 | default: |
127 | if (aEnc->enc_token) { | 129 | if (aEnc->enc_token) { |
128 | enc = QString(aEnc->enc_token); | 130 | enc = QString(aEnc->enc_token); |
129 | } | 131 | } |
130 | break; | 132 | break; |
131 | } | 133 | } |
132 | return enc; | 134 | return enc; |
133 | } | 135 | } |
134 | 136 | ||
135 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 137 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
136 | { | 138 | { |
137 | if (current_rec >= 10) { | 139 | if (current_rec >= 10) { |
138 | odebug << "too deep recursion!" << oendl; | 140 | odebug << "too deep recursion!" << oendl; |
139 | } | 141 | } |
140 | if (!message || !mime) { | 142 | if (!message || !mime) { |
141 | return; | 143 | return; |
142 | } | 144 | } |
143 | int r; | 145 | int r; |
144 | char*data = 0; | 146 | char*data = 0; |
145 | size_t len; | 147 | size_t len; |
146 | clistiter * cur = 0; | 148 | clistiter * cur = 0; |
147 | QString b; | 149 | QString b; |
148 | RecPartP part = new RecPart(); | 150 | RecPartP part = new RecPart(); |
149 | 151 | ||
150 | switch (mime->mm_type) { | 152 | switch (mime->mm_type) { |
151 | case MAILMIME_SINGLE: | 153 | case MAILMIME_SINGLE: |
152 | { | 154 | { |
153 | QValueList<int>countlist = recList; | 155 | QValueList<int>countlist = recList; |
154 | countlist.append(current_count); | 156 | countlist.append(current_count); |
155 | r = mailmessage_fetch_section(message,mime,&data,&len); | 157 | r = mailmessage_fetch_section(message,mime,&data,&len); |
156 | part->setSize(len); | 158 | part->setSize(len); |
157 | part->setPositionlist(countlist); | 159 | part->setPositionlist(countlist); |
158 | b = gen_attachment_id(); | 160 | b = gen_attachment_id(); |
159 | part->setIdentifier(b); | 161 | part->setIdentifier(b); |
160 | fillSingleBody(part,message,mime); | 162 | fillSingleBody(part,message,mime); |
161 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 163 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
162 | encodedString*rs = new encodedString(); | 164 | encodedString*rs = new encodedString(); |
163 | rs->setContent(data,len); | 165 | rs->setContent(data,len); |
164 | encodedString*res = decode_String(rs,part->Encoding()); | 166 | encodedString*res = decode_String(rs,part->Encoding()); |
165 | if (countlist.count()>2) { | 167 | if (countlist.count()>2) { |
166 | bodyCache[b]=rs; | 168 | bodyCache[b]=rs; |
167 | target->addPart(part); | 169 | target->addPart(part); |
168 | } else { | 170 | } else { |
169 | delete rs; | 171 | delete rs; |
170 | } | 172 | } |
171 | b = QString(res->Content()); | 173 | b = QString(res->Content()); |
172 | delete res; | 174 | delete res; |
173 | target->setBodytext(b); | 175 | target->setBodytext(b); |
174 | target->setDescription(part); | 176 | target->setDescription(part); |
175 | } else { | 177 | } else { |
176 | bodyCache[b]=new encodedString(data,len); | 178 | bodyCache[b]=new encodedString(data,len); |
177 | target->addPart(part); | 179 | target->addPart(part); |
178 | } | 180 | } |
179 | } | 181 | } |
180 | break; | 182 | break; |
181 | case MAILMIME_MULTIPLE: | 183 | case MAILMIME_MULTIPLE: |
182 | { | 184 | { |
183 | unsigned int ccount = 1; | 185 | unsigned int ccount = 1; |
184 | mailmime*cbody=0; | 186 | mailmime*cbody=0; |
185 | QValueList<int>countlist = recList; | 187 | QValueList<int>countlist = recList; |
186 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 188 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
187 | cbody = (mailmime*)clist_content(cur); | 189 | cbody = (mailmime*)clist_content(cur); |
188 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 190 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
189 | RecPartP targetPart = new RecPart(); | 191 | RecPartP targetPart = new RecPart(); |
190 | targetPart->setType("multipart"); | 192 | targetPart->setType("multipart"); |
191 | countlist.append(current_count); | 193 | countlist.append(current_count); |
192 | targetPart->setPositionlist(countlist); | 194 | targetPart->setPositionlist(countlist); |
193 | target->addPart(targetPart); | 195 | target->addPart(targetPart); |
194 | } | 196 | } |
195 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 197 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
196 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 198 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 35468fe..9b7c0e0 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,196 +1,197 @@ | |||
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 | 6 | ||
6 | #include "imapwrapper.h" | 7 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 8 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 9 | #include "logindialog.h" |
9 | 10 | ||
10 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
11 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
12 | : AbstractMail() | 13 | : AbstractMail() |
13 | { | 14 | { |
14 | account = a; | 15 | account = a; |
15 | m_imap = 0; | 16 | m_imap = 0; |
16 | m_Lastmbox = ""; | 17 | m_Lastmbox = ""; |
17 | } | 18 | } |
18 | 19 | ||
19 | IMAPwrapper::~IMAPwrapper() | 20 | IMAPwrapper::~IMAPwrapper() |
20 | { | 21 | { |
21 | logout(); | 22 | logout(); |
22 | } | 23 | } |
23 | 24 | ||
24 | /* to avoid to often select statements in loops etc. | 25 | /* to avoid to often select statements in loops etc. |
25 | we trust that we are logged in and connection is established!*/ | 26 | we trust that we are logged in and connection is established!*/ |
26 | int IMAPwrapper::selectMbox(const QString&mbox) | 27 | int IMAPwrapper::selectMbox(const QString&mbox) |
27 | { | 28 | { |
28 | if (mbox == m_Lastmbox) { | 29 | if (mbox == m_Lastmbox) { |
29 | return MAILIMAP_NO_ERROR; | 30 | return MAILIMAP_NO_ERROR; |
30 | } | 31 | } |
31 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
32 | if ( err != MAILIMAP_NO_ERROR ) { | 33 | if ( err != MAILIMAP_NO_ERROR ) { |
33 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; | 34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; |
34 | m_Lastmbox = ""; | 35 | m_Lastmbox = ""; |
35 | return err; | 36 | return err; |
36 | } | 37 | } |
37 | m_Lastmbox = mbox; | 38 | m_Lastmbox = mbox; |
38 | return err; | 39 | return err; |
39 | } | 40 | } |
40 | 41 | ||
41 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
42 | { | 43 | { |
43 | qApp->processEvents(); | 44 | qApp->processEvents(); |
44 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; | 45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; |
45 | } | 46 | } |
46 | 47 | ||
47 | bool IMAPwrapper::start_tls(bool force_tls) | 48 | bool IMAPwrapper::start_tls(bool force_tls) |
48 | { | 49 | { |
49 | int err; | 50 | int err; |
50 | bool try_tls; | 51 | bool try_tls; |
51 | mailimap_capability_data * cap_data = 0; | 52 | mailimap_capability_data * cap_data = 0; |
52 | 53 | ||
53 | err = mailimap_capability(m_imap,&cap_data); | 54 | err = mailimap_capability(m_imap,&cap_data); |
54 | if (err != MAILIMAP_NO_ERROR) { | 55 | if (err != MAILIMAP_NO_ERROR) { |
55 | Global::statusMessage("error getting capabilities!"); | 56 | Global::statusMessage("error getting capabilities!"); |
56 | odebug << "error getting capabilities!" << oendl; | 57 | odebug << "error getting capabilities!" << oendl; |
57 | return false; | 58 | return false; |
58 | } | 59 | } |
59 | clistiter * cur; | 60 | clistiter * cur; |
60 | 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)) { |
61 | struct mailimap_capability * cap; | 62 | struct mailimap_capability * cap; |
62 | cap = (struct mailimap_capability *)clist_content(cur); | 63 | cap = (struct mailimap_capability *)clist_content(cur); |
63 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 64 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
64 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 65 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
65 | try_tls = true; | 66 | try_tls = true; |
66 | break; | 67 | break; |
67 | } | 68 | } |
68 | } | 69 | } |
69 | } | 70 | } |
70 | if (cap_data) { | 71 | if (cap_data) { |
71 | mailimap_capability_data_free(cap_data); | 72 | mailimap_capability_data_free(cap_data); |
72 | } | 73 | } |
73 | if (try_tls) { | 74 | if (try_tls) { |
74 | err = mailimap_starttls(m_imap); | 75 | err = mailimap_starttls(m_imap); |
75 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 76 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
76 | Global::statusMessage(tr("Server has no TLS support!")); | 77 | Global::statusMessage(tr("Server has no TLS support!")); |
77 | odebug << "Server has no TLS support!" << oendl; | 78 | odebug << "Server has no TLS support!" << oendl; |
78 | try_tls = false; | 79 | try_tls = false; |
79 | } else { | 80 | } else { |
80 | mailstream_low * low; | 81 | mailstream_low * low; |
81 | mailstream_low * new_low; | 82 | mailstream_low * new_low; |
82 | low = mailstream_get_low(m_imap->imap_stream); | 83 | low = mailstream_get_low(m_imap->imap_stream); |
83 | if (!low) { | 84 | if (!low) { |
84 | try_tls = false; | 85 | try_tls = false; |
85 | } else { | 86 | } else { |
86 | int fd = mailstream_low_get_fd(low); | 87 | int fd = mailstream_low_get_fd(low); |
87 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 88 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
88 | mailstream_low_free(low); | 89 | mailstream_low_free(low); |
89 | mailstream_set_low(m_imap->imap_stream, new_low); | 90 | mailstream_set_low(m_imap->imap_stream, new_low); |
90 | } else { | 91 | } else { |
91 | try_tls = false; | 92 | try_tls = false; |
92 | } | 93 | } |
93 | } | 94 | } |
94 | } | 95 | } |
95 | } | 96 | } |
96 | return try_tls; | 97 | return try_tls; |
97 | } | 98 | } |
98 | 99 | ||
99 | void IMAPwrapper::login() | 100 | void IMAPwrapper::login() |
100 | { | 101 | { |
101 | const char *server, *user, *pass; | 102 | const char *server, *user, *pass; |
102 | uint16_t port; | 103 | uint16_t port; |
103 | int err = MAILIMAP_NO_ERROR; | 104 | int err = MAILIMAP_NO_ERROR; |
104 | 105 | ||
105 | if (account->getOffline()) return; | 106 | if (account->getOffline()) return; |
106 | /* we are connected this moment */ | 107 | /* we are connected this moment */ |
107 | /* 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 */ |
108 | if (m_imap) { | 109 | if (m_imap) { |
109 | err = mailimap_noop(m_imap); | 110 | err = mailimap_noop(m_imap); |
110 | if (err!=MAILIMAP_NO_ERROR) { | 111 | if (err!=MAILIMAP_NO_ERROR) { |
111 | logout(); | 112 | logout(); |
112 | } else { | 113 | } else { |
113 | mailstream_flush(m_imap->imap_stream); | 114 | mailstream_flush(m_imap->imap_stream); |
114 | return; | 115 | return; |
115 | } | 116 | } |
116 | } | 117 | } |
117 | server = account->getServer().latin1(); | 118 | server = account->getServer().latin1(); |
118 | port = account->getPort().toUInt(); | 119 | port = account->getPort().toUInt(); |
119 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 120 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
120 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 121 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
121 | login.show(); | 122 | login.show(); |
122 | if ( QDialog::Accepted == login.exec() ) { | 123 | if ( QDialog::Accepted == login.exec() ) { |
123 | // ok | 124 | // ok |
124 | user = login.getUser().latin1(); | 125 | user = login.getUser().latin1(); |
125 | pass = login.getPassword().latin1(); | 126 | pass = login.getPassword().latin1(); |
126 | } else { | 127 | } else { |
127 | // cancel | 128 | // cancel |
128 | odebug << "IMAP: Login canceled" << oendl; | 129 | odebug << "IMAP: Login canceled" << oendl; |
129 | return; | 130 | return; |
130 | } | 131 | } |
131 | } else { | 132 | } else { |
132 | user = account->getUser().latin1(); | 133 | user = account->getUser().latin1(); |
133 | pass = account->getPassword().latin1(); | 134 | pass = account->getPassword().latin1(); |
134 | } | 135 | } |
135 | 136 | ||
136 | m_imap = mailimap_new( 20, &imap_progress ); | 137 | m_imap = mailimap_new( 20, &imap_progress ); |
137 | 138 | ||
138 | /* connect */ | 139 | /* connect */ |
139 | bool ssl = false; | 140 | bool ssl = false; |
140 | bool try_tls = false; | 141 | bool try_tls = false; |
141 | bool force_tls = false; | 142 | bool force_tls = false; |
142 | 143 | ||
143 | if ( account->ConnectionType() == 2 ) { | 144 | if ( account->ConnectionType() == 2 ) { |
144 | ssl = true; | 145 | ssl = true; |
145 | } | 146 | } |
146 | if (account->ConnectionType()==1) { | 147 | if (account->ConnectionType()==1) { |
147 | force_tls = true; | 148 | force_tls = true; |
148 | } | 149 | } |
149 | 150 | ||
150 | if ( ssl ) { | 151 | if ( ssl ) { |
151 | odebug << "using ssl" << oendl; | 152 | odebug << "using ssl" << oendl; |
152 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
153 | } else { | 154 | } else { |
154 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
155 | } | 156 | } |
156 | 157 | ||
157 | if ( err != MAILIMAP_NO_ERROR && | 158 | if ( err != MAILIMAP_NO_ERROR && |
158 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 159 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
159 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 160 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
160 | QString failure = ""; | 161 | QString failure = ""; |
161 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 162 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
162 | failure="Connection refused"; | 163 | failure="Connection refused"; |
163 | } else { | 164 | } else { |
164 | failure="Unknown failure"; | 165 | failure="Unknown failure"; |
165 | } | 166 | } |
166 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 167 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
167 | mailimap_free( m_imap ); | 168 | mailimap_free( m_imap ); |
168 | m_imap = 0; | 169 | m_imap = 0; |
169 | return; | 170 | return; |
170 | } | 171 | } |
171 | 172 | ||
172 | if (!ssl) { | 173 | if (!ssl) { |
173 | try_tls = start_tls(force_tls); | 174 | try_tls = start_tls(force_tls); |
174 | } | 175 | } |
175 | 176 | ||
176 | bool ok = true; | 177 | bool ok = true; |
177 | if (force_tls && !try_tls) { | 178 | if (force_tls && !try_tls) { |
178 | Global::statusMessage(tr("Server has no TLS support!")); | 179 | Global::statusMessage(tr("Server has no TLS support!")); |
179 | odebug << "Server has no TLS support!" << oendl; | 180 | odebug << "Server has no TLS support!" << oendl; |
180 | ok = false; | 181 | ok = false; |
181 | } | 182 | } |
182 | 183 | ||
183 | 184 | ||
184 | /* login */ | 185 | /* login */ |
185 | 186 | ||
186 | if (ok) { | 187 | if (ok) { |
187 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 188 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
188 | if ( err != MAILIMAP_NO_ERROR ) { | 189 | if ( err != MAILIMAP_NO_ERROR ) { |
189 | 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)); |
190 | ok = false; | 191 | ok = false; |
191 | } | 192 | } |
192 | } | 193 | } |
193 | if (!ok) { | 194 | if (!ok) { |
194 | err = mailimap_close( m_imap ); | 195 | err = mailimap_close( m_imap ); |
195 | mailimap_free( m_imap ); | 196 | mailimap_free( m_imap ); |
196 | m_imap = 0; | 197 | m_imap = 0; |
diff --git a/noncore/net/mail/libmailwrapper/logindialog.cpp b/noncore/net/mail/libmailwrapper/logindialog.cpp index c9ae190..ce705b2 100644 --- a/noncore/net/mail/libmailwrapper/logindialog.cpp +++ b/noncore/net/mail/libmailwrapper/logindialog.cpp | |||
@@ -1,29 +1,33 @@ | |||
1 | #include <qlineedit.h> | 1 | #include <qlineedit.h> |
2 | 2 | ||
3 | #include "logindialog.h" | 3 | #include "logindialog.h" |
4 | 4 | ||
5 | #include <opie2/odebug.h> | ||
6 | |||
7 | using namespace Opie::Core; | ||
8 | |||
5 | LoginDialog::LoginDialog(const QString&user,const QString&pass, QWidget *parent, const char *name, bool modal, WFlags flags ) | 9 | LoginDialog::LoginDialog(const QString&user,const QString&pass, QWidget *parent, const char *name, bool modal, WFlags flags ) |
6 | : LoginDialogUI( parent, name, modal, flags ) | 10 | : LoginDialogUI( parent, name, modal, flags ) |
7 | { | 11 | { |
8 | userLine->setText( (user.isEmpty()?QString(""):user) ); | 12 | userLine->setText( (user.isEmpty()?QString(""):user) ); |
9 | passLine->setText( (pass.isEmpty()?QString(""):pass) ); | 13 | passLine->setText( (pass.isEmpty()?QString(""):pass) ); |
10 | _user = user; | 14 | _user = user; |
11 | _pass = pass; | 15 | _pass = pass; |
12 | 16 | ||
13 | if ( user.isEmpty() ) { | 17 | if ( user.isEmpty() ) { |
14 | userLine->setFocus(); | 18 | userLine->setFocus(); |
15 | } else { | 19 | } else { |
16 | passLine->setFocus(); | 20 | passLine->setFocus(); |
17 | } | 21 | } |
18 | } | 22 | } |
19 | 23 | ||
20 | void LoginDialog::accept() | 24 | void LoginDialog::accept() |
21 | { | 25 | { |
22 | //_user.replace( 0, _user.length(), userLine->text() ); | 26 | //_user.replace( 0, _user.length(), userLine->text() ); |
23 | //_pass.replace( 0, _pass.length(), passLine->text() ); | 27 | //_pass.replace( 0, _pass.length(), passLine->text() ); |
24 | _user = userLine->text(); | 28 | _user = userLine->text(); |
25 | _pass = passLine->text(); | 29 | _pass = passLine->text(); |
26 | 30 | ||
27 | odebug << "User im accept: |" << _user.latin1() << "|" << oendl; | 31 | odebug << "User im accept: |" << _user.latin1() << "|" << oendl; |
28 | QDialog::accept(); | 32 | QDialog::accept(); |
29 | } | 33 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 6d44db4..d4395a2 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,193 +1,196 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | |||
3 | #include <opie2/odebug.h> | ||
4 | |||
2 | #include <stdlib.h> | 5 | #include <stdlib.h> |
3 | 6 | ||
4 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
5 | RecMail::RecMail() | 8 | RecMail::RecMail() |
6 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
7 | { | 10 | { |
8 | init(); | 11 | init(); |
9 | } | 12 | } |
10 | 13 | ||
11 | RecMail::RecMail(const RecMail&old) | 14 | RecMail::RecMail(const RecMail&old) |
12 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
13 | { | 16 | { |
14 | init(); | 17 | init(); |
15 | copy_old(old); | 18 | copy_old(old); |
16 | odebug << "Copy constructor RecMail" << oendl; | 19 | odebug << "Copy constructor RecMail" << oendl; |
17 | } | 20 | } |
18 | 21 | ||
19 | RecMail::~RecMail() | 22 | RecMail::~RecMail() |
20 | { | 23 | { |
21 | wrapper = 0; | 24 | wrapper = 0; |
22 | } | 25 | } |
23 | 26 | ||
24 | void RecMail::copy_old(const RecMail&old) | 27 | void RecMail::copy_old(const RecMail&old) |
25 | { | 28 | { |
26 | subject = old.subject; | 29 | subject = old.subject; |
27 | date = old.date; | 30 | date = old.date; |
28 | mbox = old.mbox; | 31 | mbox = old.mbox; |
29 | msg_id = old.msg_id; | 32 | msg_id = old.msg_id; |
30 | msg_size = old.msg_size; | 33 | msg_size = old.msg_size; |
31 | msg_number = old.msg_number; | 34 | msg_number = old.msg_number; |
32 | from = old.from; | 35 | from = old.from; |
33 | msg_flags = old.msg_flags; | 36 | msg_flags = old.msg_flags; |
34 | to = old.to; | 37 | to = old.to; |
35 | cc = old.cc; | 38 | cc = old.cc; |
36 | bcc = old.bcc; | 39 | bcc = old.bcc; |
37 | wrapper = old.wrapper; | 40 | wrapper = old.wrapper; |
38 | in_reply_to = old.in_reply_to; | 41 | in_reply_to = old.in_reply_to; |
39 | references = old.references; | 42 | references = old.references; |
40 | replyto = old.replyto; | 43 | replyto = old.replyto; |
41 | } | 44 | } |
42 | 45 | ||
43 | void RecMail::init() | 46 | void RecMail::init() |
44 | { | 47 | { |
45 | to.clear(); | 48 | to.clear(); |
46 | cc.clear(); | 49 | cc.clear(); |
47 | bcc.clear(); | 50 | bcc.clear(); |
48 | in_reply_to.clear(); | 51 | in_reply_to.clear(); |
49 | references.clear(); | 52 | references.clear(); |
50 | wrapper = 0; | 53 | wrapper = 0; |
51 | } | 54 | } |
52 | 55 | ||
53 | void RecMail::setWrapper(AbstractMail*awrapper) | 56 | void RecMail::setWrapper(AbstractMail*awrapper) |
54 | { | 57 | { |
55 | wrapper = awrapper; | 58 | wrapper = awrapper; |
56 | } | 59 | } |
57 | 60 | ||
58 | AbstractMail* RecMail::Wrapper() | 61 | AbstractMail* RecMail::Wrapper() |
59 | { | 62 | { |
60 | return wrapper; | 63 | return wrapper; |
61 | } | 64 | } |
62 | 65 | ||
63 | void RecMail::setTo(const QStringList&list) | 66 | void RecMail::setTo(const QStringList&list) |
64 | { | 67 | { |
65 | to = list; | 68 | to = list; |
66 | } | 69 | } |
67 | 70 | ||
68 | const QStringList&RecMail::To()const | 71 | const QStringList&RecMail::To()const |
69 | { | 72 | { |
70 | return to; | 73 | return to; |
71 | } | 74 | } |
72 | 75 | ||
73 | void RecMail::setCC(const QStringList&list) | 76 | void RecMail::setCC(const QStringList&list) |
74 | { | 77 | { |
75 | cc = list; | 78 | cc = list; |
76 | } | 79 | } |
77 | 80 | ||
78 | const QStringList&RecMail::CC()const | 81 | const QStringList&RecMail::CC()const |
79 | { | 82 | { |
80 | return cc; | 83 | return cc; |
81 | } | 84 | } |
82 | 85 | ||
83 | void RecMail::setBcc(const QStringList&list) | 86 | void RecMail::setBcc(const QStringList&list) |
84 | { | 87 | { |
85 | bcc = list; | 88 | bcc = list; |
86 | } | 89 | } |
87 | 90 | ||
88 | const QStringList& RecMail::Bcc()const | 91 | const QStringList& RecMail::Bcc()const |
89 | { | 92 | { |
90 | return bcc; | 93 | return bcc; |
91 | } | 94 | } |
92 | 95 | ||
93 | void RecMail::setInreply(const QStringList&list) | 96 | void RecMail::setInreply(const QStringList&list) |
94 | { | 97 | { |
95 | in_reply_to = list; | 98 | in_reply_to = list; |
96 | } | 99 | } |
97 | 100 | ||
98 | const QStringList& RecMail::Inreply()const | 101 | const QStringList& RecMail::Inreply()const |
99 | { | 102 | { |
100 | return in_reply_to; | 103 | return in_reply_to; |
101 | } | 104 | } |
102 | 105 | ||
103 | void RecMail::setReferences(const QStringList&list) | 106 | void RecMail::setReferences(const QStringList&list) |
104 | { | 107 | { |
105 | references = list; | 108 | references = list; |
106 | } | 109 | } |
107 | 110 | ||
108 | const QStringList& RecMail::References()const | 111 | const QStringList& RecMail::References()const |
109 | { | 112 | { |
110 | return references; | 113 | return references; |
111 | } | 114 | } |
112 | 115 | ||
113 | RecPart::RecPart() | 116 | RecPart::RecPart() |
114 | : Opie::Core::ORefCount(), | 117 | : Opie::Core::ORefCount(), |
115 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 118 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
116 | { | 119 | { |
117 | m_Parameters.clear(); | 120 | m_Parameters.clear(); |
118 | m_poslist.clear(); | 121 | m_poslist.clear(); |
119 | } | 122 | } |
120 | 123 | ||
121 | RecPart::RecPart(const RecPart&old) | 124 | RecPart::RecPart(const RecPart&old) |
122 | : Opie::Core::ORefCount(), | 125 | : Opie::Core::ORefCount(), |
123 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 126 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
124 | { | 127 | { |
125 | m_type = old.m_type; | 128 | m_type = old.m_type; |
126 | m_subtype = old.m_subtype; | 129 | m_subtype = old.m_subtype; |
127 | m_identifier = old.m_identifier; | 130 | m_identifier = old.m_identifier; |
128 | m_encoding = old.m_encoding; | 131 | m_encoding = old.m_encoding; |
129 | m_description = old.m_description; | 132 | m_description = old.m_description; |
130 | m_lines = old.m_lines; | 133 | m_lines = old.m_lines; |
131 | m_size = old.m_size; | 134 | m_size = old.m_size; |
132 | m_Parameters = old.m_Parameters; | 135 | m_Parameters = old.m_Parameters; |
133 | m_poslist = old.m_poslist; | 136 | m_poslist = old.m_poslist; |
134 | odebug << "RecPart copy constructor" << oendl; | 137 | odebug << "RecPart copy constructor" << oendl; |
135 | } | 138 | } |
136 | 139 | ||
137 | RecPart::~RecPart() | 140 | RecPart::~RecPart() |
138 | { | 141 | { |
139 | } | 142 | } |
140 | 143 | ||
141 | void RecPart::setSize(unsigned int size) | 144 | void RecPart::setSize(unsigned int size) |
142 | { | 145 | { |
143 | m_size = size; | 146 | m_size = size; |
144 | } | 147 | } |
145 | 148 | ||
146 | const unsigned int RecPart::Size()const | 149 | const unsigned int RecPart::Size()const |
147 | { | 150 | { |
148 | return m_size; | 151 | return m_size; |
149 | } | 152 | } |
150 | 153 | ||
151 | void RecPart::setLines(unsigned int lines) | 154 | void RecPart::setLines(unsigned int lines) |
152 | { | 155 | { |
153 | m_lines = lines; | 156 | m_lines = lines; |
154 | } | 157 | } |
155 | 158 | ||
156 | const unsigned int RecPart::Lines()const | 159 | const unsigned int RecPart::Lines()const |
157 | { | 160 | { |
158 | return m_lines; | 161 | return m_lines; |
159 | } | 162 | } |
160 | 163 | ||
161 | const QString& RecPart::Type()const | 164 | const QString& RecPart::Type()const |
162 | { | 165 | { |
163 | return m_type; | 166 | return m_type; |
164 | } | 167 | } |
165 | 168 | ||
166 | void RecPart::setType(const QString&type) | 169 | void RecPart::setType(const QString&type) |
167 | { | 170 | { |
168 | m_type = type; | 171 | m_type = type; |
169 | } | 172 | } |
170 | 173 | ||
171 | const QString& RecPart::Subtype()const | 174 | const QString& RecPart::Subtype()const |
172 | { | 175 | { |
173 | return m_subtype; | 176 | return m_subtype; |
174 | } | 177 | } |
175 | 178 | ||
176 | void RecPart::setSubtype(const QString&subtype) | 179 | void RecPart::setSubtype(const QString&subtype) |
177 | { | 180 | { |
178 | m_subtype = subtype; | 181 | m_subtype = subtype; |
179 | } | 182 | } |
180 | 183 | ||
181 | const QString& RecPart::Identifier()const | 184 | const QString& RecPart::Identifier()const |
182 | { | 185 | { |
183 | return m_identifier; | 186 | return m_identifier; |
184 | } | 187 | } |
185 | 188 | ||
186 | void RecPart::setIdentifier(const QString&identifier) | 189 | void RecPart::setIdentifier(const QString&identifier) |
187 | { | 190 | { |
188 | m_identifier = identifier; | 191 | m_identifier = identifier; |
189 | } | 192 | } |
190 | 193 | ||
191 | const QString& RecPart::Encoding()const | 194 | const QString& RecPart::Encoding()const |
192 | { | 195 | { |
193 | return m_encoding; | 196 | return m_encoding; |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index df2112f..a030cca 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,198 +1,200 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | |||
8 | #include <opie2/odebug.h> | ||
7 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
8 | 10 | ||
9 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
10 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 12 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
11 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 13 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
12 | { | 14 | { |
13 | QDir dir(MBOXPath); | 15 | QDir dir(MBOXPath); |
14 | if (!dir.exists()) { | 16 | if (!dir.exists()) { |
15 | dir.mkdir(MBOXPath); | 17 | dir.mkdir(MBOXPath); |
16 | } | 18 | } |
17 | } | 19 | } |
18 | 20 | ||
19 | MBOXwrapper::~MBOXwrapper() | 21 | MBOXwrapper::~MBOXwrapper() |
20 | { | 22 | { |
21 | } | 23 | } |
22 | 24 | ||
23 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 25 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) |
24 | { | 26 | { |
25 | mailstorage*storage = mailstorage_new(NULL); | 27 | mailstorage*storage = mailstorage_new(NULL); |
26 | QString p = MBOXPath+"/"; | 28 | QString p = MBOXPath+"/"; |
27 | p+=mailbox; | 29 | p+=mailbox; |
28 | 30 | ||
29 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 31 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
30 | mailfolder*folder; | 32 | mailfolder*folder; |
31 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 33 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
32 | r = mailfolder_connect(folder); | 34 | r = mailfolder_connect(folder); |
33 | if (r != MAIL_NO_ERROR) { | 35 | if (r != MAIL_NO_ERROR) { |
34 | odebug << "Error initializing mbox" << oendl; | 36 | odebug << "Error initializing mbox" << oendl; |
35 | mailfolder_free(folder); | 37 | mailfolder_free(folder); |
36 | mailstorage_free(storage); | 38 | mailstorage_free(storage); |
37 | return; | 39 | return; |
38 | } | 40 | } |
39 | 41 | ||
40 | parseList(target,folder->fld_session,mailbox); | 42 | parseList(target,folder->fld_session,mailbox); |
41 | 43 | ||
42 | mailfolder_disconnect(folder); | 44 | mailfolder_disconnect(folder); |
43 | mailfolder_free(folder); | 45 | mailfolder_free(folder); |
44 | mailstorage_free(storage); | 46 | mailstorage_free(storage); |
45 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 47 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
46 | } | 48 | } |
47 | 49 | ||
48 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 50 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
49 | { | 51 | { |
50 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 52 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
51 | QDir dir(MBOXPath); | 53 | QDir dir(MBOXPath); |
52 | if (!dir.exists()) return folders; | 54 | if (!dir.exists()) return folders; |
53 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 55 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
54 | QStringList entries = dir.entryList(); | 56 | QStringList entries = dir.entryList(); |
55 | QStringList::ConstIterator it = entries.begin(); | 57 | QStringList::ConstIterator it = entries.begin(); |
56 | for (;it!=entries.end();++it) { | 58 | for (;it!=entries.end();++it) { |
57 | FolderP inb=new Folder(*it,"/"); | 59 | FolderP inb=new Folder(*it,"/"); |
58 | folders->append(inb); | 60 | folders->append(inb); |
59 | } | 61 | } |
60 | return folders; | 62 | return folders; |
61 | } | 63 | } |
62 | 64 | ||
63 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 65 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
64 | { | 66 | { |
65 | mailstorage*storage = mailstorage_new(NULL); | 67 | mailstorage*storage = mailstorage_new(NULL); |
66 | QString p = MBOXPath+"/"; | 68 | QString p = MBOXPath+"/"; |
67 | p+=mail->getMbox(); | 69 | p+=mail->getMbox(); |
68 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 70 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
69 | mailfolder*folder; | 71 | mailfolder*folder; |
70 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 72 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
71 | r = mailfolder_connect(folder); | 73 | r = mailfolder_connect(folder); |
72 | if (r != MAIL_NO_ERROR) { | 74 | if (r != MAIL_NO_ERROR) { |
73 | odebug << "Error initializing mbox" << oendl; | 75 | odebug << "Error initializing mbox" << oendl; |
74 | mailfolder_free(folder); | 76 | mailfolder_free(folder); |
75 | mailstorage_free(storage); | 77 | mailstorage_free(storage); |
76 | return; | 78 | return; |
77 | } | 79 | } |
78 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); | 80 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); |
79 | if (r != MAIL_NO_ERROR) { | 81 | if (r != MAIL_NO_ERROR) { |
80 | odebug << "error deleting mail" << oendl; | 82 | odebug << "error deleting mail" << oendl; |
81 | } | 83 | } |
82 | mailfolder_free(folder); | 84 | mailfolder_free(folder); |
83 | mailstorage_free(storage); | 85 | mailstorage_free(storage); |
84 | } | 86 | } |
85 | 87 | ||
86 | void MBOXwrapper::answeredMail(const RecMailP&) | 88 | void MBOXwrapper::answeredMail(const RecMailP&) |
87 | { | 89 | { |
88 | } | 90 | } |
89 | 91 | ||
90 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) | 92 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) |
91 | { | 93 | { |
92 | RecBodyP body = new RecBody(); | 94 | RecBodyP body = new RecBody(); |
93 | mailstorage*storage = mailstorage_new(NULL); | 95 | mailstorage*storage = mailstorage_new(NULL); |
94 | QString p = MBOXPath+"/"; | 96 | QString p = MBOXPath+"/"; |
95 | p+=mail->getMbox(); | 97 | p+=mail->getMbox(); |
96 | mailmessage * msg; | 98 | mailmessage * msg; |
97 | char*data=0; | 99 | char*data=0; |
98 | size_t size; | 100 | size_t size; |
99 | 101 | ||
100 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 102 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
101 | mailfolder*folder; | 103 | mailfolder*folder; |
102 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 104 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
103 | r = mailfolder_connect(folder); | 105 | r = mailfolder_connect(folder); |
104 | if (r != MAIL_NO_ERROR) { | 106 | if (r != MAIL_NO_ERROR) { |
105 | odebug << "Error initializing mbox" << oendl; | 107 | odebug << "Error initializing mbox" << oendl; |
106 | mailfolder_free(folder); | 108 | mailfolder_free(folder); |
107 | mailstorage_free(storage); | 109 | mailstorage_free(storage); |
108 | return body; | 110 | return body; |
109 | } | 111 | } |
110 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 112 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
111 | if (r != MAIL_NO_ERROR) { | 113 | if (r != MAIL_NO_ERROR) { |
112 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; | 114 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; |
113 | mailfolder_free(folder); | 115 | mailfolder_free(folder); |
114 | mailstorage_free(storage); | 116 | mailstorage_free(storage); |
115 | return body; | 117 | return body; |
116 | } | 118 | } |
117 | r = mailmessage_fetch(msg,&data,&size); | 119 | r = mailmessage_fetch(msg,&data,&size); |
118 | if (r != MAIL_NO_ERROR) { | 120 | if (r != MAIL_NO_ERROR) { |
119 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; | 121 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; |
120 | mailfolder_free(folder); | 122 | mailfolder_free(folder); |
121 | mailstorage_free(storage); | 123 | mailstorage_free(storage); |
122 | mailmessage_free(msg); | 124 | mailmessage_free(msg); |
123 | return body; | 125 | return body; |
124 | } | 126 | } |
125 | body = parseMail(msg); | 127 | body = parseMail(msg); |
126 | mailmessage_fetch_result_free(msg,data); | 128 | mailmessage_fetch_result_free(msg,data); |
127 | mailfolder_free(folder); | 129 | mailfolder_free(folder); |
128 | mailstorage_free(storage); | 130 | mailstorage_free(storage); |
129 | 131 | ||
130 | return body; | 132 | return body; |
131 | } | 133 | } |
132 | 134 | ||
133 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
134 | { | 136 | { |
135 | odebug << "MBOX " << current << " von " << maximum << "" << oendl; | 137 | odebug << "MBOX " << current << " von " << maximum << "" << oendl; |
136 | } | 138 | } |
137 | 139 | ||
138 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) | 140 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
139 | { | 141 | { |
140 | QString p = MBOXPath+"/"; | 142 | QString p = MBOXPath+"/"; |
141 | p+=folder; | 143 | p+=folder; |
142 | QFileInfo fi(p); | 144 | QFileInfo fi(p); |
143 | if (fi.exists()) { | 145 | if (fi.exists()) { |
144 | Global::statusMessage(tr("Mailbox exists.")); | 146 | Global::statusMessage(tr("Mailbox exists.")); |
145 | return 0; | 147 | return 0; |
146 | } | 148 | } |
147 | mailmbox_folder*f = 0; | 149 | mailmbox_folder*f = 0; |
148 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
149 | Global::statusMessage(tr("Error init folder")); | 151 | Global::statusMessage(tr("Error init folder")); |
150 | return 0; | 152 | return 0; |
151 | } | 153 | } |
152 | if (f) mailmbox_done(f); | 154 | if (f) mailmbox_done(f); |
153 | return 1; | 155 | return 1; |
154 | } | 156 | } |
155 | 157 | ||
156 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
157 | { | 159 | { |
158 | QString p = MBOXPath+"/"; | 160 | QString p = MBOXPath+"/"; |
159 | p+=folder; | 161 | p+=folder; |
160 | mailmbox_folder*f = 0; | 162 | mailmbox_folder*f = 0; |
161 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
162 | if (r != MAIL_NO_ERROR) { | 164 | if (r != MAIL_NO_ERROR) { |
163 | Global::statusMessage(tr("Error init folder")); | 165 | Global::statusMessage(tr("Error init folder")); |
164 | return; | 166 | return; |
165 | } | 167 | } |
166 | r = mailmbox_append_message(f,msg,length); | 168 | r = mailmbox_append_message(f,msg,length); |
167 | if (r != MAIL_NO_ERROR) { | 169 | if (r != MAIL_NO_ERROR) { |
168 | Global::statusMessage(tr("Error writing to message folder")); | 170 | Global::statusMessage(tr("Error writing to message folder")); |
169 | } | 171 | } |
170 | mailmbox_done(f); | 172 | mailmbox_done(f); |
171 | } | 173 | } |
172 | 174 | ||
173 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | 175 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) |
174 | { | 176 | { |
175 | RecBody body; | 177 | RecBody body; |
176 | mailstorage*storage = mailstorage_new(NULL); | 178 | mailstorage*storage = mailstorage_new(NULL); |
177 | QString p = MBOXPath+"/"; | 179 | QString p = MBOXPath+"/"; |
178 | p+=mail->getMbox(); | 180 | p+=mail->getMbox(); |
179 | mailmessage * msg; | 181 | mailmessage * msg; |
180 | char*data=0; | 182 | char*data=0; |
181 | size_t size; | 183 | size_t size; |
182 | 184 | ||
183 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
184 | mailfolder*folder; | 186 | mailfolder*folder; |
185 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
186 | r = mailfolder_connect(folder); | 188 | r = mailfolder_connect(folder); |
187 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
188 | Global::statusMessage(tr("Error initializing mbox")); | 190 | Global::statusMessage(tr("Error initializing mbox")); |
189 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
190 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
191 | return 0; | 193 | return 0; |
192 | } | 194 | } |
193 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 195 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
194 | if (r != MAIL_NO_ERROR) { | 196 | if (r != MAIL_NO_ERROR) { |
195 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
196 | mailfolder_free(folder); | 198 | mailfolder_free(folder); |
197 | mailstorage_free(storage); | 199 | mailstorage_free(storage); |
198 | return 0; | 200 | return 0; |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index cd7cecb..403afcf 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,201 +1,202 @@ | |||
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 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
13 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
14 | { | 15 | { |
15 | if (MHPath.length()>0) { | 16 | if (MHPath.length()>0) { |
16 | if (MHPath[MHPath.length()-1]=='/') { | 17 | if (MHPath[MHPath.length()-1]=='/') { |
17 | MHPath=MHPath.left(MHPath.length()-1); | 18 | MHPath=MHPath.left(MHPath.length()-1); |
18 | } | 19 | } |
19 | odebug << MHPath << oendl; | 20 | odebug << MHPath << oendl; |
20 | QDir dir(MHPath); | 21 | QDir dir(MHPath); |
21 | if (!dir.exists()) { | 22 | if (!dir.exists()) { |
22 | dir.mkdir(MHPath); | 23 | dir.mkdir(MHPath); |
23 | } | 24 | } |
24 | init_storage(); | 25 | init_storage(); |
25 | } | 26 | } |
26 | } | 27 | } |
27 | 28 | ||
28 | void MHwrapper::init_storage() | 29 | void MHwrapper::init_storage() |
29 | { | 30 | { |
30 | int r; | 31 | int r; |
31 | QString pre = MHPath; | 32 | QString pre = MHPath; |
32 | if (!m_storage) { | 33 | if (!m_storage) { |
33 | m_storage = mailstorage_new(NULL); | 34 | m_storage = mailstorage_new(NULL); |
34 | 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); |
35 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
36 | odebug << "error initializing storage" << oendl; | 37 | odebug << "error initializing storage" << oendl; |
37 | mailstorage_free(m_storage); | 38 | mailstorage_free(m_storage); |
38 | m_storage = 0; | 39 | m_storage = 0; |
39 | return; | 40 | return; |
40 | } | 41 | } |
41 | } | 42 | } |
42 | r = mailstorage_connect(m_storage); | 43 | r = mailstorage_connect(m_storage); |
43 | if (r!=MAIL_NO_ERROR) { | 44 | if (r!=MAIL_NO_ERROR) { |
44 | odebug << "error connecting storage" << oendl; | 45 | odebug << "error connecting storage" << oendl; |
45 | mailstorage_free(m_storage); | 46 | mailstorage_free(m_storage); |
46 | m_storage = 0; | 47 | m_storage = 0; |
47 | } | 48 | } |
48 | } | 49 | } |
49 | 50 | ||
50 | void MHwrapper::clean_storage() | 51 | void MHwrapper::clean_storage() |
51 | { | 52 | { |
52 | if (m_storage) { | 53 | if (m_storage) { |
53 | mailstorage_disconnect(m_storage); | 54 | mailstorage_disconnect(m_storage); |
54 | mailstorage_free(m_storage); | 55 | mailstorage_free(m_storage); |
55 | m_storage = 0; | 56 | m_storage = 0; |
56 | } | 57 | } |
57 | } | 58 | } |
58 | 59 | ||
59 | MHwrapper::~MHwrapper() | 60 | MHwrapper::~MHwrapper() |
60 | { | 61 | { |
61 | clean_storage(); | 62 | clean_storage(); |
62 | } | 63 | } |
63 | 64 | ||
64 | 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 ) |
65 | { | 66 | { |
66 | init_storage(); | 67 | init_storage(); |
67 | if (!m_storage) { | 68 | if (!m_storage) { |
68 | return; | 69 | return; |
69 | } | 70 | } |
70 | QString f = buildPath(mailbox); | 71 | QString f = buildPath(mailbox); |
71 | 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()); |
72 | if (r!=MAIL_NO_ERROR) { | 73 | if (r!=MAIL_NO_ERROR) { |
73 | odebug << "listMessages: error selecting folder!" << oendl; | 74 | odebug << "listMessages: error selecting folder!" << oendl; |
74 | return; | 75 | return; |
75 | } | 76 | } |
76 | parseList(target,m_storage->sto_session,f); | 77 | parseList(target,m_storage->sto_session,f); |
77 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
78 | } | 79 | } |
79 | 80 | ||
80 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
81 | { | 82 | { |
82 | 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> >(); |
83 | /* this is needed! */ | 84 | /* this is needed! */ |
84 | if (m_storage) mailstorage_disconnect(m_storage); | 85 | if (m_storage) mailstorage_disconnect(m_storage); |
85 | init_storage(); | 86 | init_storage(); |
86 | if (!m_storage) { | 87 | if (!m_storage) { |
87 | return folders; | 88 | return folders; |
88 | } | 89 | } |
89 | mail_list*flist = 0; | 90 | mail_list*flist = 0; |
90 | clistcell*current=0; | 91 | clistcell*current=0; |
91 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
92 | if (r != MAIL_NO_ERROR || !flist) { | 93 | if (r != MAIL_NO_ERROR || !flist) { |
93 | odebug << "error getting folder list" << oendl; | 94 | odebug << "error getting folder list" << oendl; |
94 | return folders; | 95 | return folders; |
95 | } | 96 | } |
96 | 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)) { |
97 | QString t = (char*)current->data; | 98 | QString t = (char*)current->data; |
98 | t.replace(0,MHPath.length(),""); | 99 | t.replace(0,MHPath.length(),""); |
99 | folders->append(new MHFolder(t,MHPath)); | 100 | folders->append(new MHFolder(t,MHPath)); |
100 | } | 101 | } |
101 | mail_list_free(flist); | 102 | mail_list_free(flist); |
102 | return folders; | 103 | return folders; |
103 | } | 104 | } |
104 | 105 | ||
105 | void MHwrapper::deleteMail(const RecMailP&mail) | 106 | void MHwrapper::deleteMail(const RecMailP&mail) |
106 | { | 107 | { |
107 | init_storage(); | 108 | init_storage(); |
108 | if (!m_storage) { | 109 | if (!m_storage) { |
109 | return; | 110 | return; |
110 | } | 111 | } |
111 | 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()); |
112 | if (r!=MAIL_NO_ERROR) { | 113 | if (r!=MAIL_NO_ERROR) { |
113 | odebug << "error selecting folder!" << oendl; | 114 | odebug << "error selecting folder!" << oendl; |
114 | return; | 115 | return; |
115 | } | 116 | } |
116 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
117 | if (r != MAIL_NO_ERROR) { | 118 | if (r != MAIL_NO_ERROR) { |
118 | odebug << "error deleting mail" << oendl; | 119 | odebug << "error deleting mail" << oendl; |
119 | } | 120 | } |
120 | } | 121 | } |
121 | 122 | ||
122 | void MHwrapper::answeredMail(const RecMailP&) | 123 | void MHwrapper::answeredMail(const RecMailP&) |
123 | { | 124 | { |
124 | } | 125 | } |
125 | 126 | ||
126 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
127 | { | 128 | { |
128 | RecBodyP body = new RecBody(); | 129 | RecBodyP body = new RecBody(); |
129 | init_storage(); | 130 | init_storage(); |
130 | if (!m_storage) { | 131 | if (!m_storage) { |
131 | return body; | 132 | return body; |
132 | } | 133 | } |
133 | mailmessage * msg; | 134 | mailmessage * msg; |
134 | char*data=0; | 135 | char*data=0; |
135 | 136 | ||
136 | /* mail should hold the complete path! */ | 137 | /* mail should hold the complete path! */ |
137 | 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()); |
138 | if (r != MAIL_NO_ERROR) { | 139 | if (r != MAIL_NO_ERROR) { |
139 | return body; | 140 | return body; |
140 | } | 141 | } |
141 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
142 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
143 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; | 144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; |
144 | return body; | 145 | return body; |
145 | } | 146 | } |
146 | body = parseMail(msg); | 147 | body = parseMail(msg); |
147 | mailmessage_fetch_result_free(msg,data); | 148 | mailmessage_fetch_result_free(msg,data); |
148 | return body; | 149 | return body; |
149 | } | 150 | } |
150 | 151 | ||
151 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
152 | { | 153 | { |
153 | odebug << "MH " << current << " von " << maximum << "" << oendl; | 154 | odebug << "MH " << current << " von " << maximum << "" << oendl; |
154 | } | 155 | } |
155 | 156 | ||
156 | QString MHwrapper::buildPath(const QString&p) | 157 | QString MHwrapper::buildPath(const QString&p) |
157 | { | 158 | { |
158 | QString f=""; | 159 | QString f=""; |
159 | if (p.length()==0||p=="/") | 160 | if (p.length()==0||p=="/") |
160 | return MHPath; | 161 | return MHPath; |
161 | if (!p.startsWith(MHPath)) { | 162 | if (!p.startsWith(MHPath)) { |
162 | f+=MHPath; | 163 | f+=MHPath; |
163 | } | 164 | } |
164 | if (!p.startsWith("/")) { | 165 | if (!p.startsWith("/")) { |
165 | f+="/"; | 166 | f+="/"; |
166 | } | 167 | } |
167 | f+=p; | 168 | f+=p; |
168 | return f; | 169 | return f; |
169 | } | 170 | } |
170 | 171 | ||
171 | 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 ) |
172 | { | 173 | { |
173 | init_storage(); | 174 | init_storage(); |
174 | if (!m_storage) { | 175 | if (!m_storage) { |
175 | return 0; | 176 | return 0; |
176 | } | 177 | } |
177 | QString f; | 178 | QString f; |
178 | if (!pfolder) { | 179 | if (!pfolder) { |
179 | // toplevel folder | 180 | // toplevel folder |
180 | f = buildPath(folder); | 181 | f = buildPath(folder); |
181 | } else { | 182 | } else { |
182 | f = pfolder->getName(); | 183 | f = pfolder->getName(); |
183 | f+="/"; | 184 | f+="/"; |
184 | f+=folder; | 185 | f+=folder; |
185 | } | 186 | } |
186 | odebug << f << oendl; | 187 | odebug << f << oendl; |
187 | 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()); |
188 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
189 | odebug << "error creating folder " << r << "" << oendl; | 190 | odebug << "error creating folder " << r << "" << oendl; |
190 | return 0; | 191 | return 0; |
191 | } | 192 | } |
192 | odebug << "Folder created" << oendl; | 193 | odebug << "Folder created" << oendl; |
193 | return 1; | 194 | return 1; |
194 | } | 195 | } |
195 | 196 | ||
196 | 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) |
197 | { | 198 | { |
198 | init_storage(); | 199 | init_storage(); |
199 | if (!m_storage) { | 200 | if (!m_storage) { |
200 | return; | 201 | return; |
201 | } | 202 | } |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 5d5011a..c99b97c 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,202 +1,203 @@ | |||
1 | #include "nntpwrapper.h" | 1 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 2 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | 8 | ||
9 | #include <libetpan/libetpan.h> | 9 | #include <libetpan/libetpan.h> |
10 | 10 | ||
11 | #include <opie2/odebug.h> | ||
11 | 12 | ||
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 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 16 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
16 | : Genericwrapper() { | 17 | : Genericwrapper() { |
17 | account = a; | 18 | account = a; |
18 | m_nntp = NULL; | 19 | m_nntp = NULL; |
19 | msgTempName = a->getFileName()+"_msg_cache"; | 20 | msgTempName = a->getFileName()+"_msg_cache"; |
20 | last_msg_id = 0; | 21 | last_msg_id = 0; |
21 | } | 22 | } |
22 | 23 | ||
23 | NNTPwrapper::~NNTPwrapper() { | 24 | NNTPwrapper::~NNTPwrapper() { |
24 | logout(); | 25 | logout(); |
25 | QFile msg_cache(msgTempName); | 26 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 27 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 28 | msg_cache.remove(); |
28 | } | 29 | } |
29 | } | 30 | } |
30 | 31 | ||
31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 32 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
32 | odebug << "NNTP: " << current << " of " << maximum << "" << oendl; | 33 | odebug << "NNTP: " << current << " of " << maximum << "" << oendl; |
33 | } | 34 | } |
34 | 35 | ||
35 | 36 | ||
36 | RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | 37 | RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { |
37 | int err = NEWSNNTP_NO_ERROR; | 38 | int err = NEWSNNTP_NO_ERROR; |
38 | char *message = 0; | 39 | char *message = 0; |
39 | size_t length = 0; | 40 | size_t length = 0; |
40 | 41 | ||
41 | RecBodyP body = new RecBody(); | 42 | RecBodyP body = new RecBody(); |
42 | login(); | 43 | login(); |
43 | if ( !m_nntp ) { | 44 | if ( !m_nntp ) { |
44 | return body; | 45 | return body; |
45 | } | 46 | } |
46 | 47 | ||
47 | mailmessage * mailmsg; | 48 | mailmessage * mailmsg; |
48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 49 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
49 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 50 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; |
50 | return body; | 51 | return body; |
51 | } | 52 | } |
52 | 53 | ||
53 | QFile msg_cache(msgTempName); | 54 | QFile msg_cache(msgTempName); |
54 | 55 | ||
55 | cleanMimeCache(); | 56 | cleanMimeCache(); |
56 | 57 | ||
57 | if (mail->getNumber()!=last_msg_id) { | 58 | if (mail->getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 59 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 60 | msg_cache.remove(); |
60 | } | 61 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 62 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail->getNumber(); | 63 | last_msg_id = mail->getNumber(); |
63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 64 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
64 | err = mailmessage_fetch(mailmsg,&message,&length); | 65 | err = mailmessage_fetch(mailmsg,&message,&length); |
65 | msg_cache.writeBlock(message,length); | 66 | msg_cache.writeBlock(message,length); |
66 | } else { | 67 | } else { |
67 | QString msg=""; | 68 | QString msg=""; |
68 | msg_cache.open(IO_ReadOnly); | 69 | msg_cache.open(IO_ReadOnly); |
69 | message = new char[4096]; | 70 | message = new char[4096]; |
70 | memset(message,0,4096); | 71 | memset(message,0,4096); |
71 | while (msg_cache.readBlock(message,4095)>0) { | 72 | while (msg_cache.readBlock(message,4095)>0) { |
72 | msg+=message; | 73 | msg+=message; |
73 | memset(message,0,4096); | 74 | memset(message,0,4096); |
74 | } | 75 | } |
75 | delete message; | 76 | delete message; |
76 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 77 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
77 | memset(message,0,msg.length()+1); | 78 | memset(message,0,msg.length()+1); |
78 | memcpy(message,msg.latin1(),msg.length()); | 79 | memcpy(message,msg.latin1(),msg.length()); |
79 | /* transform to libetpan stuff */ | 80 | /* transform to libetpan stuff */ |
80 | mailmsg = mailmessage_new(); | 81 | mailmsg = mailmessage_new(); |
81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 82 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
82 | generic_message_t * msg_data; | 83 | generic_message_t * msg_data; |
83 | msg_data = (generic_message_t *)mailmsg->msg_data; | 84 | msg_data = (generic_message_t *)mailmsg->msg_data; |
84 | msg_data->msg_fetched = 1; | 85 | msg_data->msg_fetched = 1; |
85 | msg_data->msg_message = message; | 86 | msg_data->msg_message = message; |
86 | msg_data->msg_length = strlen(message); | 87 | msg_data->msg_length = strlen(message); |
87 | } | 88 | } |
88 | body = parseMail(mailmsg); | 89 | body = parseMail(mailmsg); |
89 | 90 | ||
90 | /* clean up */ | 91 | /* clean up */ |
91 | if (mailmsg) | 92 | if (mailmsg) |
92 | mailmessage_free(mailmsg); | 93 | mailmessage_free(mailmsg); |
93 | if (message) | 94 | if (message) |
94 | free(message); | 95 | free(message); |
95 | 96 | ||
96 | return body; | 97 | return body; |
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 101 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
101 | { | 102 | { |
102 | login(); | 103 | login(); |
103 | if (!m_nntp) | 104 | if (!m_nntp) |
104 | return; | 105 | return; |
105 | uint32_t res_messages,res_recent,res_unseen; | 106 | uint32_t res_messages,res_recent,res_unseen; |
106 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 107 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
107 | parseList(target,m_nntp->sto_session,which,true); | 108 | parseList(target,m_nntp->sto_session,which,true); |
108 | } | 109 | } |
109 | 110 | ||
110 | void NNTPwrapper::login() | 111 | void NNTPwrapper::login() |
111 | { | 112 | { |
112 | if (account->getOffline()) | 113 | if (account->getOffline()) |
113 | return; | 114 | return; |
114 | /* we'll hold the line */ | 115 | /* we'll hold the line */ |
115 | if ( m_nntp != NULL ) | 116 | if ( m_nntp != NULL ) |
116 | return; | 117 | return; |
117 | 118 | ||
118 | const char *server, *user, *pass; | 119 | const char *server, *user, *pass; |
119 | QString User,Pass; | 120 | QString User,Pass; |
120 | uint16_t port; | 121 | uint16_t port; |
121 | int err = NEWSNNTP_NO_ERROR; | 122 | int err = NEWSNNTP_NO_ERROR; |
122 | 123 | ||
123 | server = account->getServer().latin1(); | 124 | server = account->getServer().latin1(); |
124 | port = account->getPort().toUInt(); | 125 | port = account->getPort().toUInt(); |
125 | 126 | ||
126 | user = pass = 0; | 127 | user = pass = 0; |
127 | 128 | ||
128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 129 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 130 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 131 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 132 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 133 | // ok |
133 | User = login.getUser().latin1(); | 134 | User = login.getUser().latin1(); |
134 | Pass = login.getPassword().latin1(); | 135 | Pass = login.getPassword().latin1(); |
135 | } else { | 136 | } else { |
136 | // cancel | 137 | // cancel |
137 | odebug << "NNTP: Login canceled" << oendl; | 138 | odebug << "NNTP: Login canceled" << oendl; |
138 | return; | 139 | return; |
139 | } | 140 | } |
140 | } else { | 141 | } else { |
141 | User = account->getUser().latin1(); | 142 | User = account->getUser().latin1(); |
142 | Pass = account->getPassword().latin1(); | 143 | Pass = account->getPassword().latin1(); |
143 | } | 144 | } |
144 | 145 | ||
145 | if (User.isEmpty()) { | 146 | if (User.isEmpty()) { |
146 | user=0; | 147 | user=0; |
147 | pass = 0; | 148 | pass = 0; |
148 | } else { | 149 | } else { |
149 | user=User.latin1(); | 150 | user=User.latin1(); |
150 | pass=Pass.latin1(); | 151 | pass=Pass.latin1(); |
151 | } | 152 | } |
152 | // bool ssl = account->getSSL(); | 153 | // bool ssl = account->getSSL(); |
153 | 154 | ||
154 | m_nntp=mailstorage_new(NULL); | 155 | m_nntp=mailstorage_new(NULL); |
155 | 156 | ||
156 | int conntypeset = account->ConnectionType(); | 157 | int conntypeset = account->ConnectionType(); |
157 | int conntype = 0; | 158 | int conntype = 0; |
158 | if ( conntypeset == 3 ) { | 159 | if ( conntypeset == 3 ) { |
159 | conntype = CONNECTION_TYPE_COMMAND; | 160 | conntype = CONNECTION_TYPE_COMMAND; |
160 | } else if ( conntypeset == 2 ) { | 161 | } else if ( conntypeset == 2 ) { |
161 | conntype = CONNECTION_TYPE_TLS; | 162 | conntype = CONNECTION_TYPE_TLS; |
162 | } else if ( conntypeset == 1 ) { | 163 | } else if ( conntypeset == 1 ) { |
163 | conntype = CONNECTION_TYPE_STARTTLS; | 164 | conntype = CONNECTION_TYPE_STARTTLS; |
164 | } else if ( conntypeset == 0 ) { | 165 | } else if ( conntypeset == 0 ) { |
165 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 166 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
166 | } | 167 | } |
167 | 168 | ||
168 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 169 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
169 | (char*)user,(char*)pass,0,0,0); | 170 | (char*)user,(char*)pass,0,0,0); |
170 | 171 | ||
171 | err = mailstorage_connect( m_nntp ); | 172 | err = mailstorage_connect( m_nntp ); |
172 | 173 | ||
173 | if (err != NEWSNNTP_NO_ERROR) { | 174 | if (err != NEWSNNTP_NO_ERROR) { |
174 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 175 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
175 | // Global::statusMessage(tr("Error initializing folder")); | 176 | // Global::statusMessage(tr("Error initializing folder")); |
176 | mailstorage_free(m_nntp); | 177 | mailstorage_free(m_nntp); |
177 | m_nntp = 0; | 178 | m_nntp = 0; |
178 | 179 | ||
179 | } else { | 180 | } else { |
180 | mailsession * session = m_nntp->sto_session; | 181 | mailsession * session = m_nntp->sto_session; |
181 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 182 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
182 | news->nntp_progr_fun = &nntp_progress; | 183 | news->nntp_progr_fun = &nntp_progress; |
183 | } | 184 | } |
184 | 185 | ||
185 | } | 186 | } |
186 | 187 | ||
187 | void NNTPwrapper::logout() | 188 | void NNTPwrapper::logout() |
188 | { | 189 | { |
189 | int err = NEWSNNTP_NO_ERROR; | 190 | int err = NEWSNNTP_NO_ERROR; |
190 | if ( m_nntp == NULL ) | 191 | if ( m_nntp == NULL ) |
191 | return; | 192 | return; |
192 | mailstorage_free(m_nntp); | 193 | mailstorage_free(m_nntp); |
193 | m_nntp = 0; | 194 | m_nntp = 0; |
194 | } | 195 | } |
195 | 196 | ||
196 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 197 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
197 | 198 | ||
198 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 199 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
199 | QStringList groups; | 200 | QStringList groups; |
200 | if (account) { | 201 | if (account) { |
201 | groups = account->getGroups(); | 202 | groups = account->getGroups(); |
202 | } | 203 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index c586c29..3cfd1ee 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,200 +1,201 @@ | |||
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 | |||
7 | #include <opie2/odebug.h> | ||
6 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
7 | #include <qfile.h> | 9 | #include <qfile.h> |
8 | //#include <qstring.h> | ||
9 | 10 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 11 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 12 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 13 | ||
13 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
14 | POP3wrapper::POP3wrapper( POP3account *a ) | 15 | POP3wrapper::POP3wrapper( POP3account *a ) |
15 | : Genericwrapper() { | 16 | : Genericwrapper() { |
16 | account = a; | 17 | account = a; |
17 | m_pop3 = NULL; | 18 | m_pop3 = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 19 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 20 | last_msg_id = 0; |
20 | } | 21 | } |
21 | 22 | ||
22 | POP3wrapper::~POP3wrapper() { | 23 | POP3wrapper::~POP3wrapper() { |
23 | logout(); | 24 | logout(); |
24 | QFile msg_cache(msgTempName); | 25 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 26 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 27 | msg_cache.remove(); |
27 | } | 28 | } |
28 | } | 29 | } |
29 | 30 | ||
30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 31 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
31 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; | 32 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; |
32 | } | 33 | } |
33 | 34 | ||
34 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | 35 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { |
35 | int err = MAILPOP3_NO_ERROR; | 36 | int err = MAILPOP3_NO_ERROR; |
36 | char *message = 0; | 37 | char *message = 0; |
37 | size_t length = 0; | 38 | size_t length = 0; |
38 | 39 | ||
39 | RecBodyP body = new RecBody(); | 40 | RecBodyP body = new RecBody(); |
40 | 41 | ||
41 | login(); | 42 | login(); |
42 | if ( !m_pop3 ) { | 43 | if ( !m_pop3 ) { |
43 | return body; | 44 | return body; |
44 | } | 45 | } |
45 | 46 | ||
46 | mailmessage * mailmsg; | 47 | mailmessage * mailmsg; |
47 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
48 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 49 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; |
49 | return body; | 50 | return body; |
50 | } | 51 | } |
51 | 52 | ||
52 | QFile msg_cache(msgTempName); | 53 | QFile msg_cache(msgTempName); |
53 | 54 | ||
54 | cleanMimeCache(); | 55 | cleanMimeCache(); |
55 | 56 | ||
56 | if (mail->getNumber()!=last_msg_id) { | 57 | if (mail->getNumber()!=last_msg_id) { |
57 | if (msg_cache.exists()) { | 58 | if (msg_cache.exists()) { |
58 | msg_cache.remove(); | 59 | msg_cache.remove(); |
59 | } | 60 | } |
60 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 61 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
61 | last_msg_id = mail->getNumber(); | 62 | last_msg_id = mail->getNumber(); |
62 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 63 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
63 | err = mailmessage_fetch(mailmsg,&message,&length); | 64 | err = mailmessage_fetch(mailmsg,&message,&length); |
64 | msg_cache.writeBlock(message,length); | 65 | msg_cache.writeBlock(message,length); |
65 | } else { | 66 | } else { |
66 | QString msg=""; | 67 | QString msg=""; |
67 | msg_cache.open(IO_ReadOnly); | 68 | msg_cache.open(IO_ReadOnly); |
68 | message = new char[4096]; | 69 | message = new char[4096]; |
69 | memset(message,0,4096); | 70 | memset(message,0,4096); |
70 | while (msg_cache.readBlock(message,4095)>0) { | 71 | while (msg_cache.readBlock(message,4095)>0) { |
71 | msg+=message; | 72 | msg+=message; |
72 | memset(message,0,4096); | 73 | memset(message,0,4096); |
73 | } | 74 | } |
74 | delete message; | 75 | delete message; |
75 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 76 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
76 | memset(message,0,msg.length()+1); | 77 | memset(message,0,msg.length()+1); |
77 | memcpy(message,msg.latin1(),msg.length()); | 78 | memcpy(message,msg.latin1(),msg.length()); |
78 | /* transform to libetpan stuff */ | 79 | /* transform to libetpan stuff */ |
79 | mailmsg = mailmessage_new(); | 80 | mailmsg = mailmessage_new(); |
80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
81 | generic_message_t * msg_data; | 82 | generic_message_t * msg_data; |
82 | msg_data = (generic_message_t *)mailmsg->msg_data; | 83 | msg_data = (generic_message_t *)mailmsg->msg_data; |
83 | msg_data->msg_fetched = 1; | 84 | msg_data->msg_fetched = 1; |
84 | msg_data->msg_message = message; | 85 | msg_data->msg_message = message; |
85 | msg_data->msg_length = strlen(message); | 86 | msg_data->msg_length = strlen(message); |
86 | } | 87 | } |
87 | body = parseMail(mailmsg); | 88 | body = parseMail(mailmsg); |
88 | 89 | ||
89 | /* clean up */ | 90 | /* clean up */ |
90 | if (mailmsg) | 91 | if (mailmsg) |
91 | mailmessage_free(mailmsg); | 92 | mailmessage_free(mailmsg); |
92 | if (message) | 93 | if (message) |
93 | free(message); | 94 | free(message); |
94 | 95 | ||
95 | return body; | 96 | return body; |
96 | } | 97 | } |
97 | 98 | ||
98 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 99 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
99 | { | 100 | { |
100 | login(); | 101 | login(); |
101 | if (!m_pop3) | 102 | if (!m_pop3) |
102 | return; | 103 | return; |
103 | uint32_t res_messages,res_recent,res_unseen; | 104 | uint32_t res_messages,res_recent,res_unseen; |
104 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 105 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
105 | parseList(target,m_pop3->sto_session,"INBOX"); | 106 | parseList(target,m_pop3->sto_session,"INBOX"); |
106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 107 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
107 | } | 108 | } |
108 | 109 | ||
109 | void POP3wrapper::login() | 110 | void POP3wrapper::login() |
110 | { | 111 | { |
111 | if (account->getOffline()) | 112 | if (account->getOffline()) |
112 | return; | 113 | return; |
113 | /* we'll hold the line */ | 114 | /* we'll hold the line */ |
114 | if ( m_pop3 != NULL ) | 115 | if ( m_pop3 != NULL ) |
115 | return; | 116 | return; |
116 | 117 | ||
117 | const char *server, *user, *pass; | 118 | const char *server, *user, *pass; |
118 | uint16_t port; | 119 | uint16_t port; |
119 | int err = MAILPOP3_NO_ERROR; | 120 | int err = MAILPOP3_NO_ERROR; |
120 | 121 | ||
121 | server = account->getServer().latin1(); | 122 | server = account->getServer().latin1(); |
122 | port = account->getPort().toUInt(); | 123 | port = account->getPort().toUInt(); |
123 | 124 | ||
124 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 125 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
125 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 126 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
126 | login.show(); | 127 | login.show(); |
127 | if ( QDialog::Accepted == login.exec() ) { | 128 | if ( QDialog::Accepted == login.exec() ) { |
128 | // ok | 129 | // ok |
129 | user = login.getUser().latin1(); | 130 | user = login.getUser().latin1(); |
130 | pass = login.getPassword().latin1(); | 131 | pass = login.getPassword().latin1(); |
131 | } else { | 132 | } else { |
132 | // cancel | 133 | // cancel |
133 | odebug << "POP3: Login canceled" << oendl; | 134 | odebug << "POP3: Login canceled" << oendl; |
134 | return; | 135 | return; |
135 | } | 136 | } |
136 | } else { | 137 | } else { |
137 | user = account->getUser().latin1(); | 138 | user = account->getUser().latin1(); |
138 | pass = account->getPassword().latin1(); | 139 | pass = account->getPassword().latin1(); |
139 | } | 140 | } |
140 | 141 | ||
141 | // bool ssl = account->getSSL(); | 142 | // bool ssl = account->getSSL(); |
142 | 143 | ||
143 | m_pop3=mailstorage_new(NULL); | 144 | m_pop3=mailstorage_new(NULL); |
144 | 145 | ||
145 | int conntypeset = account->ConnectionType(); | 146 | int conntypeset = account->ConnectionType(); |
146 | int conntype = 0; | 147 | int conntype = 0; |
147 | if ( conntypeset == 3 ) { | 148 | if ( conntypeset == 3 ) { |
148 | conntype = CONNECTION_TYPE_COMMAND; | 149 | conntype = CONNECTION_TYPE_COMMAND; |
149 | } else if ( conntypeset == 2 ) { | 150 | } else if ( conntypeset == 2 ) { |
150 | conntype = CONNECTION_TYPE_TLS; | 151 | conntype = CONNECTION_TYPE_TLS; |
151 | } else if ( conntypeset == 1 ) { | 152 | } else if ( conntypeset == 1 ) { |
152 | conntype = CONNECTION_TYPE_STARTTLS; | 153 | conntype = CONNECTION_TYPE_STARTTLS; |
153 | } else if ( conntypeset == 0 ) { | 154 | } else if ( conntypeset == 0 ) { |
154 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 155 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
155 | } | 156 | } |
156 | 157 | ||
157 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 158 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
158 | 159 | ||
159 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 160 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
160 | (char*)user,(char*)pass,0,0,0); | 161 | (char*)user,(char*)pass,0,0,0); |
161 | 162 | ||
162 | 163 | ||
163 | err = mailstorage_connect(m_pop3); | 164 | err = mailstorage_connect(m_pop3); |
164 | if (err != MAIL_NO_ERROR) { | 165 | if (err != MAIL_NO_ERROR) { |
165 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 166 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
166 | Global::statusMessage(tr("Error initializing folder")); | 167 | Global::statusMessage(tr("Error initializing folder")); |
167 | mailstorage_free(m_pop3); | 168 | mailstorage_free(m_pop3); |
168 | m_pop3 = 0; | 169 | m_pop3 = 0; |
169 | } else { | 170 | } else { |
170 | mailsession * session = m_pop3->sto_session; | 171 | mailsession * session = m_pop3->sto_session; |
171 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 172 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
172 | if (mail) { | 173 | if (mail) { |
173 | mail->pop3_progr_fun = &pop3_progress; | 174 | mail->pop3_progr_fun = &pop3_progress; |
174 | } | 175 | } |
175 | } | 176 | } |
176 | } | 177 | } |
177 | 178 | ||
178 | void POP3wrapper::logout() | 179 | void POP3wrapper::logout() |
179 | { | 180 | { |
180 | if ( m_pop3 == NULL ) | 181 | if ( m_pop3 == NULL ) |
181 | return; | 182 | return; |
182 | mailstorage_free(m_pop3); | 183 | mailstorage_free(m_pop3); |
183 | m_pop3 = 0; | 184 | m_pop3 = 0; |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 188 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
188 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 189 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
189 | FolderP inb=new Folder("INBOX","/"); | 190 | FolderP inb=new Folder("INBOX","/"); |
190 | folders->append(inb); | 191 | folders->append(inb); |
191 | return folders; | 192 | return folders; |
192 | } | 193 | } |
193 | 194 | ||
194 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 195 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
195 | login(); | 196 | login(); |
196 | if (!m_pop3) | 197 | if (!m_pop3) |
197 | return; | 198 | return; |
198 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 199 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
199 | if (err != MAIL_NO_ERROR) { | 200 | if (err != MAIL_NO_ERROR) { |
200 | Global::statusMessage(tr("error deleting mail")); | 201 | Global::statusMessage(tr("error deleting mail")); |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index de36eeb..3c9b25c 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -1,195 +1,196 @@ | |||
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 <qpe/config.h> | 5 | #include <qpe/config.h> |
5 | 6 | ||
6 | #include "settings.h" | 7 | #include "settings.h" |
7 | //#include "defines.h" | 8 | //#include "defines.h" |
8 | 9 | ||
9 | #define IMAP_PORT "143" | 10 | #define IMAP_PORT "143" |
10 | #define IMAP_SSL_PORT "993" | 11 | #define IMAP_SSL_PORT "993" |
11 | #define SMTP_PORT "25" | 12 | #define SMTP_PORT "25" |
12 | #define SMTP_SSL_PORT "465" | 13 | #define SMTP_SSL_PORT "465" |
13 | #define POP3_PORT "110" | 14 | #define POP3_PORT "110" |
14 | #define POP3_SSL_PORT "995" | 15 | #define POP3_SSL_PORT "995" |
15 | #define NNTP_PORT "119" | 16 | #define NNTP_PORT "119" |
16 | #define NNTP_SSL_PORT "563" | 17 | #define NNTP_SSL_PORT "563" |
17 | 18 | ||
18 | 19 | ||
19 | Settings::Settings() | 20 | Settings::Settings() |
20 | : QObject() | 21 | : QObject() |
21 | { | 22 | { |
22 | updateAccounts(); | 23 | updateAccounts(); |
23 | } | 24 | } |
24 | 25 | ||
25 | void Settings::checkDirectory() | 26 | void Settings::checkDirectory() |
26 | { | 27 | { |
27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 28 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
28 | system( "mkdir -p $HOME/Applications/opiemail" ); | 29 | system( "mkdir -p $HOME/Applications/opiemail" ); |
29 | odebug << "$HOME/Applications/opiemail created" << oendl; | 30 | odebug << "$HOME/Applications/opiemail created" << oendl; |
30 | } | 31 | } |
31 | } | 32 | } |
32 | 33 | ||
33 | QList<Account> Settings::getAccounts() | 34 | QList<Account> Settings::getAccounts() |
34 | { | 35 | { |
35 | return accounts; | 36 | return accounts; |
36 | } | 37 | } |
37 | 38 | ||
38 | void Settings::addAccount( Account *account ) | 39 | void Settings::addAccount( Account *account ) |
39 | { | 40 | { |
40 | accounts.append( account ); | 41 | accounts.append( account ); |
41 | } | 42 | } |
42 | 43 | ||
43 | void Settings::delAccount( Account *account ) | 44 | void Settings::delAccount( Account *account ) |
44 | { | 45 | { |
45 | accounts.remove( account ); | 46 | accounts.remove( account ); |
46 | account->remove(); | 47 | account->remove(); |
47 | } | 48 | } |
48 | 49 | ||
49 | void Settings::updateAccounts() | 50 | void Settings::updateAccounts() |
50 | { | 51 | { |
51 | accounts.clear(); | 52 | accounts.clear(); |
52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 53 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
53 | QStringList::Iterator it; | 54 | QStringList::Iterator it; |
54 | 55 | ||
55 | QStringList imap = dir.entryList( "imap-*" ); | 56 | QStringList imap = dir.entryList( "imap-*" ); |
56 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 57 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
57 | odebug << "Added IMAP account" << oendl; | 58 | odebug << "Added IMAP account" << oendl; |
58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 59 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
59 | accounts.append( account ); | 60 | accounts.append( account ); |
60 | } | 61 | } |
61 | 62 | ||
62 | QStringList pop3 = dir.entryList( "pop3-*" ); | 63 | QStringList pop3 = dir.entryList( "pop3-*" ); |
63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 64 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
64 | odebug << "Added POP account" << oendl; | 65 | odebug << "Added POP account" << oendl; |
65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 66 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
66 | accounts.append( account ); | 67 | accounts.append( account ); |
67 | } | 68 | } |
68 | 69 | ||
69 | QStringList smtp = dir.entryList( "smtp-*" ); | 70 | QStringList smtp = dir.entryList( "smtp-*" ); |
70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 71 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
71 | odebug << "Added SMTP account" << oendl; | 72 | odebug << "Added SMTP account" << oendl; |
72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 73 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
73 | accounts.append( account ); | 74 | accounts.append( account ); |
74 | } | 75 | } |
75 | 76 | ||
76 | QStringList nntp = dir.entryList( "nntp-*" ); | 77 | QStringList nntp = dir.entryList( "nntp-*" ); |
77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 78 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
78 | odebug << "Added NNTP account" << oendl; | 79 | odebug << "Added NNTP account" << oendl; |
79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 80 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
80 | accounts.append( account ); | 81 | accounts.append( account ); |
81 | } | 82 | } |
82 | 83 | ||
83 | readAccounts(); | 84 | readAccounts(); |
84 | } | 85 | } |
85 | 86 | ||
86 | void Settings::saveAccounts() | 87 | void Settings::saveAccounts() |
87 | { | 88 | { |
88 | checkDirectory(); | 89 | checkDirectory(); |
89 | Account *it; | 90 | Account *it; |
90 | 91 | ||
91 | for ( it = accounts.first(); it; it = accounts.next() ) { | 92 | for ( it = accounts.first(); it; it = accounts.next() ) { |
92 | it->save(); | 93 | it->save(); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
96 | void Settings::readAccounts() | 97 | void Settings::readAccounts() |
97 | { | 98 | { |
98 | checkDirectory(); | 99 | checkDirectory(); |
99 | Account *it; | 100 | Account *it; |
100 | 101 | ||
101 | for ( it = accounts.first(); it; it = accounts.next() ) { | 102 | for ( it = accounts.first(); it; it = accounts.next() ) { |
102 | it->read(); | 103 | it->read(); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||
106 | Account::Account() | 107 | Account::Account() |
107 | { | 108 | { |
108 | accountName = "changeMe"; | 109 | accountName = "changeMe"; |
109 | type = MAILLIB::A_UNDEFINED; | 110 | type = MAILLIB::A_UNDEFINED; |
110 | ssl = false; | 111 | ssl = false; |
111 | connectionType = 1; | 112 | connectionType = 1; |
112 | offline = false; | 113 | offline = false; |
113 | } | 114 | } |
114 | 115 | ||
115 | void Account::remove() | 116 | void Account::remove() |
116 | { | 117 | { |
117 | QFile file( getFileName() ); | 118 | QFile file( getFileName() ); |
118 | file.remove(); | 119 | file.remove(); |
119 | } | 120 | } |
120 | 121 | ||
121 | IMAPaccount::IMAPaccount() | 122 | IMAPaccount::IMAPaccount() |
122 | : Account() | 123 | : Account() |
123 | { | 124 | { |
124 | file = IMAPaccount::getUniqueFileName(); | 125 | file = IMAPaccount::getUniqueFileName(); |
125 | accountName = "New IMAP Account"; | 126 | accountName = "New IMAP Account"; |
126 | ssl = false; | 127 | ssl = false; |
127 | connectionType = 1; | 128 | connectionType = 1; |
128 | type = MAILLIB::A_IMAP; | 129 | type = MAILLIB::A_IMAP; |
129 | port = IMAP_PORT; | 130 | port = IMAP_PORT; |
130 | } | 131 | } |
131 | 132 | ||
132 | IMAPaccount::IMAPaccount( QString filename ) | 133 | IMAPaccount::IMAPaccount( QString filename ) |
133 | : Account() | 134 | : Account() |
134 | { | 135 | { |
135 | file = filename; | 136 | file = filename; |
136 | accountName = "New IMAP Account"; | 137 | accountName = "New IMAP Account"; |
137 | ssl = false; | 138 | ssl = false; |
138 | connectionType = 1; | 139 | connectionType = 1; |
139 | type = MAILLIB::A_IMAP; | 140 | type = MAILLIB::A_IMAP; |
140 | port = IMAP_PORT; | 141 | port = IMAP_PORT; |
141 | } | 142 | } |
142 | 143 | ||
143 | QString IMAPaccount::getUniqueFileName() | 144 | QString IMAPaccount::getUniqueFileName() |
144 | { | 145 | { |
145 | int num = 0; | 146 | int num = 0; |
146 | QString unique; | 147 | QString unique; |
147 | 148 | ||
148 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 149 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
149 | 150 | ||
150 | QStringList imap = dir.entryList( "imap-*" ); | 151 | QStringList imap = dir.entryList( "imap-*" ); |
151 | do { | 152 | do { |
152 | unique.setNum( num++ ); | 153 | unique.setNum( num++ ); |
153 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 154 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
154 | 155 | ||
155 | return unique; | 156 | return unique; |
156 | } | 157 | } |
157 | 158 | ||
158 | void IMAPaccount::read() | 159 | void IMAPaccount::read() |
159 | { | 160 | { |
160 | Config *conf = new Config( getFileName(), Config::File ); | 161 | Config *conf = new Config( getFileName(), Config::File ); |
161 | conf->setGroup( "IMAP Account" ); | 162 | conf->setGroup( "IMAP Account" ); |
162 | accountName = conf->readEntry( "Account","" ); | 163 | accountName = conf->readEntry( "Account","" ); |
163 | if (accountName.isNull()) accountName = ""; | 164 | if (accountName.isNull()) accountName = ""; |
164 | server = conf->readEntry( "Server","" ); | 165 | server = conf->readEntry( "Server","" ); |
165 | if (server.isNull()) server=""; | 166 | if (server.isNull()) server=""; |
166 | port = conf->readEntry( "Port","" ); | 167 | port = conf->readEntry( "Port","" ); |
167 | if (port.isNull()) port="143"; | 168 | if (port.isNull()) port="143"; |
168 | connectionType = conf->readNumEntry( "ConnectionType" ); | 169 | connectionType = conf->readNumEntry( "ConnectionType" ); |
169 | ssl = conf->readBoolEntry( "SSL",false ); | 170 | ssl = conf->readBoolEntry( "SSL",false ); |
170 | user = conf->readEntry( "User","" ); | 171 | user = conf->readEntry( "User","" ); |
171 | if (user.isNull()) user = ""; | 172 | if (user.isNull()) user = ""; |
172 | password = conf->readEntryCrypt( "Password","" ); | 173 | password = conf->readEntryCrypt( "Password","" ); |
173 | if (password.isNull()) password = ""; | 174 | if (password.isNull()) password = ""; |
174 | prefix = conf->readEntry("MailPrefix",""); | 175 | prefix = conf->readEntry("MailPrefix",""); |
175 | if (prefix.isNull()) prefix = ""; | 176 | if (prefix.isNull()) prefix = ""; |
176 | offline = conf->readBoolEntry("Offline",false); | 177 | offline = conf->readBoolEntry("Offline",false); |
177 | delete conf; | 178 | delete conf; |
178 | } | 179 | } |
179 | 180 | ||
180 | void IMAPaccount::save() | 181 | void IMAPaccount::save() |
181 | { | 182 | { |
182 | odebug << "saving " + getFileName() << oendl; | 183 | odebug << "saving " + getFileName() << oendl; |
183 | Settings::checkDirectory(); | 184 | Settings::checkDirectory(); |
184 | 185 | ||
185 | Config *conf = new Config( getFileName(), Config::File ); | 186 | Config *conf = new Config( getFileName(), Config::File ); |
186 | conf->setGroup( "IMAP Account" ); | 187 | conf->setGroup( "IMAP Account" ); |
187 | conf->writeEntry( "Account", accountName ); | 188 | conf->writeEntry( "Account", accountName ); |
188 | conf->writeEntry( "Server", server ); | 189 | conf->writeEntry( "Server", server ); |
189 | conf->writeEntry( "Port", port ); | 190 | conf->writeEntry( "Port", port ); |
190 | conf->writeEntry( "SSL", ssl ); | 191 | conf->writeEntry( "SSL", ssl ); |
191 | conf->writeEntry( "ConnectionType", connectionType ); | 192 | conf->writeEntry( "ConnectionType", connectionType ); |
192 | conf->writeEntry( "User", user ); | 193 | conf->writeEntry( "User", user ); |
193 | conf->writeEntryCrypt( "Password", password ); | 194 | conf->writeEntryCrypt( "Password", password ); |
194 | conf->writeEntry( "MailPrefix",prefix); | 195 | conf->writeEntry( "MailPrefix",prefix); |
195 | conf->writeEntry( "Offline",offline); | 196 | conf->writeEntry( "Offline",offline); |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index ba78c3b..db7a8ee 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,199 +1,200 @@ | |||
1 | #include "smtpwrapper.h" | 1 | #include "smtpwrapper.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | #include "abstractmail.h" | 3 | #include "abstractmail.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include "sendmailprogress.h" | 6 | #include "sendmailprogress.h" |
7 | 7 | ||
8 | #include <opie2/odebug.h> | ||
8 | #include <qt.h> | 9 | #include <qt.h> |
9 | 10 | ||
10 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
11 | #include <qpe/qcopenvelope_qws.h> | 12 | #include <qpe/qcopenvelope_qws.h> |
12 | 13 | ||
13 | #include <libetpan/libetpan.h> | 14 | #include <libetpan/libetpan.h> |
14 | 15 | ||
15 | 16 | ||
16 | using namespace Opie::Core; | 17 | using namespace Opie::Core; |
17 | progressMailSend*SMTPwrapper::sendProgress = 0; | 18 | progressMailSend*SMTPwrapper::sendProgress = 0; |
18 | 19 | ||
19 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) | 20 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) |
20 | : Generatemail() | 21 | : Generatemail() |
21 | { | 22 | { |
22 | m_SmtpAccount = aSmtp; | 23 | m_SmtpAccount = aSmtp; |
23 | Config cfg( "mail" ); | 24 | Config cfg( "mail" ); |
24 | cfg.setGroup( "Status" ); | 25 | cfg.setGroup( "Status" ); |
25 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 26 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
26 | emit queuedMails( m_queuedMail ); | 27 | emit queuedMails( m_queuedMail ); |
27 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); | 28 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); |
28 | m_smtp = 0; | 29 | m_smtp = 0; |
29 | } | 30 | } |
30 | 31 | ||
31 | SMTPwrapper::~SMTPwrapper() | 32 | SMTPwrapper::~SMTPwrapper() |
32 | { | 33 | { |
33 | disc_server(); | 34 | disc_server(); |
34 | } | 35 | } |
35 | 36 | ||
36 | void SMTPwrapper::emitQCop( int queued ) { | 37 | void SMTPwrapper::emitQCop( int queued ) { |
37 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 38 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
38 | env << queued; | 39 | env << queued; |
39 | } | 40 | } |
40 | 41 | ||
41 | QString SMTPwrapper::mailsmtpError( int errnum ) { | 42 | QString SMTPwrapper::mailsmtpError( int errnum ) { |
42 | switch ( errnum ) { | 43 | switch ( errnum ) { |
43 | case MAILSMTP_NO_ERROR: | 44 | case MAILSMTP_NO_ERROR: |
44 | return tr( "No error" ); | 45 | return tr( "No error" ); |
45 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 46 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
46 | return tr( "Unexpected error code" ); | 47 | return tr( "Unexpected error code" ); |
47 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 48 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
48 | return tr( "Service not available" ); | 49 | return tr( "Service not available" ); |
49 | case MAILSMTP_ERROR_STREAM: | 50 | case MAILSMTP_ERROR_STREAM: |
50 | return tr( "Stream error" ); | 51 | return tr( "Stream error" ); |
51 | case MAILSMTP_ERROR_HOSTNAME: | 52 | case MAILSMTP_ERROR_HOSTNAME: |
52 | return tr( "gethostname() failed" ); | 53 | return tr( "gethostname() failed" ); |
53 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 54 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
54 | return tr( "Not implemented" ); | 55 | return tr( "Not implemented" ); |
55 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 56 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
56 | return tr( "Error, action not taken" ); | 57 | return tr( "Error, action not taken" ); |
57 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 58 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
58 | return tr( "Data exceeds storage allocation" ); | 59 | return tr( "Data exceeds storage allocation" ); |
59 | case MAILSMTP_ERROR_IN_PROCESSING: | 60 | case MAILSMTP_ERROR_IN_PROCESSING: |
60 | return tr( "Error in processing" ); | 61 | return tr( "Error in processing" ); |
61 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: | 62 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: |
62 | return tr( "Starttls not supported" ); | 63 | return tr( "Starttls not supported" ); |
63 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 64 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
64 | // return tr( "Insufficient system storage" ); | 65 | // return tr( "Insufficient system storage" ); |
65 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 66 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
66 | return tr( "Mailbox unavailable" ); | 67 | return tr( "Mailbox unavailable" ); |
67 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 68 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
68 | return tr( "Mailbox name not allowed" ); | 69 | return tr( "Mailbox name not allowed" ); |
69 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 70 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
70 | return tr( "Bad command sequence" ); | 71 | return tr( "Bad command sequence" ); |
71 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 72 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |
72 | return tr( "User not local" ); | 73 | return tr( "User not local" ); |
73 | case MAILSMTP_ERROR_TRANSACTION_FAILED: | 74 | case MAILSMTP_ERROR_TRANSACTION_FAILED: |
74 | return tr( "Transaction failed" ); | 75 | return tr( "Transaction failed" ); |
75 | case MAILSMTP_ERROR_MEMORY: | 76 | case MAILSMTP_ERROR_MEMORY: |
76 | return tr( "Memory error" ); | 77 | return tr( "Memory error" ); |
77 | case MAILSMTP_ERROR_CONNECTION_REFUSED: | 78 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
78 | return tr( "Connection refused" ); | 79 | return tr( "Connection refused" ); |
79 | default: | 80 | default: |
80 | return tr( "Unknown error code" ); | 81 | return tr( "Unknown error code" ); |
81 | } | 82 | } |
82 | } | 83 | } |
83 | 84 | ||
84 | 85 | ||
85 | void SMTPwrapper::progress( size_t current, size_t maximum ) { | 86 | void SMTPwrapper::progress( size_t current, size_t maximum ) { |
86 | if (SMTPwrapper::sendProgress) { | 87 | if (SMTPwrapper::sendProgress) { |
87 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 88 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
88 | qApp->processEvents(); | 89 | qApp->processEvents(); |
89 | } | 90 | } |
90 | } | 91 | } |
91 | 92 | ||
92 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { | 93 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { |
93 | if (!mail) | 94 | if (!mail) |
94 | return; | 95 | return; |
95 | QString localfolders = AbstractMail::defaultLocalfolder(); | 96 | QString localfolders = AbstractMail::defaultLocalfolder(); |
96 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 97 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
97 | wrap->createMbox(box); | 98 | wrap->createMbox(box); |
98 | wrap->storeMessage(mail,length,box); | 99 | wrap->storeMessage(mail,length,box); |
99 | delete wrap; | 100 | delete wrap; |
100 | } | 101 | } |
101 | 102 | ||
102 | void SMTPwrapper::smtpSend( mailmime *mail,bool later) { | 103 | void SMTPwrapper::smtpSend( mailmime *mail,bool later) { |
103 | clist *rcpts = 0; | 104 | clist *rcpts = 0; |
104 | char *from, *data; | 105 | char *from, *data; |
105 | size_t size; | 106 | size_t size; |
106 | 107 | ||
107 | from = data = 0; | 108 | from = data = 0; |
108 | 109 | ||
109 | mailmessage * msg = 0; | 110 | mailmessage * msg = 0; |
110 | msg = mime_message_init(mail); | 111 | msg = mime_message_init(mail); |
111 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 112 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
112 | int r = mailmessage_fetch(msg,&data,&size); | 113 | int r = mailmessage_fetch(msg,&data,&size); |
113 | mime_message_detach_mime(msg); | 114 | mime_message_detach_mime(msg); |
114 | mailmessage_free(msg); | 115 | mailmessage_free(msg); |
115 | if (r != MAIL_NO_ERROR || !data) { | 116 | if (r != MAIL_NO_ERROR || !data) { |
116 | if (data) | 117 | if (data) |
117 | free(data); | 118 | free(data); |
118 | odebug << "Error fetching mime..." << oendl; | 119 | odebug << "Error fetching mime..." << oendl; |
119 | return; | 120 | return; |
120 | } | 121 | } |
121 | msg = 0; | 122 | msg = 0; |
122 | if (later) { | 123 | if (later) { |
123 | storeMail(data,size,"Outgoing"); | 124 | storeMail(data,size,"Outgoing"); |
124 | if (data) | 125 | if (data) |
125 | free( data ); | 126 | free( data ); |
126 | Config cfg( "mail" ); | 127 | Config cfg( "mail" ); |
127 | cfg.setGroup( "Status" ); | 128 | cfg.setGroup( "Status" ); |
128 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 129 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
129 | emit queuedMails( m_queuedMail ); | 130 | emit queuedMails( m_queuedMail ); |
130 | return; | 131 | return; |
131 | } | 132 | } |
132 | from = getFrom( mail ); | 133 | from = getFrom( mail ); |
133 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 134 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
134 | smtpSend(from,rcpts,data,size); | 135 | smtpSend(from,rcpts,data,size); |
135 | if (data) { | 136 | if (data) { |
136 | free(data); | 137 | free(data); |
137 | } | 138 | } |
138 | if (from) { | 139 | if (from) { |
139 | free(from); | 140 | free(from); |
140 | } | 141 | } |
141 | if (rcpts) | 142 | if (rcpts) |
142 | smtp_address_list_free( rcpts ); | 143 | smtp_address_list_free( rcpts ); |
143 | } | 144 | } |
144 | 145 | ||
145 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) | 146 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) |
146 | { | 147 | { |
147 | if (data) { | 148 | if (data) { |
148 | storeMail(data,size,"Sendfailed"); | 149 | storeMail(data,size,"Sendfailed"); |
149 | } | 150 | } |
150 | if (failuremessage) { | 151 | if (failuremessage) { |
151 | QMessageBox::critical(0,tr("Error sending mail"), | 152 | QMessageBox::critical(0,tr("Error sending mail"), |
152 | tr("<center>%1</center>").arg(failuremessage)); | 153 | tr("<center>%1</center>").arg(failuremessage)); |
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
156 | int SMTPwrapper::start_smtp_tls() | 157 | int SMTPwrapper::start_smtp_tls() |
157 | { | 158 | { |
158 | if (!m_smtp) { | 159 | if (!m_smtp) { |
159 | return MAILSMTP_ERROR_IN_PROCESSING; | 160 | return MAILSMTP_ERROR_IN_PROCESSING; |
160 | } | 161 | } |
161 | int err = mailesmtp_starttls(m_smtp); | 162 | int err = mailesmtp_starttls(m_smtp); |
162 | if (err != MAILSMTP_NO_ERROR) return err; | 163 | if (err != MAILSMTP_NO_ERROR) return err; |
163 | mailstream_low * low; | 164 | mailstream_low * low; |
164 | mailstream_low * new_low; | 165 | mailstream_low * new_low; |
165 | low = mailstream_get_low(m_smtp->stream); | 166 | low = mailstream_get_low(m_smtp->stream); |
166 | if (!low) { | 167 | if (!low) { |
167 | return MAILSMTP_ERROR_IN_PROCESSING; | 168 | return MAILSMTP_ERROR_IN_PROCESSING; |
168 | } | 169 | } |
169 | int fd = mailstream_low_get_fd(low); | 170 | int fd = mailstream_low_get_fd(low); |
170 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 171 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
171 | mailstream_low_free(low); | 172 | mailstream_low_free(low); |
172 | mailstream_set_low(m_smtp->stream, new_low); | 173 | mailstream_set_low(m_smtp->stream, new_low); |
173 | } else { | 174 | } else { |
174 | return MAILSMTP_ERROR_IN_PROCESSING; | 175 | return MAILSMTP_ERROR_IN_PROCESSING; |
175 | } | 176 | } |
176 | return err; | 177 | return err; |
177 | } | 178 | } |
178 | 179 | ||
179 | void SMTPwrapper::connect_server() | 180 | void SMTPwrapper::connect_server() |
180 | { | 181 | { |
181 | const char *server, *user, *pass; | 182 | const char *server, *user, *pass; |
182 | bool ssl; | 183 | bool ssl; |
183 | uint16_t port; | 184 | uint16_t port; |
184 | ssl = false; | 185 | ssl = false; |
185 | bool try_tls = true; | 186 | bool try_tls = true; |
186 | bool force_tls=false; | 187 | bool force_tls=false; |
187 | server = user = pass = 0; | 188 | server = user = pass = 0; |
188 | QString failuretext = ""; | 189 | QString failuretext = ""; |
189 | 190 | ||
190 | if (m_smtp || !m_SmtpAccount) { | 191 | if (m_smtp || !m_SmtpAccount) { |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | server = m_SmtpAccount->getServer().latin1(); | 194 | server = m_SmtpAccount->getServer().latin1(); |
194 | if ( m_SmtpAccount->ConnectionType() == 2 ) { | 195 | if ( m_SmtpAccount->ConnectionType() == 2 ) { |
195 | ssl = true; | 196 | ssl = true; |
196 | try_tls = false; | 197 | try_tls = false; |
197 | } else if (m_SmtpAccount->ConnectionType() == 1) { | 198 | } else if (m_SmtpAccount->ConnectionType() == 1) { |
198 | force_tls = true; | 199 | force_tls = true; |
199 | } | 200 | } |
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 51383f6..7e14df3 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp | |||
@@ -1,90 +1,94 @@ | |||
1 | #include "statusmail.h" | 1 | #include "statusmail.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | ||
4 | |||
5 | using namespace Opie::Core; | ||
6 | |||
3 | StatusMail::StatusMail(QList<Account>&list) | 7 | StatusMail::StatusMail(QList<Account>&list) |
4 | { | 8 | { |
5 | currentImapStat.message_count=0; | 9 | currentImapStat.message_count=0; |
6 | currentImapStat.message_unseen=0; | 10 | currentImapStat.message_unseen=0; |
7 | currentImapStat.message_recent=0; | 11 | currentImapStat.message_recent=0; |
8 | lastPop3Stat = currentImapStat; | 12 | lastPop3Stat = currentImapStat; |
9 | currentPop3Stat = currentImapStat; | 13 | currentPop3Stat = currentImapStat; |
10 | connectionList.setAutoDelete(true); | 14 | connectionList.setAutoDelete(true); |
11 | connectionList.clear(); | 15 | connectionList.clear(); |
12 | initAccounts(list); | 16 | initAccounts(list); |
13 | } | 17 | } |
14 | 18 | ||
15 | StatusMail::~StatusMail() | 19 | StatusMail::~StatusMail() |
16 | { | 20 | { |
17 | } | 21 | } |
18 | 22 | ||
19 | void StatusMail::initAccounts(QList<Account>&accounts) | 23 | void StatusMail::initAccounts(QList<Account>&accounts) |
20 | { | 24 | { |
21 | 25 | ||
22 | Account *it; | 26 | Account *it; |
23 | folderStat currentStat; | 27 | folderStat currentStat; |
24 | AbstractMail * current = 0; | 28 | AbstractMail * current = 0; |
25 | currentPop3Stat.message_count=0; | 29 | currentPop3Stat.message_count=0; |
26 | currentPop3Stat.message_recent=0; | 30 | currentPop3Stat.message_recent=0; |
27 | currentPop3Stat.message_unseen=0; | 31 | currentPop3Stat.message_unseen=0; |
28 | for ( it = accounts.first(); it; it = accounts.next() ) { | 32 | for ( it = accounts.first(); it; it = accounts.next() ) { |
29 | if ( it->getType()==MAILLIB::A_IMAP && !it->getOffline() ) { | 33 | if ( it->getType()==MAILLIB::A_IMAP && !it->getOffline() ) { |
30 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); | 34 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); |
31 | current = AbstractMail::getWrapper(ima); | 35 | current = AbstractMail::getWrapper(ima); |
32 | connectionList.append(current); | 36 | connectionList.append(current); |
33 | current->statusFolder(currentStat); | 37 | current->statusFolder(currentStat); |
34 | currentImapStat.message_count+=currentStat.message_unseen; | 38 | currentImapStat.message_count+=currentStat.message_unseen; |
35 | currentImapStat.message_count+=currentStat.message_recent; | 39 | currentImapStat.message_count+=currentStat.message_recent; |
36 | currentImapStat.message_count+=currentStat.message_count; | 40 | currentImapStat.message_count+=currentStat.message_count; |
37 | } else if ( it->getType() == MAILLIB::A_POP3 && !it->getOffline() ) { | 41 | } else if ( it->getType() == MAILLIB::A_POP3 && !it->getOffline() ) { |
38 | POP3account *pop3 = static_cast<POP3account *>(it); | 42 | POP3account *pop3 = static_cast<POP3account *>(it); |
39 | current = AbstractMail::getWrapper(pop3); | 43 | current = AbstractMail::getWrapper(pop3); |
40 | connectionList.append(current); | 44 | connectionList.append(current); |
41 | current->statusFolder(currentStat); | 45 | current->statusFolder(currentStat); |
42 | currentPop3Stat.message_count+=currentStat.message_count; | 46 | currentPop3Stat.message_count+=currentStat.message_count; |
43 | } | 47 | } |
44 | current->logout(); | 48 | current->logout(); |
45 | } | 49 | } |
46 | odebug << "Pop3 init count: " << currentPop3Stat.message_count << "" << oendl; | 50 | odebug << "Pop3 init count: " << currentPop3Stat.message_count << "" << oendl; |
47 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | 51 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; |
48 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; | 52 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; |
49 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; | 53 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; |
50 | lastPop3Stat.message_count = currentPop3Stat.message_count; | 54 | lastPop3Stat.message_count = currentPop3Stat.message_count; |
51 | } | 55 | } |
52 | 56 | ||
53 | void StatusMail::reset_status() | 57 | void StatusMail::reset_status() |
54 | { | 58 | { |
55 | lastPop3Stat = currentPop3Stat; | 59 | lastPop3Stat = currentPop3Stat; |
56 | } | 60 | } |
57 | 61 | ||
58 | void StatusMail::check_current_stat(folderStat&targetStat) | 62 | void StatusMail::check_current_stat(folderStat&targetStat) |
59 | { | 63 | { |
60 | AbstractMail*it = 0; | 64 | AbstractMail*it = 0; |
61 | folderStat currentStat; | 65 | folderStat currentStat; |
62 | currentPop3Stat.message_recent = 0; | 66 | currentPop3Stat.message_recent = 0; |
63 | currentPop3Stat.message_count = 0; | 67 | currentPop3Stat.message_count = 0; |
64 | currentPop3Stat.message_unseen = 0; | 68 | currentPop3Stat.message_unseen = 0; |
65 | currentImapStat = currentPop3Stat; | 69 | currentImapStat = currentPop3Stat; |
66 | for ( it = connectionList.first(); it; it = connectionList.next() ) { | 70 | for ( it = connectionList.first(); it; it = connectionList.next() ) { |
67 | it->statusFolder(currentStat); | 71 | it->statusFolder(currentStat); |
68 | it->logout(); | 72 | it->logout(); |
69 | if (it->getType() == MAILLIB::A_IMAP) { | 73 | if (it->getType() == MAILLIB::A_IMAP) { |
70 | currentImapStat.message_unseen+=currentStat.message_unseen; | 74 | currentImapStat.message_unseen+=currentStat.message_unseen; |
71 | currentImapStat.message_recent+=currentStat.message_recent; | 75 | currentImapStat.message_recent+=currentStat.message_recent; |
72 | currentImapStat.message_count+=currentStat.message_count; | 76 | currentImapStat.message_count+=currentStat.message_count; |
73 | } else if (it->getType() == MAILLIB::A_POP3) { | 77 | } else if (it->getType() == MAILLIB::A_POP3) { |
74 | currentPop3Stat.message_count+=currentStat.message_count; | 78 | currentPop3Stat.message_count+=currentStat.message_count; |
75 | odebug << "Pop3 count: " << currentPop3Stat.message_count << "" << oendl; | 79 | odebug << "Pop3 count: " << currentPop3Stat.message_count << "" << oendl; |
76 | } | 80 | } |
77 | } | 81 | } |
78 | odebug << "Pop3 last: " << lastPop3Stat.message_count << "" << oendl; | 82 | odebug << "Pop3 last: " << lastPop3Stat.message_count << "" << oendl; |
79 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { | 83 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { |
80 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; | 84 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; |
81 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; | 85 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; |
82 | } else { | 86 | } else { |
83 | lastPop3Stat.message_count = currentPop3Stat.message_count; | 87 | lastPop3Stat.message_count = currentPop3Stat.message_count; |
84 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | 88 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; |
85 | } | 89 | } |
86 | targetStat = currentImapStat; | 90 | targetStat = currentImapStat; |
87 | targetStat.message_unseen+=currentPop3Stat.message_unseen; | 91 | targetStat.message_unseen+=currentPop3Stat.message_unseen; |
88 | targetStat.message_recent+=currentPop3Stat.message_recent; | 92 | targetStat.message_recent+=currentPop3Stat.message_recent; |
89 | targetStat.message_count+=currentPop3Stat.message_count; | 93 | targetStat.message_count+=currentPop3Stat.message_count; |
90 | } | 94 | } |
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp index 546d756..4add8a1 100644 --- a/noncore/net/mail/libmailwrapper/storemail.cpp +++ b/noncore/net/mail/libmailwrapper/storemail.cpp | |||
@@ -1,91 +1,91 @@ | |||
1 | #include "storemail.h" | 1 | #include "storemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | #include "settings.h" | 3 | #include "settings.h" |
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | 5 | ||
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | #include <opie2/odebug.h> | |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | 9 | ||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | 11 | ||
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
13 | Storemail::Storemail(Account*aAccount,const QString&aFolder) | 13 | Storemail::Storemail(Account*aAccount,const QString&aFolder) |
14 | : Generatemail() | 14 | : Generatemail() |
15 | { | 15 | { |
16 | wrapper = 0; | 16 | wrapper = 0; |
17 | m_Account = aAccount; | 17 | m_Account = aAccount; |
18 | m_tfolder = aFolder; | 18 | m_tfolder = aFolder; |
19 | wrapper = AbstractMail::getWrapper(m_Account); | 19 | wrapper = AbstractMail::getWrapper(m_Account); |
20 | if (wrapper) { | 20 | if (wrapper) { |
21 | wrapper->createMbox(m_tfolder); | 21 | wrapper->createMbox(m_tfolder); |
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | Storemail::Storemail(const QString&dir,const QString&aFolder) | 25 | Storemail::Storemail(const QString&dir,const QString&aFolder) |
26 | : Generatemail() | 26 | : Generatemail() |
27 | { | 27 | { |
28 | wrapper = 0; | 28 | wrapper = 0; |
29 | m_Account = 0; | 29 | m_Account = 0; |
30 | m_tfolder = aFolder; | 30 | m_tfolder = aFolder; |
31 | wrapper = AbstractMail::getWrapper(dir); | 31 | wrapper = AbstractMail::getWrapper(dir); |
32 | if (wrapper) { | 32 | if (wrapper) { |
33 | wrapper->createMbox(m_tfolder); | 33 | wrapper->createMbox(m_tfolder); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | Storemail::Storemail(const QString&aFolder) | 37 | Storemail::Storemail(const QString&aFolder) |
38 | : Generatemail() | 38 | : Generatemail() |
39 | { | 39 | { |
40 | wrapper = 0; | 40 | wrapper = 0; |
41 | m_Account = 0; | 41 | m_Account = 0; |
42 | m_tfolder = aFolder; | 42 | m_tfolder = aFolder; |
43 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); | 43 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); |
44 | if (wrapper) { | 44 | if (wrapper) { |
45 | wrapper->createMbox(m_tfolder); | 45 | wrapper->createMbox(m_tfolder); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | Storemail::~Storemail() | 49 | Storemail::~Storemail() |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) | 53 | int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) |
54 | { | 54 | { |
55 | if (!wrapper) return 0; | 55 | if (!wrapper) return 0; |
56 | int ret = 1; | 56 | int ret = 1; |
57 | 57 | ||
58 | mailmime * mimeMail = 0; | 58 | mailmime * mimeMail = 0; |
59 | mimeMail = createMimeMail(mail ); | 59 | mimeMail = createMimeMail(mail ); |
60 | if ( mimeMail == NULL ) { | 60 | if ( mimeMail == NULL ) { |
61 | odebug << "storeMail: error creating mime mail" << oendl; | 61 | odebug << "storeMail: error creating mime mail" << oendl; |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | char *data; | 64 | char *data; |
65 | size_t size; | 65 | size_t size; |
66 | data = 0; | 66 | data = 0; |
67 | 67 | ||
68 | mailmessage * msg = 0; | 68 | mailmessage * msg = 0; |
69 | msg = mime_message_init(mimeMail); | 69 | msg = mime_message_init(mimeMail); |
70 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 70 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
71 | int r = mailmessage_fetch(msg,&data,&size); | 71 | int r = mailmessage_fetch(msg,&data,&size); |
72 | mime_message_detach_mime(msg); | 72 | mime_message_detach_mime(msg); |
73 | mailmessage_free(msg); | 73 | mailmessage_free(msg); |
74 | msg = 0; | 74 | msg = 0; |
75 | if (r != MAIL_NO_ERROR || !data) { | 75 | if (r != MAIL_NO_ERROR || !data) { |
76 | odebug << "Error fetching mime..." << oendl; | 76 | odebug << "Error fetching mime..." << oendl; |
77 | ret = 0; | 77 | ret = 0; |
78 | } | 78 | } |
79 | 79 | ||
80 | if (ret) { | 80 | if (ret) { |
81 | wrapper->storeMessage(data,size,m_tfolder); | 81 | wrapper->storeMessage(data,size,m_tfolder); |
82 | } | 82 | } |
83 | 83 | ||
84 | if (data) { | 84 | if (data) { |
85 | free(data); | 85 | free(data); |
86 | } | 86 | } |
87 | if (mimeMail) { | 87 | if (mimeMail) { |
88 | mailmime_free( mimeMail ); | 88 | mailmime_free( mimeMail ); |
89 | } | 89 | } |
90 | return ret; | 90 | return ret; |
91 | } | 91 | } |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 4c87d64..979b73a 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,203 +1,205 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | ||
7 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
8 | 9 | ||
9 | #include "defines.h" | 10 | #include "defines.h" |
10 | #include "mainwindow.h" | 11 | #include "mainwindow.h" |
11 | 12 | ||
13 | using namespace Opie::Core; | ||
12 | 14 | ||
13 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
14 | : QMainWindow( parent, name, flags ) | 16 | : QMainWindow( parent, name, flags ) |
15 | { | 17 | { |
16 | 18 | ||
17 | setCaption( tr( "Mail" ) ); | 19 | setCaption( tr( "Mail" ) ); |
18 | setToolBarsMovable( false ); | 20 | setToolBarsMovable( false ); |
19 | 21 | ||
20 | toolBar = new QToolBar( this ); | 22 | toolBar = new QToolBar( this ); |
21 | menuBar = new QMenuBar( toolBar ); | 23 | menuBar = new QMenuBar( toolBar ); |
22 | mailMenu = new QPopupMenu( menuBar ); | 24 | mailMenu = new QPopupMenu( menuBar ); |
23 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 25 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
24 | settingsMenu = new QPopupMenu( menuBar ); | 26 | settingsMenu = new QPopupMenu( menuBar ); |
25 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 27 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
26 | 28 | ||
27 | addToolBar( toolBar ); | 29 | addToolBar( toolBar ); |
28 | toolBar->setHorizontalStretchable( true ); | 30 | toolBar->setHorizontalStretchable( true ); |
29 | 31 | ||
30 | QLabel *spacer = new QLabel( toolBar ); | 32 | QLabel *spacer = new QLabel( toolBar ); |
31 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 33 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
32 | toolBar->setStretchableWidget( spacer ); | 34 | toolBar->setStretchableWidget( spacer ); |
33 | 35 | ||
34 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 36 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
35 | 0, 0, this ); | 37 | 0, 0, this ); |
36 | composeMail->addTo( toolBar ); | 38 | composeMail->addTo( toolBar ); |
37 | composeMail->addTo( mailMenu ); | 39 | composeMail->addTo( mailMenu ); |
38 | 40 | ||
39 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 41 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
40 | 0, 0, this ); | 42 | 0, 0, this ); |
41 | sendQueued->addTo( toolBar ); | 43 | sendQueued->addTo( toolBar ); |
42 | sendQueued->addTo( mailMenu ); | 44 | sendQueued->addTo( mailMenu ); |
43 | 45 | ||
44 | /* | 46 | /* |
45 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 47 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
46 | 0, 0, this ); | 48 | 0, 0, this ); |
47 | syncFolders->addTo( toolBar ); | 49 | syncFolders->addTo( toolBar ); |
48 | syncFolders->addTo( mailMenu ); | 50 | syncFolders->addTo( mailMenu ); |
49 | */ | 51 | */ |
50 | 52 | ||
51 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 53 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
52 | 0, 0, this, 0, true ); | 54 | 0, 0, this, 0, true ); |
53 | showFolders->addTo( toolBar ); | 55 | showFolders->addTo( toolBar ); |
54 | showFolders->addTo( mailMenu ); | 56 | showFolders->addTo( mailMenu ); |
55 | showFolders->setOn( true ); | 57 | showFolders->setOn( true ); |
56 | connect(showFolders, SIGNAL( toggled(bool) ), | 58 | connect(showFolders, SIGNAL( toggled(bool) ), |
57 | SLOT( slotShowFolders(bool) ) ); | 59 | SLOT( slotShowFolders(bool) ) ); |
58 | 60 | ||
59 | /* | 61 | /* |
60 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), | 62 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), |
61 | 0, 0, this ); | 63 | 0, 0, this ); |
62 | searchMails->addTo( toolBar ); | 64 | searchMails->addTo( toolBar ); |
63 | searchMails->addTo( mailMenu ); | 65 | searchMails->addTo( mailMenu ); |
64 | */ | 66 | */ |
65 | 67 | ||
66 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); | 68 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); |
67 | deleteMails->addTo( toolBar ); | 69 | deleteMails->addTo( toolBar ); |
68 | deleteMails->addTo( mailMenu ); | 70 | deleteMails->addTo( mailMenu ); |
69 | connect( deleteMails, SIGNAL( activated() ), | 71 | connect( deleteMails, SIGNAL( activated() ), |
70 | SLOT( slotDeleteMail() ) ); | 72 | SLOT( slotDeleteMail() ) ); |
71 | 73 | ||
72 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , | 74 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , |
73 | 0, 0, this ); | 75 | 0, 0, this ); |
74 | editSettings->addTo( settingsMenu ); | 76 | editSettings->addTo( settingsMenu ); |
75 | connect( editSettings, SIGNAL( activated() ), | 77 | connect( editSettings, SIGNAL( activated() ), |
76 | SLOT( slotEditSettings() ) ); | 78 | SLOT( slotEditSettings() ) ); |
77 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , | 79 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , |
78 | 0, 0, this ); | 80 | 0, 0, this ); |
79 | editAccounts->addTo( settingsMenu ); | 81 | editAccounts->addTo( settingsMenu ); |
80 | 82 | ||
81 | //setCentralWidget( view ); | 83 | //setCentralWidget( view ); |
82 | 84 | ||
83 | QVBox* wrapperBox = new QVBox( this ); | 85 | QVBox* wrapperBox = new QVBox( this ); |
84 | setCentralWidget( wrapperBox ); | 86 | setCentralWidget( wrapperBox ); |
85 | 87 | ||
86 | QWidget *view = new QWidget( wrapperBox ); | 88 | QWidget *view = new QWidget( wrapperBox ); |
87 | 89 | ||
88 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 90 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
89 | 91 | ||
90 | folderView = new AccountView( view ); | 92 | folderView = new AccountView( view ); |
91 | folderView->header()->hide(); | 93 | folderView->header()->hide(); |
92 | folderView->setRootIsDecorated( true ); | 94 | folderView->setRootIsDecorated( true ); |
93 | folderView->addColumn( tr( "Mailbox" ) ); | 95 | folderView->addColumn( tr( "Mailbox" ) ); |
94 | 96 | ||
95 | layout->addWidget( folderView ); | 97 | layout->addWidget( folderView ); |
96 | 98 | ||
97 | mailView = new QListView( view ); | 99 | mailView = new QListView( view ); |
98 | mailView->addColumn( tr( "" ) ); | 100 | mailView->addColumn( tr( "" ) ); |
99 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 101 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
100 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 102 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
101 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 103 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
102 | mailView->addColumn( tr( "Date" )); | 104 | mailView->addColumn( tr( "Date" )); |
103 | mailView->setAllColumnsShowFocus(true); | 105 | mailView->setAllColumnsShowFocus(true); |
104 | mailView->setSorting(-1); | 106 | mailView->setSorting(-1); |
105 | 107 | ||
106 | statusWidget = new StatusWidget( wrapperBox ); | 108 | statusWidget = new StatusWidget( wrapperBox ); |
107 | statusWidget->hide(); | 109 | statusWidget->hide(); |
108 | 110 | ||
109 | layout->addWidget( mailView ); | 111 | layout->addWidget( mailView ); |
110 | layout->setStretchFactor( folderView, 1 ); | 112 | layout->setStretchFactor( folderView, 1 ); |
111 | layout->setStretchFactor( mailView, 2 ); | 113 | layout->setStretchFactor( mailView, 2 ); |
112 | 114 | ||
113 | slotAdjustLayout(); | 115 | slotAdjustLayout(); |
114 | 116 | ||
115 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 117 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
116 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 118 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
117 | 119 | ||
118 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, | 120 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, |
119 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); | 121 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); |
120 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 122 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
121 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 123 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
122 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 124 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
123 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 125 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
124 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 126 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
125 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 127 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
126 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 128 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
127 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 129 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
128 | // Added by Stefan Eilers to allow starting by addressbook.. | 130 | // Added by Stefan Eilers to allow starting by addressbook.. |
129 | // copied from old mail2 | 131 | // copied from old mail2 |
130 | #if !defined(QT_NO_COP) | 132 | #if !defined(QT_NO_COP) |
131 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 133 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
132 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 134 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
133 | #endif | 135 | #endif |
134 | 136 | ||
135 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 137 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
136 | } | 138 | } |
137 | 139 | ||
138 | MainWindow::~MainWindow() | 140 | MainWindow::~MainWindow() |
139 | { | 141 | { |
140 | } | 142 | } |
141 | 143 | ||
142 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 144 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
143 | { | 145 | { |
144 | odebug << "appMessage not reached" << oendl; | 146 | odebug << "appMessage not reached" << oendl; |
145 | } | 147 | } |
146 | 148 | ||
147 | void MainWindow::slotAdjustLayout() { | 149 | void MainWindow::slotAdjustLayout() { |
148 | 150 | ||
149 | QWidget *d = QApplication::desktop(); | 151 | QWidget *d = QApplication::desktop(); |
150 | 152 | ||
151 | if ( d->width() < d->height() ) { | 153 | if ( d->width() < d->height() ) { |
152 | layout->setDirection( QBoxLayout::TopToBottom ); | 154 | layout->setDirection( QBoxLayout::TopToBottom ); |
153 | } else { | 155 | } else { |
154 | layout->setDirection( QBoxLayout::LeftToRight ); | 156 | layout->setDirection( QBoxLayout::LeftToRight ); |
155 | } | 157 | } |
156 | } | 158 | } |
157 | 159 | ||
158 | void MainWindow::slotAdjustColumns() | 160 | void MainWindow::slotAdjustColumns() |
159 | { | 161 | { |
160 | bool hidden = folderView->isHidden(); | 162 | bool hidden = folderView->isHidden(); |
161 | if ( hidden ) folderView->show(); | 163 | if ( hidden ) folderView->show(); |
162 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 164 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
163 | if ( hidden ) folderView->hide(); | 165 | if ( hidden ) folderView->hide(); |
164 | 166 | ||
165 | mailView->setColumnWidth( 0, 10 ); | 167 | mailView->setColumnWidth( 0, 10 ); |
166 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 168 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
167 | mailView->setColumnWidth( 2, 80 ); | 169 | mailView->setColumnWidth( 2, 80 ); |
168 | mailView->setColumnWidth( 3, 50 ); | 170 | mailView->setColumnWidth( 3, 50 ); |
169 | mailView->setColumnWidth( 4, 50 ); | 171 | mailView->setColumnWidth( 4, 50 ); |
170 | } | 172 | } |
171 | 173 | ||
172 | void MainWindow::slotEditSettings() | 174 | void MainWindow::slotEditSettings() |
173 | { | 175 | { |
174 | } | 176 | } |
175 | 177 | ||
176 | void MainWindow::slotShowFolders( bool ) | 178 | void MainWindow::slotShowFolders( bool ) |
177 | { | 179 | { |
178 | odebug << "slotShowFolders not reached" << oendl; | 180 | odebug << "slotShowFolders not reached" << oendl; |
179 | } | 181 | } |
180 | 182 | ||
181 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 183 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
182 | { | 184 | { |
183 | odebug << "refreshMailView not reached" << oendl; | 185 | odebug << "refreshMailView not reached" << oendl; |
184 | } | 186 | } |
185 | 187 | ||
186 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) | 188 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) |
187 | { | 189 | { |
188 | odebug << "mailLeftClicked not reached" << oendl; | 190 | odebug << "mailLeftClicked not reached" << oendl; |
189 | } | 191 | } |
190 | 192 | ||
191 | void MainWindow::displayMail() | 193 | void MainWindow::displayMail() |
192 | { | 194 | { |
193 | odebug << "displayMail not reached" << oendl; | 195 | odebug << "displayMail not reached" << oendl; |
194 | } | 196 | } |
195 | 197 | ||
196 | void MainWindow::slotDeleteMail() | 198 | void MainWindow::slotDeleteMail() |
197 | { | 199 | { |
198 | odebug << "deleteMail not reached" << oendl; | 200 | odebug << "deleteMail not reached" << oendl; |
199 | } | 201 | } |
200 | 202 | ||
201 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 203 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
202 | { | 204 | { |
203 | odebug << "mailHold not reached" << oendl; | 205 | odebug << "mailHold not reached" << oendl; |
diff --git a/noncore/net/mail/nntpgroups.cpp b/noncore/net/mail/nntpgroups.cpp index 3243ee3..d81d8b1 100644 --- a/noncore/net/mail/nntpgroups.cpp +++ b/noncore/net/mail/nntpgroups.cpp | |||
@@ -1,62 +1,64 @@ | |||
1 | #include "nntpgroups.h" | 1 | #include "nntpgroups.h" |
2 | 2 | ||
3 | #include <libmailwrapper/settings.h> | 3 | #include <libmailwrapper/settings.h> |
4 | 4 | #include <opie2/odebug.h> | |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | #include <qlineedit.h> | 6 | #include <qlineedit.h> |
7 | 7 | ||
8 | using namespace Opie::Core; | ||
9 | |||
8 | NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl) | 10 | NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl) |
9 | : NNTPGroupsUI(parent,name,fl),subscribedGroups() | 11 | : NNTPGroupsUI(parent,name,fl),subscribedGroups() |
10 | { | 12 | { |
11 | m_Account = account; | 13 | m_Account = account; |
12 | fillGroups(); | 14 | fillGroups(); |
13 | } | 15 | } |
14 | 16 | ||
15 | NNTPGroups::~NNTPGroups() | 17 | NNTPGroups::~NNTPGroups() |
16 | { | 18 | { |
17 | 19 | ||
18 | } | 20 | } |
19 | 21 | ||
20 | void NNTPGroups::slotGetNG() | 22 | void NNTPGroups::slotGetNG() |
21 | { | 23 | { |
22 | if (!m_Account) return; | 24 | if (!m_Account) return; |
23 | GroupListView->clear(); | 25 | GroupListView->clear(); |
24 | NNTPwrapper tmp( m_Account ); | 26 | NNTPwrapper tmp( m_Account ); |
25 | QString filter = Groupfilteredit->text(); | 27 | QString filter = Groupfilteredit->text(); |
26 | QStringList list = tmp.listAllNewsgroups(filter); | 28 | QStringList list = tmp.listAllNewsgroups(filter); |
27 | subscribedGroupsNotListed = subscribedGroups; | 29 | subscribedGroupsNotListed = subscribedGroups; |
28 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 30 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
29 | QCheckListItem *item; | 31 | QCheckListItem *item; |
30 | item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); | 32 | item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); |
31 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 33 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
32 | item->setOn( true ); | 34 | item->setOn( true ); |
33 | subscribedGroupsNotListed.remove((*it)); | 35 | subscribedGroupsNotListed.remove((*it)); |
34 | } | 36 | } |
35 | } | 37 | } |
36 | } | 38 | } |
37 | 39 | ||
38 | void NNTPGroups::fillGroups() | 40 | void NNTPGroups::fillGroups() |
39 | { | 41 | { |
40 | if (!m_Account) return; | 42 | if (!m_Account) return; |
41 | subscribedGroups = m_Account->getGroups(); | 43 | subscribedGroups = m_Account->getGroups(); |
42 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 44 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
43 | QCheckListItem *item; | 45 | QCheckListItem *item; |
44 | item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); | 46 | item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); |
45 | item->setOn( true ); | 47 | item->setOn( true ); |
46 | } | 48 | } |
47 | } | 49 | } |
48 | 50 | ||
49 | void NNTPGroups::storeValues() | 51 | void NNTPGroups::storeValues() |
50 | { | 52 | { |
51 | if (!m_Account) return; | 53 | if (!m_Account) return; |
52 | QListViewItemIterator list_it( GroupListView ); | 54 | QListViewItemIterator list_it( GroupListView ); |
53 | subscribedGroups.clear(); | 55 | subscribedGroups.clear(); |
54 | for ( ; list_it.current(); ++list_it ) { | 56 | for ( ; list_it.current(); ++list_it ) { |
55 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | 57 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { |
56 | odebug << list_it.current()->text(0) << oendl; | 58 | odebug << list_it.current()->text(0) << oendl; |
57 | subscribedGroups.append( list_it.current()->text(0) ); | 59 | subscribedGroups.append( list_it.current()->text(0) ); |
58 | } | 60 | } |
59 | } | 61 | } |
60 | subscribedGroups+=subscribedGroupsNotListed; | 62 | subscribedGroups+=subscribedGroupsNotListed; |
61 | m_Account->setGroups( subscribedGroups ); | 63 | m_Account->setGroups( subscribedGroups ); |
62 | } | 64 | } |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 0669b5a..5399c3c 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -1,211 +1,214 @@ | |||
1 | 1 | ||
2 | #include "settingsdialog.h" | 2 | #include "settingsdialog.h" |
3 | #include "opiemail.h" | 3 | #include "opiemail.h" |
4 | #include "editaccounts.h" | 4 | #include "editaccounts.h" |
5 | #include "composemail.h" | 5 | #include "composemail.h" |
6 | #include "mailistviewitem.h" | 6 | #include "mailistviewitem.h" |
7 | #include "viewmail.h" | 7 | #include "viewmail.h" |
8 | #include "selectstore.h" | 8 | #include "selectstore.h" |
9 | #include "selectsmtp.h" | 9 | #include "selectsmtp.h" |
10 | 10 | ||
11 | /* OPIE */ | ||
12 | #include <libmailwrapper/smtpwrapper.h> | 11 | #include <libmailwrapper/smtpwrapper.h> |
13 | #include <libmailwrapper/mailtypes.h> | 12 | #include <libmailwrapper/mailtypes.h> |
14 | #include <libmailwrapper/abstractmail.h> | 13 | #include <libmailwrapper/abstractmail.h> |
14 | /* OPIE */ | ||
15 | #include <opie2/odebug.h> | ||
15 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
16 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
17 | 18 | ||
18 | /* QT */ | 19 | /* QT */ |
19 | 20 | ||
21 | using namespace Opie::Core; | ||
22 | |||
20 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 23 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) |
21 | : MainWindow( parent, name, WStyle_ContextHelp ) | 24 | : MainWindow( parent, name, WStyle_ContextHelp ) |
22 | { | 25 | { |
23 | settings = new Settings(); | 26 | settings = new Settings(); |
24 | 27 | ||
25 | folderView->populate( settings->getAccounts() ); | 28 | folderView->populate( settings->getAccounts() ); |
26 | } | 29 | } |
27 | 30 | ||
28 | OpieMail::~OpieMail() | 31 | OpieMail::~OpieMail() |
29 | { | 32 | { |
30 | if (settings) delete settings; | 33 | if (settings) delete settings; |
31 | } | 34 | } |
32 | 35 | ||
33 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 36 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
34 | { | 37 | { |
35 | // copied from old mail2 | 38 | // copied from old mail2 |
36 | if (msg == "writeMail(QString,QString)") | 39 | if (msg == "writeMail(QString,QString)") |
37 | { | 40 | { |
38 | QDataStream stream(data,IO_ReadOnly); | 41 | QDataStream stream(data,IO_ReadOnly); |
39 | QString name, email; | 42 | QString name, email; |
40 | stream >> name >> email; | 43 | stream >> name >> email; |
41 | // removing the whitespaces at beginning and end is needed! | 44 | // removing the whitespaces at beginning and end is needed! |
42 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 45 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
43 | } | 46 | } |
44 | else if (msg == "newMail()") | 47 | else if (msg == "newMail()") |
45 | { | 48 | { |
46 | slotComposeMail(); | 49 | slotComposeMail(); |
47 | } | 50 | } |
48 | } | 51 | } |
49 | 52 | ||
50 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 53 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
51 | { | 54 | { |
52 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 55 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
53 | if (!email.isEmpty()) | 56 | if (!email.isEmpty()) |
54 | { | 57 | { |
55 | if (!name.isEmpty()) | 58 | if (!name.isEmpty()) |
56 | { | 59 | { |
57 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 60 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
58 | } | 61 | } |
59 | else | 62 | else |
60 | { | 63 | { |
61 | compose.setTo(email); | 64 | compose.setTo(email); |
62 | } | 65 | } |
63 | } | 66 | } |
64 | compose.slotAdjustColumns(); | 67 | compose.slotAdjustColumns(); |
65 | QPEApplication::execDialog( &compose ); | 68 | QPEApplication::execDialog( &compose ); |
66 | } | 69 | } |
67 | 70 | ||
68 | void OpieMail::slotComposeMail() | 71 | void OpieMail::slotComposeMail() |
69 | { | 72 | { |
70 | odebug << "Compose Mail" << oendl; | 73 | odebug << "Compose Mail" << oendl; |
71 | slotwriteMail(0l,0l); | 74 | slotwriteMail(0l,0l); |
72 | } | 75 | } |
73 | 76 | ||
74 | void OpieMail::slotSendQueued() | 77 | void OpieMail::slotSendQueued() |
75 | { | 78 | { |
76 | odebug << "Send Queued" << oendl; | 79 | odebug << "Send Queued" << oendl; |
77 | SMTPaccount *smtp = 0; | 80 | SMTPaccount *smtp = 0; |
78 | 81 | ||
79 | QList<Account> list = settings->getAccounts(); | 82 | QList<Account> list = settings->getAccounts(); |
80 | QList<SMTPaccount> smtpList; | 83 | QList<SMTPaccount> smtpList; |
81 | smtpList.setAutoDelete(false); | 84 | smtpList.setAutoDelete(false); |
82 | Account *it; | 85 | Account *it; |
83 | for ( it = list.first(); it; it = list.next() ) | 86 | for ( it = list.first(); it; it = list.next() ) |
84 | { | 87 | { |
85 | if ( it->getType() == MAILLIB::A_SMTP ) | 88 | if ( it->getType() == MAILLIB::A_SMTP ) |
86 | { | 89 | { |
87 | smtp = static_cast<SMTPaccount *>(it); | 90 | smtp = static_cast<SMTPaccount *>(it); |
88 | smtpList.append(smtp); | 91 | smtpList.append(smtp); |
89 | } | 92 | } |
90 | } | 93 | } |
91 | if (smtpList.count()==0) | 94 | if (smtpList.count()==0) |
92 | { | 95 | { |
93 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 96 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
94 | return; | 97 | return; |
95 | } | 98 | } |
96 | if (smtpList.count()==1) | 99 | if (smtpList.count()==1) |
97 | { | 100 | { |
98 | smtp = smtpList.at(0); | 101 | smtp = smtpList.at(0); |
99 | } | 102 | } |
100 | else | 103 | else |
101 | { | 104 | { |
102 | smtp = 0; | 105 | smtp = 0; |
103 | selectsmtp selsmtp; | 106 | selectsmtp selsmtp; |
104 | selsmtp.setSelectionlist(&smtpList); | 107 | selsmtp.setSelectionlist(&smtpList); |
105 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 108 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
106 | { | 109 | { |
107 | smtp = selsmtp.selected_smtp(); | 110 | smtp = selsmtp.selected_smtp(); |
108 | } | 111 | } |
109 | } | 112 | } |
110 | if (smtp) | 113 | if (smtp) |
111 | { | 114 | { |
112 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 115 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
113 | if ( wrap->flushOutbox() ) | 116 | if ( wrap->flushOutbox() ) |
114 | { | 117 | { |
115 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 118 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
116 | } | 119 | } |
117 | delete wrap; | 120 | delete wrap; |
118 | } | 121 | } |
119 | } | 122 | } |
120 | 123 | ||
121 | void OpieMail::slotSearchMails() | 124 | void OpieMail::slotSearchMails() |
122 | { | 125 | { |
123 | odebug << "Search Mails" << oendl; | 126 | odebug << "Search Mails" << oendl; |
124 | } | 127 | } |
125 | 128 | ||
126 | void OpieMail::slotEditSettings() | 129 | void OpieMail::slotEditSettings() |
127 | { | 130 | { |
128 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 131 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
129 | QPEApplication::execDialog( &settingsDialog ); | 132 | QPEApplication::execDialog( &settingsDialog ); |
130 | } | 133 | } |
131 | 134 | ||
132 | void OpieMail::slotEditAccounts() | 135 | void OpieMail::slotEditAccounts() |
133 | { | 136 | { |
134 | odebug << "Edit Accounts" << oendl; | 137 | odebug << "Edit Accounts" << oendl; |
135 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 138 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
136 | eaDialog.slotAdjustColumns(); | 139 | eaDialog.slotAdjustColumns(); |
137 | QPEApplication::execDialog( &eaDialog ); | 140 | QPEApplication::execDialog( &eaDialog ); |
138 | if ( settings ) delete settings; | 141 | if ( settings ) delete settings; |
139 | settings = new Settings(); | 142 | settings = new Settings(); |
140 | 143 | ||
141 | folderView->populate( settings->getAccounts() ); | 144 | folderView->populate( settings->getAccounts() ); |
142 | } | 145 | } |
143 | 146 | ||
144 | void OpieMail::displayMail() | 147 | void OpieMail::displayMail() |
145 | { | 148 | { |
146 | QListViewItem*item = mailView->currentItem(); | 149 | QListViewItem*item = mailView->currentItem(); |
147 | if (!item) return; | 150 | if (!item) return; |
148 | RecMailP mail = ((MailListViewItem*)item)->data(); | 151 | RecMailP mail = ((MailListViewItem*)item)->data(); |
149 | RecBodyP body = folderView->fetchBody(mail); | 152 | RecBodyP body = folderView->fetchBody(mail); |
150 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 153 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
151 | readMail.setBody( body ); | 154 | readMail.setBody( body ); |
152 | readMail.setMail( mail ); | 155 | readMail.setMail( mail ); |
153 | readMail.showMaximized(); | 156 | readMail.showMaximized(); |
154 | readMail.exec(); | 157 | readMail.exec(); |
155 | 158 | ||
156 | if ( readMail.deleted ) | 159 | if ( readMail.deleted ) |
157 | { | 160 | { |
158 | folderView->refreshCurrent(); | 161 | folderView->refreshCurrent(); |
159 | } | 162 | } |
160 | else | 163 | else |
161 | { | 164 | { |
162 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 165 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
163 | } | 166 | } |
164 | } | 167 | } |
165 | 168 | ||
166 | void OpieMail::slotDeleteMail() | 169 | void OpieMail::slotDeleteMail() |
167 | { | 170 | { |
168 | if (!mailView->currentItem()) return; | 171 | if (!mailView->currentItem()) return; |
169 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 172 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
170 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 173 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
171 | { | 174 | { |
172 | mail->Wrapper()->deleteMail( mail ); | 175 | mail->Wrapper()->deleteMail( mail ); |
173 | folderView->refreshCurrent(); | 176 | folderView->refreshCurrent(); |
174 | } | 177 | } |
175 | } | 178 | } |
176 | 179 | ||
177 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 180 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
178 | { | 181 | { |
179 | if (!mailView->currentItem()) return; | 182 | if (!mailView->currentItem()) return; |
180 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 183 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
181 | /* just the RIGHT button - or hold on pda */ | 184 | /* just the RIGHT button - or hold on pda */ |
182 | if (button!=2) {return;} | 185 | if (button!=2) {return;} |
183 | odebug << "Event right/hold" << oendl; | 186 | odebug << "Event right/hold" << oendl; |
184 | if (!item) return; | 187 | if (!item) return; |
185 | QPopupMenu *m = new QPopupMenu(0); | 188 | QPopupMenu *m = new QPopupMenu(0); |
186 | if (m) | 189 | if (m) |
187 | { | 190 | { |
188 | if (mailtype==MAILLIB::A_NNTP) { | 191 | if (mailtype==MAILLIB::A_NNTP) { |
189 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 192 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
190 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 193 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
191 | } else { | 194 | } else { |
192 | if (folderView->currentisDraft()) { | 195 | if (folderView->currentisDraft()) { |
193 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 196 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
194 | } | 197 | } |
195 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 198 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
196 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 199 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
197 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 200 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); |
198 | } | 201 | } |
199 | m->setFocus(); | 202 | m->setFocus(); |
200 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 203 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
201 | delete m; | 204 | delete m; |
202 | } | 205 | } |
203 | } | 206 | } |
204 | 207 | ||
205 | void OpieMail::slotShowFolders( bool show ) | 208 | void OpieMail::slotShowFolders( bool show ) |
206 | { | 209 | { |
207 | odebug << "Show Folders" << oendl; | 210 | odebug << "Show Folders" << oendl; |
208 | if ( show && folderView->isHidden() ) | 211 | if ( show && folderView->isHidden() ) |
209 | { | 212 | { |
210 | odebug << "-> showing" << oendl; | 213 | odebug << "-> showing" << oendl; |
211 | folderView->show(); | 214 | folderView->show(); |
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp index cac9048..2fc1d01 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.cpp +++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp | |||
@@ -1,145 +1,145 @@ | |||
1 | #include <qpainter.h> | 1 | #include <qpainter.h> |
2 | #include <qtimer.h> | 2 | #include <qtimer.h> |
3 | 3 | ||
4 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
5 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/applnk.h> | 7 | #include <qpe/applnk.h> |
8 | 8 | #include <opie2/odebug.h> | |
9 | #include <opie2/odevice.h> | 9 | #include <opie2/odevice.h> |
10 | 10 | ||
11 | #include <libmailwrapper/settings.h> | 11 | #include <libmailwrapper/settings.h> |
12 | 12 | ||
13 | #include "mailapplet.h" | 13 | #include "mailapplet.h" |
14 | 14 | ||
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | ||
17 | MailApplet::MailApplet( QWidget *parent ) | 17 | MailApplet::MailApplet( QWidget *parent ) |
18 | : QWidget( parent ) { | 18 | : QWidget( parent ) { |
19 | 19 | ||
20 | m_config = new Config( "mail" ); | 20 | m_config = new Config( "mail" ); |
21 | m_config->setGroup( "Applet" ); | 21 | m_config->setGroup( "Applet" ); |
22 | 22 | ||
23 | setFixedWidth( AppLnk::smallIconSize() ); | 23 | setFixedWidth( AppLnk::smallIconSize() ); |
24 | setFixedHeight( AppLnk::smallIconSize() ); | 24 | setFixedHeight( AppLnk::smallIconSize() ); |
25 | 25 | ||
26 | hide(); | 26 | hide(); |
27 | 27 | ||
28 | m_newMails = 0; | 28 | m_newMails = 0; |
29 | m_statusMail = 0l; | 29 | m_statusMail = 0l; |
30 | 30 | ||
31 | if ( !m_config->readBoolEntry( "Disabled", false ) ) { | 31 | if ( !m_config->readBoolEntry( "Disabled", false ) ) { |
32 | // delay 5 sec until the whole mail backend gets started .-) | 32 | // delay 5 sec until the whole mail backend gets started .-) |
33 | QTimer::singleShot( 5000, this, SLOT( startup() ) ); | 33 | QTimer::singleShot( 5000, this, SLOT( startup() ) ); |
34 | } | 34 | } |
35 | repaint( true ); | 35 | repaint( true ); |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | MailApplet::~MailApplet() { | 39 | MailApplet::~MailApplet() { |
40 | if ( m_statusMail ) | 40 | if ( m_statusMail ) |
41 | delete m_statusMail; | 41 | delete m_statusMail; |
42 | if ( m_config ) | 42 | if ( m_config ) |
43 | delete m_config; | 43 | delete m_config; |
44 | } | 44 | } |
45 | 45 | ||
46 | void MailApplet::paintEvent( QPaintEvent* ) { | 46 | void MailApplet::paintEvent( QPaintEvent* ) { |
47 | QPainter p( this ); | 47 | QPainter p( this ); |
48 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); | 48 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); |
49 | QFont f( "vera", AppLnk::smallIconSize() ); | 49 | QFont f( "vera", AppLnk::smallIconSize() ); |
50 | QFontMetrics fm( f ); | 50 | QFontMetrics fm( f ); |
51 | p.setFont( f ); | 51 | p.setFont( f ); |
52 | p.setPen( Qt::blue ); | 52 | p.setPen( Qt::blue ); |
53 | p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); | 53 | p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); |
54 | return; | 54 | return; |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { | 58 | void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { |
59 | slotClicked(); | 59 | slotClicked(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void MailApplet::slotClicked() { | 62 | void MailApplet::slotClicked() { |
63 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 63 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
64 | e << QString( "opiemail" ); | 64 | e << QString( "opiemail" ); |
65 | 65 | ||
66 | ODevice *device = ODevice::inst(); | 66 | ODevice *device = ODevice::inst(); |
67 | if ( !device-> ledList().isEmpty() ) { | 67 | if ( !device-> ledList().isEmpty() ) { |
68 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 68 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
69 | 69 | ||
70 | device->setLedState( led, Led_Off ); | 70 | device->setLedState( led, Led_Off ); |
71 | } | 71 | } |
72 | 72 | ||
73 | if (m_statusMail) | 73 | if (m_statusMail) |
74 | m_statusMail->reset_status(); | 74 | m_statusMail->reset_status(); |
75 | 75 | ||
76 | hide(); | 76 | hide(); |
77 | } | 77 | } |
78 | 78 | ||
79 | void MailApplet::startup() { | 79 | void MailApplet::startup() { |
80 | Settings *settings = new Settings(); | 80 | Settings *settings = new Settings(); |
81 | QList<Account> ma = settings->getAccounts(); | 81 | QList<Account> ma = settings->getAccounts(); |
82 | m_statusMail = new StatusMail( ma ); | 82 | m_statusMail = new StatusMail( ma ); |
83 | delete settings; | 83 | delete settings; |
84 | 84 | ||
85 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | 85 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; |
86 | m_intervalTimer = new QTimer(); | 86 | m_intervalTimer = new QTimer(); |
87 | m_intervalTimer->start( m_intervalMs ); | 87 | m_intervalTimer->start( m_intervalMs ); |
88 | connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); | 88 | connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | void MailApplet::slotCheck() { | 91 | void MailApplet::slotCheck() { |
92 | // Check wether the check interval has been changed. | 92 | // Check wether the check interval has been changed. |
93 | int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | 93 | int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; |
94 | if ( newIntervalMs != m_intervalMs ) { | 94 | if ( newIntervalMs != m_intervalMs ) { |
95 | m_intervalTimer->changeInterval( newIntervalMs ); | 95 | m_intervalTimer->changeInterval( newIntervalMs ); |
96 | m_intervalMs = newIntervalMs; | 96 | m_intervalMs = newIntervalMs; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (m_statusMail == 0) { | 99 | if (m_statusMail == 0) { |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | folderStat stat; | 103 | folderStat stat; |
104 | m_statusMail->check_current_stat( stat ); | 104 | m_statusMail->check_current_stat( stat ); |
105 | int newMailsOld = m_newMails; | 105 | int newMailsOld = m_newMails; |
106 | m_newMails = stat.message_unseen; | 106 | m_newMails = stat.message_unseen; |
107 | odebug << QString( "test %1" ).arg( m_newMails ) << oendl; | 107 | odebug << QString( "test %1" ).arg( m_newMails ) << oendl; |
108 | if ( m_newMails > 0 && newMailsOld != m_newMails ) { | 108 | if ( m_newMails > 0 && newMailsOld != m_newMails ) { |
109 | ODevice *device = ODevice::inst(); | 109 | ODevice *device = ODevice::inst(); |
110 | if ( isHidden() ) | 110 | if ( isHidden() ) |
111 | show(); | 111 | show(); |
112 | if ( m_config->readBoolEntry( "BlinkLed", true ) ) { | 112 | if ( m_config->readBoolEntry( "BlinkLed", true ) ) { |
113 | if ( !device->ledList().isEmpty() ) { | 113 | if ( !device->ledList().isEmpty() ) { |
114 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 114 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
115 | device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); | 115 | device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | if ( m_config->readBoolEntry( "PlaySound", false ) ) | 118 | if ( m_config->readBoolEntry( "PlaySound", false ) ) |
119 | device->playAlarmSound(); | 119 | device->playAlarmSound(); |
120 | 120 | ||
121 | Config cfg( "mail" ); | 121 | Config cfg( "mail" ); |
122 | cfg.setGroup( "Status" ); | 122 | cfg.setGroup( "Status" ); |
123 | cfg.writeEntry( "newMails", m_newMails ); | 123 | cfg.writeEntry( "newMails", m_newMails ); |
124 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); | 124 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); |
125 | env << m_newMails; | 125 | env << m_newMails; |
126 | repaint( true ); | 126 | repaint( true ); |
127 | 127 | ||
128 | } else { | 128 | } else { |
129 | ODevice *device = ODevice::inst(); | 129 | ODevice *device = ODevice::inst(); |
130 | if ( !isHidden() ) | 130 | if ( !isHidden() ) |
131 | hide(); | 131 | hide(); |
132 | if ( !device->ledList().isEmpty() ) { | 132 | if ( !device->ledList().isEmpty() ) { |
133 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 133 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
134 | device->setLedState( led, Led_Off ); | 134 | device->setLedState( led, Led_Off ); |
135 | } | 135 | } |
136 | 136 | ||
137 | if ( newMailsOld != m_newMails ) { | 137 | if ( newMailsOld != m_newMails ) { |
138 | Config cfg( "mail" ); | 138 | Config cfg( "mail" ); |
139 | cfg.setGroup( "Status" ); | 139 | cfg.setGroup( "Status" ); |
140 | cfg.writeEntry( "newMails", m_newMails ); | 140 | cfg.writeEntry( "newMails", m_newMails ); |
141 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); | 141 | QCopEnvelope env( "QPE/Pim", "newMails(int)" ); |
142 | env << m_newMails; | 142 | env << m_newMails; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | } | 145 | } |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index a574ea1..7267bcb 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,213 +1,216 @@ | |||
1 | #include "composemail.h" | 1 | #include "composemail.h" |
2 | #include "viewmail.h" | 2 | #include "viewmail.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | 8 | ||
9 | #include <opie2/odebug.h> | ||
9 | #include <opie2/ofiledialog.h> | 10 | #include <opie2/ofiledialog.h> |
10 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
11 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
12 | 13 | ||
13 | /* QT */ | 14 | /* QT */ |
14 | #include <qtextbrowser.h> | 15 | #include <qtextbrowser.h> |
15 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
16 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
17 | #include <qaction.h> | 18 | #include <qaction.h> |
18 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
19 | #include <qfile.h> | 20 | #include <qfile.h> |
20 | 21 | ||
21 | using namespace Opie::Ui; | 22 | using namespace Opie::Ui; |
23 | using namespace Opie::Core; | ||
24 | |||
22 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 25 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
23 | const QString&fsize,int num,const QValueList<int>&path) | 26 | const QString&fsize,int num,const QValueList<int>&path) |
24 | : QListViewItem(parent,after),_partNum(num) | 27 | : QListViewItem(parent,after),_partNum(num) |
25 | { | 28 | { |
26 | _path=path; | 29 | _path=path; |
27 | setText(0, mime); | 30 | setText(0, mime); |
28 | setText(1, desc); | 31 | setText(1, desc); |
29 | setText(2, file); | 32 | setText(2, file); |
30 | setText(3, fsize); | 33 | setText(3, fsize); |
31 | } | 34 | } |
32 | 35 | ||
33 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 36 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
34 | const QString&fsize,int num,const QValueList<int>&path) | 37 | const QString&fsize,int num,const QValueList<int>&path) |
35 | : QListViewItem(parent,after),_partNum(num) | 38 | : QListViewItem(parent,after),_partNum(num) |
36 | { | 39 | { |
37 | _path=path; | 40 | _path=path; |
38 | setText(0, mime); | 41 | setText(0, mime); |
39 | setText(1, desc); | 42 | setText(1, desc); |
40 | setText(2, file); | 43 | setText(2, file); |
41 | setText(3, fsize); | 44 | setText(3, fsize); |
42 | } | 45 | } |
43 | 46 | ||
44 | bool AttachItem::isParentof(const QValueList<int>&path) | 47 | bool AttachItem::isParentof(const QValueList<int>&path) |
45 | { | 48 | { |
46 | /* if not set, then no parent */ | 49 | /* if not set, then no parent */ |
47 | if (path.count()==0||_path.count()==0) return false; | 50 | if (path.count()==0||_path.count()==0) return false; |
48 | /* the parent must have one digit less then a child */ | 51 | /* the parent must have one digit less then a child */ |
49 | if (path.count()!=_path.count()+1) return false; | 52 | if (path.count()!=_path.count()+1) return false; |
50 | for (unsigned int i=0; i < _path.count();++i) | 53 | for (unsigned int i=0; i < _path.count();++i) |
51 | { | 54 | { |
52 | if (_path[i]!=path[i]) return false; | 55 | if (_path[i]!=path[i]) return false; |
53 | } | 56 | } |
54 | return true; | 57 | return true; |
55 | } | 58 | } |
56 | 59 | ||
57 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 60 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
58 | { | 61 | { |
59 | QListViewItemIterator it( attachments ); | 62 | QListViewItemIterator it( attachments ); |
60 | for ( ; it.current(); ++it ) | 63 | for ( ; it.current(); ++it ) |
61 | { | 64 | { |
62 | AttachItem*ati = (AttachItem*)it.current(); | 65 | AttachItem*ati = (AttachItem*)it.current(); |
63 | if (ati->isParentof(path)) return ati; | 66 | if (ati->isParentof(path)) return ati; |
64 | } | 67 | } |
65 | return 0; | 68 | return 0; |
66 | } | 69 | } |
67 | 70 | ||
68 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 71 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
69 | { | 72 | { |
70 | if (!parent) return 0; | 73 | if (!parent) return 0; |
71 | AttachItem* item = (AttachItem*)parent->firstChild(); | 74 | AttachItem* item = (AttachItem*)parent->firstChild(); |
72 | if (!item) return item; | 75 | if (!item) return item; |
73 | AttachItem*temp=0; | 76 | AttachItem*temp=0; |
74 | while( (temp=(AttachItem*)item->nextSibling())) | 77 | while( (temp=(AttachItem*)item->nextSibling())) |
75 | { | 78 | { |
76 | item = temp; | 79 | item = temp; |
77 | } | 80 | } |
78 | return item; | 81 | return item; |
79 | } | 82 | } |
80 | 83 | ||
81 | void ViewMail::setBody(const RecBodyP&body ) | 84 | void ViewMail::setBody(const RecBodyP&body ) |
82 | { | 85 | { |
83 | 86 | ||
84 | m_body = body; | 87 | m_body = body; |
85 | m_mail[2] = body->Bodytext(); | 88 | m_mail[2] = body->Bodytext(); |
86 | attachbutton->setEnabled(body->Parts().count()>0); | 89 | attachbutton->setEnabled(body->Parts().count()>0); |
87 | attachments->setEnabled(body->Parts().count()>0); | 90 | attachments->setEnabled(body->Parts().count()>0); |
88 | if (body->Parts().count()==0) | 91 | if (body->Parts().count()==0) |
89 | { | 92 | { |
90 | return; | 93 | return; |
91 | } | 94 | } |
92 | AttachItem * curItem=0; | 95 | AttachItem * curItem=0; |
93 | AttachItem * parentItem = 0; | 96 | AttachItem * parentItem = 0; |
94 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 97 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
95 | QString desc,fsize; | 98 | QString desc,fsize; |
96 | double s = body->Description()->Size(); | 99 | double s = body->Description()->Size(); |
97 | int w; | 100 | int w; |
98 | w=0; | 101 | w=0; |
99 | 102 | ||
100 | while (s>1024) | 103 | while (s>1024) |
101 | { | 104 | { |
102 | s/=1024; | 105 | s/=1024; |
103 | ++w; | 106 | ++w; |
104 | if (w>=2) break; | 107 | if (w>=2) break; |
105 | } | 108 | } |
106 | 109 | ||
107 | QString q=""; | 110 | QString q=""; |
108 | switch(w) | 111 | switch(w) |
109 | { | 112 | { |
110 | case 1: | 113 | case 1: |
111 | q="k"; | 114 | q="k"; |
112 | break; | 115 | break; |
113 | case 2: | 116 | case 2: |
114 | q="M"; | 117 | q="M"; |
115 | break; | 118 | break; |
116 | default: | 119 | default: |
117 | break; | 120 | break; |
118 | } | 121 | } |
119 | 122 | ||
120 | { | 123 | { |
121 | /* I did not found a method to make a CONTENT reset on a QTextStream | 124 | /* I did not found a method to make a CONTENT reset on a QTextStream |
122 | so I use this construct that the stream will re-constructed in each | 125 | so I use this construct that the stream will re-constructed in each |
123 | loop. To let it work, the textstream is packed into a own area of | 126 | loop. To let it work, the textstream is packed into a own area of |
124 | code is it will be destructed after finishing its small job. | 127 | code is it will be destructed after finishing its small job. |
125 | */ | 128 | */ |
126 | QTextOStream o(&fsize); | 129 | QTextOStream o(&fsize); |
127 | if (w>0) o.precision(2); else o.precision(0); | 130 | if (w>0) o.precision(2); else o.precision(0); |
128 | o.setf(QTextStream::fixed); | 131 | o.setf(QTextStream::fixed); |
129 | o << s << " " << q << "Byte"; | 132 | o << s << " " << q << "Byte"; |
130 | } | 133 | } |
131 | 134 | ||
132 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 135 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
133 | QString filename = ""; | 136 | QString filename = ""; |
134 | 137 | ||
135 | for (unsigned int i = 0; i < body->Parts().count();++i) | 138 | for (unsigned int i = 0; i < body->Parts().count();++i) |
136 | { | 139 | { |
137 | filename = ""; | 140 | filename = ""; |
138 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 141 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
139 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 142 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
140 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 143 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
141 | { | 144 | { |
142 | odebug << it.key() << oendl; | 145 | odebug << it.key() << oendl; |
143 | if (it.key().lower()=="name") | 146 | if (it.key().lower()=="name") |
144 | { | 147 | { |
145 | filename=it.data(); | 148 | filename=it.data(); |
146 | } | 149 | } |
147 | } | 150 | } |
148 | s = body->Parts()[i]->Size(); | 151 | s = body->Parts()[i]->Size(); |
149 | w = 0; | 152 | w = 0; |
150 | while (s>1024) | 153 | while (s>1024) |
151 | { | 154 | { |
152 | s/=1024; | 155 | s/=1024; |
153 | ++w; | 156 | ++w; |
154 | if (w>=2) break; | 157 | if (w>=2) break; |
155 | } | 158 | } |
156 | switch(w) | 159 | switch(w) |
157 | { | 160 | { |
158 | case 1: | 161 | case 1: |
159 | q="k"; | 162 | q="k"; |
160 | break; | 163 | break; |
161 | case 2: | 164 | case 2: |
162 | q="M"; | 165 | q="M"; |
163 | break; | 166 | break; |
164 | default: | 167 | default: |
165 | q=""; | 168 | q=""; |
166 | break; | 169 | break; |
167 | } | 170 | } |
168 | QTextOStream o(&fsize); | 171 | QTextOStream o(&fsize); |
169 | if (w>0) o.precision(2); else o.precision(0); | 172 | if (w>0) o.precision(2); else o.precision(0); |
170 | o.setf(QTextStream::fixed); | 173 | o.setf(QTextStream::fixed); |
171 | o << s << " " << q << "Byte"; | 174 | o << s << " " << q << "Byte"; |
172 | desc = body->Parts()[i]->Description(); | 175 | desc = body->Parts()[i]->Description(); |
173 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 176 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
174 | if (parentItem) | 177 | if (parentItem) |
175 | { | 178 | { |
176 | AttachItem*temp = lastChild(parentItem); | 179 | AttachItem*temp = lastChild(parentItem); |
177 | if (temp) curItem = temp; | 180 | if (temp) curItem = temp; |
178 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 181 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
179 | attachments->setRootIsDecorated(true); | 182 | attachments->setRootIsDecorated(true); |
180 | curItem = parentItem; | 183 | curItem = parentItem; |
181 | } | 184 | } |
182 | else | 185 | else |
183 | { | 186 | { |
184 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 187 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
185 | } | 188 | } |
186 | } | 189 | } |
187 | } | 190 | } |
188 | 191 | ||
189 | 192 | ||
190 | void ViewMail::slotShowHtml( bool state ) | 193 | void ViewMail::slotShowHtml( bool state ) |
191 | { | 194 | { |
192 | m_showHtml = state; | 195 | m_showHtml = state; |
193 | setText(); | 196 | setText(); |
194 | } | 197 | } |
195 | 198 | ||
196 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 199 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
197 | { | 200 | { |
198 | if (!item ) | 201 | if (!item ) |
199 | return; | 202 | return; |
200 | 203 | ||
201 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 204 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
202 | { | 205 | { |
203 | setText(); | 206 | setText(); |
204 | return; | 207 | return; |
205 | } | 208 | } |
206 | QPopupMenu *menu = new QPopupMenu(); | 209 | QPopupMenu *menu = new QPopupMenu(); |
207 | int ret=0; | 210 | int ret=0; |
208 | 211 | ||
209 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 212 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
210 | { | 213 | { |
211 | menu->insertItem( tr( "Show Text" ), 1 ); | 214 | menu->insertItem( tr( "Show Text" ), 1 ); |
212 | } | 215 | } |
213 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 216 | menu->insertItem( tr( "Save Attachment" ), 0 ); |