From cdf781e3243601bce6c7bcbb10f38e7a24f04887 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 16 Dec 2002 15:26:35 +0000 Subject: Addressbook is now able to send mails through opie-mail.. --- (limited to 'noncore/unsupported/mail2/mainwindow.cpp') diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp index 047c54b..a596653 100644 --- a/noncore/unsupported/mail2/mainwindow.cpp +++ b/noncore/unsupported/mail2/mainwindow.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "mailstatusbar.h" #include "folderwidget.h" @@ -10,6 +11,7 @@ #include "mailtable.h" #include "composer.h" #include "viewmail.h" +#include "mailfactory.h" MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) : MainWindowBase(parent, name, fl) @@ -28,19 +30,57 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) connect(status, SIGNAL(stop()), mailView, SLOT(stop())); - connect(compose, SIGNAL(activated()), SLOT(slotCompose())); + connect(compose, SIGNAL(activated()), SLOT(slotComposeNoParams())); connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued())); connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); + + // Added by Stefan Eilers to allow starting by addressbook.. +#if !defined(QT_NO_COP) + QCopChannel *addressChannel = new QCopChannel("QPE/Application/mail" , this ); + connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), + this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); +#endif +} + +// Added by Stefan Eilers to allow starting by addressbook.. +void MainWindow::appMessage(const QCString &msg, const QByteArray &data) +{ + if (msg == "writeMail(QString,QString)") { + QDataStream stream(data,IO_ReadOnly); + QString name, email; + stream >> name >> email; + + qWarning("opie-mail:: Should send mail to %s with address %s", name.latin1(), email.latin1() ); + + slotCompose( name, email ); + + }else{ + QString str_message = msg; + qWarning("opie-mail:: Received unknown QCop-Message: %s", str_message.latin1() ); + } } -void MainWindow::slotCompose() +void MainWindow::slotCompose( const QString& name, const QString& email ) { Composer composer(this, 0, true); + + // If there is a mailaddress given, create message.. + if ( ! name.isEmpty() ){ + qWarning("opie-mail:: Compose mail for %s with address %s", name.latin1(), email.latin1() ); + SendMail compMail; + compMail.setTo( "\"" + name + "\"" + " " + "<"+ email + ">"); + composer.setSendMail( compMail ); + } composer.showMaximized(); composer.exec(); } +void MainWindow::slotComposeNoParams() +{ + slotCompose( 0l, 0l); +} + void MainWindow::slotSendQueued() { Composer composer(this, 0, true, true); -- cgit v0.9.0.2