summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Side-by-side diff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp130
-rw-r--r--kaddressbook/kabcore.h5
-rw-r--r--kaddressbook/kaimportoldialog.cpp712
-rw-r--r--kaddressbook/kaimportoldialog.h63
-rw-r--r--kaddressbook/phoneeditwidget.cpp11
5 files changed, 120 insertions, 801 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7d8586a..ab2824c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -158,6 +158,7 @@ $Id$
#ifdef _WIN32_
#ifdef _OL_IMPORT_
#include "kaimportoldialog.h"
+#include <libkdepim/ol_access.h>
#endif
#else
#include <unistd.h>
@@ -1369,32 +1370,80 @@ void KABCore::importVCard( const KURL &url, bool showPreview )
void KABCore::importFromOL()
{
#ifdef _OL_IMPORT_
- KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
- idgl->exec();
- KABC::Addressee::List list = idgl->getAddressList();
- if ( list.count() > 0 ) {
- KABC::Addressee::List listNew;
- KABC::Addressee::List listExisting;
- KABC::Addressee::List::Iterator it;
- KABC::AddressBook::Iterator iter;
- for ( it = list.begin(); it != list.end(); ++it ) {
- if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
- listNew.append( (*it) );
- else
- listExisting.append( (*it) );
- }
- if ( listExisting.count() > 0 )
- KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
- if ( listNew.count() > 0 ) {
- pasteWithNewUid = false;
- pasteContacts( listNew );
- pasteWithNewUid = true;
+ KABC::Addressee::List list = OL_access::instance()->importOLcontacts();
+ if ( list.count() > 0 ) {
+ KABC::Addressee::List listNew;
+ KABC::Addressee::List listExisting;
+ KABC::Addressee::List::Iterator it;
+ KABC::AddressBook::Iterator iter;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
+ listNew.append( (*it) );
+ else
+ listExisting.append( (*it) );
+ }
+ QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() );
+ if ( listExisting.count() > 0 )
+ mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() );
+
+ KMessageBox::information( this, mess );
+ if ( listNew.count() > 0 ) {
+ pasteWithNewUid = false;
+ pasteContacts( listNew );
+ pasteWithNewUid = true;
+ }
}
- }
- delete idgl;
#endif
}
+bool KABCore::readOLdata( KABC::AddressBook* local )
+{
+#ifdef _OL_IMPORT_
+ QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync"));
+ KABC::Addressee::List list;
+ if ( folderList.count() ) {
+ OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true );
+ KABC::Addressee::List::Iterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ (*it).setExternalUID( (*it).uid() );
+ (*it).setOriginalExternalUID( (*it).uid() );
+ (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
+ local->insertAddressee( (*it) , false, false );
+ }
+ mOLsyncFolderID = folderList[1];
+ //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID );
+ }
+ return list.count() > 0;
+#else
+ return false;
+#endif
+}
+bool KABCore::writeOLdata( KABC::AddressBook* aBook )
+{
+#ifdef _OL_IMPORT_
+ if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) )
+ return false;
+ KABC::AddressBook::Iterator it;
+ for ( it = aBook->begin(); it != aBook->end(); ++it ) {
+ if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
+ KABC::Addressee addressee = (*it);
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
+ (*it) = OL_access::instance()->addAddressee( (*it) );
+ (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
+ OL_access::instance()->deleteAddressee( (*it) );
+ } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
+ //changed
+ (*it) = OL_access::instance()->changeAddressee( (*it) );
+ (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
+ }
+ }
+ }
+ return true;
+#else
+ return false;
+#endif
+}
void KABCore::importVCard( const QString &vCard, bool showPreview )
{
mXXPortManager->importVCard( vCard, showPreview );
@@ -3374,12 +3423,49 @@ void KABCore::removeSyncInfo( QString syncProfile)
setModified();
}
+bool KABCore::syncOL()
+{
+ disableBR( true );
+ QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
+ AddressBook abLocal;
+ if ( ! readOLdata( &abLocal ) )
+ return false;
+ bool syncOK = false;
+ message(i18n("Data from OL loaded..."), false);
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ message(i18n("Sync preprocessing..."),false);
+ abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice );
+ message(i18n("Synchronizing..."),false);
+ syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
+ syncManager->hideProgressBar();
+ if ( syncOK ) {
+ if ( syncManager->mWriteBackFile ) {
+ abLocal.removeSyncAddressees( false );
+ message(i18n("Saving address data to OL..."),false);
+ //abLocal.saveAB();
+ writeOLdata( &abLocal );
+ message(i18n("Sync postprocessing..."),false);
+ abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
+ }
+ } else
+ message( i18n("Sync cancelled or failed.") );
+ setModified();
+ abLocal.removeResources();
+ if ( syncOK ) {
+ mViewManager->refreshView();
+ message(i18n("OL syncing finished."));
+ }
+ disableBR( false );
+ return syncOK;
+}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
if ( resource == "phone" )
return syncPhone();
+ if ( resource == "ol" )
+ return syncOL();
disableBR( true );
if ( manager != syncManager )
qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e69cb60..ec6a9ec 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -515,6 +515,9 @@ class KABCore : public QWidget, public KSyncInterface
virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
virtual bool syncExternal(KSyncManager* manager, QString resource);
virtual void removeSyncInfo( QString syncProfile);
+ bool readOLdata( KABC::AddressBook* local );
+ bool writeOLdata( KABC::AddressBook* local );
+ bool syncOL();
bool syncPhone();
void message( QString m , bool startTimer = true);
@@ -529,6 +532,8 @@ class KABCore : public QWidget, public KSyncInterface
QDateTime mLastAddressbookSync;
int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
// *********************
+ //OL sync stuff
+ QString mOLsyncFolderID;
};
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 2f794d6..6afc288 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -21,715 +21,3 @@
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 <qprogressdialog.h>
-#include <qwidgetstack.h>
-#include <qdatetime.h>
-#include <qdir.h>
-#include <qregexp.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();
- QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this);
- bar.setCaption (i18n("Importing!") );
- 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()));
- //GetLastModificationTime()
- //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()).replace( QRegExp("\\r"), "") );
- QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
- notesStr.replace( QRegExp("\\r"), "");
-
- 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()).replace( QRegExp("\\r"), "");
- 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()).replace( QRegExp("\\r"), "");
- cat = cat.replace( QRegExp("; "), ";");
- 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());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setCountry(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setRegion(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setLocality(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostalCode(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostOfficeBox(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setStreet(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- 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());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setCountry(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setRegion(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setLocality(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostalCode(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostOfficeBox(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setStreet(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- 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());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setCountry(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setRegion(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setLocality(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostalCode(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostOfficeBox(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- 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());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setCountry(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setRegion(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setLocality(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostalCode(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setPostOfficeBox(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! phoneS.isEmpty()) {
- addressAdd->setStreet(phoneS );
- insert = true;
- }
- phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- 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());
- phoneS.replace( QRegExp("\\r"), "");
- 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" );
- }
- QString additionalInfo;
- QString tempAdd;
- tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer());
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nLanguage: ");
- additionalInfo += tempAdd;
- }
- tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nHobby: ");
- additionalInfo += tempAdd;;
- }
- tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nHomepage: ");
- additionalInfo += tempAdd;;
- }
- tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nBilling information: ");
- additionalInfo += tempAdd;;
- }
- tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nCustomer ID: ");
- additionalInfo += tempAdd;;
- }
- tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nUser1: ");
- additionalInfo += tempAdd;;
- }
- tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nUser2: ");
- additionalInfo += tempAdd;;
- }
- tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nUser3: ");
- additionalInfo += tempAdd;;
- }
- tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer());
- phoneS.replace( QRegExp("\\r"), "");
- if ( ! tempAdd.isEmpty() ) {
- additionalInfo += i18n("\nUser4: ");
- additionalInfo += tempAdd;;
- }
- if (!additionalInfo.isEmpty() ) {
- tempAdd = notesStr;
- notesStr = "+++++++++++++++++++++++++++\n";
- notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:");
- notesStr += additionalInfo;
- notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n");
- notesStr += "+++++++++++++++++++++++++++\n";
- notesStr += tempAdd;
- }
- addressee.setNote( notesStr );
-#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 ) {
- if ( mABook->findByUid(a.uid() ).isEmpty())
- mAList.append ( a );
- else
- add = false;
- }
- return add;
-}
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h
index 41ea5f8..278935b 100644
--- a/kaddressbook/kaimportoldialog.h
+++ b/kaddressbook/kaimportoldialog.h
@@ -20,66 +20,3 @@
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
-
-
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 5639aa2..df3b551 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -40,6 +40,7 @@
#include <kapplication.h>
#include <qapplication.h>
#include <kconfig.h>
+#include <kmessagebox.h>
#include <klineedit.h>
#include <kcombobox.h>
#include <klocale.h>
@@ -112,11 +113,13 @@ void PhoneEditWidget::setDefaults()
phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
edit->setPhoneNumber( phoneNumber );
edit = appendEditCombo();
- phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
- edit->setPhoneNumber( phoneNumber );
+ KABC::PhoneNumber phoneNumber2;
+ phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
+ edit->setPhoneNumber( phoneNumber2 );
edit = appendEditCombo();
- phoneNumber.setType( KABC::PhoneNumber::Cell );
- edit->setPhoneNumber( phoneNumber );
+ KABC::PhoneNumber phoneNumber3;
+ phoneNumber3.setType( KABC::PhoneNumber::Cell );
+ edit->setPhoneNumber( phoneNumber3 );
}
void PhoneEditWidget::addNumberInt( int index )