summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-08 11:34:38 (UTC)
committer zautrix <zautrix>2004-09-08 11:34:38 (UTC)
commit1fcec858408b88bb412af18fbf853b49b6970d8a (patch) (side-by-side diff)
tree702e94a74f0bb90335b9b193d28e31c1dc392c03
parentcdff4506a9148c47406af86968da73c0dbfca0ba (diff)
downloadkdepimpi-1fcec858408b88bb412af18fbf853b49b6970d8a.zip
kdepimpi-1fcec858408b88bb412af18fbf853b49b6970d8a.tar.gz
kdepimpi-1fcec858408b88bb412af18fbf853b49b6970d8a.tar.bz2
Fixed QCOP call problem of kopiemail
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp4
-rw-r--r--kmicromail/composemail.cpp11
-rw-r--r--kmicromail/opiemail.cpp62
-rw-r--r--kmicromail/opiemail.h2
4 files changed, 49 insertions, 30 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d1d385c..74e5cf7 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2041,62 +2041,62 @@ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QSt
for (i=0; i < list.count(); i++)
{
nameList.append(list[i].realName());
emailList.append(list[i].preferredEmail());
uidList.append(list[i].uid());
}
bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
}
/* this method will be called through the QCop interface from other apps to show details of a contact.
*/
void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
{
qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
QString foundUid = QString::null;
if ( ! uid.isEmpty() ) {
Addressee adrr = mAddressBook->findByUid( uid );
if ( !adrr.isEmpty() ) {
foundUid = uid;
}
if ( email == "sendbacklist" ) {
- qDebug("ssssssssssssssssssssssend ");
+ //qDebug("ssssssssssssssssssssssend ");
QStringList nameList;
QStringList emailList;
QStringList uidList;
nameList.append(adrr.realName());
emailList = adrr.emails();
uidList.append( adrr.preferredEmail());
bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
return;
}
}
- if ( email == "sendback" )
+ if ( email == "sendbacklist" )
return;
if (foundUid.isEmpty())
{
//find the uid of the person first
Addressee::List namelist;
Addressee::List emaillist;
if (!name.isEmpty())
namelist = mAddressBook->findByName( name );
if (!email.isEmpty())
emaillist = mAddressBook->findByEmail( email );
qDebug("count %d %d ", namelist.count(),emaillist.count() );
//check if we have a match in Namelist and Emaillist
if ((namelist.count() == 0) && (emaillist.count() > 0)) {
foundUid = emaillist[0].uid();
}
else if ((namelist.count() > 0) && (emaillist.count() == 0))
foundUid = namelist[0].uid();
else
{
for (int i = 0; i < namelist.count(); i++)
{
for (int j = 0; j < emaillist.count(); j++)
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 01dd406..9efa932 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -20,90 +20,92 @@
#include <qcombobox.h>
#include <qcheckbox.h>
#include <qtimer.h>
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qlabel.h>
#include <qtabwidget.h>
#include <qlistview.h>
#include <kabc/addresseedialog.h>
#include <kabc/stdaddressbook.h>
#include <kabc/addressee.h>
#ifdef DESKTOP_VERSION
#include <kabc/addresseedialog.h>
#else //DESKTOP_VERSION
#include <libkdepim/externalapphandler.h>
#endif //DESKTOP_VERSION
//using namespace Opie::Core;
//using namespace Opie::Ui;
ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal )
: ComposeMailUI( parent, name, modal )
{
-
+
mPickLineEdit = 0;
connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
settings = s;
m_replyid = "";
KConfig config( locateLocal("config", "kabcrc") );
config.setGroup( "General" );
QString whoami_uid = config.readEntry( "WhoAmI" );
+
if ( whoami_uid.isEmpty() ) {
QMessageBox::information( 0, tr( "Hint" ),
tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
tr( "Ok" ) );
} else
- bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
+ ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
+
+
#ifdef DESKTOP_VERSION
KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
QStringList mails = con.emails();
QString defmail = con.preferredEmail();
if ( mails.count() == 0)
QMessageBox::information( 0, tr( "Hint" ),
tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
tr( "Ok" ) );
if (defmail.length()!=0) {
fromBox->insertItem(defmail);
}
QStringList::ConstIterator sit = mails.begin();
for (;sit!=mails.end();++sit) {
if ( (*sit)==defmail)
continue;
fromBox->insertItem((*sit));
}
senderNameEdit->setText(con.formattedName());
#endif
Config cfg( "mail" );
cfg.setGroup( "Compose" );
checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
attList->addColumn( tr( "Name" ) );
attList->addColumn( tr( "Size" ) );
-
QList<Account> accounts = settings->getAccounts();
Account *it;
for ( it = accounts.first(); it; it = accounts.next() ) {
if ( it->getType()==MAILLIB::A_SMTP ) {
SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
smtpAccountBox->insertItem( smtp->getAccountName() );
smtpAccounts.append( smtp );
}
}
if ( smtpAccounts.count() > 0 ) {
fillValues( smtpAccountBox->currentItem() );
} else {
QMessageBox::information( 0, tr( "Problem" ),
tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ),
tr( "Ok" ) );
return;
}
connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
@@ -176,53 +178,52 @@ void ComposeMail::pickAddress( )
uint i=0;
for (i=0; i < list.count(); i++) {
if ( !list[i].preferredEmail().isEmpty()) {
if ( ! names.isEmpty() )
names+= ",";
names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
}
}
if ( line->text().isEmpty() ) {
line->setText( names );
} else if ( !names.isEmpty() ) {
line->setText( line->text() + ", " + names );
}
#else
bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
// the result should now arrive through method insertAttendees
#endif
}
//the map includes name/email pairs, that comes from Ka/Pi
void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
{
- qDebug("ComposeMail::insertAttendees ");
+ //qDebug("ComposeMail::insertAttendees ");
raise();
if ( mPickLineEdit == 0 ) { //whoami received
- qDebug("returnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn ");
QString defmail = uidList[0];
if ( emailList.count() == 0 )
QMessageBox::information( 0, tr( "Hint" ),
tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
tr( "Ok" ) );
if (defmail.length()!=0) {
fromBox->insertItem(defmail);
}
QStringList::ConstIterator sit = emailList.begin();
int pref = 0;
for (;sit!=emailList.end();++sit) {
if ( (*sit)==defmail)
continue;
fromBox->insertItem((*sit));
}
senderNameEdit->setText(nameList[0]);
return;
}
QString names ;
QLineEdit *line = mPickLineEdit;
if (uid == this->name())
{
for ( int i = 0; i < nameList.count(); i++)
{
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 0c581c0..b2119e6 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,159 +1,175 @@
// CHANGED 2004-09-31 Lutz Rogowski
// CHANGED 2004-08-06 Lutz Rogowski
#include "settingsdialog.h"
#include "opiemail.h"
#include "editaccounts.h"
#include "composemail.h"
#include "mailistviewitem.h"
#include "viewmail.h"
#include "selectstore.h"
#include "selectsmtp.h"
#include <qmessagebox.h>
+#include <qtimer.h>
#include <libkdepim/externalapphandler.h>
#include <qpe/qpeapplication.h>
#include <libmailwrapper/smtpwrapper.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
/* OPIE */
//#include <qpe/resource.h>
//#include <qpe/qpeapplication.h>
/* QT */
//using namespace Opie::Core;
OpieMail::OpieMail( QWidget *parent, const char *name )
: MainWindow( parent, name) //, WStyle_ContextHelp )
{
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
OpieMail::~OpieMail()
{
if (settings) delete settings;
}
void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
{
}
#include <stdlib.h>
void OpieMail::message(const QCString &msg, const QByteArray &data)
{
// copied from old mail2
static int ii = 0;
- qDebug("call ############################# %d ", ii);
- // block second call
- if ( ii < 2 ) {
- //++ii;
- if ( ii > 1 ) {
- qDebug("qcop call blocked ");
- //return;
- }
- }
+ //qDebug("QCOP CALL ############################# %d ", ii);
+ //QString mess ( msg );
+ //qDebug("Message = %s ",mess.latin1());
++ii;
//qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
+
+ mPendingEmail = QString::null;
+ mPendingName = QString::null;
if (msg == "writeMail(QString,QString)")
{
+ //qDebug("writeMail(QString,QString) ");
QDataStream stream(data,IO_ReadOnly);
- QString name, email;
- stream >> name >> email;
+ stream >> mPendingName >> mPendingEmail;
// removing the whitespaces at beginning and end is needed!
- slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
+ QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
}
else if (msg == "newMail()")
{
- slotComposeMail();
+ //qDebug("slotComposeMail() ");
+ // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
+ // and a QCOP call does not like a processevents in his execution
+ // with the Qtimer we call slotComposeMail() after we reached the main event loop
+ QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
+ // slotComposeMail();
}
else if (msg == "newMail(QString)")
{
+ //qDebug(" newMail(QString)");
QDataStream stream(data,IO_ReadOnly);
- QString nameemail;
- stream >> nameemail;
+ stream >> mPendingName;
// the format is
// NAME <EMAIL>:SUBJECT
- //qDebug("message %s ", nameemail.latin1());
-
- slotwriteMail2( nameemail );
- } else
- ExternalAppHandler::instance()->appMessage ( msg, data);
+ QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
+ } else {
+ if ( ii == 1 ) {
+ qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported ");
+ return;
+ }
+ ExternalAppHandler::instance()->appMessage ( msg, data);
+ }
+
+ //qDebug("END OpieMail::message ");
}
void OpieMail::slotwriteMail2(const QString& namemail )
{
- // qDebug("OpieMail::slotwriteMail2 ");
- qApp->processEvents();
+ //qDebug("OpieMail::slotwriteMail2 ");
+ //qApp->processEvents();
ComposeMail compose( settings, this, 0, true );
if ( !namemail.isEmpty() ) {
QString to = namemail;
if ( namemail.find( " <") > 1 ) {
to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
} else
if ( namemail.find( "<") > 1 ) {
to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
}
int sub = to.find( ">:");
if ( sub > 0 ) {
compose.setTo( to.left(sub+1) );
compose.setSubject( to.mid(sub+2) );
} else
compose.setTo( to );
}
compose.slotAdjustColumns();
compose.showMaximized();
compose.exec();
raise();
//qDebug("retttich ");
}
void OpieMail::slotwriteMail(const QString&name,const QString&email)
{
// qDebug("OpieMail::slotwriteMail ");
ComposeMail compose( settings, this, 0, true );
if (!email.isEmpty())
{
if (!name.isEmpty())
{
compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
}
else
{
compose.setTo(email);
}
}
compose.slotAdjustColumns();
compose.showMaximized();
compose.exec();
+ raise();
}
void OpieMail::slotComposeMail()
{
- slotwriteMail2( QString () );
+ if ( mPendingEmail == QString::null && mPendingName == QString::null)
+ slotwriteMail2( QString () );
+ else {
+ if ( mPendingEmail == QString::null )
+ slotwriteMail2( mPendingName );
+ else
+ slotwriteMail( mPendingName, mPendingEmail );
+ }
//slotwriteMail(0l,0l);
}
void OpieMail::slotSendQueued()
{
SMTPaccount *smtp = 0;
QList<Account> list = settings->getAccounts();
QList<SMTPaccount> smtpList;
smtpList.setAutoDelete(false);
Account *it;
for ( it = list.first(); it; it = list.next() )
{
if ( it->getType() == MAILLIB::A_SMTP )
{
smtp = static_cast<SMTPaccount *>(it);
smtpList.append(smtp);
}
}
if (smtpList.count()==0)
{
QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
return;
}
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h
index 7434e59..1de5f6b 100644
--- a/kmicromail/opiemail.h
+++ b/kmicromail/opiemail.h
@@ -20,29 +20,31 @@ public:
public slots:
virtual void slotwriteMail(const QString&name,const QString&email);
virtual void slotwriteMail2(const QString&nameemail);
virtual void slotComposeMail();
virtual void appMessage(const QCString &msg, const QByteArray &data);
virtual void message(const QCString &msg, const QByteArray &data);
protected slots:
virtual void slotSendQueued();
virtual void slotSearchMails();
virtual void slotEditSettings();
virtual void slotEditAccounts();
virtual void displayMail();
virtual void slotDeleteMail();
virtual void slotDeleteAllMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotShowFolders( bool show );
virtual void refreshMailView(const QValueList<RecMailP>&);
virtual void mailLeftClicked( QListViewItem * );
virtual void slotMoveCopyMail();
virtual void slotMoveCopyAllMail();
virtual void reEditMail();
void clearSelection();
private:
+ QString mPendingEmail;
+ QString mPendingName;
Settings *settings;
};
#endif