summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2006-02-24 18:49:56 (UTC)
committer zautrix <zautrix>2006-02-24 18:49:56 (UTC)
commitd7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (unidiff)
treed9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9
parent987757f168bbae56100f2aff763b865e81ceec18 (diff)
downloadkdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip
kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz
kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2
kapi sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp22
-rw-r--r--kabc/addressbook.h1
-rw-r--r--kabc/addressee.cpp75
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/phonenumber.cpp24
-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
-rw-r--r--korganizer/journalentry.h1
-rw-r--r--korganizer/kojournalview.cpp9
-rw-r--r--libkdepim/externalapphandler.cpp2
-rw-r--r--libkdepim/ksyncmanager.cpp71
-rw-r--r--libkdepim/ksyncmanager.h3
-rw-r--r--libkdepim/libkdepim.pro15
16 files changed, 337 insertions, 811 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index f9e4387..fe59fcb 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -937,44 +937,62 @@ Addressee AddressBook::findByUid( const QString &uid )
937 return Addressee(); 937 return Addressee();
938} 938}
939void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 939void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
940{ 940{
941 //qDebug("AddressBook::preExternSync "); 941 //qDebug("AddressBook::preExternSync ");
942 AddressBook::Iterator it; 942 AddressBook::Iterator it;
943 for ( it = begin(); it != end(); ++it ) { 943 for ( it = begin(); it != end(); ++it ) {
944 (*it).setID( csd, (*it).externalUID() ); 944 (*it).setID( csd, (*it).externalUID() );
945 (*it).computeCsum( csd ); 945 (*it).computeCsum( csd );
946 } 946 }
947 mergeAB( aBook ,csd, isSubset ); 947 mergeAB( aBook ,csd, isSubset );
948} 948}
949void AddressBook::preOLSync( AddressBook* aBook, const QString& csd )
950{
951 //qDebug("AddressBook::preExternSync ");
952 AddressBook::Iterator it;
953 for ( it = begin(); it != end(); ++it ) {
954 (*it).setID( csd, (*it).externalUID() );
955 (*it).computeCsum( csd );
956 }
957
958 Addressee ad;
959 for ( it = begin(); it != end(); ++it ) {
960 ad = aBook->findByExternUid( (*it).externalUID(), csd );
961 if ( !ad.isEmpty() ) {
962 (*it).mergeOLContact( ad );
963 }
964 }
965}
949void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) 966void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
950{ 967{
951 //qDebug("AddressBook::postExternSync "); 968 //qDebug("AddressBook::postExternSync ");
952 AddressBook::Iterator it; 969 AddressBook::Iterator it;
953 int foundEmpty = 0; 970 int foundEmpty = 0;
954 for ( it = begin(); it != end(); ++it ) { 971 for ( it = begin(); it != end(); ++it ) {
955 //qDebug("check uid %s ", (*it).uid().latin1() ); 972 //qDebug("check uid %s ", (*it).uid().latin1() );
956 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 973 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
957 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || 974 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
958 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { 975 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
959 Addressee ad = aBook->findByUid( ( (*it).uid() )); 976 Addressee ad = aBook->findByUid( ( (*it).uid() ));
960 if ( ad.isEmpty() ) { 977 if ( ad.isEmpty() ) {
961 ++foundEmpty; 978 ++foundEmpty;
962 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); 979 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
963 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); 980 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
964 } else { 981 } else {
965 (*it).setIDStr(":"); 982 (*it).setIDStr(":");
966 if ( setID ) { 983 if ( setID ) {
967 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 984 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
968 ad.setID( csd, (*it).externalUID() ); 985 ad.setID( csd, (*it).externalUID() );{
986 }
969 } else 987 } else
970 ad.setID( csd, (*it).uid() ); 988 ad.setID( csd, (*it).uid() );
971 (*it).computeCsum( csd ); 989 (*it).computeCsum( csd );
972 ad.setCsum( csd, (*it).getCsum( csd ) ); 990 ad.setCsum( csd, (*it).getCsum( csd ) );
973 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); 991 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
974 aBook->insertAddressee( ad , false); 992 aBook->insertAddressee( ad , false);
975 } 993 }
976 } 994 }
977 } 995 }
978 if ( foundEmpty ) { 996 if ( foundEmpty ) {
979 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); 997 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
980 } 998 }
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e6daa5e..a8a9fc1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -299,24 +299,25 @@ class AddressBook : public QObject
299 void cleanUp(); 299 void cleanUp();
300 300
301 // sync stuff 301 // sync stuff
302 //Addressee::List getExternLastSyncAddressees(); 302 //Addressee::List getExternLastSyncAddressees();
303 void resetTempSyncStat(); 303 void resetTempSyncStat();
304 QStringList uidList(); 304 QStringList uidList();
305 void removeSyncAddressees( bool removeDeleted = false ); 305 void removeSyncAddressees( bool removeDeleted = false );
306 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); 306 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
307 const Addressee findByExternUid( const QString& uid , const QString& profile ) const; 307 const Addressee findByExternUid( const QString& uid , const QString& profile ) const;
308 bool containsExternalUid( const QString& uid ); 308 bool containsExternalUid( const QString& uid );
309 309
310 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); 310 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
311 void preOLSync( AddressBook* aBook, const QString& csd);
311 void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); 312 void postExternSync( AddressBook* aBook, const QString& csd , bool setID );
312 signals: 313 signals:
313 /** 314 /**
314 Emitted, when the address book has changed on disk. 315 Emitted, when the address book has changed on disk.
315 */ 316 */
316 void addressBookChanged( AddressBook * ); 317 void addressBookChanged( AddressBook * );
317 318
318 /** 319 /**
319 Emitted, when the address book has been locked for writing. 320 Emitted, when the address book has been locked for writing.
320 */ 321 */
321 void addressBookLocked( AddressBook * ); 322 void addressBookLocked( AddressBook * );
322 323
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 6cfac80..e8e440c 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -23,24 +23,25 @@
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h>
35#include <kidmanager.h> 36#include <kidmanager.h>
36//US 37//US
37#include <kstandarddirs.h> 38#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 39#include <libkcal/syncdefines.h>
39 40
40//US #include "resource.h" 41//US #include "resource.h"
41#include "addressee.h" 42#include "addressee.h"
42 43
43using namespace KABC; 44using namespace KABC;
44 45
45static bool matchBinaryPattern( int value, int pattern ); 46static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 47static bool matchBinaryPatternA( int value, int pattern );
@@ -202,25 +203,25 @@ ulong Addressee::getCsum4List( const QStringList & attList)
202 203
203 } 204 }
204 //QString dump = attList.join(","); 205 //QString dump = attList.join(",");
205 //qDebug("csum: %d %s", cSum,dump.latin1()); 206 //qDebug("csum: %d %s", cSum,dump.latin1());
206 207
207 return cSum; 208 return cSum;
208 209
209} 210}
210void Addressee::computeCsum(const QString &dev) 211void Addressee::computeCsum(const QString &dev)
211{ 212{
212 QStringList l; 213 QStringList l;
213 //if ( !mData->name.isEmpty() ) l.append(mData->name); 214 //if ( !mData->name.isEmpty() ) l.append(mData->name);
214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 215 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 216 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 217 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 218 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 219 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 220 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 221 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 222 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 223 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 224 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 225 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
225 if ( !mData->title .isEmpty() ) l.append( mData->title ); 226 if ( !mData->title .isEmpty() ) l.append( mData->title );
226 if ( !mData->role.isEmpty() ) l.append( mData->role ); 227 if ( !mData->role.isEmpty() ) l.append( mData->role );
@@ -323,24 +324,71 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const
323 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { 324 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
324#if QT_VERSION >= 0x030000 325#if QT_VERSION >= 0x030000
325 if (re->search( (*phoneIter).number() ) == 0) 326 if (re->search( (*phoneIter).number() ) == 0)
326#else 327#else
327 if (re->match( (*phoneIter).number() ) == 0) 328 if (re->match( (*phoneIter).number() ) == 0)
328#endif 329#endif
329 return true; 330 return true;
330 331
331 } 332 }
332 return false; 333 return false;
333 334
334} 335}
336void Addressee::mergeOLContact( const Addressee& ad )
337{
338 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
339 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
340 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
341 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
342 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
343 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
344 if ( !mData->sound.isIntern() ) {
345 if ( mData->sound.url().isEmpty() ) {
346 mData->sound = ad.mData->sound;
347 }
348 }
349 if ( !mData->agent.isIntern() ) {
350 if ( mData->agent.url().isEmpty() ) {
351 mData->agent = ad.mData->agent;
352 }
353 }
354 {
355 Key::List::Iterator itA;
356 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
357 bool found = false;
358 Key::List::Iterator it;
359 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
360 if ( (*it) == (*itA)) {
361 found = true;
362 break;
363
364 }
365 }
366 if ( ! found ) {
367 mData->keys.append( *itA );
368 }
369 }
370 }
371
372 KABC::Address addthis = otherAddress();
373 KABC::Address addother = ad.otherAddress();
374 if ( !addthis.isEmpty() && !addother.isEmpty() )
375 addthis.setType( addother.type() );
376 //qDebug("merge contact %s ", ad.uid().latin1());
377 setUid( ad.uid() );
378 setRevision( ad.revision() );
379
380
381}
382
335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 383void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
336{ 384{
337 // merge all standard non-outlook fields. 385 // merge all standard non-outlook fields.
338 //if isSubSet (e.g. mobile phone sync) merge all fields 386 //if isSubSet (e.g. mobile phone sync) merge all fields
339 387
340 detach(); 388 detach();
341 if ( isSubSet ) { 389 if ( isSubSet ) {
342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 390 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 391 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 392 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 393 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 394 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
@@ -1644,25 +1692,24 @@ QString Addressee::preferredEmail() const
1644QStringList Addressee::emails() const 1692QStringList Addressee::emails() const
1645{ 1693{
1646 return mData->emails; 1694 return mData->emails;
1647} 1695}
1648void Addressee::setEmails( const QStringList& emails ) { 1696void Addressee::setEmails( const QStringList& emails ) {
1649 detach(); 1697 detach();
1650 mData->emails = emails; 1698 mData->emails = emails;
1651} 1699}
1652void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1700void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1653{ 1701{
1654 detach(); 1702 detach();
1655 mData->empty = false; 1703 mData->empty = false;
1656
1657 PhoneNumber::List::Iterator it; 1704 PhoneNumber::List::Iterator it;
1658 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1705 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1659 if ( (*it).id() == phoneNumber.id() ) { 1706 if ( (*it).id() == phoneNumber.id() ) {
1660 *it = phoneNumber; 1707 *it = phoneNumber;
1661 return; 1708 return;
1662 } 1709 }
1663 } 1710 }
1664 mData->phoneNumbers.append( phoneNumber ); 1711 mData->phoneNumbers.append( phoneNumber );
1665} 1712}
1666 1713
1667void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1714void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1668{ 1715{
@@ -1711,24 +1758,35 @@ int Addressee::hasPhoneNumberType( int type )
1711PhoneNumber::List Addressee::phoneNumbers( int type ) const 1758PhoneNumber::List Addressee::phoneNumbers( int type ) const
1712{ 1759{
1713 PhoneNumber::List list; 1760 PhoneNumber::List list;
1714 1761
1715 PhoneNumber::List::ConstIterator it; 1762 PhoneNumber::List::ConstIterator it;
1716 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1763 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1717 if ( matchBinaryPattern( (*it).type(), type ) ) { 1764 if ( matchBinaryPattern( (*it).type(), type ) ) {
1718 list.append( *it ); 1765 list.append( *it );
1719 } 1766 }
1720 } 1767 }
1721 return list; 1768 return list;
1722} 1769}
1770QString Addressee::phoneNumberString( int type ) const
1771{
1772
1773 PhoneNumber::List::ConstIterator it;
1774 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1775 if ((*it).type() == type ) {
1776 return ( *it ).number();
1777 }
1778 }
1779 return "";
1780}
1723 1781
1724PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1782PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1725{ 1783{
1726 PhoneNumber::List::ConstIterator it; 1784 PhoneNumber::List::ConstIterator it;
1727 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1785 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1728 if ( (*it).id() == id ) { 1786 if ( (*it).id() == id ) {
1729 return *it; 1787 return *it;
1730 } 1788 }
1731 } 1789 }
1732 return PhoneNumber(); 1790 return PhoneNumber();
1733} 1791}
1734 1792
@@ -1916,25 +1974,36 @@ void Addressee::insertAddress( const Address &address )
1916void Addressee::removeAddress( const Address &address ) 1974void Addressee::removeAddress( const Address &address )
1917{ 1975{
1918 detach(); 1976 detach();
1919 1977
1920 Address::List::Iterator it; 1978 Address::List::Iterator it;
1921 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1979 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1922 if ( (*it).id() == address.id() ) { 1980 if ( (*it).id() == address.id() ) {
1923 mData->addresses.remove( it ); 1981 mData->addresses.remove( it );
1924 return; 1982 return;
1925 } 1983 }
1926 } 1984 }
1927} 1985}
1928 1986Address Addressee::otherAddress() const
1987{
1988 Address::List::ConstIterator it;
1989 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1990 if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) )
1991 continue;
1992 if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) )
1993 continue;
1994 return (*it);
1995 }
1996 return Address();
1997}
1929Address Addressee::address( int type ) const 1998Address Addressee::address( int type ) const
1930{ 1999{
1931 Address address( type ); 2000 Address address( type );
1932 Address::List::ConstIterator it; 2001 Address::List::ConstIterator it;
1933 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 2002 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1934 if ( matchBinaryPatternA( (*it).type(), type ) ) { 2003 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1935 if ( (*it).type() & Address::Pref ) 2004 if ( (*it).type() & Address::Pref )
1936 return (*it); 2005 return (*it);
1937 else if ( address.isEmpty() ) 2006 else if ( address.isEmpty() )
1938 address = (*it); 2007 address = (*it);
1939 } 2008 }
1940 } 2009 }
diff --git a/kabc/addressee.h b/kabc/addressee.h
index aac78dc..0ea1803 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -109,24 +109,25 @@ class Addressee
109 void removeID(const QString &); 109 void removeID(const QString &);
110 void computeCsum(const QString &dev); 110 void computeCsum(const QString &dev);
111 ulong getCsum4List( const QStringList & attList); 111 ulong getCsum4List( const QStringList & attList);
112 /** 112 /**
113 Return, if the address book entry is empty. 113 Return, if the address book entry is empty.
114 */ 114 */
115 bool isEmpty() const; 115 bool isEmpty() const;
116 void setExternalUID( const QString &id ); 116 void setExternalUID( const QString &id );
117 const QString externalUID() const; 117 const QString externalUID() const;
118 void setOriginalExternalUID( const QString &id ); 118 void setOriginalExternalUID( const QString &id );
119 QString originalExternalUID() const; 119 QString originalExternalUID() const;
120 void mergeContact( const Addressee& ad, bool isSubSet ); 120 void mergeContact( const Addressee& ad, bool isSubSet );
121 void mergeOLContact( const Addressee& ad );
121 void simplifyEmails(); 122 void simplifyEmails();
122 void simplifyAddresses(); 123 void simplifyAddresses();
123 void simplifyPhoneNumbers(); 124 void simplifyPhoneNumbers();
124 void simplifyPhoneNumberTypes(); 125 void simplifyPhoneNumberTypes();
125 void makePhoneNumbersOLcompatible(); 126 void makePhoneNumbersOLcompatible();
126 int hasPhoneNumberType( int type ); 127 int hasPhoneNumberType( int type );
127 bool removeVoice(); 128 bool removeVoice();
128 bool containsAdr(const Addressee& addr ); 129 bool containsAdr(const Addressee& addr );
129 130
130 /** 131 /**
131 Set unique identifier. 132 Set unique identifier.
132 */ 133 */
@@ -638,24 +639,25 @@ class Addressee
638 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 639 void insertPhoneNumber( const PhoneNumber &phoneNumber );
639 640
640 /** 641 /**
641 Remove phone number. If no phone number with the given id exists for this 642 Remove phone number. If no phone number with the given id exists for this
642 addresse nothing happens. 643 addresse nothing happens.
643 */ 644 */
644 void removePhoneNumber( const PhoneNumber &phoneNumber ); 645 void removePhoneNumber( const PhoneNumber &phoneNumber );
645 646
646 /** 647 /**
647 Return phone number, which matches the given type. 648 Return phone number, which matches the given type.
648 */ 649 */
649 PhoneNumber phoneNumber( int type ) const; 650 PhoneNumber phoneNumber( int type ) const;
651 QString phoneNumberString( int type ) const;
650 652
651 bool matchPhoneNumber( QRegExp* searchExp ) const; 653 bool matchPhoneNumber( QRegExp* searchExp ) const;
652 bool matchAddress( QRegExp* searchExp ) const; 654 bool matchAddress( QRegExp* searchExp ) const;
653 655
654 /** 656 /**
655 Return list of all phone numbers. 657 Return list of all phone numbers.
656 */ 658 */
657 PhoneNumber::List phoneNumbers() const; 659 PhoneNumber::List phoneNumbers() const;
658 660
659 /** 661 /**
660 Return list of phone numbers with a special type. 662 Return list of phone numbers with a special type.
661 */ 663 */
@@ -722,25 +724,25 @@ class Addressee
722 */ 724 */
723 void removeAddress( const Address &address ); 725 void removeAddress( const Address &address );
724 726
725 /** 727 /**
726 Return address, which matches the given type. 728 Return address, which matches the given type.
727 */ 729 */
728 Address address( int type ) const; 730 Address address( int type ) const;
729 731
730 /** 732 /**
731 Return list of all addresses. 733 Return list of all addresses.
732 */ 734 */
733 Address::List addresses() const; 735 Address::List addresses() const;
734 736 Address otherAddress() const;
735 /** 737 /**
736 Return list of addresses with a special type. 738 Return list of addresses with a special type.
737 */ 739 */
738 Address::List addresses( int type ) const; 740 Address::List addresses( int type ) const;
739 741
740 /** 742 /**
741 Return address with the given id. 743 Return address with the given id.
742 */ 744 */
743 Address findAddress( const QString &id ) const; 745 Address findAddress( const QString &id ) const;
744 746
745 /** 747 /**
746 Insert category. If the category already exists it is not duplicated. 748 Insert category. If the category already exists it is not duplicated.
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 12b9b09..1752745 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -223,24 +223,48 @@ PhoneNumber::TypeList PhoneNumber::typeList()
223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
224 << Bbs << Modem << Car << Isdn << Pcs << Pager; 224 << Bbs << Modem << Car << Isdn << Pcs << Pager;
225 225
226 return list; 226 return list;
227} 227}
228PhoneNumber::TypeList PhoneNumber::supportedTypeList() 228PhoneNumber::TypeList PhoneNumber::supportedTypeList()
229{ 229{
230 static TypeList list; 230 static TypeList list;
231 if ( list.count() == 0 ) 231 if ( list.count() == 0 )
232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; 232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice;
233 return list; 233 return list;
234} 234}
235
236#if 0
237Home| Pref i18n("Home") Home
238Work| Pref i18n("Work") Business
239Cell i18n("Mobile") Mobile
240Pcs|Pref i18n("SiP") Radio
241Pcs|Voice i18n("VoIP") TTY/TTD
242Home i18n("Home2") Home 2
243Work i18n("Work2") Business 2
244Car i18n("Mobile2") Car
245Pcs i18n("SiP2") Telex
246Work| Msg | Voice i18n("Assistent") Assistent
247Work| Msg i18n("Company") Company
248Home | Fax i18n("Fax (Home)") Home Fax
249Work| Fax i18n("Fax (Work)") Business Fax
250Fax i18n("Fax (Other)") Other Fax
251Pager i18n("Pager") Pager
252Isdn i18n("ISDN") Isdn
253Msg i18n("Callback") Callback
254Pref i18n("Primary") Primary
255Voice; i18n("Other") Other
256
257#endif
258
235QStringList PhoneNumber::supportedTypeListNames() 259QStringList PhoneNumber::supportedTypeListNames()
236{ 260{
237 static QStringList list; 261 static QStringList list;
238 if ( list.count() == 0 ) 262 if ( list.count() == 0 )
239 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); 263 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other");
240 return list; 264 return list;
241} 265}
242 266
243int PhoneNumber::typeListIndex4Type(int type ) 267int PhoneNumber::typeListIndex4Type(int type )
244{ 268{
245 TypeList list = supportedTypeList(); 269 TypeList list = supportedTypeList();
246 int i = 0; 270 int i = 0;
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7d8586a..ab2824c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -149,24 +149,25 @@ $Id$
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#include <libkdepim/ol_access.h>
161#endif 162#endif
162#else 163#else
163#include <unistd.h> 164#include <unistd.h>
164#endif 165#endif
165// sync includes 166// sync includes
166#include <libkdepim/ksyncprofile.h> 167#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 168#include <libkdepim/ksyncprefsdialog.h>
168 169
169 170
170class KABCatPrefs : public QDialog 171class KABCatPrefs : public QDialog
171{ 172{
172 public: 173 public:
@@ -1360,50 +1361,98 @@ void KABCore::addEmail( QString aStr )
1360#else //KAB_EMBEDDED 1361#else //KAB_EMBEDDED
1361 qDebug("KABCore::addEmail finsih method"); 1362 qDebug("KABCore::addEmail finsih method");
1362#endif //KAB_EMBEDDED 1363#endif //KAB_EMBEDDED
1363} 1364}
1364 1365
1365void KABCore::importVCard( const KURL &url, bool showPreview ) 1366void KABCore::importVCard( const KURL &url, bool showPreview )
1366{ 1367{
1367 mXXPortManager->importVCard( url, showPreview ); 1368 mXXPortManager->importVCard( url, showPreview );
1368} 1369}
1369void KABCore::importFromOL() 1370void KABCore::importFromOL()
1370{ 1371{
1371#ifdef _OL_IMPORT_ 1372#ifdef _OL_IMPORT_
1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1373 KABC::Addressee::List list = OL_access::instance()->importOLcontacts();
1373 idgl->exec(); 1374 if ( list.count() > 0 ) {
1374 KABC::Addressee::List list = idgl->getAddressList(); 1375 KABC::Addressee::List listNew;
1375 if ( list.count() > 0 ) { 1376 KABC::Addressee::List listExisting;
1376 KABC::Addressee::List listNew; 1377 KABC::Addressee::List::Iterator it;
1377 KABC::Addressee::List listExisting; 1378 KABC::AddressBook::Iterator iter;
1378 KABC::Addressee::List::Iterator it; 1379 for ( it = list.begin(); it != list.end(); ++it ) {
1379 KABC::AddressBook::Iterator iter; 1380 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1380 for ( it = list.begin(); it != list.end(); ++it ) { 1381 listNew.append( (*it) );
1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1382 else
1382 listNew.append( (*it) ); 1383 listExisting.append( (*it) );
1383 else 1384 }
1384 listExisting.append( (*it) ); 1385 QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() );
1385 } 1386 if ( listExisting.count() > 0 )
1386 if ( listExisting.count() > 0 ) 1387 mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() );
1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1388
1388 if ( listNew.count() > 0 ) { 1389 KMessageBox::information( this, mess );
1389 pasteWithNewUid = false; 1390 if ( listNew.count() > 0 ) {
1390 pasteContacts( listNew ); 1391 pasteWithNewUid = false;
1391 pasteWithNewUid = true; 1392 pasteContacts( listNew );
1393 pasteWithNewUid = true;
1394 }
1392 } 1395 }
1393 }
1394 delete idgl;
1395#endif 1396#endif
1396} 1397}
1397 1398
1399bool KABCore::readOLdata( KABC::AddressBook* local )
1400{
1401#ifdef _OL_IMPORT_
1402 QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync"));
1403 KABC::Addressee::List list;
1404 if ( folderList.count() ) {
1405 OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true );
1406 KABC::Addressee::List::Iterator it;
1407 for ( it = list.begin(); it != list.end(); ++it ) {
1408 (*it).setExternalUID( (*it).uid() );
1409 (*it).setOriginalExternalUID( (*it).uid() );
1410 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
1411 local->insertAddressee( (*it) , false, false );
1412 }
1413 mOLsyncFolderID = folderList[1];
1414 //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID );
1415 }
1416 return list.count() > 0;
1417#else
1418 return false;
1419#endif
1420}
1421bool KABCore::writeOLdata( KABC::AddressBook* aBook )
1422{
1423#ifdef _OL_IMPORT_
1424 if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) )
1425 return false;
1426 KABC::AddressBook::Iterator it;
1427 for ( it = aBook->begin(); it != aBook->end(); ++it ) {
1428 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1429 KABC::Addressee addressee = (*it);
1430 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
1431 (*it) = OL_access::instance()->addAddressee( (*it) );
1432 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1433 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
1434 OL_access::instance()->deleteAddressee( (*it) );
1435 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1436 //changed
1437 (*it) = OL_access::instance()->changeAddressee( (*it) );
1438 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
1439 }
1440 }
1441 }
1442 return true;
1443#else
1444 return false;
1445#endif
1446}
1398void KABCore::importVCard( const QString &vCard, bool showPreview ) 1447void KABCore::importVCard( const QString &vCard, bool showPreview )
1399{ 1448{
1400 mXXPortManager->importVCard( vCard, showPreview ); 1449 mXXPortManager->importVCard( vCard, showPreview );
1401} 1450}
1402 1451
1403//US added a second method without defaultparameter 1452//US added a second method without defaultparameter
1404void KABCore::editContact2() { 1453void KABCore::editContact2() {
1405 editContact( QString::null ); 1454 editContact( QString::null );
1406} 1455}
1407 1456
1408void KABCore::editContact( const QString &uid ) 1457void KABCore::editContact( const QString &uid )
1409{ 1458{
@@ -3365,30 +3414,67 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString res
3365 if ( syncOK ) 3414 if ( syncOK )
3366 mViewManager->refreshView(); 3415 mViewManager->refreshView();
3367 return syncOK; 3416 return syncOK;
3368 3417
3369} 3418}
3370void KABCore::removeSyncInfo( QString syncProfile) 3419void KABCore::removeSyncInfo( QString syncProfile)
3371{ 3420{
3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3421 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3373 mAddressBook->removeSyncInfo( syncProfile ); 3422 mAddressBook->removeSyncInfo( syncProfile );
3374 setModified(); 3423 setModified();
3375} 3424}
3376 3425
3426bool KABCore::syncOL()
3427{
3428 disableBR( true );
3429 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3430 AddressBook abLocal;
3431 if ( ! readOLdata( &abLocal ) )
3432 return false;
3433 bool syncOK = false;
3434 message(i18n("Data from OL loaded..."), false);
3435 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3436 message(i18n("Sync preprocessing..."),false);
3437 abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice );
3438 message(i18n("Synchronizing..."),false);
3439 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3440 syncManager->hideProgressBar();
3441 if ( syncOK ) {
3442 if ( syncManager->mWriteBackFile ) {
3443 abLocal.removeSyncAddressees( false );
3444 message(i18n("Saving address data to OL..."),false);
3445 //abLocal.saveAB();
3446 writeOLdata( &abLocal );
3447 message(i18n("Sync postprocessing..."),false);
3448 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3449 }
3450 } else
3451 message( i18n("Sync cancelled or failed.") );
3452 setModified();
3453 abLocal.removeResources();
3454 if ( syncOK ) {
3455 mViewManager->refreshView();
3456 message(i18n("OL syncing finished."));
3457 }
3458 disableBR( false );
3459 return syncOK;
3460}
3377 3461
3378//this is a overwritten callbackmethods from the syncinterface 3462//this is a overwritten callbackmethods from the syncinterface
3379bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3463bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3380{ 3464{
3381 if ( resource == "phone" ) 3465 if ( resource == "phone" )
3382 return syncPhone(); 3466 return syncPhone();
3467 if ( resource == "ol" )
3468 return syncOL();
3383 disableBR( true ); 3469 disableBR( true );
3384 if ( manager != syncManager ) 3470 if ( manager != syncManager )
3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3471 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3472 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3387 3473
3388 AddressBook abLocal( resource,"syncContact"); 3474 AddressBook abLocal( resource,"syncContact");
3389 bool syncOK = false; 3475 bool syncOK = false;
3390 message(i18n("Loading DTM address data..."), false); 3476 message(i18n("Loading DTM address data..."), false);
3391 if ( abLocal.load() ) { 3477 if ( abLocal.load() ) {
3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3478 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3479 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3394 message(i18n("Sync preprocessing..."),false); 3480 message(i18n("Sync preprocessing..."),false);
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e69cb60..ec6a9ec 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -506,30 +506,35 @@ class KABCore : public QWidget, public KSyncInterface
506 class KABCorePrivate; 506 class KABCorePrivate;
507 KABCorePrivate *d; 507 KABCorePrivate *d;
508 //US bool mBlockSaveFlag; 508 //US bool mBlockSaveFlag;
509 509
510#ifdef KAB_EMBEDDED 510#ifdef KAB_EMBEDDED
511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
512#endif //KAB_EMBEDDED 512#endif //KAB_EMBEDDED
513 513
514 //this are the overwritten callbackmethods from the syncinterface 514 //this are the overwritten callbackmethods from the syncinterface
515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); 515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
516 virtual bool syncExternal(KSyncManager* manager, QString resource); 516 virtual bool syncExternal(KSyncManager* manager, QString resource);
517 virtual void removeSyncInfo( QString syncProfile); 517 virtual void removeSyncInfo( QString syncProfile);
518 bool readOLdata( KABC::AddressBook* local );
519 bool writeOLdata( KABC::AddressBook* local );
520 bool syncOL();
518 bool syncPhone(); 521 bool syncPhone();
519 void message( QString m , bool startTimer = true); 522 void message( QString m , bool startTimer = true);
520 523
521 // LR ******************************* 524 // LR *******************************
522 // sync stuff! 525 // sync stuff!
523 QString sentSyncFile(); 526 QString sentSyncFile();
524 QPopupMenu *syncMenu; 527 QPopupMenu *syncMenu;
525 KSyncManager* syncManager; 528 KSyncManager* syncManager;
526 int mGlobalSyncMode; 529 int mGlobalSyncMode;
527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 530 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
528 KABC::Addressee getLastSyncAddressee(); 531 KABC::Addressee getLastSyncAddressee();
529 QDateTime mLastAddressbookSync; 532 QDateTime mLastAddressbookSync;
530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 533 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
531 // ********************* 534 // *********************
535 //OL sync stuff
536 QString mOLsyncFolderID;
532 537
533}; 538};
534 539
535#endif 540#endif
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 2f794d6..6afc288 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -12,724 +12,12 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h>
25#include <qframe.h>
26#include <qpixmap.h>
27#include <qlayout.h>
28#include <qprogressbar.h>
29#include <qprogressdialog.h>
30#include <qwidgetstack.h>
31#include <qdatetime.h>
32#include <qdir.h>
33#include <qregexp.h>
34#include <qapplication.h>
35#include <qhbox.h>
36#include <qheader.h>
37#include <qdatetime.h>
38#include <qlistview.h>
39
40#include <kdebug.h>
41#include <klocale.h>
42#include <kstandarddirs.h>
43#include <kmessagebox.h>
44#include <kfiledialog.h>
45
46#include <libkdepim/categoryselectdialog.h>
47#include <libkdepim/kinputdialog.h>
48
49#include <libkcal/calendarlocal.h>
50#include <libkcal/icalformat.h>
51
52#include <kabc/addresseelist.h>
53#include <kabc/phonenumber.h>
54
55#include "kaimportoldialog.h"
56
57#include "../outport/msoutl9.h"
58#include <ole2.h>
59#include <comutil.h>
60_Application gOlAppAB;
61
62QDateTime mDdate2Qdtr( DATE dt)
63{
64 COleDateTime odt;
65 SYSTEMTIME st;
66 odt = dt;
67 if ( odt.GetStatus() != 0 )
68 return QDateTime();
69 odt.GetAsSystemTime(st);
70 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
71 return QDateTime();
72 // it seems so, that 1.1.4501 indicates: DATE invalid
73 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
74 return qdt;
75}
76
77class OLEListViewItem : public QCheckListItem
78{
79 public:
80 OLEListViewItem( QListView *parent, QString text ) :
81 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
82 OLEListViewItem( QListViewItem *after, QString text ) :
83 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
84 ~OLEListViewItem() {};
85 void setData( DWORD data ) {mData= data; };
86 DWORD data() { return mData ;};
87 private:
88 DWORD mData;
89};
90
91KAImportOLdialog::KAImportOLdialog( const QString &caption,
92 KABC::AddressBook * aBook, QWidget *parent ) :
93 KDialogBase( Plain, caption, User1 | Close, Ok,
94 parent, caption, true, false, i18n("Import!") )
95{
96 QHBox * mw = new QHBox( this );
97 setMainWidget( mw );
98 mListView = new QListView( mw );
99 mListView->addColumn(i18n("Select Folder to import"));
100 mListView->addColumn(i18n("Content Type"));
101 mABook = aBook;
102 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
103 setupFolderView();
104 resize( sizeHint().width()+50, sizeHint().height()+50 );
105}
106
107KAImportOLdialog::~KAImportOLdialog()
108{
109
110}
111
112KABC::Addressee::List KAImportOLdialog::getAddressList()
113{
114 return mAList;
115}
116void KAImportOLdialog::setupFolderView()
117{
118 SCODE sc = ::OleInitialize(NULL);
119 if ( FAILED ( sc ) ) {
120 KMessageBox::information(this,"OLE initialisation failed");
121 return;
122 }
123
124 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
125 KMessageBox::information(this,"Sorry, cannot access Outlook");
126 return ;
127 }
128 MAPIFolder mfInbox;
129 MAPIFolder mfRoot;
130 CString szName;
131 _NameSpace olNS;
132 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
133 mfInbox = olNS.GetDefaultFolder(6);
134 mfRoot = mfInbox.GetParent();
135 szName = mfRoot.GetName();
136 long iType = mfRoot.GetDefaultItemType();
137 QString mes;
138 mes = QString::fromUcs2( szName.GetBuffer() );
139 OLEListViewItem * root = new OLEListViewItem( mListView, mes );
140 mfRoot.m_lpDispatch->AddRef();
141 addFolder( root, mfRoot.m_lpDispatch );
142 root->setOpen( true );
143 mListView->setSortColumn( 0 );
144 mListView->sort( );
145}
146
147
148void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
149{
150 MAPIFolder mfParent(dispParent), mfChild;
151 _Folders folders;
152 _variant_t fndx((long)0);
153 CString szName;
154 long iType;
155 OLEListViewItem* hChild;
156
157 folders = mfParent.GetFolders();
158 for(int i=1; i <= folders.GetCount(); ++i)
159 {
160 fndx = (long)i;
161 mfChild = folders.Item(fndx.Detach());
162 mfChild.m_lpDispatch->AddRef();
163 szName = mfChild.GetName();
164 iType = mfChild.GetDefaultItemType();
165 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
166 if ( iType != 2)
167 hChild->setEnabled( false );
168 QString ts;
169 switch( iType ) {
170 case 0:
171 ts = i18n("Mail");
172 break;
173 case 1:
174 ts = i18n("Calendar");
175 break;
176 case 2:
177 ts = i18n("Contacts");
178 break;
179 case 3:
180 ts = i18n("Todos");
181 break;
182 case 4:
183 ts = i18n("Journals");
184 break;
185 case 5:
186 ts = i18n("Notes");
187 break;
188 default:
189 ts = i18n("Unknown");
190 }
191 hChild->setText( 1,ts);
192 hChild->setData( (DWORD) mfChild.m_lpDispatch );
193 mfChild.m_lpDispatch->AddRef();
194 addFolder(hChild, mfChild.m_lpDispatch);
195 }
196}
197
198void KAImportOLdialog::slotApply()
199{
200 importedItems = 0;
201 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
202 while ( child ) {
203 if ( child->isOn() )
204 readContactData( child->data() );
205 child = (OLEListViewItem*) child->itemBelow();
206 }
207 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
208 KMessageBox::information(this,mes);
209}
210void KAImportOLdialog::readContactData( DWORD folder )
211{
212
213 LPDISPATCH dispItem = (LPDISPATCH)folder;
214 dispItem->AddRef();
215 MAPIFolder mf(dispItem);
216 mf.m_lpDispatch->AddRef();
217 _Items folderItems;
218 _variant_t indx((long)0);
219 LPDISPATCH itm;
220 int i;
221 folderItems = mf.GetItems();
222 QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this);
223 bar.setCaption (i18n("Importing!") );
224 int h = bar.sizeHint().height() ;
225 int w = 300;
226 int dw = QApplication::desktop()->width();
227 int dh = QApplication::desktop()->height();
228 //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
229 bar.show();
230 for(i=1; i <= folderItems.GetCount(); ++i)
231 {
232 qApp->processEvents();
233 if ( ! bar.isVisible() )
234 return ;
235 bar.setProgress( i );
236 indx = (long)i;
237 itm = folderItems.Item(indx.Detach());
238 _ContactItem * pItem = (_ContactItem *)&itm;
239 ol2kapiContact( pItem );
240 itm->Release();
241 }
242}
243void KAImportOLdialog::slotOk()
244{
245 QDialog::accept();
246}
247
248void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
249{
250 KABC::Addressee addressee;
251
252 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
253 //GetLastModificationTime()
254 //addressee.setName( const QString &name );
255 //addressee.setFormattedName( const QString &formattedName );
256 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
257 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
258 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
259 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
260 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
261 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
262 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
263 if ( dtb.isValid() )
264 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
265
266 //QString::fromUcs2(aItem->.GetBuffer())
267 //addressee.setMailer( const QString &mailer );
268 //addressee.setTimeZone( const TimeZone &timeZone );
269 //addressee.setGeo( const Geo &geo );
270 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
271 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
272 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") );
273 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
274 notesStr.replace( QRegExp("\\r"), "");
275
276 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
277 //addressee.setRevision( const QDateTime &revision );
278 // addressee.setSortString( const QString &sortString );
279 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
280
281 QString tempS;
282 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
283 if ( tempS.length() > 12 )
284 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
285 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
286 if ( !tempS.isEmpty() )
287 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
288 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
289 if ( !tempS.isEmpty() )
290 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
291 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
292 if ( !tempS.isEmpty() )
293 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
294 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
295 if ( !tempS.isEmpty() )
296 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
297 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), "");
298 if ( !tempS.isEmpty() )
299 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
300 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
301 if ( !tempS.isEmpty() )
302 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
303 dtb = mDdate2Qdtr(aItem->GetAnniversary());
304 if (dtb.isValid() ) {
305 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
306 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
307 }
308 int sec = aItem->GetSensitivity() ;
309 if ( sec > 1 )// mapping pers -> private
310 --sec;
311 addressee.setSecrecy( sec );
312 //addressee.setLogo( const Picture &logo );
313 //addressee.setPhoto( const Picture &photo );
314 //addressee.setSound( const Sound &sound );
315 //addressee.setAgent( const Agent &agent );
316 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), "");
317 cat = cat.replace( QRegExp("; "), ";");
318 addressee.setCategories( QStringList::split( ";", cat ));
319
320 QString phoneS;
321
322 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
323 if ( ! phoneS.isEmpty())
324 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) );
325 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
326 if ( ! phoneS.isEmpty())
327 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
328 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
329 if ( ! phoneS.isEmpty())
330 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
331 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
332 if ( ! phoneS.isEmpty())
333 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) );
334 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
335 if ( ! phoneS.isEmpty())
336 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) );
337 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
338 if ( ! phoneS.isEmpty())
339 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
340 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
341 if ( ! phoneS.isEmpty())
342 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
343 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
344 if ( ! phoneS.isEmpty())
345 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) );
346 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
347 if ( ! phoneS.isEmpty())
348 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) );
349 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
350 if ( ! phoneS.isEmpty())
351 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) );
352 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
353 if ( ! phoneS.isEmpty())
354 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) );
355 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
356 if ( ! phoneS.isEmpty())
357 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) );
358 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
359 if ( ! phoneS.isEmpty())
360 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) );
361 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
362 if ( ! phoneS.isEmpty())
363 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) );
364 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
365 if ( ! phoneS.isEmpty())
366 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) );
367 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
368 if ( ! phoneS.isEmpty())
369 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) );
370 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
371 if ( ! phoneS.isEmpty())
372 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) );
373 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
374 if ( ! phoneS.isEmpty())
375 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) );
376 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
377 if ( ! phoneS.isEmpty())
378 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) );
379
380 bool preferred = true;
381 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
382 if ( ! phoneS.isEmpty()) {
383 addressee.insertEmail(phoneS , preferred );
384 preferred = false;
385 }
386 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer());
387 if ( ! phoneS.isEmpty()) {
388 addressee.insertEmail(phoneS , preferred );
389 preferred = false;
390 }
391 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer());
392 if ( ! phoneS.isEmpty()) {
393 addressee.insertEmail(phoneS , preferred );
394 preferred = false;
395 }
396 // is this the number of the preferred email?
397 //long GetSelectedMailingAddress();???
398
399 KABC::Address addressHome;
400 KABC::Address* addressAdd = &addressHome;
401 bool insert = false;
402 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer());
403 phoneS.replace( QRegExp("\\r"), "");
404 if ( ! phoneS.isEmpty()) {
405 addressAdd->setCountry(phoneS );
406 insert = true;
407 }
408 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
409 phoneS.replace( QRegExp("\\r"), "");
410 if ( ! phoneS.isEmpty()) {
411 addressAdd->setRegion(phoneS );
412 insert = true;
413 }
414 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
415 phoneS.replace( QRegExp("\\r"), "");
416 if ( ! phoneS.isEmpty()) {
417 addressAdd->setLocality(phoneS );
418 insert = true;
419 }
420 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
421 phoneS.replace( QRegExp("\\r"), "");
422 if ( ! phoneS.isEmpty()) {
423 addressAdd->setPostalCode(phoneS );
424 insert = true;
425 }
426 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
427 phoneS.replace( QRegExp("\\r"), "");
428 if ( ! phoneS.isEmpty()) {
429 addressAdd->setPostOfficeBox(phoneS );
430 insert = true;
431 }
432 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
433 phoneS.replace( QRegExp("\\r"), "");
434 if ( ! phoneS.isEmpty()) {
435 addressAdd->setStreet(phoneS );
436 insert = true;
437 }
438 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
439 phoneS.replace( QRegExp("\\r"), "");
440 if ( ! phoneS.isEmpty()) {
441 // redundant !addressAdd->setExtended(phoneS );
442 // insert = true;
443 }
444 addressAdd->setType( KABC::Address::Home );
445 if ( insert )
446 addressee.insertAddress( *addressAdd );
447 // ++++++++++++++++++++++ end of address
448
449 KABC::Address addressWork;
450 addressAdd = &addressWork;
451 insert = false;
452 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer());
453 phoneS.replace( QRegExp("\\r"), "");
454 if ( ! phoneS.isEmpty()) {
455 addressAdd->setCountry(phoneS );
456 insert = true;
457 }
458 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
459 phoneS.replace( QRegExp("\\r"), "");
460 if ( ! phoneS.isEmpty()) {
461 addressAdd->setRegion(phoneS );
462 insert = true;
463 }
464 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
465 phoneS.replace( QRegExp("\\r"), "");
466 if ( ! phoneS.isEmpty()) {
467 addressAdd->setLocality(phoneS );
468 insert = true;
469 }
470 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
471 phoneS.replace( QRegExp("\\r"), "");
472 if ( ! phoneS.isEmpty()) {
473 addressAdd->setPostalCode(phoneS );
474 insert = true;
475 }
476 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
477 phoneS.replace( QRegExp("\\r"), "");
478 if ( ! phoneS.isEmpty()) {
479 addressAdd->setPostOfficeBox(phoneS );
480 insert = true;
481 }
482 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
483 phoneS.replace( QRegExp("\\r"), "");
484 if ( ! phoneS.isEmpty()) {
485 addressAdd->setStreet(phoneS );
486 insert = true;
487 }
488 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
489 phoneS.replace( QRegExp("\\r"), "");
490 if ( ! phoneS.isEmpty()) {
491 // redundant !addressAdd->setExtended(phoneS );
492 // insert = true;
493 }
494 addressAdd->setType( KABC::Address::Work );
495 if ( insert )
496 addressee.insertAddress( *addressAdd );
497 // ++++++++++++++++++++++ end of address
498
499 KABC::Address addressOther;
500 addressAdd = &addressOther;
501 insert = false;
502 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer());
503 phoneS.replace( QRegExp("\\r"), "");
504 if ( ! phoneS.isEmpty()) {
505 addressAdd->setCountry(phoneS );
506 insert = true;
507 }
508 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
509 phoneS.replace( QRegExp("\\r"), "");
510 if ( ! phoneS.isEmpty()) {
511 addressAdd->setRegion(phoneS );
512 insert = true;
513 }
514 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
515 phoneS.replace( QRegExp("\\r"), "");
516 if ( ! phoneS.isEmpty()) {
517 addressAdd->setLocality(phoneS );
518 insert = true;
519 }
520 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
521 phoneS.replace( QRegExp("\\r"), "");
522 if ( ! phoneS.isEmpty()) {
523 addressAdd->setPostalCode(phoneS );
524 insert = true;
525 }
526 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
527 phoneS.replace( QRegExp("\\r"), "");
528 if ( ! phoneS.isEmpty()) {
529 addressAdd->setPostOfficeBox(phoneS );
530 insert = true;
531 }
532 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
533 phoneS.replace( QRegExp("\\r"), "");
534 if ( ! phoneS.isEmpty()) {
535 addressAdd->setStreet(phoneS );
536 insert = true;
537 }
538 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer());
539 if ( ! phoneS.isEmpty()) {
540 // redundant !addressAdd->setExtended(phoneS );
541 //insert = true;
542 }
543 //addressAdd->setId( );
544 if ( insert )
545 addressee.insertAddress( *addressAdd );
546 // ++++++++++++++++++++++ end of address
547 KABC::Address addressMail;
548 addressAdd = &addressMail;
549 insert = false;
550 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
551 phoneS.replace( QRegExp("\\r"), "");
552 if ( ! phoneS.isEmpty()) {
553 addressAdd->setCountry(phoneS );
554 insert = true;
555 }
556 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
557 phoneS.replace( QRegExp("\\r"), "");
558 if ( ! phoneS.isEmpty()) {
559 addressAdd->setRegion(phoneS );
560 insert = true;
561 }
562 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
563 phoneS.replace( QRegExp("\\r"), "");
564 if ( ! phoneS.isEmpty()) {
565 addressAdd->setLocality(phoneS );
566 insert = true;
567 }
568 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
569 phoneS.replace( QRegExp("\\r"), "");
570 if ( ! phoneS.isEmpty()) {
571 addressAdd->setPostalCode(phoneS );
572 insert = true;
573 }
574 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
575 phoneS.replace( QRegExp("\\r"), "");
576 if ( ! phoneS.isEmpty()) {
577 addressAdd->setPostOfficeBox(phoneS );
578 insert = true;
579 }
580 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
581 phoneS.replace( QRegExp("\\r"), "");
582 if ( ! phoneS.isEmpty()) {
583 addressAdd->setStreet(phoneS );
584 insert = true;
585 }
586 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
587 phoneS.replace( QRegExp("\\r"), "");
588 if ( ! phoneS.isEmpty()) {
589 // redundant ! addressAdd->setExtended(phoneS );
590 // insert = true;
591 }
592 addressAdd->setType( KABC::Address::Postal );
593 if ( insert ) {
594 addressee.insertAddress( *addressAdd );
595 }
596 // the following code is disabled
597 // it does not seem to be useful
598#if 0
599 if ( insert ) {
600 addressAdd->setType( KABC::Address::Home );
601 if ( addressMail == addressHome ) {
602 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
603 addressee.insertAddress( addressHome );
604 } else {
605 addressAdd->setType( KABC::Address::Work );
606 if ( addressMail == addressWork ){
607 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
608 addressee.insertAddress( addressWork );
609
610 } else {
611 addressAdd->setType( 0 );
612 if ( addressOther == addressMail ){
613 addressOther.setType( KABC::Address::Postal );
614 addressee.insertAddress( addressOther );
615 } else {
616 addressee.insertAddress( *addressAdd );
617 }
618 }
619 }
620 }
621#endif
622 // ++++++++++++++++++++++ end of ALL addresses
623 //GetUserProperties();
624 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
625 phoneS.replace( QRegExp("\\r"), "");
626 if ( !tempS.isEmpty() )
627 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
628 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
629 if ( !tempS.isEmpty() )
630 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
631 int gen = aItem->GetGender();
632 if ( gen != 0 ) { // 0 undef - 1 female - 2 male
633 if ( gen == 1 )
634 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
635 else
636 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
637 }
638 QString additionalInfo;
639 QString tempAdd;
640 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer());
641 if ( ! tempAdd.isEmpty() ) {
642 additionalInfo += i18n("\nLanguage: ");
643 additionalInfo += tempAdd;
644 }
645 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer());
646 phoneS.replace( QRegExp("\\r"), "");
647 if ( ! tempAdd.isEmpty() ) {
648 additionalInfo += i18n("\nHobby: ");
649 additionalInfo += tempAdd;;
650 }
651 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer());
652 phoneS.replace( QRegExp("\\r"), "");
653 if ( ! tempAdd.isEmpty() ) {
654 additionalInfo += i18n("\nHomepage: ");
655 additionalInfo += tempAdd;;
656 }
657 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer());
658 phoneS.replace( QRegExp("\\r"), "");
659 if ( ! tempAdd.isEmpty() ) {
660 additionalInfo += i18n("\nBilling information: ");
661 additionalInfo += tempAdd;;
662 }
663 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer());
664 phoneS.replace( QRegExp("\\r"), "");
665 if ( ! tempAdd.isEmpty() ) {
666 additionalInfo += i18n("\nCustomer ID: ");
667 additionalInfo += tempAdd;;
668 }
669 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer());
670 phoneS.replace( QRegExp("\\r"), "");
671 if ( ! tempAdd.isEmpty() ) {
672 additionalInfo += i18n("\nUser1: ");
673 additionalInfo += tempAdd;;
674 }
675 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer());
676 phoneS.replace( QRegExp("\\r"), "");
677 if ( ! tempAdd.isEmpty() ) {
678 additionalInfo += i18n("\nUser2: ");
679 additionalInfo += tempAdd;;
680 }
681 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer());
682 phoneS.replace( QRegExp("\\r"), "");
683 if ( ! tempAdd.isEmpty() ) {
684 additionalInfo += i18n("\nUser3: ");
685 additionalInfo += tempAdd;;
686 }
687 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer());
688 phoneS.replace( QRegExp("\\r"), "");
689 if ( ! tempAdd.isEmpty() ) {
690 additionalInfo += i18n("\nUser4: ");
691 additionalInfo += tempAdd;;
692 }
693 if (!additionalInfo.isEmpty() ) {
694 tempAdd = notesStr;
695 notesStr = "+++++++++++++++++++++++++++\n";
696 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:");
697 notesStr += additionalInfo;
698 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n");
699 notesStr += "+++++++++++++++++++++++++++\n";
700 notesStr += tempAdd;
701 }
702 addressee.setNote( notesStr );
703#if 0
704 // pending
705 - IM address: no clue where to get info about the helper ID
706 -custom fields: difficult to implement - not implemented
707 -keys: makes no sense
708#endif
709
710 if ( addAddressee( addressee ))
711 ++importedItems;
712}
713void KAImportOLdialog::slotCancel()
714{
715 reject();
716}
717
718bool KAImportOLdialog::addAddressee( KABC::Addressee a )
719{
720 bool add = true;
721 KABC::Addressee::List::Iterator it;
722 for ( it = mAList.begin(); it != mAList.end(); ++it ) {
723 if ( (*it).uid() == a.uid() ) {
724 add = false;
725 break;
726 }
727 }
728 if ( add ) {
729 if ( mABook->findByUid(a.uid() ).isEmpty())
730 mAList.append ( a );
731 else
732 add = false;
733 }
734 return add;
735}
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h
index 41ea5f8..278935b 100644
--- a/kaddressbook/kaimportoldialog.h
+++ b/kaddressbook/kaimportoldialog.h
@@ -11,75 +11,12 @@
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 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
33class QDateTime;
34class QListView;
35class OLEListViewItem;
36class _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*/
45class 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
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 5639aa2..df3b551 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -31,24 +31,25 @@
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qbuttongroup.h> 32#include <qbuttongroup.h>
33#include <qhbox.h> 33#include <qhbox.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qapplication.h> 36#include <qapplication.h>
37 37
38#include <kbuttonbox.h> 38#include <kbuttonbox.h>
39#include <klistview.h> 39#include <klistview.h>
40#include <kapplication.h> 40#include <kapplication.h>
41#include <qapplication.h> 41#include <qapplication.h>
42#include <kconfig.h> 42#include <kconfig.h>
43#include <kmessagebox.h>
43#include <klineedit.h> 44#include <klineedit.h>
44#include <kcombobox.h> 45#include <kcombobox.h>
45#include <klocale.h> 46#include <klocale.h>
46#include <kdebug.h> 47#include <kdebug.h>
47#include <kglobal.h> 48#include <kglobal.h>
48#include <kiconloader.h> 49#include <kiconloader.h>
49 50
50#include <kabc/phonenumber.h> 51#include <kabc/phonenumber.h>
51 52
52#include "typecombo.h" 53#include "typecombo.h"
53 54
54#include "phoneeditwidget.h" 55#include "phoneeditwidget.h"
@@ -103,29 +104,31 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
103 104
104PhoneEditWidget::~PhoneEditWidget() 105PhoneEditWidget::~PhoneEditWidget()
105{ 106{
106} 107}
107void PhoneEditWidget::setDefaults() 108void PhoneEditWidget::setDefaults()
108{ 109{
109 mTypeNumberEditList.clear(); 110 mTypeNumberEditList.clear();
110 PhoneTypeNumberEdit* edit = appendEditCombo(); 111 PhoneTypeNumberEdit* edit = appendEditCombo();
111 KABC::PhoneNumber phoneNumber; 112 KABC::PhoneNumber phoneNumber;
112 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); 113 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
113 edit->setPhoneNumber( phoneNumber ); 114 edit->setPhoneNumber( phoneNumber );
114 edit = appendEditCombo(); 115 edit = appendEditCombo();
115 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 116 KABC::PhoneNumber phoneNumber2;
116 edit->setPhoneNumber( phoneNumber ); 117 phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
118 edit->setPhoneNumber( phoneNumber2 );
117 edit = appendEditCombo(); 119 edit = appendEditCombo();
118 phoneNumber.setType( KABC::PhoneNumber::Cell ); 120 KABC::PhoneNumber phoneNumber3;
119 edit->setPhoneNumber( phoneNumber ); 121 phoneNumber3.setType( KABC::PhoneNumber::Cell );
122 edit->setPhoneNumber( phoneNumber3 );
120 123
121} 124}
122void PhoneEditWidget::addNumberInt( int index ) 125void PhoneEditWidget::addNumberInt( int index )
123{ 126{
124 PhoneTypeNumberEdit* edit = appendEditCombo(); 127 PhoneTypeNumberEdit* edit = appendEditCombo();
125 KABC::PhoneNumber phoneNumber; 128 KABC::PhoneNumber phoneNumber;
126 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 129 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
127 edit->setPhoneNumber( phoneNumber ); 130 edit->setPhoneNumber( phoneNumber );
128 //verticalScrollBar()->setValue( 1024); 131 //verticalScrollBar()->setValue( 1024);
129 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); 132 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) );
130} 133}
131void PhoneEditWidget::bottomVisible() 134void PhoneEditWidget::bottomVisible()
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index a69846c..ee17da8 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -47,24 +47,25 @@ class JournalEntry : public QFrame {
47 Journal *journal() const; 47 Journal *journal() const;
48 48
49 void setDate(const QDate &); 49 void setDate(const QDate &);
50 50
51 void clear(); 51 void clear();
52 52
53 void flushEntry(); 53 void flushEntry();
54 void setShowOnly(); 54 void setShowOnly();
55 QSize sizeHint() const; 55 QSize sizeHint() const;
56 void setVisibleMode( bool b ) { visibleMode = b;} 56 void setVisibleMode( bool b ) { visibleMode = b;}
57 void fillCalendar( int id = 0 ); 57 void fillCalendar( int id = 0 );
58 void resizeEvent(QResizeEvent* e ) ; 58 void resizeEvent(QResizeEvent* e ) ;
59 KTextEdit * editor() {return mEditor;};
59 protected slots: 60 protected slots:
60 void slotSaveTemplate(); 61 void slotSaveTemplate();
61 void slotLoadTemplate(); 62 void slotLoadTemplate();
62 void toggleShowJournal(); 63 void toggleShowJournal();
63 void setVisibleOn(); 64 void setVisibleOn();
64 signals: 65 signals:
65 void deleteJournal(Journal *); 66 void deleteJournal(Journal *);
66 void newJournal(); 67 void newJournal();
67 void showJournalOnly( Journal * ); 68 void showJournalOnly( Journal * );
68 69
69 protected: 70 protected:
70 bool eventFilter( QObject *o, QEvent *e ); 71 bool eventFilter( QObject *o, QEvent *e );
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index a23a3b2..406df5a 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -28,24 +28,25 @@
28#include <qscrollview.h> 28#include <qscrollview.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30#include <qhbox.h> 30#include <qhbox.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qapplication.h> 34#include <qapplication.h>
35 35
36#include <klocale.h> 36#include <klocale.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include "koprefs.h" 38#include "koprefs.h"
39#include <kglobal.h> 39#include <kglobal.h>
40#include <ktextedit.h>
40 41
41#include <libkcal/calendar.h> 42#include <libkcal/calendar.h>
42 43
43#include "journalentry.h" 44#include "journalentry.h"
44 45
45#include "kojournalview.h" 46#include "kojournalview.h"
46using namespace KOrg; 47using namespace KOrg;
47 48
48KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 49KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
49 const char *name) 50 const char *name)
50 : KOrg::BaseView(calendar, parent, name) 51 : KOrg::BaseView(calendar, parent, name)
51{ 52{
@@ -168,39 +169,47 @@ void KOJournalView::showOnly ( Journal* j )
168 mEntry->setShowOnly(); 169 mEntry->setShowOnly();
169} 170}
170void KOJournalView::showList(QPtrList<Journal> jl) 171void KOJournalView::showList(QPtrList<Journal> jl)
171{ 172{
172 static bool ff = false; 173 static bool ff = false;
173 if ( ff ) return; 174 if ( ff ) return;
174 ff = true; 175 ff = true;
175 //qDebug("KOJournalView::showList %d",jl.count() ); 176 //qDebug("KOJournalView::showList %d",jl.count() );
176 JournalEntry* mEntry = jEntries.first(); 177 JournalEntry* mEntry = jEntries.first();
177 JournalEntry* firstEntry = mEntry; 178 JournalEntry* firstEntry = mEntry;
178 int count = jl.count(); 179 int count = jl.count();
179 int iii = 0; 180 int iii = 0;
181 QWidget* fw = qApp->focusWidget ();
180 while ( iii < count ) { 182 while ( iii < count ) {
181 if ( !mEntry ) { 183 if ( !mEntry ) {
182 mEntry = getNewEntry(); 184 mEntry = getNewEntry();
183 mEntry->setVisibleMode( true ); 185 mEntry->setVisibleMode( true );
184 mEntry->setDate(mDate); 186 mEntry->setDate(mDate);
185 mEntry->setJournal(jl.at(iii), false); 187 mEntry->setJournal(jl.at(iii), false);
186 mEntry->setVisibleMode( true ); 188 mEntry->setVisibleMode( true );
187 mEntry->show(); 189 mEntry->show();
188 mEntry = 0; 190 mEntry = 0;
189 } else { 191 } else {
192 int xxx = -1, yyy = -1;
193 if ( ((QWidget*) mEntry->editor() ) == fw ) {
194 mEntry->editor()->getCursorPosition( &xxx,&yyy);
195 }
190 mEntry->setVisibleMode( true ); 196 mEntry->setVisibleMode( true );
191 mEntry->setDate(mDate); 197 mEntry->setDate(mDate);
192 mEntry->setJournal(jl.at(iii), false); 198 mEntry->setJournal(jl.at(iii), false);
193 mEntry->setVisibleMode( true ); 199 mEntry->setVisibleMode( true );
194 mEntry->show(); 200 mEntry->show();
201 if ( xxx > -1 && yyy > -1 ) {
202 mEntry->editor()->setCursorPosition( xxx, yyy );
203 }
195 mEntry = jEntries.next(); 204 mEntry = jEntries.next();
196 } 205 }
197 ++iii; 206 ++iii;
198 } 207 }
199 while ( mEntry ) { 208 while ( mEntry ) {
200 mEntry->setDate(mDate); 209 mEntry->setDate(mDate);
201 mEntry->clear(); 210 mEntry->clear();
202 if ( mEntry != firstEntry ) { 211 if ( mEntry != firstEntry ) {
203 mEntry->hide(); 212 mEntry->hide();
204 mEntry->setVisibleMode( false ); 213 mEntry->setVisibleMode( false );
205 } 214 }
206 else { 215 else {
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 59be506..f376e6c 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -838,24 +838,26 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e
838 int i = 0; 838 int i = 0;
839 while ( i < list.count ( ) ) { 839 while ( i < list.count ( ) ) {
840 //qDebug("add%sdd ",list[i].latin1() ); 840 //qDebug("add%sdd ",list[i].latin1() );
841 proc->addArgument( list[i] ); 841 proc->addArgument( list[i] );
842 //KMessageBox::sorry( 0,list[i]); 842 //KMessageBox::sorry( 0,list[i]);
843 ++i; 843 ++i;
844 } 844 }
845 } else { 845 } else {
846 proc->addArgument(message ); 846 proc->addArgument(message );
847 847
848 } 848 }
849 parameters = translateMessage(parameters, name, emailadress); 849 parameters = translateMessage(parameters, name, emailadress);
850
851 //KMessageBox::information(0,parameters);
850 proc->addArgument( parameters ); 852 proc->addArgument( parameters );
851 proc->launch(""); 853 proc->launch("");
852#endif 854#endif
853 855
854 return true; 856 return true;
855} 857}
856 858
857/************************************************************************** 859/**************************************************************************
858 * 860 *
859 **************************************************************************/ 861 **************************************************************************/
860 862
861//calls the emailapplication and creates a mail with parameter as recipients 863//calls the emailapplication and creates a mail with parameter as recipients
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index b7929ec..5708dfc 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -103,25 +103,25 @@ void KSyncManager::fillSyncMenu()
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
@@ -134,25 +134,25 @@ void KSyncManager::fillSyncMenu()
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
@@ -925,26 +925,92 @@ void KSyncManager::confSync()
925#endif 925#endif
926 sp->exec(); 926 sp->exec();
927 QStringList oldSyncProfileNames = mSyncProfileNames; 927 QStringList oldSyncProfileNames = mSyncProfileNames;
928 mSyncProfileNames = sp->getSyncProfileNames(); 928 mSyncProfileNames = sp->getSyncProfileNames();
929 mLocalMachineName = sp->getLocalMachineName (); 929 mLocalMachineName = sp->getLocalMachineName ();
930 uint ii; 930 uint ii;
931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
934 } 934 }
935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
936} 936}
937void KSyncManager::syncOL()
938{
939 mSyncWithDesktop = true;
940 emit save();
941 switch(mTargetApp)
942 {
943 case (KAPI):
944 {
945 syncExternalApplication("ol");
946 }
947 break;
948 case (KOPI):
949 {
950#ifdef DESKTOP_VERSION
951 QString command = "kdecaldump33";
952 QString commandfile = "kdecaldump33";
953 QString commandpath = qApp->applicationDirPath () + "/";
954#else
955 QString command = "kdecaldump33";
956 QString commandfile = "kdecaldump33";
957 QString commandpath = QDir::homeDirPath ()+"/";
958#endif
959 if ( ! QFile::exists ( commandpath+commandfile ) )
960 command = commandfile;
961 else
962 command = commandpath+commandfile;
963
964 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
965 int result = system ( command.latin1());
966 qDebug("Cal dump 33 command call result result: %d ", result);
967 if ( result != 0 ) {
968 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
969 commandfile = "kdecaldump34";
970 if ( ! QFile::exists ( commandpath+commandfile ) )
971 command = commandfile;
972 else
973 command = commandpath+commandfile;
974 result = system ( command.latin1());
975 qDebug("Cal dump 34 command call result result: %d ", result);
976 if ( result != 0 ) {
977 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
978 return;
979 }
980 }
981 if ( syncWithFile( fileName,true ) ) {
982 if ( mWriteBackFile ) {
983 command += " --read";
984 system ( command.latin1());
985 }
986 }
987
988 }
989 break;
990 case (PWMPI):
991
992 break;
993 default:
994 qDebug("KSM::slotSyncMenu: invalid apptype selected");
995 break;
996
997 }
998}
937void KSyncManager::syncKDE() 999void KSyncManager::syncKDE()
938{ 1000{
1001#ifdef _WIN32_
1002 syncOL();
1003#else
1004
939 mSyncWithDesktop = true; 1005 mSyncWithDesktop = true;
940 emit save(); 1006 emit save();
941 switch(mTargetApp) 1007 switch(mTargetApp)
942 { 1008 {
943 case (KAPI): 1009 case (KAPI):
944 { 1010 {
945#ifdef DESKTOP_VERSION 1011#ifdef DESKTOP_VERSION
946 QString command = "kdeabdump33"; 1012 QString command = "kdeabdump33";
947 QString commandfile = "kdeabdump33"; 1013 QString commandfile = "kdeabdump33";
948 QString commandpath = qApp->applicationDirPath () + "/"; 1014 QString commandpath = qApp->applicationDirPath () + "/";
949#else 1015#else
950 QString command = "kdeabdump33"; 1016 QString command = "kdeabdump33";
@@ -1023,24 +1089,25 @@ void KSyncManager::syncKDE()
1023 } 1089 }
1024 1090
1025 } 1091 }
1026 break; 1092 break;
1027 case (PWMPI): 1093 case (PWMPI):
1028 1094
1029 break; 1095 break;
1030 default: 1096 default:
1031 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1097 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1032 break; 1098 break;
1033 1099
1034 } 1100 }
1101#endif
1035} 1102}
1036 1103
1037void KSyncManager::syncSharp() 1104void KSyncManager::syncSharp()
1038{ 1105{
1039 1106
1040 if ( ! syncExternalApplication("sharp") ) 1107 if ( ! syncExternalApplication("sharp") )
1041 qDebug("KSM::ERROR sync sharp "); 1108 qDebug("KSM::ERROR sync sharp ");
1042} 1109}
1043 1110
1044bool KSyncManager::syncExternalApplication(QString resource) 1111bool KSyncManager::syncExternalApplication(QString resource)
1045{ 1112{
1046 1113
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 04cdade..71d17e9 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -194,24 +194,25 @@ class KSyncManager : public QObject
194 void syncPi(); 194 void syncPi();
195 KServerSocket * mServerSocket; 195 KServerSocket * mServerSocket;
196 KPimPrefs* mPrefs; 196 KPimPrefs* mPrefs;
197 QString mDefFileName; 197 QString mDefFileName;
198 QString mCurrentSyncDevice; 198 QString mCurrentSyncDevice;
199 QString mCurrentSyncName; 199 QString mCurrentSyncName;
200 void quickSyncLocalFile(); 200 void quickSyncLocalFile();
201 bool syncWithFile( QString fn , bool quick ); 201 bool syncWithFile( QString fn , bool quick );
202 void syncLocalFile(); 202 void syncLocalFile();
203 void syncPhone(); 203 void syncPhone();
204 void syncSharp(); 204 void syncSharp();
205 void syncKDE(); 205 void syncKDE();
206 void syncOL();
206 bool syncExternalApplication(QString); 207 bool syncExternalApplication(QString);
207 int mCurrentSyncProfile ; 208 int mCurrentSyncProfile ;
208 void syncRemote( KSyncProfile* prof, bool ask = true); 209 void syncRemote( KSyncProfile* prof, bool ask = true);
209 bool edit_sync_options(); 210 bool edit_sync_options();
210 bool edit_pisync_options(); 211 bool edit_pisync_options();
211 int ringSync(); 212 int ringSync();
212 QString getPassword( ); 213 QString getPassword( );
213 bool mPisyncFinished; 214 bool mPisyncFinished;
214 QStringList mSpecificResources; 215 QStringList mSpecificResources;
215 QString mCurrentResourceLocal; 216 QString mCurrentResourceLocal;
216 QString mCurrentResourceRemote; 217 QString mCurrentResourceRemote;
217 bool mBlockSaveFlag; 218 bool mBlockSaveFlag;
@@ -232,18 +233,16 @@ private slots:
232 233
233class KSyncInterface 234class KSyncInterface
234{ 235{
235 public : 236 public :
236 virtual void removeSyncInfo( QString syncProfile) = 0; 237 virtual void removeSyncInfo( QString syncProfile) = 0;
237 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; 238 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
238 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) 239 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/)
239 { 240 {
240 // empty implementation, because some syncable applications do not 241 // empty implementation, because some syncable applications do not
241 // have an external(sharpdtm) syncmode, like pwmanager. 242 // have an external(sharpdtm) syncmode, like pwmanager.
242 return false; 243 return false;
243 } 244 }
244
245
246}; 245};
247 246
248 247
249#endif 248#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 84af7ad..7160d0e 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -49,13 +49,28 @@ SOURCES = \
49 kinputdialog.cpp \ 49 kinputdialog.cpp \
50 kpimprefs.cpp \ 50 kpimprefs.cpp \
51 kpimglobalprefs.cpp \ 51 kpimglobalprefs.cpp \
52 kprefsdialog.cpp \ 52 kprefsdialog.cpp \
53 kprefswidget.cpp \ 53 kprefswidget.cpp \
54 ksyncmanager.cpp \ 54 ksyncmanager.cpp \
55 ksyncprofile.cpp \ 55 ksyncprofile.cpp \
56 ksyncprefsdialog.cpp \ 56 ksyncprefsdialog.cpp \
57 kcmconfigs/kcmkdepimconfig.cpp \ 57 kcmconfigs/kcmkdepimconfig.cpp \
58 kcmconfigs/kdepimconfigwidget.cpp \ 58 kcmconfigs/kdepimconfigwidget.cpp \
59 phoneaccess.cpp 59 phoneaccess.cpp
60 60
61win32: {
61 62
63#olimport section
64importol {
65debug: {
66LIBS += mfc71ud.lib
67}
68release: {
69LIBS += mfc71u.lib
70}
71DEFINES += _OL_IMPORT_
72HEADERS += ol_access.h
73SOURCES += ol_access.cpp
74#olimport section end
75}
76}