-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 5 | ||||
-rw-r--r-- | kmicromail/accountitem.cpp | 97 | ||||
-rw-r--r-- | kmicromail/accountview.cpp | 9 | ||||
-rw-r--r-- | kmicromail/addresspicker.cpp | 6 | ||||
-rw-r--r-- | kmicromail/composemail.cpp | 66 | ||||
-rw-r--r-- | kmicromail/editaccounts.cpp | 45 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 22 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 58 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.cpp | 29 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.cpp | 59 | ||||
-rw-r--r-- | kmicromail/nntpgroupsdlg.cpp | 3 | ||||
-rw-r--r-- | kmicromail/selectsmtp.cpp | 5 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 23 | ||||
-rw-r--r-- | kmicromail/viewmailbase.cpp | 21 |
15 files changed, 240 insertions, 229 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 99e8618..d6df981 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -1,126 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | //#include <unistd.h> | 29 | #ifndef _WIN32_ |
30 | 30 | #include <unistd.h> | |
31 | #endif | ||
31 | #include <qdir.h> | 32 | #include <qdir.h> |
32 | #include <qfile.h> | 33 | #include <qfile.h> |
33 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
34 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 36 | #include <qregexp.h> |
36 | //US #include <qtimer.h> | 37 | //US #include <qtimer.h> |
37 | 38 | ||
38 | #include <kapplication.h> | 39 | #include <kapplication.h> |
39 | #include <kconfig.h> | 40 | #include <kconfig.h> |
40 | #include <kdebug.h> | 41 | #include <kdebug.h> |
41 | #include <klocale.h> | 42 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
45 | 46 | ||
46 | 47 | ||
47 | #include "resourceqtopiaconfig.h" | 48 | #include "resourceqtopiaconfig.h" |
48 | #include "stdaddressbook.h" | 49 | #include "stdaddressbook.h" |
49 | 50 | ||
50 | #include "qtopiaconverter.h" | 51 | #include "qtopiaconverter.h" |
51 | 52 | ||
52 | #include "resourceqtopia.h" | 53 | #include "resourceqtopia.h" |
53 | 54 | ||
54 | using namespace KABC; | 55 | using namespace KABC; |
55 | 56 | ||
56 | extern "C" | 57 | extern "C" |
57 | #ifdef _WIN32_ | 58 | #ifdef _WIN32_ |
58 | __declspec(dllexport) | 59 | __declspec(dllexport) |
59 | #else | 60 | #else |
60 | { | 61 | { |
61 | #endif | 62 | #endif |
62 | void *init_microkabc_qtopia() | 63 | void *init_microkabc_qtopia() |
63 | { | 64 | { |
64 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); | 65 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); |
65 | } | 66 | } |
66 | #ifndef _WIN32_ | 67 | #ifndef _WIN32_ |
67 | } | 68 | } |
68 | #endif | 69 | #endif |
69 | 70 | ||
70 | ResourceQtopia::ResourceQtopia( const KConfig *config ) | 71 | ResourceQtopia::ResourceQtopia( const KConfig *config ) |
71 | : Resource( config ), mConverter (0) | 72 | : Resource( config ), mConverter (0) |
72 | { | 73 | { |
73 | // we can not choose the filename. Therefore use the default to display | 74 | // we can not choose the filename. Therefore use the default to display |
74 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 75 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
75 | init( fileName ); | 76 | init( fileName ); |
76 | } | 77 | } |
77 | 78 | ||
78 | ResourceQtopia::ResourceQtopia( const QString &fileName ) | 79 | ResourceQtopia::ResourceQtopia( const QString &fileName ) |
79 | : Resource( 0 ) | 80 | : Resource( 0 ) |
80 | { | 81 | { |
81 | init( fileName ); | 82 | init( fileName ); |
82 | } | 83 | } |
83 | 84 | ||
84 | void ResourceQtopia::init( const QString &fileName ) | 85 | void ResourceQtopia::init( const QString &fileName ) |
85 | { | 86 | { |
86 | #ifdef _USE_DIRWATCH_ | 87 | #ifdef _USE_DIRWATCH_ |
87 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 88 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
88 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 89 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
89 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 90 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
90 | #endif | 91 | #endif |
91 | setFileName( fileName ); | 92 | setFileName( fileName ); |
92 | } | 93 | } |
93 | 94 | ||
94 | ResourceQtopia::~ResourceQtopia() | 95 | ResourceQtopia::~ResourceQtopia() |
95 | { | 96 | { |
96 | if (mConverter != 0) | 97 | if (mConverter != 0) |
97 | delete mConverter; | 98 | delete mConverter; |
98 | 99 | ||
99 | } | 100 | } |
100 | 101 | ||
101 | void ResourceQtopia::writeConfig( KConfig *config ) | 102 | void ResourceQtopia::writeConfig( KConfig *config ) |
102 | { | 103 | { |
103 | Resource::writeConfig( config ); | 104 | Resource::writeConfig( config ); |
104 | } | 105 | } |
105 | 106 | ||
106 | Ticket *ResourceQtopia::requestSaveTicket() | 107 | Ticket *ResourceQtopia::requestSaveTicket() |
107 | { | 108 | { |
108 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; | 109 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; |
109 | 110 | ||
110 | qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); | 111 | qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); |
111 | 112 | ||
112 | if ( !addressBook() ) return 0; | 113 | if ( !addressBook() ) return 0; |
113 | 114 | ||
114 | if ( !lock( fileName() ) ) { | 115 | if ( !lock( fileName() ) ) { |
115 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" | 116 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" |
116 | << fileName() << "'" << endl; | 117 | << fileName() << "'" << endl; |
117 | return 0; | 118 | return 0; |
118 | } | 119 | } |
119 | return createTicket( this ); | 120 | return createTicket( this ); |
120 | } | 121 | } |
121 | 122 | ||
122 | 123 | ||
123 | bool ResourceQtopia::doOpen() | 124 | bool ResourceQtopia::doOpen() |
124 | { | 125 | { |
125 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); | 126 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); |
126 | 127 | ||
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 49d86fc..567de87 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,1182 +1,1183 @@ | |||
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 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <kiconloader.h> | 17 | #include <kiconloader.h> |
18 | #include <klocale.h> | ||
18 | 19 | ||
19 | #define GET_NEW_MAILS 101 | 20 | #define GET_NEW_MAILS 101 |
20 | 21 | ||
21 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
22 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 23 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
23 | /** | 24 | /** |
24 | * POP3 Account stuff | 25 | * POP3 Account stuff |
25 | */ | 26 | */ |
26 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 27 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
27 | : AccountViewItem( parent ) | 28 | : AccountViewItem( parent ) |
28 | { | 29 | { |
29 | account = a; | 30 | account = a; |
30 | wrapper = AbstractMail::getWrapper( account ); | 31 | wrapper = AbstractMail::getWrapper( account ); |
31 | SETPIX(PIXMAP_POP3FOLDER); | 32 | SETPIX(PIXMAP_POP3FOLDER); |
32 | #if 0 | 33 | #if 0 |
33 | if (!account->getOffline()) | 34 | if (!account->getOffline()) |
34 | { | 35 | { |
35 | setPixmap( 0, ); | 36 | setPixmap( 0, ); |
36 | } | 37 | } |
37 | else | 38 | else |
38 | { | 39 | { |
39 | setPixmap( 0, PIXMAP_OFFLINE ); | 40 | setPixmap( 0, PIXMAP_OFFLINE ); |
40 | } | 41 | } |
41 | #endif | 42 | #endif |
42 | setText( 0, account->getAccountName() ); | 43 | setText( 0, account->getAccountName() ); |
43 | setOpen( true ); | 44 | setOpen( true ); |
44 | } | 45 | } |
45 | 46 | ||
46 | POP3viewItem::~POP3viewItem() | 47 | POP3viewItem::~POP3viewItem() |
47 | { | 48 | { |
48 | delete wrapper; | 49 | delete wrapper; |
49 | } | 50 | } |
50 | 51 | ||
51 | AbstractMail *POP3viewItem::getWrapper() | 52 | AbstractMail *POP3viewItem::getWrapper() |
52 | { | 53 | { |
53 | return wrapper; | 54 | return wrapper; |
54 | } | 55 | } |
55 | 56 | ||
56 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 57 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
57 | { | 58 | { |
58 | refresh(); | 59 | refresh(); |
59 | } | 60 | } |
60 | 61 | ||
61 | void POP3viewItem::refresh() | 62 | void POP3viewItem::refresh() |
62 | { | 63 | { |
63 | if (account->getOffline()) return; | 64 | if (account->getOffline()) return; |
64 | QValueList<FolderP> *folders = wrapper->listFolders(); | 65 | QValueList<FolderP> *folders = wrapper->listFolders(); |
65 | QListViewItem *child = firstChild(); | 66 | QListViewItem *child = firstChild(); |
66 | while ( child ) | 67 | while ( child ) |
67 | { | 68 | { |
68 | QListViewItem *tmp = child; | 69 | QListViewItem *tmp = child; |
69 | child = child->nextSibling(); | 70 | child = child->nextSibling(); |
70 | delete tmp; | 71 | delete tmp; |
71 | } | 72 | } |
72 | QValueList<FolderP>::ConstIterator it; | 73 | QValueList<FolderP>::ConstIterator it; |
73 | QListViewItem*item = 0; | 74 | QListViewItem*item = 0; |
74 | for ( it = folders->begin(); it!=folders->end(); ++it) | 75 | for ( it = folders->begin(); it!=folders->end(); ++it) |
75 | { | 76 | { |
76 | item = new POP3folderItem( (*it), this , item ); | 77 | item = new POP3folderItem( (*it), this , item ); |
77 | item->setSelectable( (*it)->may_select()); | 78 | item->setSelectable( (*it)->may_select()); |
78 | } | 79 | } |
79 | delete folders; | 80 | delete folders; |
80 | } | 81 | } |
81 | 82 | ||
82 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 83 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
83 | { | 84 | { |
84 | 85 | ||
85 | return wrapper->fetchBody( mail ); | 86 | return wrapper->fetchBody( mail ); |
86 | } | 87 | } |
87 | 88 | ||
88 | QPopupMenu * POP3viewItem::getContextMenu() | 89 | QPopupMenu * POP3viewItem::getContextMenu() |
89 | { | 90 | { |
90 | QPopupMenu *m = new QPopupMenu(0); | 91 | QPopupMenu *m = new QPopupMenu(0); |
91 | if (m) | 92 | if (m) |
92 | { | 93 | { |
93 | if (!account->getOffline()) | 94 | if (!account->getOffline()) |
94 | { | 95 | { |
95 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); | 96 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
96 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 97 | m->insertItem(i18n("Disconnect"),0); |
97 | m->insertItem(QObject::tr("Set offline",contextName),1); | 98 | m->insertItem(i18n("Set offline"),1); |
98 | } | 99 | } |
99 | else | 100 | else |
100 | { | 101 | { |
101 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); | 102 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
102 | m->insertItem(QObject::tr("Set online",contextName),1); | 103 | m->insertItem(i18n("Set online"),1); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | return m; | 106 | return m; |
106 | } | 107 | } |
107 | 108 | ||
108 | void POP3viewItem::disconnect() | 109 | void POP3viewItem::disconnect() |
109 | { | 110 | { |
110 | QListViewItem *child = firstChild(); | 111 | QListViewItem *child = firstChild(); |
111 | while ( child ) | 112 | while ( child ) |
112 | { | 113 | { |
113 | QListViewItem *tmp = child; | 114 | QListViewItem *tmp = child; |
114 | child = child->nextSibling(); | 115 | child = child->nextSibling(); |
115 | delete tmp; | 116 | delete tmp; |
116 | } | 117 | } |
117 | wrapper->logout(); | 118 | wrapper->logout(); |
118 | } | 119 | } |
119 | 120 | ||
120 | void POP3viewItem::setOnOffline() | 121 | void POP3viewItem::setOnOffline() |
121 | { | 122 | { |
122 | if (!account->getOffline()) | 123 | if (!account->getOffline()) |
123 | { | 124 | { |
124 | disconnect(); | 125 | disconnect(); |
125 | } | 126 | } |
126 | account->setOffline(!account->getOffline()); | 127 | account->setOffline(!account->getOffline()); |
127 | account->save(); | 128 | account->save(); |
128 | SETPIX(PIXMAP_POP3FOLDER); | 129 | SETPIX(PIXMAP_POP3FOLDER); |
129 | refresh(); | 130 | refresh(); |
130 | } | 131 | } |
131 | 132 | ||
132 | void POP3viewItem::contextMenuSelected(int which) | 133 | void POP3viewItem::contextMenuSelected(int which) |
133 | { | 134 | { |
134 | switch (which) | 135 | switch (which) |
135 | { | 136 | { |
136 | case 0: | 137 | case 0: |
137 | disconnect(); | 138 | disconnect(); |
138 | break; | 139 | break; |
139 | case 1: | 140 | case 1: |
140 | setOnOffline(); | 141 | setOnOffline(); |
141 | break; | 142 | break; |
142 | case GET_NEW_MAILS: // daunlood | 143 | case GET_NEW_MAILS: // daunlood |
143 | if (account->getOffline()) | 144 | if (account->getOffline()) |
144 | setOnOffline(); | 145 | setOnOffline(); |
145 | AccountView*bl = accountView(); | 146 | AccountView*bl = accountView(); |
146 | if (!bl) return; | 147 | if (!bl) return; |
147 | AccountViewItem* in = findSubItem( "inbox" , 0); | 148 | AccountViewItem* in = findSubItem( "inbox" , 0); |
148 | if ( ! in ) | 149 | if ( ! in ) |
149 | return; | 150 | return; |
150 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 151 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
151 | setOnOffline(); | 152 | setOnOffline(); |
152 | break; | 153 | break; |
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
156 | POP3folderItem::~POP3folderItem() | 157 | POP3folderItem::~POP3folderItem() |
157 | {} | 158 | {} |
158 | 159 | ||
159 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 160 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
160 | : AccountViewItem(folderInit,parent,after ) | 161 | : AccountViewItem(folderInit,parent,after ) |
161 | { | 162 | { |
162 | pop3 = parent; | 163 | pop3 = parent; |
163 | if (folder->getDisplayName().lower()!="inbox") | 164 | if (folder->getDisplayName().lower()!="inbox") |
164 | { | 165 | { |
165 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 166 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
166 | } | 167 | } |
167 | else | 168 | else |
168 | { | 169 | { |
169 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 170 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
170 | } | 171 | } |
171 | setText( 0, folder->getDisplayName() ); | 172 | setText( 0, folder->getDisplayName() ); |
172 | } | 173 | } |
173 | 174 | ||
174 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 175 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
175 | { | 176 | { |
176 | if (folder->may_select()) | 177 | if (folder->may_select()) |
177 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 178 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
178 | } | 179 | } |
179 | 180 | ||
180 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 181 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
181 | { | 182 | { |
182 | return pop3->getWrapper()->fetchBody(aMail); | 183 | return pop3->getWrapper()->fetchBody(aMail); |
183 | } | 184 | } |
184 | 185 | ||
185 | QPopupMenu * POP3folderItem::getContextMenu() | 186 | QPopupMenu * POP3folderItem::getContextMenu() |
186 | { | 187 | { |
187 | QPopupMenu *m = new QPopupMenu(0); | 188 | QPopupMenu *m = new QPopupMenu(0); |
188 | if (m) | 189 | if (m) |
189 | { | 190 | { |
190 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); | 191 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
191 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 192 | m->insertItem(i18n("Refresh header list"),0); |
192 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 193 | m->insertItem(i18n("Delete all mails"),1); |
193 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 194 | m->insertItem(i18n("Move/Copie all mails"),2); |
194 | } | 195 | } |
195 | return m; | 196 | return m; |
196 | } | 197 | } |
197 | 198 | ||
198 | void POP3folderItem::downloadMails() | 199 | void POP3folderItem::downloadMails() |
199 | { | 200 | { |
200 | AccountView*bl = pop3->accountView(); | 201 | AccountView*bl = pop3->accountView(); |
201 | if (!bl) return; | 202 | if (!bl) return; |
202 | bl->downloadMails(folder,pop3->getWrapper()); | 203 | bl->downloadMails(folder,pop3->getWrapper()); |
203 | } | 204 | } |
204 | 205 | ||
205 | void POP3folderItem::contextMenuSelected(int which) | 206 | void POP3folderItem::contextMenuSelected(int which) |
206 | { | 207 | { |
207 | AccountView * view = (AccountView*)listView(); | 208 | AccountView * view = (AccountView*)listView(); |
208 | switch (which) | 209 | switch (which) |
209 | { | 210 | { |
210 | case 0: | 211 | case 0: |
211 | /* must be 'cause pop3 lists are cached */ | 212 | /* must be 'cause pop3 lists are cached */ |
212 | pop3->getWrapper()->logout(); | 213 | pop3->getWrapper()->logout(); |
213 | view->refreshCurrent(); | 214 | view->refreshCurrent(); |
214 | break; | 215 | break; |
215 | case 1: | 216 | case 1: |
216 | deleteAllMail(pop3->getWrapper(),folder); | 217 | deleteAllMail(pop3->getWrapper(),folder); |
217 | break; | 218 | break; |
218 | case 2: | 219 | case 2: |
219 | downloadMails(); | 220 | downloadMails(); |
220 | break; | 221 | break; |
221 | case GET_NEW_MAILS: // daunlood | 222 | case GET_NEW_MAILS: // daunlood |
222 | view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); | 223 | view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); |
223 | break; | 224 | break; |
224 | default: | 225 | default: |
225 | break; | 226 | break; |
226 | } | 227 | } |
227 | } | 228 | } |
228 | 229 | ||
229 | /** | 230 | /** |
230 | * NNTP Account stuff | 231 | * NNTP Account stuff |
231 | */ | 232 | */ |
232 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 233 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
233 | : AccountViewItem( parent ) | 234 | : AccountViewItem( parent ) |
234 | { | 235 | { |
235 | account = a; | 236 | account = a; |
236 | wrapper = AbstractMail::getWrapper( account ); | 237 | wrapper = AbstractMail::getWrapper( account ); |
237 | //FIXME | 238 | //FIXME |
238 | SETPIX(PIXMAP_POP3FOLDER); | 239 | SETPIX(PIXMAP_POP3FOLDER); |
239 | #if 0 | 240 | #if 0 |
240 | if (!account->getOffline()) | 241 | if (!account->getOffline()) |
241 | { | 242 | { |
242 | setPixmap( 0, ); | 243 | setPixmap( 0, ); |
243 | } | 244 | } |
244 | else | 245 | else |
245 | { | 246 | { |
246 | setPixmap( 0, PIXMAP_OFFLINE ); | 247 | setPixmap( 0, PIXMAP_OFFLINE ); |
247 | } | 248 | } |
248 | #endif | 249 | #endif |
249 | setText( 0, account->getAccountName() ); | 250 | setText( 0, account->getAccountName() ); |
250 | setOpen( true ); | 251 | setOpen( true ); |
251 | } | 252 | } |
252 | 253 | ||
253 | NNTPviewItem::~NNTPviewItem() | 254 | NNTPviewItem::~NNTPviewItem() |
254 | { | 255 | { |
255 | delete wrapper; | 256 | delete wrapper; |
256 | } | 257 | } |
257 | 258 | ||
258 | AbstractMail *NNTPviewItem::getWrapper() | 259 | AbstractMail *NNTPviewItem::getWrapper() |
259 | { | 260 | { |
260 | return wrapper; | 261 | return wrapper; |
261 | } | 262 | } |
262 | 263 | ||
263 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 264 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
264 | { | 265 | { |
265 | refresh(); | 266 | refresh(); |
266 | } | 267 | } |
267 | 268 | ||
268 | void NNTPviewItem::refresh() | 269 | void NNTPviewItem::refresh() |
269 | { | 270 | { |
270 | if (account->getOffline()) return; | 271 | if (account->getOffline()) return; |
271 | QValueList<FolderP> *folders = wrapper->listFolders(); | 272 | QValueList<FolderP> *folders = wrapper->listFolders(); |
272 | 273 | ||
273 | QListViewItem *child = firstChild(); | 274 | QListViewItem *child = firstChild(); |
274 | while ( child ) | 275 | while ( child ) |
275 | { | 276 | { |
276 | QListViewItem *tmp = child; | 277 | QListViewItem *tmp = child; |
277 | child = child->nextSibling(); | 278 | child = child->nextSibling(); |
278 | delete tmp; | 279 | delete tmp; |
279 | } | 280 | } |
280 | QValueList<FolderP>::ConstIterator it; | 281 | QValueList<FolderP>::ConstIterator it; |
281 | QListViewItem*item = 0; | 282 | QListViewItem*item = 0; |
282 | for ( it = folders->begin(); it!=folders->end(); ++it) | 283 | for ( it = folders->begin(); it!=folders->end(); ++it) |
283 | { | 284 | { |
284 | item = new NNTPfolderItem( (*it), this , item ); | 285 | item = new NNTPfolderItem( (*it), this , item ); |
285 | item->setSelectable( (*it)->may_select()); | 286 | item->setSelectable( (*it)->may_select()); |
286 | } | 287 | } |
287 | delete folders; | 288 | delete folders; |
288 | } | 289 | } |
289 | 290 | ||
290 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 291 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
291 | { | 292 | { |
292 | 293 | ||
293 | return wrapper->fetchBody( mail ); | 294 | return wrapper->fetchBody( mail ); |
294 | } | 295 | } |
295 | 296 | ||
296 | QPopupMenu * NNTPviewItem::getContextMenu() | 297 | QPopupMenu * NNTPviewItem::getContextMenu() |
297 | { | 298 | { |
298 | QPopupMenu *m = new QPopupMenu(0); | 299 | QPopupMenu *m = new QPopupMenu(0); |
299 | if (m) | 300 | if (m) |
300 | { | 301 | { |
301 | if (!account->getOffline()) | 302 | if (!account->getOffline()) |
302 | { | 303 | { |
303 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 304 | m->insertItem(i18n("Disconnect"),0); |
304 | m->insertItem(QObject::tr("Set offline",contextName),1); | 305 | m->insertItem(i18n("Set offline"),1); |
305 | //m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 306 | //m->insertItem(i18n("(Un-)Subscribe groups"),2); |
306 | } | 307 | } |
307 | else | 308 | else |
308 | { | 309 | { |
309 | m->insertItem(QObject::tr("Set online",contextName),1); | 310 | m->insertItem(i18n("Set online"),1); |
310 | } | 311 | } |
311 | } | 312 | } |
312 | return m; | 313 | return m; |
313 | } | 314 | } |
314 | 315 | ||
315 | void NNTPviewItem::subscribeGroups() | 316 | void NNTPviewItem::subscribeGroups() |
316 | { | 317 | { |
317 | NNTPGroupsDlg dlg(account); | 318 | NNTPGroupsDlg dlg(account); |
318 | dlg.showMaximized(); | 319 | dlg.showMaximized(); |
319 | if ( dlg.exec()== QDialog::Accepted ){ | 320 | if ( dlg.exec()== QDialog::Accepted ){ |
320 | refresh(); | 321 | refresh(); |
321 | } | 322 | } |
322 | } | 323 | } |
323 | 324 | ||
324 | void NNTPviewItem::disconnect() | 325 | void NNTPviewItem::disconnect() |
325 | { | 326 | { |
326 | QListViewItem *child = firstChild(); | 327 | QListViewItem *child = firstChild(); |
327 | while ( child ) | 328 | while ( child ) |
328 | { | 329 | { |
329 | QListViewItem *tmp = child; | 330 | QListViewItem *tmp = child; |
330 | child = child->nextSibling(); | 331 | child = child->nextSibling(); |
331 | delete tmp; | 332 | delete tmp; |
332 | } | 333 | } |
333 | wrapper->logout(); | 334 | wrapper->logout(); |
334 | } | 335 | } |
335 | 336 | ||
336 | void NNTPviewItem::setOnOffline() | 337 | void NNTPviewItem::setOnOffline() |
337 | { | 338 | { |
338 | if (!account->getOffline()) | 339 | if (!account->getOffline()) |
339 | { | 340 | { |
340 | disconnect(); | 341 | disconnect(); |
341 | } | 342 | } |
342 | account->setOffline(!account->getOffline()); | 343 | account->setOffline(!account->getOffline()); |
343 | account->save(); | 344 | account->save(); |
344 | //FIXME | 345 | //FIXME |
345 | SETPIX(PIXMAP_POP3FOLDER); | 346 | SETPIX(PIXMAP_POP3FOLDER); |
346 | refresh(); | 347 | refresh(); |
347 | } | 348 | } |
348 | 349 | ||
349 | void NNTPviewItem::contextMenuSelected(int which) | 350 | void NNTPviewItem::contextMenuSelected(int which) |
350 | { | 351 | { |
351 | switch (which) | 352 | switch (which) |
352 | { | 353 | { |
353 | case 0: | 354 | case 0: |
354 | disconnect(); | 355 | disconnect(); |
355 | break; | 356 | break; |
356 | case 1: | 357 | case 1: |
357 | setOnOffline(); | 358 | setOnOffline(); |
358 | break; | 359 | break; |
359 | case 2: | 360 | case 2: |
360 | subscribeGroups(); | 361 | subscribeGroups(); |
361 | break; | 362 | break; |
362 | } | 363 | } |
363 | } | 364 | } |
364 | 365 | ||
365 | NNTPfolderItem::~NNTPfolderItem() | 366 | NNTPfolderItem::~NNTPfolderItem() |
366 | {} | 367 | {} |
367 | 368 | ||
368 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 369 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
369 | : AccountViewItem( folderInit, parent,after ) | 370 | : AccountViewItem( folderInit, parent,after ) |
370 | { | 371 | { |
371 | nntp = parent; | 372 | nntp = parent; |
372 | if (folder->getDisplayName().lower()!="inbox") | 373 | if (folder->getDisplayName().lower()!="inbox") |
373 | { | 374 | { |
374 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 375 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
375 | } | 376 | } |
376 | else | 377 | else |
377 | { | 378 | { |
378 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 379 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
379 | } | 380 | } |
380 | setText( 0, folder->getDisplayName() ); | 381 | setText( 0, folder->getDisplayName() ); |
381 | } | 382 | } |
382 | 383 | ||
383 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 384 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
384 | { | 385 | { |
385 | if (folder->may_select()) | 386 | if (folder->may_select()) |
386 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 387 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
387 | } | 388 | } |
388 | 389 | ||
389 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 390 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
390 | { | 391 | { |
391 | return nntp->getWrapper()->fetchBody(aMail); | 392 | return nntp->getWrapper()->fetchBody(aMail); |
392 | } | 393 | } |
393 | 394 | ||
394 | QPopupMenu * NNTPfolderItem::getContextMenu() | 395 | QPopupMenu * NNTPfolderItem::getContextMenu() |
395 | { | 396 | { |
396 | QPopupMenu *m = new QPopupMenu(0); | 397 | QPopupMenu *m = new QPopupMenu(0); |
397 | if (m) | 398 | if (m) |
398 | { | 399 | { |
399 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 400 | m->insertItem(i18n("Refresh header list"),0); |
400 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 401 | m->insertItem(i18n("Copy all postings"),1); |
401 | } | 402 | } |
402 | return m; | 403 | return m; |
403 | } | 404 | } |
404 | 405 | ||
405 | void NNTPfolderItem::downloadMails() | 406 | void NNTPfolderItem::downloadMails() |
406 | { | 407 | { |
407 | AccountView*bl = nntp->accountView(); | 408 | AccountView*bl = nntp->accountView(); |
408 | if (!bl) return; | 409 | if (!bl) return; |
409 | bl->downloadMails(folder,nntp->getWrapper()); | 410 | bl->downloadMails(folder,nntp->getWrapper()); |
410 | } | 411 | } |
411 | 412 | ||
412 | void NNTPfolderItem::contextMenuSelected(int which) | 413 | void NNTPfolderItem::contextMenuSelected(int which) |
413 | { | 414 | { |
414 | AccountView * view = (AccountView*)listView(); | 415 | AccountView * view = (AccountView*)listView(); |
415 | switch (which) | 416 | switch (which) |
416 | { | 417 | { |
417 | case 0: | 418 | case 0: |
418 | /* must be 'cause pop3 lists are cached */ | 419 | /* must be 'cause pop3 lists are cached */ |
419 | nntp->getWrapper()->logout(); | 420 | nntp->getWrapper()->logout(); |
420 | view->refreshCurrent(); | 421 | view->refreshCurrent(); |
421 | break; | 422 | break; |
422 | case 1: | 423 | case 1: |
423 | downloadMails(); | 424 | downloadMails(); |
424 | break; | 425 | break; |
425 | default: | 426 | default: |
426 | break; | 427 | break; |
427 | } | 428 | } |
428 | } | 429 | } |
429 | 430 | ||
430 | /** | 431 | /** |
431 | * IMAP Account stuff | 432 | * IMAP Account stuff |
432 | */ | 433 | */ |
433 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 434 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
434 | : AccountViewItem( parent ) | 435 | : AccountViewItem( parent ) |
435 | { | 436 | { |
436 | account = a; | 437 | account = a; |
437 | wrapper = AbstractMail::getWrapper( account ); | 438 | wrapper = AbstractMail::getWrapper( account ); |
438 | SETPIX(PIXMAP_IMAPFOLDER); | 439 | SETPIX(PIXMAP_IMAPFOLDER); |
439 | setText( 0, account->getAccountName() ); | 440 | setText( 0, account->getAccountName() ); |
440 | setOpen( true ); | 441 | setOpen( true ); |
441 | } | 442 | } |
442 | 443 | ||
443 | IMAPviewItem::~IMAPviewItem() | 444 | IMAPviewItem::~IMAPviewItem() |
444 | { | 445 | { |
445 | delete wrapper; | 446 | delete wrapper; |
446 | } | 447 | } |
447 | 448 | ||
448 | AbstractMail *IMAPviewItem::getWrapper() | 449 | AbstractMail *IMAPviewItem::getWrapper() |
449 | { | 450 | { |
450 | return wrapper; | 451 | return wrapper; |
451 | } | 452 | } |
452 | 453 | ||
453 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 454 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
454 | { | 455 | { |
455 | refreshFolders(false); | 456 | refreshFolders(false); |
456 | } | 457 | } |
457 | 458 | ||
458 | const QStringList&IMAPviewItem::subFolders() | 459 | const QStringList&IMAPviewItem::subFolders() |
459 | { | 460 | { |
460 | return currentFolders; | 461 | return currentFolders; |
461 | } | 462 | } |
462 | 463 | ||
463 | void IMAPviewItem::refreshFolders(bool force) | 464 | void IMAPviewItem::refreshFolders(bool force) |
464 | { | 465 | { |
465 | if (childCount()>0 && force==false) return; | 466 | if (childCount()>0 && force==false) return; |
466 | if (account->getOffline()) return; | 467 | if (account->getOffline()) return; |
467 | 468 | ||
468 | removeChilds(); | 469 | removeChilds(); |
469 | currentFolders.clear(); | 470 | currentFolders.clear(); |
470 | QValueList<FolderP> * folders = wrapper->listFolders(); | 471 | QValueList<FolderP> * folders = wrapper->listFolders(); |
471 | 472 | ||
472 | QValueList<FolderP>::Iterator it; | 473 | QValueList<FolderP>::Iterator it; |
473 | QListViewItem*item = 0; | 474 | QListViewItem*item = 0; |
474 | QListViewItem*titem = 0; | 475 | QListViewItem*titem = 0; |
475 | QString fname,del,search; | 476 | QString fname,del,search; |
476 | int pos; | 477 | int pos; |
477 | 478 | ||
478 | for ( it = folders->begin(); it!=folders->end(); ++it) | 479 | for ( it = folders->begin(); it!=folders->end(); ++it) |
479 | { | 480 | { |
480 | if ((*it)->getDisplayName().lower()=="inbox") | 481 | if ((*it)->getDisplayName().lower()=="inbox") |
481 | { | 482 | { |
482 | item = new IMAPfolderItem( (*it), this , item ); | 483 | item = new IMAPfolderItem( (*it), this , item ); |
483 | folders->remove(it); | 484 | folders->remove(it); |
484 | break; | 485 | break; |
485 | } | 486 | } |
486 | } | 487 | } |
487 | for ( it = folders->begin(); it!=folders->end(); ++it) | 488 | for ( it = folders->begin(); it!=folders->end(); ++it) |
488 | { | 489 | { |
489 | fname = (*it)->getDisplayName(); | 490 | fname = (*it)->getDisplayName(); |
490 | currentFolders.append((*it)->getName()); | 491 | currentFolders.append((*it)->getName()); |
491 | pos = fname.findRev((*it)->Separator()); | 492 | pos = fname.findRev((*it)->Separator()); |
492 | if (pos != -1) | 493 | if (pos != -1) |
493 | { | 494 | { |
494 | fname = fname.left(pos); | 495 | fname = fname.left(pos); |
495 | } | 496 | } |
496 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 497 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
497 | if (pitem) | 498 | if (pitem) |
498 | { | 499 | { |
499 | titem = item; | 500 | titem = item; |
500 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 501 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
501 | /* setup the short name */ | 502 | /* setup the short name */ |
502 | item->setText(0,(*it)->getDisplayName().mid(pos+1)); | 503 | item->setText(0,(*it)->getDisplayName().mid(pos+1)); |
503 | item = titem; | 504 | item = titem; |
504 | } | 505 | } |
505 | else | 506 | else |
506 | { | 507 | { |
507 | item = new IMAPfolderItem( (*it), this , item ); | 508 | item = new IMAPfolderItem( (*it), this , item ); |
508 | } | 509 | } |
509 | } | 510 | } |
510 | delete folders; | 511 | delete folders; |
511 | } | 512 | } |
512 | 513 | ||
513 | QPopupMenu * IMAPviewItem::getContextMenu() | 514 | QPopupMenu * IMAPviewItem::getContextMenu() |
514 | { | 515 | { |
515 | QPopupMenu *m = new QPopupMenu(0); | 516 | QPopupMenu *m = new QPopupMenu(0); |
516 | if (m) | 517 | if (m) |
517 | { | 518 | { |
518 | if (!account->getOffline()) | 519 | if (!account->getOffline()) |
519 | { | 520 | { |
520 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); | 521 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
521 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 522 | m->insertItem(i18n("Refresh folder list"),0); |
522 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 523 | m->insertItem(i18n("Create new folder"),1); |
523 | m->insertSeparator(); | 524 | m->insertSeparator(); |
524 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 525 | m->insertItem(i18n("Disconnect"),2); |
525 | m->insertItem(QObject::tr("Set offline",contextName),3); | 526 | m->insertItem(i18n("Set offline"),3); |
526 | m->insertSeparator(); | 527 | m->insertSeparator(); |
527 | } | 528 | } |
528 | else | 529 | else |
529 | { | 530 | { |
530 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); | 531 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
531 | m->insertItem(QObject::tr("Set online",contextName),3); | 532 | m->insertItem(i18n("Set online"),3); |
532 | } | 533 | } |
533 | } | 534 | } |
534 | return m; | 535 | return m; |
535 | } | 536 | } |
536 | 537 | ||
537 | void IMAPviewItem::createNewFolder() | 538 | void IMAPviewItem::createNewFolder() |
538 | { | 539 | { |
539 | Newmdirdlg ndirdlg; | 540 | Newmdirdlg ndirdlg; |
540 | 541 | ||
541 | ndirdlg.showMaximized(); | 542 | ndirdlg.showMaximized(); |
542 | if ( ndirdlg.exec() ) | 543 | if ( ndirdlg.exec() ) |
543 | { | 544 | { |
544 | QString ndir = ndirdlg.Newdir(); | 545 | QString ndir = ndirdlg.Newdir(); |
545 | bool makesubs = ndirdlg.subpossible(); | 546 | bool makesubs = ndirdlg.subpossible(); |
546 | QString delemiter = "/"; | 547 | QString delemiter = "/"; |
547 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 548 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
548 | if (item) | 549 | if (item) |
549 | { | 550 | { |
550 | delemiter = item->Delemiter(); | 551 | delemiter = item->Delemiter(); |
551 | } | 552 | } |
552 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 553 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
553 | { | 554 | { |
554 | refreshFolders(true); | 555 | refreshFolders(true); |
555 | } | 556 | } |
556 | } | 557 | } |
557 | } | 558 | } |
558 | 559 | ||
559 | void IMAPviewItem::contextMenuSelected(int id) | 560 | void IMAPviewItem::contextMenuSelected(int id) |
560 | { | 561 | { |
561 | 562 | ||
562 | switch (id) | 563 | switch (id) |
563 | { | 564 | { |
564 | case 0: | 565 | case 0: |
565 | refreshFolders(true); | 566 | refreshFolders(true); |
566 | break; | 567 | break; |
567 | case 1: | 568 | case 1: |
568 | createNewFolder(); | 569 | createNewFolder(); |
569 | break; | 570 | break; |
570 | case 2: | 571 | case 2: |
571 | removeChilds(); | 572 | removeChilds(); |
572 | wrapper->logout(); | 573 | wrapper->logout(); |
573 | break; | 574 | break; |
574 | case 3: | 575 | case 3: |
575 | if (account->getOffline()==false) | 576 | if (account->getOffline()==false) |
576 | { | 577 | { |
577 | removeChilds(); | 578 | removeChilds(); |
578 | wrapper->logout(); | 579 | wrapper->logout(); |
579 | } | 580 | } |
580 | account->setOffline(!account->getOffline()); | 581 | account->setOffline(!account->getOffline()); |
581 | account->save(); | 582 | account->save(); |
582 | SETPIX(PIXMAP_IMAPFOLDER); | 583 | SETPIX(PIXMAP_IMAPFOLDER); |
583 | refreshFolders(false); | 584 | refreshFolders(false); |
584 | break; | 585 | break; |
585 | case GET_NEW_MAILS: // daunlood | 586 | case GET_NEW_MAILS: // daunlood |
586 | { | 587 | { |
587 | if (account->getOffline()) { | 588 | if (account->getOffline()) { |
588 | contextMenuSelected( 3 ); | 589 | contextMenuSelected( 3 ); |
589 | } | 590 | } |
590 | AccountView*bl = accountView(); | 591 | AccountView*bl = accountView(); |
591 | if (!bl) return; | 592 | if (!bl) return; |
592 | AccountViewItem* in = findSubItem( "inbox" , 0); | 593 | AccountViewItem* in = findSubItem( "inbox" , 0); |
593 | if ( ! in ) | 594 | if ( ! in ) |
594 | return; | 595 | return; |
595 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | 596 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); |
596 | } | 597 | } |
597 | break; | 598 | break; |
598 | default: | 599 | default: |
599 | break; | 600 | break; |
600 | } | 601 | } |
601 | } | 602 | } |
602 | 603 | ||
603 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 604 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
604 | { | 605 | { |
605 | return new RecBody(); | 606 | return new RecBody(); |
606 | } | 607 | } |
607 | 608 | ||
608 | bool IMAPviewItem::offline() | 609 | bool IMAPviewItem::offline() |
609 | { | 610 | { |
610 | return account->getOffline(); | 611 | return account->getOffline(); |
611 | } | 612 | } |
612 | 613 | ||
613 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 614 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
614 | : AccountViewItem( folderInit, parent , after ) | 615 | : AccountViewItem( folderInit, parent , after ) |
615 | { | 616 | { |
616 | imap = parent; | 617 | imap = parent; |
617 | if (folder->getDisplayName().lower()!="inbox") | 618 | if (folder->getDisplayName().lower()!="inbox") |
618 | { | 619 | { |
619 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 620 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
620 | } | 621 | } |
621 | else | 622 | else |
622 | { | 623 | { |
623 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 624 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
624 | } | 625 | } |
625 | setText( 0, folder->getDisplayName() ); | 626 | setText( 0, folder->getDisplayName() ); |
626 | } | 627 | } |
627 | 628 | ||
628 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 629 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
629 | : AccountViewItem(folderInit, parent,after ) | 630 | : AccountViewItem(folderInit, parent,after ) |
630 | { | 631 | { |
631 | imap = master; | 632 | imap = master; |
632 | if (folder->getDisplayName().lower()!="inbox") | 633 | if (folder->getDisplayName().lower()!="inbox") |
633 | { | 634 | { |
634 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 635 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
635 | } | 636 | } |
636 | else | 637 | else |
637 | { | 638 | { |
638 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 639 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
639 | } | 640 | } |
640 | setText( 0, folder->getDisplayName() ); | 641 | setText( 0, folder->getDisplayName() ); |
641 | } | 642 | } |
642 | 643 | ||
643 | IMAPfolderItem::~IMAPfolderItem() | 644 | IMAPfolderItem::~IMAPfolderItem() |
644 | {} | 645 | {} |
645 | 646 | ||
646 | const QString& IMAPfolderItem::Delemiter()const | 647 | const QString& IMAPfolderItem::Delemiter()const |
647 | { | 648 | { |
648 | return folder->Separator(); | 649 | return folder->Separator(); |
649 | } | 650 | } |
650 | 651 | ||
651 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 652 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
652 | { | 653 | { |
653 | if (folder->may_select()) | 654 | if (folder->may_select()) |
654 | { | 655 | { |
655 | imap->getWrapper()->listMessages( folder->getName(),target ); | 656 | imap->getWrapper()->listMessages( folder->getName(),target ); |
656 | } | 657 | } |
657 | else | 658 | else |
658 | { | 659 | { |
659 | target.clear(); | 660 | target.clear(); |
660 | } | 661 | } |
661 | } | 662 | } |
662 | 663 | ||
663 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 664 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
664 | { | 665 | { |
665 | return imap->getWrapper()->fetchBody(aMail); | 666 | return imap->getWrapper()->fetchBody(aMail); |
666 | } | 667 | } |
667 | 668 | ||
668 | QPopupMenu * IMAPfolderItem::getContextMenu() | 669 | QPopupMenu * IMAPfolderItem::getContextMenu() |
669 | { | 670 | { |
670 | QPopupMenu *m = new QPopupMenu(0); | 671 | QPopupMenu *m = new QPopupMenu(0); |
671 | if (m) | 672 | if (m) |
672 | { | 673 | { |
673 | if (folder->may_select()) | 674 | if (folder->may_select()) |
674 | { | 675 | { |
675 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); | 676 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
676 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 677 | m->insertItem(i18n("Refresh header list"),0); |
677 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 678 | m->insertItem(i18n("Move/Copie all mails"),4); |
678 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 679 | m->insertItem(i18n("Delete all mails"),1); |
679 | } | 680 | } |
680 | if (folder->no_inferior()==false) | 681 | if (folder->no_inferior()==false) |
681 | { | 682 | { |
682 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 683 | m->insertItem(i18n("Create new subfolder"),2); |
683 | } | 684 | } |
684 | if (folder->getDisplayName().lower()!="inbox") | 685 | if (folder->getDisplayName().lower()!="inbox") |
685 | { | 686 | { |
686 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 687 | m->insertItem(i18n("Delete folder"),3); |
687 | } | 688 | } |
688 | } | 689 | } |
689 | return m; | 690 | return m; |
690 | } | 691 | } |
691 | 692 | ||
692 | void IMAPfolderItem::createNewFolder() | 693 | void IMAPfolderItem::createNewFolder() |
693 | { | 694 | { |
694 | Newmdirdlg ndirdlg; | 695 | Newmdirdlg ndirdlg; |
695 | ndirdlg.showMaximized(); | 696 | ndirdlg.showMaximized(); |
696 | if ( ndirdlg.exec() ) | 697 | if ( ndirdlg.exec() ) |
697 | { | 698 | { |
698 | QString ndir = ndirdlg.Newdir(); | 699 | QString ndir = ndirdlg.Newdir(); |
699 | bool makesubs = ndirdlg.subpossible(); | 700 | bool makesubs = ndirdlg.subpossible(); |
700 | QString delemiter = Delemiter(); | 701 | QString delemiter = Delemiter(); |
701 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 702 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
702 | { | 703 | { |
703 | imap->refreshFolders(true); | 704 | imap->refreshFolders(true); |
704 | } | 705 | } |
705 | } | 706 | } |
706 | } | 707 | } |
707 | 708 | ||
708 | void IMAPfolderItem::deleteFolder() | 709 | void IMAPfolderItem::deleteFolder() |
709 | { | 710 | { |
710 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 711 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), |
711 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 712 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), |
712 | QObject::tr("Yes",contextName), | 713 | i18n("Yes"), |
713 | QObject::tr("No",contextName),QString::null,1,1); | 714 | i18n("No"),QString::null,1,1); |
714 | 715 | ||
715 | if (yesno == 0) | 716 | if (yesno == 0) |
716 | { | 717 | { |
717 | if (imap->getWrapper()->deleteMbox(folder)) | 718 | if (imap->getWrapper()->deleteMbox(folder)) |
718 | { | 719 | { |
719 | QListView*v=listView(); | 720 | QListView*v=listView(); |
720 | IMAPviewItem * box = imap; | 721 | IMAPviewItem * box = imap; |
721 | /* be carefull - after that this object is destroyd so don't use | 722 | /* be carefull - after that this object is destroyd so don't use |
722 | * any member of it after that call!!*/ | 723 | * any member of it after that call!!*/ |
723 | imap->refreshFolders(true); | 724 | imap->refreshFolders(true); |
724 | if (v) | 725 | if (v) |
725 | { | 726 | { |
726 | v->setSelected(box,true); | 727 | v->setSelected(box,true); |
727 | } | 728 | } |
728 | } | 729 | } |
729 | } | 730 | } |
730 | } | 731 | } |
731 | 732 | ||
732 | void IMAPfolderItem::downloadMails() | 733 | void IMAPfolderItem::downloadMails() |
733 | { | 734 | { |
734 | AccountView*bl = imap->accountView(); | 735 | AccountView*bl = imap->accountView(); |
735 | if (!bl) return; | 736 | if (!bl) return; |
736 | bl->downloadMails(folder,imap->getWrapper()); | 737 | bl->downloadMails(folder,imap->getWrapper()); |
737 | } | 738 | } |
738 | 739 | ||
739 | void IMAPfolderItem::contextMenuSelected(int id) | 740 | void IMAPfolderItem::contextMenuSelected(int id) |
740 | { | 741 | { |
741 | 742 | ||
742 | AccountView * view = (AccountView*)listView(); | 743 | AccountView * view = (AccountView*)listView(); |
743 | switch(id) | 744 | switch(id) |
744 | { | 745 | { |
745 | case 0: | 746 | case 0: |
746 | view->refreshCurrent(); | 747 | view->refreshCurrent(); |
747 | break; | 748 | break; |
748 | case 1: | 749 | case 1: |
749 | deleteAllMail(imap->getWrapper(),folder); | 750 | deleteAllMail(imap->getWrapper(),folder); |
750 | break; | 751 | break; |
751 | case 2: | 752 | case 2: |
752 | createNewFolder(); | 753 | createNewFolder(); |
753 | break; | 754 | break; |
754 | case 3: | 755 | case 3: |
755 | deleteFolder(); | 756 | deleteFolder(); |
756 | break; | 757 | break; |
757 | case 4: | 758 | case 4: |
758 | downloadMails(); | 759 | downloadMails(); |
759 | break; | 760 | break; |
760 | case GET_NEW_MAILS: // daunlood | 761 | case GET_NEW_MAILS: // daunlood |
761 | { | 762 | { |
762 | if (!view) return; | 763 | if (!view) return; |
763 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); | 764 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); |
764 | } | 765 | } |
765 | break; | 766 | break; |
766 | default: | 767 | default: |
767 | break; | 768 | break; |
768 | } | 769 | } |
769 | } | 770 | } |
770 | 771 | ||
771 | /** | 772 | /** |
772 | * MH Account stuff | 773 | * MH Account stuff |
773 | */ | 774 | */ |
774 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 775 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
775 | POP3 and MBOX */ | 776 | POP3 and MBOX */ |
776 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 777 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
777 | : AccountViewItem( parent ) | 778 | : AccountViewItem( parent ) |
778 | { | 779 | { |
779 | m_Path = aPath; | 780 | m_Path = aPath; |
780 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 781 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
781 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 782 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
782 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 783 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
783 | setText( 0, " Local Folders" ); | 784 | setText( 0, " Local Folders" ); |
784 | setOpen( true ); | 785 | setOpen( true ); |
785 | folder = 0; | 786 | folder = 0; |
786 | } | 787 | } |
787 | 788 | ||
788 | MHviewItem::~MHviewItem() | 789 | MHviewItem::~MHviewItem() |
789 | { | 790 | { |
790 | delete wrapper; | 791 | delete wrapper; |
791 | } | 792 | } |
792 | 793 | ||
793 | AbstractMail *MHviewItem::getWrapper() | 794 | AbstractMail *MHviewItem::getWrapper() |
794 | { | 795 | { |
795 | return wrapper; | 796 | return wrapper; |
796 | } | 797 | } |
797 | 798 | ||
798 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 799 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
799 | { | 800 | { |
800 | refresh(false); | 801 | refresh(false); |
801 | getWrapper()->listMessages( "",target ); | 802 | getWrapper()->listMessages( "",target ); |
802 | } | 803 | } |
803 | 804 | ||
804 | void MHviewItem::refresh(bool force) | 805 | void MHviewItem::refresh(bool force) |
805 | { | 806 | { |
806 | if (childCount()>0 && force==false) return; | 807 | if (childCount()>0 && force==false) return; |
807 | removeChilds(); | 808 | removeChilds(); |
808 | currentFolders.clear(); | 809 | currentFolders.clear(); |
809 | QValueList<FolderP> *folders = wrapper->listFolders(); | 810 | QValueList<FolderP> *folders = wrapper->listFolders(); |
810 | QValueList<FolderP>::ConstIterator it; | 811 | QValueList<FolderP>::ConstIterator it; |
811 | MHfolderItem*item = 0; | 812 | MHfolderItem*item = 0; |
812 | MHfolderItem*pmaster = 0; | 813 | MHfolderItem*pmaster = 0; |
813 | QString fname = ""; | 814 | QString fname = ""; |
814 | int pos; | 815 | int pos; |
815 | for ( it = folders->begin(); it!=folders->end(); ++it) | 816 | for ( it = folders->begin(); it!=folders->end(); ++it) |
816 | { | 817 | { |
817 | fname = (*it)->getDisplayName(); | 818 | fname = (*it)->getDisplayName(); |
818 | /* this folder itself */ | 819 | /* this folder itself */ |
819 | if (fname=="/") | 820 | if (fname=="/") |
820 | { | 821 | { |
821 | currentFolders.append(fname); | 822 | currentFolders.append(fname); |
822 | folder = (*it); | 823 | folder = (*it); |
823 | continue; | 824 | continue; |
824 | } | 825 | } |
825 | currentFolders.append(fname); | 826 | currentFolders.append(fname); |
826 | pos = fname.findRev("/"); | 827 | pos = fname.findRev("/"); |
827 | if (pos > 0) | 828 | if (pos > 0) |
828 | { | 829 | { |
829 | fname = fname.left(pos); | 830 | fname = fname.left(pos); |
830 | pmaster = (MHfolderItem*)findSubItem(fname); | 831 | pmaster = (MHfolderItem*)findSubItem(fname); |
831 | } | 832 | } |
832 | else | 833 | else |
833 | { | 834 | { |
834 | pmaster = 0; | 835 | pmaster = 0; |
835 | } | 836 | } |
836 | if (pmaster) | 837 | if (pmaster) |
837 | { | 838 | { |
838 | item = new MHfolderItem( (*it), pmaster, item, this ); | 839 | item = new MHfolderItem( (*it), pmaster, item, this ); |
839 | } | 840 | } |
840 | else | 841 | else |
841 | { | 842 | { |
842 | item = new MHfolderItem( (*it), this , item ); | 843 | item = new MHfolderItem( (*it), this , item ); |
843 | } | 844 | } |
844 | item->setSelectable((*it)->may_select()); | 845 | item->setSelectable((*it)->may_select()); |
845 | } | 846 | } |
846 | delete folders; | 847 | delete folders; |
847 | } | 848 | } |
848 | 849 | ||
849 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 850 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
850 | { | 851 | { |
851 | 852 | ||
852 | return wrapper->fetchBody( mail ); | 853 | return wrapper->fetchBody( mail ); |
853 | } | 854 | } |
854 | 855 | ||
855 | QPopupMenu * MHviewItem::getContextMenu() | 856 | QPopupMenu * MHviewItem::getContextMenu() |
856 | { | 857 | { |
857 | QPopupMenu *m = new QPopupMenu(0); | 858 | QPopupMenu *m = new QPopupMenu(0); |
858 | if (m) | 859 | if (m) |
859 | { | 860 | { |
860 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 861 | m->insertItem(i18n("Refresh folder list"),0); |
861 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 862 | m->insertItem(i18n("Create new folder"),1); |
862 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 863 | m->insertItem(i18n("Delete all mails"),2); |
863 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 864 | m->insertItem(i18n("Move/Copie all mails"),3); |
864 | } | 865 | } |
865 | return m; | 866 | return m; |
866 | } | 867 | } |
867 | 868 | ||
868 | void MHviewItem::createFolder() | 869 | void MHviewItem::createFolder() |
869 | { | 870 | { |
870 | Newmdirdlg ndirdlg(0,0,true); | 871 | Newmdirdlg ndirdlg(0,0,true); |
871 | ndirdlg.showMaximized(); | 872 | ndirdlg.showMaximized(); |
872 | if ( ndirdlg.exec() ) | 873 | if ( ndirdlg.exec() ) |
873 | { | 874 | { |
874 | QString ndir = ndirdlg.Newdir(); | 875 | QString ndir = ndirdlg.Newdir(); |
875 | if (wrapper->createMbox(ndir)) | 876 | if (wrapper->createMbox(ndir)) |
876 | { | 877 | { |
877 | refresh(true); | 878 | refresh(true); |
878 | } | 879 | } |
879 | } | 880 | } |
880 | } | 881 | } |
881 | 882 | ||
882 | void MHviewItem::downloadMails() | 883 | void MHviewItem::downloadMails() |
883 | { | 884 | { |
884 | AccountView*bl = accountView(); | 885 | AccountView*bl = accountView(); |
885 | if (!bl) return; | 886 | if (!bl) return; |
886 | bl->downloadMails(folder,getWrapper()); | 887 | bl->downloadMails(folder,getWrapper()); |
887 | } | 888 | } |
888 | 889 | ||
889 | QStringList MHviewItem::subFolders() | 890 | QStringList MHviewItem::subFolders() |
890 | { | 891 | { |
891 | return currentFolders; | 892 | return currentFolders; |
892 | } | 893 | } |
893 | 894 | ||
894 | void MHviewItem::contextMenuSelected(int which) | 895 | void MHviewItem::contextMenuSelected(int which) |
895 | { | 896 | { |
896 | switch (which) | 897 | switch (which) |
897 | { | 898 | { |
898 | case 0: | 899 | case 0: |
899 | refresh(true); | 900 | refresh(true); |
900 | break; | 901 | break; |
901 | case 1: | 902 | case 1: |
902 | createFolder(); | 903 | createFolder(); |
903 | break; | 904 | break; |
904 | case 2: | 905 | case 2: |
905 | deleteAllMail(getWrapper(),folder); | 906 | deleteAllMail(getWrapper(),folder); |
906 | break; | 907 | break; |
907 | case 3: | 908 | case 3: |
908 | downloadMails(); | 909 | downloadMails(); |
909 | break; | 910 | break; |
910 | default: | 911 | default: |
911 | break; | 912 | break; |
912 | } | 913 | } |
913 | } | 914 | } |
914 | 915 | ||
915 | MHfolderItem::~MHfolderItem() | 916 | MHfolderItem::~MHfolderItem() |
916 | {} | 917 | {} |
917 | 918 | ||
918 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 919 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
919 | : AccountViewItem(folderInit, parent,after ) | 920 | : AccountViewItem(folderInit, parent,after ) |
920 | { | 921 | { |
921 | mbox = parent; | 922 | mbox = parent; |
922 | initName(); | 923 | initName(); |
923 | } | 924 | } |
924 | 925 | ||
925 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 926 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
926 | : AccountViewItem(folderInit, parent,after ) | 927 | : AccountViewItem(folderInit, parent,after ) |
927 | { | 928 | { |
928 | folder = folderInit; | 929 | folder = folderInit; |
929 | mbox = master; | 930 | mbox = master; |
930 | initName(); | 931 | initName(); |
931 | } | 932 | } |
932 | 933 | ||
933 | void MHfolderItem::initName() | 934 | void MHfolderItem::initName() |
934 | { | 935 | { |
935 | QString bName = folder->getDisplayName(); | 936 | QString bName = folder->getDisplayName(); |
936 | if (bName.startsWith("/")&&bName.length()>1) | 937 | if (bName.startsWith("/")&&bName.length()>1) |
937 | { | 938 | { |
938 | bName.replace(0,1,""); | 939 | bName.replace(0,1,""); |
939 | } | 940 | } |
940 | int pos = bName.findRev("/"); | 941 | int pos = bName.findRev("/"); |
941 | if (pos > 0) | 942 | if (pos > 0) |
942 | { | 943 | { |
943 | bName.replace(0,pos+1,""); | 944 | bName.replace(0,pos+1,""); |
944 | } | 945 | } |
945 | if (bName.lower() == "outgoing") | 946 | if (bName.lower() == "outgoing") |
946 | { | 947 | { |
947 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 948 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
948 | } | 949 | } |
949 | else if (bName.lower() == "inbox") | 950 | else if (bName.lower() == "inbox") |
950 | { | 951 | { |
951 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 952 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
952 | } else if (bName.lower() == "drafts") { | 953 | } else if (bName.lower() == "drafts") { |
953 | setPixmap(0, SmallIcon ("edit")); | 954 | setPixmap(0, SmallIcon ("edit")); |
954 | } else { | 955 | } else { |
955 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 956 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
956 | } | 957 | } |
957 | setText( 0, bName ); | 958 | setText( 0, bName ); |
958 | } | 959 | } |
959 | 960 | ||
960 | const FolderP&MHfolderItem::getFolder()const | 961 | const FolderP&MHfolderItem::getFolder()const |
961 | { | 962 | { |
962 | return folder; | 963 | return folder; |
963 | } | 964 | } |
964 | 965 | ||
965 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 966 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
966 | { | 967 | { |
967 | if (folder->may_select()) | 968 | if (folder->may_select()) |
968 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 969 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
969 | } | 970 | } |
970 | 971 | ||
971 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 972 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
972 | { | 973 | { |
973 | return mbox->getWrapper()->fetchBody(aMail); | 974 | return mbox->getWrapper()->fetchBody(aMail); |
974 | } | 975 | } |
975 | 976 | ||
976 | void MHfolderItem::deleteFolder() | 977 | void MHfolderItem::deleteFolder() |
977 | { | 978 | { |
978 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 979 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), |
979 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 980 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), |
980 | QObject::tr("Yes",contextName), | 981 | i18n("Yes"), |
981 | QObject::tr("No",contextName),QString::null,1,1); | 982 | i18n("No"),QString::null,1,1); |
982 | 983 | ||
983 | if (yesno == 0) | 984 | if (yesno == 0) |
984 | { | 985 | { |
985 | if (mbox->getWrapper()->deleteMbox(folder)) | 986 | if (mbox->getWrapper()->deleteMbox(folder)) |
986 | { | 987 | { |
987 | QListView*v=listView(); | 988 | QListView*v=listView(); |
988 | MHviewItem * box = mbox; | 989 | MHviewItem * box = mbox; |
989 | /* be carefull - after that this object is destroyd so don't use | 990 | /* be carefull - after that this object is destroyd so don't use |
990 | * any member of it after that call!!*/ | 991 | * any member of it after that call!!*/ |
991 | mbox->refresh(true); | 992 | mbox->refresh(true); |
992 | if (v) | 993 | if (v) |
993 | { | 994 | { |
994 | v->setSelected(box,true); | 995 | v->setSelected(box,true); |
995 | } | 996 | } |
996 | } | 997 | } |
997 | } | 998 | } |
998 | } | 999 | } |
999 | 1000 | ||
1000 | QPopupMenu * MHfolderItem::getContextMenu() | 1001 | QPopupMenu * MHfolderItem::getContextMenu() |
1001 | { | 1002 | { |
1002 | QPopupMenu *m = new QPopupMenu(0); | 1003 | QPopupMenu *m = new QPopupMenu(0); |
1003 | if (m) | 1004 | if (m) |
1004 | { | 1005 | { |
1005 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 1006 | m->insertItem(i18n("Move/Copie all mails"),2); |
1006 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 1007 | m->insertItem(i18n("Delete all mails"),0); |
1007 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 1008 | m->insertItem(i18n("Create new subfolder"),3); |
1008 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 1009 | m->insertItem(i18n("Delete folder"),1); |
1009 | } | 1010 | } |
1010 | return m; | 1011 | return m; |
1011 | } | 1012 | } |
1012 | 1013 | ||
1013 | void MHfolderItem::downloadMails() | 1014 | void MHfolderItem::downloadMails() |
1014 | { | 1015 | { |
1015 | AccountView*bl = mbox->accountView(); | 1016 | AccountView*bl = mbox->accountView(); |
1016 | if (!bl) return; | 1017 | if (!bl) return; |
1017 | bl->downloadMails(folder,mbox->getWrapper()); | 1018 | bl->downloadMails(folder,mbox->getWrapper()); |
1018 | } | 1019 | } |
1019 | 1020 | ||
1020 | void MHfolderItem::createFolder() | 1021 | void MHfolderItem::createFolder() |
1021 | { | 1022 | { |
1022 | Newmdirdlg ndirdlg(0,0,true); | 1023 | Newmdirdlg ndirdlg(0,0,true); |
1023 | ndirdlg.showMaximized(); | 1024 | ndirdlg.showMaximized(); |
1024 | if (ndirdlg.exec() ) | 1025 | if (ndirdlg.exec() ) |
1025 | { | 1026 | { |
1026 | QString ndir = ndirdlg.Newdir(); | 1027 | QString ndir = ndirdlg.Newdir(); |
1027 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 1028 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
1028 | { | 1029 | { |
1029 | QListView*v=listView(); | 1030 | QListView*v=listView(); |
1030 | MHviewItem * box = mbox; | 1031 | MHviewItem * box = mbox; |
1031 | /* be carefull - after that this object is destroyd so don't use | 1032 | /* be carefull - after that this object is destroyd so don't use |
1032 | * any member of it after that call!!*/ | 1033 | * any member of it after that call!!*/ |
1033 | mbox->refresh(true); | 1034 | mbox->refresh(true); |
1034 | if (v) | 1035 | if (v) |
1035 | { | 1036 | { |
1036 | v->setSelected(box,true); | 1037 | v->setSelected(box,true); |
1037 | } | 1038 | } |
1038 | } | 1039 | } |
1039 | } | 1040 | } |
1040 | } | 1041 | } |
1041 | 1042 | ||
1042 | void MHfolderItem::contextMenuSelected(int which) | 1043 | void MHfolderItem::contextMenuSelected(int which) |
1043 | { | 1044 | { |
1044 | switch(which) | 1045 | switch(which) |
1045 | { | 1046 | { |
1046 | case 0: | 1047 | case 0: |
1047 | deleteAllMail(mbox->getWrapper(),folder); | 1048 | deleteAllMail(mbox->getWrapper(),folder); |
1048 | break; | 1049 | break; |
1049 | case 1: | 1050 | case 1: |
1050 | deleteFolder(); | 1051 | deleteFolder(); |
1051 | break; | 1052 | break; |
1052 | case 2: | 1053 | case 2: |
1053 | downloadMails(); | 1054 | downloadMails(); |
1054 | break; | 1055 | break; |
1055 | case 3: | 1056 | case 3: |
1056 | createFolder(); | 1057 | createFolder(); |
1057 | break; | 1058 | break; |
1058 | default: | 1059 | default: |
1059 | break; | 1060 | break; |
1060 | } | 1061 | } |
1061 | } | 1062 | } |
1062 | 1063 | ||
1063 | bool MHfolderItem::isDraftfolder() | 1064 | bool MHfolderItem::isDraftfolder() |
1064 | { | 1065 | { |
1065 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1066 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1066 | return false; | 1067 | return false; |
1067 | } | 1068 | } |
1068 | 1069 | ||
1069 | /** | 1070 | /** |
1070 | * Generic stuff | 1071 | * Generic stuff |
1071 | */ | 1072 | */ |
1072 | 1073 | ||
1073 | const QString AccountViewItem::contextName="AccountViewItem"; | 1074 | const QString AccountViewItem::contextName="AccountViewItem"; |
1074 | 1075 | ||
1075 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1076 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1076 | : QListViewItem( parent ) | 1077 | : QListViewItem( parent ) |
1077 | { | 1078 | { |
1078 | init(); | 1079 | init(); |
1079 | m_Backlink = parent; | 1080 | m_Backlink = parent; |
1080 | } | 1081 | } |
1081 | 1082 | ||
1082 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1083 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1083 | : QListViewItem( parent),folder(0) | 1084 | : QListViewItem( parent),folder(0) |
1084 | { | 1085 | { |
1085 | init(); | 1086 | init(); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1089 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1089 | :QListViewItem( parent,after ),folder(0) | 1090 | :QListViewItem( parent,after ),folder(0) |
1090 | { | 1091 | { |
1091 | init(); | 1092 | init(); |
1092 | } | 1093 | } |
1093 | 1094 | ||
1094 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1095 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) |
1095 | :QListViewItem( parent,after ),folder(folderInit) | 1096 | :QListViewItem( parent,after ),folder(folderInit) |
1096 | { | 1097 | { |
1097 | init(); | 1098 | init(); |
1098 | } | 1099 | } |
1099 | 1100 | ||
1100 | void AccountViewItem::init() | 1101 | void AccountViewItem::init() |
1101 | { | 1102 | { |
1102 | m_Backlink = 0; | 1103 | m_Backlink = 0; |
1103 | } | 1104 | } |
1104 | 1105 | ||
1105 | AccountViewItem::~AccountViewItem() | 1106 | AccountViewItem::~AccountViewItem() |
1106 | { | 1107 | { |
1107 | folder = 0; | 1108 | folder = 0; |
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | AccountView*AccountViewItem::accountView() | 1111 | AccountView*AccountViewItem::accountView() |
1111 | { | 1112 | { |
1112 | return m_Backlink; | 1113 | return m_Backlink; |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1116 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1116 | { | 1117 | { |
1117 | if (!wrapper) return; | 1118 | if (!wrapper) return; |
1118 | QString fname=""; | 1119 | QString fname=""; |
1119 | if (folder) fname = folder->getDisplayName(); | 1120 | if (folder) fname = folder->getDisplayName(); |
1120 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1121 | int yesno = QMessageBox::warning(0,i18n("Delete all mails"), |
1121 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1122 | i18n("<center>Realy delete all mails in box <br>%1</center>"). |
1122 | arg(fname), | 1123 | arg(fname), |
1123 | QObject::tr("Yes",contextName), | 1124 | i18n("Yes"), |
1124 | QObject::tr("No",contextName),QString::null,1,1); | 1125 | i18n("No"),QString::null,1,1); |
1125 | 1126 | ||
1126 | if (yesno == 0) | 1127 | if (yesno == 0) |
1127 | { | 1128 | { |
1128 | if (wrapper->deleteAllMail(folder)) | 1129 | if (wrapper->deleteAllMail(folder)) |
1129 | { | 1130 | { |
1130 | AccountView * view = (AccountView*)listView(); | 1131 | AccountView * view = (AccountView*)listView(); |
1131 | if (view) view->refreshCurrent(); | 1132 | if (view) view->refreshCurrent(); |
1132 | } | 1133 | } |
1133 | } | 1134 | } |
1134 | } | 1135 | } |
1135 | 1136 | ||
1136 | void AccountViewItem::removeChilds() | 1137 | void AccountViewItem::removeChilds() |
1137 | { | 1138 | { |
1138 | QListViewItem *child = firstChild(); | 1139 | QListViewItem *child = firstChild(); |
1139 | while ( child ) | 1140 | while ( child ) |
1140 | { | 1141 | { |
1141 | QListViewItem *tmp = child; | 1142 | QListViewItem *tmp = child; |
1142 | child = child->nextSibling(); | 1143 | child = child->nextSibling(); |
1143 | delete tmp; | 1144 | delete tmp; |
1144 | } | 1145 | } |
1145 | } | 1146 | } |
1146 | 1147 | ||
1147 | bool AccountViewItem::matchName(const QString&name)const | 1148 | bool AccountViewItem::matchName(const QString&name)const |
1148 | { | 1149 | { |
1149 | if (!folder) return false; | 1150 | if (!folder) return false; |
1150 | return folder->getDisplayName().lower()==name.lower(); | 1151 | return folder->getDisplayName().lower()==name.lower(); |
1151 | } | 1152 | } |
1152 | 1153 | ||
1153 | 1154 | ||
1154 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1155 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1155 | { | 1156 | { |
1156 | AccountViewItem*pitem,*sitem; | 1157 | AccountViewItem*pitem,*sitem; |
1157 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1158 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1158 | else pitem = (AccountViewItem*)start->firstChild(); | 1159 | else pitem = (AccountViewItem*)start->firstChild(); |
1159 | while (pitem) | 1160 | while (pitem) |
1160 | { | 1161 | { |
1161 | if (pitem->matchName(path)) | 1162 | if (pitem->matchName(path)) |
1162 | { | 1163 | { |
1163 | break; | 1164 | break; |
1164 | } | 1165 | } |
1165 | if (pitem->childCount()>0) | 1166 | if (pitem->childCount()>0) |
1166 | { | 1167 | { |
1167 | sitem = findSubItem(path,pitem); | 1168 | sitem = findSubItem(path,pitem); |
1168 | if (sitem) | 1169 | if (sitem) |
1169 | { | 1170 | { |
1170 | pitem = sitem; | 1171 | pitem = sitem; |
1171 | break; | 1172 | break; |
1172 | } | 1173 | } |
1173 | } | 1174 | } |
1174 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1175 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1175 | } | 1176 | } |
1176 | return pitem; | 1177 | return pitem; |
1177 | } | 1178 | } |
1178 | 1179 | ||
1179 | bool AccountViewItem::isDraftfolder() | 1180 | bool AccountViewItem::isDraftfolder() |
1180 | { | 1181 | { |
1181 | return false; | 1182 | return false; |
1182 | } | 1183 | } |
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index de8c5bb..c10d384 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -1,206 +1,207 @@ | |||
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 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qpopupmenu.h> | 16 | #include <qpopupmenu.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qspinbox.h> | 18 | #include <qspinbox.h> |
19 | #include <klocale.h> | ||
19 | 20 | ||
20 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
21 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 22 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
22 | : QListView( parent, name, flags ) | 23 | : QListView( parent, name, flags ) |
23 | { | 24 | { |
24 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 25 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
25 | SLOT( refresh(QListViewItem*) ) ); | 26 | SLOT( refresh(QListViewItem*) ) ); |
26 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 27 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
27 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 28 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
28 | setSorting(0); | 29 | setSorting(0); |
29 | } | 30 | } |
30 | 31 | ||
31 | AccountView::~AccountView() | 32 | AccountView::~AccountView() |
32 | { | 33 | { |
33 | imapAccounts.clear(); | 34 | imapAccounts.clear(); |
34 | mhAccounts.clear(); | 35 | mhAccounts.clear(); |
35 | } | 36 | } |
36 | 37 | ||
37 | void AccountView::slotContextMenu(int id) | 38 | void AccountView::slotContextMenu(int id) |
38 | { | 39 | { |
39 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 40 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
40 | if (!view) return; | 41 | if (!view) return; |
41 | view->contextMenuSelected(id); | 42 | view->contextMenuSelected(id); |
42 | } | 43 | } |
43 | 44 | ||
44 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 45 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
45 | { | 46 | { |
46 | if (button==1) {return;} | 47 | if (button==1) {return;} |
47 | if (!item) return; | 48 | if (!item) return; |
48 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
49 | QPopupMenu*m = view->getContextMenu(); | 50 | QPopupMenu*m = view->getContextMenu(); |
50 | if (!m) return; | 51 | if (!m) return; |
51 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 52 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
52 | m->setFocus(); | 53 | m->setFocus(); |
53 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 54 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
54 | delete m; | 55 | delete m; |
55 | } | 56 | } |
56 | 57 | ||
57 | void AccountView::populate( QList<Account> list ) | 58 | void AccountView::populate( QList<Account> list ) |
58 | { | 59 | { |
59 | clear(); | 60 | clear(); |
60 | 61 | ||
61 | imapAccounts.clear(); | 62 | imapAccounts.clear(); |
62 | mhAccounts.clear(); | 63 | mhAccounts.clear(); |
63 | 64 | ||
64 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 65 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
65 | 66 | ||
66 | Account *it; | 67 | Account *it; |
67 | for ( it = list.first(); it; it = list.next() ) | 68 | for ( it = list.first(); it; it = list.next() ) |
68 | { | 69 | { |
69 | if ( it->getType() == MAILLIB::A_IMAP ) | 70 | if ( it->getType() == MAILLIB::A_IMAP ) |
70 | { | 71 | { |
71 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 72 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
72 | imapAccounts.append(new IMAPviewItem( imap, this )); | 73 | imapAccounts.append(new IMAPviewItem( imap, this )); |
73 | } | 74 | } |
74 | else if ( it->getType() == MAILLIB::A_POP3 ) | 75 | else if ( it->getType() == MAILLIB::A_POP3 ) |
75 | { | 76 | { |
76 | POP3account *pop3 = static_cast<POP3account *>(it); | 77 | POP3account *pop3 = static_cast<POP3account *>(it); |
77 | /* must not be hold 'cause it isn't required */ | 78 | /* must not be hold 'cause it isn't required */ |
78 | (void) new POP3viewItem( pop3, this ); | 79 | (void) new POP3viewItem( pop3, this ); |
79 | } | 80 | } |
80 | else if ( it->getType() == MAILLIB::A_NNTP ) | 81 | else if ( it->getType() == MAILLIB::A_NNTP ) |
81 | { | 82 | { |
82 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 83 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
83 | /* must not be hold 'cause it isn't required */ | 84 | /* must not be hold 'cause it isn't required */ |
84 | (void) new NNTPviewItem( nntp, this ); | 85 | (void) new NNTPviewItem( nntp, this ); |
85 | } | 86 | } |
86 | } | 87 | } |
87 | } | 88 | } |
88 | 89 | ||
89 | void AccountView::refresh(QListViewItem *item) | 90 | void AccountView::refresh(QListViewItem *item) |
90 | { | 91 | { |
91 | if ( item ) | 92 | if ( item ) |
92 | { | 93 | { |
93 | m_currentItem = item; | 94 | m_currentItem = item; |
94 | QValueList<RecMailP> headerlist; | 95 | QValueList<RecMailP> headerlist; |
95 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 96 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
96 | view->refresh(headerlist); | 97 | view->refresh(headerlist); |
97 | emit refreshMailview(headerlist); | 98 | emit refreshMailview(headerlist); |
98 | } | 99 | } |
99 | } | 100 | } |
100 | 101 | ||
101 | void AccountView::refreshCurrent() | 102 | void AccountView::refreshCurrent() |
102 | { | 103 | { |
103 | m_currentItem = currentItem(); | 104 | m_currentItem = currentItem(); |
104 | if ( !m_currentItem ) return; | 105 | if ( !m_currentItem ) return; |
105 | QValueList<RecMailP> headerlist; | 106 | QValueList<RecMailP> headerlist; |
106 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 107 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
107 | view->refresh(headerlist); | 108 | view->refresh(headerlist); |
108 | emit refreshMailview(headerlist); | 109 | emit refreshMailview(headerlist); |
109 | } | 110 | } |
110 | 111 | ||
111 | void AccountView::refreshAll() | 112 | void AccountView::refreshAll() |
112 | { | 113 | { |
113 | } | 114 | } |
114 | 115 | ||
115 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 116 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
116 | { | 117 | { |
117 | QListViewItem*item = selectedItem (); | 118 | QListViewItem*item = selectedItem (); |
118 | if (!item) return new RecBody(); | 119 | if (!item) return new RecBody(); |
119 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 120 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
120 | return view->fetchBody(aMail); | 121 | return view->fetchBody(aMail); |
121 | } | 122 | } |
122 | 123 | ||
123 | void AccountView::setupFolderselect(Selectstore*sels) | 124 | void AccountView::setupFolderselect(Selectstore*sels) |
124 | { | 125 | { |
125 | sels->showMaximized(); | 126 | sels->showMaximized(); |
126 | QStringList sFolders; | 127 | QStringList sFolders; |
127 | unsigned int i = 0; | 128 | unsigned int i = 0; |
128 | for (i=0; i < mhAccounts.count();++i) | 129 | for (i=0; i < mhAccounts.count();++i) |
129 | { | 130 | { |
130 | mhAccounts[i]->refresh(false); | 131 | mhAccounts[i]->refresh(false); |
131 | sFolders = mhAccounts[i]->subFolders(); | 132 | sFolders = mhAccounts[i]->subFolders(); |
132 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 133 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
133 | } | 134 | } |
134 | for (i=0; i < imapAccounts.count();++i) | 135 | for (i=0; i < imapAccounts.count();++i) |
135 | { | 136 | { |
136 | if (imapAccounts[i]->offline()) | 137 | if (imapAccounts[i]->offline()) |
137 | continue; | 138 | continue; |
138 | imapAccounts[i]->refreshFolders(false); | 139 | imapAccounts[i]->refreshFolders(false); |
139 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 140 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
140 | } | 141 | } |
141 | } | 142 | } |
142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 143 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
143 | { | 144 | { |
144 | #if 0 | 145 | #if 0 |
145 | AbstractMail*targetMail = 0; | 146 | AbstractMail*targetMail = 0; |
146 | QString targetFolder = ""; | 147 | QString targetFolder = ""; |
147 | Selectstore sels; | 148 | Selectstore sels; |
148 | setupFolderselect(&sels); | 149 | setupFolderselect(&sels); |
149 | if (!sels.exec()) return; | 150 | if (!sels.exec()) return; |
150 | targetMail = sels.currentMail(); | 151 | targetMail = sels.currentMail(); |
151 | targetFolder = sels.currentFolder(); | 152 | targetFolder = sels.currentFolder(); |
152 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 153 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
153 | targetFolder.isEmpty()) | 154 | targetFolder.isEmpty()) |
154 | { | 155 | { |
155 | return; | 156 | return; |
156 | } | 157 | } |
157 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 158 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
158 | { | 159 | { |
159 | QMessageBox::critical(0,tr("Error creating new Folder"), | 160 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
160 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 161 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
161 | return; | 162 | return; |
162 | } | 163 | } |
163 | int maxsize = 0; | 164 | int maxsize = 0; |
164 | if ( sels.useSize->isChecked()) | 165 | if ( sels.useSize->isChecked()) |
165 | maxsize = sels.sizeSpinBox->value(); | 166 | maxsize = sels.sizeSpinBox->value(); |
166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 167 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
167 | #endif | 168 | #endif |
168 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | 169 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); |
169 | refreshCurrent(); | 170 | refreshCurrent(); |
170 | 171 | ||
171 | } | 172 | } |
172 | 173 | ||
173 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 174 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
174 | { | 175 | { |
175 | AbstractMail*targetMail = 0; | 176 | AbstractMail*targetMail = 0; |
176 | QString targetFolder = ""; | 177 | QString targetFolder = ""; |
177 | Selectstore sels; | 178 | Selectstore sels; |
178 | setupFolderselect(&sels); | 179 | setupFolderselect(&sels); |
179 | if (!sels.exec()) return; | 180 | if (!sels.exec()) return; |
180 | targetMail = sels.currentMail(); | 181 | targetMail = sels.currentMail(); |
181 | targetFolder = sels.currentFolder(); | 182 | targetFolder = sels.currentFolder(); |
182 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 183 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
183 | targetFolder.isEmpty()) | 184 | targetFolder.isEmpty()) |
184 | { | 185 | { |
185 | return; | 186 | return; |
186 | } | 187 | } |
187 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 188 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
188 | { | 189 | { |
189 | QMessageBox::critical(0,tr("Error creating new Folder"), | 190 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
190 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 191 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | int maxsize = 0; | 194 | int maxsize = 0; |
194 | if ( sels.useSize->isChecked()) | 195 | if ( sels.useSize->isChecked()) |
195 | maxsize = sels.sizeSpinBox->value(); | 196 | maxsize = sels.sizeSpinBox->value(); |
196 | 197 | ||
197 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 198 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
198 | refreshCurrent(); | 199 | refreshCurrent(); |
199 | } | 200 | } |
200 | 201 | ||
201 | bool AccountView::currentisDraft() | 202 | bool AccountView::currentisDraft() |
202 | { | 203 | { |
203 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 204 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
204 | if (!view) return false; | 205 | if (!view) return false; |
205 | return view->isDraftfolder(); | 206 | return view->isDraftfolder(); |
206 | } | 207 | } |
diff --git a/kmicromail/addresspicker.cpp b/kmicromail/addresspicker.cpp index ec6da49..f4234b4 100644 --- a/kmicromail/addresspicker.cpp +++ b/kmicromail/addresspicker.cpp | |||
@@ -1,116 +1,116 @@ | |||
1 | 1 | ||
2 | #include "composemail.h" | 2 | #include "composemail.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | //#include <opie2/ocontactaccess.h> | 5 | //#include <opie2/ocontactaccess.h> |
6 | //#include <opie2/opimcontact.h> | 6 | //#include <opie2/opimcontact.h> |
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | /* QT */ | 10 | /* QT */ |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlistbox.h> | 13 | #include <qlistbox.h> |
14 | 14 | ||
15 | /* STD */ | 15 | /* STD */ |
16 | #include <stdlib.h> | 16 | #include <stdlib.h> |
17 | 17 | ||
18 | AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) | 18 | AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) |
19 | : AddressPickerUI( parent, name, modal, flags ) | 19 | : AddressPickerUI( parent, name, modal, flags ) |
20 | { | 20 | { |
21 | okButton->setIconSet( Resource::loadPixmap( "enter" ) ); | 21 | okButton->setIconSet( Resource::loadPixmap( "enter" ) ); |
22 | cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); | 22 | cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); |
23 | 23 | ||
24 | connect(okButton, SIGNAL(clicked()), SLOT(accept())); | 24 | connect(okButton, SIGNAL(clicked()), SLOT(accept())); |
25 | connect(cancelButton, SIGNAL(clicked()), SLOT(close())); | 25 | connect(cancelButton, SIGNAL(clicked()), SLOT(close())); |
26 | qDebug("AddressPicker::AddressPicker pending access KA/PI "); | 26 | qDebug("AddressPicker::AddressPicker pending access KA/PI "); |
27 | #if 0 | 27 | #if 0 |
28 | Opie::OPimContactAccess::List::Iterator it; | 28 | Opie::OPimContactAccess::List::Iterator it; |
29 | 29 | ||
30 | QString lineEmail, lineName, contactLine; | 30 | QString lineEmail, lineName, contactLine; |
31 | /* what name has to set here???? */ | 31 | /* what name has to set here???? */ |
32 | Opie::OPimContactAccess m_contactdb("opiemail"); | 32 | Opie::OPimContactAccess m_contactdb("opiemail"); |
33 | 33 | ||
34 | QStringList mails; | 34 | QStringList mails; |
35 | QString pre,suf; | 35 | QString pre,suf; |
36 | Opie::OPimContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); | 36 | Opie::OPimContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); |
37 | for ( it = m_list.begin(); it != m_list.end(); ++it ) | 37 | for ( it = m_list.begin(); it != m_list.end(); ++it ) |
38 | { | 38 | { |
39 | if ((*it).defaultEmail().length()!=0) | 39 | if ((*it).defaultEmail().length()!=0) |
40 | { | 40 | { |
41 | mails = (*it).emailList(); | 41 | mails = (*it).emailList(); |
42 | if ((*it).fileAs().length()>0) | 42 | if ((*it).fileAs().length()>0) |
43 | { | 43 | { |
44 | pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; | 44 | pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; |
45 | suf = ">"; | 45 | suf = ">"; |
46 | } | 46 | } |
47 | else | 47 | else |
48 | { | 48 | { |
49 | pre = ""; | 49 | pre = ""; |
50 | suf = ""; | 50 | suf = ""; |
51 | } | 51 | } |
52 | QStringList::ConstIterator sit = mails.begin(); | 52 | QStringList::ConstIterator sit = mails.begin(); |
53 | for (;sit!=mails.end();++sit) | 53 | for (;sit!=mails.end();++sit) |
54 | { | 54 | { |
55 | contactLine=pre+(*sit)+suf; | 55 | contactLine=pre+(*sit)+suf; |
56 | addressList->insertItem(contactLine); | 56 | addressList->insertItem(contactLine); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } | 59 | } |
60 | if ( addressList->count() <= 0 ) | 60 | if ( addressList->count() <= 0 ) |
61 | { | 61 | { |
62 | #if 0 | 62 | #if 0 |
63 | // makes this realy sense?? | 63 | // makes this realy sense?? |
64 | addressList->insertItem( | 64 | addressList->insertItem( |
65 | tr( "There are no entries in the addressbook." ) ); | 65 | i18n( "There are no entries in the addressbook." ) ); |
66 | #endif | 66 | #endif |
67 | addressList->setEnabled( false ); | 67 | addressList->setEnabled( false ); |
68 | okButton->setEnabled( false ); | 68 | okButton->setEnabled( false ); |
69 | } | 69 | } |
70 | else | 70 | else |
71 | { | 71 | { |
72 | // addressList->sort(); | 72 | // addressList->sort(); |
73 | } | 73 | } |
74 | #endif | 74 | #endif |
75 | } | 75 | } |
76 | 76 | ||
77 | void AddressPicker::accept() | 77 | void AddressPicker::accept() |
78 | { | 78 | { |
79 | QListBoxItem *item = addressList->firstItem(); | 79 | QListBoxItem *item = addressList->firstItem(); |
80 | QString names; | 80 | QString names; |
81 | 81 | ||
82 | while ( item ) | 82 | while ( item ) |
83 | { | 83 | { |
84 | if ( item->selected() ) | 84 | if ( item->selected() ) |
85 | names += item->text() + ", "; | 85 | names += item->text() + ", "; |
86 | item = item->next(); | 86 | item = item->next(); |
87 | } | 87 | } |
88 | names.replace( names.length() - 2, 2, "" ); | 88 | names.replace( names.length() - 2, 2, "" ); |
89 | 89 | ||
90 | if ( names.isEmpty() ) | 90 | if ( names.isEmpty() ) |
91 | { | 91 | { |
92 | QMessageBox::information(this, tr("Error"), tr("<p>You have to select" | 92 | QMessageBox::information(this, i18n("Error"), i18n("<p>You have to select" |
93 | " at least one address entry.</p>"), tr("Ok")); | 93 | " at least one address entry.</p>"), i18n("Ok")); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | 96 | ||
97 | selectedNames = names; | 97 | selectedNames = names; |
98 | QDialog::accept(); | 98 | QDialog::accept(); |
99 | } | 99 | } |
100 | 100 | ||
101 | QString AddressPicker::getNames() | 101 | QString AddressPicker::getNames() |
102 | { | 102 | { |
103 | QString names = 0; | 103 | QString names = 0; |
104 | 104 | ||
105 | AddressPicker picker(0, 0, true); | 105 | AddressPicker picker(0, 0, true); |
106 | 106 | ||
107 | picker.showMaximized(); | 107 | picker.showMaximized(); |
108 | int ret = picker.exec(); | 108 | int ret = picker.exec(); |
109 | if ( QDialog::Accepted == ret ) | 109 | if ( QDialog::Accepted == ret ) |
110 | { | 110 | { |
111 | return picker.selectedNames; | 111 | return picker.selectedNames; |
112 | } | 112 | } |
113 | 113 | ||
114 | return 0; | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 946e97d..35ad367 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -1,483 +1,483 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | #include "composemail.h" | 3 | #include "composemail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/smtpwrapper.h> | 5 | #include <libmailwrapper/smtpwrapper.h> |
6 | #include <libmailwrapper/storemail.h> | 6 | #include <libmailwrapper/storemail.h> |
7 | #include <libmailwrapper/abstractmail.h> | 7 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/ofiledialog.h> | 11 | //#include <opie2/ofiledialog.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | #include <kfiledialog.h> | 13 | #include <kfiledialog.h> |
14 | //#include <qpe/resource.h> | 14 | //#include <qpe/resource.h> |
15 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
16 | //#include <qpe/contact.h> | 16 | //#include <qpe/contact.h> |
17 | 17 | ||
18 | 18 | ||
19 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
20 | #include <qcheckbox.h> | 20 | #include <qcheckbox.h> |
21 | #include <qtimer.h> | 21 | #include <qtimer.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qmultilineedit.h> | 24 | #include <qmultilineedit.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qtabwidget.h> | 26 | #include <qtabwidget.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <kabc/addresseedialog.h> | 28 | #include <kabc/addresseedialog.h> |
29 | #include <kabc/stdaddressbook.h> | 29 | #include <kabc/stdaddressbook.h> |
30 | #include <kabc/addressee.h> | 30 | #include <kabc/addressee.h> |
31 | #ifdef DESKTOP_VERSION | 31 | #ifdef DESKTOP_VERSION |
32 | #include <kabc/addresseedialog.h> | 32 | #include <kabc/addresseedialog.h> |
33 | #else //DESKTOP_VERSION | 33 | #else //DESKTOP_VERSION |
34 | #include <libkdepim/externalapphandler.h> | 34 | #include <libkdepim/externalapphandler.h> |
35 | #endif //DESKTOP_VERSION | 35 | #endif //DESKTOP_VERSION |
36 | 36 | ||
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | 38 | ||
39 | //using namespace Opie::Core; | 39 | //using namespace Opie::Core; |
40 | //using namespace Opie::Ui; | 40 | //using namespace Opie::Ui; |
41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) | 41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) |
42 | : ComposeMailUI( parent, name, modal ) | 42 | : ComposeMailUI( parent, name, modal ) |
43 | { | 43 | { |
44 | mPickLineEdit = 0; | 44 | mPickLineEdit = 0; |
45 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 45 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
46 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 46 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
47 | settings = s; | 47 | settings = s; |
48 | m_replyid = ""; | 48 | m_replyid = ""; |
49 | if ( KOPrefs::instance()->mUseKapi) { | 49 | if ( KOPrefs::instance()->mUseKapi) { |
50 | KConfig config( locateLocal("config", "kabcrc") ); | 50 | KConfig config( locateLocal("config", "kabcrc") ); |
51 | config.setGroup( "General" ); | 51 | config.setGroup( "General" ); |
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 52 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
53 | 53 | ||
54 | if ( whoami_uid.isEmpty() ) { | 54 | if ( whoami_uid.isEmpty() ) { |
55 | QMessageBox::information( 0, tr( "Hint" ), | 55 | QMessageBox::information( 0, i18n( "Hint" ), |
56 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 56 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
57 | tr( "Ok" ) ); | 57 | i18n( "Ok" ) ); |
58 | 58 | ||
59 | 59 | ||
60 | fillSettings(); | 60 | fillSettings(); |
61 | } else | 61 | } else |
62 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 62 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
63 | 63 | ||
64 | 64 | ||
65 | #ifdef DESKTOP_VERSION | 65 | #ifdef DESKTOP_VERSION |
66 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 66 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
67 | QStringList mails = con.emails(); | 67 | QStringList mails = con.emails(); |
68 | QString defmail = con.preferredEmail(); | 68 | QString defmail = con.preferredEmail(); |
69 | if ( mails.count() == 0) | 69 | if ( mails.count() == 0) |
70 | QMessageBox::information( 0, tr( "Hint" ), | 70 | QMessageBox::information( 0, i18n( "Hint" ), |
71 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 71 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
72 | tr( "Ok" ) ); | 72 | i18n( "Ok" ) ); |
73 | if (defmail.length()!=0) { | 73 | if (defmail.length()!=0) { |
74 | fromBox->insertItem(defmail); | 74 | fromBox->insertItem(defmail); |
75 | } | 75 | } |
76 | QStringList::ConstIterator sit = mails.begin(); | 76 | QStringList::ConstIterator sit = mails.begin(); |
77 | for (;sit!=mails.end();++sit) { | 77 | for (;sit!=mails.end();++sit) { |
78 | if ( (*sit)==defmail) | 78 | if ( (*sit)==defmail) |
79 | continue; | 79 | continue; |
80 | fromBox->insertItem((*sit)); | 80 | fromBox->insertItem((*sit)); |
81 | } | 81 | } |
82 | senderNameEdit->setText(con.formattedName()); | 82 | senderNameEdit->setText(con.formattedName()); |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | } else { | 85 | } else { |
86 | fillSettings(); | 86 | fillSettings(); |
87 | } | 87 | } |
88 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); | 88 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); |
89 | 89 | ||
90 | attList->addColumn( tr( "Name" ) ); | 90 | attList->addColumn( i18n( "Name" ) ); |
91 | attList->addColumn( tr( "Size" ) ); | 91 | attList->addColumn( i18n( "Size" ) ); |
92 | QList<Account> accounts = settings->getAccounts(); | 92 | QList<Account> accounts = settings->getAccounts(); |
93 | 93 | ||
94 | if ( QApplication::desktop()->width() < 320 ) | 94 | if ( QApplication::desktop()->width() < 320 ) |
95 | smtpAccountBox->setMaximumWidth( 80 ); | 95 | smtpAccountBox->setMaximumWidth( 80 ); |
96 | Account *it; | 96 | Account *it; |
97 | for ( it = accounts.first(); it; it = accounts.next() ) { | 97 | for ( it = accounts.first(); it; it = accounts.next() ) { |
98 | if ( it->getType()==MAILLIB::A_SMTP ) { | 98 | if ( it->getType()==MAILLIB::A_SMTP ) { |
99 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 99 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
100 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 100 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
101 | smtpAccounts.append( smtp ); | 101 | smtpAccounts.append( smtp ); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 104 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
105 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 105 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
106 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 106 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
107 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 107 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
108 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 108 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
109 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 109 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
110 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 110 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
111 | mMail = 0; | 111 | mMail = 0; |
112 | warnAttach = true; | 112 | warnAttach = true; |
113 | if ( smtpAccounts.count() > 0 ) { | 113 | if ( smtpAccounts.count() > 0 ) { |
114 | fillValues( smtpAccountBox->currentItem() ); | 114 | fillValues( smtpAccountBox->currentItem() ); |
115 | } else { | 115 | } else { |
116 | QMessageBox::information( 0, tr( "Problem" ), | 116 | QMessageBox::information( 0, i18n( "Problem" ), |
117 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | 117 | i18n( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), |
118 | tr( "Ok" ) ); | 118 | i18n( "Ok" ) ); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 121 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
122 | message->setFont ( KOPrefs::instance()->mComposeFont ); | 122 | message->setFont ( KOPrefs::instance()->mComposeFont ); |
123 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | 123 | message->setWordWrap (QMultiLineEdit::WidgetWidth); |
124 | #ifndef DESKTOP_VERSION | 124 | #ifndef DESKTOP_VERSION |
125 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | 125 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); |
126 | #endif | 126 | #endif |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | void ComposeMail::fillSettings() | 130 | void ComposeMail::fillSettings() |
131 | { | 131 | { |
132 | if ( QApplication::desktop()->width() < 320 ) | 132 | if ( QApplication::desktop()->width() < 320 ) |
133 | fromBox->setMaximumWidth( 100 ); | 133 | fromBox->setMaximumWidth( 100 ); |
134 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | 134 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); |
135 | QStringList::ConstIterator sit = mailList.begin(); | 135 | QStringList::ConstIterator sit = mailList.begin(); |
136 | int pref = 0; | 136 | int pref = 0; |
137 | for (;sit!=mailList.end();++sit) { | 137 | for (;sit!=mailList.end();++sit) { |
138 | fromBox->insertItem((*sit)); | 138 | fromBox->insertItem((*sit)); |
139 | } | 139 | } |
140 | senderNameEdit->setText(KOPrefs::instance()->mName); | 140 | senderNameEdit->setText(KOPrefs::instance()->mName); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | void ComposeMail::saveAsDraft() | 144 | void ComposeMail::saveAsDraft() |
145 | { | 145 | { |
146 | 146 | ||
147 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 147 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
148 | mail->setMail(fromBox->currentText()); | 148 | mail->setMail(fromBox->currentText()); |
149 | mail->setTo( toLine->text() ); | 149 | mail->setTo( toLine->text() ); |
150 | mail->setName(senderNameEdit->text()); | 150 | mail->setName(senderNameEdit->text()); |
151 | mail->setCC( ccLine->text() ); | 151 | mail->setCC( ccLine->text() ); |
152 | mail->setBCC( bccLine->text() ); | 152 | mail->setBCC( bccLine->text() ); |
153 | mail->setReply( replyLine->text() ); | 153 | mail->setReply( replyLine->text() ); |
154 | mail->setSubject( subjectLine->text() ); | 154 | mail->setSubject( subjectLine->text() ); |
155 | if (!m_replyid.isEmpty()) { | 155 | if (!m_replyid.isEmpty()) { |
156 | QStringList ids; | 156 | QStringList ids; |
157 | ids.append(m_replyid); | 157 | ids.append(m_replyid); |
158 | mail->setInreply(ids); | 158 | mail->setInreply(ids); |
159 | } | 159 | } |
160 | QString txt = message->text(); | 160 | QString txt = message->text(); |
161 | if ( !sigMultiLine->text().isEmpty() ) { | 161 | if ( !sigMultiLine->text().isEmpty() ) { |
162 | txt.append( "\n--\n" ); | 162 | txt.append( "\n--\n" ); |
163 | txt.append( sigMultiLine->text() ); | 163 | txt.append( sigMultiLine->text() ); |
164 | } | 164 | } |
165 | mail->setMessage( txt ); | 165 | mail->setMessage( txt ); |
166 | 166 | ||
167 | /* only use the default drafts folder name! */ | 167 | /* only use the default drafts folder name! */ |
168 | Storemail wrapper(AbstractMail::draftFolder()); | 168 | Storemail wrapper(AbstractMail::draftFolder()); |
169 | wrapper.storeMail(mail); | 169 | wrapper.storeMail(mail); |
170 | 170 | ||
171 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 171 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
172 | /* attachments we will ignore! */ | 172 | /* attachments we will ignore! */ |
173 | if ( it != 0 ) { | 173 | if ( it != 0 ) { |
174 | if ( warnAttach ) | 174 | if ( warnAttach ) |
175 | QMessageBox::warning(0,tr("Store message"), | 175 | QMessageBox::warning(0,i18n("Store message"), |
176 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 176 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
177 | warnAttach = false; | 177 | warnAttach = false; |
178 | } | 178 | } |
179 | setStatus( tr("Mail saved as draft!") ); | 179 | setStatus( i18n("Mail saved as draft!") ); |
180 | } | 180 | } |
181 | void ComposeMail::clearStatus() | 181 | void ComposeMail::clearStatus() |
182 | { | 182 | { |
183 | topLevelWidget()->setCaption( tr("Compose mail") ); | 183 | topLevelWidget()->setCaption( i18n("Compose mail") ); |
184 | } | 184 | } |
185 | void ComposeMail::setStatus( QString status ) | 185 | void ComposeMail::setStatus( QString status ) |
186 | { | 186 | { |
187 | topLevelWidget()->setCaption( status ); | 187 | topLevelWidget()->setCaption( status ); |
188 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 188 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
189 | } | 189 | } |
190 | void ComposeMail::pickAddress( ) | 190 | void ComposeMail::pickAddress( ) |
191 | { | 191 | { |
192 | 192 | ||
193 | QLineEdit *line = mPickLineEdit; | 193 | QLineEdit *line = mPickLineEdit; |
194 | if ( line == 0 ) | 194 | if ( line == 0 ) |
195 | return; | 195 | return; |
196 | #ifdef DESKTOP_VERSION | 196 | #ifdef DESKTOP_VERSION |
197 | //qDebug(" ComposeMail::pickAddress "); | 197 | //qDebug(" ComposeMail::pickAddress "); |
198 | QString names ;//= AddressPicker::getNames(); | 198 | QString names ;//= AddressPicker::getNames(); |
199 | 199 | ||
200 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 200 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
201 | uint i=0; | 201 | uint i=0; |
202 | for (i=0; i < list.count(); i++) { | 202 | for (i=0; i < list.count(); i++) { |
203 | if ( !list[i].preferredEmail().isEmpty()) { | 203 | if ( !list[i].preferredEmail().isEmpty()) { |
204 | if ( ! names.isEmpty() ) | 204 | if ( ! names.isEmpty() ) |
205 | names+= ","; | 205 | names+= ","; |
206 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 206 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
207 | 207 | ||
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | if ( line->text().isEmpty() ) { | 212 | if ( line->text().isEmpty() ) { |
213 | line->setText( names ); | 213 | line->setText( names ); |
214 | } else if ( !names.isEmpty() ) { | 214 | } else if ( !names.isEmpty() ) { |
215 | line->setText( line->text() + ", " + names ); | 215 | line->setText( line->text() + ", " + names ); |
216 | } | 216 | } |
217 | #else | 217 | #else |
218 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 218 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
219 | // the result should now arrive through method insertAttendees | 219 | // the result should now arrive through method insertAttendees |
220 | #endif | 220 | #endif |
221 | } | 221 | } |
222 | //the map includes name/email pairs, that comes from Ka/Pi | 222 | //the map includes name/email pairs, that comes from Ka/Pi |
223 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 223 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
224 | { | 224 | { |
225 | //qDebug("ComposeMail::insertAttendees "); | 225 | //qDebug("ComposeMail::insertAttendees "); |
226 | raise(); | 226 | raise(); |
227 | 227 | ||
228 | if ( mPickLineEdit == 0 ) { //whoami received | 228 | if ( mPickLineEdit == 0 ) { //whoami received |
229 | QString defmail = uidList[0]; | 229 | QString defmail = uidList[0]; |
230 | if ( emailList.count() == 0 ) | 230 | if ( emailList.count() == 0 ) |
231 | QMessageBox::information( 0, tr( "Hint" ), | 231 | QMessageBox::information( 0, i18n( "Hint" ), |
232 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 232 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
233 | tr( "Ok" ) ); | 233 | i18n( "Ok" ) ); |
234 | if (defmail.length()!=0) { | 234 | if (defmail.length()!=0) { |
235 | fromBox->insertItem(defmail); | 235 | fromBox->insertItem(defmail); |
236 | } | 236 | } |
237 | QStringList::ConstIterator sit = emailList.begin(); | 237 | QStringList::ConstIterator sit = emailList.begin(); |
238 | int pref = 0; | 238 | int pref = 0; |
239 | for (;sit!=emailList.end();++sit) { | 239 | for (;sit!=emailList.end();++sit) { |
240 | if ( (*sit)==defmail) | 240 | if ( (*sit)==defmail) |
241 | continue; | 241 | continue; |
242 | fromBox->insertItem((*sit)); | 242 | fromBox->insertItem((*sit)); |
243 | } | 243 | } |
244 | senderNameEdit->setText(nameList[0]); | 244 | senderNameEdit->setText(nameList[0]); |
245 | return; | 245 | return; |
246 | } | 246 | } |
247 | QString names ; | 247 | QString names ; |
248 | QLineEdit *line = mPickLineEdit; | 248 | QLineEdit *line = mPickLineEdit; |
249 | if (uid == this->name()) | 249 | if (uid == this->name()) |
250 | { | 250 | { |
251 | for ( int i = 0; i < nameList.count(); i++) | 251 | for ( int i = 0; i < nameList.count(); i++) |
252 | { | 252 | { |
253 | QString _name = nameList[i]; | 253 | QString _name = nameList[i]; |
254 | QString _email = emailList[i]; | 254 | QString _email = emailList[i]; |
255 | QString _uid = uidList[i]; | 255 | QString _uid = uidList[i]; |
256 | if ( ! _email.isEmpty() ) { | 256 | if ( ! _email.isEmpty() ) { |
257 | if ( ! names.isEmpty() ) | 257 | if ( ! names.isEmpty() ) |
258 | names+= ","; | 258 | names+= ","; |
259 | names+= "\""+_name +"\"<" +_email +">"; | 259 | names+= "\""+_name +"\"<" +_email +">"; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | if ( line->text().isEmpty() ) { | 263 | if ( line->text().isEmpty() ) { |
264 | line->setText( names ); | 264 | line->setText( names ); |
265 | } else if ( !names.isEmpty() ) { | 265 | } else if ( !names.isEmpty() ) { |
266 | line->setText( line->text() + ", " + names ); | 266 | line->setText( line->text() + ", " + names ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | void ComposeMail::setTo( const QString & to ) | 270 | void ComposeMail::setTo( const QString & to ) |
271 | { | 271 | { |
272 | toLine->setText( to ); | 272 | toLine->setText( to ); |
273 | } | 273 | } |
274 | 274 | ||
275 | void ComposeMail::setSubject( const QString & subject ) | 275 | void ComposeMail::setSubject( const QString & subject ) |
276 | { | 276 | { |
277 | subjectLine->setText( subject ); | 277 | subjectLine->setText( subject ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void ComposeMail::setInReplyTo( const QString & messageId ) | 280 | void ComposeMail::setInReplyTo( const QString & messageId ) |
281 | { | 281 | { |
282 | m_replyid = messageId; | 282 | m_replyid = messageId; |
283 | } | 283 | } |
284 | 284 | ||
285 | void ComposeMail::setMessage( const QString & text ) | 285 | void ComposeMail::setMessage( const QString & text ) |
286 | { | 286 | { |
287 | message->setText( text ); | 287 | message->setText( text ); |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | void ComposeMail::pickAddressTo() | 291 | void ComposeMail::pickAddressTo() |
292 | { | 292 | { |
293 | mPickLineEdit = toLine; | 293 | mPickLineEdit = toLine; |
294 | pickAddress( ); | 294 | pickAddress( ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void ComposeMail::pickAddressCC() | 297 | void ComposeMail::pickAddressCC() |
298 | { | 298 | { |
299 | mPickLineEdit = ccLine; | 299 | mPickLineEdit = ccLine; |
300 | pickAddress( ); | 300 | pickAddress( ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ComposeMail::pickAddressBCC() | 303 | void ComposeMail::pickAddressBCC() |
304 | { | 304 | { |
305 | mPickLineEdit = bccLine; | 305 | mPickLineEdit = bccLine; |
306 | pickAddress( ); | 306 | pickAddress( ); |
307 | } | 307 | } |
308 | 308 | ||
309 | void ComposeMail::pickAddressReply() | 309 | void ComposeMail::pickAddressReply() |
310 | { | 310 | { |
311 | mPickLineEdit = replyLine; | 311 | mPickLineEdit = replyLine; |
312 | pickAddress( ); | 312 | pickAddress( ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void ComposeMail::fillValues( int ) | 315 | void ComposeMail::fillValues( int ) |
316 | { | 316 | { |
317 | #if 0 | 317 | #if 0 |
318 | SMTPaccount *smtp = smtpAccounts.at( current ); | 318 | SMTPaccount *smtp = smtpAccounts.at( current ); |
319 | ccLine->clear(); | 319 | ccLine->clear(); |
320 | if ( smtp->getUseCC() ) { | 320 | if ( smtp->getUseCC() ) { |
321 | ccLine->setText( smtp->getCC() ); | 321 | ccLine->setText( smtp->getCC() ); |
322 | } | 322 | } |
323 | bccLine->clear(); | 323 | bccLine->clear(); |
324 | if ( smtp->getUseBCC() ) { | 324 | if ( smtp->getUseBCC() ) { |
325 | bccLine->setText( smtp->getBCC() ); | 325 | bccLine->setText( smtp->getBCC() ); |
326 | } | 326 | } |
327 | replyLine->clear(); | 327 | replyLine->clear(); |
328 | if ( smtp->getUseReply() ) { | 328 | if ( smtp->getUseReply() ) { |
329 | replyLine->setText( smtp->getReply() ); | 329 | replyLine->setText( smtp->getReply() ); |
330 | } | 330 | } |
331 | sigMultiLine->setText( smtp->getSignature() ); | 331 | sigMultiLine->setText( smtp->getSignature() ); |
332 | #endif | 332 | #endif |
333 | } | 333 | } |
334 | 334 | ||
335 | void ComposeMail::slotAdjustColumns() | 335 | void ComposeMail::slotAdjustColumns() |
336 | { | 336 | { |
337 | int currPage = tabWidget->currentPageIndex(); | 337 | int currPage = tabWidget->currentPageIndex(); |
338 | 338 | ||
339 | tabWidget->showPage( attachTab ); | 339 | tabWidget->showPage( attachTab ); |
340 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 340 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
341 | attList->setColumnWidth( 1, 80 ); | 341 | attList->setColumnWidth( 1, 80 ); |
342 | 342 | ||
343 | tabWidget->setCurrentPage( currPage ); | 343 | tabWidget->setCurrentPage( currPage ); |
344 | } | 344 | } |
345 | 345 | ||
346 | void ComposeMail::addAttachment() | 346 | void ComposeMail::addAttachment() |
347 | { | 347 | { |
348 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 348 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
349 | if ( !lnk.isEmpty() ) { | 349 | if ( !lnk.isEmpty() ) { |
350 | Attachment *att = new Attachment( lnk ); | 350 | Attachment *att = new Attachment( lnk ); |
351 | (void) new AttachViewItem( attList, att ); | 351 | (void) new AttachViewItem( attList, att ); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | void ComposeMail::removeAttachment() | 355 | void ComposeMail::removeAttachment() |
356 | { | 356 | { |
357 | if ( !attList->currentItem() ) { | 357 | if ( !attList->currentItem() ) { |
358 | QMessageBox::information( this, tr( "Error" ), | 358 | QMessageBox::information( this, i18n( "Error" ), |
359 | tr( "<p>Please select a File.</p>" ), | 359 | i18n( "<p>Please select a File.</p>" ), |
360 | tr( "Ok" ) ); | 360 | i18n( "Ok" ) ); |
361 | } else { | 361 | } else { |
362 | attList->takeItem( attList->currentItem() ); | 362 | attList->takeItem( attList->currentItem() ); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | void ComposeMail::accept() | 366 | void ComposeMail::accept() |
367 | { | 367 | { |
368 | if ( smtpAccountBox->count() == 0 ) { | 368 | if ( smtpAccountBox->count() == 0 ) { |
369 | 369 | ||
370 | reject(); | 370 | reject(); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | if (! checkBoxLater->isChecked() ) { | 374 | if (! checkBoxLater->isChecked() ) { |
375 | int yesno = QMessageBox::warning(0,tr("Stop editing message"), | 375 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), |
376 | tr("Send this message?"), | 376 | i18n("Send this message?"), |
377 | tr("Yes"), | 377 | i18n("Yes"), |
378 | tr("Cancel")); | 378 | i18n("Cancel")); |
379 | 379 | ||
380 | if (yesno == 1) { | 380 | if (yesno == 1) { |
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | #if 0 | 384 | #if 0 |
385 | odebug << "Sending Mail with " | 385 | odebug << "Sending Mail with " |
386 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; | 386 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; |
387 | #endif | 387 | #endif |
388 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 388 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
389 | 389 | ||
390 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 390 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
391 | mail->setMail(fromBox->currentText()); | 391 | mail->setMail(fromBox->currentText()); |
392 | 392 | ||
393 | if ( !toLine->text().isEmpty() ) { | 393 | if ( !toLine->text().isEmpty() ) { |
394 | mail->setTo( toLine->text() ); | 394 | mail->setTo( toLine->text() ); |
395 | } else { | 395 | } else { |
396 | QMessageBox::warning(0,tr("Sending mail"), | 396 | QMessageBox::warning(0,i18n("Sending mail"), |
397 | tr("No Receiver spezified" ) ); | 397 | i18n("No Receiver spezified" ) ); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | 400 | ||
401 | mail->setName(senderNameEdit->text()); | 401 | mail->setName(senderNameEdit->text()); |
402 | mail->setCC( ccLine->text() ); | 402 | mail->setCC( ccLine->text() ); |
403 | mail->setBCC( bccLine->text() ); | 403 | mail->setBCC( bccLine->text() ); |
404 | mail->setReply( replyLine->text() ); | 404 | mail->setReply( replyLine->text() ); |
405 | mail->setSubject( subjectLine->text() ); | 405 | mail->setSubject( subjectLine->text() ); |
406 | if (!m_replyid.isEmpty()) { | 406 | if (!m_replyid.isEmpty()) { |
407 | QStringList ids; | 407 | QStringList ids; |
408 | ids.append(m_replyid); | 408 | ids.append(m_replyid); |
409 | mail->setInreply(ids); | 409 | mail->setInreply(ids); |
410 | } | 410 | } |
411 | QString txt = message->text(); | 411 | QString txt = message->text(); |
412 | if ( !sigMultiLine->text().isEmpty() ) { | 412 | if ( !sigMultiLine->text().isEmpty() ) { |
413 | txt.append( "\n--\n" ); | 413 | txt.append( "\n--\n" ); |
414 | txt.append( sigMultiLine->text() ); | 414 | txt.append( sigMultiLine->text() ); |
415 | } | 415 | } |
416 | mail->setMessage( txt ); | 416 | mail->setMessage( txt ); |
417 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 417 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
418 | while ( it != 0 ) { | 418 | while ( it != 0 ) { |
419 | mail->addAttachment( it->getAttachment() ); | 419 | mail->addAttachment( it->getAttachment() ); |
420 | it = (AttachViewItem *) it->nextSibling(); | 420 | it = (AttachViewItem *) it->nextSibling(); |
421 | } | 421 | } |
422 | 422 | ||
423 | SMTPwrapper wrapper( smtp ); | 423 | SMTPwrapper wrapper( smtp ); |
424 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) | 424 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) |
425 | setStatus( tr ("Mail sent")); | 425 | setStatus( tr ("Mail sent")); |
426 | else { | 426 | else { |
427 | setStatus( tr ("Error: Something went wrong. Nothing sent")); | 427 | setStatus( tr ("Error: Something went wrong. Nothing sent")); |
428 | return; | 428 | return; |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | QDialog::accept(); | 432 | QDialog::accept(); |
433 | } | 433 | } |
434 | 434 | ||
435 | void ComposeMail::reject() | 435 | void ComposeMail::reject() |
436 | { | 436 | { |
437 | //qDebug("ComposeMail::reject() "); | 437 | //qDebug("ComposeMail::reject() "); |
438 | int yesno = QMessageBox::warning(0,tr("Store message?"), | 438 | int yesno = QMessageBox::warning(0,i18n("Store message?"), |
439 | tr("Store message into drafts?\n"), | 439 | i18n("Store message into drafts?\n"), |
440 | tr("Yes"), | 440 | i18n("Yes"), |
441 | tr("No")); | 441 | i18n("No")); |
442 | 442 | ||
443 | //qDebug("button %d ", yesno); | 443 | //qDebug("button %d ", yesno); |
444 | if (yesno == 0) { | 444 | if (yesno == 0) { |
445 | if ( toLine->text().isEmpty() ) { | 445 | if ( toLine->text().isEmpty() ) { |
446 | QMessageBox::warning(0,tr("Sending mail"), | 446 | QMessageBox::warning(0,i18n("Sending mail"), |
447 | tr("No Receiver spezified" ) ); | 447 | i18n("No Receiver spezified" ) ); |
448 | return; | 448 | return; |
449 | } | 449 | } |
450 | saveAsDraft(); | 450 | saveAsDraft(); |
451 | } | 451 | } |
452 | if (yesno == 2) { | 452 | if (yesno == 2) { |
453 | qDebug("return "); | 453 | qDebug("return "); |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | QDialog::reject(); | 456 | QDialog::reject(); |
457 | } | 457 | } |
458 | 458 | ||
459 | ComposeMail::~ComposeMail() | 459 | ComposeMail::~ComposeMail() |
460 | { | 460 | { |
461 | } | 461 | } |
462 | 462 | ||
463 | void ComposeMail::reEditMail(const RecMailP¤t) | 463 | void ComposeMail::reEditMail(const RecMailP¤t) |
464 | { | 464 | { |
465 | RecMailP data = current; | 465 | RecMailP data = current; |
466 | message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); | 466 | message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); |
467 | subjectLine->setText( data->getSubject()); | 467 | subjectLine->setText( data->getSubject()); |
468 | toLine->setText(data->To().join(",")); | 468 | toLine->setText(data->To().join(",")); |
469 | ccLine->setText(data->CC().join(",")); | 469 | ccLine->setText(data->CC().join(",")); |
470 | bccLine->setText(data->Bcc().join(",")); | 470 | bccLine->setText(data->Bcc().join(",")); |
471 | replyLine->setText(data->Replyto()); | 471 | replyLine->setText(data->Replyto()); |
472 | } | 472 | } |
473 | 473 | ||
474 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 474 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
475 | : QListViewItem( parent ) | 475 | : QListViewItem( parent ) |
476 | { | 476 | { |
477 | attachment = att; | 477 | attachment = att; |
478 | if ( !attachment->getPixmap().isNull() ) | 478 | if ( !attachment->getPixmap().isNull() ) |
479 | setPixmap( 0,attachment->getPixmap() ); | 479 | setPixmap( 0,attachment->getPixmap() ); |
480 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 480 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
481 | setText( 1, QString::number( att->getSize() ) ); | 481 | setText( 1, QString::number( att->getSize() ) ); |
482 | } | 482 | } |
483 | 483 | ||
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index 733e38a..7ad4ec8 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp | |||
@@ -1,368 +1,369 @@ | |||
1 | 1 | ||
2 | #include "defines.h" | 2 | #include "defines.h" |
3 | #include "editaccounts.h" | 3 | #include "editaccounts.h" |
4 | #include "kapplication.h" | 4 | #include "kapplication.h" |
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | 10 | ||
11 | #include <qcombobox.h> | 11 | #include <qcombobox.h> |
12 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qlabel.h> | 16 | #include <qlabel.h> |
17 | #include <qtabwidget.h> | 17 | #include <qtabwidget.h> |
18 | #include <qlistview.h> | 18 | #include <qlistview.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <klocale.h> | ||
20 | 21 | ||
21 | #include <libmailwrapper/nntpwrapper.h> | 22 | #include <libmailwrapper/nntpwrapper.h> |
22 | 23 | ||
23 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
24 | 25 | ||
25 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 26 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
26 | : QListViewItem( parent ) | 27 | : QListViewItem( parent ) |
27 | { | 28 | { |
28 | account = a; | 29 | account = a; |
29 | setText( 0, account->getAccountName() ); | 30 | setText( 0, account->getAccountName() ); |
30 | QString ttext = ""; | 31 | QString ttext = ""; |
31 | switch (account->getType()) { | 32 | switch (account->getType()) { |
32 | case MAILLIB::A_NNTP: | 33 | case MAILLIB::A_NNTP: |
33 | ttext="NNTP"; | 34 | ttext="NNTP"; |
34 | break; | 35 | break; |
35 | case MAILLIB::A_POP3: | 36 | case MAILLIB::A_POP3: |
36 | ttext = "POP3"; | 37 | ttext = "POP3"; |
37 | break; | 38 | break; |
38 | case MAILLIB::A_IMAP: | 39 | case MAILLIB::A_IMAP: |
39 | ttext = "IMAP"; | 40 | ttext = "IMAP"; |
40 | break; | 41 | break; |
41 | case MAILLIB::A_SMTP: | 42 | case MAILLIB::A_SMTP: |
42 | ttext = "SMTP"; | 43 | ttext = "SMTP"; |
43 | break; | 44 | break; |
44 | default: | 45 | default: |
45 | ttext = "UNKNOWN"; | 46 | ttext = "UNKNOWN"; |
46 | break; | 47 | break; |
47 | } | 48 | } |
48 | setText( 1, ttext); | 49 | setText( 1, ttext); |
49 | } | 50 | } |
50 | 51 | ||
51 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 52 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
52 | : EditAccountsUI( parent, name, modal, flags ) | 53 | : EditAccountsUI( parent, name, modal, flags ) |
53 | { | 54 | { |
54 | settings = s; | 55 | settings = s; |
55 | 56 | ||
56 | mailList->addColumn( tr( "Account" ) ); | 57 | mailList->addColumn( i18n( "Account" ) ); |
57 | mailList->addColumn( tr( "Type" ) ); | 58 | mailList->addColumn( i18n( "Type" ) ); |
58 | 59 | ||
59 | newsList->addColumn( tr( "Account" ) ); | 60 | newsList->addColumn( i18n( "Account" ) ); |
60 | 61 | ||
61 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 62 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
62 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 63 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
63 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 64 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
64 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 65 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
65 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 66 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
66 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 67 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
67 | 68 | ||
68 | slotFillLists(); | 69 | slotFillLists(); |
69 | } | 70 | } |
70 | 71 | ||
71 | void EditAccounts::slotFillLists() | 72 | void EditAccounts::slotFillLists() |
72 | { | 73 | { |
73 | mailList->clear(); | 74 | mailList->clear(); |
74 | newsList->clear(); | 75 | newsList->clear(); |
75 | 76 | ||
76 | QList<Account> accounts = settings->getAccounts(); | 77 | QList<Account> accounts = settings->getAccounts(); |
77 | Account *it; | 78 | Account *it; |
78 | for ( it = accounts.first(); it; it = accounts.next() ) | 79 | for ( it = accounts.first(); it; it = accounts.next() ) |
79 | { | 80 | { |
80 | if ( it->getType()==MAILLIB::A_NNTP ) | 81 | if ( it->getType()==MAILLIB::A_NNTP ) |
81 | { | 82 | { |
82 | (void) new AccountListItem( newsList, it ); | 83 | (void) new AccountListItem( newsList, it ); |
83 | } | 84 | } |
84 | else | 85 | else |
85 | { | 86 | { |
86 | (void) new AccountListItem( mailList, it ); | 87 | (void) new AccountListItem( mailList, it ); |
87 | } | 88 | } |
88 | } | 89 | } |
89 | } | 90 | } |
90 | 91 | ||
91 | void EditAccounts::slotNewMail() | 92 | void EditAccounts::slotNewMail() |
92 | { | 93 | { |
93 | QString *selection = new QString(); | 94 | QString *selection = new QString(); |
94 | SelectMailType selType( selection, this, 0, true ); | 95 | SelectMailType selType( selection, this, 0, true ); |
95 | selType.show(); | 96 | selType.show(); |
96 | if ( QDialog::Accepted == selType.exec() ) | 97 | if ( QDialog::Accepted == selType.exec() ) |
97 | { | 98 | { |
98 | slotNewAccount( *selection ); | 99 | slotNewAccount( *selection ); |
99 | } | 100 | } |
100 | } | 101 | } |
101 | 102 | ||
102 | void EditAccounts::slotNewAccount( const QString &type ) | 103 | void EditAccounts::slotNewAccount( const QString &type ) |
103 | { | 104 | { |
104 | if ( type.compare( "IMAP" ) == 0 ) | 105 | if ( type.compare( "IMAP" ) == 0 ) |
105 | { | 106 | { |
106 | IMAPaccount *account = new IMAPaccount(); | 107 | IMAPaccount *account = new IMAPaccount(); |
107 | IMAPconfig imap( account, this, 0, true ); | 108 | IMAPconfig imap( account, this, 0, true ); |
108 | imap.showMaximized(); | 109 | imap.showMaximized(); |
109 | if ( QDialog::Accepted == imap.exec() ) | 110 | if ( QDialog::Accepted == imap.exec() ) |
110 | { | 111 | { |
111 | settings->addAccount( account ); | 112 | settings->addAccount( account ); |
112 | account->save(); | 113 | account->save(); |
113 | slotFillLists(); | 114 | slotFillLists(); |
114 | } | 115 | } |
115 | else | 116 | else |
116 | { | 117 | { |
117 | account->remove(); | 118 | account->remove(); |
118 | } | 119 | } |
119 | } | 120 | } |
120 | else if ( type.compare( "POP3" ) == 0 ) | 121 | else if ( type.compare( "POP3" ) == 0 ) |
121 | { | 122 | { |
122 | POP3account *account = new POP3account(); | 123 | POP3account *account = new POP3account(); |
123 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 124 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
124 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 125 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
125 | { | 126 | { |
126 | settings->addAccount( account ); | 127 | settings->addAccount( account ); |
127 | account->save(); | 128 | account->save(); |
128 | slotFillLists(); | 129 | slotFillLists(); |
129 | } | 130 | } |
130 | else | 131 | else |
131 | { | 132 | { |
132 | account->remove(); | 133 | account->remove(); |
133 | } | 134 | } |
134 | } | 135 | } |
135 | else if ( type.compare( "SMTP" ) == 0 ) | 136 | else if ( type.compare( "SMTP" ) == 0 ) |
136 | { | 137 | { |
137 | SMTPaccount *account = new SMTPaccount(); | 138 | SMTPaccount *account = new SMTPaccount(); |
138 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 139 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
139 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 140 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
140 | { | 141 | { |
141 | settings->addAccount( account ); | 142 | settings->addAccount( account ); |
142 | account->save(); | 143 | account->save(); |
143 | slotFillLists(); | 144 | slotFillLists(); |
144 | 145 | ||
145 | } | 146 | } |
146 | else | 147 | else |
147 | { | 148 | { |
148 | account->remove(); | 149 | account->remove(); |
149 | } | 150 | } |
150 | } | 151 | } |
151 | else if ( type.compare( "NNTP" ) == 0 ) | 152 | else if ( type.compare( "NNTP" ) == 0 ) |
152 | { | 153 | { |
153 | NNTPaccount *account = new NNTPaccount(); | 154 | NNTPaccount *account = new NNTPaccount(); |
154 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 155 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
155 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 156 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
156 | { | 157 | { |
157 | settings->addAccount( account ); | 158 | settings->addAccount( account ); |
158 | account->save(); | 159 | account->save(); |
159 | slotFillLists(); | 160 | slotFillLists(); |
160 | } | 161 | } |
161 | else | 162 | else |
162 | { | 163 | { |
163 | account->remove(); | 164 | account->remove(); |
164 | } | 165 | } |
165 | } | 166 | } |
166 | } | 167 | } |
167 | 168 | ||
168 | void EditAccounts::slotEditAccount( Account *account ) | 169 | void EditAccounts::slotEditAccount( Account *account ) |
169 | { | 170 | { |
170 | if ( account->getType() == MAILLIB::A_IMAP ) | 171 | if ( account->getType() == MAILLIB::A_IMAP ) |
171 | { | 172 | { |
172 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 173 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
173 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 174 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
174 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) | 175 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) |
175 | { | 176 | { |
176 | slotFillLists(); | 177 | slotFillLists(); |
177 | } | 178 | } |
178 | } | 179 | } |
179 | else if ( account->getType()==MAILLIB::A_POP3 ) | 180 | else if ( account->getType()==MAILLIB::A_POP3 ) |
180 | { | 181 | { |
181 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 182 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
182 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 183 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
183 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 184 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
184 | { | 185 | { |
185 | slotFillLists(); | 186 | slotFillLists(); |
186 | } | 187 | } |
187 | } | 188 | } |
188 | else if ( account->getType()==MAILLIB::A_SMTP ) | 189 | else if ( account->getType()==MAILLIB::A_SMTP ) |
189 | { | 190 | { |
190 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 191 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
191 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 192 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
192 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 193 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
193 | { | 194 | { |
194 | slotFillLists(); | 195 | slotFillLists(); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | else if ( account->getType()==MAILLIB::A_NNTP) | 198 | else if ( account->getType()==MAILLIB::A_NNTP) |
198 | { | 199 | { |
199 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 200 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
200 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 201 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
201 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 202 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
202 | { | 203 | { |
203 | slotFillLists(); | 204 | slotFillLists(); |
204 | } | 205 | } |
205 | } | 206 | } |
206 | } | 207 | } |
207 | 208 | ||
208 | void EditAccounts::slotDeleteAccount( Account *account ) | 209 | void EditAccounts::slotDeleteAccount( Account *account ) |
209 | { | 210 | { |
210 | if ( QMessageBox::information( this, tr( "Question" ), | 211 | if ( QMessageBox::information( this, i18n( "Question" ), |
211 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 212 | i18n( "<p>Do you really want to delete the selected Account?</p>" ), |
212 | tr( "Yes" ), tr( "No" ) ) == 0 ) | 213 | i18n( "Yes" ), i18n( "No" ) ) == 0 ) |
213 | { | 214 | { |
214 | settings->delAccount( account ); | 215 | settings->delAccount( account ); |
215 | slotFillLists(); | 216 | slotFillLists(); |
216 | } | 217 | } |
217 | } | 218 | } |
218 | 219 | ||
219 | void EditAccounts::slotEditMail() | 220 | void EditAccounts::slotEditMail() |
220 | { | 221 | { |
221 | if ( !mailList->currentItem() ) | 222 | if ( !mailList->currentItem() ) |
222 | { | 223 | { |
223 | QMessageBox::information( this, tr( "Error" ), | 224 | QMessageBox::information( this, i18n( "Error" ), |
224 | tr( "<p>Please select an account.</p>" ), | 225 | i18n( "<p>Please select an account.</p>" ), |
225 | tr( "Ok" ) ); | 226 | i18n( "Ok" ) ); |
226 | return; | 227 | return; |
227 | } | 228 | } |
228 | 229 | ||
229 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 230 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
230 | slotEditAccount( a ); | 231 | slotEditAccount( a ); |
231 | } | 232 | } |
232 | 233 | ||
233 | void EditAccounts::slotDeleteMail() | 234 | void EditAccounts::slotDeleteMail() |
234 | { | 235 | { |
235 | if ( !mailList->currentItem() ) | 236 | if ( !mailList->currentItem() ) |
236 | { | 237 | { |
237 | QMessageBox::information( this, tr( "Error" ), | 238 | QMessageBox::information( this, i18n( "Error" ), |
238 | tr( "<p>Please select an account.</p>" ), | 239 | i18n( "<p>Please select an account.</p>" ), |
239 | tr( "Ok" ) ); | 240 | i18n( "Ok" ) ); |
240 | return; | 241 | return; |
241 | } | 242 | } |
242 | 243 | ||
243 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 244 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
244 | slotDeleteAccount( a ); | 245 | slotDeleteAccount( a ); |
245 | } | 246 | } |
246 | 247 | ||
247 | void EditAccounts::slotNewNews() | 248 | void EditAccounts::slotNewNews() |
248 | { | 249 | { |
249 | slotNewAccount( "NNTP" ); | 250 | slotNewAccount( "NNTP" ); |
250 | } | 251 | } |
251 | 252 | ||
252 | void EditAccounts::slotEditNews() | 253 | void EditAccounts::slotEditNews() |
253 | { | 254 | { |
254 | if ( !newsList->currentItem() ) | 255 | if ( !newsList->currentItem() ) |
255 | { | 256 | { |
256 | QMessageBox::information( this, tr( "Error" ), | 257 | QMessageBox::information( this, i18n( "Error" ), |
257 | tr( "<p>Please select an account.</p>" ), | 258 | i18n( "<p>Please select an account.</p>" ), |
258 | tr( "Ok" ) ); | 259 | i18n( "Ok" ) ); |
259 | return; | 260 | return; |
260 | } | 261 | } |
261 | 262 | ||
262 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 263 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
263 | slotEditAccount( a ); | 264 | slotEditAccount( a ); |
264 | } | 265 | } |
265 | 266 | ||
266 | void EditAccounts::slotDeleteNews() | 267 | void EditAccounts::slotDeleteNews() |
267 | { | 268 | { |
268 | if ( !newsList->currentItem() ) | 269 | if ( !newsList->currentItem() ) |
269 | { | 270 | { |
270 | QMessageBox::information( this, tr( "Error" ), | 271 | QMessageBox::information( this, i18n( "Error" ), |
271 | tr( "<p>Please select an account.</p>" ), | 272 | i18n( "<p>Please select an account.</p>" ), |
272 | tr( "Ok" ) ); | 273 | i18n( "Ok" ) ); |
273 | return; | 274 | return; |
274 | } | 275 | } |
275 | 276 | ||
276 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 277 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
277 | slotDeleteAccount( a ); | 278 | slotDeleteAccount( a ); |
278 | } | 279 | } |
279 | 280 | ||
280 | void EditAccounts::slotAdjustColumns() | 281 | void EditAccounts::slotAdjustColumns() |
281 | { | 282 | { |
282 | int currPage = configTab->currentPageIndex(); | 283 | int currPage = configTab->currentPageIndex(); |
283 | 284 | ||
284 | configTab->showPage( mailTab ); | 285 | configTab->showPage( mailTab ); |
285 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 286 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
286 | mailList->setColumnWidth( 1, 50 ); | 287 | mailList->setColumnWidth( 1, 50 ); |
287 | 288 | ||
288 | configTab->showPage( newsTab ); | 289 | configTab->showPage( newsTab ); |
289 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 290 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
290 | 291 | ||
291 | configTab->setCurrentPage( currPage ); | 292 | configTab->setCurrentPage( currPage ); |
292 | } | 293 | } |
293 | 294 | ||
294 | void EditAccounts::accept() | 295 | void EditAccounts::accept() |
295 | { | 296 | { |
296 | settings->saveAccounts(); | 297 | settings->saveAccounts(); |
297 | 298 | ||
298 | QDialog::accept(); | 299 | QDialog::accept(); |
299 | } | 300 | } |
300 | 301 | ||
301 | /** | 302 | /** |
302 | * SelectMailType | 303 | * SelectMailType |
303 | */ | 304 | */ |
304 | 305 | ||
305 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 306 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
306 | : SelectMailTypeUI( parent, name, modal, flags ) | 307 | : SelectMailTypeUI( parent, name, modal, flags ) |
307 | { | 308 | { |
308 | selected = selection; | 309 | selected = selection; |
309 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 310 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
310 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); | 311 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); |
311 | } | 312 | } |
312 | 313 | ||
313 | void SelectMailType::slotSelection( const QString &sel ) | 314 | void SelectMailType::slotSelection( const QString &sel ) |
314 | { | 315 | { |
315 | selected->replace( 0, selected->length(), sel ); | 316 | selected->replace( 0, selected->length(), sel ); |
316 | } | 317 | } |
317 | 318 | ||
318 | /** | 319 | /** |
319 | * IMAPconfig | 320 | * IMAPconfig |
320 | */ | 321 | */ |
321 | 322 | ||
322 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 323 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
323 | : IMAPconfigUI( parent, name, modal, flags ) | 324 | : IMAPconfigUI( parent, name, modal, flags ) |
324 | { | 325 | { |
325 | data = account; | 326 | data = account; |
326 | 327 | ||
327 | fillValues(); | 328 | fillValues(); |
328 | 329 | ||
329 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 330 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
330 | ComboBox1->insertItem( "Only if available", 0 ); | 331 | ComboBox1->insertItem( "Only if available", 0 ); |
331 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 332 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
332 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 333 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
333 | ComboBox1->insertItem( "Run command instead", 3 ); | 334 | ComboBox1->insertItem( "Run command instead", 3 ); |
334 | CommandEdit->hide(); | 335 | CommandEdit->hide(); |
335 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 336 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
336 | } | 337 | } |
337 | 338 | ||
338 | void IMAPconfig::slotConnectionToggle( int index ) | 339 | void IMAPconfig::slotConnectionToggle( int index ) |
339 | { | 340 | { |
340 | if ( index == 2 ) | 341 | if ( index == 2 ) |
341 | { | 342 | { |
342 | portLine->setText( IMAP_SSL_PORT ); | 343 | portLine->setText( IMAP_SSL_PORT ); |
343 | } | 344 | } |
344 | else if ( index == 3 ) | 345 | else if ( index == 3 ) |
345 | { | 346 | { |
346 | portLine->setText( IMAP_PORT ); | 347 | portLine->setText( IMAP_PORT ); |
347 | CommandEdit->show(); | 348 | CommandEdit->show(); |
348 | } | 349 | } |
349 | else | 350 | else |
350 | { | 351 | { |
351 | portLine->setText( IMAP_PORT ); | 352 | portLine->setText( IMAP_PORT ); |
352 | } | 353 | } |
353 | } | 354 | } |
354 | 355 | ||
355 | void IMAPconfig::fillValues() | 356 | void IMAPconfig::fillValues() |
356 | { | 357 | { |
357 | accountLine->setText( data->getAccountName() ); | 358 | accountLine->setText( data->getAccountName() ); |
358 | serverLine->setText( data->getServer() ); | 359 | serverLine->setText( data->getServer() ); |
359 | portLine->setText( data->getPort() ); | 360 | portLine->setText( data->getPort() ); |
360 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 361 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
361 | userLine->setText( data->getUser() ); | 362 | userLine->setText( data->getUser() ); |
362 | passLine->setText( data->getPassword() ); | 363 | passLine->setText( data->getPassword() ); |
363 | prefixLine->setText(data->getPrefix()); | 364 | prefixLine->setText(data->getPrefix()); |
364 | localFolder->setText( data->getLocalFolder() ); | 365 | localFolder->setText( data->getLocalFolder() ); |
365 | int max = data->getMaxMailSize() ; | 366 | int max = data->getMaxMailSize() ; |
366 | if ( max ) { | 367 | if ( max ) { |
367 | CheckBoxDown->setChecked( true ); | 368 | CheckBoxDown->setChecked( true ); |
368 | SpinBoxDown->setValue ( max ); | 369 | SpinBoxDown->setValue ( max ); |
@@ -462,200 +463,200 @@ void POP3config::accept() | |||
462 | } | 463 | } |
463 | 464 | ||
464 | /** | 465 | /** |
465 | * SMTPconfig | 466 | * SMTPconfig |
466 | */ | 467 | */ |
467 | 468 | ||
468 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 469 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
469 | : SMTPconfigUI( parent, name, modal, flags ) | 470 | : SMTPconfigUI( parent, name, modal, flags ) |
470 | { | 471 | { |
471 | data = account; | 472 | data = account; |
472 | 473 | ||
473 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 474 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
474 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 475 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
475 | 476 | ||
476 | fillValues(); | 477 | fillValues(); |
477 | 478 | ||
478 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 479 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
479 | ComboBox1->insertItem( "Only if available", 0 ); | 480 | ComboBox1->insertItem( "Only if available", 0 ); |
480 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 481 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
481 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 482 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
482 | ComboBox1->insertItem( "Run command instead", 3 ); | 483 | ComboBox1->insertItem( "Run command instead", 3 ); |
483 | CommandEdit->hide(); | 484 | CommandEdit->hide(); |
484 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 485 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
485 | } | 486 | } |
486 | 487 | ||
487 | void SMTPconfig::slotConnectionToggle( int index ) | 488 | void SMTPconfig::slotConnectionToggle( int index ) |
488 | { | 489 | { |
489 | // 2 is ssl connection | 490 | // 2 is ssl connection |
490 | if ( index == 2 ) | 491 | if ( index == 2 ) |
491 | { | 492 | { |
492 | portLine->setText( SMTP_SSL_PORT ); | 493 | portLine->setText( SMTP_SSL_PORT ); |
493 | } | 494 | } |
494 | else if ( index == 3 ) | 495 | else if ( index == 3 ) |
495 | { | 496 | { |
496 | portLine->setText( SMTP_PORT ); | 497 | portLine->setText( SMTP_PORT ); |
497 | CommandEdit->show(); | 498 | CommandEdit->show(); |
498 | } | 499 | } |
499 | else | 500 | else |
500 | { | 501 | { |
501 | portLine->setText( SMTP_PORT ); | 502 | portLine->setText( SMTP_PORT ); |
502 | } | 503 | } |
503 | } | 504 | } |
504 | 505 | ||
505 | void SMTPconfig::fillValues() | 506 | void SMTPconfig::fillValues() |
506 | { | 507 | { |
507 | accountLine->setText( data->getAccountName() ); | 508 | accountLine->setText( data->getAccountName() ); |
508 | serverLine->setText( data->getServer() ); | 509 | serverLine->setText( data->getServer() ); |
509 | portLine->setText( data->getPort() ); | 510 | portLine->setText( data->getPort() ); |
510 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 511 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
511 | loginBox->setChecked( data->getLogin() ); | 512 | loginBox->setChecked( data->getLogin() ); |
512 | userLine->setText( data->getUser() ); | 513 | userLine->setText( data->getUser() ); |
513 | passLine->setText( data->getPassword() ); | 514 | passLine->setText( data->getPassword() ); |
514 | } | 515 | } |
515 | 516 | ||
516 | void SMTPconfig::accept() | 517 | void SMTPconfig::accept() |
517 | { | 518 | { |
518 | data->setAccountName( accountLine->text() ); | 519 | data->setAccountName( accountLine->text() ); |
519 | data->setServer( serverLine->text() ); | 520 | data->setServer( serverLine->text() ); |
520 | data->setPort( portLine->text() ); | 521 | data->setPort( portLine->text() ); |
521 | data->setConnectionType( ComboBox1->currentItem() ); | 522 | data->setConnectionType( ComboBox1->currentItem() ); |
522 | data->setLogin( loginBox->isChecked() ); | 523 | data->setLogin( loginBox->isChecked() ); |
523 | data->setUser( userLine->text() ); | 524 | data->setUser( userLine->text() ); |
524 | data->setPassword( passLine->text() ); | 525 | data->setPassword( passLine->text() ); |
525 | 526 | ||
526 | QDialog::accept(); | 527 | QDialog::accept(); |
527 | } | 528 | } |
528 | 529 | ||
529 | /** | 530 | /** |
530 | * NNTPconfig | 531 | * NNTPconfig |
531 | */ | 532 | */ |
532 | 533 | ||
533 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 534 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
534 | : NNTPconfigUI( parent, name, modal, flags ) | 535 | : NNTPconfigUI( parent, name, modal, flags ) |
535 | { | 536 | { |
536 | data = account; | 537 | data = account; |
537 | 538 | ||
538 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 539 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
539 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 540 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
540 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 541 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
541 | connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); | 542 | connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); |
542 | connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); | 543 | connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); |
543 | fillValues(); | 544 | fillValues(); |
544 | 545 | ||
545 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 546 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
546 | } | 547 | } |
547 | 548 | ||
548 | void NNTPconfig::slotShowSub() | 549 | void NNTPconfig::slotShowSub() |
549 | { | 550 | { |
550 | save(); | 551 | save(); |
551 | data->save(); | 552 | data->save(); |
552 | ListViewGroups->clear(); | 553 | ListViewGroups->clear(); |
553 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 554 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
554 | QCheckListItem *item; | 555 | QCheckListItem *item; |
555 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 556 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
556 | item->setOn( true ); | 557 | item->setOn( true ); |
557 | } | 558 | } |
558 | topLevelWidget()->setCaption( tr("%1 groups subscribed").arg( subscribedGroups.count())); | 559 | topLevelWidget()->setCaption( i18n("%1 groups subscribed").arg( subscribedGroups.count())); |
559 | } | 560 | } |
560 | void NNTPconfig::slotShowFilter() | 561 | void NNTPconfig::slotShowFilter() |
561 | { | 562 | { |
562 | save(); | 563 | save(); |
563 | data->save(); | 564 | data->save(); |
564 | ListViewGroups->clear(); | 565 | ListViewGroups->clear(); |
565 | int count = 0; | 566 | int count = 0; |
566 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { | 567 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { |
567 | QCheckListItem *item; | 568 | QCheckListItem *item; |
568 | if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { | 569 | if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { |
569 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 570 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
570 | ++count; | 571 | ++count; |
571 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 572 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
572 | item->setOn( true ); | 573 | item->setOn( true ); |
573 | } | 574 | } |
574 | } | 575 | } |
575 | } | 576 | } |
576 | topLevelWidget()->setCaption( tr("Filter found %1 groups").arg( count)); | 577 | topLevelWidget()->setCaption( i18n("Filter found %1 groups").arg( count)); |
577 | } | 578 | } |
578 | void NNTPconfig::slotGetNG() { | 579 | void NNTPconfig::slotGetNG() { |
579 | save(); | 580 | save(); |
580 | data->save(); | 581 | data->save(); |
581 | topLevelWidget()->setCaption( tr("Fetching group list...")); | 582 | topLevelWidget()->setCaption( i18n("Fetching group list...")); |
582 | qApp->processEvents(); | 583 | qApp->processEvents(); |
583 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 584 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
584 | allGroups = tmp->listAllNewsgroups(); | 585 | allGroups = tmp->listAllNewsgroups(); |
585 | topLevelWidget()->setCaption( tr("Downloaded %1 group names").arg( allGroups.count())); | 586 | topLevelWidget()->setCaption( i18n("Downloaded %1 group names").arg( allGroups.count())); |
586 | 587 | ||
587 | ListViewGroups->clear(); | 588 | ListViewGroups->clear(); |
588 | 589 | ||
589 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { | 590 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { |
590 | QCheckListItem *item; | 591 | QCheckListItem *item; |
591 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 592 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
592 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 593 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
593 | item->setOn( true ); | 594 | item->setOn( true ); |
594 | 595 | ||
595 | } | 596 | } |
596 | } | 597 | } |
597 | delete tmp; | 598 | delete tmp; |
598 | } | 599 | } |
599 | 600 | ||
600 | void NNTPconfig::slotSSL( bool enabled ) | 601 | void NNTPconfig::slotSSL( bool enabled ) |
601 | { | 602 | { |
602 | if ( enabled ) | 603 | if ( enabled ) |
603 | { | 604 | { |
604 | portLine->setText( NNTP_SSL_PORT ); | 605 | portLine->setText( NNTP_SSL_PORT ); |
605 | } | 606 | } |
606 | else | 607 | else |
607 | { | 608 | { |
608 | portLine->setText( NNTP_PORT ); | 609 | portLine->setText( NNTP_PORT ); |
609 | } | 610 | } |
610 | } | 611 | } |
611 | 612 | ||
612 | void NNTPconfig::fillValues() | 613 | void NNTPconfig::fillValues() |
613 | { | 614 | { |
614 | accountLine->setText( data->getAccountName() ); | 615 | accountLine->setText( data->getAccountName() ); |
615 | serverLine->setText( data->getServer() ); | 616 | serverLine->setText( data->getServer() ); |
616 | portLine->setText( data->getPort() ); | 617 | portLine->setText( data->getPort() ); |
617 | sslBox->setChecked( data->getSSL() ); | 618 | sslBox->setChecked( data->getSSL() ); |
618 | loginBox->setChecked( data->getLogin() ); | 619 | loginBox->setChecked( data->getLogin() ); |
619 | userLine->setText( data->getUser() ); | 620 | userLine->setText( data->getUser() ); |
620 | passLine->setText( data->getPassword() ); | 621 | passLine->setText( data->getPassword() ); |
621 | subscribedGroups = data->getGroups(); | 622 | subscribedGroups = data->getGroups(); |
622 | /* don't forget that - you will overwrite values if user clicks cancel! */ | 623 | /* don't forget that - you will overwrite values if user clicks cancel! */ |
623 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 624 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
624 | QCheckListItem *item; | 625 | QCheckListItem *item; |
625 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 626 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
626 | item->setOn( true ); | 627 | item->setOn( true ); |
627 | } | 628 | } |
628 | } | 629 | } |
629 | 630 | ||
630 | void NNTPconfig::save() | 631 | void NNTPconfig::save() |
631 | { | 632 | { |
632 | data->setAccountName( accountLine->text() ); | 633 | data->setAccountName( accountLine->text() ); |
633 | data->setServer( serverLine->text() ); | 634 | data->setServer( serverLine->text() ); |
634 | data->setPort( portLine->text() ); | 635 | data->setPort( portLine->text() ); |
635 | data->setSSL( sslBox->isChecked() ); | 636 | data->setSSL( sslBox->isChecked() ); |
636 | data->setLogin( loginBox->isChecked() ); | 637 | data->setLogin( loginBox->isChecked() ); |
637 | data->setUser( userLine->text() ); | 638 | data->setUser( userLine->text() ); |
638 | data->setPassword( passLine->text() ); | 639 | data->setPassword( passLine->text() ); |
639 | 640 | ||
640 | QListViewItemIterator list_it( ListViewGroups ); | 641 | QListViewItemIterator list_it( ListViewGroups ); |
641 | 642 | ||
642 | for ( ; list_it.current(); ++list_it ) { | 643 | for ( ; list_it.current(); ++list_it ) { |
643 | 644 | ||
644 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | 645 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { |
645 | if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) | 646 | if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) |
646 | subscribedGroups.append( list_it.current()->text(0) ); | 647 | subscribedGroups.append( list_it.current()->text(0) ); |
647 | } else { | 648 | } else { |
648 | if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) | 649 | if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) |
649 | subscribedGroups.remove( list_it.current()->text(0) ); | 650 | subscribedGroups.remove( list_it.current()->text(0) ); |
650 | } | 651 | } |
651 | 652 | ||
652 | } | 653 | } |
653 | data->setGroups( subscribedGroups ); | 654 | data->setGroups( subscribedGroups ); |
654 | } | 655 | } |
655 | 656 | ||
656 | void NNTPconfig::accept() | 657 | void NNTPconfig::accept() |
657 | { | 658 | { |
658 | save(); | 659 | save(); |
659 | QDialog::accept(); | 660 | QDialog::accept(); |
660 | } | 661 | } |
661 | 662 | ||
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 2d7533c..8ee112c 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,278 +1,278 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
3 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | #include <klocale.h> | |
15 | #include <kdecore/kstandarddirs.h> | 15 | #include <kdecore/kstandarddirs.h> |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | #include <libetpan/mailmime_content.h> | 19 | #include <libetpan/mailmime_content.h> |
20 | #include <libetpan/mailmime.h> | 20 | #include <libetpan/mailmime.h> |
21 | 21 | ||
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 23 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
24 | { | 24 | { |
25 | return new IMAPwrapper(a); | 25 | return new IMAPwrapper(a); |
26 | } | 26 | } |
27 | 27 | ||
28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 28 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
29 | { | 29 | { |
30 | return new POP3wrapper(a); | 30 | return new POP3wrapper(a); |
31 | } | 31 | } |
32 | 32 | ||
33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 33 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
34 | { | 34 | { |
35 | return new NNTPwrapper(a); | 35 | return new NNTPwrapper(a); |
36 | } | 36 | } |
37 | 37 | ||
38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 38 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
39 | { | 39 | { |
40 | return new MHwrapper(a,name); | 40 | return new MHwrapper(a,name); |
41 | } | 41 | } |
42 | 42 | ||
43 | AbstractMail* AbstractMail::getWrapper(Account*a) | 43 | AbstractMail* AbstractMail::getWrapper(Account*a) |
44 | { | 44 | { |
45 | if (!a) return 0; | 45 | if (!a) return 0; |
46 | switch (a->getType()) { | 46 | switch (a->getType()) { |
47 | case MAILLIB::A_IMAP: | 47 | case MAILLIB::A_IMAP: |
48 | return new IMAPwrapper((IMAPaccount*)a); | 48 | return new IMAPwrapper((IMAPaccount*)a); |
49 | break; | 49 | break; |
50 | case MAILLIB::A_POP3: | 50 | case MAILLIB::A_POP3: |
51 | return new POP3wrapper((POP3account*)a); | 51 | return new POP3wrapper((POP3account*)a); |
52 | break; | 52 | break; |
53 | case MAILLIB::A_NNTP: | 53 | case MAILLIB::A_NNTP: |
54 | return new NNTPwrapper((NNTPaccount*)a); | 54 | return new NNTPwrapper((NNTPaccount*)a); |
55 | break; | 55 | break; |
56 | default: | 56 | default: |
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 61 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
62 | { | 62 | { |
63 | // odebug << "Decode string start" << oendl; | 63 | // odebug << "Decode string start" << oendl; |
64 | char*result_text; | 64 | char*result_text; |
65 | size_t index = 0; | 65 | size_t index = 0; |
66 | /* reset for recursive use! */ | 66 | /* reset for recursive use! */ |
67 | size_t target_length = 0; | 67 | size_t target_length = 0; |
68 | result_text = 0; | 68 | result_text = 0; |
69 | int mimetype = MAILMIME_MECHANISM_7BIT; | 69 | int mimetype = MAILMIME_MECHANISM_7BIT; |
70 | if (enc.lower()=="quoted-printable") { | 70 | if (enc.lower()=="quoted-printable") { |
71 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 71 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
72 | } else if (enc.lower()=="base64") { | 72 | } else if (enc.lower()=="base64") { |
73 | mimetype = MAILMIME_MECHANISM_BASE64; | 73 | mimetype = MAILMIME_MECHANISM_BASE64; |
74 | } else if (enc.lower()=="8bit") { | 74 | } else if (enc.lower()=="8bit") { |
75 | mimetype = MAILMIME_MECHANISM_8BIT; | 75 | mimetype = MAILMIME_MECHANISM_8BIT; |
76 | } else if (enc.lower()=="binary") { | 76 | } else if (enc.lower()=="binary") { |
77 | mimetype = MAILMIME_MECHANISM_BINARY; | 77 | mimetype = MAILMIME_MECHANISM_BINARY; |
78 | } | 78 | } |
79 | 79 | ||
80 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 80 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
81 | &result_text,&target_length); | 81 | &result_text,&target_length); |
82 | 82 | ||
83 | encodedString* result = new encodedString(); | 83 | encodedString* result = new encodedString(); |
84 | if (err == MAILIMF_NO_ERROR) { | 84 | if (err == MAILIMF_NO_ERROR) { |
85 | result->setContent(result_text,target_length); | 85 | result->setContent(result_text,target_length); |
86 | } | 86 | } |
87 | //odebug << "Decode string finished" << oendl; | 87 | //odebug << "Decode string finished" << oendl; |
88 | return result; | 88 | return result; |
89 | } | 89 | } |
90 | 90 | ||
91 | QString AbstractMail::convert_String(const char*text) | 91 | QString AbstractMail::convert_String(const char*text) |
92 | { | 92 | { |
93 | size_t index = 0; | 93 | size_t index = 0; |
94 | char*res = 0; | 94 | char*res = 0; |
95 | int err = MAILIMF_NO_ERROR; | 95 | int err = MAILIMF_NO_ERROR; |
96 | 96 | ||
97 | QString result(text); | 97 | QString result(text); |
98 | 98 | ||
99 | err = mailmime_encoded_phrase_parse("iso-8859-1", | 99 | err = mailmime_encoded_phrase_parse("iso-8859-1", |
100 | text, strlen(text),&index, "iso-8859-1",&res); | 100 | text, strlen(text),&index, "iso-8859-1",&res); |
101 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 101 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
102 | result = QString(res); | 102 | result = QString(res); |
103 | } | 103 | } |
104 | //qDebug("convert_String:%s ",result.latin1() ); | 104 | //qDebug("convert_String:%s ",result.latin1() ); |
105 | if (res) free(res); | 105 | if (res) free(res); |
106 | return result; | 106 | return result; |
107 | } | 107 | } |
108 | 108 | ||
109 | /* cp & paste from launcher */ | 109 | /* cp & paste from launcher */ |
110 | QString AbstractMail::gen_attachment_id() | 110 | QString AbstractMail::gen_attachment_id() |
111 | { | 111 | { |
112 | QFile file( "/proc/sys/kernel/random/uuid" ); | 112 | QFile file( "/proc/sys/kernel/random/uuid" ); |
113 | if (!file.open(IO_ReadOnly ) ) | 113 | if (!file.open(IO_ReadOnly ) ) |
114 | return QString::null; | 114 | return QString::null; |
115 | 115 | ||
116 | QTextStream stream(&file); | 116 | QTextStream stream(&file); |
117 | 117 | ||
118 | return "{" + stream.read().stripWhiteSpace() + "}"; | 118 | return "{" + stream.read().stripWhiteSpace() + "}"; |
119 | } | 119 | } |
120 | 120 | ||
121 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 121 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
122 | { | 122 | { |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
125 | 125 | ||
126 | QString AbstractMail::defaultLocalfolder() | 126 | QString AbstractMail::defaultLocalfolder() |
127 | { | 127 | { |
128 | // QString f = getenv( "HOME" ); | 128 | // QString f = getenv( "HOME" ); |
129 | QString f = locateLocal( "data", "kopiemail/localmail"); | 129 | QString f = locateLocal( "data", "kopiemail/localmail"); |
130 | // f += "/Applications/opiemail/localmail"; | 130 | // f += "/Applications/opiemail/localmail"; |
131 | return f; | 131 | return f; |
132 | } | 132 | } |
133 | 133 | ||
134 | QString AbstractMail::draftFolder() | 134 | QString AbstractMail::draftFolder() |
135 | { | 135 | { |
136 | return QString("Drafts"); | 136 | return QString("Drafts"); |
137 | } | 137 | } |
138 | 138 | ||
139 | /* temporary - will be removed when implemented in all classes */ | 139 | /* temporary - will be removed when implemented in all classes */ |
140 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 140 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
141 | { | 141 | { |
142 | } | 142 | } |
143 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 143 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
144 | { | 144 | { |
145 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 145 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
146 | // this is currently re-implemented in pop3wrapper and imapwrapper | 146 | // this is currently re-implemented in pop3wrapper and imapwrapper |
147 | int iii = 0; | 147 | int iii = 0; |
148 | int count = target.count(); | 148 | int count = target.count(); |
149 | QProgressBar wid ( count ); | 149 | QProgressBar wid ( count ); |
150 | wid.setCaption( tr("Deleting ...")); | 150 | wid.setCaption( i18n("Deleting ...")); |
151 | wid.show(); | 151 | wid.show(); |
152 | while (iii < count ) { | 152 | while (iii < count ) { |
153 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 153 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
154 | wid.setProgress( iii ); | 154 | wid.setProgress( iii ); |
155 | wid.raise(); | 155 | wid.raise(); |
156 | qApp->processEvents(); | 156 | qApp->processEvents(); |
157 | RecMailP mail = (*target.at( iii )); | 157 | RecMailP mail = (*target.at( iii )); |
158 | deleteMail(mail); | 158 | deleteMail(mail); |
159 | ++iii; | 159 | ++iii; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | 163 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) |
164 | { | 164 | { |
165 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | 165 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); |
166 | // get local folder | 166 | // get local folder |
167 | Account * acc = getAccount(); | 167 | Account * acc = getAccount(); |
168 | if ( !acc ) return; | 168 | if ( !acc ) return; |
169 | QString lfName = acc->getLocalFolder(); | 169 | QString lfName = acc->getLocalFolder(); |
170 | if ( lfName.isEmpty() ) | 170 | if ( lfName.isEmpty() ) |
171 | lfName = acc->getAccountName(); | 171 | lfName = acc->getAccountName(); |
172 | // create local folder | 172 | // create local folder |
173 | if ( !targetMail->createMbox(lfName)) | 173 | if ( !targetMail->createMbox(lfName)) |
174 | { | 174 | { |
175 | QMessageBox::critical(0,tr("Error creating new Folder"), | 175 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
176 | tr("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | 176 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); |
177 | return; | 177 | return; |
178 | } | 178 | } |
179 | QValueList<RecMailP> t; | 179 | QValueList<RecMailP> t; |
180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | 180 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); |
181 | if ( t.count() == 0 ) { | 181 | if ( t.count() == 0 ) { |
182 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); | 182 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); |
183 | Global::statusMessage(tr("There are no new messages")); | 183 | Global::statusMessage(i18n("There are no new messages")); |
184 | return; | 184 | return; |
185 | } | 185 | } |
186 | QValueList<RecMailP> e; | 186 | QValueList<RecMailP> e; |
187 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | 187 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); |
188 | //qDebug("target has mails %d ", e.count()); | 188 | //qDebug("target has mails %d ", e.count()); |
189 | QValueList<RecMailP> n; | 189 | QValueList<RecMailP> n; |
190 | int iii = 0; | 190 | int iii = 0; |
191 | int count = t.count(); | 191 | int count = t.count(); |
192 | while (iii < count ) { | 192 | while (iii < count ) { |
193 | RecMailP r = (*t.at( iii )); | 193 | RecMailP r = (*t.at( iii )); |
194 | bool found = false; | 194 | bool found = false; |
195 | int jjj = 0; | 195 | int jjj = 0; |
196 | int countE = e.count(); | 196 | int countE = e.count(); |
197 | while (jjj < countE ) { | 197 | while (jjj < countE ) { |
198 | RecMailP re = (*e.at( jjj )); | 198 | RecMailP re = (*e.at( jjj )); |
199 | if ( re->isEqual(r) ) { | 199 | if ( re->isEqual(r) ) { |
200 | found = true; | 200 | found = true; |
201 | break; | 201 | break; |
202 | } | 202 | } |
203 | ++jjj; | 203 | ++jjj; |
204 | } | 204 | } |
205 | if ( !found ) { | 205 | if ( !found ) { |
206 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); | 206 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); |
207 | n.append( r ); | 207 | n.append( r ); |
208 | } | 208 | } |
209 | ++iii; | 209 | ++iii; |
210 | } | 210 | } |
211 | qDebug("Downloaded %d messages ",n.count() ); | 211 | qDebug("Downloaded %d messages ",n.count() ); |
212 | if ( n.count() == 0 ) { | 212 | if ( n.count() == 0 ) { |
213 | Global::statusMessage(tr("There are no new messages")); | 213 | Global::statusMessage(i18n("There are no new messages")); |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | 216 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); |
217 | Global::statusMessage(tr("Downloaded %1 messages").arg(n.count())); | 217 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); |
218 | 218 | ||
219 | #if 0 | 219 | #if 0 |
220 | QValueList<RecMailP> t; | 220 | QValueList<RecMailP> t; |
221 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 221 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
222 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 222 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
223 | #endif | 223 | #endif |
224 | 224 | ||
225 | } | 225 | } |
226 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 226 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
227 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 227 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
228 | { | 228 | { |
229 | QValueList<RecMailP> t; | 229 | QValueList<RecMailP> t; |
230 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 230 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
231 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 231 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
232 | 232 | ||
233 | } | 233 | } |
234 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 234 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
235 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 235 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
236 | { | 236 | { |
237 | encodedString*st = 0; | 237 | encodedString*st = 0; |
238 | int iii = 0; | 238 | int iii = 0; |
239 | int count = t.count(); | 239 | int count = t.count(); |
240 | if ( count == 0 ) | 240 | if ( count == 0 ) |
241 | return; | 241 | return; |
242 | // wel, processevents is qite strange, we need a widget for getting | 242 | // wel, processevents is qite strange, we need a widget for getting |
243 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displaye | 243 | // Global::statusMessage(i18n("Copy2 message %1").arg(iii)); displaye |
244 | 244 | ||
245 | QProgressBar wid ( count ); | 245 | QProgressBar wid ( count ); |
246 | wid.setCaption( tr("Copying ...")); | 246 | wid.setCaption( i18n("Copying...")); |
247 | wid.show(); | 247 | wid.show(); |
248 | while (iii < count ) { | 248 | while (iii < count ) { |
249 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); | 249 | Global::statusMessage(i18n("Copy message %1 of %2").arg(iii).arg(count)); |
250 | wid.setProgress( iii ); | 250 | wid.setProgress( iii ); |
251 | wid.raise(); | 251 | wid.raise(); |
252 | qApp->processEvents(); | 252 | qApp->processEvents(); |
253 | RecMailP r = (*t.at( iii )); | 253 | RecMailP r = (*t.at( iii )); |
254 | st = fetchRawBody(r); | 254 | st = fetchRawBody(r); |
255 | if (st) { | 255 | if (st) { |
256 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 256 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
257 | delete st; | 257 | delete st; |
258 | } | 258 | } |
259 | ++iii; | 259 | ++iii; |
260 | } | 260 | } |
261 | if (moveit) { | 261 | if (moveit) { |
262 | deleteMailList( t ); | 262 | deleteMailList( t ); |
263 | //deleteAllMail(fromFolder); | 263 | //deleteAllMail(fromFolder); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 267 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
268 | { | 268 | { |
269 | encodedString*st = 0; | 269 | encodedString*st = 0; |
270 | st = fetchRawBody(mail); | 270 | st = fetchRawBody(mail); |
271 | if (st) { | 271 | if (st) { |
272 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 272 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
273 | delete st; | 273 | delete st; |
274 | } | 274 | } |
275 | if (moveit) { | 275 | if (moveit) { |
276 | deleteMail(mail); | 276 | deleteMail(mail); |
277 | } | 277 | } |
278 | } | 278 | } |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 8150453..3aec13d 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,432 +1,432 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
28 | { | 28 | { |
29 | logout(); | 29 | logout(); |
30 | } | 30 | } |
31 | 31 | ||
32 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
35 | { | 35 | { |
36 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
37 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
38 | } | 38 | } |
39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
40 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
41 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
42 | return err; | 42 | return err; |
43 | } | 43 | } |
44 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
45 | return err; | 45 | return err; |
46 | } | 46 | } |
47 | 47 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 52 | //qApp->processEvents() |
53 | static int last = 0; | 53 | static int last = 0; |
54 | if ( last != current ) | 54 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
56 | last = current; | 56 | last = current; |
57 | } | 57 | } |
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 1; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
73 | qApp->processEvents(); | 73 | qApp->processEvents(); |
74 | } | 74 | } |
75 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
76 | { | 76 | { |
77 | int err; | 77 | int err; |
78 | bool try_tls; | 78 | bool try_tls; |
79 | mailimap_capability_data * cap_data = 0; | 79 | mailimap_capability_data * cap_data = 0; |
80 | 80 | ||
81 | err = mailimap_capability(m_imap,&cap_data); | 81 | err = mailimap_capability(m_imap,&cap_data); |
82 | if (err != MAILIMAP_NO_ERROR) { | 82 | if (err != MAILIMAP_NO_ERROR) { |
83 | Global::statusMessage("error getting capabilities!"); | 83 | Global::statusMessage("error getting capabilities!"); |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | clistiter * cur; | 86 | clistiter * cur; |
87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
88 | struct mailimap_capability * cap; | 88 | struct mailimap_capability * cap; |
89 | cap = (struct mailimap_capability *)clist_content(cur); | 89 | cap = (struct mailimap_capability *)clist_content(cur); |
90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
92 | try_tls = true; | 92 | try_tls = true; |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | if (cap_data) { | 97 | if (cap_data) { |
98 | mailimap_capability_data_free(cap_data); | 98 | mailimap_capability_data_free(cap_data); |
99 | } | 99 | } |
100 | if (try_tls) { | 100 | if (try_tls) { |
101 | err = mailimap_starttls(m_imap); | 101 | err = mailimap_starttls(m_imap); |
102 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 102 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
103 | Global::statusMessage(tr("Server has no TLS support!")); | 103 | Global::statusMessage(i18n("Server has no TLS support!")); |
104 | try_tls = false; | 104 | try_tls = false; |
105 | } else { | 105 | } else { |
106 | mailstream_low * low; | 106 | mailstream_low * low; |
107 | mailstream_low * new_low; | 107 | mailstream_low * new_low; |
108 | low = mailstream_get_low(m_imap->imap_stream); | 108 | low = mailstream_get_low(m_imap->imap_stream); |
109 | if (!low) { | 109 | if (!low) { |
110 | try_tls = false; | 110 | try_tls = false; |
111 | } else { | 111 | } else { |
112 | int fd = mailstream_low_get_fd(low); | 112 | int fd = mailstream_low_get_fd(low); |
113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
114 | mailstream_low_free(low); | 114 | mailstream_low_free(low); |
115 | mailstream_set_low(m_imap->imap_stream, new_low); | 115 | mailstream_set_low(m_imap->imap_stream, new_low); |
116 | } else { | 116 | } else { |
117 | try_tls = false; | 117 | try_tls = false; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | return try_tls; | 122 | return try_tls; |
123 | } | 123 | } |
124 | 124 | ||
125 | void IMAPwrapper::login() | 125 | void IMAPwrapper::login() |
126 | { | 126 | { |
127 | QString server, user, pass; | 127 | QString server, user, pass; |
128 | uint16_t port; | 128 | uint16_t port; |
129 | int err = MAILIMAP_NO_ERROR; | 129 | int err = MAILIMAP_NO_ERROR; |
130 | 130 | ||
131 | if (account->getOffline()) return; | 131 | if (account->getOffline()) return; |
132 | /* we are connected this moment */ | 132 | /* we are connected this moment */ |
133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
134 | if (m_imap) { | 134 | if (m_imap) { |
135 | err = mailimap_noop(m_imap); | 135 | err = mailimap_noop(m_imap); |
136 | if (err!=MAILIMAP_NO_ERROR) { | 136 | if (err!=MAILIMAP_NO_ERROR) { |
137 | logout(); | 137 | logout(); |
138 | } else { | 138 | } else { |
139 | mailstream_flush(m_imap->imap_stream); | 139 | mailstream_flush(m_imap->imap_stream); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | server = account->getServer(); | 143 | server = account->getServer(); |
144 | port = account->getPort().toUInt(); | 144 | port = account->getPort().toUInt(); |
145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
147 | login.show(); | 147 | login.show(); |
148 | if ( QDialog::Accepted == login.exec() ) { | 148 | if ( QDialog::Accepted == login.exec() ) { |
149 | // ok | 149 | // ok |
150 | user = login.getUser(); | 150 | user = login.getUser(); |
151 | pass = login.getPassword(); | 151 | pass = login.getPassword(); |
152 | } else { | 152 | } else { |
153 | // cancel | 153 | // cancel |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | user = account->getUser(); | 157 | user = account->getUser(); |
158 | pass = account->getPassword(); | 158 | pass = account->getPassword(); |
159 | } | 159 | } |
160 | 160 | ||
161 | m_imap = mailimap_new( 20, &imap_progress ); | 161 | m_imap = mailimap_new( 20, &imap_progress ); |
162 | 162 | ||
163 | /* connect */ | 163 | /* connect */ |
164 | bool ssl = false; | 164 | bool ssl = false; |
165 | bool try_tls = false; | 165 | bool try_tls = false; |
166 | bool force_tls = false; | 166 | bool force_tls = false; |
167 | 167 | ||
168 | if ( account->ConnectionType() == 2 ) { | 168 | if ( account->ConnectionType() == 2 ) { |
169 | ssl = true; | 169 | ssl = true; |
170 | } | 170 | } |
171 | if (account->ConnectionType()==1) { | 171 | if (account->ConnectionType()==1) { |
172 | force_tls = true; | 172 | force_tls = true; |
173 | } | 173 | } |
174 | 174 | ||
175 | if ( ssl ) { | 175 | if ( ssl ) { |
176 | //qDebug("using ssl "); | 176 | //qDebug("using ssl "); |
177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
178 | } else { | 178 | } else { |
179 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 179 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
180 | } | 180 | } |
181 | 181 | ||
182 | if ( err != MAILIMAP_NO_ERROR && | 182 | if ( err != MAILIMAP_NO_ERROR && |
183 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 183 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
184 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 184 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
185 | QString failure = ""; | 185 | QString failure = ""; |
186 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 186 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
187 | failure="Connection refused"; | 187 | failure="Connection refused"; |
188 | } else { | 188 | } else { |
189 | failure="Unknown failure"; | 189 | failure="Unknown failure"; |
190 | } | 190 | } |
191 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 191 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); |
192 | mailimap_free( m_imap ); | 192 | mailimap_free( m_imap ); |
193 | m_imap = 0; | 193 | m_imap = 0; |
194 | return; | 194 | return; |
195 | } | 195 | } |
196 | 196 | ||
197 | if (!ssl) { | 197 | if (!ssl) { |
198 | try_tls = start_tls(force_tls); | 198 | try_tls = start_tls(force_tls); |
199 | } | 199 | } |
200 | 200 | ||
201 | bool ok = true; | 201 | bool ok = true; |
202 | if (force_tls && !try_tls) { | 202 | if (force_tls && !try_tls) { |
203 | Global::statusMessage(tr("Server has no TLS support!")); | 203 | Global::statusMessage(i18n("Server has no TLS support!")); |
204 | ok = false; | 204 | ok = false; |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | /* login */ | 208 | /* login */ |
209 | 209 | ||
210 | if (ok) { | 210 | if (ok) { |
211 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 211 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
212 | if ( err != MAILIMAP_NO_ERROR ) { | 212 | if ( err != MAILIMAP_NO_ERROR ) { |
213 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 213 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
214 | ok = false; | 214 | ok = false; |
215 | } | 215 | } |
216 | } | 216 | } |
217 | if (!ok) { | 217 | if (!ok) { |
218 | err = mailimap_close( m_imap ); | 218 | err = mailimap_close( m_imap ); |
219 | mailimap_free( m_imap ); | 219 | mailimap_free( m_imap ); |
220 | m_imap = 0; | 220 | m_imap = 0; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | void IMAPwrapper::logout() | 224 | void IMAPwrapper::logout() |
225 | { | 225 | { |
226 | int err = MAILIMAP_NO_ERROR; | 226 | int err = MAILIMAP_NO_ERROR; |
227 | if (!m_imap) return; | 227 | if (!m_imap) return; |
228 | err = mailimap_logout( m_imap ); | 228 | err = mailimap_logout( m_imap ); |
229 | err = mailimap_close( m_imap ); | 229 | err = mailimap_close( m_imap ); |
230 | mailimap_free( m_imap ); | 230 | mailimap_free( m_imap ); |
231 | m_imap = 0; | 231 | m_imap = 0; |
232 | m_Lastmbox = ""; | 232 | m_Lastmbox = ""; |
233 | } | 233 | } |
234 | 234 | ||
235 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 235 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
236 | { | 236 | { |
237 | 237 | ||
238 | int tryAgain = 1; | 238 | int tryAgain = 1; |
239 | while ( tryAgain >= 0 ) { | 239 | while ( tryAgain >= 0 ) { |
240 | int err = MAILIMAP_NO_ERROR; | 240 | int err = MAILIMAP_NO_ERROR; |
241 | clist *result = 0; | 241 | clist *result = 0; |
242 | clistcell *current; | 242 | clistcell *current; |
243 | mailimap_fetch_type *fetchType = 0; | 243 | mailimap_fetch_type *fetchType = 0; |
244 | mailimap_set *set = 0; | 244 | mailimap_set *set = 0; |
245 | 245 | ||
246 | login(); | 246 | login(); |
247 | if (!m_imap) { | 247 | if (!m_imap) { |
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | /* select mailbox READONLY for operations */ | 250 | /* select mailbox READONLY for operations */ |
251 | err = selectMbox(mailbox); | 251 | err = selectMbox(mailbox); |
252 | if ( err != MAILIMAP_NO_ERROR ) { | 252 | if ( err != MAILIMAP_NO_ERROR ) { |
253 | return; | 253 | return; |
254 | } | 254 | } |
255 | 255 | ||
256 | int last = m_imap->imap_selection_info->sel_exists; | 256 | int last = m_imap->imap_selection_info->sel_exists; |
257 | 257 | ||
258 | if (last == 0) { | 258 | if (last == 0) { |
259 | Global::statusMessage(tr("Mailbox has no mails")); | 259 | Global::statusMessage(i18n("Mailbox has no mails")); |
260 | return; | 260 | return; |
261 | } else { | 261 | } else { |
262 | } | 262 | } |
263 | progress( tr("Fetch ")); | 263 | progress( i18n("Fetch ")); |
264 | mMax = last; | 264 | mMax = last; |
265 | //qDebug("last %d ", last); | 265 | //qDebug("last %d ", last); |
266 | Global::statusMessage(tr("Fetching header list")); | 266 | Global::statusMessage(i18n("Fetching header list")); |
267 | qApp->processEvents(); | 267 | qApp->processEvents(); |
268 | /* the range has to start at 1!!! not with 0!!!! */ | 268 | /* the range has to start at 1!!! not with 0!!!! */ |
269 | //LR the access to web.de imap server is no working with value 1 | 269 | //LR the access to web.de imap server is no working with value 1 |
270 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | 270 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
271 | set = mailimap_set_new_interval( tryAgain, last ); | 271 | set = mailimap_set_new_interval( tryAgain, last ); |
272 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 272 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
273 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 273 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
277 | 277 | ||
278 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 278 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
279 | mailimap_set_free( set ); | 279 | mailimap_set_free( set ); |
280 | mailimap_fetch_type_free( fetchType ); | 280 | mailimap_fetch_type_free( fetchType ); |
281 | 281 | ||
282 | QString date,subject,from; | 282 | QString date,subject,from; |
283 | 283 | ||
284 | if ( err == MAILIMAP_NO_ERROR ) { | 284 | if ( err == MAILIMAP_NO_ERROR ) { |
285 | tryAgain = -1; | 285 | tryAgain = -1; |
286 | mailimap_msg_att * msg_att; | 286 | mailimap_msg_att * msg_att; |
287 | int i = 0; | 287 | int i = 0; |
288 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 288 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
289 | ++i; | 289 | ++i; |
290 | //qDebug("iii %d ",i); | 290 | //qDebug("iii %d ",i); |
291 | msg_att = (mailimap_msg_att*)current->data; | 291 | msg_att = (mailimap_msg_att*)current->data; |
292 | RecMail*m = parse_list_result(msg_att); | 292 | RecMail*m = parse_list_result(msg_att); |
293 | if (m) { | 293 | if (m) { |
294 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 294 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { |
295 | m->setNumber(i); | 295 | m->setNumber(i); |
296 | m->setMbox(mailbox); | 296 | m->setMbox(mailbox); |
297 | m->setWrapper(this); | 297 | m->setWrapper(this); |
298 | target.append(m); | 298 | target.append(m); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 302 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
303 | } else { | 303 | } else { |
304 | --tryAgain; | 304 | --tryAgain; |
305 | --tryAgain;//disabled tryagain by adding this line | 305 | --tryAgain;//disabled tryagain by adding this line |
306 | if ( tryAgain < 0 ) | 306 | if ( tryAgain < 0 ) |
307 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 307 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
308 | else | 308 | else |
309 | qDebug("try again... "); | 309 | qDebug("try again... "); |
310 | } | 310 | } |
311 | 311 | ||
312 | if (result) mailimap_fetch_list_free(result); | 312 | if (result) mailimap_fetch_list_free(result); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 316 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
317 | { | 317 | { |
318 | const char *path, *mask; | 318 | const char *path, *mask; |
319 | int err = MAILIMAP_NO_ERROR; | 319 | int err = MAILIMAP_NO_ERROR; |
320 | clist *result = 0; | 320 | clist *result = 0; |
321 | clistcell *current = 0; | 321 | clistcell *current = 0; |
322 | clistcell*cur_flag = 0; | 322 | clistcell*cur_flag = 0; |
323 | mailimap_mbx_list_flags*bflags = 0; | 323 | mailimap_mbx_list_flags*bflags = 0; |
324 | 324 | ||
325 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 325 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
326 | login(); | 326 | login(); |
327 | if (!m_imap) { | 327 | if (!m_imap) { |
328 | return folders; | 328 | return folders; |
329 | } | 329 | } |
330 | 330 | ||
331 | /* | 331 | /* |
332 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 332 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
333 | * We must not forget to filter them out in next loop! | 333 | * We must not forget to filter them out in next loop! |
334 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 334 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
335 | */ | 335 | */ |
336 | Global::statusMessage(tr("Fetching folder list")); | 336 | Global::statusMessage(i18n("Fetching folder list")); |
337 | qApp->processEvents(); | 337 | qApp->processEvents(); |
338 | QString temp; | 338 | QString temp; |
339 | mask = "INBOX" ; | 339 | mask = "INBOX" ; |
340 | mailimap_mailbox_list *list; | 340 | mailimap_mailbox_list *list; |
341 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 341 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
342 | QString del; | 342 | QString del; |
343 | bool selectable = true; | 343 | bool selectable = true; |
344 | bool no_inferiors = false; | 344 | bool no_inferiors = false; |
345 | if ( err == MAILIMAP_NO_ERROR ) { | 345 | if ( err == MAILIMAP_NO_ERROR ) { |
346 | current = result->first; | 346 | current = result->first; |
347 | for ( int i = result->count; i > 0; i-- ) { | 347 | for ( int i = result->count; i > 0; i-- ) { |
348 | list = (mailimap_mailbox_list *) current->data; | 348 | list = (mailimap_mailbox_list *) current->data; |
349 | // it is better use the deep copy mechanism of qt itself | 349 | // it is better use the deep copy mechanism of qt itself |
350 | // instead of using strdup! | 350 | // instead of using strdup! |
351 | temp = list->mb_name; | 351 | temp = list->mb_name; |
352 | del = list->mb_delimiter; | 352 | del = list->mb_delimiter; |
353 | current = current->next; | 353 | current = current->next; |
354 | if ( (bflags = list->mb_flag) ) { | 354 | if ( (bflags = list->mb_flag) ) { |
355 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 355 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
356 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 356 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
357 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 357 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
358 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 358 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
359 | no_inferiors = true; | 359 | no_inferiors = true; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | } | 362 | } |
363 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 363 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
364 | } | 364 | } |
365 | } else { | 365 | } else { |
366 | qDebug("error fetching folders: "); | 366 | qDebug("error fetching folders: "); |
367 | 367 | ||
368 | } | 368 | } |
369 | mailimap_list_result_free( result ); | 369 | mailimap_list_result_free( result ); |
370 | 370 | ||
371 | /* | 371 | /* |
372 | * second stage - get the other then inbox folders | 372 | * second stage - get the other then inbox folders |
373 | */ | 373 | */ |
374 | mask = "*" ; | 374 | mask = "*" ; |
375 | path = account->getPrefix().latin1(); | 375 | path = account->getPrefix().latin1(); |
376 | if (!path) path = ""; | 376 | if (!path) path = ""; |
377 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 377 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
378 | if ( err == MAILIMAP_NO_ERROR ) { | 378 | if ( err == MAILIMAP_NO_ERROR ) { |
379 | current = result->first; | 379 | current = result->first; |
380 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 380 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
381 | no_inferiors = false; | 381 | no_inferiors = false; |
382 | list = (mailimap_mailbox_list *) current->data; | 382 | list = (mailimap_mailbox_list *) current->data; |
383 | // it is better use the deep copy mechanism of qt itself | 383 | // it is better use the deep copy mechanism of qt itself |
384 | // instead of using strdup! | 384 | // instead of using strdup! |
385 | temp = list->mb_name; | 385 | temp = list->mb_name; |
386 | if (temp.lower()=="inbox") | 386 | if (temp.lower()=="inbox") |
387 | continue; | 387 | continue; |
388 | if (temp.lower()==account->getPrefix().lower()) | 388 | if (temp.lower()==account->getPrefix().lower()) |
389 | continue; | 389 | continue; |
390 | if ( (bflags = list->mb_flag) ) { | 390 | if ( (bflags = list->mb_flag) ) { |
391 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 391 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
392 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 392 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
393 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 393 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
394 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 394 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
395 | no_inferiors = true; | 395 | no_inferiors = true; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | del = list->mb_delimiter; | 399 | del = list->mb_delimiter; |
400 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 400 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
401 | } | 401 | } |
402 | } else { | 402 | } else { |
403 | qDebug("error fetching folders "); | 403 | qDebug("error fetching folders "); |
404 | 404 | ||
405 | } | 405 | } |
406 | if (result) mailimap_list_result_free( result ); | 406 | if (result) mailimap_list_result_free( result ); |
407 | return folders; | 407 | return folders; |
408 | } | 408 | } |
409 | 409 | ||
410 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 410 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
411 | { | 411 | { |
412 | RecMail * m = 0; | 412 | RecMail * m = 0; |
413 | mailimap_msg_att_item *item=0; | 413 | mailimap_msg_att_item *item=0; |
414 | clistcell *current,*c,*cf; | 414 | clistcell *current,*c,*cf; |
415 | mailimap_msg_att_dynamic*flist; | 415 | mailimap_msg_att_dynamic*flist; |
416 | mailimap_flag_fetch*cflag; | 416 | mailimap_flag_fetch*cflag; |
417 | int size; | 417 | int size; |
418 | QBitArray mFlags(7); | 418 | QBitArray mFlags(7); |
419 | QStringList addresslist; | 419 | QStringList addresslist; |
420 | 420 | ||
421 | if (!m_att) { | 421 | if (!m_att) { |
422 | return m; | 422 | return m; |
423 | } | 423 | } |
424 | m = new RecMail(); | 424 | m = new RecMail(); |
425 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 425 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
426 | current = c; | 426 | current = c; |
427 | size = 0; | 427 | size = 0; |
428 | item = (mailimap_msg_att_item*)current->data; | 428 | item = (mailimap_msg_att_item*)current->data; |
429 | if ( !item ) | 429 | if ( !item ) |
430 | continue; | 430 | continue; |
431 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 431 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
432 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 432 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
@@ -876,461 +876,461 @@ void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_ba | |||
876 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 876 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
877 | type = "audio"; | 877 | type = "audio"; |
878 | break; | 878 | break; |
879 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 879 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
880 | type = "image"; | 880 | type = "image"; |
881 | break; | 881 | break; |
882 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 882 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
883 | type = "message"; | 883 | type = "message"; |
884 | break; | 884 | break; |
885 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 885 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
886 | type = "video"; | 886 | type = "video"; |
887 | break; | 887 | break; |
888 | case MAILIMAP_MEDIA_BASIC_OTHER: | 888 | case MAILIMAP_MEDIA_BASIC_OTHER: |
889 | default: | 889 | default: |
890 | if (which->bd_media_basic->med_basic_type) { | 890 | if (which->bd_media_basic->med_basic_type) { |
891 | type = which->bd_media_basic->med_basic_type; | 891 | type = which->bd_media_basic->med_basic_type; |
892 | } else { | 892 | } else { |
893 | type = ""; | 893 | type = ""; |
894 | } | 894 | } |
895 | break; | 895 | break; |
896 | } | 896 | } |
897 | if (which->bd_media_basic->med_subtype) { | 897 | if (which->bd_media_basic->med_subtype) { |
898 | sub = which->bd_media_basic->med_subtype; | 898 | sub = which->bd_media_basic->med_subtype; |
899 | } else { | 899 | } else { |
900 | sub = ""; | 900 | sub = ""; |
901 | } | 901 | } |
902 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 902 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
903 | target_part->setType(type.lower()); | 903 | target_part->setType(type.lower()); |
904 | target_part->setSubtype(sub.lower()); | 904 | target_part->setSubtype(sub.lower()); |
905 | fillBodyFields(target_part,which->bd_fields); | 905 | fillBodyFields(target_part,which->bd_fields); |
906 | } | 906 | } |
907 | 907 | ||
908 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 908 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
909 | { | 909 | { |
910 | if (!which) return; | 910 | if (!which) return; |
911 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 911 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
912 | clistcell*cur; | 912 | clistcell*cur; |
913 | mailimap_single_body_fld_param*param=0; | 913 | mailimap_single_body_fld_param*param=0; |
914 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 914 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
915 | param = (mailimap_single_body_fld_param*)cur->data; | 915 | param = (mailimap_single_body_fld_param*)cur->data; |
916 | if (param) { | 916 | if (param) { |
917 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 917 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
918 | } | 918 | } |
919 | } | 919 | } |
920 | } | 920 | } |
921 | mailimap_body_fld_enc*enc = which->bd_encoding; | 921 | mailimap_body_fld_enc*enc = which->bd_encoding; |
922 | QString encoding(""); | 922 | QString encoding(""); |
923 | switch (enc->enc_type) { | 923 | switch (enc->enc_type) { |
924 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 924 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
925 | encoding = "7bit"; | 925 | encoding = "7bit"; |
926 | break; | 926 | break; |
927 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 927 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
928 | encoding = "8bit"; | 928 | encoding = "8bit"; |
929 | break; | 929 | break; |
930 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 930 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
931 | encoding="binary"; | 931 | encoding="binary"; |
932 | break; | 932 | break; |
933 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 933 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
934 | encoding="base64"; | 934 | encoding="base64"; |
935 | break; | 935 | break; |
936 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 936 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
937 | encoding="quoted-printable"; | 937 | encoding="quoted-printable"; |
938 | break; | 938 | break; |
939 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 939 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
940 | default: | 940 | default: |
941 | if (enc->enc_value) { | 941 | if (enc->enc_value) { |
942 | char*t=enc->enc_value; | 942 | char*t=enc->enc_value; |
943 | encoding=QString(enc->enc_value); | 943 | encoding=QString(enc->enc_value); |
944 | enc->enc_value=0L; | 944 | enc->enc_value=0L; |
945 | free(t); | 945 | free(t); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | if (which->bd_description) { | 948 | if (which->bd_description) { |
949 | target_part->setDescription(QString(which->bd_description)); | 949 | target_part->setDescription(QString(which->bd_description)); |
950 | } | 950 | } |
951 | target_part->setEncoding(encoding); | 951 | target_part->setEncoding(encoding); |
952 | target_part->setSize(which->bd_size); | 952 | target_part->setSize(which->bd_size); |
953 | } | 953 | } |
954 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 954 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
955 | { | 955 | { |
956 | //#if 0 | 956 | //#if 0 |
957 | mailimap_flag_list*flist; | 957 | mailimap_flag_list*flist; |
958 | mailimap_set *set; | 958 | mailimap_set *set; |
959 | mailimap_store_att_flags * store_flags; | 959 | mailimap_store_att_flags * store_flags; |
960 | int err; | 960 | int err; |
961 | login(); | 961 | login(); |
962 | //#endif | 962 | //#endif |
963 | if (!m_imap) { | 963 | if (!m_imap) { |
964 | return; | 964 | return; |
965 | } | 965 | } |
966 | int iii = 0; | 966 | int iii = 0; |
967 | int count = target.count(); | 967 | int count = target.count(); |
968 | // qDebug("imap remove count %d ", count); | 968 | // qDebug("imap remove count %d ", count); |
969 | 969 | ||
970 | 970 | ||
971 | mMax = count; | 971 | mMax = count; |
972 | progress( tr("Delete")); | 972 | progress( i18n("Delete")); |
973 | 973 | ||
974 | QProgressBar wid ( count ); | 974 | QProgressBar wid ( count ); |
975 | wid.setCaption( tr("Deleting ...")); | 975 | wid.setCaption( i18n("Deleting ...")); |
976 | wid.show(); | 976 | wid.show(); |
977 | while (iii < count ) { | 977 | while (iii < count ) { |
978 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 978 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
979 | wid.setProgress( iii ); | 979 | wid.setProgress( iii ); |
980 | wid.raise(); | 980 | wid.raise(); |
981 | qApp->processEvents(); | 981 | qApp->processEvents(); |
982 | RecMailP mail = (*target.at( iii )); | 982 | RecMailP mail = (*target.at( iii )); |
983 | //#if 0 | 983 | //#if 0 |
984 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 984 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
985 | err = selectMbox(mail->getMbox()); | 985 | err = selectMbox(mail->getMbox()); |
986 | if ( err != MAILIMAP_NO_ERROR ) { | 986 | if ( err != MAILIMAP_NO_ERROR ) { |
987 | return; | 987 | return; |
988 | } | 988 | } |
989 | flist = mailimap_flag_list_new_empty(); | 989 | flist = mailimap_flag_list_new_empty(); |
990 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 990 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
991 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 991 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
992 | set = mailimap_set_new_single(mail->getNumber()); | 992 | set = mailimap_set_new_single(mail->getNumber()); |
993 | err = mailimap_store(m_imap,set,store_flags); | 993 | err = mailimap_store(m_imap,set,store_flags); |
994 | mailimap_set_free( set ); | 994 | mailimap_set_free( set ); |
995 | mailimap_store_att_flags_free(store_flags); | 995 | mailimap_store_att_flags_free(store_flags); |
996 | 996 | ||
997 | if (err != MAILIMAP_NO_ERROR) { | 997 | if (err != MAILIMAP_NO_ERROR) { |
998 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 998 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
999 | return; | 999 | return; |
1000 | } | 1000 | } |
1001 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1001 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1002 | /* should we realy do that at this moment? */ | 1002 | /* should we realy do that at this moment? */ |
1003 | 1003 | ||
1004 | // err = mailimap_expunge(m_imap); | 1004 | // err = mailimap_expunge(m_imap); |
1005 | //if (err != MAILIMAP_NO_ERROR) { | 1005 | //if (err != MAILIMAP_NO_ERROR) { |
1006 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | 1006 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1007 | // } | 1007 | // } |
1008 | //#endif | 1008 | //#endif |
1009 | //deleteMail( mail); | 1009 | //deleteMail( mail); |
1010 | ++iii; | 1010 | ++iii; |
1011 | } | 1011 | } |
1012 | //qDebug("Deleting imap mails... "); | 1012 | //qDebug("Deleting imap mails... "); |
1013 | err = mailimap_expunge(m_imap); | 1013 | err = mailimap_expunge(m_imap); |
1014 | if (err != MAILIMAP_NO_ERROR) { | 1014 | if (err != MAILIMAP_NO_ERROR) { |
1015 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | 1015 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1016 | } | 1016 | } |
1017 | } | 1017 | } |
1018 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1018 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1019 | { | 1019 | { |
1020 | mailimap_flag_list*flist; | 1020 | mailimap_flag_list*flist; |
1021 | mailimap_set *set; | 1021 | mailimap_set *set; |
1022 | mailimap_store_att_flags * store_flags; | 1022 | mailimap_store_att_flags * store_flags; |
1023 | int err; | 1023 | int err; |
1024 | login(); | 1024 | login(); |
1025 | if (!m_imap) { | 1025 | if (!m_imap) { |
1026 | return; | 1026 | return; |
1027 | } | 1027 | } |
1028 | err = selectMbox(mail->getMbox()); | 1028 | err = selectMbox(mail->getMbox()); |
1029 | if ( err != MAILIMAP_NO_ERROR ) { | 1029 | if ( err != MAILIMAP_NO_ERROR ) { |
1030 | return; | 1030 | return; |
1031 | } | 1031 | } |
1032 | flist = mailimap_flag_list_new_empty(); | 1032 | flist = mailimap_flag_list_new_empty(); |
1033 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1033 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1034 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1034 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1035 | set = mailimap_set_new_single(mail->getNumber()); | 1035 | set = mailimap_set_new_single(mail->getNumber()); |
1036 | err = mailimap_store(m_imap,set,store_flags); | 1036 | err = mailimap_store(m_imap,set,store_flags); |
1037 | mailimap_set_free( set ); | 1037 | mailimap_set_free( set ); |
1038 | mailimap_store_att_flags_free(store_flags); | 1038 | mailimap_store_att_flags_free(store_flags); |
1039 | 1039 | ||
1040 | if (err != MAILIMAP_NO_ERROR) { | 1040 | if (err != MAILIMAP_NO_ERROR) { |
1041 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1041 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1042 | return; | 1042 | return; |
1043 | } | 1043 | } |
1044 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1044 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1045 | /* should we realy do that at this moment? */ | 1045 | /* should we realy do that at this moment? */ |
1046 | 1046 | ||
1047 | err = mailimap_expunge(m_imap); | 1047 | err = mailimap_expunge(m_imap); |
1048 | if (err != MAILIMAP_NO_ERROR) { | 1048 | if (err != MAILIMAP_NO_ERROR) { |
1049 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1049 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1050 | } | 1050 | } |
1051 | //qDebug("IMAPwrapper::deleteMail 2"); | 1051 | //qDebug("IMAPwrapper::deleteMail 2"); |
1052 | 1052 | ||
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1055 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1056 | { | 1056 | { |
1057 | mailimap_flag_list*flist; | 1057 | mailimap_flag_list*flist; |
1058 | mailimap_set *set; | 1058 | mailimap_set *set; |
1059 | mailimap_store_att_flags * store_flags; | 1059 | mailimap_store_att_flags * store_flags; |
1060 | int err; | 1060 | int err; |
1061 | login(); | 1061 | login(); |
1062 | if (!m_imap) { | 1062 | if (!m_imap) { |
1063 | return; | 1063 | return; |
1064 | } | 1064 | } |
1065 | err = selectMbox(mail->getMbox()); | 1065 | err = selectMbox(mail->getMbox()); |
1066 | if ( err != MAILIMAP_NO_ERROR ) { | 1066 | if ( err != MAILIMAP_NO_ERROR ) { |
1067 | return; | 1067 | return; |
1068 | } | 1068 | } |
1069 | flist = mailimap_flag_list_new_empty(); | 1069 | flist = mailimap_flag_list_new_empty(); |
1070 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1070 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1071 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1071 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1072 | set = mailimap_set_new_single(mail->getNumber()); | 1072 | set = mailimap_set_new_single(mail->getNumber()); |
1073 | err = mailimap_store(m_imap,set,store_flags); | 1073 | err = mailimap_store(m_imap,set,store_flags); |
1074 | mailimap_set_free( set ); | 1074 | mailimap_set_free( set ); |
1075 | mailimap_store_att_flags_free(store_flags); | 1075 | mailimap_store_att_flags_free(store_flags); |
1076 | 1076 | ||
1077 | if (err != MAILIMAP_NO_ERROR) { | 1077 | if (err != MAILIMAP_NO_ERROR) { |
1078 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1078 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1079 | return; | 1079 | return; |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1083 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1084 | { | 1084 | { |
1085 | QString body(""); | 1085 | QString body(""); |
1086 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1086 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1087 | encodedString*r = decode_String(res,enc); | 1087 | encodedString*r = decode_String(res,enc); |
1088 | delete res; | 1088 | delete res; |
1089 | if (r) { | 1089 | if (r) { |
1090 | if (r->Length()>0) { | 1090 | if (r->Length()>0) { |
1091 | body = r->Content(); | 1091 | body = r->Content(); |
1092 | } | 1092 | } |
1093 | delete r; | 1093 | delete r; |
1094 | } | 1094 | } |
1095 | return body; | 1095 | return body; |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1098 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1099 | { | 1099 | { |
1100 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1100 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1103 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1104 | { | 1104 | { |
1105 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1105 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1106 | encodedString*r = decode_String(res,part->Encoding()); | 1106 | encodedString*r = decode_String(res,part->Encoding()); |
1107 | delete res; | 1107 | delete res; |
1108 | return r; | 1108 | return r; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1111 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1112 | { | 1112 | { |
1113 | return fetchRawPart(mail,part->Positionlist(),false); | 1113 | return fetchRawPart(mail,part->Positionlist(),false); |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1116 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1117 | { | 1117 | { |
1118 | login(); | 1118 | login(); |
1119 | if (!m_imap) { | 1119 | if (!m_imap) { |
1120 | return 0; | 1120 | return 0; |
1121 | } | 1121 | } |
1122 | mailimap_flag_list*flist; | 1122 | mailimap_flag_list*flist; |
1123 | mailimap_set *set; | 1123 | mailimap_set *set; |
1124 | mailimap_store_att_flags * store_flags; | 1124 | mailimap_store_att_flags * store_flags; |
1125 | int err = selectMbox(folder->getName()); | 1125 | int err = selectMbox(folder->getName()); |
1126 | if ( err != MAILIMAP_NO_ERROR ) { | 1126 | if ( err != MAILIMAP_NO_ERROR ) { |
1127 | return 0; | 1127 | return 0; |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | int last = m_imap->imap_selection_info->sel_exists; | 1130 | int last = m_imap->imap_selection_info->sel_exists; |
1131 | if (last == 0) { | 1131 | if (last == 0) { |
1132 | Global::statusMessage(tr("Mailbox has no mails!")); | 1132 | Global::statusMessage(i18n("Mailbox has no mails!")); |
1133 | return 0; | 1133 | return 0; |
1134 | } | 1134 | } |
1135 | flist = mailimap_flag_list_new_empty(); | 1135 | flist = mailimap_flag_list_new_empty(); |
1136 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1136 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1137 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1137 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1138 | set = mailimap_set_new_interval( 1, last ); | 1138 | set = mailimap_set_new_interval( 1, last ); |
1139 | err = mailimap_store(m_imap,set,store_flags); | 1139 | err = mailimap_store(m_imap,set,store_flags); |
1140 | mailimap_set_free( set ); | 1140 | mailimap_set_free( set ); |
1141 | mailimap_store_att_flags_free(store_flags); | 1141 | mailimap_store_att_flags_free(store_flags); |
1142 | if (err != MAILIMAP_NO_ERROR) { | 1142 | if (err != MAILIMAP_NO_ERROR) { |
1143 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1143 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1144 | return 0; | 1144 | return 0; |
1145 | } | 1145 | } |
1146 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1146 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1147 | /* should we realy do that at this moment? */ | 1147 | /* should we realy do that at this moment? */ |
1148 | err = mailimap_expunge(m_imap); | 1148 | err = mailimap_expunge(m_imap); |
1149 | if (err != MAILIMAP_NO_ERROR) { | 1149 | if (err != MAILIMAP_NO_ERROR) { |
1150 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1150 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1151 | return 0; | 1151 | return 0; |
1152 | } | 1152 | } |
1153 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1153 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1154 | return 1; | 1154 | return 1; |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1157 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1158 | { | 1158 | { |
1159 | if (folder.length()==0) return 0; | 1159 | if (folder.length()==0) return 0; |
1160 | login(); | 1160 | login(); |
1161 | if (!m_imap) {return 0;} | 1161 | if (!m_imap) {return 0;} |
1162 | QString pre = account->getPrefix(); | 1162 | QString pre = account->getPrefix(); |
1163 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1163 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1164 | pre+=delemiter; | 1164 | pre+=delemiter; |
1165 | } | 1165 | } |
1166 | if (parentfolder) { | 1166 | if (parentfolder) { |
1167 | pre += parentfolder->getDisplayName()+delemiter; | 1167 | pre += parentfolder->getDisplayName()+delemiter; |
1168 | } | 1168 | } |
1169 | pre+=folder; | 1169 | pre+=folder; |
1170 | if (getsubfolder) { | 1170 | if (getsubfolder) { |
1171 | if (delemiter.length()>0) { | 1171 | if (delemiter.length()>0) { |
1172 | pre+=delemiter; | 1172 | pre+=delemiter; |
1173 | } else { | 1173 | } else { |
1174 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1174 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); |
1175 | return 0; | 1175 | return 0; |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | // odebug << "Creating " << pre.latin1() << "" << oendl; | 1178 | // odebug << "Creating " << pre.latin1() << "" << oendl; |
1179 | int res = mailimap_create(m_imap,pre.latin1()); | 1179 | int res = mailimap_create(m_imap,pre.latin1()); |
1180 | if (res != MAILIMAP_NO_ERROR) { | 1180 | if (res != MAILIMAP_NO_ERROR) { |
1181 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1181 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1182 | return 0; | 1182 | return 0; |
1183 | } | 1183 | } |
1184 | return 1; | 1184 | return 1; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1187 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1188 | { | 1188 | { |
1189 | if (!folder) return 0; | 1189 | if (!folder) return 0; |
1190 | login(); | 1190 | login(); |
1191 | if (!m_imap) {return 0;} | 1191 | if (!m_imap) {return 0;} |
1192 | int res = mailimap_delete(m_imap,folder->getName()); | 1192 | int res = mailimap_delete(m_imap,folder->getName()); |
1193 | if (res != MAILIMAP_NO_ERROR) { | 1193 | if (res != MAILIMAP_NO_ERROR) { |
1194 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1194 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1195 | return 0; | 1195 | return 0; |
1196 | } | 1196 | } |
1197 | return 1; | 1197 | return 1; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1200 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1201 | { | 1201 | { |
1202 | mailimap_status_att_list * att_list =0; | 1202 | mailimap_status_att_list * att_list =0; |
1203 | mailimap_mailbox_data_status * status=0; | 1203 | mailimap_mailbox_data_status * status=0; |
1204 | clistiter * cur = 0; | 1204 | clistiter * cur = 0; |
1205 | int r = 0; | 1205 | int r = 0; |
1206 | target_stat.message_count = 0; | 1206 | target_stat.message_count = 0; |
1207 | target_stat.message_unseen = 0; | 1207 | target_stat.message_unseen = 0; |
1208 | target_stat.message_recent = 0; | 1208 | target_stat.message_recent = 0; |
1209 | login(); | 1209 | login(); |
1210 | if (!m_imap) { | 1210 | if (!m_imap) { |
1211 | return; | 1211 | return; |
1212 | } | 1212 | } |
1213 | att_list = mailimap_status_att_list_new_empty(); | 1213 | att_list = mailimap_status_att_list_new_empty(); |
1214 | if (!att_list) return; | 1214 | if (!att_list) return; |
1215 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1215 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1216 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1216 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1217 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1217 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1218 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1218 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1219 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1219 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1220 | for (cur = clist_begin(status->st_info_list); | 1220 | for (cur = clist_begin(status->st_info_list); |
1221 | cur != NULL ; cur = clist_next(cur)) { | 1221 | cur != NULL ; cur = clist_next(cur)) { |
1222 | mailimap_status_info * status_info; | 1222 | mailimap_status_info * status_info; |
1223 | status_info = (mailimap_status_info *)clist_content(cur); | 1223 | status_info = (mailimap_status_info *)clist_content(cur); |
1224 | switch (status_info->st_att) { | 1224 | switch (status_info->st_att) { |
1225 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1225 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1226 | target_stat.message_count = status_info->st_value; | 1226 | target_stat.message_count = status_info->st_value; |
1227 | break; | 1227 | break; |
1228 | case MAILIMAP_STATUS_ATT_RECENT: | 1228 | case MAILIMAP_STATUS_ATT_RECENT: |
1229 | target_stat.message_recent = status_info->st_value; | 1229 | target_stat.message_recent = status_info->st_value; |
1230 | break; | 1230 | break; |
1231 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1231 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1232 | target_stat.message_unseen = status_info->st_value; | 1232 | target_stat.message_unseen = status_info->st_value; |
1233 | break; | 1233 | break; |
1234 | } | 1234 | } |
1235 | } | 1235 | } |
1236 | } else { | 1236 | } else { |
1237 | // odebug << "Error retrieving status" << oendl; | 1237 | // odebug << "Error retrieving status" << oendl; |
1238 | } | 1238 | } |
1239 | if (status) mailimap_mailbox_data_status_free(status); | 1239 | if (status) mailimap_mailbox_data_status_free(status); |
1240 | if (att_list) mailimap_status_att_list_free(att_list); | 1240 | if (att_list) mailimap_status_att_list_free(att_list); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1243 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1244 | { | 1244 | { |
1245 | login(); | 1245 | login(); |
1246 | if (!m_imap) return; | 1246 | if (!m_imap) return; |
1247 | if (!msg) return; | 1247 | if (!msg) return; |
1248 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1248 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1249 | if (r != MAILIMAP_NO_ERROR) { | 1249 | if (r != MAILIMAP_NO_ERROR) { |
1250 | Global::statusMessage("Error storing mail!"); | 1250 | Global::statusMessage("Error storing mail!"); |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1254 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1255 | { | 1255 | { |
1256 | return account->getType(); | 1256 | return account->getType(); |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | const QString&IMAPwrapper::getName()const | 1259 | const QString&IMAPwrapper::getName()const |
1260 | { | 1260 | { |
1261 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1261 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1262 | return account->getAccountName(); | 1262 | return account->getAccountName(); |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1265 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1266 | { | 1266 | { |
1267 | // dummy | 1267 | // dummy |
1268 | QValueList<int> path; | 1268 | QValueList<int> path; |
1269 | return fetchRawPart(mail,path,false); | 1269 | return fetchRawPart(mail,path,false); |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1272 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1273 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1273 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1274 | { | 1274 | { |
1275 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1275 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1276 | mMax = 0; | 1276 | mMax = 0; |
1277 | progress( tr("Copy")); | 1277 | progress( i18n("Copy")); |
1278 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1278 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1279 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1279 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1280 | // odebug << "Using generic" << oendl; | 1280 | // odebug << "Using generic" << oendl; |
1281 | return; | 1281 | return; |
1282 | } | 1282 | } |
1283 | mailimap_set *set = 0; | 1283 | mailimap_set *set = 0; |
1284 | login(); | 1284 | login(); |
1285 | if (!m_imap) { | 1285 | if (!m_imap) { |
1286 | return; | 1286 | return; |
1287 | } | 1287 | } |
1288 | int err = selectMbox(fromFolder->getName()); | 1288 | int err = selectMbox(fromFolder->getName()); |
1289 | if ( err != MAILIMAP_NO_ERROR ) { | 1289 | if ( err != MAILIMAP_NO_ERROR ) { |
1290 | return; | 1290 | return; |
1291 | } | 1291 | } |
1292 | Global::statusMessage( tr("Copying mails on server...") ); | 1292 | Global::statusMessage( i18n("Copying mails on server...") ); |
1293 | int last = m_imap->imap_selection_info->sel_exists; | 1293 | int last = m_imap->imap_selection_info->sel_exists; |
1294 | set = mailimap_set_new_interval( 1, last ); | 1294 | set = mailimap_set_new_interval( 1, last ); |
1295 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1295 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1296 | mailimap_set_free( set ); | 1296 | mailimap_set_free( set ); |
1297 | if ( err != MAILIMAP_NO_ERROR ) { | 1297 | if ( err != MAILIMAP_NO_ERROR ) { |
1298 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); | 1298 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); |
1299 | Global::statusMessage(error_msg); | 1299 | Global::statusMessage(error_msg); |
1300 | // odebug << error_msg << oendl; | 1300 | // odebug << error_msg << oendl; |
1301 | return; | 1301 | return; |
1302 | } | 1302 | } |
1303 | if (moveit) { | 1303 | if (moveit) { |
1304 | deleteAllMail(fromFolder); | 1304 | deleteAllMail(fromFolder); |
1305 | } | 1305 | } |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1308 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1309 | { | 1309 | { |
1310 | if (targetWrapper != this) { | 1310 | if (targetWrapper != this) { |
1311 | // odebug << "Using generic" << oendl; | 1311 | // odebug << "Using generic" << oendl; |
1312 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1312 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1313 | return; | 1313 | return; |
1314 | } | 1314 | } |
1315 | mailimap_set *set = 0; | 1315 | mailimap_set *set = 0; |
1316 | login(); | 1316 | login(); |
1317 | if (!m_imap) { | 1317 | if (!m_imap) { |
1318 | return; | 1318 | return; |
1319 | } | 1319 | } |
1320 | int err = selectMbox(mail->getMbox()); | 1320 | int err = selectMbox(mail->getMbox()); |
1321 | if ( err != MAILIMAP_NO_ERROR ) { | 1321 | if ( err != MAILIMAP_NO_ERROR ) { |
1322 | return; | 1322 | return; |
1323 | } | 1323 | } |
1324 | set = mailimap_set_new_single(mail->getNumber()); | 1324 | set = mailimap_set_new_single(mail->getNumber()); |
1325 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1325 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1326 | mailimap_set_free( set ); | 1326 | mailimap_set_free( set ); |
1327 | if ( err != MAILIMAP_NO_ERROR ) { | 1327 | if ( err != MAILIMAP_NO_ERROR ) { |
1328 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1328 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); |
1329 | Global::statusMessage(error_msg); | 1329 | Global::statusMessage(error_msg); |
1330 | // odebug << error_msg << oendl; | 1330 | // odebug << error_msg << oendl; |
1331 | return; | 1331 | return; |
1332 | } | 1332 | } |
1333 | if (moveit) { | 1333 | if (moveit) { |
1334 | deleteMail(mail); | 1334 | deleteMail(mail); |
1335 | } | 1335 | } |
1336 | } | 1336 | } |
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp index 39dd156..0cdbae4 100644 --- a/kmicromail/libmailwrapper/mboxwrapper.cpp +++ b/kmicromail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,338 +1,339 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <klocale.h> | ||
7 | 8 | ||
8 | 9 | ||
9 | #include <qpe/global.h> | 10 | #include <qpe/global.h> |
10 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
13 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 14 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
14 | { | 15 | { |
15 | QDir dir(MBOXPath); | 16 | QDir dir(MBOXPath); |
16 | if (!dir.exists()) { | 17 | if (!dir.exists()) { |
17 | dir.mkdir(MBOXPath); | 18 | dir.mkdir(MBOXPath); |
18 | } | 19 | } |
19 | } | 20 | } |
20 | 21 | ||
21 | MBOXwrapper::~MBOXwrapper() | 22 | MBOXwrapper::~MBOXwrapper() |
22 | { | 23 | { |
23 | } | 24 | } |
24 | 25 | ||
25 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 26 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) |
26 | { | 27 | { |
27 | mailstorage*storage = mailstorage_new(NULL); | 28 | mailstorage*storage = mailstorage_new(NULL); |
28 | QString p = MBOXPath+"/"; | 29 | QString p = MBOXPath+"/"; |
29 | p+=mailbox; | 30 | p+=mailbox; |
30 | 31 | ||
31 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 32 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
32 | mailfolder*folder; | 33 | mailfolder*folder; |
33 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 34 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
34 | r = mailfolder_connect(folder); | 35 | r = mailfolder_connect(folder); |
35 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
36 | //odebug << "Error initializing mbox" << oendl; | 37 | //odebug << "Error initializing mbox" << oendl; |
37 | mailfolder_free(folder); | 38 | mailfolder_free(folder); |
38 | mailstorage_free(storage); | 39 | mailstorage_free(storage); |
39 | return; | 40 | return; |
40 | } | 41 | } |
41 | 42 | ||
42 | parseList(target,folder->fld_session,mailbox); | 43 | parseList(target,folder->fld_session,mailbox); |
43 | 44 | ||
44 | mailfolder_disconnect(folder); | 45 | mailfolder_disconnect(folder); |
45 | mailfolder_free(folder); | 46 | mailfolder_free(folder); |
46 | mailstorage_free(storage); | 47 | mailstorage_free(storage); |
47 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 48 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
48 | } | 49 | } |
49 | 50 | ||
50 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 51 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
51 | { | 52 | { |
52 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 53 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
53 | QDir dir(MBOXPath); | 54 | QDir dir(MBOXPath); |
54 | if (!dir.exists()) return folders; | 55 | if (!dir.exists()) return folders; |
55 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 56 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
56 | QStringList entries = dir.entryList(); | 57 | QStringList entries = dir.entryList(); |
57 | QStringList::ConstIterator it = entries.begin(); | 58 | QStringList::ConstIterator it = entries.begin(); |
58 | for (;it!=entries.end();++it) { | 59 | for (;it!=entries.end();++it) { |
59 | FolderP inb=new Folder(*it,"/"); | 60 | FolderP inb=new Folder(*it,"/"); |
60 | folders->append(inb); | 61 | folders->append(inb); |
61 | } | 62 | } |
62 | return folders; | 63 | return folders; |
63 | } | 64 | } |
64 | 65 | ||
65 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 66 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
66 | { | 67 | { |
67 | mailstorage*storage = mailstorage_new(NULL); | 68 | mailstorage*storage = mailstorage_new(NULL); |
68 | QString p = MBOXPath+"/"; | 69 | QString p = MBOXPath+"/"; |
69 | p+=mail->getMbox(); | 70 | p+=mail->getMbox(); |
70 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 71 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
71 | mailfolder*folder; | 72 | mailfolder*folder; |
72 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 73 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
73 | r = mailfolder_connect(folder); | 74 | r = mailfolder_connect(folder); |
74 | if (r != MAIL_NO_ERROR) { | 75 | if (r != MAIL_NO_ERROR) { |
75 | ; // << "Error initializing mbox" << oendl; | 76 | ; // << "Error initializing mbox" << oendl; |
76 | mailfolder_free(folder); | 77 | mailfolder_free(folder); |
77 | mailstorage_free(storage); | 78 | mailstorage_free(storage); |
78 | return; | 79 | return; |
79 | } | 80 | } |
80 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); | 81 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); |
81 | if (r != MAIL_NO_ERROR) { | 82 | if (r != MAIL_NO_ERROR) { |
82 | ; // << "error deleting mail" << oendl; | 83 | ; // << "error deleting mail" << oendl; |
83 | } | 84 | } |
84 | mailfolder_free(folder); | 85 | mailfolder_free(folder); |
85 | mailstorage_free(storage); | 86 | mailstorage_free(storage); |
86 | } | 87 | } |
87 | 88 | ||
88 | void MBOXwrapper::answeredMail(const RecMailP&) | 89 | void MBOXwrapper::answeredMail(const RecMailP&) |
89 | { | 90 | { |
90 | } | 91 | } |
91 | 92 | ||
92 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) | 93 | RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) |
93 | { | 94 | { |
94 | RecBodyP body = new RecBody(); | 95 | RecBodyP body = new RecBody(); |
95 | mailstorage*storage = mailstorage_new(NULL); | 96 | mailstorage*storage = mailstorage_new(NULL); |
96 | QString p = MBOXPath+"/"; | 97 | QString p = MBOXPath+"/"; |
97 | p+=mail->getMbox(); | 98 | p+=mail->getMbox(); |
98 | mailmessage * msg; | 99 | mailmessage * msg; |
99 | char*data=0; | 100 | char*data=0; |
100 | size_t size; | 101 | size_t size; |
101 | 102 | ||
102 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 103 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
103 | mailfolder*folder; | 104 | mailfolder*folder; |
104 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 105 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
105 | r = mailfolder_connect(folder); | 106 | r = mailfolder_connect(folder); |
106 | if (r != MAIL_NO_ERROR) { | 107 | if (r != MAIL_NO_ERROR) { |
107 | ; // << "Error initializing mbox" << oendl; | 108 | ; // << "Error initializing mbox" << oendl; |
108 | mailfolder_free(folder); | 109 | mailfolder_free(folder); |
109 | mailstorage_free(storage); | 110 | mailstorage_free(storage); |
110 | return body; | 111 | return body; |
111 | } | 112 | } |
112 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 113 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
113 | if (r != MAIL_NO_ERROR) { | 114 | if (r != MAIL_NO_ERROR) { |
114 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; | 115 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; |
115 | mailfolder_free(folder); | 116 | mailfolder_free(folder); |
116 | mailstorage_free(storage); | 117 | mailstorage_free(storage); |
117 | return body; | 118 | return body; |
118 | } | 119 | } |
119 | r = mailmessage_fetch(msg,&data,&size); | 120 | r = mailmessage_fetch(msg,&data,&size); |
120 | if (r != MAIL_NO_ERROR) { | 121 | if (r != MAIL_NO_ERROR) { |
121 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; | 122 | ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; |
122 | mailfolder_free(folder); | 123 | mailfolder_free(folder); |
123 | mailstorage_free(storage); | 124 | mailstorage_free(storage); |
124 | mailmessage_free(msg); | 125 | mailmessage_free(msg); |
125 | return body; | 126 | return body; |
126 | } | 127 | } |
127 | body = parseMail(msg); | 128 | body = parseMail(msg); |
128 | mailmessage_fetch_result_free(msg,data); | 129 | mailmessage_fetch_result_free(msg,data); |
129 | mailfolder_free(folder); | 130 | mailfolder_free(folder); |
130 | mailstorage_free(storage); | 131 | mailstorage_free(storage); |
131 | 132 | ||
132 | return body; | 133 | return body; |
133 | } | 134 | } |
134 | 135 | ||
135 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 136 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
136 | { | 137 | { |
137 | ; // << "MBOX " << current << " von " << maximum << "" << oendl; | 138 | ; // << "MBOX " << current << " von " << maximum << "" << oendl; |
138 | } | 139 | } |
139 | 140 | ||
140 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) | 141 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
141 | { | 142 | { |
142 | QString p = MBOXPath+"/"; | 143 | QString p = MBOXPath+"/"; |
143 | p+=folder; | 144 | p+=folder; |
144 | QFileInfo fi(p); | 145 | QFileInfo fi(p); |
145 | if (fi.exists()) { | 146 | if (fi.exists()) { |
146 | Global::statusMessage(tr("Mailbox exists.")); | 147 | Global::statusMessage(i18n("Mailbox exists.")); |
147 | return 0; | 148 | return 0; |
148 | } | 149 | } |
149 | mailmbox_folder*f = 0; | 150 | mailmbox_folder*f = 0; |
150 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { | 151 | if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { |
151 | Global::statusMessage(tr("Error init folder")); | 152 | Global::statusMessage(i18n("Error init folder")); |
152 | return 0; | 153 | return 0; |
153 | } | 154 | } |
154 | if (f) mailmbox_done(f); | 155 | if (f) mailmbox_done(f); |
155 | return 1; | 156 | return 1; |
156 | } | 157 | } |
157 | 158 | ||
158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 159 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
159 | { | 160 | { |
160 | QString p = MBOXPath+"/"; | 161 | QString p = MBOXPath+"/"; |
161 | p+=folder; | 162 | p+=folder; |
162 | mailmbox_folder*f = 0; | 163 | mailmbox_folder*f = 0; |
163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 164 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
164 | if (r != MAIL_NO_ERROR) { | 165 | if (r != MAIL_NO_ERROR) { |
165 | Global::statusMessage(tr("Error init folder")); | 166 | Global::statusMessage(i18n("Error init folder")); |
166 | return; | 167 | return; |
167 | } | 168 | } |
168 | r = mailmbox_append_message(f,msg,length); | 169 | r = mailmbox_append_message(f,msg,length); |
169 | if (r != MAIL_NO_ERROR) { | 170 | if (r != MAIL_NO_ERROR) { |
170 | Global::statusMessage(tr("Error writing to message folder")); | 171 | Global::statusMessage(i18n("Error writing to message folder")); |
171 | } | 172 | } |
172 | mailmbox_done(f); | 173 | mailmbox_done(f); |
173 | } | 174 | } |
174 | 175 | ||
175 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) | 176 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) |
176 | { | 177 | { |
177 | RecBody body; | 178 | RecBody body; |
178 | mailstorage*storage = mailstorage_new(NULL); | 179 | mailstorage*storage = mailstorage_new(NULL); |
179 | QString p = MBOXPath+"/"; | 180 | QString p = MBOXPath+"/"; |
180 | p+=mail->getMbox(); | 181 | p+=mail->getMbox(); |
181 | mailmessage * msg; | 182 | mailmessage * msg; |
182 | char*data=0; | 183 | char*data=0; |
183 | size_t size; | 184 | size_t size; |
184 | 185 | ||
185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 186 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
186 | mailfolder*folder; | 187 | mailfolder*folder; |
187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 188 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
188 | r = mailfolder_connect(folder); | 189 | r = mailfolder_connect(folder); |
189 | if (r != MAIL_NO_ERROR) { | 190 | if (r != MAIL_NO_ERROR) { |
190 | Global::statusMessage(tr("Error initializing mbox")); | 191 | Global::statusMessage(i18n("Error initializing mbox")); |
191 | mailfolder_free(folder); | 192 | mailfolder_free(folder); |
192 | mailstorage_free(storage); | 193 | mailstorage_free(storage); |
193 | return 0; | 194 | return 0; |
194 | } | 195 | } |
195 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); | 196 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
196 | if (r != MAIL_NO_ERROR) { | 197 | if (r != MAIL_NO_ERROR) { |
197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 198 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
198 | mailfolder_free(folder); | 199 | mailfolder_free(folder); |
199 | mailstorage_free(storage); | 200 | mailstorage_free(storage); |
200 | return 0; | 201 | return 0; |
201 | } | 202 | } |
202 | r = mailmessage_fetch(msg,&data,&size); | 203 | r = mailmessage_fetch(msg,&data,&size); |
203 | if (r != MAIL_NO_ERROR) { | 204 | if (r != MAIL_NO_ERROR) { |
204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 205 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
205 | mailfolder_free(folder); | 206 | mailfolder_free(folder); |
206 | mailstorage_free(storage); | 207 | mailstorage_free(storage); |
207 | mailmessage_free(msg); | 208 | mailmessage_free(msg); |
208 | return 0; | 209 | return 0; |
209 | } | 210 | } |
210 | encodedString*result = new encodedString(data,size); | 211 | encodedString*result = new encodedString(data,size); |
211 | 212 | ||
212 | mailfolder_free(folder); | 213 | mailfolder_free(folder); |
213 | mailstorage_free(storage); | 214 | mailstorage_free(storage); |
214 | mailmessage_free(msg); | 215 | mailmessage_free(msg); |
215 | return result; | 216 | return result; |
216 | } | 217 | } |
217 | 218 | ||
218 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 219 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
219 | { | 220 | { |
220 | QString p = MBOXPath+"/"; | 221 | QString p = MBOXPath+"/"; |
221 | p+=mailbox; | 222 | p+=mailbox; |
222 | mailmbox_folder*f = 0; | 223 | mailmbox_folder*f = 0; |
223 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 224 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
224 | if (r != MAIL_NO_ERROR) { | 225 | if (r != MAIL_NO_ERROR) { |
225 | ; // << "Error init folder" << oendl; | 226 | ; // << "Error init folder" << oendl; |
226 | return; | 227 | return; |
227 | } | 228 | } |
228 | deleteMails(f,target); | 229 | deleteMails(f,target); |
229 | mailmbox_done(f); | 230 | mailmbox_done(f); |
230 | } | 231 | } |
231 | 232 | ||
232 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) | 233 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) |
233 | { | 234 | { |
234 | if (!f) return; | 235 | if (!f) return; |
235 | int r; | 236 | int r; |
236 | QValueList<RecMailP>::ConstIterator it; | 237 | QValueList<RecMailP>::ConstIterator it; |
237 | for (it=target.begin(); it != target.end();++it) { | 238 | for (it=target.begin(); it != target.end();++it) { |
238 | r = mailmbox_delete_msg(f,(*it)->getNumber()); | 239 | r = mailmbox_delete_msg(f,(*it)->getNumber()); |
239 | if (r!=MAILMBOX_NO_ERROR) { | 240 | if (r!=MAILMBOX_NO_ERROR) { |
240 | ; // << "error delete mail" << oendl; | 241 | ; // << "error delete mail" << oendl; |
241 | } | 242 | } |
242 | } | 243 | } |
243 | r = mailmbox_expunge(f); | 244 | r = mailmbox_expunge(f); |
244 | if (r != MAILMBOX_NO_ERROR) { | 245 | if (r != MAILMBOX_NO_ERROR) { |
245 | ; // << "error expunge mailbox" << oendl; | 246 | ; // << "error expunge mailbox" << oendl; |
246 | } | 247 | } |
247 | } | 248 | } |
248 | 249 | ||
249 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) | 250 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) |
250 | { | 251 | { |
251 | if (!tfolder) return 0; | 252 | if (!tfolder) return 0; |
252 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 253 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
253 | int res = 1; | 254 | int res = 1; |
254 | 255 | ||
255 | mailfolder*folder = 0; | 256 | mailfolder*folder = 0; |
256 | mailmessage_list*l=0; | 257 | mailmessage_list*l=0; |
257 | mailstorage*storage = mailstorage_new(NULL); | 258 | mailstorage*storage = mailstorage_new(NULL); |
258 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 259 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
259 | if (r != MAIL_NO_ERROR) { | 260 | if (r != MAIL_NO_ERROR) { |
260 | Global::statusMessage(tr("Error initializing mbox")); | 261 | Global::statusMessage(i18n("Error initializing mbox")); |
261 | res = 0; | 262 | res = 0; |
262 | } | 263 | } |
263 | if (res) { | 264 | if (res) { |
264 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 265 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
265 | r = mailfolder_connect(folder); | 266 | r = mailfolder_connect(folder); |
266 | if (r != MAIL_NO_ERROR) { | 267 | if (r != MAIL_NO_ERROR) { |
267 | Global::statusMessage(tr("Error initializing mbox")); | 268 | Global::statusMessage(i18n("Error initializing mbox")); |
268 | res = 0; | 269 | res = 0; |
269 | } | 270 | } |
270 | } | 271 | } |
271 | if (res) { | 272 | if (res) { |
272 | r = mailsession_get_messages_list(folder->fld_session,&l); | 273 | r = mailsession_get_messages_list(folder->fld_session,&l); |
273 | if (r != MAIL_NO_ERROR) { | 274 | if (r != MAIL_NO_ERROR) { |
274 | ; // << "Error message list" << oendl; | 275 | ; // << "Error message list" << oendl; |
275 | res=0; | 276 | res=0; |
276 | } | 277 | } |
277 | } | 278 | } |
278 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 279 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
279 | r = mailsession_remove_message(folder->fld_session,i+1); | 280 | r = mailsession_remove_message(folder->fld_session,i+1); |
280 | if (r != MAIL_NO_ERROR) { | 281 | if (r != MAIL_NO_ERROR) { |
281 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 282 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
282 | res = 0; | 283 | res = 0; |
283 | break; | 284 | break; |
284 | } | 285 | } |
285 | } | 286 | } |
286 | if (l) mailmessage_list_free(l); | 287 | if (l) mailmessage_list_free(l); |
287 | if (folder) mailfolder_free(folder); | 288 | if (folder) mailfolder_free(folder); |
288 | if (storage) mailstorage_free(storage); | 289 | if (storage) mailstorage_free(storage); |
289 | return res; | 290 | return res; |
290 | } | 291 | } |
291 | 292 | ||
292 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) | 293 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) |
293 | { | 294 | { |
294 | if (!tfolder) return 0; | 295 | if (!tfolder) return 0; |
295 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 296 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
296 | QFile fi(p); | 297 | QFile fi(p); |
297 | if (!fi.exists()) { | 298 | if (!fi.exists()) { |
298 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 299 | Global::statusMessage(i18n("Mailbox doesn't exist.")); |
299 | return 0; | 300 | return 0; |
300 | } | 301 | } |
301 | if (!fi.remove()) { | 302 | if (!fi.remove()) { |
302 | Global::statusMessage(tr("Error deleting Mailbox.")); | 303 | Global::statusMessage(i18n("Error deleting Mailbox.")); |
303 | return 0; | 304 | return 0; |
304 | } | 305 | } |
305 | return 1; | 306 | return 1; |
306 | } | 307 | } |
307 | 308 | ||
308 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 309 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
309 | { | 310 | { |
310 | mailfolder*folder = 0; | 311 | mailfolder*folder = 0; |
311 | mailstorage*storage = mailstorage_new(NULL); | 312 | mailstorage*storage = mailstorage_new(NULL); |
312 | target_stat.message_count = 0; | 313 | target_stat.message_count = 0; |
313 | target_stat.message_unseen = 0; | 314 | target_stat.message_unseen = 0; |
314 | target_stat.message_recent = 0; | 315 | target_stat.message_recent = 0; |
315 | QString p = MBOXPath+"/"+mailbox; | 316 | QString p = MBOXPath+"/"+mailbox; |
316 | QFile fi(p); | 317 | QFile fi(p); |
317 | if (!fi.exists()) { | 318 | if (!fi.exists()) { |
318 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 319 | Global::statusMessage(i18n("Mailbox doesn't exist.")); |
319 | return; | 320 | return; |
320 | } | 321 | } |
321 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 322 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
322 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 323 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
323 | r = mailfolder_connect(folder); | 324 | r = mailfolder_connect(folder); |
324 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 325 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
325 | &target_stat.message_recent,&target_stat.message_unseen); | 326 | &target_stat.message_recent,&target_stat.message_unseen); |
326 | if (folder) mailfolder_free(folder); | 327 | if (folder) mailfolder_free(folder); |
327 | if (storage) mailstorage_free(storage); | 328 | if (storage) mailstorage_free(storage); |
328 | } | 329 | } |
329 | 330 | ||
330 | MAILLIB::ATYPE MBOXwrapper::getType()const | 331 | MAILLIB::ATYPE MBOXwrapper::getType()const |
331 | { | 332 | { |
332 | return MAILLIB::A_MBOX; | 333 | return MAILLIB::A_MBOX; |
333 | } | 334 | } |
334 | 335 | ||
335 | const QString&MBOXwrapper::getName()const | 336 | const QString&MBOXwrapper::getName()const |
336 | { | 337 | { |
337 | return MBOXName; | 338 | return MBOXName; |
338 | } | 339 | } |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 9d52f52..2888f7c 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,302 +1,303 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | #include "logindialog.h" | 5 | #include "logindialog.h" |
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | ||
8 | #include <klocale.h> | ||
8 | 9 | ||
9 | #include <qpe/global.h> | 10 | #include <qpe/global.h> |
10 | #include <qfile.h> | 11 | #include <qfile.h> |
11 | #include <qprogressbar.h> | 12 | #include <qprogressbar.h> |
12 | #include <qapplication.h> | 13 | #include <qapplication.h> |
13 | 14 | ||
14 | /* we don't fetch messages larger than 5 MB */ | 15 | /* we don't fetch messages larger than 5 MB */ |
15 | #define HARD_MSG_SIZE_LIMIT 5242880 | 16 | #define HARD_MSG_SIZE_LIMIT 5242880 |
16 | 17 | ||
17 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
18 | POP3wrapper::POP3wrapper( POP3account *a ) | 19 | POP3wrapper::POP3wrapper( POP3account *a ) |
19 | : Genericwrapper() { | 20 | : Genericwrapper() { |
20 | account = a; | 21 | account = a; |
21 | m_pop3 = NULL; | 22 | m_pop3 = NULL; |
22 | msgTempName = a->getFileName()+"_msg_cache"; | 23 | msgTempName = a->getFileName()+"_msg_cache"; |
23 | last_msg_id = 0; | 24 | last_msg_id = 0; |
24 | } | 25 | } |
25 | 26 | ||
26 | POP3wrapper::~POP3wrapper() { | 27 | POP3wrapper::~POP3wrapper() { |
27 | logout(); | 28 | logout(); |
28 | QFile msg_cache(msgTempName); | 29 | QFile msg_cache(msgTempName); |
29 | if (msg_cache.exists()) { | 30 | if (msg_cache.exists()) { |
30 | msg_cache.remove(); | 31 | msg_cache.remove(); |
31 | } | 32 | } |
32 | } | 33 | } |
33 | 34 | ||
34 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 35 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
35 | ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl; | 36 | ; // odebug << "POP3: " << current << " of " << maximum << "" << oendl; |
36 | } | 37 | } |
37 | 38 | ||
38 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | 39 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { |
39 | int err = MAILPOP3_NO_ERROR; | 40 | int err = MAILPOP3_NO_ERROR; |
40 | char *message = 0; | 41 | char *message = 0; |
41 | size_t length = 0; | 42 | size_t length = 0; |
42 | 43 | ||
43 | RecBodyP body = new RecBody(); | 44 | RecBodyP body = new RecBody(); |
44 | 45 | ||
45 | login(); | 46 | login(); |
46 | if ( !m_pop3 ) { | 47 | if ( !m_pop3 ) { |
47 | return body; | 48 | return body; |
48 | } | 49 | } |
49 | 50 | ||
50 | mailmessage * mailmsg; | 51 | mailmessage * mailmsg; |
51 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 52 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
52 | ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 53 | ; // odebug << "Message to large: " << mail->Msgsize() << "" << oendl; |
53 | return body; | 54 | return body; |
54 | } | 55 | } |
55 | 56 | ||
56 | QFile msg_cache(msgTempName); | 57 | QFile msg_cache(msgTempName); |
57 | 58 | ||
58 | cleanMimeCache(); | 59 | cleanMimeCache(); |
59 | 60 | ||
60 | if (mail->getNumber()!=last_msg_id) { | 61 | if (mail->getNumber()!=last_msg_id) { |
61 | if (msg_cache.exists()) { | 62 | if (msg_cache.exists()) { |
62 | msg_cache.remove(); | 63 | msg_cache.remove(); |
63 | } | 64 | } |
64 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 65 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
65 | last_msg_id = mail->getNumber(); | 66 | last_msg_id = mail->getNumber(); |
66 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 67 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
67 | err = mailmessage_fetch(mailmsg,&message,&length); | 68 | err = mailmessage_fetch(mailmsg,&message,&length); |
68 | msg_cache.writeBlock(message,length); | 69 | msg_cache.writeBlock(message,length); |
69 | } else { | 70 | } else { |
70 | QString msg=""; | 71 | QString msg=""; |
71 | msg_cache.open(IO_ReadOnly); | 72 | msg_cache.open(IO_ReadOnly); |
72 | message = new char[4096]; | 73 | message = new char[4096]; |
73 | memset(message,0,4096); | 74 | memset(message,0,4096); |
74 | while (msg_cache.readBlock(message,4095)>0) { | 75 | while (msg_cache.readBlock(message,4095)>0) { |
75 | msg+=message; | 76 | msg+=message; |
76 | memset(message,0,4096); | 77 | memset(message,0,4096); |
77 | } | 78 | } |
78 | delete message; | 79 | delete message; |
79 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 80 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
80 | memset(message,0,msg.length()+1); | 81 | memset(message,0,msg.length()+1); |
81 | memcpy(message,msg.latin1(),msg.length()); | 82 | memcpy(message,msg.latin1(),msg.length()); |
82 | /* transform to libetpan stuff */ | 83 | /* transform to libetpan stuff */ |
83 | mailmsg = mailmessage_new(); | 84 | mailmsg = mailmessage_new(); |
84 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 85 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
85 | generic_message_t * msg_data; | 86 | generic_message_t * msg_data; |
86 | msg_data = (generic_message_t *)mailmsg->msg_data; | 87 | msg_data = (generic_message_t *)mailmsg->msg_data; |
87 | msg_data->msg_fetched = 1; | 88 | msg_data->msg_fetched = 1; |
88 | msg_data->msg_message = message; | 89 | msg_data->msg_message = message; |
89 | msg_data->msg_length = strlen(message); | 90 | msg_data->msg_length = strlen(message); |
90 | } | 91 | } |
91 | body = parseMail(mailmsg); | 92 | body = parseMail(mailmsg); |
92 | 93 | ||
93 | /* clean up */ | 94 | /* clean up */ |
94 | if (mailmsg) | 95 | if (mailmsg) |
95 | mailmessage_free(mailmsg); | 96 | mailmessage_free(mailmsg); |
96 | if (message) | 97 | if (message) |
97 | free(message); | 98 | free(message); |
98 | 99 | ||
99 | return body; | 100 | return body; |
100 | } | 101 | } |
101 | 102 | ||
102 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 103 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
103 | { | 104 | { |
104 | login(); | 105 | login(); |
105 | if (!m_pop3) | 106 | if (!m_pop3) |
106 | return; | 107 | return; |
107 | uint32_t res_messages,res_recent,res_unseen; | 108 | uint32_t res_messages,res_recent,res_unseen; |
108 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 109 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
109 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); | 110 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); |
110 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 111 | Global::statusMessage( i18n("Mailbox contains %1 mail(s)").arg(res_messages)); |
111 | } | 112 | } |
112 | 113 | ||
113 | void POP3wrapper::login() | 114 | void POP3wrapper::login() |
114 | { | 115 | { |
115 | if (account->getOffline()) | 116 | if (account->getOffline()) |
116 | return; | 117 | return; |
117 | /* we'll hold the line */ | 118 | /* we'll hold the line */ |
118 | if ( m_pop3 != NULL ) | 119 | if ( m_pop3 != NULL ) |
119 | return; | 120 | return; |
120 | 121 | ||
121 | QString server,user, pass; | 122 | QString server,user, pass; |
122 | uint16_t port; | 123 | uint16_t port; |
123 | int err = MAILPOP3_NO_ERROR; | 124 | int err = MAILPOP3_NO_ERROR; |
124 | 125 | ||
125 | server = account->getServer(); | 126 | server = account->getServer(); |
126 | port = account->getPort().toUInt(); | 127 | port = account->getPort().toUInt(); |
127 | 128 | ||
128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 129 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
129 | qApp->processEvents(); | 130 | qApp->processEvents(); |
130 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 131 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
131 | login.show(); | 132 | login.show(); |
132 | if ( QDialog::Accepted == login.exec() ) { | 133 | if ( QDialog::Accepted == login.exec() ) { |
133 | // ok | 134 | // ok |
134 | user = login.getUser(); | 135 | user = login.getUser(); |
135 | pass = login.getPassword(); | 136 | pass = login.getPassword(); |
136 | } else { | 137 | } else { |
137 | // cancel | 138 | // cancel |
138 | ; // odebug << "POP3: Login canceled" << oendl; | 139 | ; // odebug << "POP3: Login canceled" << oendl; |
139 | return; | 140 | return; |
140 | } | 141 | } |
141 | } else { | 142 | } else { |
142 | user = account->getUser(); | 143 | user = account->getUser(); |
143 | pass = account->getPassword(); | 144 | pass = account->getPassword(); |
144 | } | 145 | } |
145 | // bool ssl = account->getSSL(); | 146 | // bool ssl = account->getSSL(); |
146 | 147 | ||
147 | m_pop3=mailstorage_new(NULL); | 148 | m_pop3=mailstorage_new(NULL); |
148 | int conntypeset = account->ConnectionType(); | 149 | int conntypeset = account->ConnectionType(); |
149 | int conntype = 0; | 150 | int conntype = 0; |
150 | if ( conntypeset == 3 ) { | 151 | if ( conntypeset == 3 ) { |
151 | conntype = CONNECTION_TYPE_COMMAND; | 152 | conntype = CONNECTION_TYPE_COMMAND; |
152 | } else if ( conntypeset == 2 ) { | 153 | } else if ( conntypeset == 2 ) { |
153 | conntype = CONNECTION_TYPE_TLS; | 154 | conntype = CONNECTION_TYPE_TLS; |
154 | } else if ( conntypeset == 1 ) { | 155 | } else if ( conntypeset == 1 ) { |
155 | conntype = CONNECTION_TYPE_STARTTLS; | 156 | conntype = CONNECTION_TYPE_STARTTLS; |
156 | } else if ( conntypeset == 0 ) { | 157 | } else if ( conntypeset == 0 ) { |
157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 158 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
158 | } | 159 | } |
159 | 160 | ||
160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 161 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
161 | 162 | ||
162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 163 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); | 164 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); |
164 | 165 | ||
165 | err = mailstorage_connect(m_pop3); | 166 | err = mailstorage_connect(m_pop3); |
166 | if (err != MAIL_NO_ERROR) { | 167 | if (err != MAIL_NO_ERROR) { |
167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 168 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
168 | Global::statusMessage(tr("Error %1 initializing folder").arg( err )); | 169 | Global::statusMessage(i18n("Error %1 initializing folder").arg( err )); |
169 | mailstorage_free(m_pop3); | 170 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 171 | m_pop3 = 0; |
171 | } else { | 172 | } else { |
172 | mailsession * session = m_pop3->sto_session; | 173 | mailsession * session = m_pop3->sto_session; |
173 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 174 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
174 | if (mail) { | 175 | if (mail) { |
175 | mail->pop3_progr_fun = &pop3_progress; | 176 | mail->pop3_progr_fun = &pop3_progress; |
176 | } | 177 | } |
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
180 | void POP3wrapper::logout() | 181 | void POP3wrapper::logout() |
181 | { | 182 | { |
182 | if ( m_pop3 == NULL ) | 183 | if ( m_pop3 == NULL ) |
183 | return; | 184 | return; |
184 | mailstorage_free(m_pop3); | 185 | mailstorage_free(m_pop3); |
185 | m_pop3 = 0; | 186 | m_pop3 = 0; |
186 | } | 187 | } |
187 | 188 | ||
188 | 189 | ||
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 190 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
190 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 191 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
191 | FolderP inb=new Folder("INBOX","/"); | 192 | FolderP inb=new Folder("INBOX","/"); |
192 | folders->append(inb); | 193 | folders->append(inb); |
193 | return folders; | 194 | return folders; |
194 | } | 195 | } |
195 | 196 | ||
196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) | 197 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) |
197 | { | 198 | { |
198 | login(); | 199 | login(); |
199 | if (!m_pop3) | 200 | if (!m_pop3) |
200 | return; | 201 | return; |
201 | int iii = 0; | 202 | int iii = 0; |
202 | int count = target.count(); | 203 | int count = target.count(); |
203 | 204 | ||
204 | QProgressBar wid ( count ); | 205 | QProgressBar wid ( count ); |
205 | wid.setCaption( tr("Deleting ...")); | 206 | wid.setCaption( i18n("Deleting ...")); |
206 | wid.show(); | 207 | wid.show(); |
207 | while (iii < count ) { | 208 | while (iii < count ) { |
208 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 209 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
209 | wid.setProgress( iii ); | 210 | wid.setProgress( iii ); |
210 | wid.raise(); | 211 | wid.raise(); |
211 | qApp->processEvents(); | 212 | qApp->processEvents(); |
212 | //qDebug("delete "); | 213 | //qDebug("delete "); |
213 | RecMailP mail = (*target.at( iii )); | 214 | RecMailP mail = (*target.at( iii )); |
214 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 215 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
215 | if (err != MAIL_NO_ERROR) { | 216 | if (err != MAIL_NO_ERROR) { |
216 | Global::statusMessage(tr("Error deleting mail")); | 217 | Global::statusMessage(i18n("Error deleting mail")); |
217 | } | 218 | } |
218 | ++iii; | 219 | ++iii; |
219 | } | 220 | } |
220 | } | 221 | } |
221 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 222 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
222 | login(); | 223 | login(); |
223 | if (!m_pop3) | 224 | if (!m_pop3) |
224 | return; | 225 | return; |
225 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 226 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
226 | if (err != MAIL_NO_ERROR) { | 227 | if (err != MAIL_NO_ERROR) { |
227 | Global::statusMessage(tr("error deleting mail")); | 228 | Global::statusMessage(i18n("error deleting mail")); |
228 | } | 229 | } |
229 | } | 230 | } |
230 | 231 | ||
231 | void POP3wrapper::answeredMail(const RecMailP&) {} | 232 | void POP3wrapper::answeredMail(const RecMailP&) {} |
232 | 233 | ||
233 | int POP3wrapper::deleteAllMail(const FolderP&) { | 234 | int POP3wrapper::deleteAllMail(const FolderP&) { |
234 | login(); | 235 | login(); |
235 | if (!m_pop3) | 236 | if (!m_pop3) |
236 | return 0; | 237 | return 0; |
237 | int res = 1; | 238 | int res = 1; |
238 | 239 | ||
239 | uint32_t result = 0; | 240 | uint32_t result = 0; |
240 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 241 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
241 | if (err != MAIL_NO_ERROR) { | 242 | if (err != MAIL_NO_ERROR) { |
242 | Global::statusMessage(tr("Error getting folder info")); | 243 | Global::statusMessage(i18n("Error getting folder info")); |
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | 246 | ||
246 | 247 | ||
247 | 248 | ||
248 | QProgressBar wid ( result ); | 249 | QProgressBar wid ( result ); |
249 | wid.setCaption( tr("Deleting ...")); | 250 | wid.setCaption( i18n("Deleting ...")); |
250 | wid.show(); | 251 | wid.show(); |
251 | for (unsigned int i = 0; i < result; ++i) { | 252 | for (unsigned int i = 0; i < result; ++i) { |
252 | Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); | 253 | Global::statusMessage(i18n("Delete message %1 of %2").arg(i).arg(result)); |
253 | wid.setProgress( i ); | 254 | wid.setProgress( i ); |
254 | wid.raise(); | 255 | wid.raise(); |
255 | qApp->processEvents(); | 256 | qApp->processEvents(); |
256 | 257 | ||
257 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 258 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
258 | if (err != MAIL_NO_ERROR) { | 259 | if (err != MAIL_NO_ERROR) { |
259 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 260 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
260 | res=0; | 261 | res=0; |
261 | } | 262 | } |
262 | break; | 263 | break; |
263 | } | 264 | } |
264 | return res; | 265 | return res; |
265 | } | 266 | } |
266 | 267 | ||
267 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 268 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
268 | login(); | 269 | login(); |
269 | target_stat.message_count = 0; | 270 | target_stat.message_count = 0; |
270 | target_stat.message_unseen = 0; | 271 | target_stat.message_unseen = 0; |
271 | target_stat.message_recent = 0; | 272 | target_stat.message_recent = 0; |
272 | if (!m_pop3) | 273 | if (!m_pop3) |
273 | return; | 274 | return; |
274 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 275 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
275 | &target_stat.message_recent,&target_stat.message_unseen); | 276 | &target_stat.message_recent,&target_stat.message_unseen); |
276 | if (r != MAIL_NO_ERROR) { | 277 | if (r != MAIL_NO_ERROR) { |
277 | ; // odebug << "error getting folter status." << oendl; | 278 | ; // odebug << "error getting folter status." << oendl; |
278 | } | 279 | } |
279 | } | 280 | } |
280 | 281 | ||
281 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { | 282 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
282 | char*target=0; | 283 | char*target=0; |
283 | size_t length=0; | 284 | size_t length=0; |
284 | encodedString*res = 0; | 285 | encodedString*res = 0; |
285 | mailmessage * mailmsg = 0; | 286 | mailmessage * mailmsg = 0; |
286 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 287 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
287 | err = mailmessage_fetch(mailmsg,&target,&length); | 288 | err = mailmessage_fetch(mailmsg,&target,&length); |
288 | if (mailmsg) | 289 | if (mailmsg) |
289 | mailmessage_free(mailmsg); | 290 | mailmessage_free(mailmsg); |
290 | if (target) { | 291 | if (target) { |
291 | res = new encodedString(target,length); | 292 | res = new encodedString(target,length); |
292 | } | 293 | } |
293 | return res; | 294 | return res; |
294 | } | 295 | } |
295 | 296 | ||
296 | MAILLIB::ATYPE POP3wrapper::getType()const { | 297 | MAILLIB::ATYPE POP3wrapper::getType()const { |
297 | return account->getType(); | 298 | return account->getType(); |
298 | } | 299 | } |
299 | 300 | ||
300 | const QString&POP3wrapper::getName()const{ | 301 | const QString&POP3wrapper::getName()const{ |
301 | return account->getAccountName(); | 302 | return account->getAccountName(); |
302 | } | 303 | } |
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp index d5a528c..dee1477 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.cpp +++ b/kmicromail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,460 +1,461 @@ | |||
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 <opie2/odebug.h> |
9 | //#include <qt.h> | 9 | //#include <qt.h> |
10 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | #include <qpe/qcopenvelope_qws.h> | 14 | #include <qpe/qcopenvelope_qws.h> |
15 | 15 | ||
16 | #include <libetpan/libetpan.h> | 16 | #include <libetpan/libetpan.h> |
17 | #include <klocale.h> | ||
17 | 18 | ||
18 | 19 | ||
19 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
20 | progressMailSend*SMTPwrapper::sendProgress = 0; | 21 | progressMailSend*SMTPwrapper::sendProgress = 0; |
21 | 22 | ||
22 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) | 23 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) |
23 | : Generatemail() | 24 | : Generatemail() |
24 | { | 25 | { |
25 | m_SmtpAccount = aSmtp; | 26 | m_SmtpAccount = aSmtp; |
26 | Config cfg( "mail" ); | 27 | Config cfg( "mail" ); |
27 | cfg.setGroup( "Status" ); | 28 | cfg.setGroup( "Status" ); |
28 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 29 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
29 | emit queuedMails( m_queuedMail ); | 30 | emit queuedMails( m_queuedMail ); |
30 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); | 31 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); |
31 | m_smtp = 0; | 32 | m_smtp = 0; |
32 | } | 33 | } |
33 | 34 | ||
34 | SMTPwrapper::~SMTPwrapper() | 35 | SMTPwrapper::~SMTPwrapper() |
35 | { | 36 | { |
36 | disc_server(); | 37 | disc_server(); |
37 | } | 38 | } |
38 | 39 | ||
39 | void SMTPwrapper::emitQCop( int queued ) { | 40 | void SMTPwrapper::emitQCop( int queued ) { |
40 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 41 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
41 | env << queued; | 42 | env << queued; |
42 | } | 43 | } |
43 | 44 | ||
44 | QString SMTPwrapper::mailsmtpError( int errnum ) { | 45 | QString SMTPwrapper::mailsmtpError( int errnum ) { |
45 | switch ( errnum ) { | 46 | switch ( errnum ) { |
46 | case MAILSMTP_NO_ERROR: | 47 | case MAILSMTP_NO_ERROR: |
47 | return tr( "No error" ); | 48 | return i18n( "No error" ); |
48 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 49 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
49 | return tr( "Unexpected error code" ); | 50 | return i18n( "Unexpected error code" ); |
50 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 51 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
51 | return tr( "Service not available" ); | 52 | return i18n( "Service not available" ); |
52 | case MAILSMTP_ERROR_STREAM: | 53 | case MAILSMTP_ERROR_STREAM: |
53 | return tr( "Stream error" ); | 54 | return i18n( "Stream error" ); |
54 | case MAILSMTP_ERROR_HOSTNAME: | 55 | case MAILSMTP_ERROR_HOSTNAME: |
55 | return tr( "gethostname() failed" ); | 56 | return i18n( "gethostname() failed" ); |
56 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 57 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
57 | return tr( "Not implemented" ); | 58 | return i18n( "Not implemented" ); |
58 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 59 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
59 | return tr( "Error, action not taken" ); | 60 | return i18n( "Error, action not taken" ); |
60 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 61 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
61 | return tr( "Data exceeds storage allocation" ); | 62 | return i18n( "Data exceeds storage allocation" ); |
62 | case MAILSMTP_ERROR_IN_PROCESSING: | 63 | case MAILSMTP_ERROR_IN_PROCESSING: |
63 | return tr( "Error in processing" ); | 64 | return i18n( "Error in processing" ); |
64 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: | 65 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: |
65 | return tr( "Starttls not supported" ); | 66 | return i18n( "Starttls not supported" ); |
66 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 67 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
67 | // return tr( "Insufficient system storage" ); | 68 | // return i18n( "Insufficient system storage" ); |
68 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 69 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
69 | return tr( "Mailbox unavailable" ); | 70 | return i18n( "Mailbox unavailable" ); |
70 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 71 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
71 | return tr( "Mailbox name not allowed" ); | 72 | return i18n( "Mailbox name not allowed" ); |
72 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 73 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
73 | return tr( "Bad command sequence" ); | 74 | return i18n( "Bad command sequence" ); |
74 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 75 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |
75 | return tr( "User not local" ); | 76 | return i18n( "User not local" ); |
76 | case MAILSMTP_ERROR_TRANSACTION_FAILED: | 77 | case MAILSMTP_ERROR_TRANSACTION_FAILED: |
77 | return tr( "Transaction failed" ); | 78 | return i18n( "Transaction failed" ); |
78 | case MAILSMTP_ERROR_MEMORY: | 79 | case MAILSMTP_ERROR_MEMORY: |
79 | return tr( "Memory error" ); | 80 | return i18n( "Memory error" ); |
80 | case MAILSMTP_ERROR_CONNECTION_REFUSED: | 81 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
81 | return tr( "Connection refused" ); | 82 | return i18n( "Connection refused" ); |
82 | default: | 83 | default: |
83 | return tr( "Unknown error code" ); | 84 | return i18n( "Unknown error code" ); |
84 | } | 85 | } |
85 | } | 86 | } |
86 | 87 | ||
87 | 88 | ||
88 | void SMTPwrapper::progress( size_t current, size_t maximum ) { | 89 | void SMTPwrapper::progress( size_t current, size_t maximum ) { |
89 | if (SMTPwrapper::sendProgress) { | 90 | if (SMTPwrapper::sendProgress) { |
90 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 91 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
91 | qApp->processEvents(); | 92 | qApp->processEvents(); |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { | 96 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { |
96 | if (!mail) | 97 | if (!mail) |
97 | return; | 98 | return; |
98 | QString localfolders = AbstractMail::defaultLocalfolder(); | 99 | QString localfolders = AbstractMail::defaultLocalfolder(); |
99 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 100 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
100 | wrap->createMbox(box); | 101 | wrap->createMbox(box); |
101 | wrap->storeMessage(mail,length,box); | 102 | wrap->storeMessage(mail,length,box); |
102 | delete wrap; | 103 | delete wrap; |
103 | } | 104 | } |
104 | 105 | ||
105 | bool SMTPwrapper::smtpSend( mailmime *mail,bool later) { | 106 | bool SMTPwrapper::smtpSend( mailmime *mail,bool later) { |
106 | clist *rcpts = 0; | 107 | clist *rcpts = 0; |
107 | char *from, *data; | 108 | char *from, *data; |
108 | size_t size; | 109 | size_t size; |
109 | 110 | ||
110 | from = data = 0; | 111 | from = data = 0; |
111 | 112 | ||
112 | mailmessage * msg = 0; | 113 | mailmessage * msg = 0; |
113 | msg = mime_message_init(mail); | 114 | msg = mime_message_init(mail); |
114 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 115 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
115 | int r = mailmessage_fetch(msg,&data,&size); | 116 | int r = mailmessage_fetch(msg,&data,&size); |
116 | mime_message_detach_mime(msg); | 117 | mime_message_detach_mime(msg); |
117 | mailmessage_free(msg); | 118 | mailmessage_free(msg); |
118 | if (r != MAIL_NO_ERROR || !data) { | 119 | if (r != MAIL_NO_ERROR || !data) { |
119 | if (data) | 120 | if (data) |
120 | free(data); | 121 | free(data); |
121 | qDebug("Error fetching mime... "); | 122 | qDebug("Error fetching mime... "); |
122 | return false; | 123 | return false; |
123 | } | 124 | } |
124 | msg = 0; | 125 | msg = 0; |
125 | if (later) { | 126 | if (later) { |
126 | storeMail(data,size,"Outgoing"); | 127 | storeMail(data,size,"Outgoing"); |
127 | if (data) | 128 | if (data) |
128 | free( data ); | 129 | free( data ); |
129 | Config cfg( "mail" ); | 130 | Config cfg( "mail" ); |
130 | cfg.setGroup( "Status" ); | 131 | cfg.setGroup( "Status" ); |
131 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 132 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
132 | emit queuedMails( m_queuedMail ); | 133 | emit queuedMails( m_queuedMail ); |
133 | return true; | 134 | return true; |
134 | } | 135 | } |
135 | from = getFrom( mail ); | 136 | from = getFrom( mail ); |
136 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 137 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
137 | bool result = smtpSend(from,rcpts,data,size); | 138 | bool result = smtpSend(from,rcpts,data,size); |
138 | if (data) { | 139 | if (data) { |
139 | free(data); | 140 | free(data); |
140 | } | 141 | } |
141 | if (from) { | 142 | if (from) { |
142 | free(from); | 143 | free(from); |
143 | } | 144 | } |
144 | if (rcpts) | 145 | if (rcpts) |
145 | smtp_address_list_free( rcpts ); | 146 | smtp_address_list_free( rcpts ); |
146 | return result; | 147 | return result; |
147 | } | 148 | } |
148 | 149 | ||
149 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) | 150 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) |
150 | { | 151 | { |
151 | if (data) { | 152 | if (data) { |
152 | storeMail(data,size,"Sendfailed"); | 153 | storeMail(data,size,"Sendfailed"); |
153 | } | 154 | } |
154 | if (failuremessage) { | 155 | if (failuremessage) { |
155 | QMessageBox::critical(0,tr("Error sending mail"), | 156 | QMessageBox::critical(0,i18n("Error sending mail"), |
156 | tr("<center>%1</center>").arg(failuremessage)); | 157 | i18n("<center>%1</center>").arg(failuremessage)); |
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | int SMTPwrapper::start_smtp_tls() | 161 | int SMTPwrapper::start_smtp_tls() |
161 | { | 162 | { |
162 | if (!m_smtp) { | 163 | if (!m_smtp) { |
163 | return MAILSMTP_ERROR_IN_PROCESSING; | 164 | return MAILSMTP_ERROR_IN_PROCESSING; |
164 | } | 165 | } |
165 | int err = mailesmtp_starttls(m_smtp); | 166 | int err = mailesmtp_starttls(m_smtp); |
166 | if (err != MAILSMTP_NO_ERROR) return err; | 167 | if (err != MAILSMTP_NO_ERROR) return err; |
167 | mailstream_low * low; | 168 | mailstream_low * low; |
168 | mailstream_low * new_low; | 169 | mailstream_low * new_low; |
169 | low = mailstream_get_low(m_smtp->stream); | 170 | low = mailstream_get_low(m_smtp->stream); |
170 | if (!low) { | 171 | if (!low) { |
171 | return MAILSMTP_ERROR_IN_PROCESSING; | 172 | return MAILSMTP_ERROR_IN_PROCESSING; |
172 | } | 173 | } |
173 | int fd = mailstream_low_get_fd(low); | 174 | int fd = mailstream_low_get_fd(low); |
174 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 175 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
175 | mailstream_low_free(low); | 176 | mailstream_low_free(low); |
176 | mailstream_set_low(m_smtp->stream, new_low); | 177 | mailstream_set_low(m_smtp->stream, new_low); |
177 | } else { | 178 | } else { |
178 | return MAILSMTP_ERROR_IN_PROCESSING; | 179 | return MAILSMTP_ERROR_IN_PROCESSING; |
179 | } | 180 | } |
180 | return err; | 181 | return err; |
181 | } | 182 | } |
182 | 183 | ||
183 | void SMTPwrapper::connect_server() | 184 | void SMTPwrapper::connect_server() |
184 | { | 185 | { |
185 | QString server, user, pass; | 186 | QString server, user, pass; |
186 | bool ssl; | 187 | bool ssl; |
187 | uint16_t port; | 188 | uint16_t port; |
188 | ssl = false; | 189 | ssl = false; |
189 | bool try_tls = true; | 190 | bool try_tls = true; |
190 | bool force_tls=false; | 191 | bool force_tls=false; |
191 | QString failuretext = ""; | 192 | QString failuretext = ""; |
192 | 193 | ||
193 | if (m_smtp || !m_SmtpAccount) { | 194 | if (m_smtp || !m_SmtpAccount) { |
194 | return; | 195 | return; |
195 | } | 196 | } |
196 | server = m_SmtpAccount->getServer(); | 197 | server = m_SmtpAccount->getServer(); |
197 | if ( m_SmtpAccount->ConnectionType() == 2 ) { | 198 | if ( m_SmtpAccount->ConnectionType() == 2 ) { |
198 | ssl = true; | 199 | ssl = true; |
199 | try_tls = false; | 200 | try_tls = false; |
200 | } else if (m_SmtpAccount->ConnectionType() == 1) { | 201 | } else if (m_SmtpAccount->ConnectionType() == 1) { |
201 | force_tls = true; | 202 | force_tls = true; |
202 | } | 203 | } |
203 | int result = 1; | 204 | int result = 1; |
204 | port = m_SmtpAccount->getPort().toUInt(); | 205 | port = m_SmtpAccount->getPort().toUInt(); |
205 | 206 | ||
206 | m_smtp = mailsmtp_new( 20, &progress ); | 207 | m_smtp = mailsmtp_new( 20, &progress ); |
207 | if ( m_smtp == NULL ) { | 208 | if ( m_smtp == NULL ) { |
208 | /* no failure message cause this happens when problems with memory - than we | 209 | /* no failure message cause this happens when problems with memory - than we |
209 | we can not display any messagebox */ | 210 | we can not display any messagebox */ |
210 | return; | 211 | return; |
211 | } | 212 | } |
212 | 213 | ||
213 | int err = MAILSMTP_NO_ERROR; | 214 | int err = MAILSMTP_NO_ERROR; |
214 | ; // odebug << "Servername " << server << " at port " << port << "" << oendl; | 215 | ; // odebug << "Servername " << server << " at port " << port << "" << oendl; |
215 | if ( ssl ) { | 216 | if ( ssl ) { |
216 | ; // odebug << "SSL session" << oendl; | 217 | ; // odebug << "SSL session" << oendl; |
217 | err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); | 218 | err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); |
218 | } else { | 219 | } else { |
219 | ; // odebug << "No SSL session" << oendl; | 220 | ; // odebug << "No SSL session" << oendl; |
220 | err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); | 221 | err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); |
221 | } | 222 | } |
222 | if ( err != MAILSMTP_NO_ERROR ) { | 223 | if ( err != MAILSMTP_NO_ERROR ) { |
223 | ; // odebug << "Error init connection" << oendl; | 224 | ; // odebug << "Error init connection" << oendl; |
224 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 225 | failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
225 | result = 0; | 226 | result = 0; |
226 | } | 227 | } |
227 | 228 | ||
228 | /* switch to tls after init 'cause there it will send the ehlo */ | 229 | /* switch to tls after init 'cause there it will send the ehlo */ |
229 | if (result) { | 230 | if (result) { |
230 | err = mailsmtp_init( m_smtp ); | 231 | err = mailsmtp_init( m_smtp ); |
231 | if (err != MAILSMTP_NO_ERROR) { | 232 | if (err != MAILSMTP_NO_ERROR) { |
232 | result = 0; | 233 | result = 0; |
233 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 234 | failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
237 | if (try_tls) { | 238 | if (try_tls) { |
238 | err = start_smtp_tls(); | 239 | err = start_smtp_tls(); |
239 | if (err != MAILSMTP_NO_ERROR) { | 240 | if (err != MAILSMTP_NO_ERROR) { |
240 | try_tls = false; | 241 | try_tls = false; |
241 | } else { | 242 | } else { |
242 | err = mailesmtp_ehlo(m_smtp); | 243 | err = mailesmtp_ehlo(m_smtp); |
243 | } | 244 | } |
244 | } | 245 | } |
245 | 246 | ||
246 | if (!try_tls && force_tls) { | 247 | if (!try_tls && force_tls) { |
247 | result = 0; | 248 | result = 0; |
248 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); | 249 | failuretext = i18n("Error init SMTP tls: %1").arg(mailsmtpError(err)); |
249 | } | 250 | } |
250 | 251 | ||
251 | if (result==1 && m_SmtpAccount->getLogin() ) { | 252 | if (result==1 && m_SmtpAccount->getLogin() ) { |
252 | ; // odebug << "smtp with auth" << oendl; | 253 | ; // odebug << "smtp with auth" << oendl; |
253 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { | 254 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { |
254 | // get'em | 255 | // get'em |
255 | LoginDialog login( m_SmtpAccount->getUser(), | 256 | LoginDialog login( m_SmtpAccount->getUser(), |
256 | m_SmtpAccount->getPassword(), NULL, 0, true ); | 257 | m_SmtpAccount->getPassword(), NULL, 0, true ); |
257 | login.show(); | 258 | login.show(); |
258 | if ( QDialog::Accepted == login.exec() ) { | 259 | if ( QDialog::Accepted == login.exec() ) { |
259 | // ok | 260 | // ok |
260 | user = login.getUser(); | 261 | user = login.getUser(); |
261 | pass = login.getPassword(); | 262 | pass = login.getPassword(); |
262 | } else { | 263 | } else { |
263 | result = 0; | 264 | result = 0; |
264 | failuretext=tr("Login aborted - storing mail to localfolder"); | 265 | failuretext=i18n("Login aborted - storing mail to localfolder"); |
265 | } | 266 | } |
266 | } else { | 267 | } else { |
267 | user = m_SmtpAccount->getUser(); | 268 | user = m_SmtpAccount->getUser(); |
268 | pass = m_SmtpAccount->getPassword(); | 269 | pass = m_SmtpAccount->getPassword(); |
269 | } | 270 | } |
270 | ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; | 271 | ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; |
271 | if (result) { | 272 | if (result) { |
272 | err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); | 273 | err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); |
273 | if ( err == MAILSMTP_NO_ERROR ) { | 274 | if ( err == MAILSMTP_NO_ERROR ) { |
274 | ; // odebug << "auth ok" << oendl; | 275 | ; // odebug << "auth ok" << oendl; |
275 | } else { | 276 | } else { |
276 | failuretext = tr("Authentification failed"); | 277 | failuretext = i18n("Authentification failed"); |
277 | result = 0; | 278 | result = 0; |
278 | } | 279 | } |
279 | } | 280 | } |
280 | } | 281 | } |
281 | } | 282 | } |
282 | 283 | ||
283 | void SMTPwrapper::disc_server() | 284 | void SMTPwrapper::disc_server() |
284 | { | 285 | { |
285 | if (m_smtp) { | 286 | if (m_smtp) { |
286 | mailsmtp_quit( m_smtp ); | 287 | mailsmtp_quit( m_smtp ); |
287 | mailsmtp_free( m_smtp ); | 288 | mailsmtp_free( m_smtp ); |
288 | m_smtp = 0; | 289 | m_smtp = 0; |
289 | } | 290 | } |
290 | } | 291 | } |
291 | 292 | ||
292 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | 293 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) |
293 | { | 294 | { |
294 | int err,result; | 295 | int err,result; |
295 | QString failuretext = ""; | 296 | QString failuretext = ""; |
296 | 297 | ||
297 | connect_server(); | 298 | connect_server(); |
298 | 299 | ||
299 | result = 1; | 300 | result = 1; |
300 | if (m_smtp) { | 301 | if (m_smtp) { |
301 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); | 302 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); |
302 | if ( err != MAILSMTP_NO_ERROR ) { | 303 | if ( err != MAILSMTP_NO_ERROR ) { |
303 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); | 304 | failuretext=i18n("Error sending mail: %1").arg(mailsmtpError(err)); |
304 | result = 0; | 305 | result = 0; |
305 | } | 306 | } |
306 | } else { | 307 | } else { |
307 | result = 0; | 308 | result = 0; |
308 | } | 309 | } |
309 | 310 | ||
310 | if (!result) { | 311 | if (!result) { |
311 | storeFailedMail(data,size,failuretext); | 312 | storeFailedMail(data,size,failuretext); |
312 | } else { | 313 | } else { |
313 | ; // odebug << "Mail sent." << oendl; | 314 | ; // odebug << "Mail sent." << oendl; |
314 | storeMail(data,size,"Sent"); | 315 | storeMail(data,size,"Sent"); |
315 | } | 316 | } |
316 | return result; | 317 | return result; |
317 | } | 318 | } |
318 | 319 | ||
319 | bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) | 320 | bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) |
320 | { | 321 | { |
321 | mailmime * mimeMail; | 322 | mailmime * mimeMail; |
322 | bool result = true; | 323 | bool result = true; |
323 | mimeMail = createMimeMail(mail ); | 324 | mimeMail = createMimeMail(mail ); |
324 | if ( mimeMail == 0 ) { | 325 | if ( mimeMail == 0 ) { |
325 | qDebug("SMTP wrapper:Error creating mail! "); | 326 | qDebug("SMTP wrapper:Error creating mail! "); |
326 | return false; | 327 | return false; |
327 | } else { | 328 | } else { |
328 | sendProgress = new progressMailSend(); | 329 | sendProgress = new progressMailSend(); |
329 | sendProgress->show(); | 330 | sendProgress->show(); |
330 | sendProgress->setMaxMails(1); | 331 | sendProgress->setMaxMails(1); |
331 | result = smtpSend( mimeMail,later); | 332 | result = smtpSend( mimeMail,later); |
332 | ; // odebug << "Clean up done" << oendl; | 333 | ; // odebug << "Clean up done" << oendl; |
333 | sendProgress->hide(); | 334 | sendProgress->hide(); |
334 | delete sendProgress; | 335 | delete sendProgress; |
335 | sendProgress = 0; | 336 | sendProgress = 0; |
336 | mailmime_free( mimeMail ); | 337 | mailmime_free( mimeMail ); |
337 | } | 338 | } |
338 | return result; | 339 | return result; |
339 | } | 340 | } |
340 | 341 | ||
341 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { | 342 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { |
342 | size_t curTok = 0; | 343 | size_t curTok = 0; |
343 | mailimf_fields *fields = 0; | 344 | mailimf_fields *fields = 0; |
344 | mailimf_field*ffrom = 0; | 345 | mailimf_field*ffrom = 0; |
345 | clist *rcpts = 0; | 346 | clist *rcpts = 0; |
346 | char*from = 0; | 347 | char*from = 0; |
347 | int res = 0; | 348 | int res = 0; |
348 | 349 | ||
349 | encodedString * data = wrap->fetchRawBody(which); | 350 | encodedString * data = wrap->fetchRawBody(which); |
350 | if (!data) | 351 | if (!data) |
351 | return 0; | 352 | return 0; |
352 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 353 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
353 | if (err != MAILIMF_NO_ERROR) { | 354 | if (err != MAILIMF_NO_ERROR) { |
354 | delete data; | 355 | delete data; |
355 | delete wrap; | 356 | delete wrap; |
356 | return 0; | 357 | return 0; |
357 | } | 358 | } |
358 | 359 | ||
359 | rcpts = createRcptList( fields ); | 360 | rcpts = createRcptList( fields ); |
360 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 361 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
361 | from = getFrom(ffrom); | 362 | from = getFrom(ffrom); |
362 | 363 | ||
363 | if (rcpts && from) { | 364 | if (rcpts && from) { |
364 | res = smtpSend(from,rcpts,data->Content(),data->Length()); | 365 | res = smtpSend(from,rcpts,data->Content(),data->Length()); |
365 | } | 366 | } |
366 | if (fields) { | 367 | if (fields) { |
367 | mailimf_fields_free(fields); | 368 | mailimf_fields_free(fields); |
368 | fields = 0; | 369 | fields = 0; |
369 | } | 370 | } |
370 | if (data) { | 371 | if (data) { |
371 | delete data; | 372 | delete data; |
372 | } | 373 | } |
373 | if (from) { | 374 | if (from) { |
374 | free(from); | 375 | free(from); |
375 | } | 376 | } |
376 | if (rcpts) { | 377 | if (rcpts) { |
377 | smtp_address_list_free( rcpts ); | 378 | smtp_address_list_free( rcpts ); |
378 | } | 379 | } |
379 | return res; | 380 | return res; |
380 | } | 381 | } |
381 | 382 | ||
382 | /* this is a special fun */ | 383 | /* this is a special fun */ |
383 | bool SMTPwrapper::flushOutbox() { | 384 | bool SMTPwrapper::flushOutbox() { |
384 | bool returnValue = true; | 385 | bool returnValue = true; |
385 | 386 | ||
386 | ; // odebug << "Sending the queue" << oendl; | 387 | ; // odebug << "Sending the queue" << oendl; |
387 | if (!m_SmtpAccount) { | 388 | if (!m_SmtpAccount) { |
388 | ; // odebug << "No smtp account given" << oendl; | 389 | ; // odebug << "No smtp account given" << oendl; |
389 | return false; | 390 | return false; |
390 | } | 391 | } |
391 | 392 | ||
392 | bool reset_user_value = false; | 393 | bool reset_user_value = false; |
393 | QString localfolders = AbstractMail::defaultLocalfolder(); | 394 | QString localfolders = AbstractMail::defaultLocalfolder(); |
394 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 395 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
395 | if (!wrap) { | 396 | if (!wrap) { |
396 | ; // odebug << "memory error" << oendl; | 397 | ; // odebug << "memory error" << oendl; |
397 | return false; | 398 | return false; |
398 | } | 399 | } |
399 | QString oldPw, oldUser; | 400 | QString oldPw, oldUser; |
400 | QValueList<RecMailP> mailsToSend; | 401 | QValueList<RecMailP> mailsToSend; |
401 | QValueList<RecMailP> mailsToRemove; | 402 | QValueList<RecMailP> mailsToRemove; |
402 | QString mbox("Outgoing"); | 403 | QString mbox("Outgoing"); |
403 | wrap->listMessages(mbox,mailsToSend); | 404 | wrap->listMessages(mbox,mailsToSend); |
404 | if (mailsToSend.count()==0) { | 405 | if (mailsToSend.count()==0) { |
405 | delete wrap; | 406 | delete wrap; |
406 | ; // odebug << "No mails to send" << oendl; | 407 | ; // odebug << "No mails to send" << oendl; |
407 | return false; | 408 | return false; |
408 | } | 409 | } |
409 | 410 | ||
410 | oldPw = m_SmtpAccount->getPassword(); | 411 | oldPw = m_SmtpAccount->getPassword(); |
411 | oldUser = m_SmtpAccount->getUser(); | 412 | oldUser = m_SmtpAccount->getUser(); |
412 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 413 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
413 | // get'em | 414 | // get'em |
414 | QString user,pass; | 415 | QString user,pass; |
415 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); | 416 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); |
416 | login.show(); | 417 | login.show(); |
417 | if ( QDialog::Accepted == login.exec() ) { | 418 | if ( QDialog::Accepted == login.exec() ) { |
418 | // ok | 419 | // ok |
419 | user = login.getUser().latin1(); | 420 | user = login.getUser().latin1(); |
420 | pass = login.getPassword().latin1(); | 421 | pass = login.getPassword().latin1(); |
421 | reset_user_value = true; | 422 | reset_user_value = true; |
422 | m_SmtpAccount->setUser(user); | 423 | m_SmtpAccount->setUser(user); |
423 | m_SmtpAccount->setPassword(pass); | 424 | m_SmtpAccount->setPassword(pass); |
424 | } else { | 425 | } else { |
425 | return true; | 426 | return true; |
426 | } | 427 | } |
427 | } | 428 | } |
428 | 429 | ||
429 | 430 | ||
430 | sendProgress = new progressMailSend(); | 431 | sendProgress = new progressMailSend(); |
431 | sendProgress->show(); | 432 | sendProgress->show(); |
432 | sendProgress->setMaxMails(mailsToSend.count()); | 433 | sendProgress->setMaxMails(mailsToSend.count()); |
433 | 434 | ||
434 | while (mailsToSend.count()>0) { | 435 | while (mailsToSend.count()>0) { |
435 | if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { | 436 | if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { |
436 | QMessageBox::critical(0,tr("Error sending mail"), | 437 | QMessageBox::critical(0,i18n("Error sending mail"), |
437 | tr("Error sending queued mail - breaking")); | 438 | i18n("Error sending queued mail - breaking")); |
438 | returnValue = false; | 439 | returnValue = false; |
439 | break; | 440 | break; |
440 | } | 441 | } |
441 | mailsToRemove.append((*mailsToSend.begin())); | 442 | mailsToRemove.append((*mailsToSend.begin())); |
442 | mailsToSend.remove(mailsToSend.begin()); | 443 | mailsToSend.remove(mailsToSend.begin()); |
443 | sendProgress->setCurrentMails(mailsToRemove.count()); | 444 | sendProgress->setCurrentMails(mailsToRemove.count()); |
444 | } | 445 | } |
445 | if (reset_user_value) { | 446 | if (reset_user_value) { |
446 | m_SmtpAccount->setUser(oldUser); | 447 | m_SmtpAccount->setUser(oldUser); |
447 | m_SmtpAccount->setPassword(oldPw); | 448 | m_SmtpAccount->setPassword(oldPw); |
448 | } | 449 | } |
449 | Config cfg( "mail" ); | 450 | Config cfg( "mail" ); |
450 | cfg.setGroup( "Status" ); | 451 | cfg.setGroup( "Status" ); |
451 | m_queuedMail = 0; | 452 | m_queuedMail = 0; |
452 | cfg.writeEntry( "outgoing", m_queuedMail ); | 453 | cfg.writeEntry( "outgoing", m_queuedMail ); |
453 | emit queuedMails( m_queuedMail ); | 454 | emit queuedMails( m_queuedMail ); |
454 | sendProgress->hide(); | 455 | sendProgress->hide(); |
455 | delete sendProgress; | 456 | delete sendProgress; |
456 | sendProgress = 0; | 457 | sendProgress = 0; |
457 | wrap->deleteMails(mbox,mailsToRemove); | 458 | wrap->deleteMails(mbox,mailsToRemove); |
458 | delete wrap; | 459 | delete wrap; |
459 | return returnValue; | 460 | return returnValue; |
460 | } | 461 | } |
diff --git a/kmicromail/nntpgroupsdlg.cpp b/kmicromail/nntpgroupsdlg.cpp index c94d9fa..a461bdf 100644 --- a/kmicromail/nntpgroupsdlg.cpp +++ b/kmicromail/nntpgroupsdlg.cpp | |||
@@ -1,29 +1,30 @@ | |||
1 | #include "nntpgroupsdlg.h" | 1 | #include "nntpgroupsdlg.h" |
2 | #include "nntpgroups.h" | 2 | #include "nntpgroups.h" |
3 | #include <klocale.h> | ||
3 | 4 | ||
4 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
5 | 6 | ||
6 | #include <qlayout.h> | 7 | #include <qlayout.h> |
7 | 8 | ||
8 | NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name) | 9 | NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name) |
9 | : QDialog(parent,name,true,WStyle_ContextHelp) | 10 | : QDialog(parent,name,true,WStyle_ContextHelp) |
10 | { | 11 | { |
11 | setCaption(tr("Subscribed newsgroups")); | 12 | setCaption(i18n("Subscribed newsgroups")); |
12 | m_Account = account; | 13 | m_Account = account; |
13 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 14 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
14 | dlglayout->setSpacing(2); | 15 | dlglayout->setSpacing(2); |
15 | dlglayout->setMargin(1); | 16 | dlglayout->setMargin(1); |
16 | groupsWidget = new NNTPGroups(account,this); | 17 | groupsWidget = new NNTPGroups(account,this); |
17 | dlglayout->addWidget(groupsWidget); | 18 | dlglayout->addWidget(groupsWidget); |
18 | } | 19 | } |
19 | 20 | ||
20 | NNTPGroupsDlg::~NNTPGroupsDlg() | 21 | NNTPGroupsDlg::~NNTPGroupsDlg() |
21 | { | 22 | { |
22 | } | 23 | } |
23 | 24 | ||
24 | void NNTPGroupsDlg::accept() | 25 | void NNTPGroupsDlg::accept() |
25 | { | 26 | { |
26 | groupsWidget->storeValues(); | 27 | groupsWidget->storeValues(); |
27 | m_Account->save(); | 28 | m_Account->save(); |
28 | QDialog::accept(); | 29 | QDialog::accept(); |
29 | } | 30 | } |
diff --git a/kmicromail/selectsmtp.cpp b/kmicromail/selectsmtp.cpp index 24eced1..ff8b524 100644 --- a/kmicromail/selectsmtp.cpp +++ b/kmicromail/selectsmtp.cpp | |||
@@ -1,63 +1,64 @@ | |||
1 | #include "selectsmtp.h" | 1 | #include "selectsmtp.h" |
2 | #include <libmailwrapper/mailwrapper.h> | 2 | #include <libmailwrapper/mailwrapper.h> |
3 | 3 | ||
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qtabwidget.h> | 10 | #include <qtabwidget.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <klocale.h> | ||
12 | selectsmtp::selectsmtp(QWidget* parent, const char* name, bool modal, WFlags fl) | 13 | selectsmtp::selectsmtp(QWidget* parent, const char* name, bool modal, WFlags fl) |
13 | : selectstoreui(parent,name,modal,fl) | 14 | : selectstoreui(parent,name,modal,fl) |
14 | { | 15 | { |
15 | //m_smtpList.setAutoDelete(false); | 16 | //m_smtpList.setAutoDelete(false); |
16 | m_smtpList = 0; | 17 | m_smtpList = 0; |
17 | //headlabel->setText(tr("<center>Select SMTP account to use</center>")); | 18 | //headlabel->setText(i18n("<center>Select SMTP account to use</center>")); |
18 | headlabel->hide(); | 19 | headlabel->hide(); |
19 | folderSelection->hide(); | 20 | folderSelection->hide(); |
20 | folderLabel->hide(); | 21 | folderLabel->hide(); |
21 | accountlabel->setText("<center>SMTP Accounts</center>"); | 22 | accountlabel->setText("<center>SMTP Accounts</center>"); |
22 | Line1->hide(); | 23 | Line1->hide(); |
23 | newFoldersel->hide(); | 24 | newFoldersel->hide(); |
24 | newFolderedit->hide(); | 25 | newFolderedit->hide(); |
25 | newFolderLabel->hide(); | 26 | newFolderLabel->hide(); |
26 | Line2->hide(); | 27 | Line2->hide(); |
27 | selMove->hide(); | 28 | selMove->hide(); |
28 | m_current_smtp = 0; | 29 | m_current_smtp = 0; |
29 | setCaption(tr("Select SMTP Account")); | 30 | setCaption(i18n("Select SMTP Account")); |
30 | } | 31 | } |
31 | 32 | ||
32 | selectsmtp::~selectsmtp() | 33 | selectsmtp::~selectsmtp() |
33 | { | 34 | { |
34 | } | 35 | } |
35 | 36 | ||
36 | void selectsmtp::slotAccountselected(int which) | 37 | void selectsmtp::slotAccountselected(int which) |
37 | { | 38 | { |
38 | if (!m_smtpList || (unsigned)which>=m_smtpList->count() || which < 0) { | 39 | if (!m_smtpList || (unsigned)which>=m_smtpList->count() || which < 0) { |
39 | m_current_smtp = 0; | 40 | m_current_smtp = 0; |
40 | return; | 41 | return; |
41 | } | 42 | } |
42 | m_current_smtp = m_smtpList->at(which); | 43 | m_current_smtp = m_smtpList->at(which); |
43 | } | 44 | } |
44 | 45 | ||
45 | void selectsmtp::setSelectionlist(QList<SMTPaccount>*list) | 46 | void selectsmtp::setSelectionlist(QList<SMTPaccount>*list) |
46 | { | 47 | { |
47 | m_smtpList = list; | 48 | m_smtpList = list; |
48 | accountSelection->clear(); | 49 | accountSelection->clear(); |
49 | if (!m_smtpList || m_smtpList->count()==0) { | 50 | if (!m_smtpList || m_smtpList->count()==0) { |
50 | accountSelection->setEnabled(false); | 51 | accountSelection->setEnabled(false); |
51 | return; | 52 | return; |
52 | } | 53 | } |
53 | accountSelection->setEnabled(true); | 54 | accountSelection->setEnabled(true); |
54 | for (unsigned i = 0; m_smtpList!=0 && i < m_smtpList->count(); ++i) { | 55 | for (unsigned i = 0; m_smtpList!=0 && i < m_smtpList->count(); ++i) { |
55 | accountSelection->insertItem( m_smtpList->at(i)->getAccountName()); | 56 | accountSelection->insertItem( m_smtpList->at(i)->getAccountName()); |
56 | } | 57 | } |
57 | m_current_smtp = m_smtpList->at(0); | 58 | m_current_smtp = m_smtpList->at(0); |
58 | } | 59 | } |
59 | 60 | ||
60 | SMTPaccount*selectsmtp::selected_smtp() | 61 | SMTPaccount*selectsmtp::selected_smtp() |
61 | { | 62 | { |
62 | return m_current_smtp; | 63 | return m_current_smtp; |
63 | } | 64 | } |
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 32a3b7c..7cf5c8e 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -1,531 +1,532 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include "composemail.h" | 2 | #include "composemail.h" |
3 | #include "viewmail.h" | 3 | #include "viewmail.h" |
4 | 4 | ||
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 | #include <kapplication.h> | 8 | #include <kapplication.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/odebug.h> | 11 | //#include <opie2/odebug.h> |
12 | //#include <opie2/ofiledialog.h> | 12 | //#include <opie2/ofiledialog.h> |
13 | //#include <opie2/oimagescrollview.h> | 13 | //#include <opie2/oimagescrollview.h> |
14 | 14 | ||
15 | #include <kfiledialog.h> | 15 | #include <kfiledialog.h> |
16 | #include <kdialog.h> | 16 | #include <kdialog.h> |
17 | 17 | ||
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | #include <klocale.h> | ||
29 | 30 | ||
30 | //using namespace Opie::Ui; | 31 | //using namespace Opie::Ui; |
31 | //using namespace Opie::Core; | 32 | //using namespace Opie::Core; |
32 | 33 | ||
33 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 34 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
34 | const QString&fsize,int num,const QValueList<int>&path) | 35 | const QString&fsize,int num,const QValueList<int>&path) |
35 | : QListViewItem(parent,after),_partNum(num) | 36 | : QListViewItem(parent,after),_partNum(num) |
36 | { | 37 | { |
37 | _path=path; | 38 | _path=path; |
38 | setText(0, mime); | 39 | setText(0, mime); |
39 | setText(1, desc); | 40 | setText(1, desc); |
40 | setText(2, file); | 41 | setText(2, file); |
41 | setText(3, fsize); | 42 | setText(3, fsize); |
42 | } | 43 | } |
43 | 44 | ||
44 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 45 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
45 | const QString&fsize,int num,const QValueList<int>&path) | 46 | const QString&fsize,int num,const QValueList<int>&path) |
46 | : QListViewItem(parent,after),_partNum(num) | 47 | : QListViewItem(parent,after),_partNum(num) |
47 | { | 48 | { |
48 | _path=path; | 49 | _path=path; |
49 | setText(0, mime); | 50 | setText(0, mime); |
50 | setText(1, desc); | 51 | setText(1, desc); |
51 | setText(2, file); | 52 | setText(2, file); |
52 | setText(3, fsize); | 53 | setText(3, fsize); |
53 | } | 54 | } |
54 | 55 | ||
55 | bool AttachItem::isParentof(const QValueList<int>&path) | 56 | bool AttachItem::isParentof(const QValueList<int>&path) |
56 | { | 57 | { |
57 | /* if not set, then no parent */ | 58 | /* if not set, then no parent */ |
58 | if (path.count()==0||_path.count()==0) return false; | 59 | if (path.count()==0||_path.count()==0) return false; |
59 | /* the parent must have one digit less then a child */ | 60 | /* the parent must have one digit less then a child */ |
60 | if (path.count()!=_path.count()+1) return false; | 61 | if (path.count()!=_path.count()+1) return false; |
61 | for (unsigned int i=0; i < _path.count();++i) | 62 | for (unsigned int i=0; i < _path.count();++i) |
62 | { | 63 | { |
63 | if (_path[i]!=path[i]) return false; | 64 | if (_path[i]!=path[i]) return false; |
64 | } | 65 | } |
65 | return true; | 66 | return true; |
66 | } | 67 | } |
67 | 68 | ||
68 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 69 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
69 | { | 70 | { |
70 | QListViewItemIterator it( attachments ); | 71 | QListViewItemIterator it( attachments ); |
71 | for ( ; it.current(); ++it ) | 72 | for ( ; it.current(); ++it ) |
72 | { | 73 | { |
73 | AttachItem*ati = (AttachItem*)it.current(); | 74 | AttachItem*ati = (AttachItem*)it.current(); |
74 | if (ati->isParentof(path)) return ati; | 75 | if (ati->isParentof(path)) return ati; |
75 | } | 76 | } |
76 | return 0; | 77 | return 0; |
77 | } | 78 | } |
78 | 79 | ||
79 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 80 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
80 | { | 81 | { |
81 | if (!parent) return 0; | 82 | if (!parent) return 0; |
82 | AttachItem* item = (AttachItem*)parent->firstChild(); | 83 | AttachItem* item = (AttachItem*)parent->firstChild(); |
83 | if (!item) return item; | 84 | if (!item) return item; |
84 | AttachItem*temp=0; | 85 | AttachItem*temp=0; |
85 | while( (temp=(AttachItem*)item->nextSibling())) | 86 | while( (temp=(AttachItem*)item->nextSibling())) |
86 | { | 87 | { |
87 | item = temp; | 88 | item = temp; |
88 | } | 89 | } |
89 | return item; | 90 | return item; |
90 | } | 91 | } |
91 | 92 | ||
92 | void ViewMail::setBody(const RecBodyP&body ) | 93 | void ViewMail::setBody(const RecBodyP&body ) |
93 | { | 94 | { |
94 | 95 | ||
95 | m_body = body; | 96 | m_body = body; |
96 | m_mail[2] = body->Bodytext(); | 97 | m_mail[2] = body->Bodytext(); |
97 | attachbutton->setEnabled(body->Parts().count()>0); | 98 | attachbutton->setEnabled(body->Parts().count()>0); |
98 | attachments->setEnabled(body->Parts().count()>0); | 99 | attachments->setEnabled(body->Parts().count()>0); |
99 | if (body->Parts().count()==0) | 100 | if (body->Parts().count()==0) |
100 | { | 101 | { |
101 | return; | 102 | return; |
102 | } | 103 | } |
103 | AttachItem * curItem=0; | 104 | AttachItem * curItem=0; |
104 | AttachItem * parentItem = 0; | 105 | AttachItem * parentItem = 0; |
105 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 106 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
106 | QString desc,fsize; | 107 | QString desc,fsize; |
107 | double s = body->Description()->Size(); | 108 | double s = body->Description()->Size(); |
108 | int w; | 109 | int w; |
109 | w=0; | 110 | w=0; |
110 | 111 | ||
111 | while (s>1024) | 112 | while (s>1024) |
112 | { | 113 | { |
113 | s/=1024; | 114 | s/=1024; |
114 | ++w; | 115 | ++w; |
115 | if (w>=2) break; | 116 | if (w>=2) break; |
116 | } | 117 | } |
117 | 118 | ||
118 | QString q=""; | 119 | QString q=""; |
119 | switch(w) | 120 | switch(w) |
120 | { | 121 | { |
121 | case 1: | 122 | case 1: |
122 | q="k"; | 123 | q="k"; |
123 | break; | 124 | break; |
124 | case 2: | 125 | case 2: |
125 | q="M"; | 126 | q="M"; |
126 | break; | 127 | break; |
127 | default: | 128 | default: |
128 | break; | 129 | break; |
129 | } | 130 | } |
130 | 131 | ||
131 | { | 132 | { |
132 | /* I did not found a method to make a CONTENT reset on a QTextStream | 133 | /* I did not found a method to make a CONTENT reset on a QTextStream |
133 | so I use this construct that the stream will re-constructed in each | 134 | so I use this construct that the stream will re-constructed in each |
134 | loop. To let it work, the textstream is packed into a own area of | 135 | loop. To let it work, the textstream is packed into a own area of |
135 | code is it will be destructed after finishing its small job. | 136 | code is it will be destructed after finishing its small job. |
136 | */ | 137 | */ |
137 | QTextOStream o(&fsize); | 138 | QTextOStream o(&fsize); |
138 | if (w>0) o.precision(2); else o.precision(0); | 139 | if (w>0) o.precision(2); else o.precision(0); |
139 | o.setf(QTextStream::fixed); | 140 | o.setf(QTextStream::fixed); |
140 | o << s << " " << q << "Byte"; | 141 | o << s << " " << q << "Byte"; |
141 | } | 142 | } |
142 | 143 | ||
143 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 144 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
144 | QString filename = ""; | 145 | QString filename = ""; |
145 | 146 | ||
146 | for (unsigned int i = 0; i < body->Parts().count();++i) | 147 | for (unsigned int i = 0; i < body->Parts().count();++i) |
147 | { | 148 | { |
148 | filename = ""; | 149 | filename = ""; |
149 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 150 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
150 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 151 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
151 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 152 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
152 | { | 153 | { |
153 | if (it.key().lower()=="name") | 154 | if (it.key().lower()=="name") |
154 | { | 155 | { |
155 | filename=it.data(); | 156 | filename=it.data(); |
156 | } | 157 | } |
157 | } | 158 | } |
158 | s = body->Parts()[i]->Size(); | 159 | s = body->Parts()[i]->Size(); |
159 | w = 0; | 160 | w = 0; |
160 | while (s>1024) | 161 | while (s>1024) |
161 | { | 162 | { |
162 | s/=1024; | 163 | s/=1024; |
163 | ++w; | 164 | ++w; |
164 | if (w>=2) break; | 165 | if (w>=2) break; |
165 | } | 166 | } |
166 | switch(w) | 167 | switch(w) |
167 | { | 168 | { |
168 | case 1: | 169 | case 1: |
169 | q="k"; | 170 | q="k"; |
170 | break; | 171 | break; |
171 | case 2: | 172 | case 2: |
172 | q="M"; | 173 | q="M"; |
173 | break; | 174 | break; |
174 | default: | 175 | default: |
175 | q=""; | 176 | q=""; |
176 | break; | 177 | break; |
177 | } | 178 | } |
178 | QTextOStream o(&fsize); | 179 | QTextOStream o(&fsize); |
179 | if (w>0) o.precision(2); else o.precision(0); | 180 | if (w>0) o.precision(2); else o.precision(0); |
180 | o.setf(QTextStream::fixed); | 181 | o.setf(QTextStream::fixed); |
181 | o << s << " " << q << "Byte"; | 182 | o << s << " " << q << "Byte"; |
182 | desc = body->Parts()[i]->Description(); | 183 | desc = body->Parts()[i]->Description(); |
183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 184 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
184 | if (parentItem) | 185 | if (parentItem) |
185 | { | 186 | { |
186 | AttachItem*temp = lastChild(parentItem); | 187 | AttachItem*temp = lastChild(parentItem); |
187 | if (temp) curItem = temp; | 188 | if (temp) curItem = temp; |
188 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 189 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
189 | attachments->setRootIsDecorated(true); | 190 | attachments->setRootIsDecorated(true); |
190 | curItem = parentItem; | 191 | curItem = parentItem; |
191 | } | 192 | } |
192 | else | 193 | else |
193 | { | 194 | { |
194 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 195 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
199 | 200 | ||
200 | void ViewMail::slotShowHtml( bool state ) | 201 | void ViewMail::slotShowHtml( bool state ) |
201 | { | 202 | { |
202 | m_showHtml = state; | 203 | m_showHtml = state; |
203 | setText(); | 204 | setText(); |
204 | } | 205 | } |
205 | 206 | ||
206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 207 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
207 | { | 208 | { |
208 | if (!item ) | 209 | if (!item ) |
209 | return; | 210 | return; |
210 | 211 | ||
211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 212 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
212 | { | 213 | { |
213 | setText(); | 214 | setText(); |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | QPopupMenu *menu = new QPopupMenu(); | 217 | QPopupMenu *menu = new QPopupMenu(); |
217 | int ret=0; | 218 | int ret=0; |
218 | 219 | ||
219 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 220 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
220 | { | 221 | { |
221 | menu->insertItem( tr( "Show Text" ), 1 ); | 222 | menu->insertItem( i18n( "Show Text" ), 1 ); |
222 | } | 223 | } |
223 | if (item->text(0).left(6)=="image/") { | 224 | if (item->text(0).left(6)=="image/") { |
224 | menu->insertItem(tr("Display image preview"),2); | 225 | menu->insertItem(i18n("Display image preview"),2); |
225 | } | 226 | } |
226 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 227 | menu->insertItem( i18n( "Save Attachment" ), 0 ); |
227 | menu->insertSeparator(1); | 228 | menu->insertSeparator(1); |
228 | 229 | ||
229 | ret = menu->exec( point, 0 ); | 230 | ret = menu->exec( point, 0 ); |
230 | 231 | ||
231 | switch(ret) | 232 | switch(ret) |
232 | { | 233 | { |
233 | case 0: | 234 | case 0: |
234 | { | 235 | { |
235 | //MimeTypes types; | 236 | //MimeTypes types; |
236 | //types.insert( "all", "*" ); | 237 | //types.insert( "all", "*" ); |
237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 238 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
238 | 239 | ||
239 | if( !str.isEmpty() ) | 240 | if( !str.isEmpty() ) |
240 | { | 241 | { |
241 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 242 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
242 | if (content) | 243 | if (content) |
243 | { | 244 | { |
244 | QFile output(str); | 245 | QFile output(str); |
245 | output.open(IO_WriteOnly); | 246 | output.open(IO_WriteOnly); |
246 | output.writeBlock(content->Content(),content->Length()); | 247 | output.writeBlock(content->Content(),content->Length()); |
247 | output.close(); | 248 | output.close(); |
248 | delete content; | 249 | delete content; |
249 | } | 250 | } |
250 | } | 251 | } |
251 | } | 252 | } |
252 | break ; | 253 | break ; |
253 | 254 | ||
254 | case 2: | 255 | case 2: |
255 | { | 256 | { |
256 | #ifdef DESKTOP_VERSION | 257 | #ifdef DESKTOP_VERSION |
257 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | 258 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); |
258 | #else | 259 | #else |
259 | QString tmpfile = "/tmp/opiemail-image"; | 260 | QString tmpfile = "/tmp/opiemail-image"; |
260 | #endif | 261 | #endif |
261 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 262 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
262 | if (content) { | 263 | if (content) { |
263 | QFile output(tmpfile); | 264 | QFile output(tmpfile); |
264 | output.open(IO_WriteOnly); | 265 | output.open(IO_WriteOnly); |
265 | output.writeBlock(content->Content(),content->Length()); | 266 | output.writeBlock(content->Content(),content->Length()); |
266 | output.close(); | 267 | output.close(); |
267 | delete content; | 268 | delete content; |
268 | MailImageDlg iview(""); | 269 | MailImageDlg iview(""); |
269 | iview.setName(tmpfile); | 270 | iview.setName(tmpfile); |
270 | KApplication::execDialog(&iview); | 271 | KApplication::execDialog(&iview); |
271 | output.remove(); | 272 | output.remove(); |
272 | } | 273 | } |
273 | } | 274 | } |
274 | break; | 275 | break; |
275 | case 1: | 276 | case 1: |
276 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 277 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
277 | { | 278 | { |
278 | setText(); | 279 | setText(); |
279 | } | 280 | } |
280 | else | 281 | else |
281 | { | 282 | { |
282 | if ( m_recMail->Wrapper() != 0l ) | 283 | if ( m_recMail->Wrapper() != 0l ) |
283 | { // make sure that there is a wrapper , even after delete or simular actions | 284 | { // make sure that there is a wrapper , even after delete or simular actions |
284 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 285 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
285 | } | 286 | } |
286 | } | 287 | } |
287 | break; | 288 | break; |
288 | } | 289 | } |
289 | delete menu; | 290 | delete menu; |
290 | } | 291 | } |
291 | 292 | ||
292 | 293 | ||
293 | void ViewMail::setMail(const RecMailP&mail ) | 294 | void ViewMail::setMail(const RecMailP&mail ) |
294 | { | 295 | { |
295 | 296 | ||
296 | m_recMail = mail; | 297 | m_recMail = mail; |
297 | 298 | ||
298 | m_mail[0] = mail->getFrom(); | 299 | m_mail[0] = mail->getFrom(); |
299 | m_mail[1] = mail->getSubject(); | 300 | m_mail[1] = mail->getSubject(); |
300 | m_mail[3] = mail->getDate(); | 301 | m_mail[3] = mail->getDate(); |
301 | m_mail[4] = mail->Msgid(); | 302 | m_mail[4] = mail->Msgid(); |
302 | 303 | ||
303 | m_mail2[0] = mail->To(); | 304 | m_mail2[0] = mail->To(); |
304 | m_mail2[1] = mail->CC(); | 305 | m_mail2[1] = mail->CC(); |
305 | m_mail2[2] = mail->Bcc(); | 306 | m_mail2[2] = mail->Bcc(); |
306 | 307 | ||
307 | setText(); | 308 | setText(); |
308 | } | 309 | } |
309 | 310 | ||
310 | 311 | ||
311 | 312 | ||
312 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 313 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
313 | : ViewMailBase(parent, name, fl), _inLoop(false) | 314 | : ViewMailBase(parent, name, fl), _inLoop(false) |
314 | { | 315 | { |
315 | m_gotBody = false; | 316 | m_gotBody = false; |
316 | deleted = false; | 317 | deleted = false; |
317 | 318 | ||
318 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 319 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
319 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 320 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
320 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 321 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
321 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 322 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
322 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 323 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
323 | 324 | ||
324 | attachments->setEnabled(m_gotBody); | 325 | attachments->setEnabled(m_gotBody); |
325 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 326 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
326 | 327 | ||
327 | readConfig(); | 328 | readConfig(); |
328 | attachments->setSorting(-1); | 329 | attachments->setSorting(-1); |
329 | } | 330 | } |
330 | 331 | ||
331 | void ViewMail::readConfig() | 332 | void ViewMail::readConfig() |
332 | { | 333 | { |
333 | 334 | ||
334 | setFont ( KOPrefs::instance()->mReadFont ); | 335 | setFont ( KOPrefs::instance()->mReadFont ); |
335 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 336 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
336 | showHtml->setOn( m_showHtml ); | 337 | showHtml->setOn( m_showHtml ); |
337 | } | 338 | } |
338 | 339 | ||
339 | void ViewMail::setText() | 340 | void ViewMail::setText() |
340 | { | 341 | { |
341 | 342 | ||
342 | QString toString; | 343 | QString toString; |
343 | QString ccString; | 344 | QString ccString; |
344 | QString bccString; | 345 | QString bccString; |
345 | 346 | ||
346 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 347 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
347 | { | 348 | { |
348 | toString += (*it); | 349 | toString += (*it); |
349 | } | 350 | } |
350 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 351 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
351 | { | 352 | { |
352 | ccString += (*it); | 353 | ccString += (*it); |
353 | } | 354 | } |
354 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 355 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
355 | { | 356 | { |
356 | bccString += (*it); | 357 | bccString += (*it); |
357 | } | 358 | } |
358 | 359 | ||
359 | setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); | 360 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); |
360 | 361 | ||
361 | m_mailHtml = "<html><body>" | 362 | m_mailHtml = "<html><body>" |
362 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 363 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
363 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 364 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
364 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 365 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
365 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 366 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
366 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 367 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
367 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 368 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
368 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 369 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + |
369 | "</td></tr></table><font>"; | 370 | "</td></tr></table><font>"; |
370 | 371 | ||
371 | if ( !m_showHtml ) | 372 | if ( !m_showHtml ) |
372 | { | 373 | { |
373 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 374 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
374 | } | 375 | } |
375 | else | 376 | else |
376 | { | 377 | { |
377 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 378 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
378 | } | 379 | } |
379 | // remove later in favor of a real handling | 380 | // remove later in favor of a real handling |
380 | m_gotBody = true; | 381 | m_gotBody = true; |
381 | } | 382 | } |
382 | 383 | ||
383 | 384 | ||
384 | ViewMail::~ViewMail() | 385 | ViewMail::~ViewMail() |
385 | { | 386 | { |
386 | m_recMail->Wrapper()->cleanMimeCache(); | 387 | m_recMail->Wrapper()->cleanMimeCache(); |
387 | hide(); | 388 | hide(); |
388 | } | 389 | } |
389 | 390 | ||
390 | void ViewMail::hide() | 391 | void ViewMail::hide() |
391 | { | 392 | { |
392 | QWidget::hide(); | 393 | QWidget::hide(); |
393 | 394 | ||
394 | if (_inLoop) | 395 | if (_inLoop) |
395 | { | 396 | { |
396 | _inLoop = false; | 397 | _inLoop = false; |
397 | qApp->exit_loop(); | 398 | qApp->exit_loop(); |
398 | 399 | ||
399 | } | 400 | } |
400 | 401 | ||
401 | } | 402 | } |
402 | 403 | ||
403 | void ViewMail::exec() | 404 | void ViewMail::exec() |
404 | { | 405 | { |
405 | show(); | 406 | show(); |
406 | 407 | ||
407 | if (!_inLoop) | 408 | if (!_inLoop) |
408 | { | 409 | { |
409 | _inLoop = true; | 410 | _inLoop = true; |
410 | qApp->enter_loop(); | 411 | qApp->enter_loop(); |
411 | } | 412 | } |
412 | 413 | ||
413 | } | 414 | } |
414 | 415 | ||
415 | QString ViewMail::deHtml(const QString &string) | 416 | QString ViewMail::deHtml(const QString &string) |
416 | { | 417 | { |
417 | QString string_ = string; | 418 | QString string_ = string; |
418 | string_.replace(QRegExp("&"), "&"); | 419 | string_.replace(QRegExp("&"), "&"); |
419 | string_.replace(QRegExp("<"), "<"); | 420 | string_.replace(QRegExp("<"), "<"); |
420 | string_.replace(QRegExp(">"), ">"); | 421 | string_.replace(QRegExp(">"), ">"); |
421 | string_.replace(QRegExp("\\n"), "<br>"); | 422 | string_.replace(QRegExp("\\n"), "<br>"); |
422 | return string_; | 423 | return string_; |
423 | } | 424 | } |
424 | 425 | ||
425 | void ViewMail::slotReply() | 426 | void ViewMail::slotReply() |
426 | { | 427 | { |
427 | if (!m_gotBody) | 428 | if (!m_gotBody) |
428 | { | 429 | { |
429 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 430 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); |
430 | return; | 431 | return; |
431 | } | 432 | } |
432 | 433 | ||
433 | QString rtext; | 434 | QString rtext; |
434 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 435 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
435 | .arg( m_mail[0] ) | 436 | .arg( m_mail[0] ) |
436 | .arg( m_mail[3] ); | 437 | .arg( m_mail[3] ); |
437 | 438 | ||
438 | QString text = m_mail[2]; | 439 | QString text = m_mail[2]; |
439 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 440 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
440 | QStringList::Iterator it; | 441 | QStringList::Iterator it; |
441 | for (it = lines.begin(); it != lines.end(); it++) | 442 | for (it = lines.begin(); it != lines.end(); it++) |
442 | { | 443 | { |
443 | rtext += "> " + *it + "\n"; | 444 | rtext += "> " + *it + "\n"; |
444 | } | 445 | } |
445 | rtext += "\n"; | 446 | rtext += "\n"; |
446 | 447 | ||
447 | QString prefix; | 448 | QString prefix; |
448 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 449 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
449 | else prefix = "Re: "; // no i18n on purpose | 450 | else prefix = "Re: "; // no i18n on purpose |
450 | 451 | ||
451 | Settings *settings = new Settings(); | 452 | Settings *settings = new Settings(); |
452 | ComposeMail composer( settings ,this, 0, true); | 453 | ComposeMail composer( settings ,this, 0, true); |
453 | if (m_recMail->Replyto().isEmpty()) { | 454 | if (m_recMail->Replyto().isEmpty()) { |
454 | composer.setTo( m_recMail->getFrom()); | 455 | composer.setTo( m_recMail->getFrom()); |
455 | } else { | 456 | } else { |
456 | composer.setTo( m_recMail->Replyto()); | 457 | composer.setTo( m_recMail->Replyto()); |
457 | } | 458 | } |
458 | composer.setSubject( prefix + m_mail[1] ); | 459 | composer.setSubject( prefix + m_mail[1] ); |
459 | composer.setMessage( rtext ); | 460 | composer.setMessage( rtext ); |
460 | composer.setInReplyTo(m_recMail->Msgid()); | 461 | composer.setInReplyTo(m_recMail->Msgid()); |
461 | 462 | ||
462 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 463 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
463 | { | 464 | { |
464 | m_recMail->Wrapper()->answeredMail(m_recMail); | 465 | m_recMail->Wrapper()->answeredMail(m_recMail); |
465 | } | 466 | } |
466 | } | 467 | } |
467 | 468 | ||
468 | void ViewMail::slotForward() | 469 | void ViewMail::slotForward() |
469 | { | 470 | { |
470 | if (!m_gotBody) | 471 | if (!m_gotBody) |
471 | { | 472 | { |
472 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 473 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); |
473 | return; | 474 | return; |
474 | } | 475 | } |
475 | 476 | ||
476 | QString ftext; | 477 | QString ftext; |
477 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 478 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
478 | .arg( m_mail[0] ); | 479 | .arg( m_mail[0] ); |
479 | if (!m_mail[3].isNull()) | 480 | if (!m_mail[3].isNull()) |
480 | ftext += QString("Date: %1\n") | 481 | ftext += QString("Date: %1\n") |
481 | .arg( m_mail[3] ); | 482 | .arg( m_mail[3] ); |
482 | if (!m_mail[0].isNull()) | 483 | if (!m_mail[0].isNull()) |
483 | ftext += QString("From: %1\n") | 484 | ftext += QString("From: %1\n") |
484 | .arg( m_mail[0] ); | 485 | .arg( m_mail[0] ); |
485 | if (!m_mail[1].isNull()) | 486 | if (!m_mail[1].isNull()) |
486 | ftext += QString("Subject: %1\n") | 487 | ftext += QString("Subject: %1\n") |
487 | .arg( m_mail[1] ); | 488 | .arg( m_mail[1] ); |
488 | 489 | ||
489 | ftext += QString("\n%1\n") | 490 | ftext += QString("\n%1\n") |
490 | .arg( m_mail[2]); | 491 | .arg( m_mail[2]); |
491 | 492 | ||
492 | ftext += QString("----- End forwarded message -----\n"); | 493 | ftext += QString("----- End forwarded message -----\n"); |
493 | 494 | ||
494 | Settings *settings = new Settings(); | 495 | Settings *settings = new Settings(); |
495 | ComposeMail composer( settings ,this, 0, true); | 496 | ComposeMail composer( settings ,this, 0, true); |
496 | composer.setSubject( "Fwd: " + m_mail[1] ); | 497 | composer.setSubject( "Fwd: " + m_mail[1] ); |
497 | composer.setMessage( ftext ); | 498 | composer.setMessage( ftext ); |
498 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 499 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
499 | { | 500 | { |
500 | } | 501 | } |
501 | } | 502 | } |
502 | 503 | ||
503 | void ViewMail::slotDeleteMail( ) | 504 | void ViewMail::slotDeleteMail( ) |
504 | { | 505 | { |
505 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 506 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
506 | { | 507 | { |
507 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 508 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
508 | hide(); | 509 | hide(); |
509 | deleted = true; | 510 | deleted = true; |
510 | } | 511 | } |
511 | } | 512 | } |
512 | 513 | ||
513 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 514 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
514 | : KDialog(parent,name,modal) | 515 | : KDialog(parent,name,modal) |
515 | { | 516 | { |
516 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 517 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
517 | dlglayout->setSpacing(2); | 518 | dlglayout->setSpacing(2); |
518 | dlglayout->setMargin(1); | 519 | dlglayout->setMargin(1); |
519 | //m_imageview = new Opie::MM::OImageScrollView(this); | 520 | //m_imageview = new Opie::MM::OImageScrollView(this); |
520 | //dlglayout->addWidget(m_imageview); | 521 | //dlglayout->addWidget(m_imageview); |
521 | } | 522 | } |
522 | 523 | ||
523 | MailImageDlg::~MailImageDlg() | 524 | MailImageDlg::~MailImageDlg() |
524 | { | 525 | { |
525 | } | 526 | } |
526 | 527 | ||
527 | void MailImageDlg::setName(const QString&fname) | 528 | void MailImageDlg::setName(const QString&fname) |
528 | { | 529 | { |
529 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 530 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
530 | // m_imageview->setImage(fname); | 531 | // m_imageview->setImage(fname); |
531 | } | 532 | } |
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp index 705b57f..3d7ed42 100644 --- a/kmicromail/viewmailbase.cpp +++ b/kmicromail/viewmailbase.cpp | |||
@@ -1,92 +1,93 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include <qtextbrowser.h> | 2 | #include <qtextbrowser.h> |
3 | #include <qlistview.h> | 3 | #include <qlistview.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qvbox.h> | 6 | #include <qvbox.h> |
7 | 7 | ||
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | #include <kiconloader.h> | 10 | #include <kiconloader.h> |
11 | //#include <qpe/resource.h> | 11 | //#include <qpe/resource.h> |
12 | #include <klocale.h> | ||
12 | 13 | ||
13 | #include "viewmailbase.h" | 14 | #include "viewmailbase.h" |
14 | //#include "opendiag.h" | 15 | //#include "opendiag.h" |
15 | 16 | ||
16 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 17 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
17 | : QMainWindow(parent, name, fl) | 18 | : QMainWindow(parent, name, fl) |
18 | { | 19 | { |
19 | 20 | ||
20 | setToolBarsMovable(false); | 21 | setToolBarsMovable(false); |
21 | 22 | ||
22 | toolbar = new QToolBar(this); | 23 | toolbar = new QToolBar(this); |
23 | menubar = new QMenuBar( toolbar ); | 24 | menubar = new QMenuBar( toolbar ); |
24 | mailmenu = new QPopupMenu( menubar ); | 25 | mailmenu = new QPopupMenu( menubar ); |
25 | menubar->insertItem( tr( "Mail" ), mailmenu ); | 26 | menubar->insertItem( i18n( "Mail" ), mailmenu ); |
26 | 27 | ||
27 | toolbar->setHorizontalStretchable(true); | 28 | toolbar->setHorizontalStretchable(true); |
28 | addToolBar(toolbar); | 29 | addToolBar(toolbar); |
29 | 30 | ||
30 | reply = new QAction(tr("Reply"),SmallIcon("reply"), 0, 0, this); | 31 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); |
31 | reply->addTo(toolbar); | 32 | reply->addTo(toolbar); |
32 | reply->addTo(mailmenu); | 33 | reply->addTo(mailmenu); |
33 | 34 | ||
34 | forward = new QAction(tr("Forward"),SmallIcon("forward"), 0, 0, this); | 35 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); |
35 | forward->addTo(toolbar); | 36 | forward->addTo(toolbar); |
36 | forward->addTo(mailmenu); | 37 | forward->addTo(mailmenu); |
37 | 38 | ||
38 | attachbutton = new QAction(tr("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); | 39 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); |
39 | attachbutton->addTo(toolbar); | 40 | attachbutton->addTo(toolbar); |
40 | attachbutton->addTo(mailmenu); | 41 | attachbutton->addTo(mailmenu); |
41 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 42 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
42 | 43 | ||
43 | 44 | ||
44 | showHtml = new QAction( tr( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); | 45 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); |
45 | showHtml->addTo( toolbar ); | 46 | showHtml->addTo( toolbar ); |
46 | showHtml->addTo( mailmenu ); | 47 | showHtml->addTo( mailmenu ); |
47 | 48 | ||
48 | deleteMail = new QAction(tr("Delete Mail"),SmallIcon("trash"), 0, 0, this); | 49 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); |
49 | deleteMail->addTo(toolbar); | 50 | deleteMail->addTo(toolbar); |
50 | deleteMail->addTo(mailmenu); | 51 | deleteMail->addTo(mailmenu); |
51 | closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this); | 52 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
52 | QLabel *spacer = new QLabel(toolbar); | 53 | QLabel *spacer = new QLabel(toolbar); |
53 | spacer->setBackgroundMode(QWidget::PaletteButton); | 54 | spacer->setBackgroundMode(QWidget::PaletteButton); |
54 | toolbar->setStretchableWidget(spacer); | 55 | toolbar->setStretchableWidget(spacer); |
55 | closeMail->addTo(toolbar); | 56 | closeMail->addTo(toolbar); |
56 | closeMail->addTo(mailmenu); | 57 | closeMail->addTo(mailmenu); |
57 | QVBox *view = new QVBox(this); | 58 | QVBox *view = new QVBox(this); |
58 | setCentralWidget(view); | 59 | setCentralWidget(view); |
59 | 60 | ||
60 | attachments = new QListView(view); | 61 | attachments = new QListView(view); |
61 | attachments->setMinimumHeight(90); | 62 | attachments->setMinimumHeight(90); |
62 | attachments->setMaximumHeight(90); | 63 | attachments->setMaximumHeight(90); |
63 | attachments->setAllColumnsShowFocus(true); | 64 | attachments->setAllColumnsShowFocus(true); |
64 | attachments->addColumn("Mime Type", 60); | 65 | attachments->addColumn("Mime Type", 60); |
65 | attachments->addColumn(tr("Description"), 100); | 66 | attachments->addColumn(i18n("Description"), 100); |
66 | attachments->addColumn(tr("Filename"), 80); | 67 | attachments->addColumn(i18n("Filename"), 80); |
67 | attachments->addColumn(tr("Size"), 80); | 68 | attachments->addColumn(i18n("Size"), 80); |
68 | attachments->setSorting(-1); | 69 | attachments->setSorting(-1); |
69 | attachments->hide(); | 70 | attachments->hide(); |
70 | 71 | ||
71 | browser = new QTextBrowser(view); | 72 | browser = new QTextBrowser(view); |
72 | 73 | ||
73 | //openDiag = new OpenDiag(view); | 74 | //openDiag = new OpenDiag(view); |
74 | //openDiag->hide(); | 75 | //openDiag->hide(); |
75 | 76 | ||
76 | } | 77 | } |
77 | 78 | ||
78 | void ViewMailBase::slotChangeAttachview(bool state) | 79 | void ViewMailBase::slotChangeAttachview(bool state) |
79 | { | 80 | { |
80 | if (state) attachments->show(); | 81 | if (state) attachments->show(); |
81 | else attachments->hide(); | 82 | else attachments->hide(); |
82 | } | 83 | } |
83 | 84 | ||
84 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) | 85 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) |
85 | { | 86 | { |
86 | if( e->key()==Qt::Key_Escape ) { | 87 | if( e->key()==Qt::Key_Escape ) { |
87 | close(); | 88 | close(); |
88 | e->accept(); | 89 | e->accept(); |
89 | return; | 90 | return; |
90 | } | 91 | } |
91 | QWidget::keyPressEvent(e); | 92 | QWidget::keyPressEvent(e); |
92 | } | 93 | } |