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