summaryrefslogtreecommitdiff
path: root/libopie/pim
authoreilers <eilers>2002-11-18 09:36:41 (UTC)
committer eilers <eilers>2002-11-18 09:36:41 (UTC)
commit4d0773414a0fb59e53f30d4d2363f73304f474dc (patch) (side-by-side diff)
treee1d972774367a7d24239c8a00a5a3e47d9bd309c /libopie/pim
parentbbe119475b8cb5c03ffb10e4dd328ee281970608 (diff)
downloadopie-4d0773414a0fb59e53f30d4d2363f73304f474dc.zip
opie-4d0773414a0fb59e53f30d4d2363f73304f474dc.tar.gz
opie-4d0773414a0fb59e53f30d4d2363f73304f474dc.tar.bz2
Back to main tree.. Waiting for feature freeze
Diffstat (limited to 'libopie/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp625
-rw-r--r--libopie/pim/ocontact.h42
2 files changed, 40 insertions, 627 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index b0f0d7f..917eb0a 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -22,8 +22,6 @@
#define QTOPIA_INTERNAL_CONTACT_MRE
#include "ocontact.h"
-#include "../../library/backend/vobject_p.h"
-#include "../../library/backend/qfiledirect_p.h"
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
@@ -587,6 +585,12 @@ QString OContact::toRichText() const
text += "<b>" + QObject::tr("Nickname: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
+ if ( categoryNames().count() ){
+ text += "<b>" + QObject::tr( "Category:") + "</b> ";
+ text += categoryNames().join(", ");
+ text += "<br>";
+ }
+
// notes last
if ( (value = notes()) ) {
QRegExp reg("\n");
@@ -816,9 +820,12 @@ void OContact::save( QString &buf ) const
// You need to close this yourself
}
+
/*!
\internal
Returns the list of fields belonging to a contact
+ Never change order of this list ! It has to be regarding
+ enum AddressBookFields !!
*/
QStringList OContact::fields()
{
@@ -878,129 +885,6 @@ QStringList OContact::fields()
return list;
}
-/*!
- \internal
- Returns a translated list of field names for a contact.
-*/
-QStringList OContact::trfields()
-{
- QStringList list;
-
- list.append( QObject::tr( "Name Title") );
- list.append( QObject::tr( "First Name" ) );
- list.append( QObject::tr( "Middle Name" ) );
- list.append( QObject::tr( "Last Name" ) );
- list.append( QObject::tr( "Suffix" ) );
- list.append( QObject::tr( "File As" ) );
-
- list.append( QObject::tr( "Job Title" ) );
- list.append( QObject::tr( "Department" ) );
- list.append( QObject::tr( "Company" ) );
- list.append( QObject::tr( "Business Phone" ) );
- list.append( QObject::tr( "Business Fax" ) );
- list.append( QObject::tr( "Business Mobile" ) );
-
- list.append( QObject::tr( "Default Email" ) );
- list.append( QObject::tr( "Emails" ) );
-
- list.append( QObject::tr( "Home Phone" ) );
- list.append( QObject::tr( "Home Fax" ) );
- list.append( QObject::tr( "Home Mobile" ) );
-
- list.append( QObject::tr( "Business Street" ) );
- list.append( QObject::tr( "Business City" ) );
- list.append( QObject::tr( "Business State" ) );
- list.append( QObject::tr( "Business Zip" ) );
- list.append( QObject::tr( "Business Country" ) );
- list.append( QObject::tr( "Business Pager" ) );
- list.append( QObject::tr( "Business WebPage" ) );
-
- list.append( QObject::tr( "Office" ) );
- list.append( QObject::tr( "Profession" ) );
- list.append( QObject::tr( "Assistant" ) );
- list.append( QObject::tr( "Manager" ) );
-
- list.append( QObject::tr( "Home Street" ) );
- list.append( QObject::tr( "Home City" ) );
- list.append( QObject::tr( "Home State" ) );
- list.append( QObject::tr( "Home Zip" ) );
- list.append( QObject::tr( "Home Country" ) );
- list.append( QObject::tr( "Home Web Page" ) );
-
- list.append( QObject::tr( "Spouse" ) );
- list.append( QObject::tr( "Gender" ) );
- list.append( QObject::tr( "Birthday" ) );
- list.append( QObject::tr( "Anniversary" ) );
- list.append( QObject::tr( "Nickname" ) );
- list.append( QObject::tr( "Children" ) );
-
- list.append( QObject::tr( "Notes" ) );
- list.append( QObject::tr( "Groups" ) );
-
- return list;
-}
-
-/*!
- \internal
- Returns an untranslated list of field names for a contact.
-*/
-QStringList OContact::untrfields()
-{
- QStringList list;
-
- list.append( "Name Title" );
- list.append( "First Name" );
- list.append( "Middle Name" );
- list.append( "Last Name" );
- list.append( "Suffix" );
- list.append( "File As" );
-
- list.append( "Job Title" );
- list.append( "Department" );
- list.append( "Company" );
- list.append( "Business Phone" );
- list.append( "Business Fax" );
- list.append( "Business Mobile" );
-
- list.append( "Default Email" );
- list.append( "Emails" );
-
- list.append( "Home Phone" );
- list.append( "Home Fax" );
- list.append( "Home Mobile" );
-
- list.append( "Business Street" );
- list.append( "Business City" );
- list.append( "Business State" );
- list.append( "Business Zip" );
- list.append( "Business Country" );
- list.append( "Business Pager" );
- list.append( "Business WebPage" );
-
- list.append( "Office" );
- list.append( "Profession" );
- list.append( "Assistant" );
- list.append( "Manager" );
-
- list.append( "Home Street" );
- list.append( "Home City" );
- list.append( "Home State" );
- list.append( "Home Zip" );
- list.append( "Home Country" );
- list.append( "Home Web Page" );
-
- list.append( "Spouse" );
- list.append( "Gender" );
- list.append( "Birthday" );
- list.append( "Anniversary" );
- list.append( "Nickname" );
- list.append( "Children" );
-
- list.append( "Notes" );
- list.append( "Groups" );
-
- return list;
-}
/*!
Sets the list of email address for contact to those contained in \a str.
@@ -1021,470 +905,6 @@ void OContact::setChildren( const QString &str )
replace( Qtopia::Children, str );
}
-// vcard conversion code
-/*!
- \internal
-*/
-static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
-{
- VObject *ret = 0;
- if ( o && !value.isEmpty() )
- ret = addPropValue( o, prop, value.latin1() );
- return ret;
-}
-
-/*!
- \internal
-*/
-static inline VObject *safeAddProp( VObject *o, const char *prop)
-{
- VObject *ret = 0;
- if ( o )
- ret = addProp( o, prop );
- return ret;
-}
-
-/*!
- \internal
-*/
-static VObject *createVObject( const OContact &c )
-{
- VObject *vcard = newVObject( VCCardProp );
- safeAddPropValue( vcard, VCVersionProp, "2.1" );
- safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
- safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
-
- // full name
- safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
-
- // name properties
- VObject *name = safeAddProp( vcard, VCNameProp );
- safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
- safeAddPropValue( name, VCGivenNameProp, c.firstName() );
- safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
- safeAddPropValue( name, VCNamePrefixesProp, c.title() );
- safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
-
- // home properties
- VObject *home_adr= safeAddProp( vcard, VCAdrProp );
- safeAddProp( home_adr, VCHomeProp );
- safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
- safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
- safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
- safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
- safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
-
- VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
- safeAddProp( home_phone, VCHomeProp );
- home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
- safeAddProp( home_phone, VCHomeProp );
- safeAddProp( home_phone, VCCellularProp );
- home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
- safeAddProp( home_phone, VCHomeProp );
- safeAddProp( home_phone, VCFaxProp );
-
- VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
- safeAddProp( url, VCHomeProp );
-
- // work properties
- VObject *work_adr= safeAddProp( vcard, VCAdrProp );
- safeAddProp( work_adr, VCWorkProp );
- safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
- safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
- safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
- safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
- safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
-
- VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
- safeAddProp( work_phone, VCWorkProp );
- work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
- safeAddProp( work_phone, VCWorkProp );
- safeAddProp( work_phone, VCCellularProp );
- work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
- safeAddProp( work_phone, VCWorkProp );
- safeAddProp( work_phone, VCFaxProp );
- work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
- safeAddProp( work_phone, VCWorkProp );
- safeAddProp( work_phone, VCPagerProp );
-
- url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
- safeAddProp( url, VCWorkProp );
-
- VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
- safeAddProp( title, VCWorkProp );
-
-
- QStringList emails = c.emailList();
- emails.prepend( c.defaultEmail() );
- for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
- VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
- safeAddProp( email, VCInternetProp );
- }
-
- safeAddPropValue( vcard, VCNoteProp, c.notes() );
-
- // Exporting Birthday regarding RFC 2425 (5.8.4)
- if ( c.birthday().isValid() ){
- QString birthd_rfc2425 = QString("%1-%2-%3")
- .arg( c.birthday().year() )
- .arg( c.birthday().month(), 2 )
- .arg( c.birthday().day(), 2 );
- // Now replace spaces with "0"...
- int pos = 0;
- while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
- birthd_rfc2425.replace( pos, 1, "0" );
-
- qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
- safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
- }
-
- if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
- VObject *org = safeAddProp( vcard, VCOrgProp );
- safeAddPropValue( org, VCOrgNameProp, c.company() );
- safeAddPropValue( org, VCOrgUnitProp, c.department() );
- safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
- }
-
- // some values we have to export as custom fields
- safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
- safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
- safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
-
- safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
- safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
- // safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); :SX
- safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
- safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
-
- return vcard;
-}
-
-
-/*!
- \internal
-*/
-static QDate convVCardDateToDate( const QString& datestr )
-{
- int monthPos = datestr.find('-');
- int dayPos = datestr.find('-', monthPos+1 );
- int sep_ignore = 1;
- if ( monthPos == -1 || dayPos == -1 ) {
- qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
- // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
- if ( datestr.length() == 8 ){
- monthPos = 4;
- dayPos = 6;
- sep_ignore = 0;
- qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
- } else {
- return QDate();
- }
- }
- int y = datestr.left( monthPos ).toInt();
- int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
- int d = datestr.mid( dayPos + sep_ignore ).toInt();
- qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
- QDate date ( y,m,d );
- return date;
-}
-
-static OContact parseVObject( VObject *obj )
-{
- OContact c;
-
- VObjectIterator it;
- initPropIterator( &it, obj );
- while( moreIteration( &it ) ) {
- VObject *o = nextVObject( &it );
- QCString name = vObjectName( o );
- QCString value = vObjectStringZValue( o );
- if ( name == VCNameProp ) {
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- QString value = vObjectStringZValue( o );
- if ( name == VCNamePrefixesProp )
- c.setTitle( value );
- else if ( name == VCNameSuffixesProp )
- c.setSuffix( value );
- else if ( name == VCFamilyNameProp )
- c.setLastName( value );
- else if ( name == VCGivenNameProp )
- c.setFirstName( value );
- else if ( name == VCAdditionalNamesProp )
- c.setMiddleName( value );
- }
- }
- else if ( name == VCAdrProp ) {
- bool work = TRUE; // default address is work address
- QString street;
- QString city;
- QString region;
- QString postal;
- QString country;
-
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectName( o );
- QString value = vObjectStringZValue( o );
-
- if ( name == VCHomeProp )
- work = FALSE;
- else if ( name == VCWorkProp )
- work = TRUE;
- else if ( name == VCStreetAddressProp )
- street = value;
- else if ( name == VCCityProp )
- city = value;
- else if ( name == VCRegionProp )
- region = value;
- else if ( name == VCPostalCodeProp )
- postal = value;
- else if ( name == VCCountryNameProp )
- country = value;
- }
- if ( work ) {
- c.setBusinessStreet( street );
- c.setBusinessCity( city );
- c.setBusinessCountry( country );
- c.setBusinessZip( postal );
- c.setBusinessState( region );
- } else {
- c.setHomeStreet( street );
- c.setHomeCity( city );
- c.setHomeCountry( country );
- c.setHomeZip( postal );
- c.setHomeState( region );
- }
- }
- else if ( name == VCTelephoneProp ) {
- enum {
- HOME = 0x01,
- WORK = 0x02,
- VOICE = 0x04,
- CELL = 0x08,
- FAX = 0x10,
- PAGER = 0x20,
- UNKNOWN = 0x80
- };
- int type = 0;
-
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- if ( name == VCHomeProp )
- type |= HOME;
- else if ( name == VCWorkProp )
- type |= WORK;
- else if ( name == VCVoiceProp )
- type |= VOICE;
- else if ( name == VCCellularProp )
- type |= CELL;
- else if ( name == VCFaxProp )
- type |= FAX;
- else if ( name == VCPagerProp )
- type |= PAGER;
- else if ( name == VCPreferredProp )
- ;
- else
- type |= UNKNOWN;
- }
- if ( (type & UNKNOWN) != UNKNOWN ) {
- if ( ( type & (HOME|WORK) ) == 0 ) // default
- type |= HOME;
- if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
- type |= VOICE;
-
- if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
- c.setHomePhone( value );
- if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
- c.setHomeFax( value );
- if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
- c.setHomeMobile( value );
- if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
- c.setBusinessPhone( value );
- if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
- c.setBusinessFax( value );
- if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
- c.setBusinessMobile( value );
- if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
- c.setBusinessPager( value );
- }
- }
- else if ( name == VCEmailAddressProp ) {
- QString email = vObjectStringZValue( o );
- bool valid = TRUE;
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- if ( name != VCInternetProp && name != VCHomeProp &&
- name != VCWorkProp &&
- name != VCPreferredProp )
- // ### preffered should map to default email
- valid = FALSE;
- }
- if ( valid ) {
- c.insertEmail( email );
- }
- }
- else if ( name == VCURLProp ) {
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- if ( name == VCHomeProp )
- c.setHomeWebpage( value );
- else if ( name == VCWorkProp )
- c.setBusinessWebpage( value );
- }
- }
- else if ( name == VCOrgProp ) {
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectName( o );
- QString value = vObjectStringZValue( o );
- if ( name == VCOrgNameProp )
- c.setCompany( value );
- else if ( name == VCOrgUnitProp )
- c.setDepartment( value );
- else if ( name == VCOrgUnit2Prop )
- c.setOffice( value );
- }
- }
- else if ( name == VCTitleProp ) {
- c.setJobTitle( value );
- }
- else if ( name == "X-Qtopia-Profession" ) {
- c.setProfession( value );
- }
- else if ( name == "X-Qtopia-Manager" ) {
- c.setManager( value );
- }
- else if ( name == "X-Qtopia-Assistant" ) {
- c.setAssistant( value );
- }
- else if ( name == "X-Qtopia-Spouse" ) {
- c.setSpouse( value );
- }
- else if ( name == "X-Qtopia-Gender" ) {
- c.setGender( value );
- }
- else if ( name == "X-Qtopia-Anniversary" ) {
-// c.setAnniversary( TimeConversion::fromString( value ) ); :SX
- }
- else if ( name == "X-Qtopia-Nickname" ) {
- c.setNickname( value );
- }
- else if ( name == "X-Qtopia-Children" ) {
- c.setChildren( value );
- }
- else if ( name == VCBirthDateProp ) {
- // Reading Birthdate regarding RFC 2425 (5.8.4)
- c.setBirthday( convVCardDateToDate( value ) );
-
- }
-
-#if 0
- else {
- printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectName( o );
- QString value = vObjectStringZValue( o );
- printf(" subprop: %s = %s\n", name.data(), value.latin1() );
- }
- }
-#endif
- }
- c.setFileAs();
- return c;
-}
-
-/*!
- Writes the list of \a contacts as a set of VCards to the file \a filename.
-*/
-void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts)
-{
- QFileDirect f( filename.utf8().data() );
- if ( !f.open( IO_WriteOnly ) ) {
- qWarning("Unable to open vcard write");
- return;
- }
-
- QValueList<OContact>::ConstIterator it;
- for( it = contacts.begin(); it != contacts.end(); ++it ) {
- VObject *obj = createVObject( *it );
- writeVObject(f.directHandle() , obj );
- cleanVObject( obj );
- }
- cleanStrTbl();
-}
-
-/*!
- writes \a contact as a VCard to the file \a filename.
-*/
-void OContact::writeVCard( const QString &filename, const OContact &contact)
-{
- QFileDirect f( filename.utf8().data() );
- if ( !f.open( IO_WriteOnly ) ) {
- qWarning("Unable to open vcard write");
- return;
- }
-
- VObject *obj = createVObject( contact );
- writeVObject( f.directHandle() , obj );
- cleanVObject( obj );
-
- cleanStrTbl();
-}
-
-/*!
- Returns the set of contacts read as VCards from the file \a filename.
-*/
-QValueList<OContact> OContact::readVCard( const QString &filename )
-{
- qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
- VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
-
- qDebug("vobject = %p", obj );
-
- QValueList<OContact> contacts;
-
- while ( obj ) {
- OContact con = parseVObject( obj );
- /*
- * if uid is 0 assign a new one
- * this at least happens on
- * Nokia6210
- */
- if ( con.uid() == 0 ){
- con.setUid( 1 );
- qWarning("assigned new uid %d",con.uid() );
- }
-
- contacts.append(con );
-
- VObject *t = obj;
- obj = nextVObjectInList(obj);
- cleanVObject( t );
- }
-
- return contacts;
-}
-
/*!
Returns TRUE if the contact matches the regular expression \a regexp.
Otherwise returns FALSE.
@@ -1542,22 +962,36 @@ class QString OContact::recordField( int pos ) const
// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
/*! \fn void OContact::setBirthday( const QDate& date )
- Sets the birthday for the contact to \a date.
+ Sets the birthday for the contact to \a date. If date is null
+ the current stored date will be removed.
*/
void OContact::setBirthday( const QDate &v )
{
- if ( ( !v.isNull() ) && ( v.isValid() ) )
+ if ( v.isNull() ){
+ qWarning( "Remove Birthday");
+ replace( Qtopia::Birthday, QString::null );
+ return;
+ }
+
+ if ( v.isValid() )
replace( Qtopia::Birthday, TimeConversion::toString( v ) );
}
/*! \fn void OContact::setAnniversary( const QDate &date )
- Sets the anniversary of the contact to \a date.
+ Sets the anniversary of the contact to \a date. If date is
+ null, the current stored date will be removed.
*/
void OContact::setAnniversary( const QDate &v )
{
- if ( ( !v.isNull() ) && ( v.isValid() ) )
+ if ( v.isNull() ){
+ qWarning( "Remove Anniversary");
+ replace( Qtopia::Anniversary, QString::null );
+ return;
+ }
+
+ if ( v.isValid() )
replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
}
@@ -1662,3 +1096,8 @@ void OContact::insertEmails( const QStringList &v )
insertEmail( *it );
}
+void OContact::setUid( int i )
+{
+ OPimRecord::setUid(i);
+ replace( Qtopia::AddressUid , QString::number(i));
+}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 9643e8b..d97af1c 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -34,16 +34,8 @@ QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
// MOC_SKIP_END
#endif
-class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se)
- /* Stefan das ist eine forward declaration
- * dann machst du in der private section
- * ContactPrivate *d;
- *
- * und wenn du bei Opie1.1 was hinzufuegen moechtest
- * packst du es in ContactPrivate damit Opie
- * binaer kompatibel bleibt
- * -zecke
- */
+class ContactPrivate;
+
class QPC_EXPORT OContact : public OPimRecord
{
friend class DataSet;
@@ -52,11 +44,6 @@ public:
OContact( const QMap<int, QString> &fromMap );
virtual ~OContact();
- /* VCARD stuff should vanish! -zecke */
- static void writeVCard( const QString &filename, const QValueList<OContact> &contacts);
- static void writeVCard( const QString &filename, const OContact &c );
- static QValueList<OContact> readVCard( const QString &filename );
-
enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
/*
@@ -206,23 +193,13 @@ public:
// const QString &customField( const QString &key )
// { return find( Custom- + key ); }
- static QStringList fields();
- static QStringList trfields();
- static QStringList untrfields();
QString toRichText() const;
QMap<int, QString> toMap() const;
QString field( int key ) const { return find( key ); }
- // journaling...
- /* do we still need them? Stefan your backend takes care of these -zecke */
- void saveJournal( journal_action action, const QString &key = QString::null );
- void save( QString &buf ) const;
-
- /* we shouldn't inline this one -zecke */
- void setUid( int i )
-{ OPimRecord::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
+ void setUid( int i );
QString toShortText()const;
QString OContact::type()const;
@@ -237,18 +214,15 @@ public:
private:
- /* I do not like friends ;)
- * besides that I think we do not need them
- * anymore -zecke
- */
- friend class AbEditor;
- friend class AbTable;
- friend class AddressBookAccessPrivate;
- friend class XMLIO;
+ // The XML-Backend needs some access to the private functions
+ friend class OContactAccessBackend_XML;
void insert( int key, const QString &value );
void replace( int key, const QString &value );
QString find( int key ) const;
+ static QStringList fields();
+
+ void save( QString &buf ) const;
QString displayAddress( const QString &street,
const QString &city,