From 2676646d4744ccceab1063dc02d772a26a203c61 Mon Sep 17 00:00:00 2001 From: zautrix Date: Tue, 07 Sep 2004 22:51:29 +0000 Subject: Implemented Ompi - kapi connection --- (limited to 'kmicromail') diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 654cfc0..5f446fa 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -29,7 +29,11 @@ #include #include #include - +#ifdef DESKTOP_VERSION +#include +#else //DESKTOP_VERSION +#include +#endif //DESKTOP_VERSION //using namespace Opie::Core; @@ -38,8 +42,16 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m : 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(); @@ -57,6 +69,7 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m fromBox->insertItem((*sit)); } senderNameEdit->setText(con.formattedName()); +#endif Config cfg( "mail" ); cfg.setGroup( "Compose" ); checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); @@ -91,9 +104,12 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); mMail = 0; - warnAttach = true; + warnAttach = true; } + + + void ComposeMail::saveAsDraft() { @@ -140,8 +156,13 @@ 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(); @@ -149,9 +170,10 @@ void ComposeMail::pickAddress( QLineEdit *line ) 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() +">"; + } } @@ -161,8 +183,59 @@ void ComposeMail::pickAddress( QLineEdit *line ) } 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 ) { @@ -187,22 +260,26 @@ void ComposeMail::setMessage( const QString & 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 ) diff --git a/kmicromail/composemail.h b/kmicromail/composemail.h index 876b597..657f665 100644 --- a/kmicromail/composemail.h +++ b/kmicromail/composemail.h @@ -34,6 +34,7 @@ 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(); @@ -45,7 +46,9 @@ public slots: 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(); @@ -53,7 +56,7 @@ protected slots: private slots: void fillValues( int current ); - void pickAddress( QLineEdit *line ); + void pickAddress(); void pickAddressTo(); void pickAddressCC(); void pickAddressBCC(); @@ -65,6 +68,7 @@ private slots: void setStatus( QString ); protected: + QLineEdit* mPickLineEdit; Opie::Core::OSmartPointer mMail; Settings *settings; QList smtpAccounts; diff --git a/kmicromail/main.cpp b/kmicromail/main.cpp index 22f1200..a3e1b86 100644 --- a/kmicromail/main.cpp +++ b/kmicromail/main.cpp @@ -1,7 +1,9 @@ // CHANGED 2004-08-06 Lutz Rogowski + #ifndef DESKTOP_VERSION #include +#include #include #else #include @@ -44,7 +46,8 @@ int main( int argc, char **argv ) { 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 ); diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 704a9ab..6df95c6 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -24,7 +24,7 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags 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 ); diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 251f15a..3e560c5 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -104,6 +104,7 @@ void OpieMail::slotwriteMail2(const QString& namemail ) compose.slotAdjustColumns(); compose.showMaximized(); compose.exec(); + raise(); //qDebug("retttich "); } void OpieMail::slotwriteMail(const QString&name,const QString&email) -- cgit v0.9.0.2