summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (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
5 files changed, 193 insertions, 33 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a7ca0ce..2a54900 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -78,8 +78,14 @@
78 78
79#include <kcmkabconfig.h> 79#include <kcmkabconfig.h>
80 80
81//US#include <qpe/resource.h> // needed for Resource::loadPixmap
82//#include <qlabel.h> 81//#include <qlabel.h>
82
83
84#ifdef Q_WS_QWS
85#include <qtopia/services.h>
86#include <qtopia/qcopenvelope_qws.h>
87#endif
88
83#endif // KAB_EMBEDDED 89#endif // KAB_EMBEDDED
84#include <kcmkabconfig.h> 90#include <kcmkabconfig.h>
85 91
@@ -91,11 +97,17 @@
91#include <resource.h> 97#include <resource.h>
92 98
93//US#include <qsplitter.h> 99//US#include <qsplitter.h>
100#include <qmap.h>
101#include <qdir.h>
102#include <qfile.h>
94#include <qvbox.h> 103#include <qvbox.h>
95#include <qlayout.h> 104#include <qlayout.h>
96#include <qclipboard.h> 105#include <qclipboard.h>
106#include <qtextstream.h>
97 107
98#include <libkdepim/categoryselectdialog.h> 108#include <libkdepim/categoryselectdialog.h>
109#include <kabc/vcardconverter.h>
110
99 111
100#include "addresseeutil.h" 112#include "addresseeutil.h"
101#include "undocmds.h" 113#include "undocmds.h"
@@ -129,10 +141,7 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
129 mReadWrite( readWrite ), mModified( false ) 141 mReadWrite( readWrite ), mModified( false )
130#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
131{ 143{
132#ifdef KAB_EMBEDDED 144
133 //US we define here our own global actioncollection.
134 //mActionCollection = new KActionCollection(this);
135#endif //KAB_EMBEDDED
136 mExtensionBarSplitter = 0; 145 mExtensionBarSplitter = 0;
137 mIsPart = !parent->inherits( "KAddressBookMain" ); 146 mIsPart = !parent->inherits( "KAddressBookMain" );
138 147
@@ -196,12 +205,13 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
196 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 205 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
197 mJumpButtonBar, SLOT( recreateButtons() ) ); 206 mJumpButtonBar, SLOT( recreateButtons() ) );
198 207
208 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
209 SLOT( sendMail( const QString& ) ) );
210
199#ifndef KAB_EMBEDDED 211#ifndef KAB_EMBEDDED
200 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 212 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
201 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 213 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
202 214
203 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
204 SLOT( sendMail( const QString& ) ) );
205 connect( mDetails, SIGNAL( browse( const QString& ) ), 215 connect( mDetails, SIGNAL( browse( const QString& ) ),
206 SLOT( browse( const QString& ) ) ); 216 SLOT( browse( const QString& ) ) );
207 217
@@ -221,12 +231,6 @@ KABCore::~KABCore()
221 delete AddresseeConfig::instance(); 231 delete AddresseeConfig::instance();
222 mAddressBook = 0; 232 mAddressBook = 0;
223 KABC::StdAddressBook::close(); 233 KABC::StdAddressBook::close();
224
225#ifdef KAB_EMBEDDED
226 //US we define here our own global actioncollection.
227 // delete mActionCollection;
228#endif //KAB_EMBEDDED
229
230} 234}
231 235
232void KABCore::restoreSettings() 236void KABCore::restoreSettings()
@@ -451,38 +455,50 @@ void KABCore::setContactSelected( const QString &uid )
451 455
452void KABCore::sendMail() 456void KABCore::sendMail()
453{ 457{
454#ifndef KAB_EMBEDDED
455 sendMail( mViewManager->selectedEmails().join( ", " ) ); 458 sendMail( mViewManager->selectedEmails().join( ", " ) );
456#else //KAB_EMBEDDED
457 qDebug("KABCore::sendMail() ust be fixed");
458#endif //KAB_EMBEDDED
459} 459}
460 460
461void KABCore::sendMail( const QString& email ) 461void KABCore::sendMail( const QString& email )
462{ 462{
463#ifndef KAB_EMBEDDED 463//US original kde implementation : kapp->invokeMailer( email, "" );
464 kapp->invokeMailer( email, "" ); 464
465#else //KAB_EMBEDDED 465/*US original qtopia implementation
466 qDebug("KABCore::sendMail(const QString& email) ust be fixed"); 466 PimContact c = abList->currentEntry();
467#endif //KAB_EMBEDDED 467 QString name = c.fileAs();
468 QString email = c.defaultEmail();
469#ifndef QT_NO_COP
470 QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)");
471 e << name << email;
472#else
473*/
474
475
476#ifndef QT_NO_COP
477 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
478 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
479
480 QCopEnvelope e(channel, "writeMail(QString,QString)");
481 //US we need no names in the To field. The emailadresses are enough
482 e << "" << email;
483#else
484 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
485#endif
468} 486}
469 487
470void KABCore::mailVCard() 488void KABCore::mailVCard()
471{ 489{
472#ifndef KAB_EMBEDDED
473 QStringList uids = mViewManager->selectedUids(); 490 QStringList uids = mViewManager->selectedUids();
474 if ( !uids.isEmpty() ) 491 if ( !uids.isEmpty() )
475 mailVCard( uids ); 492 mailVCard( uids );
476#else //KAB_EMBEDDED
477 qDebug("KABCore::mailVCard() must be fixed");
478#endif //KAB_EMBEDDED
479} 493}
480 494
481void KABCore::mailVCard( const QStringList& uids ) 495void KABCore::mailVCard( const QStringList& uids )
482{ 496{
483#ifndef KAB_EMBEDDED
484 QStringList urls; 497 QStringList urls;
485 498
499 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
500
501/*US
486 // Create a temp dir, so that we can put the files in it with proper names 502 // Create a temp dir, so that we can put the files in it with proper names
487 KTempFile tempDir; 503 KTempFile tempDir;
488 if ( tempDir.status() != 0 ) { 504 if ( tempDir.status() != 0 ) {
@@ -492,6 +508,11 @@ void KABCore::mailVCard( const QStringList& uids )
492 508
493 QString dirName = tempDir.name(); 509 QString dirName = tempDir.name();
494 tempDir.unlink(); 510 tempDir.unlink();
511*/
512 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
513
514
515
495 QDir().mkdir( dirName, true ); 516 QDir().mkdir( dirName, true );
496 517
497 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 518 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
@@ -520,15 +541,26 @@ void KABCore::mailVCard( const QStringList& uids )
520 urls.append( fileName ); 541 urls.append( fileName );
521 } 542 }
522 } 543 }
523 544/*US
524 kapp->invokeMailer( QString::null, QString::null, QString::null, 545 kapp->invokeMailer( QString::null, QString::null, QString::null,
525 QString::null, // subject 546 QString::null, // subject
526 QString::null, // body 547 QString::null, // body
527 QString::null, 548 QString::null,
528 urls ); // attachments 549 urls ); // attachments
529#else //KAB_EMBEDDED 550*/
530 qDebug("KABCore::mailVCard( must be fixed"); 551#ifndef QT_NO_COP
531#endif //KAB_EMBEDDED 552 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
553 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
554
555 QMap<QString, QString> parameterMap;
556 parameterMap.insert("ATTACHMENT<n>", urls.join(", "));
557
558 QCopEnvelope e(channel, "writeMail(QMap(QString,QString))");
559 e << parameterMap;
560#else
561 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
562#endif
563
532 564
533} 565}
534 566
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 5b3b1ab..8bd4b15 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -50,6 +50,9 @@ KABPrefs::KABPrefs()
50 addItemBool("AskForQuit",&mAskForQuit,false); 50 addItemBool("AskForQuit",&mAskForQuit,false);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 addItemInt( "EmailChannelType", &mEmailClient, OMPI );
54 addItemString( "EmailChannelOther", &mEmailChannel, "" );
55
53#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
54 57
55 KPrefs::setCurrentGroup( "MainWindow" ); 58 KPrefs::setCurrentGroup( "MainWindow" );
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 370fc5b..c81a9a9 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -37,6 +37,14 @@ class KABPrefs : public KPimPrefs
37 37
38 static KABPrefs *instance(); 38 static KABPrefs *instance();
39 39
40 enum EMailClients {
41 OMPI = 0,
42 QTOPIA = 1,
43 OPIE = 2,
44 OTHER = 3
45 };
46
47
40 // General 48 // General
41 bool mHonorSingleClick; 49 bool mHonorSingleClick;
42 bool mAutomaticNameParsing; 50 bool mAutomaticNameParsing;
@@ -49,6 +57,10 @@ class KABPrefs : public KPimPrefs
49 bool mToolBarHor; 57 bool mToolBarHor;
50 bool mToolBarUp; 58 bool mToolBarUp;
51 bool mAskForQuit; 59 bool mAskForQuit;
60
61 int mEmailClient;
62 QString mEmailChannel;
63
52 /** Set preferences to default values */ 64 /** Set preferences to default values */
53// void usrSetDefaults(); 65// void usrSetDefaults();
54 66
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
@@ -27,6 +27,10 @@
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h>
31#include <qlineedit.h>
32#include <qlabel.h>
33#include <qfile.h>
30 34
31#include <kconfig.h> 35#include <kconfig.h>
32#include <kdebug.h> 36#include <kdebug.h>
@@ -93,7 +97,7 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
93 QWidget *generalPage = new QWidget( this ); 97 QWidget *generalPage = new QWidget( this );
94 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 98 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
95 KDialog::spacingHintSmall() ); 99 KDialog::spacingHintSmall() );
96 100 //general groupbox
97 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); 101 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
98 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); 102 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
99 boxLayout->setAlignment( Qt::AlignTop ); 103 boxLayout->setAlignment( Qt::AlignTop );
@@ -109,6 +113,9 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
109 113
110 layout->addWidget( groupBox ); 114 layout->addWidget( groupBox );
111 115
116
117 //extensions groupbox
118
112 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); 119 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage );
113 boxLayout = new QVBoxLayout( groupBox->layout() ); 120 boxLayout = new QVBoxLayout( groupBox->layout() );
114 boxLayout->setAlignment( Qt::AlignTop ); 121 boxLayout->setAlignment( Qt::AlignTop );
@@ -145,8 +152,96 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
145 mAddresseeWidget = new AddresseeWidget( this ); 152 mAddresseeWidget = new AddresseeWidget( this );
146 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 153 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
147 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 154 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
155
156 // mailclient page
157 QWidget *mailclientPage = new QWidget( this );
158 layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(),
159 KDialog::spacingHintSmall() );
160
161 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage );
162 boxLayout = new QVBoxLayout( groupBox->layout() );
163 boxLayout->setAlignment( Qt::AlignTop );
164// boxLayout->setMargin(KDialog::marginHintSmall() );
165// groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
166// groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
167// boxLayout->setSpacing( KDialog::spacingHintSmall() );
168
169 mEmailClient = new QComboBox( groupBox );
170 mEmailClient->insertItem( i18n("OM/Pi"), KABPrefs::OMPI );
171 mEmailClient->insertItem( i18n("Qtopia mail"), KABPrefs::QTOPIA );
172 mEmailClient->insertItem( i18n("Opie mail"), KABPrefs::OPIE );
173 mEmailClient->insertItem( i18n("Other"), KABPrefs::OTHER );
174 boxLayout->addWidget( mEmailClient );
175
176 connect( mEmailClient, SIGNAL( activated( int ) ),
177 this, SLOT (emailclient_changed( int ) ) );
178
179 QLabel* lab = new QLabel( i18n("Channel:"), groupBox);
180 boxLayout->addWidget( lab );
181 mEmailChannel = new QLineEdit(groupBox);
182 mEmailChannel->setReadOnly(true);
183 boxLayout->addWidget( mEmailChannel );
184
185 layout->addWidget( groupBox );
186 tabWidget->addTab( mailclientPage, i18n( "Mail" ) );
187
188
189
148} 190}
149 191
192
193
194void KABConfigWidget::emailclient_changed( int newClient )
195{
196 if (newClient == KABPrefs::OTHER)
197 mEmailChannel->setReadOnly(false);
198 else
199 mEmailChannel->setReadOnly(true);
200
201 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
202 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
203
204 if (opiepath.isEmpty())
205 opiepath = qtopiapath;
206
207 QString text = mEmailChannel->text();
208
209 if (newClient == KABPrefs::OPIE)
210 {
211 if ( QFile::exists( opiepath + "/bin/opiemail" ))
212 text = "QPE/Application/opiemail";
213 else
214 text = "FILENOTFOUND: " + opiepath + "/bin/opiemail";
215 }
216 else if (newClient == KABPrefs::QTOPIA)
217 {
218 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
219 text = "QPE/Application/qtmail";
220 else
221 text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail";
222
223 }
224 else if (newClient == KABPrefs::OMPI)
225 {
226 if ( QFile::exists( qtopiapath + "/bin/ompi" ))
227 text = "QPE/Application/ompi";
228 else if ( QFile::exists( opiepath + "/bin/ompi" ))
229 text = "QPE/Application/ompi";
230 else
231 text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi";
232
233 }
234 else
235 {
236 //do nothing if we choosed other
237 }
238
239 mEmailChannel->setText( text );
240
241
242}
243
244
150void KABConfigWidget::restoreSettings() 245void KABConfigWidget::restoreSettings()
151{ 246{
152 bool blocked = signalsBlocked(); 247 bool blocked = signalsBlocked();
@@ -154,6 +249,10 @@ void KABConfigWidget::restoreSettings()
154 249
155 mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing ); 250 mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing );
156 mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick ); 251 mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick );
252
253 mEmailChannel->setText( KABPrefs::instance()->mEmailChannel );
254 mEmailClient->setCurrentItem(KABPrefs::instance()->mEmailClient);
255
157 mAddresseeWidget->restoreSettings(); 256 mAddresseeWidget->restoreSettings();
158 257
159 restoreExtensionSettings(); 258 restoreExtensionSettings();
@@ -167,6 +266,10 @@ void KABConfigWidget::saveSettings()
167{ 266{
168 KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked(); 267 KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked();
169 KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 268 KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked();
269
270 KABPrefs::instance()->mEmailClient = mEmailClient->currentItem();
271 KABPrefs::instance()->mEmailChannel = mEmailChannel->text();
272
170 mAddresseeWidget->saveSettings(); 273 mAddresseeWidget->saveSettings();
171 274
172 saveExtensionSettings(); 275 saveExtensionSettings();
@@ -180,6 +283,10 @@ void KABConfigWidget::defaults()
180 mNameParsing->setChecked( true ); 283 mNameParsing->setChecked( true );
181 mViewsSingleClickBox->setChecked( false ); 284 mViewsSingleClickBox->setChecked( false );
182 285
286 mEmailClient->setCurrentItem(KABPrefs::OMPI);
287 emailclient_changed( KABPrefs::OMPI );
288
289
183 emit changed( true ); 290 emit changed( true );
184} 291}
185 292
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
@@ -29,7 +29,8 @@
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32 32class QComboBox;
33class QLineEdit;
33class KListView; 34class KListView;
34 35
35class AddresseeWidget; 36class AddresseeWidget;
@@ -51,10 +52,13 @@ class KABConfigWidget : public QWidget
51 public slots: 52 public slots:
52 void modified(); 53 void modified();
53 54
55
56
54 private slots: 57 private slots:
55 void configureExtension(); 58 void configureExtension();
56 void selectionChanged( QListViewItem* ); 59 void selectionChanged( QListViewItem* );
57 void itemClicked( QListViewItem* ); 60 void itemClicked( QListViewItem* );
61 void emailclient_changed( int newClient );
58 62
59 private: 63 private:
60 void restoreExtensionSettings(); 64 void restoreExtensionSettings();
@@ -65,6 +69,8 @@ class KABConfigWidget : public QWidget
65 QCheckBox *mNameParsing; 69 QCheckBox *mNameParsing;
66 QCheckBox *mViewsSingleClickBox; 70 QCheckBox *mViewsSingleClickBox;
67 QPushButton *mConfigureButton; 71 QPushButton *mConfigureButton;
72 QComboBox* mEmailClient;
73 QLineEdit* mEmailChannel;
68 74
69 AddresseeWidget *mAddresseeWidget; 75 AddresseeWidget *mAddresseeWidget;
70}; 76};