-rw-r--r-- | kabc/addressee.cpp | 4 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 8 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 10 |
3 files changed, 11 insertions, 11 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 661bdf6..19c78ee 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -970,211 +970,211 @@ QString Addressee::birthdayLabel() QString Addressee::homeAddressStreetLabel() { return i18n("Home Address Street"); } QString Addressee::homeAddressLocalityLabel() { return i18n("Home Address Locality"); } QString Addressee::homeAddressRegionLabel() { return i18n("Home Address Region"); } QString Addressee::homeAddressPostalCodeLabel() { return i18n("Home Address Postal Code"); } QString Addressee::homeAddressCountryLabel() { return i18n("Home Address Country"); } QString Addressee::homeAddressLabelLabel() { return i18n("Home Address Label"); } QString Addressee::businessAddressStreetLabel() { return i18n("Business Address Street"); } QString Addressee::businessAddressLocalityLabel() { return i18n("Business Address Locality"); } QString Addressee::businessAddressRegionLabel() { return i18n("Business Address Region"); } QString Addressee::businessAddressPostalCodeLabel() { return i18n("Business Address Postal Code"); } QString Addressee::businessAddressCountryLabel() { return i18n("Business Address Country"); } QString Addressee::businessAddressLabelLabel() { return i18n("Business Address Label"); } QString Addressee::homePhoneLabel() { return i18n("Home Phone"); } QString Addressee::businessPhoneLabel() { return i18n("Work Phone"); } QString Addressee::mobilePhoneLabel() { return i18n("Mobile Phone"); } QString Addressee::mobileWorkPhoneLabel() { return i18n("Mobile2 (work)"); } QString Addressee::mobileHomePhoneLabel() { - return i18n("Mobile"); + return i18n("Mobile (Home)"); } QString Addressee::homeFaxLabel() { return i18n("Fax (Home)"); } QString Addressee::businessFaxLabel() { return i18n("Fax (Work)"); } QString Addressee::carPhoneLabel() { - return i18n("Mobile2 (work)"); + return i18n("Mobile2 (car)"); } QString Addressee::isdnLabel() { return i18n("ISDN"); } QString Addressee::pagerLabel() { return i18n("Pager"); } QString Addressee::sipLabel() { return i18n("SIP"); } QString Addressee::emailLabel() { return i18n("Email Address"); } void Addressee::setMailer( const QString &mailer ) { if ( mailer == mData->mailer ) return; detach(); mData->empty = false; mData->mailer = mailer; } QString Addressee::mailer() const { return mData->mailer; } QString Addressee::mailerLabel() { return i18n("Mail Client"); } void Addressee::setTimeZone( const TimeZone &timeZone ) { if ( timeZone == mData->timeZone ) return; detach(); mData->empty = false; mData->timeZone = timeZone; } TimeZone Addressee::timeZone() const { return mData->timeZone; } QString Addressee::timeZoneLabel() { return i18n("Time Zone"); } void Addressee::setGeo( const Geo &geo ) { if ( geo == mData->geo ) return; detach(); mData->empty = false; mData->geo = geo; } Geo Addressee::geo() const { return mData->geo; } QString Addressee::geoLabel() { return i18n("Geographic Position"); } void Addressee::setTitle( const QString &title ) { if ( title == mData->title ) return; detach(); mData->empty = false; mData->title = title; } QString Addressee::title() const { return mData->title; } QString Addressee::titleLabel() diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index 39d366b..9693a68 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp @@ -108,222 +108,222 @@ QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QStr // FROM TT timeconversion.cpp GPLed QDate QtopiaConverter::fromString( const QString &datestr ) { if (datestr.isEmpty() ) return QDate(); int monthPos = datestr.find('.'); int yearPos = datestr.find('.', monthPos+1 ); if ( monthPos == -1 || yearPos == -1 ) { return QDate(); } int d = datestr.left( monthPos ).toInt(); int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); int y = datestr.mid( yearPos+1 ).toInt(); QDate date ( y,m,d ); return date; } QDate QtopiaConverter::dateFromString( const QString& s ) { QDate date; if ( s.isEmpty() ) return date; // Be backward compatible to old Opie format: // Try to load old format. If it fails, try new ISO-Format! date = fromString ( s ); if ( date.isValid() ) return date; // Read ISO-Format (YYYYMMDD) int year = s.mid(0, 4).toInt(); int month = s.mid(4,2).toInt(); int day = s.mid(6,2).toInt(); // do some quick sanity checking if ( year < 1900 || year > 3000 ) return date; if ( month < 0 || month > 12 ) return date; if ( day < 0 || day > 31 ) return date; date.setYMD( year, month, day ); if ( !date.isValid() ) return QDate(); return date; } QString QtopiaConverter::dateToString( const QDate &d ) { if ( d.isNull() || !d.isValid() ) return QString::null; // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 QString year = QString::number( d.year() ); QString month = QString::number( d.month() ); month = month.rightJustify( 2, '0' ); QString day = QString::number( d.day() ); day = day.rightJustify( 2, '0' ); QString str = year + month + day; return str; } bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr ) { { //LR adr.setUid( el.attribute("Uid" ) ); adr.setFamilyName( el.attribute( "LastName" ) ); adr.setGivenName( el.attribute( "FirstName" ) ); adr.setAdditionalName( el.attribute( "MiddleName" ) ); adr.setSuffix( el.attribute( "Suffix" ) ); adr.setNickName( el.attribute( "Nickname" ) ); QDate date = dateFromString( el.attribute( "Birthday" ) ); if ( date.isValid() ) adr.setBirthday( date ); adr.setRole( el.attribute( "JobTitle" ) ); if ( !el.attribute( "FileAs" ).isEmpty() ) adr.setFormattedName( el.attribute( "FileAs" ) ); adr.setOrganization( el.attribute( "Company" ) ); KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ), - KABC::PhoneNumber::Work ); + KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ), KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ), - KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell ); + KABC::PhoneNumber::Car ); KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ), - KABC::PhoneNumber::Work | KABC::PhoneNumber::Pager ); + KABC::PhoneNumber::Pager ); if ( !businessPhoneNum.number().isEmpty() ) adr.insertPhoneNumber( businessPhoneNum ); if ( !businessFaxNum.number().isEmpty() ) adr.insertPhoneNumber( businessFaxNum ); if ( !businessMobile.number().isEmpty() ) adr.insertPhoneNumber( businessMobile ); if ( !businessPager.number().isEmpty() ) adr.insertPhoneNumber( businessPager ); // Handle multiple mail addresses QString DefaultEmail = el.attribute( "DefaultEmail" ); if ( !DefaultEmail.isEmpty() ) adr.insertEmail( DefaultEmail, true ); // preferred QStringList Emails = QStringList::split(" ",el.attribute("Emails")); int i; for (i = 0;i < Emails.count();++i) { if ( Emails[i] != DefaultEmail ) adr.insertEmail( Emails[i], false ); } KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ), - KABC::PhoneNumber::Home ); + KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref); KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ), KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ), KABC::PhoneNumber::Cell ); if ( !homePhoneNum.number().isEmpty() ) adr.insertPhoneNumber( homePhoneNum ); if ( !homeFax.number().isEmpty() ) adr.insertPhoneNumber( homeFax ); if ( !homeMobile.number().isEmpty() ) adr.insertPhoneNumber( homeMobile ); KABC::Address business( KABC::Address::Work ); business.setStreet( el.attribute( "BusinessStreet" ) ); business.setLocality( el.attribute( "BusinessCity" ) ); business.setRegion( el.attribute( "BusinessState" ) ); business.setPostalCode( el.attribute( "BusinessZip" ) ); business.setCountry( el.attribute( "BusinessCountry" ) ); if ( !business.isEmpty() ) adr.insertAddress( business ); KABC::Address home( KABC::Address::Home ); home.setStreet( el.attribute( "HomeStreet" ) ); home.setLocality( el.attribute( "HomeCity" ) ); home.setRegion( el.attribute( "HomeState" ) ); home.setPostalCode( el.attribute( "HomeZip" ) ); home.setCountry( el.attribute( "HomeCountry" ) ); if ( !home.isEmpty() ) adr.insertAddress( home ); adr.setNickName( el.attribute( "Nickname" ) ); adr.setNote( el.attribute( "Notes" ) ); { QStringList categories = QStringList::split(";", el.attribute("Categories" ) ); QString cat; QStringList added; for ( uint i = 0; i < categories.count(); i++ ) { cat = m_edit->categoryById( categories[ i ], "Contacts" ); // if name is not empty and we did not add the // cat try to repair broken files if ( !cat.isEmpty() && !added.contains( cat ) ) { adr.insertCategory( cat ); added << cat; } } } if ( !el.attribute( "Department" ).isEmpty() ) adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) ); if ( !el.attribute( "HomeWebPage" ).isEmpty() ) adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) ); if ( !el.attribute( "Spouse" ).isEmpty() ) adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) ); if ( !el.attribute( "Gender" ).isEmpty() ) { if ( el.attribute( "Gender" ) == "1" ) adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); else if ( el.attribute( "Gender" ) == "2" ) adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); } QDate ann = dateFromString( el.attribute( "Anniversary" ) ); if ( ann.isValid() ) { QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt ); } if ( !el.attribute( "Children" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") ); if ( !el.attribute( "Office" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") ); if ( !el.attribute( "Profession" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") ); if ( !el.attribute( "Assistant" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") ); if ( !el.attribute( "Manager" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") ); } return true; } bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream ) { *stream << "<Contact "; *stream << "FirstName=\"" << escape(ab.givenName()) << "\" "; *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" "; *stream << "LastName=\"" << escape(ab.familyName()) << "\" "; *stream << "Suffix=\"" << escape(ab.suffix()) << "\" "; QString sortStr; sortStr = ab.formattedName(); diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index 4adcae4..3d429fa 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp @@ -39,265 +39,265 @@ $Id$ using namespace KABC; using namespace SlCategory; SharpDTMConverter::SharpDTMConverter() : catDB(0) { } SharpDTMConverter::~SharpDTMConverter() { deinit(); } bool SharpDTMConverter::init() { catDB = new SlCategory::SlCategories(); if (!catDB) return false; // catDB->load( categoryFileName() ); return true; } void SharpDTMConverter::deinit() { if (catDB) { delete catDB; catDB = 0; } } bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) { SlZDataBase* db = (SlZDataBase*)database; // for syncing: we need setting of the two fields addr.setExternalUID( QString::number( contact ) ); addr.setOriginalExternalUID( QString::number( contact ) ); addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); // name //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); //addr.setName(db->readField(ZdbAdrs::FullName)); addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); addr.setPrefix( db->readField(ZdbAdrs::Title) ); addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); QString emailstr = db->readField(ZdbAdrs::Emails); emailstr.replace( QRegExp(","), " " ); emailstr.replace( QRegExp(";"), " " ); emailstr.replace( QRegExp(":"), " " ); //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); bool defE = false; bool found = false; for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { if (found ) defE = false; else found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); addr.insertEmail( *it, defE ); } if ( ! found ) if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); // home if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || (!db->readField(ZdbAdrs::HomeState).isEmpty()) || (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) { Address homeaddress; homeaddress.setType(Address::Home); //US homeaddress.setPostOfficeBox( "" ); //US homeaddress.setExtended( "" ); homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); addr.insertAddress( homeaddress ); } if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) { PhoneNumber homephone; - homephone.setType( PhoneNumber::Home ); + homephone.setType( PhoneNumber::Home | PhoneNumber::Pref ); homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); addr.insertPhoneNumber( homephone ); } if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) { PhoneNumber homefax; homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); addr.insertPhoneNumber( homefax ); } if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) { PhoneNumber homemobile; - homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); + homemobile.setType( PhoneNumber::Cell ); homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); addr.insertPhoneNumber( homemobile ); } addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); // business if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) { Address businessaddress; businessaddress.setType(Address::Work); //US businessaddress.setPostOfficeBox( "" ); //US businessaddress.setExtended( "" ); businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") ); businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); addr.insertAddress( businessaddress ); } if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) { PhoneNumber businessphone; - businessphone.setType( PhoneNumber::Work ); + businessphone.setType( PhoneNumber::Work | PhoneNumber::Pref ); businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); addr.insertPhoneNumber( businessphone ); } if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) { PhoneNumber businessfax; businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); addr.insertPhoneNumber( businessfax ); } if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) { PhoneNumber businessmobile; - businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); + businessmobile.setType( PhoneNumber::Car ); businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); addr.insertPhoneNumber( businessmobile ); } if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) { PhoneNumber businesspager; - businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); + businesspager.setType( PhoneNumber::Pager ); businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); addr.insertPhoneNumber( businesspager ); } addr.setRole( db->readField(ZdbAdrs::JobTitle) ); addr.setOrganization( db->readField(ZdbAdrs::Company) ); addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); //personal addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); QString gen = db->readField(ZdbAdrs::Gender); //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); if (gen == "1") addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); else if (gen == "2") addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); else addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef"); QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); if (ann.isValid()) { QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } else addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " "); addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); //qDebug("birtd %s ", birthd.toString().latin1()); if (birthd.isValid()) addr.setBirthday( birthd ); addr.setNickName( db->readField(ZdbAdrs::Nickname) ); // others //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. //QString notes = db->readField(ZdbAdrs::Notes); //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; if ( addr.url().isEmpty() ) addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); //US QString groups() const { return find( Qtopia::Groups ); } //US QStringList groupList() const; //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); QArray<int> catArray = db->readCategories(); QString cat; for ( unsigned int i=0; i < catArray.size(); i++ ) { cat = catDB->label(catArray[i]); if ( cat.isEmpty() ) addr.insertCategory(QString::number(catArray[i])); else addr.insertCategory( cat ); } return true; } bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) { bool cellHome = false, cellWork = false; // name database->writeField(ZdbAdrs::LastName, addr.familyName()); database->writeField(ZdbAdrs::FirstName, addr.givenName()); database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); database->writeField(ZdbAdrs::Title, addr.prefix()); database->writeField(ZdbAdrs::Suffix, addr.suffix()); //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); QString formattedName = addr.formattedName(); if ( formattedName.isEmpty() ) { if ( !addr.familyName().isEmpty() ) { formattedName = addr.familyName(); if ( !addr.givenName().isEmpty() ) { formattedName += ", "; formattedName += addr.givenName(); } } else formattedName = addr.givenName(); } |