summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-08 20:03:23 (UTC)
committer zautrix <zautrix>2004-10-08 20:03:23 (UTC)
commit10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (side-by-side diff)
tree3105b985a9dbedd31dff52e14fe667eeff4f9ff4
parent13bd085e06b76228321f5a004759fcdf19cca711 (diff)
downloadkdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip
kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz
kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2
added contact phone support
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressee.cpp32
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/phonenumber.cpp23
-rw-r--r--kabc/phonenumber.h2
-rw-r--r--kaddressbook/kabcore.cpp23
5 files changed, 80 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 25c77f6..e571980 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -316,4 +316,36 @@ void Addressee::mergeContact( const Addressee& ad )
}
+// removes all emails but the first
+// needed by phone sync
+void Addressee::simplifyEmails()
+{
+ if ( mData->emails.count() == 0 ) return ;
+ QString email = mData->emails.first();
+ detach();
+ mData->emails.clear();
+ mData->emails.append( email );
+}
+
+void Addressee::simplifyPhoneNumbers()
+{
+ KABC::PhoneNumber::List removeNumbers;
+ KABC::PhoneNumber::List::Iterator phoneIter;
+ for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
+ ++phoneIter ) {
+ if ( ! ( *phoneIter ).simplifyNumber() )
+ removeNumbers.append( ( *phoneIter ) );
+ }
+ for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
+ ++phoneIter ) {
+ removePhoneNumber(( *phoneIter ));
+ }
+}
+void Addressee::simplifyPhoneNumberTypes()
+{
+ KABC::PhoneNumber::List::Iterator phoneIter;
+ for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
+ ++phoneIter )
+ ( *phoneIter ).simplifyType();
+}
void Addressee::removeID(const QString &prof)
{
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 8baa888..4cafa86 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -118,4 +118,8 @@ class Addressee
QString originalExternalUID() const;
void mergeContact( const Addressee& ad );
+ void simplifyEmails();
+ void simplifyPhoneNumbers();
+ void simplifyPhoneNumberTypes();
+
/**
Set unique identifier.
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 7aeb2ee..e5abc0e 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -67,4 +67,27 @@ bool PhoneNumber::operator!=( const PhoneNumber &p ) const
}
+bool PhoneNumber::simplifyNumber()
+{
+ QString Number;
+ int i;
+ Number = mNumber.stripWhiteSpace ();
+ mNumber = "";
+ if ( Number.at(0) == '+' )
+ mNumber += "+";
+ for ( i = 0; i < Number.length(); ++i) {
+ if ( Number.at(i).isDigit() )
+ mNumber += Number.at(i);
+ }
+ return ( mNumber.length() > 0 );
+}
+// make cellphone compatible
+void PhoneNumber::simplifyType()
+{
+ if ( mType & Fax ) mType = Fax;
+ else if ( mType & Cell ) mType = Cell;
+ else if ( mType & Work ) mType = Work ;
+ else if ( mType & Home ) mType = Home;
+ else mType = Pref;
+}
void PhoneNumber::setId( const QString &id )
{
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h
index 1df344f..410a52f 100644
--- a/kabc/phonenumber.h
+++ b/kabc/phonenumber.h
@@ -149,4 +149,6 @@ class PhoneNumber
*/
static QString label( int type );
+ bool simplifyNumber();
+ void simplifyType();
private:
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c5406bf..939296f 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -700,9 +700,12 @@ void KABCore::export2phone()
if ( a.isEmpty() )
continue;
+ a.simplifyEmails();
+ a.simplifyPhoneNumbers();
+ a.simplifyPhoneNumberTypes();
if (description.isEmpty())
description = a.formattedName();
-
QString vcard;
+ QString vcardnew;
converter.addresseeToVCard( a, vcard );
int start = 0;
@@ -716,9 +719,21 @@ void KABCore::export2phone()
else
sep = dopp;
- datastream +=vcard.mid( start, next - start);
- datastream +=vcard.mid( next+5,sep -next -5 ).upper();
+ vcardnew +=vcard.mid( start, next - start);
+ vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
start = sep;
}
- datastream += vcard.mid( start,vcard.length() );
+ vcardnew += vcard.mid( start,vcard.length() );
+ vcard = "";
+ start = 0;
+ while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
+ int sep = vcardnew.find(":", next);
+ vcard +=vcardnew.mid( start, next - start+3);
+ start = sep;
+ }
+ vcard += vcardnew.mid( start,vcardnew.length() );
+ vcard.replace ( QRegExp(";;;") , "" );
+ vcard.replace ( QRegExp(";;") , "" );
+ datastream += vcard;
+
}
QFile outFile(fileName);