summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2006-02-24 18:49:56 (UTC)
committer zautrix <zautrix>2006-02-24 18:49:56 (UTC)
commitd7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (side-by-side diff)
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
@@ -917,84 +917,102 @@ void AddressBook::removeAddressee( const Iterator &it )
AddressBook::Iterator AddressBook::find( const Addressee &a )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( a.uid() == (*it).uid() ) {
return it;
}
}
return end();
}
Addressee AddressBook::findByUid( const QString &uid )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( uid == (*it).uid() ) {
return *it;
}
}
return Addressee();
}
void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
{
//qDebug("AddressBook::preExternSync ");
AddressBook::Iterator it;
for ( it = begin(); it != end(); ++it ) {
(*it).setID( csd, (*it).externalUID() );
(*it).computeCsum( csd );
}
mergeAB( aBook ,csd, isSubset );
}
+void AddressBook::preOLSync( AddressBook* aBook, const QString& csd )
+{
+ //qDebug("AddressBook::preExternSync ");
+ AddressBook::Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ (*it).setID( csd, (*it).externalUID() );
+ (*it).computeCsum( csd );
+ }
+
+ Addressee ad;
+ for ( it = begin(); it != end(); ++it ) {
+ ad = aBook->findByExternUid( (*it).externalUID(), csd );
+ if ( !ad.isEmpty() ) {
+ (*it).mergeOLContact( ad );
+ }
+ }
+}
void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
{
//qDebug("AddressBook::postExternSync ");
AddressBook::Iterator it;
int foundEmpty = 0;
for ( it = begin(); it != end(); ++it ) {
//qDebug("check uid %s ", (*it).uid().latin1() );
if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
(*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
(*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
Addressee ad = aBook->findByUid( ( (*it).uid() ));
if ( ad.isEmpty() ) {
++foundEmpty;
//qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
//qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
} else {
(*it).setIDStr(":");
if ( setID ) {
- if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
- ad.setID( csd, (*it).externalUID() );
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
+ ad.setID( csd, (*it).externalUID() );{
+ }
} else
ad.setID( csd, (*it).uid() );
(*it).computeCsum( csd );
ad.setCsum( csd, (*it).getCsum( csd ) );
//qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
aBook->insertAddressee( ad , false);
}
}
}
if ( foundEmpty ) {
qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
}
}
bool AddressBook::containsExternalUid( const QString& uid )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( uid == (*it).externalUID( ) )
return true;
}
return false;
}
const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const
{
ConstIterator it;
for ( it = begin(); it != end(); ++it ) {
if ( uid == (*it).getID( profile ) )
return (*it);
}
return Addressee();
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e6daa5e..a8a9fc1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -279,64 +279,65 @@ class AddressBook : public QObject
/**
Return pointer list of all resources.
*/
QPtrList<Resource> resources();
/**
Set the @p ErrorHandler, that is used by @ref error() to
provide gui-independend error messages.
*/
void setErrorHandler( ErrorHandler * );
/**
Shows gui independend error messages.
*/
void error( const QString& );
/**
Query all resources to clean up their lock files
*/
void cleanUp();
// sync stuff
//Addressee::List getExternLastSyncAddressees();
void resetTempSyncStat();
QStringList uidList();
void removeSyncAddressees( bool removeDeleted = false );
void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
const Addressee findByExternUid( const QString& uid , const QString& profile ) const;
bool containsExternalUid( const QString& uid );
void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
+ void preOLSync( AddressBook* aBook, const QString& csd);
void postExternSync( AddressBook* aBook, const QString& csd , bool setID );
signals:
/**
Emitted, when the address book has changed on disk.
*/
void addressBookChanged( AddressBook * );
/**
Emitted, when the address book has been locked for writing.
*/
void addressBookLocked( AddressBook * );
/**
Emitted, when the address book has been unlocked.
*/
void addressBookUnlocked( AddressBook * );
protected:
void deleteRemovedAddressees();
void setStandardResource( Resource * );
Resource *standardResource();
KRES::Manager<Resource> *resourceManager();
void init(const QString &config, const QString &family);
private:
//US QPtrList<Resource> mDummy; // Remove in KDE 4
struct AddressBookData;
AddressBookData *d;
bool blockLSEchange;
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 6cfac80..e8e440c 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -3,64 +3,65 @@
This file is part of libkabc.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <kconfig.h>
#include <ksharedptr.h>
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>
+#include <kmessagebox.h>
#include <kidmanager.h>
//US
#include <kstandarddirs.h>
#include <libkcal/syncdefines.h>
//US #include "resource.h"
#include "addressee.h"
using namespace KABC;
static bool matchBinaryPattern( int value, int pattern );
static bool matchBinaryPatternA( int value, int pattern );
static bool matchBinaryPatternP( int value, int pattern );
struct Addressee::AddresseeData : public KShared
{
QString uid;
QString name;
QString formattedName;
QString familyName;
QString givenName;
QString additionalName;
QString prefix;
QString suffix;
QString nickName;
QDateTime birthday;
QString mailer;
TimeZone timeZone;
Geo geo;
QString title;
QString role;
QString organization;
@@ -182,65 +183,65 @@ ulong Addressee::getCsum4List( const QStringList & attList)
{
int max = attList.count();
ulong cSum = 0;
int j,k,i;
int add;
for ( i = 0; i < max ; ++i ) {
QString s = attList[i];
if ( ! s.isEmpty() ){
j = s.length();
for ( k = 0; k < j; ++k ) {
int mul = k +1;
add = s[k].unicode ();
if ( k < 16 )
mul = mul * mul;
int ii = i+1;
add = add * mul *ii*ii*ii;
cSum += add;
//qDebug("csum: %d %d %d", i,k,cSum);
}
}
}
//QString dump = attList.join(",");
//qDebug("csum: %d %s", cSum,dump.latin1());
return cSum;
}
void Addressee::computeCsum(const QString &dev)
{
QStringList l;
//if ( !mData->name.isEmpty() ) l.append(mData->name);
- //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
+ if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
if ( !mData->title .isEmpty() ) l.append( mData->title );
if ( !mData->role.isEmpty() ) l.append( mData->role );
if ( !mData->organization.isEmpty() ) l.append( mData->organization );
if ( !mData->note.isEmpty() ) l.append( mData->note );
if ( !mData->productId.isEmpty() ) l.append(mData->productId );
if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
if ( !mData->logo.undefined() ) {
if ( !mData->logo.isIntern() )
l.append( mData->logo.url() );
else
l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
} else {
l.append( "nologo");
}
if ( !mData->photo.undefined() ) {
if ( !mData->photo.isIntern() )
l.append( mData->photo.url() );
else
l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
} else {
l.append( "nophoto");
@@ -303,64 +304,111 @@ void Addressee::computeCsum(const QString &dev)
qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
#endif
setCsum( dev, QString::number (cs ));
}
bool Addressee::matchAddress( QRegExp* re ) const
{
KABC::Address::List::Iterator addressIter;
for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
++addressIter ) {
if ( (*addressIter).matchAddress( re ) )
return true;
}
return false;
}
bool Addressee::matchPhoneNumber( QRegExp* re ) const
{
KABC::PhoneNumber::List::Iterator phoneIter;
for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
#if QT_VERSION >= 0x030000
if (re->search( (*phoneIter).number() ) == 0)
#else
if (re->match( (*phoneIter).number() ) == 0)
#endif
return true;
}
return false;
}
+void Addressee::mergeOLContact( const Addressee& ad )
+{
+ if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
+ if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
+ if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
+ if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
+ if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
+ if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
+ if ( !mData->sound.isIntern() ) {
+ if ( mData->sound.url().isEmpty() ) {
+ mData->sound = ad.mData->sound;
+ }
+ }
+ if ( !mData->agent.isIntern() ) {
+ if ( mData->agent.url().isEmpty() ) {
+ mData->agent = ad.mData->agent;
+ }
+ }
+ {
+ Key::List::Iterator itA;
+ for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
+ bool found = false;
+ Key::List::Iterator it;
+ for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
+ if ( (*it) == (*itA)) {
+ found = true;
+ break;
+
+ }
+ }
+ if ( ! found ) {
+ mData->keys.append( *itA );
+ }
+ }
+ }
+
+ KABC::Address addthis = otherAddress();
+ KABC::Address addother = ad.otherAddress();
+ if ( !addthis.isEmpty() && !addother.isEmpty() )
+ addthis.setType( addother.type() );
+ //qDebug("merge contact %s ", ad.uid().latin1());
+ setUid( ad.uid() );
+ setRevision( ad.revision() );
+
+
+}
+
void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
// merge all standard non-outlook fields.
//if isSubSet (e.g. mobile phone sync) merge all fields
detach();
if ( isSubSet ) {
if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
if ( !mData->birthday.isValid() )
if ( ad.mData->birthday.isValid())
mData->birthday = ad.mData->birthday;
}
if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
QStringList t;
@@ -1624,65 +1672,64 @@ void Addressee::insertEmail( const QString &email, bool preferred )
}
}
}
void Addressee::removeEmail( const QString &email )
{
detach();
QStringList::Iterator it = mData->emails.find( email );
if ( it == mData->emails.end() ) return;
mData->emails.remove( it );
}
QString Addressee::preferredEmail() const
{
if ( mData->emails.count() == 0 ) return QString::null;
else return mData->emails.first();
}
QStringList Addressee::emails() const
{
return mData->emails;
}
void Addressee::setEmails( const QStringList& emails ) {
detach();
mData->emails = emails;
}
void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
{
detach();
mData->empty = false;
-
PhoneNumber::List::Iterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( (*it).id() == phoneNumber.id() ) {
*it = phoneNumber;
return;
}
}
mData->phoneNumbers.append( phoneNumber );
}
void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
{
detach();
PhoneNumber::List::Iterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( (*it).id() == phoneNumber.id() ) {
mData->phoneNumbers.remove( it );
return;
}
}
}
PhoneNumber Addressee::phoneNumber( int type ) const
{
PhoneNumber phoneNumber( "", type );
PhoneNumber::List::ConstIterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( matchBinaryPatternP( (*it).type(), type ) ) {
if ( (*it).type() & PhoneNumber::Pref )
return (*it);
else if ( phoneNumber.number().isEmpty() )
@@ -1691,64 +1738,75 @@ PhoneNumber Addressee::phoneNumber( int type ) const
}
return phoneNumber;
}
PhoneNumber::List Addressee::phoneNumbers() const
{
return mData->phoneNumbers;
}
int Addressee::hasPhoneNumberType( int type )
{
int retval = 0;
PhoneNumber::List::ConstIterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( (*it).type() == type )
++retval;
}
return retval;
}
PhoneNumber::List Addressee::phoneNumbers( int type ) const
{
PhoneNumber::List list;
PhoneNumber::List::ConstIterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( matchBinaryPattern( (*it).type(), type ) ) {
list.append( *it );
}
}
return list;
}
+QString Addressee::phoneNumberString( int type ) const
+{
+
+ PhoneNumber::List::ConstIterator it;
+ for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
+ if ((*it).type() == type ) {
+ return ( *it ).number();
+ }
+ }
+ return "";
+}
PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
{
PhoneNumber::List::ConstIterator it;
for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
if ( (*it).id() == id ) {
return *it;
}
}
return PhoneNumber();
}
void Addressee::insertKey( const Key &key )
{
detach();
mData->empty = false;
Key::List::Iterator it;
for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
if ( (*it).id() == key.id() ) {
*it = key;
return;
}
}
mData->keys.append( key );
}
void Addressee::removeKey( const Key &key )
{
detach();
Key::List::Iterator it;
@@ -1896,65 +1954,76 @@ void Addressee::dump() const
kdDebug(5700) << "}" << endl;
#endif
}
void Addressee::insertAddress( const Address &address )
{
detach();
mData->empty = false;
Address::List::Iterator it;
for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
if ( (*it).id() == address.id() ) {
*it = address;
return;
}
}
mData->addresses.append( address );
}
void Addressee::removeAddress( const Address &address )
{
detach();
Address::List::Iterator it;
for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
if ( (*it).id() == address.id() ) {
mData->addresses.remove( it );
return;
}
}
}
-
+Address Addressee::otherAddress() const
+{
+ Address::List::ConstIterator it;
+ for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
+ if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) )
+ continue;
+ if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) )
+ continue;
+ return (*it);
+ }
+ return Address();
+}
Address Addressee::address( int type ) const
{
Address address( type );
Address::List::ConstIterator it;
for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
if ( matchBinaryPatternA( (*it).type(), type ) ) {
if ( (*it).type() & Address::Pref )
return (*it);
else if ( address.isEmpty() )
address = (*it);
}
}
return address;
}
Address::List Addressee::addresses() const
{
return mData->addresses;
}
Address::List Addressee::addresses( int type ) const
{
Address::List list;
Address::List::ConstIterator it;
for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
if ( matchBinaryPattern( (*it).type(), type ) ) {
list.append( *it );
}
}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index aac78dc..0ea1803 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -89,64 +89,65 @@ class Addressee
/**
Construct an empty address book entry.
*/
Addressee();
~Addressee();
Addressee( const Addressee & );
Addressee &operator=( const Addressee & );
bool operator==( const Addressee & ) const;
bool operator!=( const Addressee & ) const;
// sync stuff
void setTempSyncStat(int id);
int tempSyncStat() const;
void setIDStr( const QString & );
const QString IDStr() const;
void setID( const QString &, const QString & );
const QString getID( const QString & ) const;
void setCsum( const QString &, const QString & );
const QString getCsum( const QString & ) const ;
void removeID(const QString &);
void computeCsum(const QString &dev);
ulong getCsum4List( const QStringList & attList);
/**
Return, if the address book entry is empty.
*/
bool isEmpty() const;
void setExternalUID( const QString &id );
const QString externalUID() const;
void setOriginalExternalUID( const QString &id );
QString originalExternalUID() const;
void mergeContact( const Addressee& ad, bool isSubSet );
+ void mergeOLContact( const Addressee& ad );
void simplifyEmails();
void simplifyAddresses();
void simplifyPhoneNumbers();
void simplifyPhoneNumberTypes();
void makePhoneNumbersOLcompatible();
int hasPhoneNumberType( int type );
bool removeVoice();
bool containsAdr(const Addressee& addr );
/**
Set unique identifier.
*/
void setUid( const QString &uid );
/**
Return unique identifier.
*/
const QString uid() const;
/**
Return translated label for uid field.
*/
static QString uidLabel();
/**
Set name.
*/
void setName( const QString &name );
/**
Return name.
*/
QString name() const;
/**
Return translated label for name field.
@@ -618,64 +619,65 @@ class Addressee
last one added with @ref insertEmail() with a set preferred parameter.
*/
QString preferredEmail() const;
/**
Return list of all email addresses.
*/
QStringList emails() const;
/**
Set the emails to @param.
The first email address gets the preferred one!
@param list The list of email addresses.
*/
void setEmails( const QStringList& list);
/**
Insert a phone number. If a phone number with the same id already exists
in this addressee it is not duplicated.
*/
void insertPhoneNumber( const PhoneNumber &phoneNumber );
/**
Remove phone number. If no phone number with the given id exists for this
addresse nothing happens.
*/
void removePhoneNumber( const PhoneNumber &phoneNumber );
/**
Return phone number, which matches the given type.
*/
PhoneNumber phoneNumber( int type ) const;
+ QString phoneNumberString( int type ) const;
bool matchPhoneNumber( QRegExp* searchExp ) const;
bool matchAddress( QRegExp* searchExp ) const;
/**
Return list of all phone numbers.
*/
PhoneNumber::List phoneNumbers() const;
/**
Return list of phone numbers with a special type.
*/
PhoneNumber::List phoneNumbers( int type ) const;
/**
Return phone number with the given id.
*/
PhoneNumber findPhoneNumber( const QString &id ) const;
/**
Insert a key. If a key with the same id already exists
in this addressee it is not duplicated.
*/
void insertKey( const Key &key );
/**
Remove a key. If no key with the given id exists for this
addresse nothing happens.
*/
void removeKey( const Key &key );
/**
@@ -702,65 +704,65 @@ class Addressee
If @p type == Key::Custom you can specify a string
that should match. If you leave the string empty, all custom
keys will be returned.
*/
Key::List keys( int type, QString customTypeString = QString::null ) const;
/**
Return key with the given id.
*/
Key findKey( const QString &id ) const;
/**
Insert an address. If an address with the same id already exists
in this addressee it is not duplicated.
*/
void insertAddress( const Address &address );
/**
Remove address. If no address with the given id exists for this
addresse nothing happens.
*/
void removeAddress( const Address &address );
/**
Return address, which matches the given type.
*/
Address address( int type ) const;
/**
Return list of all addresses.
*/
Address::List addresses() const;
-
+ Address otherAddress() const;
/**
Return list of addresses with a special type.
*/
Address::List addresses( int type ) const;
/**
Return address with the given id.
*/
Address findAddress( const QString &id ) const;
/**
Insert category. If the category already exists it is not duplicated.
*/
void insertCategory( const QString & );
/**
Remove category.
*/
void removeCategory( const QString & );
/**
Return, if addressee has the given category.
*/
bool hasCategory( const QString & ) const;
/**
Set categories to given value.
*/
void setCategories( const QStringList & );
/**
Return list of all set categories.
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 12b9b09..1752745 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -203,64 +203,88 @@ QString PhoneNumber::typeLabel() const
for ( it = list.begin(); it != list.end(); ++it ) {
if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
if ( first )
first = false;
}
}
return label;
}
QString PhoneNumber::label() const
{
return typeLabel( type() );
}
PhoneNumber::TypeList PhoneNumber::typeList()
{
TypeList list;
list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
<< Bbs << Modem << Car << Isdn << Pcs << Pager;
return list;
}
PhoneNumber::TypeList PhoneNumber::supportedTypeList()
{
static TypeList list;
if ( list.count() == 0 )
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;
return list;
}
+
+#if 0
+Home| Pref i18n("Home") Home
+Work| Pref i18n("Work") Business
+Cell i18n("Mobile") Mobile
+Pcs|Pref i18n("SiP") Radio
+Pcs|Voice i18n("VoIP") TTY/TTD
+Home i18n("Home2") Home 2
+Work i18n("Work2") Business 2
+Car i18n("Mobile2") Car
+Pcs i18n("SiP2") Telex
+Work| Msg | Voice i18n("Assistent") Assistent
+Work| Msg i18n("Company") Company
+Home | Fax i18n("Fax (Home)") Home Fax
+Work| Fax i18n("Fax (Work)") Business Fax
+Fax i18n("Fax (Other)") Other Fax
+Pager i18n("Pager") Pager
+Isdn i18n("ISDN") Isdn
+Msg i18n("Callback") Callback
+Pref i18n("Primary") Primary
+Voice; i18n("Other") Other
+
+#endif
+
QStringList PhoneNumber::supportedTypeListNames()
{
static QStringList list;
if ( list.count() == 0 )
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");
return list;
}
int PhoneNumber::typeListIndex4Type(int type )
{
TypeList list = supportedTypeList();
int i = 0;
while ( i < list.count() ) {
if ( list [i] == type )
return i;
++i;
}
return list.count()-1;
}
QString PhoneNumber::label( int type )
{
return typeLabel( type );
}
QString PhoneNumber::typeLabel( int type )
{
if ((type & Cell) == Cell)
return i18n("Mobile");
if ((type & Home) == Home) {
if ((type & Pref) == Pref)
return i18n("Home");
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7d8586a..ab2824c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -129,64 +129,65 @@ $Id$
#include <qmap.h>
#include <qdir.h>
#include <qfile.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qclipboard.h>
#include <qtextstream.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkdepim/categoryeditdialog.h>
#include <kabc/vcardconverter.h>
#include "addresseeutil.h"
#include "undocmds.h"
#include "addresseeeditordialog.h"
#include "viewmanager.h"
#include "details/detailsviewcontainer.h"
#include "kabprefs.h"
#include "xxportmanager.h"
#include "incsearchwidget.h"
#include "jumpbuttonbar.h"
#include "extensionmanager.h"
#include "addresseeconfig.h"
#include "nameeditdialog.h"
#include <kcmultidialog.h>
#ifdef _WIN32_
#ifdef _OL_IMPORT_
#include "kaimportoldialog.h"
+#include <libkdepim/ol_access.h>
#endif
#else
#include <unistd.h>
#endif
// sync includes
#include <libkdepim/ksyncprofile.h>
#include <libkdepim/ksyncprefsdialog.h>
class KABCatPrefs : public QDialog
{
public:
KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
{
setCaption( i18n("Manage new Categories") );
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setSpacing( 3 );
lay->setMargin( 3 );
QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
lay->addWidget( lab );
QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
lay->addWidget( format );
format->setExclusive ( true ) ;
addCatBut = new QRadioButton(i18n("Add to category list"), format );
new QRadioButton(i18n("Remove from addressees"), format );
addCatBut->setChecked( true );
QPushButton * ok = new QPushButton( i18n("OK"), this );
lay->addWidget( ok );
QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
@@ -1340,90 +1341,138 @@ void KABCore::addEmail( QString aStr )
QStringList emailList;
KABC::AddressBook::Iterator it;
for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
emailList = (*it).emails();
if ( emailList.contains( email ) > 0 ) {
found = true;
(*it).setNameFromString( fullName );
editContact( (*it).uid() );
}
}
if ( !found ) {
KABC::Addressee addr;
addr.setNameFromString( fullName );
addr.insertEmail( email, true );
mAddressBook->insertAddressee( addr );
mViewManager->refreshView( addr.uid() );
editContact( addr.uid() );
}
#else //KAB_EMBEDDED
qDebug("KABCore::addEmail finsih method");
#endif //KAB_EMBEDDED
}
void KABCore::importVCard( const KURL &url, bool showPreview )
{
mXXPortManager->importVCard( url, showPreview );
}
void KABCore::importFromOL()
{
#ifdef _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 );
}
//US added a second method without defaultparameter
void KABCore::editContact2() {
editContact( QString::null );
}
void KABCore::editContact( const QString &uid )
{
if ( mExtensionManager->isQuickEditVisible() )
return;
// First, locate the contact entry
QString localUID = uid;
if ( localUID.isNull() ) {
QStringList uidList = mViewManager->selectedUids();
if ( uidList.count() > 0 )
localUID = *( uidList.at( 0 ) );
}
KABC::Addressee addr = mAddressBook->findByUid( localUID );
if ( !addr.isEmpty() ) {
mEditorDialog->setAddressee( addr );
KApplication::execDialog ( mEditorDialog );
}
}
/**
@@ -3345,70 +3394,107 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString res
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
syncManager->hideProgressBar();
if ( syncOK ) {
if ( syncManager->mWriteBackFile )
{
if ( external )
abLocal.removeSyncAddressees( !isXML);
qDebug("KA: Sync::Saving remote AB ");
if ( ! abLocal.saveAB())
qDebug("KA: sync::Error writing back AB to file ");
if ( external ) {
// afterwrite processing
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
}
}
}
setModified();
}
abLocal.removeResources();
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
void KABCore::removeSyncInfo( QString syncProfile)
{
qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
mAddressBook->removeSyncInfo( 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 ");
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal( resource,"syncContact");
bool syncOK = false;
message(i18n("Loading DTM address data..."), false);
if ( abLocal.load() ) {
qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
message(i18n("Sync preprocessing..."),false);
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
message(i18n("Synchronizing..."),false);
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
syncManager->hideProgressBar();
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( false );
message(i18n("Saving DTM address data..."),false);
abLocal.saveAB();
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("DTM syncing finished."));
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e69cb60..ec6a9ec 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -486,50 +486,55 @@ class KABCore : public QWidget, public KSyncInterface
KAction *mActionDeleteView;
QPopupMenu *viewMenu;
QPopupMenu *filterMenu;
QPopupMenu *settingsMenu;
QPopupMenu *changeMenu;
QPopupMenu *beamMenu;
//US QAction *mActionSave;
QPopupMenu *ImportMenu;
QPopupMenu *ExportMenu;
//LR additional methods
KAction *mActionRemoveVoice;
KAction *mActionSetFormattedName;
KAction * mActionImportOL;
#ifndef KAB_EMBEDDED
KAddressBookService *mAddressBookService;
#endif //KAB_EMBEDDED
class KABCorePrivate;
KABCorePrivate *d;
//US bool mBlockSaveFlag;
#ifdef KAB_EMBEDDED
KAddressBookMain *mMainWindow; // should be the same like mGUIClient
#endif //KAB_EMBEDDED
//this are the overwritten callbackmethods from the syncinterface
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);
// LR *******************************
// sync stuff!
QString sentSyncFile();
QPopupMenu *syncMenu;
KSyncManager* syncManager;
int mGlobalSyncMode;
bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
KABC::Addressee getLastSyncAddressee();
QDateTime mLastAddressbookSync;
int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
// *********************
+ //OL sync stuff
+ QString mOLsyncFolderID;
};
#endif
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 2f794d6..6afc288 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -1,735 +1,23 @@
/*
This file is part of KAddressbook/Pi.
Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
-#include <qtooltip.h>
-#include <qframe.h>
-#include <qpixmap.h>
-#include <qlayout.h>
-#include <qprogressbar.h>
-#include <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
@@ -1,85 +1,22 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
-#ifndef KOINCIDENCEEDITOR_H
-#define KOINCIDENCEEDITOR_H
-
-#include <kdialogbase.h>
-
-#include <afxdisp.h>
-
-#include <kabc/addressee.h>
-#include <kabc/addressbook.h>
-
-class QDateTime;
-class QListView;
-class OLEListViewItem;
-class _ContactItem;
-
-
-//using namespace KABC;
-//class KABC::AddressBook;
-
-/**
- This is the base class for the calendar component editors.
-*/
-class KAImportOLdialog : public KDialogBase
-{
- Q_OBJECT
- public:
- /**
- Construct new IncidenceEditor.
- */
- KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook,
- QWidget *parent );
- ~KAImportOLdialog();
-
- /** Initialize editor. This function creates the tab widgets. */
- void init();
- KABC::Addressee::List getAddressList();
- public slots:
-
-
- signals:
-
- protected slots:
- void slotApply();
- void slotOk();
- void slotCancel();
-
- protected:
- void setupFolderView();
- void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
- void readContactData( DWORD folder );
- void ol2kapiContact( _ContactItem * );
-
- KABC::AddressBook * mABook;
- QListView * mListView;
- KABC::Addressee::List mAList;
- bool addAddressee( KABC::Addressee a );
- private:
- int importedItems;
-};
-
-#endif
-
-
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 5639aa2..df3b551 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -11,64 +11,65 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qlayout.h>
#include <qlabel.h>
#include <qtooltip.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qstring.h>
#include <qlistbox.h>
#include <qlistview.h>
#include <qbuttongroup.h>
#include <qhbox.h>
#include <qcursor.h>
#include <qtimer.h>
#include <qapplication.h>
#include <kbuttonbox.h>
#include <klistview.h>
#include <kapplication.h>
#include <qapplication.h>
#include <kconfig.h>
+#include <kmessagebox.h>
#include <klineedit.h>
#include <kcombobox.h>
#include <klocale.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kiconloader.h>
#include <kabc/phonenumber.h>
#include "typecombo.h"
#include "phoneeditwidget.h"
PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
: QWidget(parent,name)
{
QGridLayout* gridLayout = new QGridLayout ( this, 2,2 );
QLabel *temp = new QLabel( "", this );
temp->setAlignment( Qt::AlignCenter );
temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
QPushButton *addBut = new QPushButton ( "add", this );
addBut->setPixmap ( SmallIcon("plus"));
addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() );
connect(addBut,SIGNAL(clicked ()),SLOT(addNumber()));
sv = new QScrollView( this );
sv->setFrameStyle ( QFrame::Plain );
sv->setLineWidth ( 0 );
sv->setMidLineWidth ( 0 );
mw = new QWidget ( sv->viewport() );
sv->addChild(mw);
@@ -83,69 +84,71 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
gridLayout->addWidget( temp, 0, 1 );
gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 );
} else {
gridLayout->addWidget( temp, 1, 0 );
gridLayout->addWidget( addBut, 0, 0 );
gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 );
}
setDefaults();
mTypeNumberEditList.setAutoDelete( true );
mPopup = new QPopupMenu( this );
QStringList list = PhoneNumber::supportedTypeListNames();
mPopupCount = list.count();
int i = 0;
while ( i < mPopupCount ) {
mPopup->insertItem( list[ i ], i );
++i;
}
connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int)));
}
PhoneEditWidget::~PhoneEditWidget()
{
}
void PhoneEditWidget::setDefaults()
{
mTypeNumberEditList.clear();
PhoneTypeNumberEdit* edit = appendEditCombo();
KABC::PhoneNumber phoneNumber;
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 )
{
PhoneTypeNumberEdit* edit = appendEditCombo();
KABC::PhoneNumber phoneNumber;
phoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
edit->setPhoneNumber( phoneNumber );
//verticalScrollBar()->setValue( 1024);
QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) );
}
void PhoneEditWidget::bottomVisible()
{
sv->setContentsPos ( 0, 1024 );
}
void PhoneEditWidget::addNumber()
{
int i = 0;
while ( i < mPopupCount ) {
mPopup->setItemEnabled( i, true );
++i;
}
PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
while ( edit ) {
if ( edit->currentType() < mPopupCount -1 )
mPopup->setItemEnabled( edit->currentType(), false );
edit = mTypeNumberEditList.next();
}
mPopup->popup( QCursor::pos() );
}
PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()
{
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index a69846c..ee17da8 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -27,63 +27,64 @@
#include <qframe.h>
#include <libkcal/calendar.h>
class QLabel;
class KTextEdit;
class QComboBox;
class KLineEdit;
class KOLocationBox;
using namespace KCal;
class JournalEntry : public QFrame {
Q_OBJECT
public:
JournalEntry(Calendar *,QWidget *parent);
virtual ~JournalEntry();
void setJournal(Journal *, bool saveJournal = true );
Journal *journal() const;
void setDate(const QDate &);
void clear();
void flushEntry();
void setShowOnly();
QSize sizeHint() const;
void setVisibleMode( bool b ) { visibleMode = b;}
void fillCalendar( int id = 0 );
void resizeEvent(QResizeEvent* e ) ;
+ KTextEdit * editor() {return mEditor;};
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
void toggleShowJournal();
void setVisibleOn();
signals:
void deleteJournal(Journal *);
void newJournal();
void showJournalOnly( Journal * );
protected:
bool eventFilter( QObject *o, QEvent *e );
void writeJournal();
private:
int mMaxWidDiff;
int mDeskWid;
bool visibleMode;
bool showOnlyMode;
Calendar *mCalendar;
Journal *mJournal;
QDate mDate;
void keyPressEvent ( QKeyEvent * ) ;
QComboBox *mCalendarBox;
KOLocationBox * mTitle;
KTextEdit *mEditor;
int heiHint;
};
#endif
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index a23a3b2..406df5a 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -8,64 +8,65 @@
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
//
// View of Journal entries
#include <qlayout.h>
#include <qscrollview.h>
#include <qpopupmenu.h>
#include <qhbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <klocale.h>
#include <kdebug.h>
#include "koprefs.h"
#include <kglobal.h>
+#include <ktextedit.h>
#include <libkcal/calendar.h>
#include "journalentry.h"
#include "kojournalview.h"
using namespace KOrg;
KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
const char *name)
: KOrg::BaseView(calendar, parent, name)
{
mCalendar = calendar;
QHBox * vb = new QHBox ( this );
QPushButton * newJournal = new QPushButton( vb );
QPixmap icon;
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("ko16old");
else
icon = SmallIcon("ko24old");
newJournal->setPixmap (icon ) ;
int size = newJournal->sizeHint().height();
newJournal->setFixedSize( size, size );
mDateLabel = new QLabel ( vb );
mDateLabel->setMargin(1);
mDateLabel->setAlignment(AlignCenter);
QScrollView * sv = new QScrollView( this );
QVBoxLayout * hbl = new QVBoxLayout( this );
hbl->addWidget( vb );
hbl->addWidget( sv );
parWid = new QWidget( sv->viewport() );
sv->addChild(parWid);
@@ -148,79 +149,87 @@ void KOJournalView::newJournal()
//qDebug(" KOJournalView::newJournal()");
flushView();
Journal* mJournal = new Journal;
mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
mCalendar->addJournal(mJournal);
showDates( mDate, QDate() );
}
void KOJournalView::showOnly ( Journal* j )
{
//qDebug("showOnly %x ", j);
flushView();
if ( j == 0 ) {
showDates( mDate, QDate() );
return;
}
QPtrList<Journal> jl;
jl.append ( j );
showList( jl );
JournalEntry* mEntry = jEntries.first();
mEntry->setShowOnly();
}
void KOJournalView::showList(QPtrList<Journal> jl)
{
static bool ff = false;
if ( ff ) return;
ff = true;
//qDebug("KOJournalView::showList %d",jl.count() );
JournalEntry* mEntry = jEntries.first();
JournalEntry* firstEntry = mEntry;
int count = jl.count();
int iii = 0;
+ QWidget* fw = qApp->focusWidget ();
while ( iii < count ) {
if ( !mEntry ) {
mEntry = getNewEntry();
mEntry->setVisibleMode( true );
mEntry->setDate(mDate);
mEntry->setJournal(jl.at(iii), false);
mEntry->setVisibleMode( true );
mEntry->show();
mEntry = 0;
} else {
+ int xxx = -1, yyy = -1;
+ if ( ((QWidget*) mEntry->editor() ) == fw ) {
+ mEntry->editor()->getCursorPosition( &xxx,&yyy);
+ }
mEntry->setVisibleMode( true );
mEntry->setDate(mDate);
mEntry->setJournal(jl.at(iii), false);
mEntry->setVisibleMode( true );
mEntry->show();
+ if ( xxx > -1 && yyy > -1 ) {
+ mEntry->editor()->setCursorPosition( xxx, yyy );
+ }
mEntry = jEntries.next();
}
++iii;
}
while ( mEntry ) {
mEntry->setDate(mDate);
mEntry->clear();
if ( mEntry != firstEntry ) {
mEntry->hide();
mEntry->setVisibleMode( false );
}
else {
mEntry->setVisibleMode( true );
mEntry->show();
}
mEntry = jEntries.next();
}
ff = false;
}
void KOJournalView::showDates(const QDate &start, const QDate &)
{
mDate = start;
mDateLabel->setText(KGlobal::locale()->formatDate(mDate));
QPtrList<Journal> jl = calendar()->journals4Date( start );
showList( jl );
}
void KOJournalView::showEvents(QPtrList<Event>)
{
// After new creation of list view no events are selected.
// emit incidenceSelected( 0 );
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 59be506..f376e6c 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -818,64 +818,66 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e
//first check if one of the mailers need the emails right in the message.
message = translateMessage(message, name, emailadress);
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
#endif
#ifndef DESKTOP_VERSION
QCopEnvelope e(channel.latin1(), message.latin1());
//US we need no names in the To field. The emailadresses are enough
passParameters(&e, parameters, name, emailadress);
#else // DESKTOP_VERSION
//KMessageBox::sorry( 0,channel );
QProcess * proc = new QProcess( this );
proc->addArgument( channel );
if ( message.find (" " ) > 0 ) {
QStringList list = QStringList::split( " ", message );
int i = 0;
while ( i < list.count ( ) ) {
//qDebug("add%sdd ",list[i].latin1() );
proc->addArgument( list[i] );
//KMessageBox::sorry( 0,list[i]);
++i;
}
} else {
proc->addArgument(message );
}
parameters = translateMessage(parameters, name, emailadress);
+
+ //KMessageBox::information(0,parameters);
proc->addArgument( parameters );
proc->launch("");
#endif
return true;
}
/**************************************************************************
*
**************************************************************************/
//calls the emailapplication and creates a mail with parameter as recipients
// parameters format is
// NAME <EMAIL>:SUBJECT
bool ExternalAppHandler::mailToOneContact( const QString& adressline )
{
QString line = adressline;
int first = line.find( "<");
int last = line.find( ">");
QString name = line.left(first);
QString emailadress = line.mid(first+1, last-first-1);
//Subject can not be handled right now.
return mailToOneContact( name, emailadress );
}
/**************************************************************************
*
**************************************************************************/
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index b7929ec..5708dfc 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -83,96 +83,96 @@ void KSyncManager::setDefaultFileName( QString s)
}
void KSyncManager::fillSyncMenu()
{
if ( mSyncMenu->count() )
mSyncMenu->clear();
mSyncMenu->insertItem( i18n("Configure..."), 0 );
mSyncMenu->insertSeparator();
QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
clearMenu->insertItem( i18n("For all profiles"), 1 );
clearMenu->insertSeparator();
connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
mSyncMenu->insertSeparator();
if ( mServerSocket == 0 ) {
mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
} else {
mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
}
mSyncMenu->insertSeparator();
mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
mSyncMenu->insertSeparator();
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
config.setGroup("General");
QStringList prof = config.readListEntry("SyncProfileNames");
mLocalMachineName = config.readEntry("LocalMachineName","undefined");
if ( prof.count() < 2 ) {
prof.clear();
QString externalName;
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
- externalName = "OutLook(not_implemented)";
+ externalName = "OutLook";
#else
externalName = "KDE_Desktop";
#endif
#else
externalName = "Sharp_DTM";
#endif
prof << externalName;
prof << i18n("Local_file");
prof << i18n("Last_file");
KSyncProfile* temp = new KSyncProfile ();
temp->setName( prof[0] );
temp->writeConfig(&config);
temp->setName( prof[1] );
temp->writeConfig(&config);
temp->setName( prof[2] );
temp->writeConfig(&config);
config.setGroup("General");
config.writeEntry("SyncProfileNames",prof);
config.writeEntry("ExternSyncProfiles",externalName);
config.sync();
delete temp;
}
mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
mSyncProfileNames = prof;
unsigned int i;
for ( i = 0; i < prof.count(); ++i ) {
QString insertText = prof[i];
if ( i == 0 ) {
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
- insertText = "OutLook(not_implemented)";
+ insertText = "OutLook";
#else
insertText = "KDE_Desktop";
#endif
#else
insertText = "Sharp_DTM";
#endif
}
mSyncMenu->insertItem( insertText, 1000+i );
clearMenu->insertItem( insertText, 1000+i );
if ( i == 2 )
mSyncMenu->insertSeparator();
}
QDir app_dir;
//US do not display SharpDTM if app is pwmpi, or no sharpfiles available
if ( mTargetApp == PWMPI) {
mSyncMenu->removeItem( 1000 );
clearMenu->removeItem( 1000 );
}
#ifndef DESKTOP_VERSION
else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
mSyncMenu->removeItem( 1000 );
clearMenu->removeItem( 1000 );
}
#endif
mSyncMenu->removeItem( 1002 );
clearMenu->removeItem( 1002 );
}
void KSyncManager::slotClearMenu( int action )
{
QString syncDevice;
if ( action > 999 ) {
syncDevice = mSyncProfileNames[action - 1000] ;
@@ -905,66 +905,132 @@ QString KSyncManager::getPassword( )
if ( res )
retfile = lab.text();
dia.hide();
qApp->processEvents();
return retfile;
}
void KSyncManager::confSync()
{
static KSyncPrefsDialog* sp = 0;
if ( ! sp ) {
sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
}
sp->usrReadConfig();
#ifndef DESKTOP_VERSION
sp->showMaximized();
#else
sp->show();
#endif
sp->exec();
QStringList oldSyncProfileNames = mSyncProfileNames;
mSyncProfileNames = sp->getSyncProfileNames();
mLocalMachineName = sp->getLocalMachineName ();
uint ii;
for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
}
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
}
+void KSyncManager::syncOL()
+{
+ mSyncWithDesktop = true;
+ emit save();
+ switch(mTargetApp)
+ {
+ case (KAPI):
+ {
+ syncExternalApplication("ol");
+ }
+ break;
+ case (KOPI):
+ {
+#ifdef DESKTOP_VERSION
+ QString command = "kdecaldump33";
+ QString commandfile = "kdecaldump33";
+ QString commandpath = qApp->applicationDirPath () + "/";
+#else
+ QString command = "kdecaldump33";
+ QString commandfile = "kdecaldump33";
+ QString commandpath = QDir::homeDirPath ()+"/";
+#endif
+ if ( ! QFile::exists ( commandpath+commandfile ) )
+ command = commandfile;
+ else
+ command = commandpath+commandfile;
+
+ QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
+ int result = system ( command.latin1());
+ qDebug("Cal dump 33 command call result result: %d ", result);
+ if ( result != 0 ) {
+ qDebug("Calling CAL dump version 33 failed. Trying 34... ");
+ commandfile = "kdecaldump34";
+ if ( ! QFile::exists ( commandpath+commandfile ) )
+ command = commandfile;
+ else
+ command = commandpath+commandfile;
+ result = system ( command.latin1());
+ qDebug("Cal dump 34 command call result result: %d ", result);
+ if ( result != 0 ) {
+ 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 ));
+ return;
+ }
+ }
+ if ( syncWithFile( fileName,true ) ) {
+ if ( mWriteBackFile ) {
+ command += " --read";
+ system ( command.latin1());
+ }
+ }
+
+ }
+ break;
+ case (PWMPI):
+
+ break;
+ default:
+ qDebug("KSM::slotSyncMenu: invalid apptype selected");
+ break;
+
+ }
+}
void KSyncManager::syncKDE()
{
+#ifdef _WIN32_
+ syncOL();
+#else
+
mSyncWithDesktop = true;
emit save();
switch(mTargetApp)
{
case (KAPI):
{
#ifdef DESKTOP_VERSION
QString command = "kdeabdump33";
QString commandfile = "kdeabdump33";
QString commandpath = qApp->applicationDirPath () + "/";
#else
QString command = "kdeabdump33";
QString commandfile = "kdeabdump33";
QString commandpath = QDir::homeDirPath ()+"/";
#endif
if ( ! QFile::exists ( commandpath+commandfile ) )
command = commandfile;
else
command = commandpath+commandfile;
QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
int result = system ( command.latin1());
qDebug("AB dump 33 command call result: %d ", result);
if ( result != 0 ) {
qDebug("Calling AB dump version 33 failed. Trying 34... ");
commandfile = "kdeabdump34";
if ( ! QFile::exists ( commandpath+commandfile ) )
command = commandfile;
else
command = commandpath+commandfile;
result = system ( command.latin1());
qDebug("AB dump 34 command call result: %d ", result);
@@ -1003,64 +1069,65 @@ void KSyncManager::syncKDE()
qDebug("Cal dump 33 command call result result: %d ", result);
if ( result != 0 ) {
qDebug("Calling CAL dump version 33 failed. Trying 34... ");
commandfile = "kdecaldump34";
if ( ! QFile::exists ( commandpath+commandfile ) )
command = commandfile;
else
command = commandpath+commandfile;
result = system ( command.latin1());
qDebug("Cal dump 34 command call result result: %d ", result);
if ( result != 0 ) {
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 ));
return;
}
}
if ( syncWithFile( fileName,true ) ) {
if ( mWriteBackFile ) {
command += " --read";
system ( command.latin1());
}
}
}
break;
case (PWMPI):
break;
default:
qDebug("KSM::slotSyncMenu: invalid apptype selected");
break;
}
+#endif
}
void KSyncManager::syncSharp()
{
if ( ! syncExternalApplication("sharp") )
qDebug("KSM::ERROR sync sharp ");
}
bool KSyncManager::syncExternalApplication(QString resource)
{
emit save();
if ( mAskForPreferences )
if ( !edit_sync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
return false;
}
qDebug("KSM::Sync extern %s", resource.latin1());
bool syncOK = mImplementation->syncExternal(this, resource);
return syncOK;
}
void KSyncManager::syncPhone()
{
syncExternalApplication("phone");
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 04cdade..71d17e9 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -174,76 +174,75 @@ class KSyncManager : public QObject
QString mFilterInAB;
QString mFilterOutAB;
static QDateTime mRequestedSyncEvent;
signals:
void save();
void request_file();
void getFile( bool );
void getFile( bool, const QString &);
void request_file(const QString &);
void multiResourceSyncStart( bool );
public slots:
void slotSyncMenu( int );
void slotClearMenu( int action );
void deleteCommandSocket(KCommandSocket*s, int state);
void readFileFromSocket();
void fillSyncMenu();
private:
void syncPi();
KServerSocket * mServerSocket;
KPimPrefs* mPrefs;
QString mDefFileName;
QString mCurrentSyncDevice;
QString mCurrentSyncName;
void quickSyncLocalFile();
bool syncWithFile( QString fn , bool quick );
void syncLocalFile();
void syncPhone();
void syncSharp();
void syncKDE();
+ void syncOL();
bool syncExternalApplication(QString);
int mCurrentSyncProfile ;
void syncRemote( KSyncProfile* prof, bool ask = true);
bool edit_sync_options();
bool edit_pisync_options();
int ringSync();
QString getPassword( );
bool mPisyncFinished;
QStringList mSpecificResources;
QString mCurrentResourceLocal;
QString mCurrentResourceRemote;
bool mBlockSaveFlag;
QWidget* mParent;
KSyncInterface* mImplementation;
TargetApp mTargetApp;
QPopupMenu* mSyncMenu;
QProgressBar* bar;
bool mSyncWithDesktop;
private slots:
void displayErrorPort();
void confSync();
};
class KSyncInterface
{
public :
virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/)
{
// empty implementation, because some syncable applications do not
// have an external(sharpdtm) syncmode, like pwmanager.
return false;
}
-
-
};
#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 84af7ad..7160d0e 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -29,33 +29,48 @@ HEADERS = \
kinputdialog.h \
kpimprefs.h \
kpimglobalprefs.h \
kprefsdialog.h \
kprefswidget.h \
ksyncmanager.h \
ksyncprofile.h \
ksyncprefsdialog.h \
kcmconfigs/kcmkdepimconfig.h \
kcmconfigs/kdepimconfigwidget.h \
phoneaccess.h
SOURCES = \
categoryeditdialog.cpp \
categoryeditdialog_base.cpp \
categoryselectdialog.cpp \
categoryselectdialog_base.cpp \
externalapphandler.cpp \
kdateedit.cpp \
kdatepicker.cpp \
kinputdialog.cpp \
kpimprefs.cpp \
kpimglobalprefs.cpp \
kprefsdialog.cpp \
kprefswidget.cpp \
ksyncmanager.cpp \
ksyncprofile.cpp \
ksyncprefsdialog.cpp \
kcmconfigs/kcmkdepimconfig.cpp \
kcmconfigs/kdepimconfigwidget.cpp \
phoneaccess.cpp
+win32: {
+#olimport section
+importol {
+debug: {
+LIBS += mfc71ud.lib
+}
+release: {
+LIBS += mfc71u.lib
+}
+DEFINES += _OL_IMPORT_
+HEADERS += ol_access.h
+SOURCES += ol_access.cpp
+#olimport section end
+}
+}