|
|
|
@ -48,7 +48,7 @@ K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG( libkaddrbk_gmx_xxport, GMXXXPort, "libka
|
|
|
|
|
|
|
|
|
|
#define GMX_FILESELECTION_STRING "*.gmxa|" + i18n( "GMX addressbook file (*.gmxa)" )
|
|
|
|
|
|
|
|
|
|
GMXXXPort::GMXXXPort( KABC::AddressBook *ab, TQWidget *parent, const char *name )
|
|
|
|
|
GMXXXPort::GMXXXPort( TDEABC::AddressBook *ab, TQWidget *parent, const char *name )
|
|
|
|
|
: KAB::XXPort( ab, parent, name )
|
|
|
|
|
{
|
|
|
|
|
createImportAction( i18n( "Import GMX Address Book..." ) );
|
|
|
|
@ -68,9 +68,9 @@ static bool checkDateTime( const TQString &dateStr, TQDateTime &dt )
|
|
|
|
|
|
|
|
|
|
/* import */
|
|
|
|
|
|
|
|
|
|
KABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
TDEABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
{
|
|
|
|
|
KABC::AddresseeList addrList;
|
|
|
|
|
TDEABC::AddresseeList addrList;
|
|
|
|
|
|
|
|
|
|
TQString fileName = KFileDialog::getOpenFileName( ":xxport_gmx",
|
|
|
|
|
GMX_FILESELECTION_STRING, 0 );
|
|
|
|
@ -96,7 +96,7 @@ KABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQStringList strList;
|
|
|
|
|
typedef TQMap<TQString, KABC::Addressee *> AddressMap;
|
|
|
|
|
typedef TQMap<TQString, TDEABC::Addressee *> AddressMap;
|
|
|
|
|
AddressMap addrMap;
|
|
|
|
|
|
|
|
|
|
// "Address_id,Nickname,Firstname,Lastname,Title,Birthday,Comments,Change_date,Status,Address_link_id,Categories"
|
|
|
|
@ -110,7 +110,7 @@ KABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
line.append(gmxStream.readLine());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
KABC::Addressee *addr = new KABC::Addressee;
|
|
|
|
|
TDEABC::Addressee *addr = new TDEABC::Addressee;
|
|
|
|
|
addr->setNickName(strList[1]);
|
|
|
|
|
addr->setGivenName(strList[2]);
|
|
|
|
|
addr->setFamilyName(strList[3]);
|
|
|
|
@ -150,26 +150,26 @@ KABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
line.append(gmxStream.readLine());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
KABC::Addressee *addr = addrMap[strList[0]];
|
|
|
|
|
TDEABC::Addressee *addr = addrMap[strList[0]];
|
|
|
|
|
if (addr) {
|
|
|
|
|
for ( TQStringList::Iterator it = strList.begin(); it != strList.end(); ++it )
|
|
|
|
|
*it = (*it).simplifyWhiteSpace();
|
|
|
|
|
// strList[1] = Record_id (numbered item, ignore here)
|
|
|
|
|
int id = strList[14].toInt(); // Record_type_id (0=work,1=home,2=other)
|
|
|
|
|
int type = (id==0) ? KABC::Address::Work : KABC::Address::Home;
|
|
|
|
|
int type = (id==0) ? TDEABC::Address::Work : TDEABC::Address::Home;
|
|
|
|
|
if (!strList[19].isEmpty() && strList[19].toInt()!=0)
|
|
|
|
|
type |= KABC::Address::Pref; // Preferred address (seems to be bitfield for telephone Prefs)
|
|
|
|
|
KABC::Address adr = addr->address(type);
|
|
|
|
|
type |= TDEABC::Address::Pref; // Preferred address (seems to be bitfield for telephone Prefs)
|
|
|
|
|
TDEABC::Address adr = addr->address(type);
|
|
|
|
|
adr.setStreet(strList[2]);
|
|
|
|
|
adr.setCountry(strList[3]);
|
|
|
|
|
adr.setPostalCode(strList[4]);
|
|
|
|
|
adr.setLocality(strList[5]);
|
|
|
|
|
addr->insertPhoneNumber( KABC::PhoneNumber(strList[6], KABC::PhoneNumber::Home) );
|
|
|
|
|
addr->insertPhoneNumber( KABC::PhoneNumber(strList[7], KABC::PhoneNumber::Fax) );
|
|
|
|
|
int celltype = KABC::PhoneNumber::Cell;
|
|
|
|
|
addr->insertPhoneNumber( TDEABC::PhoneNumber(strList[6], TDEABC::PhoneNumber::Home) );
|
|
|
|
|
addr->insertPhoneNumber( TDEABC::PhoneNumber(strList[7], TDEABC::PhoneNumber::Fax) );
|
|
|
|
|
int celltype = TDEABC::PhoneNumber::Cell;
|
|
|
|
|
// strList[9]=Mobile_type // always 0 or -1(default phone).
|
|
|
|
|
if (strList[9].toInt()) celltype |= KABC::PhoneNumber::Pref;
|
|
|
|
|
addr->insertPhoneNumber( KABC::PhoneNumber(strList[8], celltype) );
|
|
|
|
|
if (strList[9].toInt()) celltype |= TDEABC::PhoneNumber::Pref;
|
|
|
|
|
addr->insertPhoneNumber( TDEABC::PhoneNumber(strList[8], celltype) );
|
|
|
|
|
addr->insertEmail(strList[10]);
|
|
|
|
|
if (!strList[11].isEmpty()) addr->setUrl(strList[11]);
|
|
|
|
|
if (!strList[12].isEmpty()) addr->setRole(strList[12]);
|
|
|
|
@ -192,7 +192,7 @@ KABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
|
|
|
|
|
// now add the addresses to to addrList
|
|
|
|
|
for ( AddressMap::Iterator it = addrMap.begin(); it != addrMap.end(); ++it ) {
|
|
|
|
|
KABC::Addressee *addr = it.data();
|
|
|
|
|
TDEABC::Addressee *addr = it.data();
|
|
|
|
|
addrList.append(*addr);
|
|
|
|
|
delete addr;
|
|
|
|
|
}
|
|
|
|
@ -204,7 +204,7 @@ KABC::AddresseeList GMXXXPort::importContacts( const TQString& ) const
|
|
|
|
|
|
|
|
|
|
/* export */
|
|
|
|
|
|
|
|
|
|
bool GMXXXPort::exportContacts( const KABC::AddresseeList &list, const TQString& )
|
|
|
|
|
bool GMXXXPort::exportContacts( const TDEABC::AddresseeList &list, const TQString& )
|
|
|
|
|
{
|
|
|
|
|
KURL url = KFileDialog::getSaveURL( ":xxport_gmx", GMX_FILESELECTION_STRING );
|
|
|
|
|
if ( url.isEmpty() )
|
|
|
|
@ -249,7 +249,7 @@ static const TQString dateString( const TQDateTime &dt )
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GMXXXPort::doExport( TQFile *fp, const KABC::AddresseeList &list )
|
|
|
|
|
void GMXXXPort::doExport( TQFile *fp, const TDEABC::AddresseeList &list )
|
|
|
|
|
{
|
|
|
|
|
if (!fp || !list.count())
|
|
|
|
|
return;
|
|
|
|
@ -257,10 +257,10 @@ void GMXXXPort::doExport( TQFile *fp, const KABC::AddresseeList &list )
|
|
|
|
|
TQTextStream t( fp );
|
|
|
|
|
t.setEncoding( TQTextStream::Latin1 );
|
|
|
|
|
|
|
|
|
|
KABC::AddresseeList::ConstIterator it;
|
|
|
|
|
typedef TQMap<int, const KABC::Addressee *> AddressMap;
|
|
|
|
|
TDEABC::AddresseeList::ConstIterator it;
|
|
|
|
|
typedef TQMap<int, const TDEABC::Addressee *> AddressMap;
|
|
|
|
|
AddressMap addrMap;
|
|
|
|
|
const KABC::Addressee *addr;
|
|
|
|
|
const TDEABC::Addressee *addr;
|
|
|
|
|
|
|
|
|
|
t << "AB_ADDRESSES:\n";
|
|
|
|
|
t << "Address_id,Nickname,Firstname,Lastname,Title,Birthday,Comments,"
|
|
|
|
@ -294,19 +294,19 @@ void GMXXXPort::doExport( TQFile *fp, const KABC::AddresseeList &list )
|
|
|
|
|
while ( (addr = addrMap[no]) != NULL ) {
|
|
|
|
|
for (unsigned int record_id=0; record_id<3; record_id++) {
|
|
|
|
|
|
|
|
|
|
KABC::Address address;
|
|
|
|
|
KABC::PhoneNumber phone, fax, cell;
|
|
|
|
|
TDEABC::Address address;
|
|
|
|
|
TDEABC::PhoneNumber phone, fax, cell;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (record_id == 0) {
|
|
|
|
|
address = addr->address(KABC::Address::Work);
|
|
|
|
|
phone = addr->phoneNumber(KABC::PhoneNumber::Work);
|
|
|
|
|
fax = addr->phoneNumber(KABC::PhoneNumber::Fax);
|
|
|
|
|
cell = addr->phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell);
|
|
|
|
|
address = addr->address(TDEABC::Address::Work);
|
|
|
|
|
phone = addr->phoneNumber(TDEABC::PhoneNumber::Work);
|
|
|
|
|
fax = addr->phoneNumber(TDEABC::PhoneNumber::Fax);
|
|
|
|
|
cell = addr->phoneNumber(TDEABC::PhoneNumber::Work | TDEABC::PhoneNumber::Cell);
|
|
|
|
|
} else {
|
|
|
|
|
address = addr->address(KABC::Address::Home);
|
|
|
|
|
phone = addr->phoneNumber(KABC::PhoneNumber::Home);
|
|
|
|
|
cell = addr->phoneNumber(KABC::PhoneNumber::Cell);
|
|
|
|
|
address = addr->address(TDEABC::Address::Home);
|
|
|
|
|
phone = addr->phoneNumber(TDEABC::PhoneNumber::Home);
|
|
|
|
|
cell = addr->phoneNumber(TDEABC::PhoneNumber::Cell);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TQStringList emails = addr->emails();
|
|
|
|
@ -322,7 +322,7 @@ void GMXXXPort::doExport( TQFile *fp, const KABC::AddresseeList &list )
|
|
|
|
|
<< phone.number() << DELIM // Phone
|
|
|
|
|
<< fax.number() << DELIM // Fax
|
|
|
|
|
<< cell.number() << DELIM // Mobile
|
|
|
|
|
<< ((cell.type()&KABC::PhoneNumber::Pref)?-1:0) << DELIM // Mobile_type
|
|
|
|
|
<< ((cell.type()&TDEABC::PhoneNumber::Pref)?-1:0) << DELIM // Mobile_type
|
|
|
|
|
<< email << DELIM // Email
|
|
|
|
|
<< ((record_id==0)?addr->url().url():TQString()) << DELIM // Homepage
|
|
|
|
|
<< ((record_id==0)?addr->role():TQString()) << DELIM // Position
|
|
|
|
|