summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp62
1 files changed, 39 insertions, 23 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 0c581c0..b2119e6 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -2,24 +2,25 @@
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "settingsdialog.h" 4#include "settingsdialog.h"
5#include "opiemail.h" 5#include "opiemail.h"
6#include "editaccounts.h" 6#include "editaccounts.h"
7#include "composemail.h" 7#include "composemail.h"
8#include "mailistviewitem.h" 8#include "mailistviewitem.h"
9#include "viewmail.h" 9#include "viewmail.h"
10#include "selectstore.h" 10#include "selectstore.h"
11#include "selectsmtp.h" 11#include "selectsmtp.h"
12 12
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14#include <qtimer.h>
14#include <libkdepim/externalapphandler.h> 15#include <libkdepim/externalapphandler.h>
15 16
16#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
17#include <libmailwrapper/smtpwrapper.h> 18#include <libmailwrapper/smtpwrapper.h>
18#include <libmailwrapper/mailtypes.h> 19#include <libmailwrapper/mailtypes.h>
19#include <libmailwrapper/abstractmail.h> 20#include <libmailwrapper/abstractmail.h>
20/* OPIE */ 21/* OPIE */
21//#include <qpe/resource.h> 22//#include <qpe/resource.h>
22//#include <qpe/qpeapplication.h> 23//#include <qpe/qpeapplication.h>
23 24
24/* QT */ 25/* QT */
25 26
@@ -39,64 +40,71 @@ OpieMail::~OpieMail()
39 if (settings) delete settings; 40 if (settings) delete settings;
40} 41}
41 42
42void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 43void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
43{ 44{
44 45
45} 46}
46#include <stdlib.h> 47#include <stdlib.h>
47void OpieMail::message(const QCString &msg, const QByteArray &data) 48void OpieMail::message(const QCString &msg, const QByteArray &data)
48{ 49{
49 // copied from old mail2 50 // copied from old mail2
50 static int ii = 0; 51 static int ii = 0;
51 qDebug("call ############################# %d ", ii); 52 //qDebug("QCOP CALL ############################# %d ", ii);
52 // block second call 53 //QString mess ( msg );
53 if ( ii < 2 ) { 54 //qDebug("Message = %s ",mess.latin1());
54 //++ii;
55 if ( ii > 1 ) {
56 qDebug("qcop call blocked ");
57 //return;
58 }
59 }
60 ++ii; 55 ++ii;
61 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 56 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
57
58 mPendingEmail = QString::null;
59 mPendingName = QString::null;
62 if (msg == "writeMail(QString,QString)") 60 if (msg == "writeMail(QString,QString)")
63 { 61 {
62 //qDebug("writeMail(QString,QString) ");
64 QDataStream stream(data,IO_ReadOnly); 63 QDataStream stream(data,IO_ReadOnly);
65 QString name, email; 64 stream >> mPendingName >> mPendingEmail;
66 stream >> name >> email;
67 // removing the whitespaces at beginning and end is needed! 65 // removing the whitespaces at beginning and end is needed!
68 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 66 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
69 } 67 }
70 else if (msg == "newMail()") 68 else if (msg == "newMail()")
71 { 69 {
72 slotComposeMail(); 70 //qDebug("slotComposeMail() ");
71 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
72 // and a QCOP call does not like a processevents in his execution
73 // with the Qtimer we call slotComposeMail() after we reached the main event loop
74 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
75 // slotComposeMail();
73 } 76 }
74 else if (msg == "newMail(QString)") 77 else if (msg == "newMail(QString)")
75 { 78 {
79 //qDebug(" newMail(QString)");
76 QDataStream stream(data,IO_ReadOnly); 80 QDataStream stream(data,IO_ReadOnly);
77 QString nameemail; 81 stream >> mPendingName;
78 stream >> nameemail;
79 // the format is 82 // the format is
80 // NAME <EMAIL>:SUBJECT 83 // NAME <EMAIL>:SUBJECT
81 //qDebug("message %s ", nameemail.latin1()); 84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
82 85 } else {
83 slotwriteMail2( nameemail ); 86 if ( ii == 1 ) {
84 } else 87 qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported ");
85 ExternalAppHandler::instance()->appMessage ( msg, data); 88 return;
89 }
90 ExternalAppHandler::instance()->appMessage ( msg, data);
91 }
92
93 //qDebug("END OpieMail::message ");
86} 94}
87void OpieMail::slotwriteMail2(const QString& namemail ) 95void OpieMail::slotwriteMail2(const QString& namemail )
88{ 96{
89 // qDebug("OpieMail::slotwriteMail2 "); 97 //qDebug("OpieMail::slotwriteMail2 ");
90 qApp->processEvents(); 98 //qApp->processEvents();
91 ComposeMail compose( settings, this, 0, true ); 99 ComposeMail compose( settings, this, 0, true );
92 if ( !namemail.isEmpty() ) { 100 if ( !namemail.isEmpty() ) {
93 QString to = namemail; 101 QString to = namemail;
94 if ( namemail.find( " <") > 1 ) { 102 if ( namemail.find( " <") > 1 ) {
95 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 103 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
96 } else 104 } else
97 if ( namemail.find( "<") > 1 ) { 105 if ( namemail.find( "<") > 1 ) {
98 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 106 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
99 } 107 }
100 int sub = to.find( ">:"); 108 int sub = to.find( ">:");
101 if ( sub > 0 ) { 109 if ( sub > 0 ) {
102 compose.setTo( to.left(sub+1) ); 110 compose.setTo( to.left(sub+1) );
@@ -119,29 +127,37 @@ void OpieMail::slotwriteMail(const QString&name,const QString&email)
119 if (!name.isEmpty()) 127 if (!name.isEmpty())
120 { 128 {
121 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 129 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
122 } 130 }
123 else 131 else
124 { 132 {
125 compose.setTo(email); 133 compose.setTo(email);
126 } 134 }
127 } 135 }
128 compose.slotAdjustColumns(); 136 compose.slotAdjustColumns();
129 compose.showMaximized(); 137 compose.showMaximized();
130 compose.exec(); 138 compose.exec();
139 raise();
131} 140}
132 141
133void OpieMail::slotComposeMail() 142void OpieMail::slotComposeMail()
134{ 143{
135 slotwriteMail2( QString () ); 144 if ( mPendingEmail == QString::null && mPendingName == QString::null)
145 slotwriteMail2( QString () );
146 else {
147 if ( mPendingEmail == QString::null )
148 slotwriteMail2( mPendingName );
149 else
150 slotwriteMail( mPendingName, mPendingEmail );
151 }
136 //slotwriteMail(0l,0l); 152 //slotwriteMail(0l,0l);
137} 153}
138 154
139void OpieMail::slotSendQueued() 155void OpieMail::slotSendQueued()
140{ 156{
141 SMTPaccount *smtp = 0; 157 SMTPaccount *smtp = 0;
142 158
143 QList<Account> list = settings->getAccounts(); 159 QList<Account> list = settings->getAccounts();
144 QList<SMTPaccount> smtpList; 160 QList<SMTPaccount> smtpList;
145 smtpList.setAutoDelete(false); 161 smtpList.setAutoDelete(false);
146 Account *it; 162 Account *it;
147 for ( it = list.first(); it; it = list.next() ) 163 for ( it = list.first(); it; it = list.next() )