-rw-r--r-- | kmicromail/composemail.cpp | 99 | ||||
-rw-r--r-- | kmicromail/composemail.h | 8 | ||||
-rw-r--r-- | kmicromail/main.cpp | 5 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 2 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 1 |
5 files changed, 100 insertions, 15 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 654cfc0..5f446fa 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -16,60 +16,73 @@ #include <qpe/global.h> //#include <qpe/contact.h> #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, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { + 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 = ""; + m_replyid = ""; + KConfig config( locateLocal("config", "kabcrc") ); + config.setGroup( "General" ); + QString whoami_uid = config.readEntry( "WhoAmI" ); + bool res = 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 ); } @@ -78,35 +91,38 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m 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() ) ); connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); mMail = 0; - warnAttach = true; + warnAttach = true; } + + + void ComposeMail::saveAsDraft() { Opie::Core::OSmartPointer<Mail> mail= new Mail(); mail->setMail(fromBox->currentText()); mail->setTo( toLine->text() ); mail->setName(senderNameEdit->text()); mail->setCC( ccLine->text() ); mail->setBCC( bccLine->text() ); mail->setReply( replyLine->text() ); mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); mail->setInreply(ids); } @@ -127,95 +143,156 @@ void ComposeMail::saveAsDraft() if ( warnAttach ) QMessageBox::warning(0,tr("Store message"), tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); warnAttach = false; } setStatus( tr("Mail saved as draft!") ); } void ComposeMail::clearStatus() { topLevelWidget()->setCaption( tr("Compose mail") ); } void ComposeMail::setStatus( QString status ) { topLevelWidget()->setCaption( status ); QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; } -void ComposeMail::pickAddress( QLineEdit *line ) +void ComposeMail::pickAddress( ) { + + QLineEdit *line = mPickLineEdit; + if ( line == 0 ) + return; +#ifdef DESKTOP_VERSION //qDebug(" ComposeMail::pickAddress "); QString names ;//= AddressPicker::getNames(); KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { if ( !list[i].preferredEmail().isEmpty()) { - names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; - if ( i < list.count() -1 ) + 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 "); + raise(); + + if ( mPickLineEdit == 0 ) { //whoami received + + 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++) + { + QString _name = nameList[i]; + QString _email = emailList[i]; + QString _uid = uidList[i]; + if ( ! _email.isEmpty() ) { + if ( ! names.isEmpty() ) + names+= ","; + names+= "\""+_name +"\"<" +_email +">"; + } + } + } + if ( line->text().isEmpty() ) { + line->setText( names ); + } else if ( !names.isEmpty() ) { + line->setText( line->text() + ", " + names ); + } } - void ComposeMail::setTo( const QString & to ) { toLine->setText( to ); } void ComposeMail::setSubject( const QString & subject ) { subjectLine->setText( subject ); } void ComposeMail::setInReplyTo( const QString & messageId ) { m_replyid = messageId; } void ComposeMail::setMessage( const QString & text ) { message->setText( text ); } void ComposeMail::pickAddressTo() { - pickAddress( toLine ); + mPickLineEdit = toLine; + pickAddress( ); } void ComposeMail::pickAddressCC() { - pickAddress( ccLine ); + mPickLineEdit = ccLine; + pickAddress( ); } void ComposeMail::pickAddressBCC() { - pickAddress( bccLine ); + mPickLineEdit = bccLine; + pickAddress( ); } void ComposeMail::pickAddressReply() { - pickAddress( replyLine ); + mPickLineEdit = replyLine; + pickAddress( ); } void ComposeMail::fillValues( int ) { #if 0 SMTPaccount *smtp = smtpAccounts.at( current ); ccLine->clear(); if ( smtp->getUseCC() ) { ccLine->setText( smtp->getCC() ); } bccLine->clear(); if ( smtp->getUseBCC() ) { bccLine->setText( smtp->getBCC() ); } replyLine->clear(); if ( smtp->getUseReply() ) { diff --git a/kmicromail/composemail.h b/kmicromail/composemail.h index 876b597..657f665 100644 --- a/kmicromail/composemail.h +++ b/kmicromail/composemail.h @@ -21,63 +21,67 @@ public: AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); static QString getNames(); protected: QString selectedNames; void accept(); }; #endif class RecMail; class ComposeMail : public ComposeMailUI { Q_OBJECT public: + ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); virtual ~ComposeMail(); void reEditMail(const Opie::Core::OSmartPointer<RecMail>¤t); public slots: void slotAdjustColumns(); void setTo( const QString & to ); void setSubject( const QString & subject ); void setInReplyTo( const QString & messageId ); - void setMessage( const QString & text ); + void setMessage( const QString & text ); + void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); + protected slots: void accept(); void reject(); private slots: void fillValues( int current ); - void pickAddress( QLineEdit *line ); + void pickAddress(); void pickAddressTo(); void pickAddressCC(); void pickAddressBCC(); void pickAddressReply(); void saveAsDraft(); void addAttachment(); void removeAttachment(); void clearStatus(); void setStatus( QString ); protected: + QLineEdit* mPickLineEdit; Opie::Core::OSmartPointer<Mail> mMail; Settings *settings; QList<SMTPaccount> smtpAccounts; QString m_replyid; bool warnAttach; }; class AttachViewItem : public QListViewItem { public: AttachViewItem( QListView *parent, Attachment *att ); Attachment *getAttachment() { return attachment; } private: Attachment *attachment; diff --git a/kmicromail/main.cpp b/kmicromail/main.cpp index 22f1200..a3e1b86 100644 --- a/kmicromail/main.cpp +++ b/kmicromail/main.cpp @@ -1,20 +1,22 @@ // CHANGED 2004-08-06 Lutz Rogowski + #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> +#include <libkdepim/externalapphandler.h> #include <stdlib.h> #else #include <qapplication.h> #include <qstring.h> #include <qwindowsstyle.h> #include <qplatinumstyle.h> #include <qsgistyle.h> #endif #include "opiemail.h" #include <qdir.h> #include <kstandarddirs.h> #include <kglobal.h> #include <stdio.h> #include "mainwindow.h" using namespace Opie::Core; @@ -31,28 +33,29 @@ int main( int argc, char **argv ) { KGlobal::setAppName( "kmicromail" ); QString fileName ; #ifndef DESKTOP_VERSION fileName = getenv("QPEDIR"); if ( QApplication::desktop()->width() > 320 ) KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/icons22/"); else KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/"); #else fileName = qApp->applicationDirPath () + "/kdepim/kmicromail/"; KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); #endif KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kmicromail"))); OpieMail mw; #ifndef DESKTOP_VERSION //qDebug("CONNECT "); - QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& ))); + QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& ))); + QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); a.showMainWidget(&mw ); #else a.setMainWidget(&mw ); mw.show(); //m.resize( 800, 600 ); QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); #endif int rv = a.exec(); return rv; } diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 704a9ab..6df95c6 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -11,33 +11,33 @@ #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif #include "defines.h" #include "mainwindow.h" #include <KDGanttMinimizeSplitter.h> #include <kabc/stdaddressbook.h> MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name ) //, flags ) { setCaption( tr( "KOpieMail/Pi" ) ); setToolBarsMovable( false ); - KABC::StdAddressBook::self(); + //KABC::StdAddressBook::self(); toolBar = new QToolBar( this ); menuBar = new QMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"), 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 251f15a..3e560c5 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -91,32 +91,33 @@ void OpieMail::slotwriteMail2(const QString& 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 , WStyle_ContextHelp ); if (!email.isEmpty()) { if (!name.isEmpty()) { compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); } else { compose.setTo(email); } |