summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.cpp18
-rw-r--r--kmicromail/accountview.h1
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp26
-rw-r--r--kmicromail/opiemail.cpp2
4 files changed, 35 insertions, 12 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index c9c4a0f..3ad3e9b 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -1,212 +1,230 @@
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#include <klocale.h>
20 20
21using namespace Opie::Core; 21using namespace Opie::Core;
22AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 22AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
23 : QListView( parent, name, flags ) 23 : QListView( parent, name, flags )
24{ 24{
25 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 25 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
26 SLOT( refresh(QListViewItem*) ) ); 26 SLOT( refresh(QListViewItem*) ) );
27 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 27 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
28 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 28 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
29 setSorting(0); 29 setSorting(0);
30} 30}
31 31
32AccountView::~AccountView() 32AccountView::~AccountView()
33{ 33{
34 imapAccounts.clear(); 34 imapAccounts.clear();
35 mhAccounts.clear(); 35 mhAccounts.clear();
36} 36}
37 37
38void AccountView::slotContextMenu(int id) 38void AccountView::slotContextMenu(int id)
39{ 39{
40 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 40 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
41 if (!view) return; 41 if (!view) return;
42 view->contextMenuSelected(id); 42 view->contextMenuSelected(id);
43} 43}
44 44
45void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 45void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
46{ 46{
47 if (button==1) {return;} 47 if (button==1) {return;}
48 if (!item) return; 48 if (!item) return;
49 AccountViewItem *view = static_cast<AccountViewItem *>(item); 49 AccountViewItem *view = static_cast<AccountViewItem *>(item);
50 QPopupMenu*m = view->getContextMenu(); 50 QPopupMenu*m = view->getContextMenu();
51 if (!m) return; 51 if (!m) return;
52 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 52 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
53 m->setFocus(); 53 m->setFocus();
54 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 54 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
55 delete m; 55 delete m;
56} 56}
57 57
58void AccountView::populate( QList<Account> list ) 58void AccountView::populate( QList<Account> list )
59{ 59{
60 clear(); 60 clear();
61 61
62 imapAccounts.clear(); 62 imapAccounts.clear();
63 mhAccounts.clear(); 63 mhAccounts.clear();
64 64
65 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 65 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
66 66
67 Account *it; 67 Account *it;
68 for ( it = list.first(); it; it = list.next() ) 68 for ( it = list.first(); it; it = list.next() )
69 { 69 {
70 if ( it->getType() == MAILLIB::A_IMAP ) 70 if ( it->getType() == MAILLIB::A_IMAP )
71 { 71 {
72 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 72 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
73 imapAccounts.append(new IMAPviewItem( imap, this )); 73 imapAccounts.append(new IMAPviewItem( imap, this ));
74 } 74 }
75 else if ( it->getType() == MAILLIB::A_POP3 ) 75 else if ( it->getType() == MAILLIB::A_POP3 )
76 { 76 {
77 POP3account *pop3 = static_cast<POP3account *>(it); 77 POP3account *pop3 = static_cast<POP3account *>(it);
78 /* must not be hold 'cause it isn't required */ 78 /* must not be hold 'cause it isn't required */
79 (void) new POP3viewItem( pop3, this ); 79 (void) new POP3viewItem( pop3, this );
80 } 80 }
81 else if ( it->getType() == MAILLIB::A_NNTP ) 81 else if ( it->getType() == MAILLIB::A_NNTP )
82 { 82 {
83 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 83 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
84 /* must not be hold 'cause it isn't required */ 84 /* must not be hold 'cause it isn't required */
85 (void) new NNTPviewItem( nntp, this ); 85 (void) new NNTPviewItem( nntp, this );
86 } 86 }
87 } 87 }
88} 88}
89 89
90void AccountView::refresh(QListViewItem *item) 90void AccountView::refresh(QListViewItem *item)
91{ 91{
92 if ( item ) 92 if ( item )
93 { 93 {
94 m_currentItem = item; 94 m_currentItem = item;
95 QValueList<RecMailP> headerlist; 95 QValueList<RecMailP> headerlist;
96 AccountViewItem *view = static_cast<AccountViewItem *>(item); 96 AccountViewItem *view = static_cast<AccountViewItem *>(item);
97 view->refresh(headerlist); 97 view->refresh(headerlist);
98 emit refreshMailview(headerlist); 98 emit refreshMailview(headerlist);
99 } 99 }
100} 100}
101void AccountView::refreshOutgoing()
102{
103 m_currentItem = currentItem();
104 if ( !m_currentItem ) return;
105 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
106 QString bName = view->getFolder()->getDisplayName();
107 if (bName.startsWith("/")&&bName.length()>1)
108 {
109 bName.replace(0,1,"");
110 }
111 int pos = bName.findRev("/");
112 if (pos > 0)
113 {
114 bName.replace(0,pos+1,"");
115 }
116 if ( bName.lower() == "outgoing" )
117 refreshCurrent();
118}
101 119
102void AccountView::refreshCurrent() 120void AccountView::refreshCurrent()
103{ 121{
104 m_currentItem = currentItem(); 122 m_currentItem = currentItem();
105 if ( !m_currentItem ) return; 123 if ( !m_currentItem ) return;
106 QValueList<RecMailP> headerlist; 124 QValueList<RecMailP> headerlist;
107 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 125 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
108 view->refresh(headerlist); 126 view->refresh(headerlist);
109 emit refreshMailview(headerlist); 127 emit refreshMailview(headerlist);
110} 128}
111 129
112void AccountView::refreshAll() 130void AccountView::refreshAll()
113{ 131{
114} 132}
115 133
116RecBodyP AccountView::fetchBody(const RecMailP&aMail) 134RecBodyP AccountView::fetchBody(const RecMailP&aMail)
117{ 135{
118 QListViewItem*item = selectedItem (); 136 QListViewItem*item = selectedItem ();
119 if (!item) return new RecBody(); 137 if (!item) return new RecBody();
120 AccountViewItem *view = static_cast<AccountViewItem *>(item); 138 AccountViewItem *view = static_cast<AccountViewItem *>(item);
121 return view->fetchBody(aMail); 139 return view->fetchBody(aMail);
122} 140}
123 141
124void AccountView::setupFolderselect(Selectstore*sels) 142void AccountView::setupFolderselect(Selectstore*sels)
125{ 143{
126 144
127#ifndef DESKTOP_VERSION 145#ifndef DESKTOP_VERSION
128 sels->showMaximized(); 146 sels->showMaximized();
129#else 147#else
130 sels->show(); 148 sels->show();
131#endif 149#endif
132 QStringList sFolders; 150 QStringList sFolders;
133 unsigned int i = 0; 151 unsigned int i = 0;
134 for (i=0; i < mhAccounts.count();++i) 152 for (i=0; i < mhAccounts.count();++i)
135 { 153 {
136 mhAccounts[i]->refresh(false); 154 mhAccounts[i]->refresh(false);
137 sFolders = mhAccounts[i]->subFolders(); 155 sFolders = mhAccounts[i]->subFolders();
138 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 156 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
139 } 157 }
140 for (i=0; i < imapAccounts.count();++i) 158 for (i=0; i < imapAccounts.count();++i)
141 { 159 {
142 if (imapAccounts[i]->offline()) 160 if (imapAccounts[i]->offline())
143 continue; 161 continue;
144 imapAccounts[i]->refreshFolders(false); 162 imapAccounts[i]->refreshFolders(false);
145 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 163 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
146 } 164 }
147} 165}
148void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 166void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper)
149{ 167{
150#if 0 168#if 0
151 AbstractMail*targetMail = 0; 169 AbstractMail*targetMail = 0;
152 QString targetFolder = ""; 170 QString targetFolder = "";
153 Selectstore sels; 171 Selectstore sels;
154 setupFolderselect(&sels); 172 setupFolderselect(&sels);
155 if (!sels.exec()) return; 173 if (!sels.exec()) return;
156 targetMail = sels.currentMail(); 174 targetMail = sels.currentMail();
157 targetFolder = sels.currentFolder(); 175 targetFolder = sels.currentFolder();
158 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 176 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
159 targetFolder.isEmpty()) 177 targetFolder.isEmpty())
160 { 178 {
161 return; 179 return;
162 } 180 }
163 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 181 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
164 { 182 {
165 QMessageBox::critical(0,i18n("Error creating new Folder"), 183 QMessageBox::critical(0,i18n("Error creating new Folder"),
166 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 184 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
167 return; 185 return;
168 } 186 }
169 int maxsize = 0; 187 int maxsize = 0;
170 if ( sels.useSize->isChecked()) 188 if ( sels.useSize->isChecked())
171 maxsize = sels.sizeSpinBox->value(); 189 maxsize = sels.sizeSpinBox->value();
172 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 190 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
173#endif 191#endif
174 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); 192 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper());
175 refreshCurrent(); 193 refreshCurrent();
176 194
177} 195}
178 196
179void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 197void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
180{ 198{
181 AbstractMail*targetMail = 0; 199 AbstractMail*targetMail = 0;
182 QString targetFolder = ""; 200 QString targetFolder = "";
183 Selectstore sels; 201 Selectstore sels;
184 setupFolderselect(&sels); 202 setupFolderselect(&sels);
185 if (!sels.exec()) return; 203 if (!sels.exec()) return;
186 targetMail = sels.currentMail(); 204 targetMail = sels.currentMail();
187 targetFolder = sels.currentFolder(); 205 targetFolder = sels.currentFolder();
188 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 206 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
189 targetFolder.isEmpty()) 207 targetFolder.isEmpty())
190 { 208 {
191 return; 209 return;
192 } 210 }
193 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 211 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
194 { 212 {
195 QMessageBox::critical(0,i18n("Error creating new Folder"), 213 QMessageBox::critical(0,i18n("Error creating new Folder"),
196 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 214 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
197 return; 215 return;
198 } 216 }
199 int maxsize = 0; 217 int maxsize = 0;
200 if ( sels.useSize->isChecked()) 218 if ( sels.useSize->isChecked())
201 maxsize = sels.sizeSpinBox->value(); 219 maxsize = sels.sizeSpinBox->value();
202 220
203 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 221 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
204 refreshCurrent(); 222 refreshCurrent();
205} 223}
206 224
207bool AccountView::currentisDraft() 225bool AccountView::currentisDraft()
208{ 226{
209 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 227 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
210 if (!view) return false; 228 if (!view) return false;
211 return view->isDraftfolder(); 229 return view->isDraftfolder();
212} 230}
diff --git a/kmicromail/accountview.h b/kmicromail/accountview.h
index 79ed2e7..e403cb8 100644
--- a/kmicromail/accountview.h
+++ b/kmicromail/accountview.h
@@ -1,46 +1,47 @@
1#ifndef ACCOUNTVIEW_H 1#ifndef ACCOUNTVIEW_H
2#define ACCOUNTVIEW_H 2#define ACCOUNTVIEW_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <opie2/osmartpointer.h> 6#include <opie2/osmartpointer.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8 8
9class Selectstore; 9class Selectstore;
10class Folder; 10class Folder;
11class AbstractMail; 11class AbstractMail;
12class Account; 12class Account;
13class IMAPviewItem; 13class IMAPviewItem;
14class MHviewItem; 14class MHviewItem;
15 15
16class AccountView : public QListView 16class AccountView : public QListView
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
22 virtual ~AccountView(); 22 virtual ~AccountView();
23 virtual void populate( QList<Account> list ); 23 virtual void populate( QList<Account> list );
24 virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); 24 virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail);
25 virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); 25 virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
26 virtual void downloadMailsInbox(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); 26 virtual void downloadMailsInbox(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
27 virtual bool currentisDraft(); 27 virtual bool currentisDraft();
28 QValueList<MHviewItem*> allAccounts() { return mhAccounts;} 28 QValueList<MHviewItem*> allAccounts() { return mhAccounts;}
29public slots: 29public slots:
30 virtual void refreshAll(); 30 virtual void refreshAll();
31 virtual void refresh(QListViewItem *item); 31 virtual void refresh(QListViewItem *item);
32 virtual void refreshCurrent(); 32 virtual void refreshCurrent();
33 virtual void refreshOutgoing();
33 virtual void slotHold(int, QListViewItem *,const QPoint&,int); 34 virtual void slotHold(int, QListViewItem *,const QPoint&,int);
34 virtual void slotContextMenu(int id); 35 virtual void slotContextMenu(int id);
35 void setupFolderselect(Selectstore*sels); 36 void setupFolderselect(Selectstore*sels);
36 37
37signals: 38signals:
38 void refreshMailview(const QValueList<RecMailP>& ); 39 void refreshMailview(const QValueList<RecMailP>& );
39 40
40protected: 41protected:
41 QListViewItem* m_currentItem; 42 QListViewItem* m_currentItem;
42 QValueList<IMAPviewItem*> imapAccounts; 43 QValueList<IMAPviewItem*> imapAccounts;
43 QValueList<MHviewItem*> mhAccounts; 44 QValueList<MHviewItem*> mhAccounts;
44}; 45};
45 46
46#endif 47#endif
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index f54fe2b..24f4786 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -34,404 +34,408 @@ SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp )
34 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); 34 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) );
35 m_smtp = 0; 35 m_smtp = 0;
36} 36}
37 37
38SMTPwrapper::~SMTPwrapper() 38SMTPwrapper::~SMTPwrapper()
39{ 39{
40 disc_server(); 40 disc_server();
41} 41}
42 42
43void SMTPwrapper::emitQCop( int queued ) { 43void SMTPwrapper::emitQCop( int queued ) {
44#ifndef DESKTOP_VERSION 44#ifndef DESKTOP_VERSION
45 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); 45 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" );
46 env << queued; 46 env << queued;
47#endif 47#endif
48} 48}
49 49
50QString SMTPwrapper::mailsmtpError( int errnum ) { 50QString SMTPwrapper::mailsmtpError( int errnum ) {
51 switch ( errnum ) { 51 switch ( errnum ) {
52 case MAILSMTP_NO_ERROR: 52 case MAILSMTP_NO_ERROR:
53 return i18n( "No error" ); 53 return i18n( "No error" );
54 case MAILSMTP_ERROR_UNEXPECTED_CODE: 54 case MAILSMTP_ERROR_UNEXPECTED_CODE:
55 return i18n( "Unexpected error code" ); 55 return i18n( "Unexpected error code" );
56 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 56 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
57 return i18n( "Service not available" ); 57 return i18n( "Service not available" );
58 case MAILSMTP_ERROR_STREAM: 58 case MAILSMTP_ERROR_STREAM:
59 return i18n( "Stream error" ); 59 return i18n( "Stream error" );
60 case MAILSMTP_ERROR_HOSTNAME: 60 case MAILSMTP_ERROR_HOSTNAME:
61 return i18n( "gethostname() failed" ); 61 return i18n( "gethostname() failed" );
62 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 62 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
63 return i18n( "Not implemented" ); 63 return i18n( "Not implemented" );
64 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 64 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
65 return i18n( "Error, action not taken" ); 65 return i18n( "Error, action not taken" );
66 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 66 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
67 return i18n( "Data exceeds storage allocation" ); 67 return i18n( "Data exceeds storage allocation" );
68 case MAILSMTP_ERROR_IN_PROCESSING: 68 case MAILSMTP_ERROR_IN_PROCESSING:
69 return i18n( "Error in processing" ); 69 return i18n( "Error in processing" );
70 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: 70 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED:
71 return i18n( "Starttls not supported" ); 71 return i18n( "Starttls not supported" );
72 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 72 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
73 // return i18n( "Insufficient system storage" ); 73 // return i18n( "Insufficient system storage" );
74 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 74 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
75 return i18n( "Mailbox unavailable" ); 75 return i18n( "Mailbox unavailable" );
76 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 76 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
77 return i18n( "Mailbox name not allowed" ); 77 return i18n( "Mailbox name not allowed" );
78 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 78 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
79 return i18n( "Bad command sequence" ); 79 return i18n( "Bad command sequence" );
80 case MAILSMTP_ERROR_USER_NOT_LOCAL: 80 case MAILSMTP_ERROR_USER_NOT_LOCAL:
81 return i18n( "User not local" ); 81 return i18n( "User not local" );
82 case MAILSMTP_ERROR_TRANSACTION_FAILED: 82 case MAILSMTP_ERROR_TRANSACTION_FAILED:
83 return i18n( "Transaction failed" ); 83 return i18n( "Transaction failed" );
84 case MAILSMTP_ERROR_MEMORY: 84 case MAILSMTP_ERROR_MEMORY:
85 return i18n( "Memory error" ); 85 return i18n( "Memory error" );
86 case MAILSMTP_ERROR_CONNECTION_REFUSED: 86 case MAILSMTP_ERROR_CONNECTION_REFUSED:
87 return i18n( "Connection refused" ); 87 return i18n( "Connection refused" );
88 default: 88 default:
89 return i18n( "Unknown error code" ); 89 return i18n( "Unknown error code" );
90 } 90 }
91} 91}
92 92
93 93
94void SMTPwrapper::progress( size_t current, size_t maximum ) { 94void SMTPwrapper::progress( size_t current, size_t maximum ) {
95 if (SMTPwrapper::sendProgress) { 95 if (SMTPwrapper::sendProgress) {
96 SMTPwrapper::sendProgress->setSingleMail(current, maximum ); 96 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
97 qApp->processEvents(); 97 qApp->processEvents();
98 } 98 }
99} 99}
100 100
101void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { 101void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) {
102 if (!mail) 102 if (!mail)
103 return; 103 return;
104 QString localfolders = AbstractMail::defaultLocalfolder(); 104 QString localfolders = AbstractMail::defaultLocalfolder();
105 AbstractMail*wrap = AbstractMail::getWrapper(localfolders); 105 AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
106 wrap->createMbox(box); 106 wrap->createMbox(box);
107 wrap->storeMessage(mail,length,box); 107 wrap->storeMessage(mail,length,box);
108 delete wrap; 108 delete wrap;
109} 109}
110 110
111bool SMTPwrapper::smtpSend( mailmime *mail,bool later) { 111bool SMTPwrapper::smtpSend( mailmime *mail,bool later) {
112 clist *rcpts = 0; 112 clist *rcpts = 0;
113 char *from, *data; 113 char *from, *data;
114 size_t size; 114 size_t size;
115 115
116 from = data = 0; 116 from = data = 0;
117 117
118 mailmessage * msg = 0; 118 mailmessage * msg = 0;
119 msg = mime_message_init(mail); 119 msg = mime_message_init(mail);
120 mime_message_set_tmpdir(msg,getenv( "HOME" )); 120 mime_message_set_tmpdir(msg,getenv( "HOME" ));
121 int r = mailmessage_fetch(msg,&data,&size); 121 int r = mailmessage_fetch(msg,&data,&size);
122 mime_message_detach_mime(msg); 122 mime_message_detach_mime(msg);
123 mailmessage_free(msg); 123 mailmessage_free(msg);
124 if (r != MAIL_NO_ERROR || !data) { 124 if (r != MAIL_NO_ERROR || !data) {
125 if (data) 125 if (data)
126 free(data); 126 free(data);
127 qDebug("Error fetching mime... "); 127 qDebug("Error fetching mime... ");
128 return false; 128 return false;
129 } 129 }
130 msg = 0; 130 msg = 0;
131 if (later) { 131 if (later) {
132 storeMail(data,size,"Outgoing"); 132 storeMail(data,size,"Outgoing");
133 if (data) 133 if (data)
134 free( data ); 134 free( data );
135 KConfig cfg( locateLocal("config", "kopiemailrc" ) ); 135 KConfig cfg( locateLocal("config", "kopiemailrc" ) );
136 cfg.setGroup( "Status" ); 136 cfg.setGroup( "Status" );
137 cfg.writeEntry( "outgoing", ++m_queuedMail ); 137 cfg.writeEntry( "outgoing", ++m_queuedMail );
138 emit queuedMails( m_queuedMail ); 138 emit queuedMails( m_queuedMail );
139 return true; 139 return true;
140 } 140 }
141 from = getFrom( mail ); 141 from = getFrom( mail );
142 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 142 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
143 bool result = smtpSend(from,rcpts,data,size); 143 bool result = smtpSend(from,rcpts,data,size);
144 if (data) { 144 if (data) {
145 free(data); 145 free(data);
146 } 146 }
147 if (from) { 147 if (from) {
148 free(from); 148 free(from);
149 } 149 }
150 if (rcpts) 150 if (rcpts)
151 smtp_address_list_free( rcpts ); 151 smtp_address_list_free( rcpts );
152 return result; 152 return result;
153} 153}
154 154
155void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) 155void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage)
156{ 156{
157 if (data) { 157 if (data) {
158 storeMail(data,size,"Sendfailed"); 158 storeMail(data,size,"Sendfailed");
159 } 159 }
160 if (failuremessage) { 160 if (failuremessage) {
161 QMessageBox::critical(0,i18n("Error sending mail"), 161 QMessageBox::critical(0,i18n("Error sending mail"),
162 i18n("<center>%1</center>").arg(failuremessage)); 162 failuremessage);
163 } 163 }
164} 164}
165 165
166int SMTPwrapper::start_smtp_tls() 166int SMTPwrapper::start_smtp_tls()
167{ 167{
168 if (!m_smtp) { 168 if (!m_smtp) {
169 return MAILSMTP_ERROR_IN_PROCESSING; 169 return MAILSMTP_ERROR_IN_PROCESSING;
170 } 170 }
171 int err = mailesmtp_starttls(m_smtp); 171 int err = mailesmtp_starttls(m_smtp);
172 if (err != MAILSMTP_NO_ERROR) return err; 172 if (err != MAILSMTP_NO_ERROR) return err;
173 mailstream_low * low; 173 mailstream_low * low;
174 mailstream_low * new_low; 174 mailstream_low * new_low;
175 low = mailstream_get_low(m_smtp->stream); 175 low = mailstream_get_low(m_smtp->stream);
176 if (!low) { 176 if (!low) {
177 return MAILSMTP_ERROR_IN_PROCESSING; 177 return MAILSMTP_ERROR_IN_PROCESSING;
178 } 178 }
179 int fd = mailstream_low_get_fd(low); 179 int fd = mailstream_low_get_fd(low);
180 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 180 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
181 mailstream_low_free(low); 181 mailstream_low_free(low);
182 mailstream_set_low(m_smtp->stream, new_low); 182 mailstream_set_low(m_smtp->stream, new_low);
183 } else { 183 } else {
184 return MAILSMTP_ERROR_IN_PROCESSING; 184 return MAILSMTP_ERROR_IN_PROCESSING;
185 } 185 }
186 return err; 186 return err;
187} 187}
188 188
189void SMTPwrapper::connect_server() 189void SMTPwrapper::connect_server()
190{ 190{
191 QString server, user, pass; 191 QString server, user, pass;
192 bool ssl; 192 bool ssl;
193 uint16_t port; 193 uint16_t port;
194 ssl = false; 194 ssl = false;
195 bool try_tls = true; 195 bool try_tls = true;
196 bool force_tls=false; 196 bool force_tls=false;
197 QString failuretext = ""; 197 QString failuretext = "";
198 198
199 if (m_smtp || !m_SmtpAccount) { 199 if (m_smtp || !m_SmtpAccount) {
200 return; 200 return;
201 } 201 }
202 server = m_SmtpAccount->getServer(); 202 server = m_SmtpAccount->getServer();
203 if ( m_SmtpAccount->ConnectionType() == 2 ) { 203 if ( m_SmtpAccount->ConnectionType() == 2 ) {
204 ssl = true; 204 ssl = true;
205 try_tls = false; 205 try_tls = false;
206 } else if (m_SmtpAccount->ConnectionType() == 1) { 206 } else if (m_SmtpAccount->ConnectionType() == 1) {
207 force_tls = true; 207 force_tls = true;
208 } 208 }
209 int result = 1; 209 int result = 1;
210 port = m_SmtpAccount->getPort().toUInt(); 210 port = m_SmtpAccount->getPort().toUInt();
211 211
212 m_smtp = mailsmtp_new( 20, &progress ); 212 m_smtp = mailsmtp_new( 20, &progress );
213 if ( m_smtp == NULL ) { 213 if ( m_smtp == NULL ) {
214 /* no failure message cause this happens when problems with memory - than we 214 /* no failure message cause this happens when problems with memory - than we
215 we can not display any messagebox */ 215 we can not display any messagebox */
216 return; 216 return;
217 } 217 }
218 218
219 int err = MAILSMTP_NO_ERROR; 219 int err = MAILSMTP_NO_ERROR;
220 ; // odebug << "Servername " << server << " at port " << port << "" << oendl; 220 ; // odebug << "Servername " << server << " at port " << port << "" << oendl;
221 if ( ssl ) { 221 if ( ssl ) {
222 ; // odebug << "SSL session" << oendl; 222 qDebug("smtp: ssl_connect ");
223 err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); 223 err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port );
224 } else { 224 } else {
225 ; // odebug << "No SSL session" << oendl; 225 ; // odebug << "No SSL session" << oendl;
226 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); 226 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port );
227 } 227 }
228 if ( err != MAILSMTP_NO_ERROR ) { 228 if ( err != MAILSMTP_NO_ERROR ) {
229 ; // odebug << "Error init connection" << oendl; 229 qDebug("Error init SMTP connection" );
230 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err)); 230 failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err));
231 result = 0; 231 result = 0;
232 } 232 }
233 233
234 qDebug("SMTP connection inited ");
234 /* switch to tls after init 'cause there it will send the ehlo */ 235 /* switch to tls after init 'cause there it will send the ehlo */
235 if (result) { 236 if (result) {
236 err = mailsmtp_init( m_smtp ); 237 err = mailsmtp_init( m_smtp );
237 if (err != MAILSMTP_NO_ERROR) { 238 if (err != MAILSMTP_NO_ERROR) {
238 result = 0; 239 result = 0;
239 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err)); 240 qDebug("Error init SMTP connection ");
241 failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err));
240 } 242 }
241 } 243 }
242
243 if (try_tls) { 244 if (try_tls) {
245 qDebug("Smpt: Try tls ");
244 err = start_smtp_tls(); 246 err = start_smtp_tls();
245 if (err != MAILSMTP_NO_ERROR) { 247 if (err != MAILSMTP_NO_ERROR) {
246 try_tls = false; 248 try_tls = false;
249 qDebug("no tls ");
247 } else { 250 } else {
248 err = mailesmtp_ehlo(m_smtp); 251 err = mailesmtp_ehlo(m_smtp);
249 } 252 }
250 } 253 }
251 254 //qDebug("mailesmtp_ehlo %d ",err );
252 if (!try_tls && force_tls) { 255 if (!try_tls && force_tls) {
253 result = 0; 256 result = 0;
254 failuretext = i18n("Error init SMTP tls: %1").arg(mailsmtpError(err)); 257 failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err));
255 } 258 }
256 259
257 if (result==1 && m_SmtpAccount->getLogin() ) { 260 if (result==1 && m_SmtpAccount->getLogin() ) {
258 ; // odebug << "smtp with auth" << oendl; 261 ; // odebug << "smtp with auth" << oendl;
259 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { 262 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
260 // get'em 263 // get'em
261 LoginDialog login( m_SmtpAccount->getUser(), 264 LoginDialog login( m_SmtpAccount->getUser(),
262 m_SmtpAccount->getPassword(), NULL, 0, true ); 265 m_SmtpAccount->getPassword(), NULL, 0, true );
263 login.show(); 266 login.show();
264 if ( QDialog::Accepted == login.exec() ) { 267 if ( QDialog::Accepted == login.exec() ) {
265 // ok 268 // ok
266 user = login.getUser(); 269 user = login.getUser();
267 pass = login.getPassword(); 270 pass = login.getPassword();
268 } else { 271 } else {
269 result = 0; 272 result = 0;
270 failuretext=i18n("Login aborted - storing mail to localfolder"); 273 failuretext=i18n("Login aborted - \nstoring mail to localfolder");
271 } 274 }
272 } else { 275 } else {
273 user = m_SmtpAccount->getUser(); 276 user = m_SmtpAccount->getUser();
274 pass = m_SmtpAccount->getPassword(); 277 pass = m_SmtpAccount->getPassword();
275 } 278 }
276 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; 279 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl;
277 if (result) { 280 if (result) {
278 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); 281 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() );
279 if ( err == MAILSMTP_NO_ERROR ) { 282 if ( err == MAILSMTP_NO_ERROR ) {
280 ; // odebug << "auth ok" << oendl; 283 qDebug("Smtp authentification ok ");
281 } else { 284 } else {
282 failuretext = i18n("Authentification failed"); 285 failuretext = i18n("Authentification failed");
283 result = 0; 286 result = 0;
284 } 287 }
285 } 288 }
286 } 289 }
287} 290}
288 291
289void SMTPwrapper::disc_server() 292void SMTPwrapper::disc_server()
290{ 293{
291 if (m_smtp) { 294 if (m_smtp) {
292 mailsmtp_quit( m_smtp ); 295 mailsmtp_quit( m_smtp );
293 mailsmtp_free( m_smtp ); 296 mailsmtp_free( m_smtp );
294 m_smtp = 0; 297 m_smtp = 0;
295 } 298 }
296} 299}
297 300
298int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) 301int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
299{ 302{
300 int err,result; 303 int err,result;
301 QString failuretext = ""; 304 QString failuretext = "";
302 305
303 connect_server(); 306 connect_server();
304 307
305 result = 1; 308 result = 1;
306 if (m_smtp) { 309 if (m_smtp) {
307 err = mailsmtp_send( m_smtp, from, rcpts, data, size ); 310 err = mailsmtp_send( m_smtp, from, rcpts, data, size );
308 if ( err != MAILSMTP_NO_ERROR ) { 311 if ( err != MAILSMTP_NO_ERROR ) {
309 failuretext=i18n("Error sending mail: %1").arg(mailsmtpError(err)); 312 qDebug("Error sending mail");
313 failuretext=i18n("Error sending mail:\n%1").arg(mailsmtpError(err));
310 result = 0; 314 result = 0;
311 } 315 }
312 } else { 316 } else {
313 result = 0; 317 result = 0;
314 } 318 }
315 319
316 if (!result) { 320 if (!result) {
317 storeFailedMail(data,size,failuretext); 321 storeFailedMail(data,size,failuretext);
318 } else { 322 } else {
319 ; // odebug << "Mail sent." << oendl; 323 ; // odebug << "Mail sent." << oendl;
320 storeMail(data,size,"Sent"); 324 storeMail(data,size,"Sent");
321 } 325 }
322 return result; 326 return result;
323} 327}
324 328
325bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) 329bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later )
326{ 330{
327 mailmime * mimeMail; 331 mailmime * mimeMail;
328 bool result = true; 332 bool result = true;
329 mimeMail = createMimeMail(mail ); 333 mimeMail = createMimeMail(mail );
330 if ( mimeMail == 0 ) { 334 if ( mimeMail == 0 ) {
331 qDebug("SMTP wrapper:Error creating mail! "); 335 qDebug("SMTP wrapper:Error creating mail! ");
332 return false; 336 return false;
333 } else { 337 } else {
334 sendProgress = new progressMailSend(); 338 sendProgress = new progressMailSend();
335 sendProgress->show(); 339 sendProgress->show();
336 sendProgress->setMaxMails(1); 340 sendProgress->setMaxMails(1);
337 result = smtpSend( mimeMail,later); 341 result = smtpSend( mimeMail,later);
338 ; // odebug << "Clean up done" << oendl; 342 ; // odebug << "Clean up done" << oendl;
339 sendProgress->hide(); 343 sendProgress->hide();
340 delete sendProgress; 344 delete sendProgress;
341 sendProgress = 0; 345 sendProgress = 0;
342 mailmime_free( mimeMail ); 346 mailmime_free( mimeMail );
343 } 347 }
344 return result; 348 return result;
345} 349}
346 350
347int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { 351int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
348 size_t curTok = 0; 352 size_t curTok = 0;
349 mailimf_fields *fields = 0; 353 mailimf_fields *fields = 0;
350 mailimf_field*ffrom = 0; 354 mailimf_field*ffrom = 0;
351 clist *rcpts = 0; 355 clist *rcpts = 0;
352 char*from = 0; 356 char*from = 0;
353 int res = 0; 357 int res = 0;
354 358
355 encodedString * data = wrap->fetchRawBody(which); 359 encodedString * data = wrap->fetchRawBody(which);
356 if (!data) 360 if (!data)
357 return 0; 361 return 0;
358 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); 362 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
359 if (err != MAILIMF_NO_ERROR) { 363 if (err != MAILIMF_NO_ERROR) {
360 delete data; 364 delete data;
361 delete wrap; 365 delete wrap;
362 return 0; 366 return 0;
363 } 367 }
364 368
365 rcpts = createRcptList( fields ); 369 rcpts = createRcptList( fields );
366 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 370 ffrom = getField(fields, MAILIMF_FIELD_FROM );
367 from = getFrom(ffrom); 371 from = getFrom(ffrom);
368 372
369 if (rcpts && from) { 373 if (rcpts && from) {
370 res = smtpSend(from,rcpts,data->Content(),data->Length()); 374 res = smtpSend(from,rcpts,data->Content(),data->Length());
371 } 375 }
372 if (fields) { 376 if (fields) {
373 mailimf_fields_free(fields); 377 mailimf_fields_free(fields);
374 fields = 0; 378 fields = 0;
375 } 379 }
376 if (data) { 380 if (data) {
377 delete data; 381 delete data;
378 } 382 }
379 if (from) { 383 if (from) {
380 free(from); 384 free(from);
381 } 385 }
382 if (rcpts) { 386 if (rcpts) {
383 smtp_address_list_free( rcpts ); 387 smtp_address_list_free( rcpts );
384 } 388 }
385 return res; 389 return res;
386} 390}
387 391
388/* this is a special fun */ 392/* this is a special fun */
389bool SMTPwrapper::flushOutbox() { 393bool SMTPwrapper::flushOutbox() {
390 bool returnValue = true; 394 bool returnValue = true;
391 395
392 ; // odebug << "Sending the queue" << oendl; 396 ; // odebug << "Sending the queue" << oendl;
393 if (!m_SmtpAccount) { 397 if (!m_SmtpAccount) {
394 ; // odebug << "No smtp account given" << oendl; 398 ; // odebug << "No smtp account given" << oendl;
395 return false; 399 return false;
396 } 400 }
397 401
398 bool reset_user_value = false; 402 bool reset_user_value = false;
399 QString localfolders = AbstractMail::defaultLocalfolder(); 403 QString localfolders = AbstractMail::defaultLocalfolder();
400 AbstractMail*wrap = AbstractMail::getWrapper(localfolders); 404 AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
401 if (!wrap) { 405 if (!wrap) {
402 ; // odebug << "memory error" << oendl; 406 ; // odebug << "memory error" << oendl;
403 return false; 407 return false;
404 } 408 }
405 QString oldPw, oldUser; 409 QString oldPw, oldUser;
406 QValueList<RecMailP> mailsToSend; 410 QValueList<RecMailP> mailsToSend;
407 QValueList<RecMailP> mailsToRemove; 411 QValueList<RecMailP> mailsToRemove;
408 QString mbox("Outgoing"); 412 QString mbox("Outgoing");
409 wrap->listMessages(mbox,mailsToSend); 413 wrap->listMessages(mbox,mailsToSend);
410 if (mailsToSend.count()==0) { 414 if (mailsToSend.count()==0) {
411 delete wrap; 415 delete wrap;
412 ; // odebug << "No mails to send" << oendl; 416 ; // odebug << "No mails to send" << oendl;
413 return false; 417 return false;
414 } 418 }
415 419
416 oldPw = m_SmtpAccount->getPassword(); 420 oldPw = m_SmtpAccount->getPassword();
417 oldUser = m_SmtpAccount->getUser(); 421 oldUser = m_SmtpAccount->getUser();
418 if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { 422 if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) {
419 // get'em 423 // get'em
420 QString user,pass; 424 QString user,pass;
421 LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); 425 LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true );
422 login.show(); 426 login.show();
423 if ( QDialog::Accepted == login.exec() ) { 427 if ( QDialog::Accepted == login.exec() ) {
424 // ok 428 // ok
425 user = login.getUser().latin1(); 429 user = login.getUser().latin1();
426 pass = login.getPassword().latin1(); 430 pass = login.getPassword().latin1();
427 reset_user_value = true; 431 reset_user_value = true;
428 m_SmtpAccount->setUser(user); 432 m_SmtpAccount->setUser(user);
429 m_SmtpAccount->setPassword(pass); 433 m_SmtpAccount->setPassword(pass);
430 } else { 434 } else {
431 return true; 435 return true;
432 } 436 }
433 } 437 }
434 438
435 439
436 sendProgress = new progressMailSend(); 440 sendProgress = new progressMailSend();
437 sendProgress->show(); 441 sendProgress->show();
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index e159b73..f68467c 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -111,257 +111,257 @@ void OpieMail::message(const QCString &msg, const QByteArray &data)
111 } 111 }
112 112
113 //qDebug("END OpieMail::message "); 113 //qDebug("END OpieMail::message ");
114} 114}
115void OpieMail::slotExtAppHandler() 115void OpieMail::slotExtAppHandler()
116{ 116{
117 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 117 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
118} 118}
119void OpieMail::slotwriteMail2(const QString& namemail ) 119void OpieMail::slotwriteMail2(const QString& namemail )
120{ 120{
121 //qDebug("OpieMail::slotwriteMail2 "); 121 //qDebug("OpieMail::slotwriteMail2 ");
122 //qApp->processEvents(); 122 //qApp->processEvents();
123 ComposeMail compose( settings, this, 0, true ); 123 ComposeMail compose( settings, this, 0, true );
124 if ( !namemail.isEmpty() ) { 124 if ( !namemail.isEmpty() ) {
125 QString to = namemail; 125 QString to = namemail;
126 if ( namemail.find( " <") > 1 ) { 126 if ( namemail.find( " <") > 1 ) {
127 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 127 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
128 } else 128 } else
129 if ( namemail.find( "<") > 1 ) { 129 if ( namemail.find( "<") > 1 ) {
130 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 130 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
131 } 131 }
132 int sub = to.find( ">:"); 132 int sub = to.find( ">:");
133 if ( sub > 0 ) { 133 if ( sub > 0 ) {
134 compose.setTo( to.left(sub+1) ); 134 compose.setTo( to.left(sub+1) );
135 compose.setSubject( to.mid(sub+2) ); 135 compose.setSubject( to.mid(sub+2) );
136 } else 136 } else
137 compose.setTo( to ); 137 compose.setTo( to );
138 } 138 }
139 compose.slotAdjustColumns(); 139 compose.slotAdjustColumns();
140#ifndef DESKTOP_VERSION 140#ifndef DESKTOP_VERSION
141 compose.showMaximized(); 141 compose.showMaximized();
142#endif 142#endif
143 mCurrentComposer = &compose; 143 mCurrentComposer = &compose;
144 compose.exec(); 144 compose.exec();
145 mCurrentComposer = 0; 145 mCurrentComposer = 0;
146 raise(); 146 raise();
147 //qDebug("retttich "); 147 //qDebug("retttich ");
148} 148}
149void OpieMail::slotwriteMail(const QString&name,const QString&email) 149void OpieMail::slotwriteMail(const QString&name,const QString&email)
150{ 150{
151 // qDebug("OpieMail::slotwriteMail "); 151 // qDebug("OpieMail::slotwriteMail ");
152 ComposeMail compose( settings, this, 0, true ); 152 ComposeMail compose( settings, this, 0, true );
153 if (!email.isEmpty()) 153 if (!email.isEmpty())
154 { 154 {
155 if (!name.isEmpty()) 155 if (!name.isEmpty())
156 { 156 {
157 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 157 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
158 } 158 }
159 else 159 else
160 { 160 {
161 compose.setTo(email); 161 compose.setTo(email);
162 } 162 }
163 } 163 }
164 compose.slotAdjustColumns(); 164 compose.slotAdjustColumns();
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 compose.showMaximized(); 166 compose.showMaximized();
167#endif 167#endif
168 168
169 mCurrentComposer = &compose; 169 mCurrentComposer = &compose;
170 compose.exec(); 170 compose.exec();
171 mCurrentComposer = 0; 171 mCurrentComposer = 0;
172 raise(); 172 raise();
173} 173}
174 174
175void OpieMail::slotComposeMail() 175void OpieMail::slotComposeMail()
176{ 176{
177 if ( mPendingEmail == QString::null && mPendingName == QString::null) 177 if ( mPendingEmail == QString::null && mPendingName == QString::null)
178 slotwriteMail2( QString () ); 178 slotwriteMail2( QString () );
179 else { 179 else {
180 if ( mPendingEmail == QString::null ) 180 if ( mPendingEmail == QString::null )
181 slotwriteMail2( mPendingName ); 181 slotwriteMail2( mPendingName );
182 else 182 else
183 slotwriteMail( mPendingName, mPendingEmail ); 183 slotwriteMail( mPendingName, mPendingEmail );
184 } 184 }
185 //slotwriteMail(0l,0l); 185 //slotwriteMail(0l,0l);
186} 186}
187 187
188void OpieMail::slotSendQueued() 188void OpieMail::slotSendQueued()
189{ 189{
190 SMTPaccount *smtp = 0; 190 SMTPaccount *smtp = 0;
191 191
192 QList<Account> list = settings->getAccounts(); 192 QList<Account> list = settings->getAccounts();
193 QList<SMTPaccount> smtpList; 193 QList<SMTPaccount> smtpList;
194 smtpList.setAutoDelete(false); 194 smtpList.setAutoDelete(false);
195 Account *it; 195 Account *it;
196 for ( it = list.first(); it; it = list.next() ) 196 for ( it = list.first(); it; it = list.next() )
197 { 197 {
198 if ( it->getType() == MAILLIB::A_SMTP ) 198 if ( it->getType() == MAILLIB::A_SMTP )
199 { 199 {
200 smtp = static_cast<SMTPaccount *>(it); 200 smtp = static_cast<SMTPaccount *>(it);
201 smtpList.append(smtp); 201 smtpList.append(smtp);
202 } 202 }
203 } 203 }
204 if (smtpList.count()==0) 204 if (smtpList.count()==0)
205 { 205 {
206 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 206 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n"));
207 return; 207 return;
208 } 208 }
209 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 209 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
210 return; 210 return;
211 if (smtpList.count()==1) 211 if (smtpList.count()==1)
212 { 212 {
213 smtp = smtpList.at(0); 213 smtp = smtpList.at(0);
214 } 214 }
215 else 215 else
216 { 216 {
217 smtp = 0; 217 smtp = 0;
218 selectsmtp selsmtp; 218 selectsmtp selsmtp;
219 selsmtp.setSelectionlist(&smtpList); 219 selsmtp.setSelectionlist(&smtpList);
220#ifndef DESKTOP_VERSION 220#ifndef DESKTOP_VERSION
221 selsmtp.showMaximized(); 221 selsmtp.showMaximized();
222#endif 222#endif
223 if ( selsmtp.exec() == QDialog::Accepted ) 223 if ( selsmtp.exec() == QDialog::Accepted )
224 { 224 {
225 smtp = selsmtp.selected_smtp(); 225 smtp = selsmtp.selected_smtp();
226 } 226 }
227 } 227 }
228 if (smtp) 228 if (smtp)
229 { 229 {
230 230
231 Global::statusMessage("Sending mails...!"); 231 Global::statusMessage("Sending mails...!");
232 SMTPwrapper * wrap = new SMTPwrapper(smtp); 232 SMTPwrapper * wrap = new SMTPwrapper(smtp);
233 if ( wrap->flushOutbox() ) 233 if ( wrap->flushOutbox() )
234 { 234 {
235 Global::statusMessage("Mails sent!"); 235 Global::statusMessage("Mails sent!");
236 } 236 }
237 delete wrap; 237 delete wrap;
238 } 238 }
239 // pending refresh list view, if outgoing is displayed 239 folderView->refreshOutgoing();
240} 240}
241 241
242void OpieMail::slotSearchMails() 242void OpieMail::slotSearchMails()
243{ 243{
244 qDebug("OpieMail::slotSearchMails():not implemented "); 244 qDebug("OpieMail::slotSearchMails():not implemented ");
245} 245}
246 246
247void OpieMail::slotEditSettings() 247void OpieMail::slotEditSettings()
248{ 248{
249 249
250 KOPrefsDialog settingsDialog( this, "koprefs", true ); 250 KOPrefsDialog settingsDialog( this, "koprefs", true );
251#ifndef DESKTOP_VERSION 251#ifndef DESKTOP_VERSION
252 settingsDialog.showMaximized(); 252 settingsDialog.showMaximized();
253#endif 253#endif
254 settingsDialog.exec(); 254 settingsDialog.exec();
255 255
256 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 256 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
257 // KApplication::execDialog(settingsDialog); 257 // KApplication::execDialog(settingsDialog);
258} 258}
259 259
260void OpieMail::slotEditAccounts() 260void OpieMail::slotEditAccounts()
261{ 261{
262 EditAccounts eaDialog( settings, this, 0, true ); 262 EditAccounts eaDialog( settings, this, 0, true );
263 eaDialog.slotAdjustColumns(); 263 eaDialog.slotAdjustColumns();
264#ifndef DESKTOP_VERSION 264#ifndef DESKTOP_VERSION
265 eaDialog.showMaximized(); 265 eaDialog.showMaximized();
266#endif 266#endif
267 eaDialog.exec(); 267 eaDialog.exec();
268 if ( settings ) delete settings; 268 if ( settings ) delete settings;
269 settings = new Settings(); 269 settings = new Settings();
270 270
271 folderView->populate( settings->getAccounts() ); 271 folderView->populate( settings->getAccounts() );
272} 272}
273void OpieMail::replyMail() 273void OpieMail::replyMail()
274{ 274{
275 275
276 QListViewItem*item = mailView->currentItem(); 276 QListViewItem*item = mailView->currentItem();
277 if (!item) return; 277 if (!item) return;
278 RecMailP mail = ((MailListViewItem*)item)->data(); 278 RecMailP mail = ((MailListViewItem*)item)->data();
279 RecBodyP body = folderView->fetchBody(mail); 279 RecBodyP body = folderView->fetchBody(mail);
280 280
281 QString rtext; 281 QString rtext;
282 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 282 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
283 .arg( mail->getFrom()) 283 .arg( mail->getFrom())
284 .arg( mail->getDate()); 284 .arg( mail->getDate());
285 285
286 QString text = body->Bodytext(); 286 QString text = body->Bodytext();
287 QStringList lines = QStringList::split(QRegExp("\\n"), text); 287 QStringList lines = QStringList::split(QRegExp("\\n"), text);
288 QStringList::Iterator it; 288 QStringList::Iterator it;
289 for (it = lines.begin(); it != lines.end(); it++) 289 for (it = lines.begin(); it != lines.end(); it++)
290 { 290 {
291 rtext += "> " + *it + "\n"; 291 rtext += "> " + *it + "\n";
292 } 292 }
293 rtext += "\n"; 293 rtext += "\n";
294 294
295 QString prefix; 295 QString prefix;
296 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 296 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
297 else prefix = "Re: "; // no i18n on purpose 297 else prefix = "Re: "; // no i18n on purpose
298 298
299 Settings *settings = new Settings(); 299 Settings *settings = new Settings();
300 ComposeMail composer( settings ,this, 0, true); 300 ComposeMail composer( settings ,this, 0, true);
301 if (mail->Replyto().isEmpty()) { 301 if (mail->Replyto().isEmpty()) {
302 composer.setTo( mail->getFrom()); 302 composer.setTo( mail->getFrom());
303 } else { 303 } else {
304 composer.setTo( mail->Replyto()); 304 composer.setTo( mail->Replyto());
305 } 305 }
306 composer.setSubject( prefix + mail->getSubject()); 306 composer.setSubject( prefix + mail->getSubject());
307 composer.setMessage( rtext ); 307 composer.setMessage( rtext );
308 composer.setInReplyTo( mail->Msgid()); 308 composer.setInReplyTo( mail->Msgid());
309 composer.setCharset( body->getCharset() ); 309 composer.setCharset( body->getCharset() );
310 310
311 mCurrentComposer = &composer; 311 mCurrentComposer = &composer;
312 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 312 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
313 { 313 {
314 mail->Wrapper()->answeredMail(mail); 314 mail->Wrapper()->answeredMail(mail);
315 } 315 }
316 mCurrentComposer = 0; 316 mCurrentComposer = 0;
317 delete settings; 317 delete settings;
318 318
319} 319}
320void OpieMail::closeViewMail(ViewMail * vm) 320void OpieMail::closeViewMail(ViewMail * vm)
321{ 321{
322 vm->hide(); 322 vm->hide();
323} 323}
324 324
325void OpieMail::slotDownloadMail( ) 325void OpieMail::slotDownloadMail( )
326{ 326{
327 QListViewItem*item = mailView->currentItem(); 327 QListViewItem*item = mailView->currentItem();
328 if (!item ) { 328 if (!item ) {
329 Global::statusMessage("Error: No item slected!"); 329 Global::statusMessage("Error: No item slected!");
330 return; 330 return;
331 } 331 }
332 RecMailP mail = ((MailListViewItem*)item)->data(); 332 RecMailP mail = ((MailListViewItem*)item)->data();
333 Account * acc = mail->Wrapper()->getAccount(); 333 Account * acc = mail->Wrapper()->getAccount();
334 if ( !acc ) { 334 if ( !acc ) {
335 Global::statusMessage("Mail is already stored locally!"); 335 Global::statusMessage("Mail is already stored locally!");
336 return; 336 return;
337 } 337 }
338 QString lfName = acc->getLocalFolder(); 338 QString lfName = acc->getLocalFolder();
339 //qDebug("local folder " + lfName ); 339 //qDebug("local folder " + lfName );
340 if ( lfName.isEmpty() ) 340 if ( lfName.isEmpty() )
341 lfName = acc->getAccountName(); 341 lfName = acc->getAccountName();
342 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); 342 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper();
343 //qDebug("target %d %d ",targetMail,mail->Wrapper() ); 343 //qDebug("target %d %d ",targetMail,mail->Wrapper() );
344 if ( targetMail == mail->Wrapper() ) { 344 if ( targetMail == mail->Wrapper() ) {
345 Global::statusMessage("Mail is already locally stored!"); 345 Global::statusMessage("Mail is already locally stored!");
346 return; 346 return;
347 } 347 }
348 if ( !targetMail->createMbox(lfName)) { 348 if ( !targetMail->createMbox(lfName)) {
349 Global::statusMessage("Error creating folder!"); 349 Global::statusMessage("Error creating folder!");
350 return; 350 return;
351 } 351 }
352 Global::statusMessage("Fetching mail...please wait!"); 352 Global::statusMessage("Fetching mail...please wait!");
353 qApp->processEvents(); 353 qApp->processEvents();
354 encodedString*st = 0; 354 encodedString*st = 0;
355 st = mail->Wrapper()->fetchRawBody(mail); 355 st = mail->Wrapper()->fetchRawBody(mail);
356 if ( st ) { 356 if ( st ) {
357 targetMail->storeMessage(st->Content(),st->Length(),lfName); 357 targetMail->storeMessage(st->Content(),st->Length(),lfName);
358 Global::statusMessage("Mail stored in "+ lfName); 358 Global::statusMessage("Mail stored in "+ lfName);
359 delete st; 359 delete st;
360 } else { 360 } else {
361 Global::statusMessage("Error: Cannot fetch mail!"); 361 Global::statusMessage("Error: Cannot fetch mail!");
362 } 362 }
363} 363}
364 364
365 365
366void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) 366void OpieMail::deleteAndDisplayNextMail(ViewMail * vm)
367{ 367{