-rw-r--r-- | kaddressbook/kabcore.cpp | 26 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 3 | ||||
-rw-r--r-- | kaddressbook/kaddressbook.pro | 11 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 635 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.h | 85 |
5 files changed, 757 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 7e3fc7c..f4263c4 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -101,24 +101,29 @@ | |||
101 | #include "undocmds.h" | 101 | #include "undocmds.h" |
102 | #include "addresseeeditordialog.h" | 102 | #include "addresseeeditordialog.h" |
103 | #include "viewmanager.h" | 103 | #include "viewmanager.h" |
104 | #include "details/detailsviewcontainer.h" | 104 | #include "details/detailsviewcontainer.h" |
105 | #include "kabprefs.h" | 105 | #include "kabprefs.h" |
106 | #include "xxportmanager.h" | 106 | #include "xxportmanager.h" |
107 | #include "incsearchwidget.h" | 107 | #include "incsearchwidget.h" |
108 | #include "jumpbuttonbar.h" | 108 | #include "jumpbuttonbar.h" |
109 | #include "extensionmanager.h" | 109 | #include "extensionmanager.h" |
110 | #include "addresseeconfig.h" | 110 | #include "addresseeconfig.h" |
111 | #include <kcmultidialog.h> | 111 | #include <kcmultidialog.h> |
112 | 112 | ||
113 | #ifdef _WIN32_ | ||
114 | |||
115 | #include "kaimportoldialog.h" | ||
116 | #endif | ||
117 | |||
113 | 118 | ||
114 | #ifdef KAB_EMBEDDED | 119 | #ifdef KAB_EMBEDDED |
115 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 120 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
116 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 121 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
117 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 122 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
118 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 123 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
119 | #else //KAB_EMBEDDED | 124 | #else //KAB_EMBEDDED |
120 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 125 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
121 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 126 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
122 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 127 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
123 | mReadWrite( readWrite ), mModified( false ) | 128 | mReadWrite( readWrite ), mModified( false ) |
124 | #endif //KAB_EMBEDDED | 129 | #endif //KAB_EMBEDDED |
@@ -153,24 +158,26 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
153 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 158 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
154 | "X-Office", "KADDRESSBOOK" ); | 159 | "X-Office", "KADDRESSBOOK" ); |
155 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 160 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
156 | "X-IMAddress", "KADDRESSBOOK" ); | 161 | "X-IMAddress", "KADDRESSBOOK" ); |
157 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 162 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
158 | "X-Anniversary", "KADDRESSBOOK" ); | 163 | "X-Anniversary", "KADDRESSBOOK" ); |
159 | 164 | ||
160 | //US added this field to become compatible with Opie addressbook | 165 | //US added this field to become compatible with Opie addressbook |
161 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 166 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
162 | "X-Gender", "KADDRESSBOOK" ); | 167 | "X-Gender", "KADDRESSBOOK" ); |
163 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 168 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
164 | "X-Children", "KADDRESSBOOK" ); | 169 | "X-Children", "KADDRESSBOOK" ); |
170 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | ||
171 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | ||
165 | 172 | ||
166 | initGUI(); | 173 | initGUI(); |
167 | 174 | ||
168 | mIncSearchWidget->setFocus(); | 175 | mIncSearchWidget->setFocus(); |
169 | 176 | ||
170 | 177 | ||
171 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 178 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
172 | SLOT( setContactSelected( const QString& ) ) ); | 179 | SLOT( setContactSelected( const QString& ) ) ); |
173 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 180 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
174 | SLOT( editContact( const QString& ) ) ); | 181 | SLOT( editContact( const QString& ) ) ); |
175 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 182 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
176 | SLOT( deleteContacts( ) ) ); | 183 | SLOT( deleteContacts( ) ) ); |
@@ -832,24 +839,35 @@ void KABCore::addEmail( QString aStr ) | |||
832 | mViewManager->refreshView( addr.uid() ); | 839 | mViewManager->refreshView( addr.uid() ); |
833 | editContact( addr.uid() ); | 840 | editContact( addr.uid() ); |
834 | } | 841 | } |
835 | #else //KAB_EMBEDDED | 842 | #else //KAB_EMBEDDED |
836 | qDebug("KABCore::addEmail finsih method"); | 843 | qDebug("KABCore::addEmail finsih method"); |
837 | #endif //KAB_EMBEDDED | 844 | #endif //KAB_EMBEDDED |
838 | } | 845 | } |
839 | 846 | ||
840 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 847 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
841 | { | 848 | { |
842 | mXXPortManager->importVCard( url, showPreview ); | 849 | mXXPortManager->importVCard( url, showPreview ); |
843 | } | 850 | } |
851 | void KABCore::importFromOL() | ||
852 | { | ||
853 | #ifdef _WIN32_ | ||
854 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | ||
855 | idgl->exec(); | ||
856 | KABC::Addressee::List list = idgl->getAddressList(); | ||
857 | if ( list.count() > 0 ) | ||
858 | pasteContacts( list ); | ||
859 | delete idgl; | ||
860 | #endif | ||
861 | } | ||
844 | 862 | ||
845 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 863 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
846 | { | 864 | { |
847 | mXXPortManager->importVCard( vCard, showPreview ); | 865 | mXXPortManager->importVCard( vCard, showPreview ); |
848 | } | 866 | } |
849 | 867 | ||
850 | //US added a second method without defaultparameter | 868 | //US added a second method without defaultparameter |
851 | void KABCore::editContact2() { | 869 | void KABCore::editContact2() { |
852 | editContact( QString::null ); | 870 | editContact( QString::null ); |
853 | } | 871 | } |
854 | 872 | ||
855 | void KABCore::editContact( const QString &uid ) | 873 | void KABCore::editContact( const QString &uid ) |
@@ -1388,24 +1406,27 @@ void KABCore::initActions() | |||
1388 | 1406 | ||
1389 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1407 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1390 | SLOT( setWhoAmI() ), actionCollection(), | 1408 | SLOT( setWhoAmI() ), actionCollection(), |
1391 | "set_personal" ); | 1409 | "set_personal" ); |
1392 | 1410 | ||
1393 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1411 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1394 | SLOT( setCategories() ), actionCollection(), | 1412 | SLOT( setCategories() ), actionCollection(), |
1395 | "edit_set_categories" ); | 1413 | "edit_set_categories" ); |
1396 | 1414 | ||
1397 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1415 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1398 | SLOT( removeVoice() ), actionCollection(), | 1416 | SLOT( removeVoice() ), actionCollection(), |
1399 | "remove_voice" ); | 1417 | "remove_voice" ); |
1418 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, | ||
1419 | SLOT( importFromOL() ), actionCollection(), | ||
1420 | "import_OL" ); | ||
1400 | #ifdef KAB_EMBEDDED | 1421 | #ifdef KAB_EMBEDDED |
1401 | 1422 | ||
1402 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1423 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1403 | this, SLOT( createAboutData() ), actionCollection(), | 1424 | this, SLOT( createAboutData() ), actionCollection(), |
1404 | "kaddressbook_about_data" ); | 1425 | "kaddressbook_about_data" ); |
1405 | #endif //KAB_EMBEDDED | 1426 | #endif //KAB_EMBEDDED |
1406 | 1427 | ||
1407 | clipboardDataChanged(); | 1428 | clipboardDataChanged(); |
1408 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1429 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1409 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1430 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1410 | } | 1431 | } |
1411 | 1432 | ||
@@ -1468,26 +1489,27 @@ void KABCore::addActionsManually() | |||
1468 | mActionNewContact->plug( fileMenu ); | 1489 | mActionNewContact->plug( fileMenu ); |
1469 | mActionNewContact->plug( tb ); | 1490 | mActionNewContact->plug( tb ); |
1470 | 1491 | ||
1471 | mActionEditAddressee->plug( fileMenu ); | 1492 | mActionEditAddressee->plug( fileMenu ); |
1472 | fileMenu->insertSeparator(); | 1493 | fileMenu->insertSeparator(); |
1473 | mActionSave->plug( fileMenu ); | 1494 | mActionSave->plug( fileMenu ); |
1474 | fileMenu->insertItem( "&Import", ImportMenu ); | 1495 | fileMenu->insertItem( "&Import", ImportMenu ); |
1475 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1496 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1476 | fileMenu->insertSeparator(); | 1497 | fileMenu->insertSeparator(); |
1477 | mActionMailVCard->plug( fileMenu ); | 1498 | mActionMailVCard->plug( fileMenu ); |
1478 | fileMenu->insertSeparator(); | 1499 | fileMenu->insertSeparator(); |
1479 | mActionQuit->plug( fileMenu ); | 1500 | mActionQuit->plug( fileMenu ); |
1480 | 1501 | #ifdef _WIN32_ | |
1481 | 1502 | mActionImportOL->plug( ImportMenu ); | |
1503 | #endif | ||
1482 | // edit menu | 1504 | // edit menu |
1483 | mActionUndo->plug( editMenu ); | 1505 | mActionUndo->plug( editMenu ); |
1484 | mActionRedo->plug( editMenu ); | 1506 | mActionRedo->plug( editMenu ); |
1485 | editMenu->insertSeparator(); | 1507 | editMenu->insertSeparator(); |
1486 | mActionCut->plug( editMenu ); | 1508 | mActionCut->plug( editMenu ); |
1487 | mActionCopy->plug( editMenu ); | 1509 | mActionCopy->plug( editMenu ); |
1488 | mActionPaste->plug( editMenu ); | 1510 | mActionPaste->plug( editMenu ); |
1489 | mActionDelete->plug( editMenu ); | 1511 | mActionDelete->plug( editMenu ); |
1490 | editMenu->insertSeparator(); | 1512 | editMenu->insertSeparator(); |
1491 | mActionSelectAll->plug( editMenu ); | 1513 | mActionSelectAll->plug( editMenu ); |
1492 | 1514 | ||
1493 | mActionRemoveVoice->plug( changeMenu ); | 1515 | mActionRemoveVoice->plug( changeMenu ); |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 8d6041e..69a98a5 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -309,25 +309,25 @@ class KABCore : public QWidget | |||
309 | Registers a new GUI client, so plugins can register its actions. | 309 | Registers a new GUI client, so plugins can register its actions. |
310 | */ | 310 | */ |
311 | void addGUIClient( KXMLGUIClient *client ); | 311 | void addGUIClient( KXMLGUIClient *client ); |
312 | 312 | ||
313 | signals: | 313 | signals: |
314 | void contactSelected( const QString &name ); | 314 | void contactSelected( const QString &name ); |
315 | void contactSelected( const QPixmap &pixmap ); | 315 | void contactSelected( const QPixmap &pixmap ); |
316 | public slots: | 316 | public slots: |
317 | void setDetailsVisible( bool visible ); | 317 | void setDetailsVisible( bool visible ); |
318 | void setDetailsToState(); | 318 | void setDetailsToState(); |
319 | private slots: | 319 | private slots: |
320 | void setJumpButtonBarVisible( bool visible ); | 320 | void setJumpButtonBarVisible( bool visible ); |
321 | 321 | void importFromOL(); | |
322 | void extensionModified( const KABC::Addressee::List &list ); | 322 | void extensionModified( const KABC::Addressee::List &list ); |
323 | void clipboardDataChanged(); | 323 | void clipboardDataChanged(); |
324 | void updateActionMenu(); | 324 | void updateActionMenu(); |
325 | void configureKeyBindings(); | 325 | void configureKeyBindings(); |
326 | void removeVoice(); | 326 | void removeVoice(); |
327 | #ifdef KAB_EMBEDDED | 327 | #ifdef KAB_EMBEDDED |
328 | void configureResources(); | 328 | void configureResources(); |
329 | #endif //KAB_EMBEDDED | 329 | #endif //KAB_EMBEDDED |
330 | 330 | ||
331 | void slotEditorDestroyed( const QString &uid ); | 331 | void slotEditorDestroyed( const QString &uid ); |
332 | void configurationChanged(); | 332 | void configurationChanged(); |
333 | void addressBookChanged(); | 333 | void addressBookChanged(); |
@@ -399,24 +399,25 @@ class KABCore : public QWidget | |||
399 | KAction *mActionDeleteView; | 399 | KAction *mActionDeleteView; |
400 | 400 | ||
401 | QPopupMenu *viewMenu; | 401 | QPopupMenu *viewMenu; |
402 | QPopupMenu *filterMenu; | 402 | QPopupMenu *filterMenu; |
403 | QPopupMenu *settingsMenu; | 403 | QPopupMenu *settingsMenu; |
404 | QPopupMenu *changeMenu; | 404 | QPopupMenu *changeMenu; |
405 | 405 | ||
406 | //US QAction *mActionSave; | 406 | //US QAction *mActionSave; |
407 | QPopupMenu *ImportMenu; | 407 | QPopupMenu *ImportMenu; |
408 | QPopupMenu *ExportMenu; | 408 | QPopupMenu *ExportMenu; |
409 | //LR additional methods | 409 | //LR additional methods |
410 | KAction *mActionRemoveVoice; | 410 | KAction *mActionRemoveVoice; |
411 | KAction * mActionImportOL; | ||
411 | 412 | ||
412 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
413 | KAddressBookService *mAddressBookService; | 414 | KAddressBookService *mAddressBookService; |
414 | #endif //KAB_EMBEDDED | 415 | #endif //KAB_EMBEDDED |
415 | 416 | ||
416 | class KABCorePrivate; | 417 | class KABCorePrivate; |
417 | KABCorePrivate *d; | 418 | KABCorePrivate *d; |
418 | 419 | ||
419 | #ifdef KAB_EMBEDDED | 420 | #ifdef KAB_EMBEDDED |
420 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 421 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
421 | #endif //KAB_EMBEDDED | 422 | #endif //KAB_EMBEDDED |
422 | 423 | ||
diff --git a/kaddressbook/kaddressbook.pro b/kaddressbook/kaddressbook.pro index 761c3e7..bc14e68 100644 --- a/kaddressbook/kaddressbook.pro +++ b/kaddressbook/kaddressbook.pro | |||
@@ -18,24 +18,25 @@ LIBS += -lldap | |||
18 | OBJECTS_DIR = obj/unix | 18 | OBJECTS_DIR = obj/unix |
19 | MOC_DIR = moc/unix | 19 | MOC_DIR = moc/unix |
20 | } | 20 | } |
21 | win32: { | 21 | win32: { |
22 | DEFINES += _WIN32_ | 22 | DEFINES += _WIN32_ |
23 | LIBS += ../bin/microkdepim.lib | 23 | LIBS += ../bin/microkdepim.lib |
24 | LIBS += ../bin/microkcal.lib | 24 | LIBS += ../bin/microkcal.lib |
25 | LIBS += ../bin/microkde.lib | 25 | LIBS += ../bin/microkde.lib |
26 | LIBS += ../bin/microkabc.lib | 26 | LIBS += ../bin/microkabc.lib |
27 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 27 | QMAKE_LINK += /NODEFAULTLIB:LIBC |
28 | OBJECTS_DIR = obj/win | 28 | OBJECTS_DIR = obj/win |
29 | MOC_DIR = moc/win | 29 | MOC_DIR = moc/win |
30 | LIBS += mfc71u.lib | ||
30 | } | 31 | } |
31 | 32 | ||
32 | 33 | ||
33 | 34 | ||
34 | 35 | ||
35 | 36 | ||
36 | 37 | ||
37 | 38 | ||
38 | 39 | ||
39 | INTERFACES = \ | 40 | INTERFACES = \ |
40 | # filteredit_base.ui \ | 41 | # filteredit_base.ui \ |
41 | # kofilterview_base.ui \ | 42 | # kofilterview_base.ui \ |
@@ -155,12 +156,22 @@ views/configurecardviewdialog.cpp \ | |||
155 | views/cardview.cpp \ | 156 | views/cardview.cpp \ |
156 | views/contactlistview.cpp \ | 157 | views/contactlistview.cpp \ |
157 | views/colorlistbox.cpp \ | 158 | views/colorlistbox.cpp \ |
158 | xxport/vcard_xxport.cpp \ | 159 | xxport/vcard_xxport.cpp \ |
159 | xxport/kde2_xxport.cpp \ | 160 | xxport/kde2_xxport.cpp \ |
160 | xxport/csv_xxport.cpp \ | 161 | xxport/csv_xxport.cpp \ |
161 | xxport/csvimportdialog.cpp \ | 162 | xxport/csvimportdialog.cpp \ |
162 | #details/look_details.cpp \ | 163 | #details/look_details.cpp \ |
163 | #mainwindow.cpp \ | 164 | #mainwindow.cpp \ |
164 | # calendarview.cpp \ | 165 | # calendarview.cpp \ |
165 | # timespanview.cpp | 166 | # timespanview.cpp |
166 | 167 | ||
168 | |||
169 | |||
170 | win32: { | ||
171 | HEADERS += ../outport/msoutl9.h \ | ||
172 | kaimportoldialog.h | ||
173 | |||
174 | SOURCES += ../outport/msoutl9.cpp \ | ||
175 | kaimportoldialog.cpp | ||
176 | } | ||
177 | |||
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp new file mode 100644 index 0000000..5e7d7c4 --- a/dev/null +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -0,0 +1,635 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook/Pi. | ||
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qtooltip.h> | ||
25 | #include <qframe.h> | ||
26 | #include <qpixmap.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qprogressbar.h> | ||
29 | #include <qwidgetstack.h> | ||
30 | #include <qdatetime.h> | ||
31 | #include <qdir.h> | ||
32 | #include <qapplication.h> | ||
33 | #include <qhbox.h> | ||
34 | #include <qheader.h> | ||
35 | #include <qdatetime.h> | ||
36 | #include <qlistview.h> | ||
37 | |||
38 | #include <kdebug.h> | ||
39 | #include <klocale.h> | ||
40 | #include <kstandarddirs.h> | ||
41 | #include <kmessagebox.h> | ||
42 | #include <kfiledialog.h> | ||
43 | |||
44 | #include <libkdepim/categoryselectdialog.h> | ||
45 | #include <libkdepim/kinputdialog.h> | ||
46 | |||
47 | #include <libkcal/calendarlocal.h> | ||
48 | #include <libkcal/icalformat.h> | ||
49 | |||
50 | #include <kabc/addresseelist.h> | ||
51 | #include <kabc/phonenumber.h> | ||
52 | |||
53 | #include "kaimportoldialog.h" | ||
54 | |||
55 | #include "../outport/msoutl9.h" | ||
56 | #include <ole2.h> | ||
57 | #include <comutil.h> | ||
58 | _Application gOlAppAB; | ||
59 | |||
60 | QDateTime mDdate2Qdtr( DATE dt) | ||
61 | { | ||
62 | COleDateTime odt; | ||
63 | SYSTEMTIME st; | ||
64 | odt = dt; | ||
65 | if ( odt.GetStatus() != 0 ) | ||
66 | return QDateTime(); | ||
67 | odt.GetAsSystemTime(st); | ||
68 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | ||
69 | return QDateTime(); | ||
70 | // it seems so, that 1.1.4501 indicates: DATE invalid | ||
71 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | ||
72 | return qdt; | ||
73 | } | ||
74 | |||
75 | class OLEListViewItem : public QCheckListItem | ||
76 | { | ||
77 | public: | ||
78 | OLEListViewItem( QListView *parent, QString text ) : | ||
79 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | ||
80 | OLEListViewItem( QListViewItem *after, QString text ) : | ||
81 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | ||
82 | ~OLEListViewItem() {}; | ||
83 | void setData( DWORD data ) {mData= data; }; | ||
84 | DWORD data() { return mData ;}; | ||
85 | private: | ||
86 | DWORD mData; | ||
87 | }; | ||
88 | |||
89 | KAImportOLdialog::KAImportOLdialog( const QString &caption, | ||
90 | KABC::AddressBook * aBook, QWidget *parent ) : | ||
91 | KDialogBase( Plain, caption, User1 | Close, Ok, | ||
92 | parent, caption, true, false, i18n("Import!") ) | ||
93 | { | ||
94 | QHBox * mw = new QHBox( this ); | ||
95 | setMainWidget( mw ); | ||
96 | mListView = new QListView( mw ); | ||
97 | mListView->addColumn(i18n("Select Folder to import")); | ||
98 | mListView->addColumn(i18n("Content Type")); | ||
99 | mABook = aBook; | ||
100 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | ||
101 | setupFolderView(); | ||
102 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | ||
103 | } | ||
104 | |||
105 | KAImportOLdialog::~KAImportOLdialog() | ||
106 | { | ||
107 | |||
108 | } | ||
109 | |||
110 | KABC::Addressee::List KAImportOLdialog::getAddressList() | ||
111 | { | ||
112 | return mAList; | ||
113 | } | ||
114 | void KAImportOLdialog::setupFolderView() | ||
115 | { | ||
116 | SCODE sc = ::OleInitialize(NULL); | ||
117 | if ( FAILED ( sc ) ) { | ||
118 | KMessageBox::information(this,"OLE initialisation failed"); | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ | ||
123 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | ||
124 | return ; | ||
125 | } | ||
126 | MAPIFolder mfInbox; | ||
127 | MAPIFolder mfRoot; | ||
128 | CString szName; | ||
129 | _NameSpace olNS; | ||
130 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); | ||
131 | mfInbox = olNS.GetDefaultFolder(6); | ||
132 | mfRoot = mfInbox.GetParent(); | ||
133 | szName = mfRoot.GetName(); | ||
134 | long iType = mfRoot.GetDefaultItemType(); | ||
135 | QString mes; | ||
136 | mes = QString::fromUcs2( szName.GetBuffer() ); | ||
137 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); | ||
138 | mfRoot.m_lpDispatch->AddRef(); | ||
139 | addFolder( root, mfRoot.m_lpDispatch ); | ||
140 | root->setOpen( true ); | ||
141 | mListView->setSortColumn( 0 ); | ||
142 | mListView->sort( ); | ||
143 | } | ||
144 | |||
145 | |||
146 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) | ||
147 | { | ||
148 | MAPIFolder mfParent(dispParent), mfChild; | ||
149 | _Folders folders; | ||
150 | _variant_t fndx((long)0); | ||
151 | CString szName; | ||
152 | long iType; | ||
153 | OLEListViewItem* hChild; | ||
154 | |||
155 | folders = mfParent.GetFolders(); | ||
156 | for(int i=1; i <= folders.GetCount(); ++i) | ||
157 | { | ||
158 | fndx = (long)i; | ||
159 | mfChild = folders.Item(fndx.Detach()); | ||
160 | mfChild.m_lpDispatch->AddRef(); | ||
161 | szName = mfChild.GetName(); | ||
162 | iType = mfChild.GetDefaultItemType(); | ||
163 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | ||
164 | if ( iType != 2) | ||
165 | hChild->setEnabled( false ); | ||
166 | QString ts; | ||
167 | switch( iType ) { | ||
168 | case 0: | ||
169 | ts = i18n("Mail"); | ||
170 | break; | ||
171 | case 1: | ||
172 | ts = i18n("Calendar"); | ||
173 | break; | ||
174 | case 2: | ||
175 | ts = i18n("Contacts"); | ||
176 | break; | ||
177 | case 3: | ||
178 | ts = i18n("Todos"); | ||
179 | break; | ||
180 | case 4: | ||
181 | ts = i18n("Journals"); | ||
182 | break; | ||
183 | case 5: | ||
184 | ts = i18n("Notes"); | ||
185 | break; | ||
186 | default: | ||
187 | ts = i18n("Unknown"); | ||
188 | } | ||
189 | hChild->setText( 1,ts); | ||
190 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | ||
191 | mfChild.m_lpDispatch->AddRef(); | ||
192 | addFolder(hChild, mfChild.m_lpDispatch); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | void KAImportOLdialog::slotApply() | ||
197 | { | ||
198 | importedItems = 0; | ||
199 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | ||
200 | while ( child ) { | ||
201 | if ( child->isOn() ) | ||
202 | readContactData( child->data() ); | ||
203 | child = (OLEListViewItem*) child->itemBelow(); | ||
204 | } | ||
205 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | ||
206 | KMessageBox::information(this,mes); | ||
207 | } | ||
208 | void KAImportOLdialog::readContactData( DWORD folder ) | ||
209 | { | ||
210 | |||
211 | LPDISPATCH dispItem = (LPDISPATCH)folder; | ||
212 | dispItem->AddRef(); | ||
213 | MAPIFolder mf(dispItem); | ||
214 | mf.m_lpDispatch->AddRef(); | ||
215 | _Items folderItems; | ||
216 | _variant_t indx((long)0); | ||
217 | LPDISPATCH itm; | ||
218 | int i; | ||
219 | folderItems = mf.GetItems(); | ||
220 | QProgressBar bar( folderItems.GetCount(),0 ); | ||
221 | bar.setCaption (i18n("Importing - close to abort!") ); | ||
222 | int h = bar.sizeHint().height() ; | ||
223 | int w = 300; | ||
224 | int dw = QApplication::desktop()->width(); | ||
225 | int dh = QApplication::desktop()->height(); | ||
226 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
227 | bar.show(); | ||
228 | for(i=1; i <= folderItems.GetCount(); ++i) | ||
229 | { | ||
230 | qApp->processEvents(); | ||
231 | if ( ! bar.isVisible() ) | ||
232 | return ; | ||
233 | bar.setProgress( i ); | ||
234 | indx = (long)i; | ||
235 | itm = folderItems.Item(indx.Detach()); | ||
236 | _ContactItem * pItem = (_ContactItem *)&itm; | ||
237 | ol2kapiContact( pItem ); | ||
238 | itm->Release(); | ||
239 | } | ||
240 | } | ||
241 | void KAImportOLdialog::slotOk() | ||
242 | { | ||
243 | QDialog::accept(); | ||
244 | } | ||
245 | |||
246 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | ||
247 | { | ||
248 | KABC::Addressee addressee; | ||
249 | |||
250 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); | ||
251 | |||
252 | //addressee.setName( const QString &name ); | ||
253 | //addressee.setFormattedName( const QString &formattedName ); | ||
254 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); | ||
255 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); | ||
256 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); | ||
257 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); | ||
258 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); | ||
259 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); | ||
260 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); | ||
261 | if ( dtb.isValid() ) | ||
262 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); | ||
263 | |||
264 | //QString::fromUcs2(aItem->.GetBuffer()) | ||
265 | //addressee.setMailer( const QString &mailer ); | ||
266 | //addressee.setTimeZone( const TimeZone &timeZone ); | ||
267 | //addressee.setGeo( const Geo &geo ); | ||
268 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix | ||
269 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); | ||
270 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) ); | ||
271 | addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) ); | ||
272 | |||
273 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); | ||
274 | //addressee.setRevision( const QDateTime &revision ); | ||
275 | // addressee.setSortString( const QString &sortString ); | ||
276 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); | ||
277 | |||
278 | QString tempS; | ||
279 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); | ||
280 | if ( tempS.length() > 12 ) | ||
281 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); | ||
282 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); | ||
283 | if ( !tempS.isEmpty() ) | ||
284 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); | ||
285 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); | ||
286 | if ( !tempS.isEmpty() ) | ||
287 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); | ||
288 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); | ||
289 | if ( !tempS.isEmpty() ) | ||
290 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); | ||
291 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); | ||
292 | if ( !tempS.isEmpty() ) | ||
293 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); | ||
294 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()); | ||
295 | if ( !tempS.isEmpty() ) | ||
296 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); | ||
297 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); | ||
298 | if ( !tempS.isEmpty() ) | ||
299 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); | ||
300 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); | ||
301 | if (dtb.isValid() ) { | ||
302 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); | ||
303 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | ||
304 | } | ||
305 | int sec = aItem->GetSensitivity() ; | ||
306 | if ( sec > 1 )// mapping pers -> private | ||
307 | --sec; | ||
308 | addressee.setSecrecy( sec ); | ||
309 | //addressee.setLogo( const Picture &logo ); | ||
310 | //addressee.setPhoto( const Picture &photo ); | ||
311 | //addressee.setSound( const Sound &sound ); | ||
312 | //addressee.setAgent( const Agent &agent ); | ||
313 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); | ||
314 | addressee.setCategories( QStringList::split( ";", cat )); | ||
315 | |||
316 | QString phoneS; | ||
317 | |||
318 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); | ||
319 | if ( ! phoneS.isEmpty()) | ||
320 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); | ||
321 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); | ||
322 | if ( ! phoneS.isEmpty()) | ||
323 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | ||
324 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); | ||
325 | if ( ! phoneS.isEmpty()) | ||
326 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | ||
327 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); | ||
328 | if ( ! phoneS.isEmpty()) | ||
329 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); | ||
330 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); | ||
331 | if ( ! phoneS.isEmpty()) | ||
332 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); | ||
333 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); | ||
334 | if ( ! phoneS.isEmpty()) | ||
335 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | ||
336 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); | ||
337 | if ( ! phoneS.isEmpty()) | ||
338 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | ||
339 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); | ||
340 | if ( ! phoneS.isEmpty()) | ||
341 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); | ||
342 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); | ||
343 | if ( ! phoneS.isEmpty()) | ||
344 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); | ||
345 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); | ||
346 | if ( ! phoneS.isEmpty()) | ||
347 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); | ||
348 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); | ||
349 | if ( ! phoneS.isEmpty()) | ||
350 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); | ||
351 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); | ||
352 | if ( ! phoneS.isEmpty()) | ||
353 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); | ||
354 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); | ||
355 | if ( ! phoneS.isEmpty()) | ||
356 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); | ||
357 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); | ||
358 | if ( ! phoneS.isEmpty()) | ||
359 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); | ||
360 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); | ||
361 | if ( ! phoneS.isEmpty()) | ||
362 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); | ||
363 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); | ||
364 | if ( ! phoneS.isEmpty()) | ||
365 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); | ||
366 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); | ||
367 | if ( ! phoneS.isEmpty()) | ||
368 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); | ||
369 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); | ||
370 | if ( ! phoneS.isEmpty()) | ||
371 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); | ||
372 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); | ||
373 | if ( ! phoneS.isEmpty()) | ||
374 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); | ||
375 | |||
376 | bool preferred = true; | ||
377 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); | ||
378 | if ( ! phoneS.isEmpty()) { | ||
379 | addressee.insertEmail(phoneS , preferred ); | ||
380 | preferred = false; | ||
381 | } | ||
382 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); | ||
383 | if ( ! phoneS.isEmpty()) { | ||
384 | addressee.insertEmail(phoneS , preferred ); | ||
385 | preferred = false; | ||
386 | } | ||
387 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); | ||
388 | if ( ! phoneS.isEmpty()) { | ||
389 | addressee.insertEmail(phoneS , preferred ); | ||
390 | preferred = false; | ||
391 | } | ||
392 | // is this the number of the preferred email? | ||
393 | //long GetSelectedMailingAddress();??? | ||
394 | |||
395 | KABC::Address addressHome; | ||
396 | KABC::Address* addressAdd = &addressHome; | ||
397 | bool insert = false; | ||
398 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); | ||
399 | if ( ! phoneS.isEmpty()) { | ||
400 | addressAdd->setCountry(phoneS ); | ||
401 | insert = true; | ||
402 | } | ||
403 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); | ||
404 | if ( ! phoneS.isEmpty()) { | ||
405 | addressAdd->setRegion(phoneS ); | ||
406 | insert = true; | ||
407 | } | ||
408 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); | ||
409 | if ( ! phoneS.isEmpty()) { | ||
410 | addressAdd->setLocality(phoneS ); | ||
411 | insert = true; | ||
412 | } | ||
413 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); | ||
414 | if ( ! phoneS.isEmpty()) { | ||
415 | addressAdd->setPostalCode(phoneS ); | ||
416 | insert = true; | ||
417 | } | ||
418 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); | ||
419 | if ( ! phoneS.isEmpty()) { | ||
420 | addressAdd->setPostOfficeBox(phoneS ); | ||
421 | insert = true; | ||
422 | } | ||
423 | phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); | ||
424 | if ( ! phoneS.isEmpty()) { | ||
425 | addressAdd->setStreet(phoneS ); | ||
426 | insert = true; | ||
427 | } | ||
428 | phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); | ||
429 | if ( ! phoneS.isEmpty()) { | ||
430 | // redundant !addressAdd->setExtended(phoneS ); | ||
431 | // insert = true; | ||
432 | } | ||
433 | addressAdd->setType( KABC::Address::Home ); | ||
434 | if ( insert ) | ||
435 | addressee.insertAddress( *addressAdd ); | ||
436 | // ++++++++++++++++++++++ end of address | ||
437 | |||
438 | KABC::Address addressWork; | ||
439 | addressAdd = &addressWork; | ||
440 | insert = false; | ||
441 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); | ||
442 | if ( ! phoneS.isEmpty()) { | ||
443 | addressAdd->setCountry(phoneS ); | ||
444 | insert = true; | ||
445 | } | ||
446 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); | ||
447 | if ( ! phoneS.isEmpty()) { | ||
448 | addressAdd->setRegion(phoneS ); | ||
449 | insert = true; | ||
450 | } | ||
451 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); | ||
452 | if ( ! phoneS.isEmpty()) { | ||
453 | addressAdd->setLocality(phoneS ); | ||
454 | insert = true; | ||
455 | } | ||
456 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); | ||
457 | if ( ! phoneS.isEmpty()) { | ||
458 | addressAdd->setPostalCode(phoneS ); | ||
459 | insert = true; | ||
460 | } | ||
461 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); | ||
462 | if ( ! phoneS.isEmpty()) { | ||
463 | addressAdd->setPostOfficeBox(phoneS ); | ||
464 | insert = true; | ||
465 | } | ||
466 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); | ||
467 | if ( ! phoneS.isEmpty()) { | ||
468 | addressAdd->setStreet(phoneS ); | ||
469 | insert = true; | ||
470 | } | ||
471 | phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); | ||
472 | if ( ! phoneS.isEmpty()) { | ||
473 | // redundant !addressAdd->setExtended(phoneS ); | ||
474 | // insert = true; | ||
475 | } | ||
476 | addressAdd->setType( KABC::Address::Work ); | ||
477 | if ( insert ) | ||
478 | addressee.insertAddress( *addressAdd ); | ||
479 | // ++++++++++++++++++++++ end of address | ||
480 | |||
481 | KABC::Address addressOther; | ||
482 | addressAdd = &addressOther; | ||
483 | insert = false; | ||
484 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); | ||
485 | if ( ! phoneS.isEmpty()) { | ||
486 | addressAdd->setCountry(phoneS ); | ||
487 | insert = true; | ||
488 | } | ||
489 | phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); | ||
490 | if ( ! phoneS.isEmpty()) { | ||
491 | addressAdd->setRegion(phoneS ); | ||
492 | insert = true; | ||
493 | } | ||
494 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); | ||
495 | if ( ! phoneS.isEmpty()) { | ||
496 | addressAdd->setLocality(phoneS ); | ||
497 | insert = true; | ||
498 | } | ||
499 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); | ||
500 | if ( ! phoneS.isEmpty()) { | ||
501 | addressAdd->setPostalCode(phoneS ); | ||
502 | insert = true; | ||
503 | } | ||
504 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); | ||
505 | if ( ! phoneS.isEmpty()) { | ||
506 | addressAdd->setPostOfficeBox(phoneS ); | ||
507 | insert = true; | ||
508 | } | ||
509 | phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); | ||
510 | if ( ! phoneS.isEmpty()) { | ||
511 | addressAdd->setStreet(phoneS ); | ||
512 | insert = true; | ||
513 | } | ||
514 | phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); | ||
515 | if ( ! phoneS.isEmpty()) { | ||
516 | // redundant !addressAdd->setExtended(phoneS ); | ||
517 | //insert = true; | ||
518 | } | ||
519 | //addressAdd->setId( ); | ||
520 | if ( insert ) | ||
521 | addressee.insertAddress( *addressAdd ); | ||
522 | // ++++++++++++++++++++++ end of address | ||
523 | KABC::Address addressMail; | ||
524 | addressAdd = &addressMail; | ||
525 | insert = false; | ||
526 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); | ||
527 | if ( ! phoneS.isEmpty()) { | ||
528 | addressAdd->setCountry(phoneS ); | ||
529 | insert = true; | ||
530 | } | ||
531 | phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); | ||
532 | if ( ! phoneS.isEmpty()) { | ||
533 | addressAdd->setRegion(phoneS ); | ||
534 | insert = true; | ||
535 | } | ||
536 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); | ||
537 | if ( ! phoneS.isEmpty()) { | ||
538 | addressAdd->setLocality(phoneS ); | ||
539 | insert = true; | ||
540 | } | ||
541 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); | ||
542 | if ( ! phoneS.isEmpty()) { | ||
543 | addressAdd->setPostalCode(phoneS ); | ||
544 | insert = true; | ||
545 | } | ||
546 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); | ||
547 | if ( ! phoneS.isEmpty()) { | ||
548 | addressAdd->setPostOfficeBox(phoneS ); | ||
549 | insert = true; | ||
550 | } | ||
551 | phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); | ||
552 | if ( ! phoneS.isEmpty()) { | ||
553 | addressAdd->setStreet(phoneS ); | ||
554 | insert = true; | ||
555 | } | ||
556 | phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); | ||
557 | if ( ! phoneS.isEmpty()) { | ||
558 | // redundant ! addressAdd->setExtended(phoneS ); | ||
559 | // insert = true; | ||
560 | } | ||
561 | addressAdd->setType( KABC::Address::Postal ); | ||
562 | if ( insert ) { | ||
563 | addressee.insertAddress( *addressAdd ); | ||
564 | } | ||
565 | // the following code is disabled | ||
566 | // it does not seem to be useful | ||
567 | #if 0 | ||
568 | if ( insert ) { | ||
569 | addressAdd->setType( KABC::Address::Home ); | ||
570 | if ( addressMail == addressHome ) { | ||
571 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); | ||
572 | addressee.insertAddress( addressHome ); | ||
573 | } else { | ||
574 | addressAdd->setType( KABC::Address::Work ); | ||
575 | if ( addressMail == addressWork ){ | ||
576 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); | ||
577 | addressee.insertAddress( addressWork ); | ||
578 | |||
579 | } else { | ||
580 | addressAdd->setType( 0 ); | ||
581 | if ( addressOther == addressMail ){ | ||
582 | addressOther.setType( KABC::Address::Postal ); | ||
583 | addressee.insertAddress( addressOther ); | ||
584 | } else { | ||
585 | addressee.insertAddress( *addressAdd ); | ||
586 | } | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | #endif | ||
591 | // ++++++++++++++++++++++ end of ALL addresses | ||
592 | //GetUserProperties(); | ||
593 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); | ||
594 | if ( !tempS.isEmpty() ) | ||
595 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); | ||
596 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); | ||
597 | if ( !tempS.isEmpty() ) | ||
598 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); | ||
599 | int gen = aItem->GetGender(); | ||
600 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male | ||
601 | if ( gen == 1 ) | ||
602 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); | ||
603 | else | ||
604 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); | ||
605 | } | ||
606 | |||
607 | #if 0 | ||
608 | // pending | ||
609 | - IM address: no clue where to get info about the helper ID | ||
610 | -custom fields: difficult to implement - not implemented | ||
611 | -keys: makes no sense | ||
612 | #endif | ||
613 | |||
614 | if ( addAddressee( addressee )) | ||
615 | ++importedItems; | ||
616 | } | ||
617 | void KAImportOLdialog::slotCancel() | ||
618 | { | ||
619 | reject(); | ||
620 | } | ||
621 | |||
622 | bool KAImportOLdialog::addAddressee( KABC::Addressee a ) | ||
623 | { | ||
624 | bool add = true; | ||
625 | KABC::Addressee::List::Iterator it; | ||
626 | for ( it = mAList.begin(); it != mAList.end(); ++it ) { | ||
627 | if ( (*it).uid() == a.uid() ) { | ||
628 | add = false; | ||
629 | break; | ||
630 | } | ||
631 | } | ||
632 | if ( add ) | ||
633 | mAList.append ( a ); | ||
634 | return add; | ||
635 | } | ||
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h new file mode 100644 index 0000000..41ea5f8 --- a/dev/null +++ b/kaddressbook/kaimportoldialog.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | #ifndef KOINCIDENCEEDITOR_H | ||
24 | #define KOINCIDENCEEDITOR_H | ||
25 | |||
26 | #include <kdialogbase.h> | ||
27 | |||
28 | #include <afxdisp.h> | ||
29 | |||
30 | #include <kabc/addressee.h> | ||
31 | #include <kabc/addressbook.h> | ||
32 | |||
33 | class QDateTime; | ||
34 | class QListView; | ||
35 | class OLEListViewItem; | ||
36 | class _ContactItem; | ||
37 | |||
38 | |||
39 | //using namespace KABC; | ||
40 | //class KABC::AddressBook; | ||
41 | |||
42 | /** | ||
43 | This is the base class for the calendar component editors. | ||
44 | */ | ||
45 | class KAImportOLdialog : public KDialogBase | ||
46 | { | ||
47 | Q_OBJECT | ||
48 | public: | ||
49 | /** | ||
50 | Construct new IncidenceEditor. | ||
51 | */ | ||
52 | KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, | ||
53 | QWidget *parent ); | ||
54 | ~KAImportOLdialog(); | ||
55 | |||
56 | /** Initialize editor. This function creates the tab widgets. */ | ||
57 | void init(); | ||
58 | KABC::Addressee::List getAddressList(); | ||
59 | public slots: | ||
60 | |||
61 | |||
62 | signals: | ||
63 | |||
64 | protected slots: | ||
65 | void slotApply(); | ||
66 | void slotOk(); | ||
67 | void slotCancel(); | ||
68 | |||
69 | protected: | ||
70 | void setupFolderView(); | ||
71 | void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent); | ||
72 | void readContactData( DWORD folder ); | ||
73 | void ol2kapiContact( _ContactItem * ); | ||
74 | |||
75 | KABC::AddressBook * mABook; | ||
76 | QListView * mListView; | ||
77 | KABC::Addressee::List mAList; | ||
78 | bool addAddressee( KABC::Addressee a ); | ||
79 | private: | ||
80 | int importedItems; | ||
81 | }; | ||
82 | |||
83 | #endif | ||
84 | |||
85 | |||