summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
authorzautrix <zautrix>2004-10-15 14:52:41 (UTC)
committer zautrix <zautrix>2004-10-15 14:52:41 (UTC)
commit5073db0790d4ac053624b5468107deaa9957315d (patch) (side-by-side diff)
treec40971cc49e8bc3ef455953bdc725ab5fde8b215 /kabc/plugins/sharpdtm/sharpdtmconverter.cpp
parent4f276d80bd977401d656851515474cc00c661e5b (diff)
downloadkdepimpi-5073db0790d4ac053624b5468107deaa9957315d.zip
kdepimpi-5073db0790d4ac053624b5468107deaa9957315d.tar.gz
kdepimpi-5073db0790d4ac053624b5468107deaa9957315d.tar.bz2
dtm sync fix
Diffstat (limited to 'kabc/plugins/sharpdtm/sharpdtmconverter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
index 6418b54..396be0a 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
@@ -74,231 +74,231 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa
// 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)); // needs fix
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) );
+ 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.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.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) );
+ 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.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.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
addr.insertPhoneNumber( businessmobile );
}
if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
{
PhoneNumber businesspager;
businesspager.setType( PhoneNumber::Work | 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 == "male")
addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
else if (gen == "female")
addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
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);
}
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);
+ //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) );
+ 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();
}
database->writeField(ZdbAdrs::FileAs, formattedName);
database->writeField(ZdbAdrs::FullName, formattedName);
// email
//qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");