summaryrefslogtreecommitdiff
path: root/libopie/pim/ocontactaccessbackend_vcard.cpp
Side-by-side diff
Diffstat (limited to 'libopie/pim/ocontactaccessbackend_vcard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 270bef3..b60c5be 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -1,43 +1,58 @@
/*
* VCard Backend for the OPIE-Contact Database.
*
* Copyright (C) 2000 Trolltech AS. All rights reserved.
* Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
*
* =====================================================================
* This program 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.
* =====================================================================
* ToDo:
*
* =====================================================================
* Version: $Id$
* =====================================================================
* History:
* $Log$
+ * Revision 1.11 2003/08/01 12:30:16 eilers
+ * Merging changes from BRANCH_1_0 to HEAD
+ *
+ * Revision 1.10.4.3 2003/07/23 08:54:37 eilers
+ * Default email was added to the list of all emails, which already contains
+ * the default email..
+ * This closes bug #1045
+ *
+ * Revision 1.10.4.2 2003/07/23 08:44:45 eilers
+ * Importing of Notes in vcard files wasn't implemented.
+ * Closes bug #1044
+ *
+ * Revision 1.10.4.1 2003/06/02 13:37:49 eilers
+ * Fixing memory leak
+ *
* Revision 1.10 2003/04/13 18:07:10 zecke
* More API doc
* QString -> const QString&
* QString = 0l -> QString::null
*
* Revision 1.9 2003/03/21 10:33:09 eilers
* Merged speed optimized xml backend for contacts to main.
* Added QDateTime to querybyexample. For instance, it is now possible to get
* all Birthdays/Anniversaries between two dates. This should be used
* to show all birthdays in the datebook..
* This change is sourcecode backward compatible but you have to upgrade
* the binaries for today-addressbook.
*
* Revision 1.8 2003/02/21 16:52:49 zecke
* -Remove old Todo classes they're deprecated and today I already using the
* new API
* -Guard against self assignment in OTodo
* -Add test apps for OPIM
* -Opiefied Event classes
* -Added TimeZone handling and pinning of TimeZones to OEvent
* -Adjust ORecur and the widget to better timezone behaviour
*
* Revision 1.7 2003/02/16 22:25:46 zecke
* 0000276 Fix for that bug.. or better temp workaround
@@ -130,48 +145,49 @@ bool OContactAccessBackend_VCard::load ()
bool OContactAccessBackend_VCard::reload()
{
return load();
}
bool OContactAccessBackend_VCard::save()
{
if (!m_dirty )
return true;
QFileDirect file( m_file );
if (!file.open(IO_WriteOnly ) )
return false;
VObject *obj;
obj = newVObject( VCCalProp );
addPropValue( obj, VCVersionProp, "1.0" );
VObject *vo;
for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
vo = createVObject( *it );
writeVObject( file.directHandle() , vo );
cleanVObject( vo );
}
cleanStrTbl();
+ deleteVObject( obj );
m_dirty = false;
return true;
}
void OContactAccessBackend_VCard::clear ()
{
m_map.clear();
m_dirty = true; // ??? sure ? (se)
}
bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
{
m_map.insert( newcontact.uid(), newcontact );
m_dirty = true;
return true;
}
bool OContactAccessBackend_VCard::remove ( int uid )
{
m_map.remove( uid );
m_dirty = true;
return true;
@@ -425,49 +441,51 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
}
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( convVCardDateToDate( value ) );
}
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 ) );
}
-
+ else if ( name == VCCommentProp ) {
+ c.setNotes( 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;
}
VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
{
VObject *vcard = newVObject( VCCardProp );
safeAddPropValue( vcard, VCVersionProp, "2.1" );
safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
@@ -513,49 +531,49 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
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() );
+ // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
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() ){
qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
}
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() );