summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-12 10:03:12 (UTC)
committer zautrix <zautrix>2004-07-12 10:03:12 (UTC)
commita55fa40fa32b115c7f7803fb6af0da5184cd7dff (patch) (side-by-side diff)
treed55eec53c51f3bef866b67dedd5e8508c4d8579e
parent2aeb681a7e8a0696608485f36d9c0561ba505c5c (diff)
downloadkdepimpi-a55fa40fa32b115c7f7803fb6af0da5184cd7dff.zip
kdepimpi-a55fa40fa32b115c7f7803fb6af0da5184cd7dff.tar.gz
kdepimpi-a55fa40fa32b115c7f7803fb6af0da5184cd7dff.tar.bz2
Added importing from OL to KA/Pi
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp26
-rw-r--r--kaddressbook/kabcore.h3
-rw-r--r--kaddressbook/kaddressbook.pro11
-rw-r--r--kaddressbook/kaimportoldialog.cpp635
-rw-r--r--kaddressbook/kaimportoldialog.h85
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
@@ -81,116 +81,123 @@
//US#include <qpe/resource.h> // needed for Resource::loadPixmap
//#include <qlabel.h>
#endif // KAB_EMBEDDED
#include <kcmkabconfig.h>
#include <kresources/selectdialog.h>
#include <kmessagebox.h>
#include <picture.h>
#include <resource.h>
//US#include <qsplitter.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qclipboard.h>
#include <libkdepim/categoryselectdialog.h>
#include "addresseeutil.h"
#include "undocmds.h"
#include "addresseeeditordialog.h"
#include "viewmanager.h"
#include "details/detailsviewcontainer.h"
#include "kabprefs.h"
#include "xxportmanager.h"
#include "incsearchwidget.h"
#include "jumpbuttonbar.h"
#include "extensionmanager.h"
#include "addresseeconfig.h"
#include <kcmultidialog.h>
+#ifdef _WIN32_
+
+#include "kaimportoldialog.h"
+#endif
+
#ifdef KAB_EMBEDDED
KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
: QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
#else //KAB_EMBEDDED
KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
: QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
mReadWrite( readWrite ), mModified( false )
#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" );
mAddressBook = KABC::StdAddressBook::self();
KABC::StdAddressBook::setAutomaticSave( false );
#ifndef KAB_EMBEDDED
mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
#endif //KAB_EMBEDDED
connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
SLOT( addressBookChanged() ) );
mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
"X-Department", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
"X-Profession", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
"X-AssistantsName", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
"X-ManagersName", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
"X-SpousesName", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
"X-Office", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
"X-IMAddress", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
"X-Anniversary", "KADDRESSBOOK" );
//US added this field to become compatible with Opie addressbook
mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
"X-Gender", "KADDRESSBOOK" );
mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
"X-Children", "KADDRESSBOOK" );
+ mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
+ "X-FreeBusyUrl", "KADDRESSBOOK" );
initGUI();
mIncSearchWidget->setFocus();
connect( mViewManager, SIGNAL( selected( const QString& ) ),
SLOT( setContactSelected( const QString& ) ) );
connect( mViewManager, SIGNAL( executed( const QString& ) ),
SLOT( editContact( const QString& ) ) );
connect( mViewManager, SIGNAL( deleteRequest( ) ),
SLOT( deleteContacts( ) ) );
connect( mViewManager, SIGNAL( modified() ),
SLOT( setModified() ) );
connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
connect( mXXPortManager, SIGNAL( modified() ),
SLOT( setModified() ) );
connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
mJumpButtonBar, SLOT( recreateButtons() ) );
#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& ) ),
@@ -812,64 +819,75 @@ void KABCore::addEmail( QString aStr )
// Try to lookup the addressee matching the email address
bool found = false;
QStringList emailList;
KABC::AddressBook::Iterator it;
for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
emailList = (*it).emails();
if ( emailList.contains( email ) > 0 ) {
found = true;
(*it).setNameFromString( fullName );
editContact( (*it).uid() );
}
}
if ( !found ) {
KABC::Addressee addr;
addr.setNameFromString( fullName );
addr.insertEmail( email, true );
mAddressBook->insertAddressee( addr );
mViewManager->refreshView( addr.uid() );
editContact( addr.uid() );
}
#else //KAB_EMBEDDED
qDebug("KABCore::addEmail finsih method");
#endif //KAB_EMBEDDED
}
void KABCore::importVCard( const KURL &url, bool showPreview )
{
mXXPortManager->importVCard( url, showPreview );
}
+void KABCore::importFromOL()
+{
+#ifdef _WIN32_
+ KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
+ idgl->exec();
+ KABC::Addressee::List list = idgl->getAddressList();
+ if ( list.count() > 0 )
+ pasteContacts( list );
+ delete idgl;
+#endif
+}
void KABCore::importVCard( const QString &vCard, bool showPreview )
{
mXXPortManager->importVCard( vCard, showPreview );
}
//US added a second method without defaultparameter
void KABCore::editContact2() {
editContact( QString::null );
}
void KABCore::editContact( const QString &uid )
{
if ( mExtensionManager->isQuickEditVisible() )
return;
// First, locate the contact entry
QString localUID = uid;
if ( localUID.isNull() ) {
QStringList uidList = mViewManager->selectedUids();
if ( uidList.count() > 0 )
localUID = *( uidList.at( 0 ) );
}
KABC::Addressee addr = mAddressBook->findByUid( localUID );
if ( !addr.isEmpty() ) {
mEditorDialog->setAddressee( addr );
KApplication::execDialog ( mEditorDialog );
}
}
@@ -1368,64 +1386,67 @@ void KABCore::initActions()
mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
actionCollection(), "options_show_jump_bar" );
connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0,
actionCollection(), "options_show_details" );
connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
// misc
// only enable LDAP lookup if we can handle the protocol
#ifndef KAB_EMBEDDED
if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
this, SLOT( openLDAPDialog() ), actionCollection(),
"ldap_lookup" );
}
#else //KAB_EMBEDDED
//qDebug("KABCore::initActions() LDAP has to be implemented");
#endif //KAB_EMBEDDED
mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
SLOT( setWhoAmI() ), actionCollection(),
"set_personal" );
mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
SLOT( setCategories() ), actionCollection(),
"edit_set_categories" );
mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
SLOT( removeVoice() ), actionCollection(),
"remove_voice" );
+ mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
+ SLOT( importFromOL() ), actionCollection(),
+ "import_OL" );
#ifdef KAB_EMBEDDED
mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
this, SLOT( createAboutData() ), actionCollection(),
"kaddressbook_about_data" );
#endif //KAB_EMBEDDED
clipboardDataChanged();
connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
}
//US we need this function, to plug all actions into the correct menues.
// KDE uses a XML format to plug the actions, but we work her without this overhead.
void KABCore::addActionsManually()
{
//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
#ifdef KAB_EMBEDDED
QPopupMenu *fileMenu = new QPopupMenu( this );
QPopupMenu *editMenu = new QPopupMenu( this );
QPopupMenu *helpMenu = new QPopupMenu( this );
KToolBar* tb = mMainWindow->toolBar();
#ifdef DESKTOP_VERSION
QMenuBar* mb = mMainWindow->menuBar();
//US setup menubar.
//Disable the following block if you do not want to have a menubar.
mb->insertItem( "&File", fileMenu );
mb->insertItem( "&Edit", editMenu );
@@ -1448,66 +1469,67 @@ void KABCore::addActionsManually()
popupBarTB->insertItem( "&File", fileMenu );
popupBarTB->insertItem( "&Edit", editMenu );
popupBarTB->insertItem( "&View", viewMenu );
popupBarTB->insertItem( "&Settings", settingsMenu );
mViewManager->getFilterAction()->plug ( popupBarTB);
popupBarTB->insertItem( "&Change selected", changeMenu );
popupBarTB->insertItem( "&Help", helpMenu );
if (QApplication::desktop()->width() > 320 ) {
// mViewManager->getFilterAction()->plug ( tb);
}
#endif
// mActionQuit->plug ( mMainWindow->toolBar());
//US Now connect the actions with the menue entries.
mActionPrint->plug( fileMenu );
mActionMail->plug( fileMenu );
fileMenu->insertSeparator();
mActionNewContact->plug( fileMenu );
mActionNewContact->plug( tb );
mActionEditAddressee->plug( fileMenu );
fileMenu->insertSeparator();
mActionSave->plug( fileMenu );
fileMenu->insertItem( "&Import", ImportMenu );
fileMenu->insertItem( "&Emport", ExportMenu );
fileMenu->insertSeparator();
mActionMailVCard->plug( fileMenu );
fileMenu->insertSeparator();
mActionQuit->plug( fileMenu );
-
-
+#ifdef _WIN32_
+ mActionImportOL->plug( ImportMenu );
+#endif
// edit menu
mActionUndo->plug( editMenu );
mActionRedo->plug( editMenu );
editMenu->insertSeparator();
mActionCut->plug( editMenu );
mActionCopy->plug( editMenu );
mActionPaste->plug( editMenu );
mActionDelete->plug( editMenu );
editMenu->insertSeparator();
mActionSelectAll->plug( editMenu );
mActionRemoveVoice->plug( changeMenu );
// settings menu
//US special menuentry to configure the addressbook resources. On KDE
// you do that through the control center !!!
mActionConfigResources->plug( settingsMenu );
settingsMenu->insertSeparator();
mActionConfigKAddressbook->plug( settingsMenu );
if ( mIsPart ) {
mActionConfigShortcuts->plug( settingsMenu );
mActionConfigureToolbars->plug( settingsMenu );
} else {
mActionKeyBindings->plug( settingsMenu );
}
settingsMenu->insertSeparator();
mActionJumpBar->plug( settingsMenu );
mActionDetails->plug( settingsMenu );
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 8d6041e..69a98a5 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -289,65 +289,65 @@ class KABCore : public QWidget
//US added a second method without defaultparameter
void editContact2();
/**
Launches the configuration dialog.
*/
void openConfigDialog();
/**
Launches the ldap search dialog.
*/
void openLDAPDialog();
/**
Creates a KAddressBookPrinter, which will display the print
dialog and do the printing.
*/
void print();
/**
Registers a new GUI client, so plugins can register its actions.
*/
void addGUIClient( KXMLGUIClient *client );
signals:
void contactSelected( const QString &name );
void contactSelected( const QPixmap &pixmap );
public slots:
void setDetailsVisible( bool visible );
void setDetailsToState();
private slots:
void setJumpButtonBarVisible( bool visible );
-
+ void importFromOL();
void extensionModified( const KABC::Addressee::List &list );
void clipboardDataChanged();
void updateActionMenu();
void configureKeyBindings();
void removeVoice();
#ifdef KAB_EMBEDDED
void configureResources();
#endif //KAB_EMBEDDED
void slotEditorDestroyed( const QString &uid );
void configurationChanged();
void addressBookChanged();
private:
void initGUI();
void initActions();
AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
const char *name = 0 );
KXMLGUIClient *mGUIClient;
KABC::AddressBook *mAddressBook;
ViewManager *mViewManager;
// QSplitter *mDetailsSplitter;
KDGanttMinimizeSplitter *mExtensionBarSplitter;
ViewContainer *mDetails;
KDGanttMinimizeSplitter* mMiniSplitter;
XXPortManager *mXXPortManager;
JumpButtonBar *mJumpButtonBar;
IncSearchWidget *mIncSearchWidget;
@@ -379,47 +379,48 @@ class KABCore : public QWidget
KAction *mActionCopy;
KAction *mActionCut;
KAction *mActionPaste;
KAction *mActionSelectAll;
KAction *mActionUndo;
KAction *mActionRedo;
KAction *mActionDelete;
//US settings menu
KAction *mActionConfigResources;
KAction *mActionConfigKAddressbook;
KAction *mActionConfigShortcuts;
KAction *mActionConfigureToolbars;
KAction *mActionKeyBindings;
KToggleAction *mActionJumpBar;
KToggleAction *mActionDetails;
KAction *mActionWhoAmI;
KAction *mActionCategories;
KAction *mActionAboutKAddressbook;
KAction *mActionDeleteView;
QPopupMenu *viewMenu;
QPopupMenu *filterMenu;
QPopupMenu *settingsMenu;
QPopupMenu *changeMenu;
//US QAction *mActionSave;
QPopupMenu *ImportMenu;
QPopupMenu *ExportMenu;
//LR additional methods
KAction *mActionRemoveVoice;
+ KAction * mActionImportOL;
#ifndef KAB_EMBEDDED
KAddressBookService *mAddressBookService;
#endif //KAB_EMBEDDED
class KABCorePrivate;
KABCorePrivate *d;
#ifdef KAB_EMBEDDED
KAddressBookMain *mMainWindow; // should be the same like mGUIClient
#endif //KAB_EMBEDDED
};
#endif
diff --git a/kaddressbook/kaddressbook.pro b/kaddressbook/kaddressbook.pro
index 761c3e7..bc14e68 100644
--- a/kaddressbook/kaddressbook.pro
+++ b/kaddressbook/kaddressbook.pro
@@ -1,61 +1,62 @@
TEMPLATE = app
CONFIG = qt warn_on
TARGET = kapi
DESTDIR= ../bin
include( ../variables.pri )
INCLUDEPATH += . ./details ./features ./kcmconfigs ./xxport ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kdeui ../kabc ../ interfaces
DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION
unix : {
LIBS += ../bin/libmicrokdepim.so
LIBS += ../bin/libmicrokde.so
LIBS += ../bin/libmicrokabc.so
LIBS += ../bin/libmicrokcal.so
LIBS += -lldap
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
DEFINES += _WIN32_
LIBS += ../bin/microkdepim.lib
LIBS += ../bin/microkcal.lib
LIBS += ../bin/microkde.lib
LIBS += ../bin/microkabc.lib
QMAKE_LINK += /NODEFAULTLIB:LIBC
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
+LIBS += mfc71u.lib
}
INTERFACES = \
# filteredit_base.ui \
# kofilterview_base.ui \
HEADERS = \
features/mergewidget.h \
features/distributionlistwidget.h \
kcmconfigs/addresseewidget.h \
kcmconfigs/extensionconfigdialog.h \
kcmconfigs/kcmkabconfig.h \
kcmconfigs/kabconfigwidget.h \
addresseeeditordialog.h \
addresseeeditorwidget.h \
addresseditwidget.h \
addresseeconfig.h \
addresseeutil.h \
emaileditwidget.h \
filtereditdialog.h \
kaddressbookmain.h \
kabprefs.h \
kabcore.h \
viewmanager.h \
extensionmanager.h \
@@ -135,32 +136,42 @@ keywidget.cpp \
nameeditdialog.cpp \
filter.cpp \
addviewdialog.cpp \
configurewidget.cpp \
viewconfigurewidget.cpp \
viewconfigurefieldspage.cpp \
viewconfigurefilterpage.cpp \
undo.cpp \
undocmds.cpp \
xxportmanager.cpp \
xxportobject.cpp \
xxportselectdialog.cpp \
details/detailsviewcontainer.cpp \
details/look_basic.cpp \
details/look_html.cpp \
views/kaddressbookiconview.cpp \
views/kaddressbooktableview.cpp \
views/kaddressbookcardview.cpp \
views/configuretableviewdialog.cpp \
views/configurecardviewdialog.cpp \
views/cardview.cpp \
views/contactlistview.cpp \
views/colorlistbox.cpp \
xxport/vcard_xxport.cpp \
xxport/kde2_xxport.cpp \
xxport/csv_xxport.cpp \
xxport/csvimportdialog.cpp \
#details/look_details.cpp \
#mainwindow.cpp \
# calendarview.cpp \
# timespanview.cpp
+
+
+win32: {
+HEADERS += ../outport/msoutl9.h \
+ kaimportoldialog.h
+
+SOURCES += ../outport/msoutl9.cpp \
+ kaimportoldialog.cpp
+}
+
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 @@
+/*
+ This file is part of KAddressbook/Pi.
+ Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qtooltip.h>
+#include <qframe.h>
+#include <qpixmap.h>
+#include <qlayout.h>
+#include <qprogressbar.h>
+#include <qwidgetstack.h>
+#include <qdatetime.h>
+#include <qdir.h>
+#include <qapplication.h>
+#include <qhbox.h>
+#include <qheader.h>
+#include <qdatetime.h>
+#include <qlistview.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kmessagebox.h>
+#include <kfiledialog.h>
+
+#include <libkdepim/categoryselectdialog.h>
+#include <libkdepim/kinputdialog.h>
+
+#include <libkcal/calendarlocal.h>
+#include <libkcal/icalformat.h>
+
+#include <kabc/addresseelist.h>
+#include <kabc/phonenumber.h>
+
+#include "kaimportoldialog.h"
+
+#include "../outport/msoutl9.h"
+#include <ole2.h>
+#include <comutil.h>
+_Application gOlAppAB;
+
+QDateTime mDdate2Qdtr( DATE dt)
+{
+ COleDateTime odt;
+ SYSTEMTIME st;
+ odt = dt;
+ if ( odt.GetStatus() != 0 )
+ return QDateTime();
+ odt.GetAsSystemTime(st);
+ if ( st.wYear > 4000 ) // this program as a year 4000 bug!
+ return QDateTime();
+ // it seems so, that 1.1.4501 indicates: DATE invalid
+ QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
+ return qdt;
+}
+
+class OLEListViewItem : public QCheckListItem
+{
+ public:
+ OLEListViewItem( QListView *parent, QString text ) :
+ QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
+ OLEListViewItem( QListViewItem *after, QString text ) :
+ QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
+ ~OLEListViewItem() {};
+ void setData( DWORD data ) {mData= data; };
+ DWORD data() { return mData ;};
+ private:
+ DWORD mData;
+};
+
+KAImportOLdialog::KAImportOLdialog( const QString &caption,
+ KABC::AddressBook * aBook, QWidget *parent ) :
+ KDialogBase( Plain, caption, User1 | Close, Ok,
+ parent, caption, true, false, i18n("Import!") )
+{
+ QHBox * mw = new QHBox( this );
+ setMainWidget( mw );
+ mListView = new QListView( mw );
+ mListView->addColumn(i18n("Select Folder to import"));
+ mListView->addColumn(i18n("Content Type"));
+ mABook = aBook;
+ connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
+ setupFolderView();
+ resize( sizeHint().width()+50, sizeHint().height()+50 );
+}
+
+KAImportOLdialog::~KAImportOLdialog()
+{
+
+}
+
+KABC::Addressee::List KAImportOLdialog::getAddressList()
+{
+ return mAList;
+}
+void KAImportOLdialog::setupFolderView()
+{
+ SCODE sc = ::OleInitialize(NULL);
+ if ( FAILED ( sc ) ) {
+ KMessageBox::information(this,"OLE initialisation failed");
+ return;
+ }
+
+ if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
+ KMessageBox::information(this,"Sorry, cannot access Outlook");
+ return ;
+ }
+ MAPIFolder mfInbox;
+ MAPIFolder mfRoot;
+ CString szName;
+ _NameSpace olNS;
+ olNS = gOlAppAB.GetNamespace(_T("MAPI"));
+ mfInbox = olNS.GetDefaultFolder(6);
+ mfRoot = mfInbox.GetParent();
+ szName = mfRoot.GetName();
+ long iType = mfRoot.GetDefaultItemType();
+ QString mes;
+ mes = QString::fromUcs2( szName.GetBuffer() );
+ OLEListViewItem * root = new OLEListViewItem( mListView, mes );
+ mfRoot.m_lpDispatch->AddRef();
+ addFolder( root, mfRoot.m_lpDispatch );
+ root->setOpen( true );
+ mListView->setSortColumn( 0 );
+ mListView->sort( );
+}
+
+
+void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
+{
+ MAPIFolder mfParent(dispParent), mfChild;
+ _Folders folders;
+ _variant_t fndx((long)0);
+ CString szName;
+ long iType;
+ OLEListViewItem* hChild;
+
+ folders = mfParent.GetFolders();
+ for(int i=1; i <= folders.GetCount(); ++i)
+ {
+ fndx = (long)i;
+ mfChild = folders.Item(fndx.Detach());
+ mfChild.m_lpDispatch->AddRef();
+ szName = mfChild.GetName();
+ iType = mfChild.GetDefaultItemType();
+ hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
+ if ( iType != 2)
+ hChild->setEnabled( false );
+ QString ts;
+ switch( iType ) {
+ case 0:
+ ts = i18n("Mail");
+ break;
+ case 1:
+ ts = i18n("Calendar");
+ break;
+ case 2:
+ ts = i18n("Contacts");
+ break;
+ case 3:
+ ts = i18n("Todos");
+ break;
+ case 4:
+ ts = i18n("Journals");
+ break;
+ case 5:
+ ts = i18n("Notes");
+ break;
+ default:
+ ts = i18n("Unknown");
+ }
+ hChild->setText( 1,ts);
+ hChild->setData( (DWORD) mfChild.m_lpDispatch );
+ mfChild.m_lpDispatch->AddRef();
+ addFolder(hChild, mfChild.m_lpDispatch);
+ }
+}
+
+void KAImportOLdialog::slotApply()
+{
+ importedItems = 0;
+ OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
+ while ( child ) {
+ if ( child->isOn() )
+ readContactData( child->data() );
+ child = (OLEListViewItem*) child->itemBelow();
+ }
+ QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
+ KMessageBox::information(this,mes);
+}
+void KAImportOLdialog::readContactData( DWORD folder )
+{
+
+ LPDISPATCH dispItem = (LPDISPATCH)folder;
+ dispItem->AddRef();
+ MAPIFolder mf(dispItem);
+ mf.m_lpDispatch->AddRef();
+ _Items folderItems;
+ _variant_t indx((long)0);
+ LPDISPATCH itm;
+ int i;
+ folderItems = mf.GetItems();
+ QProgressBar bar( folderItems.GetCount(),0 );
+ bar.setCaption (i18n("Importing - close to abort!") );
+ int h = bar.sizeHint().height() ;
+ int w = 300;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ bar.show();
+ for(i=1; i <= folderItems.GetCount(); ++i)
+ {
+ qApp->processEvents();
+ if ( ! bar.isVisible() )
+ return ;
+ bar.setProgress( i );
+ indx = (long)i;
+ itm = folderItems.Item(indx.Detach());
+ _ContactItem * pItem = (_ContactItem *)&itm;
+ ol2kapiContact( pItem );
+ itm->Release();
+ }
+}
+void KAImportOLdialog::slotOk()
+{
+ QDialog::accept();
+}
+
+void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
+{
+ KABC::Addressee addressee;
+
+ addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
+
+ //addressee.setName( const QString &name );
+ //addressee.setFormattedName( const QString &formattedName );
+ addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
+ addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
+ addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
+ addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
+ addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
+ addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
+ QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
+ if ( dtb.isValid() )
+ addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
+
+ //QString::fromUcs2(aItem->.GetBuffer())
+ //addressee.setMailer( const QString &mailer );
+ //addressee.setTimeZone( const TimeZone &timeZone );
+ //addressee.setGeo( const Geo &geo );
+ //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
+ addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
+ addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) );
+ addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) );
+
+ addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
+ //addressee.setRevision( const QDateTime &revision );
+ // addressee.setSortString( const QString &sortString );
+ addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
+
+ QString tempS;
+ tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
+ if ( tempS.length() > 12 )
+ addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
+ tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
+ tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
+ tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
+ tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
+ tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
+ tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
+ dtb = mDdate2Qdtr(aItem->GetAnniversary());
+ if (dtb.isValid() ) {
+ QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
+ addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
+ }
+ int sec = aItem->GetSensitivity() ;
+ if ( sec > 1 )// mapping pers -> private
+ --sec;
+ addressee.setSecrecy( sec );
+ //addressee.setLogo( const Picture &logo );
+ //addressee.setPhoto( const Picture &photo );
+ //addressee.setSound( const Sound &sound );
+ //addressee.setAgent( const Agent &agent );
+ QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer());
+ addressee.setCategories( QStringList::split( ";", cat ));
+
+ QString phoneS;
+
+ phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) );
+ phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
+ phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
+ phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) );
+ phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) );
+ phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
+ phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
+ phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) );
+ phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) );
+ phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) );
+ phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) );
+ phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) );
+ phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) );
+ phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) );
+ phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) );
+ phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) );
+ phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) );
+ phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) );
+ phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
+ if ( ! phoneS.isEmpty())
+ addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) );
+
+ bool preferred = true;
+ phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressee.insertEmail(phoneS , preferred );
+ preferred = false;
+ }
+ phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressee.insertEmail(phoneS , preferred );
+ preferred = false;
+ }
+ phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressee.insertEmail(phoneS , preferred );
+ preferred = false;
+ }
+ // is this the number of the preferred email?
+ // long GetSelectedMailingAddress();???
+
+ KABC::Address addressHome;
+ KABC::Address* addressAdd = &addressHome;
+ bool insert = false;
+ phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setCountry(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setRegion(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setLocality(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostalCode(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostOfficeBox(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setStreet(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ // redundant !addressAdd->setExtended(phoneS );
+ // insert = true;
+ }
+ addressAdd->setType( KABC::Address::Home );
+ if ( insert )
+ addressee.insertAddress( *addressAdd );
+ // ++++++++++++++++++++++ end of address
+
+ KABC::Address addressWork;
+ addressAdd = &addressWork;
+ insert = false;
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setCountry(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setRegion(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setLocality(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostalCode(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostOfficeBox(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setStreet(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ // redundant !addressAdd->setExtended(phoneS );
+ // insert = true;
+ }
+ addressAdd->setType( KABC::Address::Work );
+ if ( insert )
+ addressee.insertAddress( *addressAdd );
+ // ++++++++++++++++++++++ end of address
+
+ KABC::Address addressOther;
+ addressAdd = &addressOther;
+ insert = false;
+ phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setCountry(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setRegion(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setLocality(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostalCode(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostOfficeBox(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setStreet(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ // redundant !addressAdd->setExtended(phoneS );
+ //insert = true;
+ }
+ //addressAdd->setId( );
+ if ( insert )
+ addressee.insertAddress( *addressAdd );
+ // ++++++++++++++++++++++ end of address
+ KABC::Address addressMail;
+ addressAdd = &addressMail;
+ insert = false;
+ phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setCountry(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setRegion(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setLocality(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostalCode(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setPostOfficeBox(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ addressAdd->setStreet(phoneS );
+ insert = true;
+ }
+ phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
+ if ( ! phoneS.isEmpty()) {
+ // redundant ! addressAdd->setExtended(phoneS );
+ // insert = true;
+ }
+ addressAdd->setType( KABC::Address::Postal );
+ if ( insert ) {
+ addressee.insertAddress( *addressAdd );
+ }
+ // the following code is disabled
+ // it does not seem to be useful
+#if 0
+ if ( insert ) {
+ addressAdd->setType( KABC::Address::Home );
+ if ( addressMail == addressHome ) {
+ addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
+ addressee.insertAddress( addressHome );
+ } else {
+ addressAdd->setType( KABC::Address::Work );
+ if ( addressMail == addressWork ){
+ addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
+ addressee.insertAddress( addressWork );
+
+ } else {
+ addressAdd->setType( 0 );
+ if ( addressOther == addressMail ){
+ addressOther.setType( KABC::Address::Postal );
+ addressee.insertAddress( addressOther );
+ } else {
+ addressee.insertAddress( *addressAdd );
+ }
+ }
+ }
+ }
+#endif
+ // ++++++++++++++++++++++ end of ALL addresses
+ //GetUserProperties();
+ tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
+ tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
+ if ( !tempS.isEmpty() )
+ addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
+ int gen = aItem->GetGender();
+ if ( gen != 0 ) { // 0 undef - 1 female - 2 male
+ if ( gen == 1 )
+ addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
+ else
+ addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
+ }
+
+#if 0
+ // pending
+ - IM address: no clue where to get info about the helper ID
+ -custom fields: difficult to implement - not implemented
+ -keys: makes no sense
+#endif
+
+ if ( addAddressee( addressee ))
+ ++importedItems;
+}
+void KAImportOLdialog::slotCancel()
+{
+ reject();
+}
+
+bool KAImportOLdialog::addAddressee( KABC::Addressee a )
+{
+ bool add = true;
+ KABC::Addressee::List::Iterator it;
+ for ( it = mAList.begin(); it != mAList.end(); ++it ) {
+ if ( (*it).uid() == a.uid() ) {
+ add = false;
+ break;
+ }
+ }
+ if ( add )
+ mAList.append ( a );
+ return add;
+}
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 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef KOINCIDENCEEDITOR_H
+#define KOINCIDENCEEDITOR_H
+
+#include <kdialogbase.h>
+
+#include <afxdisp.h>
+
+#include <kabc/addressee.h>
+#include <kabc/addressbook.h>
+
+class QDateTime;
+class QListView;
+class OLEListViewItem;
+class _ContactItem;
+
+
+//using namespace KABC;
+//class KABC::AddressBook;
+
+/**
+ This is the base class for the calendar component editors.
+*/
+class KAImportOLdialog : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ /**
+ Construct new IncidenceEditor.
+ */
+ KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook,
+ QWidget *parent );
+ ~KAImportOLdialog();
+
+ /** Initialize editor. This function creates the tab widgets. */
+ void init();
+ KABC::Addressee::List getAddressList();
+ public slots:
+
+
+ signals:
+
+ protected slots:
+ void slotApply();
+ void slotOk();
+ void slotCancel();
+
+ protected:
+ void setupFolderView();
+ void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
+ void readContactData( DWORD folder );
+ void ol2kapiContact( _ContactItem * );
+
+ KABC::AddressBook * mABook;
+ QListView * mListView;
+ KABC::Addressee::List mAList;
+ bool addAddressee( KABC::Addressee a );
+ private:
+ int importedItems;
+};
+
+#endif
+
+