summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-05 22:50:37 (UTC)
committer ulf69 <ulf69>2004-08-05 22:50:37 (UTC)
commitc807547c32dd25e9d181d396590af9915b7a1166 (patch) (side-by-side diff)
tree0950df8ef9653ab30e2faebf67bdd254e0ec1b8a
parentbb1dd236b41cbd5cc4aed3b320801aa07974122d (diff)
downloadkdepimpi-c807547c32dd25e9d181d396590af9915b7a1166.zip
kdepimpi-c807547c32dd25e9d181d396590af9915b7a1166.tar.gz
kdepimpi-c807547c32dd25e9d181d396590af9915b7a1166.tar.bz2
enabled the sending of emails to selected contacts, and mailing of vCards
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp94
-rw-r--r--kaddressbook/kabprefs.cpp3
-rw-r--r--kaddressbook/kabprefs.h12
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp109
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h8
-rw-r--r--microkde/kdialogbase.cpp1
-rw-r--r--microkde/kutils/kcmultidialog.cpp3
7 files changed, 196 insertions, 34 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a7ca0ce..2a54900 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -79,6 +79,12 @@
#include <kcmkabconfig.h>
-//US#include <qpe/resource.h> // needed for Resource::loadPixmap
//#include <qlabel.h>
+
+
+#ifdef Q_WS_QWS
+#include <qtopia/services.h>
+#include <qtopia/qcopenvelope_qws.h>
+#endif
+
#endif // KAB_EMBEDDED
#include <kcmkabconfig.h>
@@ -92,9 +98,15 @@
//US#include <qsplitter.h>
+#include <qmap.h>
+#include <qdir.h>
+#include <qfile.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qclipboard.h>
+#include <qtextstream.h>
#include <libkdepim/categoryselectdialog.h>
+#include <kabc/vcardconverter.h>
+
#include "addresseeutil.h"
@@ -130,8 +142,5 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
#endif //KAB_EMBEDDED
{
-#ifdef KAB_EMBEDDED
- //US we define here our own global actioncollection.
- //mActionCollection = new KActionCollection(this);
-#endif //KAB_EMBEDDED
+
mExtensionBarSplitter = 0;
mIsPart = !parent->inherits( "KAddressBookMain" );
@@ -197,10 +206,11 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
mJumpButtonBar, SLOT( recreateButtons() ) );
+ connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
+ SLOT( sendMail( const QString& ) ) );
+
#ifndef KAB_EMBEDDED
connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
mXXPortManager, SLOT( importVCard( const KURL& ) ) );
- connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
- SLOT( sendMail( const QString& ) ) );
connect( mDetails, SIGNAL( browse( const QString& ) ),
SLOT( browse( const QString& ) ) );
@@ -222,10 +232,4 @@ KABCore::~KABCore()
mAddressBook = 0;
KABC::StdAddressBook::close();
-
-#ifdef KAB_EMBEDDED
- //US we define here our own global actioncollection.
- // delete mActionCollection;
-#endif //KAB_EMBEDDED
-
}
@@ -452,36 +456,48 @@ void KABCore::setContactSelected( const QString &uid )
void KABCore::sendMail()
{
-#ifndef KAB_EMBEDDED
sendMail( mViewManager->selectedEmails().join( ", " ) );
-#else //KAB_EMBEDDED
- qDebug("KABCore::sendMail() ust be fixed");
-#endif //KAB_EMBEDDED
}
void KABCore::sendMail( const QString& email )
{
-#ifndef KAB_EMBEDDED
- kapp->invokeMailer( email, "" );
-#else //KAB_EMBEDDED
- qDebug("KABCore::sendMail(const QString& email) ust be fixed");
-#endif //KAB_EMBEDDED
+//US original kde implementation : kapp->invokeMailer( email, "" );
+
+/*US original qtopia implementation
+ PimContact c = abList->currentEntry();
+ QString name = c.fileAs();
+ QString email = c.defaultEmail();
+#ifndef QT_NO_COP
+ QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)");
+ e << name << email;
+#else
+*/
+
+
+#ifndef QT_NO_COP
+ QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
+ qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
+
+ QCopEnvelope e(channel, "writeMail(QString,QString)");
+ //US we need no names in the To field. The emailadresses are enough
+ e << "" << email;
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
+#endif
}
void KABCore::mailVCard()
{
-#ifndef KAB_EMBEDDED
QStringList uids = mViewManager->selectedUids();
if ( !uids.isEmpty() )
mailVCard( uids );
-#else //KAB_EMBEDDED
- qDebug("KABCore::mailVCard() must be fixed");
-#endif //KAB_EMBEDDED
}
void KABCore::mailVCard( const QStringList& uids )
{
-#ifndef KAB_EMBEDDED
QStringList urls;
+ QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
+
+/*US
// Create a temp dir, so that we can put the files in it with proper names
KTempFile tempDir;
@@ -493,4 +509,9 @@ void KABCore::mailVCard( const QStringList& uids )
QString dirName = tempDir.name();
tempDir.unlink();
+*/
+ QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
+
+
+
QDir().mkdir( dirName, true );
@@ -521,5 +542,5 @@ void KABCore::mailVCard( const QStringList& uids )
}
}
-
+/*US
kapp->invokeMailer( QString::null, QString::null, QString::null,
QString::null, // subject
@@ -527,7 +548,18 @@ void KABCore::mailVCard( const QStringList& uids )
QString::null,
urls ); // attachments
-#else //KAB_EMBEDDED
- qDebug("KABCore::mailVCard( must be fixed");
-#endif //KAB_EMBEDDED
+*/
+#ifndef QT_NO_COP
+ QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
+ qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
+
+ QMap<QString, QString> parameterMap;
+ parameterMap.insert("ATTACHMENT<n>", urls.join(", "));
+
+ QCopEnvelope e(channel, "writeMail(QMap(QString,QString))");
+ e << parameterMap;
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
+#endif
+
}
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 5b3b1ab..8bd4b15 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -51,4 +51,7 @@ KABPrefs::KABPrefs()
addItemBool("ToolBarHor",&mToolBarHor, true );
addItemBool("ToolBarUp",&mToolBarUp, false );
+ addItemInt( "EmailChannelType", &mEmailClient, OMPI );
+ addItemString( "EmailChannelOther", &mEmailChannel, "" );
+
#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 370fc5b..c81a9a9 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -38,4 +38,12 @@ class KABPrefs : public KPimPrefs
static KABPrefs *instance();
+ enum EMailClients {
+ OMPI = 0,
+ QTOPIA = 1,
+ OPIE = 2,
+ OTHER = 3
+ };
+
+
// General
bool mHonorSingleClick;
@@ -50,4 +58,8 @@ class KABPrefs : public KPimPrefs
bool mToolBarUp;
bool mAskForQuit;
+
+ int mEmailClient;
+ QString mEmailChannel;
+
/** Set preferences to default values */
// void usrSetDefaults();
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 38c7946..1bac26f 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -28,4 +28,8 @@
#include <qpushbutton.h>
#include <qtabwidget.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qfile.h>
#include <kconfig.h>
@@ -94,5 +98,5 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
KDialog::spacingHintSmall() );
-
+ //general groupbox
QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
@@ -110,4 +114,7 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
layout->addWidget( groupBox );
+
+ //extensions groupbox
+
groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage );
boxLayout = new QVBoxLayout( groupBox->layout() );
@@ -146,6 +153,94 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
+
+ // mailclient page
+ QWidget *mailclientPage = new QWidget( this );
+ layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(),
+ KDialog::spacingHintSmall() );
+
+ groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage );
+ boxLayout = new QVBoxLayout( groupBox->layout() );
+ boxLayout->setAlignment( Qt::AlignTop );
+// boxLayout->setMargin(KDialog::marginHintSmall() );
+// groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
+// groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
+// boxLayout->setSpacing( KDialog::spacingHintSmall() );
+
+ mEmailClient = new QComboBox( groupBox );
+ mEmailClient->insertItem( i18n("OM/Pi"), KABPrefs::OMPI );
+ mEmailClient->insertItem( i18n("Qtopia mail"), KABPrefs::QTOPIA );
+ mEmailClient->insertItem( i18n("Opie mail"), KABPrefs::OPIE );
+ mEmailClient->insertItem( i18n("Other"), KABPrefs::OTHER );
+ boxLayout->addWidget( mEmailClient );
+
+ connect( mEmailClient, SIGNAL( activated( int ) ),
+ this, SLOT (emailclient_changed( int ) ) );
+
+ QLabel* lab = new QLabel( i18n("Channel:"), groupBox);
+ boxLayout->addWidget( lab );
+ mEmailChannel = new QLineEdit(groupBox);
+ mEmailChannel->setReadOnly(true);
+ boxLayout->addWidget( mEmailChannel );
+
+ layout->addWidget( groupBox );
+ tabWidget->addTab( mailclientPage, i18n( "Mail" ) );
+
+
+
}
+
+
+void KABConfigWidget::emailclient_changed( int newClient )
+{
+ if (newClient == KABPrefs::OTHER)
+ mEmailChannel->setReadOnly(false);
+ else
+ mEmailChannel->setReadOnly(true);
+
+ QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
+ QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
+
+ if (opiepath.isEmpty())
+ opiepath = qtopiapath;
+
+ QString text = mEmailChannel->text();
+
+ if (newClient == KABPrefs::OPIE)
+ {
+ if ( QFile::exists( opiepath + "/bin/opiemail" ))
+ text = "QPE/Application/opiemail";
+ else
+ text = "FILENOTFOUND: " + opiepath + "/bin/opiemail";
+ }
+ else if (newClient == KABPrefs::QTOPIA)
+ {
+ if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
+ text = "QPE/Application/qtmail";
+ else
+ text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail";
+
+ }
+ else if (newClient == KABPrefs::OMPI)
+ {
+ if ( QFile::exists( qtopiapath + "/bin/ompi" ))
+ text = "QPE/Application/ompi";
+ else if ( QFile::exists( opiepath + "/bin/ompi" ))
+ text = "QPE/Application/ompi";
+ else
+ text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi";
+
+ }
+ else
+ {
+ //do nothing if we choosed other
+ }
+
+ mEmailChannel->setText( text );
+
+
+}
+
+
void KABConfigWidget::restoreSettings()
{
@@ -155,4 +250,8 @@ void KABConfigWidget::restoreSettings()
mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing );
mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick );
+
+ mEmailChannel->setText( KABPrefs::instance()->mEmailChannel );
+ mEmailClient->setCurrentItem(KABPrefs::instance()->mEmailClient);
+
mAddresseeWidget->restoreSettings();
@@ -168,4 +267,8 @@ void KABConfigWidget::saveSettings()
KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked();
KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked();
+
+ KABPrefs::instance()->mEmailClient = mEmailClient->currentItem();
+ KABPrefs::instance()->mEmailChannel = mEmailChannel->text();
+
mAddresseeWidget->saveSettings();
@@ -181,4 +284,8 @@ void KABConfigWidget::defaults()
mViewsSingleClickBox->setChecked( false );
+ mEmailClient->setCurrentItem(KABPrefs::OMPI);
+ emailclient_changed( KABPrefs::OMPI );
+
+
emit changed( true );
}
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 0f36d9e..9d1363b 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -30,5 +30,6 @@ class QCheckBox;
class QListViewItem;
class QPushButton;
-
+class QComboBox;
+class QLineEdit;
class KListView;
@@ -52,8 +53,11 @@ class KABConfigWidget : public QWidget
void modified();
+
+
private slots:
void configureExtension();
void selectionChanged( QListViewItem* );
void itemClicked( QListViewItem* );
+ void emailclient_changed( int newClient );
private:
@@ -66,4 +70,6 @@ class KABConfigWidget : public QWidget
QCheckBox *mViewsSingleClickBox;
QPushButton *mConfigureButton;
+ QComboBox* mEmailClient;
+ QLineEdit* mEmailChannel;
AddresseeWidget *mAddresseeWidget;
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp
index c953058..d1f7630 100644
--- a/microkde/kdialogbase.cpp
+++ b/microkde/kdialogbase.cpp
@@ -79,5 +79,4 @@ void KDialogBase::init( const QString &caption, int buttonMask,
}
if ( buttonMask & Default ) {
- qDebug("buttonMask & Default ");
mDefaultButton = new QPushButton( i18n("Default"), this );
connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) );
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index 4136622..13be2ce 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -44,4 +44,7 @@ KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const ch
enableButton(Apply, false);
//connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
+
+ connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
+
_baseGroup = baseGroup;
mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );