summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia
Unidiff
Diffstat (limited to 'kabc/plugins/qtopia') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopia.pro16
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro6
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp24
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.h9
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp14
-rw-r--r--kabc/plugins/qtopia/resourceqtopiaconfig.cpp4
6 files changed, 42 insertions, 31 deletions
diff --git a/kabc/plugins/qtopia/qtopia.pro b/kabc/plugins/qtopia/qtopia.pro
index 64d1abc..d91a2e3 100644
--- a/kabc/plugins/qtopia/qtopia.pro
+++ b/kabc/plugins/qtopia/qtopia.pro
@@ -1,43 +1,47 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 3
4include( ../../../variables.pri ) 4include( ../../../variables.pri )
5 5
6TARGET = microkabc_qtopia 6TARGET = xmicrokabc_qtopia
7 7
8INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources 8INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources
9 9
10DESTDIR = ../../../bin 10DESTDIR = ../../../bin
11#LIBS += -lmicrokde 11#LIBS += -lxmicrokde
12#LIBS += -lkamicrokabc 12#LIBS += -lxkamicrokabc
13 13
14DEFINES += KAB_EMBEDDED DESKTOP_VERSION 14DEFINES += KAB_EMBEDDED DESKTOP_VERSION
15 15
16INTERFACES = \ 16INTERFACES = \
17 17
18HEADERS = \ 18HEADERS = \
19 resourceqtopia.h \ 19 resourceqtopia.h \
20 resourceqtopiaconfig.h \ 20 resourceqtopiaconfig.h \
21 qtopiaconverter.h 21 qtopiaconverter.h
22 22
23SOURCES = \ 23SOURCES = \
24 resourceqtopia.cpp \ 24 resourceqtopia.cpp \
25 resourceqtopiaconfig.cpp \ 25 resourceqtopiaconfig.cpp \
26 qtopiaconverter.cpp 26 qtopiaconverter.cpp
27 27
28 28
29 29
30unix : { 30unix : {
31OBJECTS_DIR = obj/unix 31OBJECTS_DIR = obj/unix
32MOC_DIR = moc/unix 32MOC_DIR = moc/unix
33} 33}
34win32: { 34win32: {
35CONFIG += dll 35CONFIG += dll
36DEFINES += _WIN32_ 36DEFINES += _WIN32_
37OBJECTS_DIR = obj/win 37OBJECTS_DIR = obj/win
38MOC_DIR = moc/win 38MOC_DIR = moc/win
39LIBS += ../../../bin/microkdepim.lib 39LIBS += ../../../bin/xmicrokdepim.lib
40LIBS += ../../../bin/microkcal.lib 40LIBS += ../../../bin/xmicrokcal.lib
41LIBS += ../../../bin/microkde.lib 41LIBS += ../../../bin/xmicrokde.lib
42LIBS += ../../../bin/microkabc.lib 42LIBS += ../../../bin/microkabc.lib
43} 43}
44#The following line was inserted by qt3to4
45QT += xml qt3support
46#The following line was inserted by qt3to4
47QT +=
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 700057b..4b174b2 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -1,26 +1,26 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3 3
4TARGET = microkabc_qtopia 4TARGET = xmicrokabc_qtopia
5 5
6INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 6INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
7 7
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += -lmicrokde 11LIBS += -lxmicrokde
12LIBS += -lmicrokabc 12LIBS += -lxmicrokabc
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14LIBS += -lqpe 14LIBS += -lqpe
15 15
16INTERFACES = \ 16INTERFACES = \
17 17
18HEADERS = \ 18HEADERS = \
19 resourceqtopia.h \ 19 resourceqtopia.h \
20 resourceqtopiaconfig.h \ 20 resourceqtopiaconfig.h \
21 qtopiaconverter.h 21 qtopiaconverter.h
22 22
23SOURCES = \ 23SOURCES = \
24 resourceqtopia.cpp \ 24 resourceqtopia.cpp \
25 resourceqtopiaconfig.cpp \ 25 resourceqtopiaconfig.cpp \
26 qtopiaconverter.cpp 26 qtopiaconverter.cpp
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 9693a68..9b3903b 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -13,87 +13,89 @@
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30#include "klocale.h" 30#include "klocale.h"
31 31
32 32
33#include "qtopiaconverter.h" 33#include "qtopiaconverter.h"
34 34
35#include <qfile.h> 35#include <qfile.h>
36#include <qdir.h> 36#include <qdir.h>
37#include <qtextstream.h> 37#include <q3textstream.h>
38//Added by qt3to4:
39#include <Q3ValueList>
38//#include <.h> 40//#include <.h>
39 41
40#include <libkdepim/ksyncprofile.h> 42#include <libkdepim/ksyncprofile.h>
41 43
42 44
43using namespace KABC; 45using namespace KABC;
44 46
45QtopiaConverter::QtopiaConverter() 47QtopiaConverter::QtopiaConverter()
46{ 48{
47 m_edit = 0; 49 m_edit = 0;
48} 50}
49 51
50QtopiaConverter::~QtopiaConverter() 52QtopiaConverter::~QtopiaConverter()
51{ 53{
52 deinit(); 54 deinit();
53} 55}
54 56
55bool QtopiaConverter::init() 57bool QtopiaConverter::init()
56{ 58{
57 QString fn = QDir::homeDirPath() +"/Settings/Categories.xml"; 59 QString fn = QDir::homeDirPath() +"/Settings/Categories.xml";
58 m_edit = new CategoryEdit( fn); 60 m_edit = new CategoryEdit( fn);
59 return true; 61 return true;
60} 62}
61 63
62void QtopiaConverter::deinit() 64void QtopiaConverter::deinit()
63{ 65{
64 if (m_edit) 66 if (m_edit)
65 { 67 {
66 delete m_edit; 68 delete m_edit;
67 m_edit = 0; 69 m_edit = 0;
68 } 70 }
69} 71}
70QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app ) 72QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app )
71{ 73{
72 startover: 74 startover:
73 QStringList dummy; 75 QStringList dummy;
74 QValueList<OpieCategories>::ConstIterator catIt; 76 Q3ValueList<OpieCategories>::ConstIterator catIt;
75 QValueList<OpieCategories> categories = m_edit->categories(); 77 Q3ValueList<OpieCategories> categories = m_edit->categories();
76 bool found = false; 78 bool found = false;
77 for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { 79 for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) {
78 /* skip empty category name */ 80 /* skip empty category name */
79 if ( (*listIt).isEmpty() ) continue; 81 if ( (*listIt).isEmpty() ) continue;
80 82
81 found = false; 83 found = false;
82 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 84 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
83 /* 85 /*
84 * We currently do not take app into account 86 * We currently do not take app into account
85 * if name matches and the id isn't already in dummy we'll add it 87 * if name matches and the id isn't already in dummy we'll add it
86 */ 88 */
87 if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name 89 if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name
88 found= true; 90 found= true;
89 dummy << (*catIt).id(); 91 dummy << (*catIt).id();
90 } 92 }
91 } 93 }
92 /* if not found and the category is not empty 94 /* if not found and the category is not empty
93 * 95 *
94 * generate a new category and start over again 96 * generate a new category and start over again
95 * ugly goto to reiterate 97 * ugly goto to reiterate
96 */ 98 */
97 99
98 if ( !found && !(*listIt).isEmpty() ){ 100 if ( !found && !(*listIt).isEmpty() ){
99 m_edit->addCategory( app, (*listIt) ); // generate a new category 101 m_edit->addCategory( app, (*listIt) ); // generate a new category
@@ -171,49 +173,49 @@ QString QtopiaConverter::dateToString( const QDate &d )
171 QString year = QString::number( d.year() ); 173 QString year = QString::number( d.year() );
172 QString month = QString::number( d.month() ); 174 QString month = QString::number( d.month() );
173 month = month.rightJustify( 2, '0' ); 175 month = month.rightJustify( 2, '0' );
174 QString day = QString::number( d.day() ); 176 QString day = QString::number( d.day() );
175 day = day.rightJustify( 2, '0' ); 177 day = day.rightJustify( 2, '0' );
176 178
177 QString str = year + month + day; 179 QString str = year + month + day;
178 180
179 return str; 181 return str;
180} 182}
181 183
182bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr ) 184bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
183{ 185{
184 { //LR 186 { //LR
185 187
186 adr.setUid( el.attribute("Uid" ) ); 188 adr.setUid( el.attribute("Uid" ) );
187 adr.setFamilyName( el.attribute( "LastName" ) ); 189 adr.setFamilyName( el.attribute( "LastName" ) );
188 adr.setGivenName( el.attribute( "FirstName" ) ); 190 adr.setGivenName( el.attribute( "FirstName" ) );
189 adr.setAdditionalName( el.attribute( "MiddleName" ) ); 191 adr.setAdditionalName( el.attribute( "MiddleName" ) );
190 adr.setSuffix( el.attribute( "Suffix" ) ); 192 adr.setSuffix( el.attribute( "Suffix" ) );
191 adr.setNickName( el.attribute( "Nickname" ) ); 193 adr.setNickName( el.attribute( "Nickname" ) );
192 194
193 QDate date = dateFromString( el.attribute( "Birthday" ) ); 195 QDate date = dateFromString( el.attribute( "Birthday" ) );
194 if ( date.isValid() ) 196 if ( date.isValid() )
195 adr.setBirthday( date ); 197 adr.setBirthday( (QDateTime)date );
196 198
197 adr.setRole( el.attribute( "JobTitle" ) ); 199 adr.setRole( el.attribute( "JobTitle" ) );
198 if ( !el.attribute( "FileAs" ).isEmpty() ) 200 if ( !el.attribute( "FileAs" ).isEmpty() )
199 adr.setFormattedName( el.attribute( "FileAs" ) ); 201 adr.setFormattedName( el.attribute( "FileAs" ) );
200 202
201 adr.setOrganization( el.attribute( "Company" ) ); 203 adr.setOrganization( el.attribute( "Company" ) );
202 204
203 KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ), 205 KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ),
204 KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 206 KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
205 KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ), 207 KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ),
206 KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 208 KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
207 KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ), 209 KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ),
208 KABC::PhoneNumber::Car ); 210 KABC::PhoneNumber::Car );
209 KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ), 211 KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ),
210 KABC::PhoneNumber::Pager ); 212 KABC::PhoneNumber::Pager );
211 if ( !businessPhoneNum.number().isEmpty() ) 213 if ( !businessPhoneNum.number().isEmpty() )
212 adr.insertPhoneNumber( businessPhoneNum ); 214 adr.insertPhoneNumber( businessPhoneNum );
213 if ( !businessFaxNum.number().isEmpty() ) 215 if ( !businessFaxNum.number().isEmpty() )
214 adr.insertPhoneNumber( businessFaxNum ); 216 adr.insertPhoneNumber( businessFaxNum );
215 if ( !businessMobile.number().isEmpty() ) 217 if ( !businessMobile.number().isEmpty() )
216 adr.insertPhoneNumber( businessMobile ); 218 adr.insertPhoneNumber( businessMobile );
217 if ( !businessPager.number().isEmpty() ) 219 if ( !businessPager.number().isEmpty() )
218 adr.insertPhoneNumber( businessPager ); 220 adr.insertPhoneNumber( businessPager );
219 221
@@ -296,49 +298,49 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); 298 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
297 } 299 }
298 QDate ann = dateFromString( el.attribute( "Anniversary" ) ); 300 QDate ann = dateFromString( el.attribute( "Anniversary" ) );
299 if ( ann.isValid() ) { 301 if ( ann.isValid() ) {
300 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 302 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
301 adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt ); 303 adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt );
302 } 304 }
303 305
304 if ( !el.attribute( "Children" ).isEmpty() ) 306 if ( !el.attribute( "Children" ).isEmpty() )
305 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") ); 307 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") );
306 if ( !el.attribute( "Office" ).isEmpty() ) 308 if ( !el.attribute( "Office" ).isEmpty() )
307 adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") ); 309 adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") );
308 if ( !el.attribute( "Profession" ).isEmpty() ) 310 if ( !el.attribute( "Profession" ).isEmpty() )
309 adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") ); 311 adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") );
310 if ( !el.attribute( "Assistant" ).isEmpty() ) 312 if ( !el.attribute( "Assistant" ).isEmpty() )
311 adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") ); 313 adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") );
312 if ( !el.attribute( "Manager" ).isEmpty() ) 314 if ( !el.attribute( "Manager" ).isEmpty() )
313 adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") ); 315 adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") );
314 316
315 317
316 } 318 }
317 return true; 319 return true;
318} 320}
319 321
320bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream ) 322bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, Q3TextStream *stream )
321{ 323{
322 *stream << "<Contact "; 324 *stream << "<Contact ";
323 *stream << "FirstName=\"" << escape(ab.givenName()) << "\" "; 325 *stream << "FirstName=\"" << escape(ab.givenName()) << "\" ";
324 *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" "; 326 *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" ";
325 *stream << "LastName=\"" << escape(ab.familyName()) << "\" "; 327 *stream << "LastName=\"" << escape(ab.familyName()) << "\" ";
326 *stream << "Suffix=\"" << escape(ab.suffix()) << "\" "; 328 *stream << "Suffix=\"" << escape(ab.suffix()) << "\" ";
327 329
328 QString sortStr; 330 QString sortStr;
329 sortStr = ab.formattedName(); 331 sortStr = ab.formattedName();
330 /* is formattedName is empty we use the assembled name as fallback */ 332 /* is formattedName is empty we use the assembled name as fallback */
331 if (sortStr.isEmpty() ) 333 if (sortStr.isEmpty() )
332 sortStr = ab.assembledName(); 334 sortStr = ab.assembledName();
333 *stream << "FileAs=\"" << escape(sortStr) << "\" "; 335 *stream << "FileAs=\"" << escape(sortStr) << "\" ";
334 336
335 *stream << "JobTitle=\"" << escape(ab.role()) << "\" "; 337 *stream << "JobTitle=\"" << escape(ab.role()) << "\" ";
336 *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" "; 338 *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" ";
337 *stream << "Company=\"" << escape(ab.organization()) << "\" "; 339 *stream << "Company=\"" << escape(ab.organization()) << "\" ";
338 340
339 KABC::PhoneNumber businessPhoneNum = ab.phoneNumber(KABC::PhoneNumber::Work ); 341 KABC::PhoneNumber businessPhoneNum = ab.phoneNumber(KABC::PhoneNumber::Work );
340 *stream << "BusinessPhone=\"" << escape( businessPhoneNum.number() ) << "\" "; 342 *stream << "BusinessPhone=\"" << escape( businessPhoneNum.number() ) << "\" ";
341 343
342 KABC::PhoneNumber businessFaxNum = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 344 KABC::PhoneNumber businessFaxNum = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
343 *stream << "BusinessFax=\"" << escape( businessFaxNum.number() )<< "\" "; 345 *stream << "BusinessFax=\"" << escape( businessFaxNum.number() )<< "\" ";
344 346
@@ -463,102 +465,102 @@ QStringList AddressBook::attributes()const {
463 lst << "Children"; 465 lst << "Children";
464 lst << "Notes"; 466 lst << "Notes";
465 lst << "Categories"; 467 lst << "Categories";
466 lst << "Uid"; 468 lst << "Uid";
467 lst << "Birthday"; 469 lst << "Birthday";
468 470
469 return lst; 471 return lst;
470} 472}
471 473
472 474
473 475
474#endif 476#endif
475 477
476 478
477CategoryEdit::CategoryEdit(){ 479CategoryEdit::CategoryEdit(){
478} 480}
479CategoryEdit::CategoryEdit(const QString &fileName){ 481CategoryEdit::CategoryEdit(const QString &fileName){
480 parse( fileName ); 482 parse( fileName );
481} 483}
482CategoryEdit::~CategoryEdit(){ 484CategoryEdit::~CategoryEdit(){
483} 485}
484void CategoryEdit::save(const QString& fileName)const{ 486void CategoryEdit::save(const QString& fileName)const{
485 QFile file( fileName ); 487 QFile file( fileName );
486 QString endl = "\n"; 488 QString endl = "\n";
487 if ( file.open( IO_WriteOnly ) ) { 489 if ( file.open( QIODevice::WriteOnly ) ) {
488 QTextStream stream( &file ); 490 Q3TextStream stream( &file );
489 stream.setEncoding( QTextStream::UnicodeUTF8 ); 491 stream.setEncoding( Q3TextStream::UnicodeUTF8 );
490 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; 492 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
491 stream << "<!DOCTYPE CategoryList>" << endl; 493 stream << "<!DOCTYPE CategoryList>" << endl;
492 stream << "<Categories>" << endl; 494 stream << "<Categories>" << endl;
493 for ( QValueList<OpieCategories>::ConstIterator it = m_categories.begin(); 495 for ( Q3ValueList<OpieCategories>::ConstIterator it = m_categories.begin();
494 it != m_categories.end(); ++it ) 496 it != m_categories.end(); ++it )
495 { 497 {
496 stream << "<Category id=\""<< ( (*it).id() ) << "\" "; 498 stream << "<Category id=\""<< ( (*it).id() ) << "\" ";
497 499
498 if ( !(*it).app().isEmpty() ) 500 if ( !(*it).app().isEmpty() )
499 stream << " app=\""<< ( (*it).app() ) << "\" "; 501 stream << " app=\""<< ( (*it).app() ) << "\" ";
500 502
501 stream << "name=\"" << ( (*it).name() ) << "\" "; 503 stream << "name=\"" << ( (*it).name() ) << "\" ";
502 stream << " />" << endl; 504 stream << " />" << endl;
503 } 505 }
504 stream << "</Categories>" << endl; 506 stream << "</Categories>" << endl;
505 file.close(); 507 file.close();
506 } 508 }
507} 509}
508int CategoryEdit::addCategory( const QString &name, int id ){ 510int CategoryEdit::addCategory( const QString &name, int id ){
509 return addCategory( QString::null, name, id ); 511 return addCategory( QString::null, name, id );
510} 512}
511int CategoryEdit::addCategory( const QString &appName, const QString &name, int id ){ 513int CategoryEdit::addCategory( const QString &appName, const QString &name, int id ){
512 if ( id == 0 ) { 514 if ( id == 0 ) {
513 // code from tt 515 // code from tt
514 //generate uid 516 //generate uid
515 QDateTime dt = QDateTime::currentDateTime(); 517 QDateTime dt = QDateTime::currentDateTime();
516 id = -1 * (int) dt.secsTo( QDateTime(QDate( 2000,1,1)) ); 518 id = -1 * (int) dt.secsTo( QDateTime(QDate( 2000,1,1)) );
517 while ( ids.contains( id ) ){ 519 while ( ids.contains( id ) ){
518 id += -1; 520 id += -1;
519 if ( id > 0 ) 521 if ( id > 0 )
520 id = -1; 522 id = -1;
521 } 523 }
522 } 524 }
523 ids.insert( id, TRUE ); 525 ids.insert( id, TRUE );
524 OpieCategories categories(QString::number(id), name, appName); 526 OpieCategories categories(QString::number(id), name, appName);
525 //pending FIXME LR m_categories.remove( categories); 527 //pending FIXME LR m_categories.remove( categories);
526 m_categories.append( categories); 528 m_categories.append( categories);
527 return id; 529 return id;
528} 530}
529/* 531/*
530 * we parse the simple Category File here 532 * we parse the simple Category File here
531 * We also keep track of global Cats 533 * We also keep track of global Cats
532 * and Of Organizer and Contact cats and then 534 * and Of Organizer and Contact cats and then
533 * we will add them to the kde side... 535 * we will add them to the kde side...
534 */ 536 */
535void CategoryEdit::parse( const QString &tempFile ){ 537void CategoryEdit::parse( const QString &tempFile ){
536 clear(); 538 clear();
537 539
538 QDomDocument doc( "mydocument" ); 540 QDomDocument doc( "mydocument" );
539 QFile f( tempFile ); 541 QFile f( tempFile );
540 if ( !f.open( IO_ReadOnly ) ) 542 if ( !f.open( QIODevice::ReadOnly ) )
541 return; 543 return;
542 544
543 if ( !doc.setContent( &f ) ) { 545 if ( !doc.setContent( &f ) ) {
544 f.close(); 546 f.close();
545 return; 547 return;
546 } 548 }
547 f.close(); 549 f.close();
548 550
549 QStringList global, contact, organizer; 551 QStringList global, contact, organizer;
550 552
551 // print out the element names of all elements that are a direct child 553 // print out the element names of all elements that are a direct child
552 // of the outermost element. 554 // of the outermost element.
553 QDomElement docElem = doc.documentElement(); 555 QDomElement docElem = doc.documentElement();
554 QDomNode n = docElem.firstChild(); 556 QDomNode n = docElem.firstChild();
555 if( docElem.nodeName() == QString::fromLatin1("Categories") ){ 557 if( docElem.nodeName() == QString::fromLatin1("Categories") ){
556 while( !n.isNull() ) { 558 while( !n.isNull() ) {
557 QDomElement e = n.toElement(); // try to convert the node to an element. 559 QDomElement e = n.toElement(); // try to convert the node to an element.
558 if( !e.isNull() ) { // the node was really an element. 560 if( !e.isNull() ) { // the node was really an element.
559 QString id = e.attribute("id" ); 561 QString id = e.attribute("id" );
560 QString app = e.attribute("app" ); 562 QString app = e.attribute("app" );
561 QString name = e.attribute("name"); 563 QString name = e.attribute("name");
562 564
563 /* 565 /*
564 * see where it belongs default to global 566 * see where it belongs default to global
@@ -566,49 +568,49 @@ void CategoryEdit::parse( const QString &tempFile ){
566 if (app == QString::fromLatin1("Calendar") || app == QString::fromLatin1("Todo List") ) 568 if (app == QString::fromLatin1("Calendar") || app == QString::fromLatin1("Todo List") )
567 organizer.append( name ); 569 organizer.append( name );
568 else if ( app == QString::fromLatin1("Contacts") ) 570 else if ( app == QString::fromLatin1("Contacts") )
569 contact.append( name ); 571 contact.append( name );
570 else 572 else
571 global.append( name ); 573 global.append( name );
572 574
573 OpieCategories category( id, name, app ); 575 OpieCategories category( id, name, app );
574 m_categories.append( category ); // cheater 576 m_categories.append( category ); // cheater
575 } 577 }
576 n = n.nextSibling(); 578 n = n.nextSibling();
577 } 579 }
578 } 580 }
579 updateKDE( "kaddressbookrc", global + contact ); 581 updateKDE( "kaddressbookrc", global + contact );
580 updateKDE( "korganizerrc", global + organizer ); 582 updateKDE( "korganizerrc", global + organizer );
581 583
582} 584}
583void CategoryEdit::clear() 585void CategoryEdit::clear()
584{ 586{
585 ids.clear(); 587 ids.clear();
586 m_categories.clear(); 588 m_categories.clear();
587} 589}
588QString CategoryEdit::categoryById( const QString &id, const QString &app )const 590QString CategoryEdit::categoryById( const QString &id, const QString &app )const
589{ 591{
590 QValueList<OpieCategories>::ConstIterator it; 592 Q3ValueList<OpieCategories>::ConstIterator it;
591 QString category; 593 QString category;
592 QString fallback; 594 QString fallback;
593 for( it = m_categories.begin(); it != m_categories.end(); ++it ){ 595 for( it = m_categories.begin(); it != m_categories.end(); ++it ){
594 if( id.stripWhiteSpace() == (*it).id().stripWhiteSpace() ){ 596 if( id.stripWhiteSpace() == (*it).id().stripWhiteSpace() ){
595 if( app == (*it).app() ){ 597 if( app == (*it).app() ){
596 category = (*it).name(); 598 category = (*it).name();
597 break; 599 break;
598 }else{ 600 }else{
599 fallback = (*it).name(); 601 fallback = (*it).name();
600 } 602 }
601 } 603 }
602 } 604 }
603 return category.isEmpty() ? fallback : category; 605 return category.isEmpty() ? fallback : category;
604} 606}
605QStringList CategoryEdit::categoriesByIds( const QStringList& ids, 607QStringList CategoryEdit::categoriesByIds( const QStringList& ids,
606 const QString& app) { 608 const QString& app) {
607 609
608 QStringList list; 610 QStringList list;
609 QStringList::ConstIterator it; 611 QStringList::ConstIterator it;
610 QString temp; 612 QString temp;
611 for ( it = ids.begin(); it != ids.end(); ++it ) { 613 for ( it = ids.begin(); it != ids.end(); ++it ) {
612 temp = categoryById( (*it), app ); 614 temp = categoryById( (*it), app );
613 if (!temp.isEmpty() ) 615 if (!temp.isEmpty() )
614 list << temp; 616 list << temp;
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h
index 744dd41..389926c 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.h
+++ b/kabc/plugins/qtopia/qtopiaconverter.h
@@ -7,127 +7,130 @@
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24$Id$ 24$Id$
25*/ 25*/
26 26
27#ifndef KABC_QTOPIACONVERTER_H 27#ifndef KABC_QTOPIACONVERTER_H
28#define KABC_QTOPIACONVERTER_H 28#define KABC_QTOPIACONVERTER_H
29 29
30#include <qstring.h> 30#include <qstring.h>
31//Added by qt3to4:
32#include <Q3ValueList>
33#include <Q3TextStream>
31 34
32#include "addressee.h" 35#include "addressee.h"
33#ifdef DESKTOP_VERSION 36#ifdef DESKTOP_VERSION
34#include <qdom.h> 37#include <qdom.h>
35#else 38#else
36#include <xml/qdom.h> 39#include <xml/qdom.h>
37#endif 40#endif
38class Categories; 41class Categories;
39 42
40namespace KABC { 43namespace KABC {
41 44
42 45
43 46
44class OpieCategories { 47class OpieCategories {
45 public: 48 public:
46 //friend class KSync::OpieSocket; 49 //friend class KSync::OpieSocket;
47 friend bool operator== ( const OpieCategories &a, const OpieCategories &b ); 50 friend bool operator== ( const OpieCategories &a, const OpieCategories &b );
48 OpieCategories(); 51 OpieCategories();
49 OpieCategories(const QString &id, const QString &name, const QString &app ); 52 OpieCategories(const QString &id, const QString &name, const QString &app );
50 OpieCategories(const OpieCategories & ); 53 OpieCategories(const OpieCategories & );
51 ~OpieCategories() {}; 54 ~OpieCategories() {};
52 OpieCategories &operator=(const OpieCategories & ); 55 OpieCategories &operator=(const OpieCategories & );
53 QString id()const; 56 QString id()const;
54 QString name()const; 57 QString name()const;
55 QString app()const; 58 QString app()const;
56 59
57 private: 60 private:
58 QString m_name; 61 QString m_name;
59 QString m_app; 62 QString m_app;
60 QString m_id; 63 QString m_id;
61}; 64};
62 65
63 66
64 class CategoryEdit { 67 class CategoryEdit {
65 public: 68 public:
66 CategoryEdit(); 69 CategoryEdit();
67 CategoryEdit(const QString &fileName); 70 CategoryEdit(const QString &fileName);
68 ~CategoryEdit(); 71 ~CategoryEdit();
69 72
70 void save(const QString&) const; 73 void save(const QString&) const;
71 int addCategory( const QString &name, int id = 0 ); 74 int addCategory( const QString &name, int id = 0 );
72 int addCategory(const QString &appName, const QString &name, int id = 0); 75 int addCategory(const QString &appName, const QString &name, int id = 0);
73 void parse( const QString &fileName ); 76 void parse( const QString &fileName );
74 77
75 QString categoryById(const QString &id, const QString &app )const; 78 QString categoryById(const QString &id, const QString &app )const;
76 QStringList categoriesByIds( const QStringList& ids, const QString& app ); 79 QStringList categoriesByIds( const QStringList& ids, const QString& app );
77 80
78 void clear(); 81 void clear();
79 QValueList<OpieCategories> categories()const { return m_categories; }; 82 Q3ValueList<OpieCategories> categories()const { return m_categories; };
80 private: 83 private:
81 /** 84 /**
82 * this function will be used internally to update the kde categories... 85 * this function will be used internally to update the kde categories...
83 */ 86 */
84 void updateKDE( const QString& app, const QStringList& categories ); 87 void updateKDE( const QString& app, const QStringList& categories );
85 QMap<int, bool> ids; // from tt Qtopia::UidGen 88 QMap<int, bool> ids; // from tt Qtopia::UidGen
86 QValueList<OpieCategories> m_categories; 89 Q3ValueList<OpieCategories> m_categories;
87 }; 90 };
88 91
89 92
90class QtopiaConverter 93class QtopiaConverter
91{ 94{
92public: 95public:
93 96
94 /** 97 /**
95 * Constructor. 98 * Constructor.
96 */ 99 */
97 QtopiaConverter(); 100 QtopiaConverter();
98 101
99 /** 102 /**
100 * Destructor. 103 * Destructor.
101 */ 104 */
102 virtual ~QtopiaConverter(); 105 virtual ~QtopiaConverter();
103 106
104 bool init(); 107 bool init();
105 void deinit(); 108 void deinit();
106 109
107 /** 110 /**
108 * Converts a vcard string to an addressee. 111 * Converts a vcard string to an addressee.
109 * 112 *
110 * @param contact The qtopia contact. 113 * @param contact The qtopia contact.
111 * @param addr The addressee. 114 * @param addr The addressee.
112 */ 115 */
113 bool qtopiaToAddressee( const QDomElement& el, Addressee &adr ); 116 bool qtopiaToAddressee( const QDomElement& el, Addressee &adr );
114 /** 117 /**
115 * Converts an addressee to a vcard string. 118 * Converts an addressee to a vcard string.
116 * 119 *
117 * @param addr The addressee. 120 * @param addr The addressee.
118 * @param contact The qtopia contact. 121 * @param contact The qtopia contact.
119 */ 122 */
120 bool addresseeToQtopia( const Addressee &ab, QTextStream *stream ); 123 bool addresseeToQtopia( const Addressee &ab, Q3TextStream *stream );
121 124
122 private: 125 private:
123 QString categoriesToNumber( const QStringList &list, const QString &app ); 126 QString categoriesToNumber( const QStringList &list, const QString &app );
124 QString escape( const QString& s){ return s;}; 127 QString escape( const QString& s){ return s;};
125 CategoryEdit *m_edit; 128 CategoryEdit *m_edit;
126 QDate fromString( const QString& ); 129 QDate fromString( const QString& );
127 QDate dateFromString( const QString& ); 130 QDate dateFromString( const QString& );
128 QString dateToString( const QDate& ); 131 QString dateToString( const QDate& );
129 132
130 133
131}; 134};
132} 135}
133#endif 136#endif
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 79ddaea..a36eb8f 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -10,49 +10,49 @@
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27#include <sys/types.h> 27#include <sys/types.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29#ifndef _WIN32_ 29#ifndef _WIN32_
30#include <unistd.h> 30#include <unistd.h>
31#endif 31#endif
32#include <qdir.h> 32#include <qdir.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qtextstream.h> 34#include <q3textstream.h>
35#include <qfileinfo.h> 35#include <qfileinfo.h>
36#include <qregexp.h> 36#include <qregexp.h>
37//US #include <qtimer.h> 37//US #include <qtimer.h>
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <klocale.h> 42#include <klocale.h>
43//US #include <ksavefile.h> 43//US #include <ksavefile.h>
44#include <kstandarddirs.h> 44#include <kstandarddirs.h>
45#include <kmessagebox.h> 45#include <kmessagebox.h>
46 46
47 47
48#include "resourceqtopiaconfig.h" 48#include "resourceqtopiaconfig.h"
49#include "stdaddressbook.h" 49#include "stdaddressbook.h"
50 50
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52 52
53#include "resourceqtopia.h" 53#include "resourceqtopia.h"
54 54
55using namespace KABC; 55using namespace KABC;
56 56
57extern "C" 57extern "C"
58#ifdef _WIN32_ 58#ifdef _WIN32_
@@ -135,101 +135,101 @@ bool ResourceQtopia::doOpen()
135 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); 135 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
136 qDebug(msg); 136 qDebug(msg);
137 return false; 137 return false;
138 } 138 }
139 } 139 }
140 140
141 return true; 141 return true;
142} 142}
143 143
144void ResourceQtopia::doClose() 144void ResourceQtopia::doClose()
145{ 145{
146 qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); 146 qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
147 147
148 148
149 // it seems so, that deletion of access deletes backend as well 149 // it seems so, that deletion of access deletes backend as well
150 //delete backend; 150 //delete backend;
151 151
152 return; 152 return;
153} 153}
154 154
155bool ResourceQtopia::load() 155bool ResourceQtopia::load()
156{ 156{
157 157
158 QFile file( fileName() ); 158 QFile file( fileName() );
159 if ( !file.open(IO_ReadOnly ) ) { 159 if ( !file.open(QIODevice::ReadOnly ) ) {
160 return false; 160 return false;
161 } 161 }
162 162
163 QDomDocument doc("mydocument" ); 163 QDomDocument doc("mydocument" );
164 if ( !doc.setContent( &file ) ) { 164 if ( !doc.setContent( &file ) ) {
165 file.close(); 165 file.close();
166 return false; 166 return false;
167 } 167 }
168 bool res; 168 bool res;
169 QDomElement docElem = doc.documentElement( ); 169 QDomElement docElem = doc.documentElement( );
170 QDomNode n = docElem.firstChild(); 170 QDomNode n = docElem.firstChild();
171 while ( !n.isNull() ) { 171 while ( !n.isNull() ) {
172 QDomElement e = n.toElement(); 172 QDomElement e = n.toElement();
173 if ( !e.isNull() ) { 173 if ( !e.isNull() ) {
174 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { 174 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) {
175 QDomNode no = e.firstChild(); 175 QDomNode no = e.firstChild();
176 while ( !no.isNull() ) { 176 while ( !no.isNull() ) {
177 QDomElement el = no.toElement(); 177 QDomElement el = no.toElement();
178 if ( !el.isNull() ) { 178 if ( !el.isNull() ) {
179 KABC::Addressee addressee; 179 KABC::Addressee addressee;
180 res = mConverter->qtopiaToAddressee( el, addressee ); 180 res = mConverter->qtopiaToAddressee( el, addressee );
181 if ( !addressee.isEmpty() && res ) 181 if ( !addressee.isEmpty() && res )
182 { 182 {
183 addressee.setResource( this ); 183 addressee.setResource( this );
184 addressBook()->insertAddressee( addressee ); 184 addressBook()->insertAddressee( addressee );
185 } 185 }
186 } 186 }
187 187
188 no = no.nextSibling(); 188 no = no.nextSibling();
189 } 189 }
190 } 190 }
191 } 191 }
192 192
193 n = n.nextSibling(); 193 n = n.nextSibling();
194 } 194 }
195 return true; 195 return true;
196} 196}
197 197
198bool ResourceQtopia::save( Ticket *ticket ) 198bool ResourceQtopia::save( Ticket *ticket )
199{ 199{
200#ifdef _USE_DIRWATCH_ 200#ifdef _USE_DIRWATCH_
201 mDirWatch.stopScan(); 201 mDirWatch.stopScan();
202#endif 202#endif
203 KABC::AddressBook::Iterator it; 203 KABC::AddressBook::Iterator it;
204 bool res; 204 bool res;
205 QFile file( fileName() ); 205 QFile file( fileName() );
206 if (!file.open( IO_WriteOnly ) ) { 206 if (!file.open( QIODevice::WriteOnly ) ) {
207 return false; 207 return false;
208 } 208 }
209 QTextStream ts( &file ); 209 Q3TextStream ts( &file );
210 QTextStream *stream = &ts; 210 Q3TextStream *stream = &ts;
211 stream->setEncoding( QTextStream::UnicodeUTF8 ); 211 stream->setEncoding( Q3TextStream::UnicodeUTF8 );
212 *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl; 212 *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl;
213 *stream << " <Groups>" << endl; 213 *stream << " <Groups>" << endl;
214 *stream << " </Groups>" << endl; 214 *stream << " </Groups>" << endl;
215 *stream << " <Contacts> " << endl; 215 *stream << " <Contacts> " << endl;
216 // for all entries 216 // for all entries
217 KABC::Addressee ab; 217 KABC::Addressee ab;
218 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 218 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
219 KABC::Addressee addressee = (*it); 219 KABC::Addressee addressee = (*it);
220 res = mConverter->addresseeToQtopia( addressee, stream ); 220 res = mConverter->addresseeToQtopia( addressee, stream );
221 if (!res == true) 221 if (!res == true)
222 { 222 {
223 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 223 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
224 } 224 }
225 } 225 }
226 *stream << "</Contacts>" << endl; 226 *stream << "</Contacts>" << endl;
227 *stream << "</AddressBook>" << endl; 227 *stream << "</AddressBook>" << endl;
228 file.close(); 228 file.close();
229#ifdef _USE_DIRWATCH_ 229#ifdef _USE_DIRWATCH_
230 mDirWatch.startScan(); 230 mDirWatch.startScan();
231#endif 231#endif
232 delete ticket; 232 delete ticket;
233 unlock( fileName() ); 233 unlock( fileName() );
234 return true; 234 return true;
235} 235}
@@ -239,49 +239,49 @@ bool ResourceQtopia::lock( const QString &lockfileName )
239 //disabled 239 //disabled
240 return true; 240 return true;
241 qDebug("ResourceQtopia::lock: %s", fileName().latin1()); 241 qDebug("ResourceQtopia::lock: %s", fileName().latin1());
242 QString fn = lockfileName; 242 QString fn = lockfileName;
243 243
244 KURL url(fn); 244 KURL url(fn);
245 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 245 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
246 246
247 if (QFile::exists( lockName )) 247 if (QFile::exists( lockName ))
248 { 248 {
249 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); 249 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1());
250 return false; 250 return false;
251 } 251 }
252 252
253 QString lockUniqueName; 253 QString lockUniqueName;
254 lockUniqueName = fn + KApplication::randomString( 8 ); 254 lockUniqueName = fn + KApplication::randomString( 8 );
255 255
256 url = lockUniqueName; 256 url = lockUniqueName;
257//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 257//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
258 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 258 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
259 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 259 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
260 260
261 // Create unique file 261 // Create unique file
262 QFile file( mLockUniqueName ); 262 QFile file( mLockUniqueName );
263 file.open( IO_WriteOnly ); 263 file.open( QIODevice::WriteOnly );
264 file.close(); 264 file.close();
265 265
266 // Create lock file 266 // Create lock file
267 int result = 0; 267 int result = 0;
268#ifndef _WIN32_ 268#ifndef _WIN32_
269 result = ::link( QFile::encodeName( mLockUniqueName ), 269 result = ::link( QFile::encodeName( mLockUniqueName ),
270 QFile::encodeName( lockName ) ); 270 QFile::encodeName( lockName ) );
271#endif 271#endif
272 if ( result == 0 ) { 272 if ( result == 0 ) {
273 addressBook()->emitAddressBookLocked(); 273 addressBook()->emitAddressBookLocked();
274 return true; 274 return true;
275 } 275 }
276 276
277 // TODO: check stat 277 // TODO: check stat
278 278
279 return false; 279 return false;
280} 280}
281 281
282void ResourceQtopia::unlock( const QString &fileName ) 282void ResourceQtopia::unlock( const QString &fileName )
283{ 283{
284 //disabled 284 //disabled
285 return; 285 return;
286 qDebug("ResourceQtopia::unlock() %s", fileName.latin1()); 286 qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
287 287
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
index d5d6141..42fd428 100644
--- a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
+++ b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
@@ -6,68 +6,70 @@
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlayout.h> 29#include <qlayout.h>
30//Added by qt3to4:
31#include <Q3GridLayout>
30 32
31#include <kdebug.h> 33#include <kdebug.h>
32#include <klocale.h> 34#include <klocale.h>
33#include <kstandarddirs.h> 35#include <kstandarddirs.h>
34#include <kdialog.h> 36#include <kdialog.h>
35 37
36//#include <unistd.h> 38//#include <unistd.h>
37 39
38#include <qdir.h> 40#include <qdir.h>
39#include <qfile.h> 41#include <qfile.h>
40#include "resourceqtopia.h" 42#include "resourceqtopia.h"
41 43
42#include "resourceqtopiaconfig.h" 44#include "resourceqtopiaconfig.h"
43 45
44using namespace KABC; 46using namespace KABC;
45 47
46ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name ) 48ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name )
47 : ConfigWidget( parent, name ) 49 : ConfigWidget( parent, name )
48{ 50{
49 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 51 Q3GridLayout *mainLayout = new Q3GridLayout( this, 1, 2, 0,
50 KDialog::spacingHint() ); 52 KDialog::spacingHint() );
51 53
52 QLabel *label = new QLabel( i18n( "Location:" ), this ); 54 QLabel *label = new QLabel( i18n( "Location:" ), this );
53 mFileNameEdit = new KURLRequester( this ); 55 mFileNameEdit = new KURLRequester( this );
54 56
55 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 57 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
56 SLOT( checkFilePermissions( const QString & ) ) ); 58 SLOT( checkFilePermissions( const QString & ) ) );
57 59
58 mainLayout->addWidget( label, 0, 0 ); 60 mainLayout->addWidget( label, 0, 0 );
59 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 61 mainLayout->addWidget( mFileNameEdit, 0, 1 );
60 62
61} 63}
62 64
63void ResourceQtopiaConfig::loadSettings( KRES::Resource *res ) 65void ResourceQtopiaConfig::loadSettings( KRES::Resource *res )
64{ 66{
65//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 67//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
66 ResourceQtopia *resource = (ResourceQtopia*)( res ); 68 ResourceQtopia *resource = (ResourceQtopia*)( res );
67 69
68 if ( !resource ) { 70 if ( !resource ) {
69 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl; 71 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl;
70 return; 72 return;
71 } 73 }
72 74
73 mFileNameEdit->setURL( resource->fileName() ); 75 mFileNameEdit->setURL( resource->fileName() );