summaryrefslogtreecommitdiffabout
path: root/kabc/converter/sharpdtm
authorulf69 <ulf69>2004-07-19 20:02:38 (UTC)
committer ulf69 <ulf69>2004-07-19 20:02:38 (UTC)
commitd498ea750239bffa7ec811aa3e60befc6bae9608 (patch) (side-by-side diff)
treebfb72103c930030cae150fb1fbe68557ca367183 /kabc/converter/sharpdtm
parentaea3eb6a96f971af49d4a75586c98cbcbb883a76 (diff)
downloadkdepimpi-d498ea750239bffa7ec811aa3e60befc6bae9608.zip
kdepimpi-d498ea750239bffa7ec811aa3e60befc6bae9608.tar.gz
kdepimpi-d498ea750239bffa7ec811aa3e60befc6bae9608.tar.bz2
the newest version of the sharp converter
Diffstat (limited to 'kabc/converter/sharpdtm') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/sharpdtm/sharpdtmconverter.cpp270
-rw-r--r--kabc/converter/sharpdtm/sharpdtmconverter.h2
2 files changed, 147 insertions, 125 deletions
diff --git a/kabc/converter/sharpdtm/sharpdtmconverter.cpp b/kabc/converter/sharpdtm/sharpdtmconverter.cpp
index 4cf2eb3..8f8334e 100644
--- a/kabc/converter/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/converter/sharpdtm/sharpdtmconverter.cpp
@@ -68,295 +68,317 @@ void SharpDTMConverter::deinit()
bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
{
-/*US
+ SlZDataBase* db = (SlZDataBase*)database;
// name
- addr.setFormattedName(contact.fileAs());
- addr.setFamilyName( contact.lastName() );
- addr.setGivenName( contact.firstName() );
- addr.setAdditionalName( contact.middleName() );
- addr.setPrefix( contact.nameTitle() );
- addr.setSuffix( contact.suffix() );
+ qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!");
+ addr.setFormattedName(db->readField(ZdbAdrs::FileAs));
+
+ 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) );
// email
- QStringList emails = contact.emailList();
+ QString emailstr = db->readField(ZdbAdrs::Emails);
+ qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1());
+ QStringList emails = QStringList::split(",", emailstr);
+
for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
- addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
+ addr.insertEmail( *it, ((*it) == db->readField(ZdbAdrs::DefaultEmail)) );
}
- if (!contact.defaultEmail().isEmpty())
- addr.insertEmail(contact.defaultEmail(), true);
+ if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty())
+ addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true);
// home
- if ((!contact.homeStreet().isEmpty()) ||
- (!contact.homeCity().isEmpty()) ||
- (!contact.homeState().isEmpty()) ||
- (!contact.homeZip().isEmpty()) ||
- (!contact.homeCountry().isEmpty()))
+ 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( contact.homeStreet() );
- homeaddress.setLocality( contact.homeCity() );
- homeaddress.setRegion( contact.homeState() );
- homeaddress.setPostalCode( contact.homeZip() );
- homeaddress.setCountry( contact.homeCountry() );
+ homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) );
+ 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 (!contact.homePhone().isEmpty())
+ if (!db->readField(ZdbAdrs::HomePhone).isEmpty())
{
PhoneNumber homephone;
homephone.setType( PhoneNumber::Home );
- homephone.setNumber( contact.homePhone() );
+ homephone.setNumber( db->readField(ZdbAdrs::HomePhone) );
addr.insertPhoneNumber( homephone );
}
- if (!contact.homeFax().isEmpty())
+ if (!db->readField(ZdbAdrs::HomeFax).isEmpty())
{
PhoneNumber homefax;
homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
- homefax.setNumber( contact.homeFax() );
+ homefax.setNumber( db->readField(ZdbAdrs::HomeFax) );
addr.insertPhoneNumber( homefax );
}
- if (!contact.homeMobile().isEmpty())
+ if (!db->readField(ZdbAdrs::HomeMobile).isEmpty())
{
PhoneNumber homemobile;
homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
- homemobile.setNumber( contact.homeMobile() );
+ homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) );
addr.insertPhoneNumber( homemobile );
}
- addr.setUrl( contact.homeWebpage() );
+ addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) );
// business
- if ((!contact.businessStreet().isEmpty()) ||
- (!contact.businessCity().isEmpty()) ||
- (!contact.businessState().isEmpty()) ||
- (!contact.businessZip().isEmpty()) ||
- (!contact.businessCountry().isEmpty()))
+ 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( contact.businessStreet() );
- businessaddress.setLocality( contact.businessCity() );
- businessaddress.setRegion( contact.businessState() );
- businessaddress.setPostalCode( contact.businessZip() );
- businessaddress.setCountry( contact.businessCountry() );
+ businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) );
+ 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 (!contact.businessPhone().isEmpty())
+ if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty())
{
PhoneNumber businessphone;
businessphone.setType( PhoneNumber::Work );
- businessphone.setNumber( contact.businessPhone() );
+ businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) );
addr.insertPhoneNumber( businessphone );
}
- if (!contact.businessFax().isEmpty())
+ if (!db->readField(ZdbAdrs::BusinessFax).isEmpty())
{
PhoneNumber businessfax;
businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
- businessfax.setNumber( contact.businessFax() );
+ businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) );
addr.insertPhoneNumber( businessfax );
}
- if (!contact.businessMobile().isEmpty())
+ if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty())
{
PhoneNumber businessmobile;
businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
- businessmobile.setNumber( contact.businessMobile() );
+ businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
addr.insertPhoneNumber( businessmobile );
}
- if (!contact.businessPager().isEmpty())
+ if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
{
PhoneNumber businesspager;
businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
- businesspager.setNumber( contact.businessPager() );
+ businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) );
addr.insertPhoneNumber( businesspager );
}
- addr.setRole( contact.jobTitle() ); //?
- addr.setOrganization( contact.company() );
- addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
- addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
- addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
- addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
- addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
+ 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", contact.spouse() );
- // qtopia uses this categorization:
- // enum GenderType { UnspecifiedGender=0, Male, Female };
- if (contact.gender() == PimContact::Male)
+ 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 == "male")
addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
- else if (contact.gender() == PimContact::Female)
+ else if (gen == "female")
addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
- if (contact.anniversary().isValid()) {
- QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
+
+ QDate ann = db->readDateField(ZdbAdrs::Anniversary);
+
+ if (ann.isValid()) {
+ QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
//US
// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
}
- addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
- if (contact.birthday().isValid())
- addr.setBirthday( contact.birthday() );
+ addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) );
+
+
+ QDate birthd = db->readDateField(ZdbAdrs::Birthday);
+ if (birthd.isValid())
+ addr.setBirthday( birthd );
- addr.setNickName( contact.nickname() );
+ 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 = contact.notes();
- notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
+ QString notes = db->readField(ZdbAdrs::Notes);
+ notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n";
- addr.setNote( contact.notes() );
+ addr.setNote( db->readField(ZdbAdrs::Notes) );
//US QString groups() const { return find( Qtopia::Groups ); }
//US QStringList groupList() const;
- QArray<int> catArray = contact.categories();
+ 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("contact", catArray[i]);
- if ( !cat.isEmpty() )
+ 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, const SlZDataBase* database , const CardId &contact )
+bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact )
{
-/*US
// name
- contact.setLastName(addr.familyName());
- contact.setFirstName(addr.givenName());
- contact.setMiddleName(addr.additionalName());
- contact.setNameTitle(addr.prefix());
- contact.setSuffix(addr.suffix());
- contact.setFileAs();
+ 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!!");
+ database->writeField(ZdbAdrs::FileAs, addr.formattedName());
// email
- QStringList emails = addr.emails();
- for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
- contact.insertEmail(*it);
- }
- contact.setDefaultEmail( addr.preferredEmail() );
+ qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
+ qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
+ QString emails = addr.emails().join(",");
+ database->writeField(ZdbAdrs::Emails, emails );
+
+ database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
// home
const Address homeaddress = addr.address(Address::Home);
if (!homeaddress.isEmpty()) {
- contact.setHomeStreet(homeaddress.street());
- contact.setHomeCity(homeaddress.locality());
- contact.setHomeState(homeaddress.region());
- contact.setHomeZip(homeaddress.postalCode());
- contact.setHomeCountry(homeaddress.country());
+ database->writeField(ZdbAdrs::HomeStreet, homeaddress.street());
+ database->writeField(ZdbAdrs::HomeCity, homeaddress.locality());
+ database->writeField(ZdbAdrs::HomeState, homeaddress.region());
+ database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode());
+ database->writeField(ZdbAdrs::HomeCountry, homeaddress.country());
}
PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
if (!homephone.number().isEmpty())
- contact.setHomePhone(homephone.number());
+ database->writeField(ZdbAdrs::HomePhone, homephone.number());
PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
if (!homefax.number().isEmpty())
- contact.setHomeFax(homefax.number());
+ database->writeField(ZdbAdrs::HomeFax, homefax.number());
PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
if (!homemobile.number().isEmpty())
- contact.setHomeMobile(homemobile.number());
+ database->writeField(ZdbAdrs::HomeMobile, homemobile.number());
- contact.setHomeWebpage(addr.url().url());
+ database->writeField(ZdbAdrs::HomeWebPage, addr.url().url());
// business
const Address businessaddress = addr.address(Address::Work);
if (!businessaddress.isEmpty()) {
- contact.setBusinessStreet(businessaddress.street());
- contact.setBusinessCity(businessaddress.locality());
- contact.setBusinessState(businessaddress.region());
- contact.setBusinessZip(businessaddress.postalCode());
- contact.setBusinessCountry(businessaddress.country());
+ database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street());
+ database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality());
+ database->writeField(ZdbAdrs::BusinessState, businessaddress.region());
+ database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode());
+ database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country());
}
PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
if (!businessphone.number().isEmpty())
- contact.setBusinessPhone(businessphone.number());
+ database->writeField(ZdbAdrs::BusinessPhone, businessphone.number());
PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
if (!businessfax.number().isEmpty())
- contact.setBusinessFax(businessfax.number());
+ database->writeField(ZdbAdrs::BusinessFax, businessfax.number());
PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
if (!businessmobile.number().isEmpty())
- contact.setBusinessMobile(businessmobile.number());
+ database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
if (!businesspager.number().isEmpty())
- contact.setBusinessPager(businesspager.number());
+ database->writeField(ZdbAdrs::BusinessPager, businesspager.number());
- contact.setJobTitle(addr.role());
- contact.setCompany(addr.organization());
+ database->writeField(ZdbAdrs::JobTitle, addr.role());
+ database->writeField(ZdbAdrs::Company, addr.organization());
- contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
- contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
- contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
- contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
- contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
+ database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" ));
+ database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
+ database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" ));
+ database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
+ database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" ));
//personal
- contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
- // qtopia uses this categorization:
- // enum GenderType { UnspecifiedGender=0, Male, Female };
+ database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" ));
+
QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
+ qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1());
+ qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?");
+ qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee");
if (gt = "male")
- contact.setGender(PimContact::Male);
+ database->writeField(ZdbAdrs::Gender, "male");
else if (gt = "female")
- contact.setGender(PimContact::Female);
+ database->writeField(ZdbAdrs::Gender, "female");
else
- contact.setGender(PimContact::UnspecifiedGender);
+ database->writeField(ZdbAdrs::Gender, "");
QDate dt = KGlobal::locale()->readDate(
addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
- contact.setAnniversary( dt );
+ database->writeField(ZdbAdrs::Anniversary, dt );
- contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
+ database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" ));
- contact.setBirthday(addr.birthday().date());
- contact.setNickname(addr.nickName());
+ database->writeField(ZdbAdrs::Birthday, addr.birthday().date());
+ database->writeField(ZdbAdrs::Nickname, addr.nickName());
// other
- contact.setNotes(addr.note());
+ database->writeField(ZdbAdrs::Notes, addr.note());
//US QString groups() const { return find( Qtopia::Groups ); }
//US QStringList groupList() const;
- QStringList cats = addr.categories();
+ qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works");
+ QStringList cats = addr.categories();
QArray<int> iar;
if ( !cats.isEmpty() ) {
- QArray<int> iar = catDB->ids("contact", cats);
- contact.setCategories(iar);
+ QArray<int> iar = catDB->ids(cats);
+ database->updateCategories(contact, iar);
}
-*/
+
return true;
}
diff --git a/kabc/converter/sharpdtm/sharpdtmconverter.h b/kabc/converter/sharpdtm/sharpdtmconverter.h
index 6a55431..99e0413 100644
--- a/kabc/converter/sharpdtm/sharpdtmconverter.h
+++ b/kabc/converter/sharpdtm/sharpdtmconverter.h
@@ -74,7 +74,7 @@ public:
* @param database The sharp database pointer we use for the conversion
* @param contact The sharp card id, eventhough it might be 0, if the contact is a new one.
*/
- bool addresseeToSharp( const Addressee &addr, const SlZDataBase* database , const CardId &contact );
+ bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact );
private:
SlCategory::SlCategories* catDB;