summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/plugins
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kabc/plugins') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/dir.pro14
-rw-r--r--kabc/plugins/dir/dirE.pro4
-rw-r--r--kabc/plugins/dir/resourcedir.cpp8
-rw-r--r--kabc/plugins/dir/resourcedirconfig.cpp4
-rw-r--r--kabc/plugins/file/file.pro14
-rw-r--r--kabc/plugins/file/fileE.pro4
-rw-r--r--kabc/plugins/file/resourcefile.cpp10
-rw-r--r--kabc/plugins/file/resourcefileconfig.cpp4
-rw-r--r--kabc/plugins/ldap/ldapE.pro4
-rw-r--r--kabc/plugins/olaccess/olaccess.pro8
-rw-r--r--kabc/plugins/opie/opieE.pro6
-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
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmE.pro8
18 files changed, 92 insertions, 69 deletions
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro
index 3e18594..9b3b894 100644
--- a/kabc/plugins/dir/dir.pro
+++ b/kabc/plugins/dir/dir.pro
@@ -1,36 +1,40 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5include( ../../../variables.pri ) 5include( ../../../variables.pri )
6 6
7TARGET = microkabc_dir 7TARGET = xmicrokabc_dir
8INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat 8INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
9DESTDIR = ../../../bin 9DESTDIR = ../../../bin
10#LIBS += -lmicrokde -lmicrokabc 10#LIBS += -lxmicrokde -lxmicrokabc
11#LIBS += -L$(QPEDIR)/lib 11#LIBS += -L$(QPEDIR)/lib
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 resourcedir.h \ 16 resourcedir.h \
17 resourcedirconfig.h 17 resourcedirconfig.h
18 18
19SOURCES = \ 19SOURCES = \
20 resourcedir.cpp \ 20 resourcedir.cpp \
21 resourcedirconfig.cpp 21 resourcedirconfig.cpp
22 22
23unix : { 23unix : {
24OBJECTS_DIR = obj/unix 24OBJECTS_DIR = obj/unix
25MOC_DIR = moc/unix 25MOC_DIR = moc/unix
26} 26}
27win32: { 27win32: {
28CONFIG += dll 28CONFIG += dll
29DEFINES += _WIN32_ 29DEFINES += _WIN32_
30OBJECTS_DIR = obj/win 30OBJECTS_DIR = obj/win
31MOC_DIR = moc/win 31MOC_DIR = moc/win
32LIBS += ../../../bin/microkdepim.lib 32LIBS += ../../../bin/xmicrokdepim.lib
33LIBS += ../../../bin/microkcal.lib 33LIBS += ../../../bin/xmicrokcal.lib
34LIBS += ../../../bin/microkde.lib 34LIBS += ../../../bin/xmicrokde.lib
35LIBS += ../../../bin/microkabc.lib 35LIBS += ../../../bin/microkabc.lib
36} 36}
37#The following line was inserted by qt3to4
38QT += qt3support
39#The following line was inserted by qt3to4
40QT += xml
diff --git a/kabc/plugins/dir/dirE.pro b/kabc/plugins/dir/dirE.pro
index cda4e2f..75332a0 100644
--- a/kabc/plugins/dir/dirE.pro
+++ b/kabc/plugins/dir/dirE.pro
@@ -1,21 +1,21 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5TARGET = microkabc_dir 5TARGET = xmicrokabc_dir
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat 6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde -lmicrokabc 10LIBS += -lxmicrokde -lxmicrokabc
11LIBS += -L$(QPEDIR)/lib 11LIBS += -L$(QPEDIR)/lib
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 resourcedir.h \ 16 resourcedir.h \
17 resourcedirconfig.h 17 resourcedirconfig.h
18 18
19SOURCES = \ 19SOURCES = \
20 resourcedir.cpp \ 20 resourcedir.cpp \
21 resourcedirconfig.cpp 21 resourcedirconfig.cpp
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index c61664b..cc4afee 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -109,226 +109,226 @@ ResourceDir::ResourceDir( const KConfig *config )
109 if ( !mFormat ) { 109 if ( !mFormat ) {
110 mFormatName = "vcard"; 110 mFormatName = "vcard";
111 mFormat = factory->format( mFormatName ); 111 mFormat = factory->format( mFormatName );
112 } 112 }
113 113
114/*US 114/*US
115//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); 115//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
116 if (mFormatName == "vcard") 116 if (mFormatName == "vcard")
117 mFormat = new VCardFormatPlugin2(); 117 mFormat = new VCardFormatPlugin2();
118 else if (mFormatName == "binary") 118 else if (mFormatName == "binary")
119 mFormat = new BinaryFormat(); 119 mFormat = new BinaryFormat();
120 else 120 else
121 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); 121 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
122*/ 122*/
123#ifndef NO_DIRWATCH 123#ifndef NO_DIRWATCH
124 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); 124 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
125 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); 125 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) );
126 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); 126 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) );
127#endif 127#endif
128 setPath( path ); 128 setPath( path );
129} 129}
130 130
131ResourceDir::~ResourceDir() 131ResourceDir::~ResourceDir()
132{ 132{
133 delete mFormat; 133 delete mFormat;
134 mFormat = 0; 134 mFormat = 0;
135} 135}
136 136
137void ResourceDir::writeConfig( KConfig *config ) 137void ResourceDir::writeConfig( KConfig *config )
138{ 138{
139 config->setGroup( "Resource_" + identifier() ); 139 config->setGroup( "Resource_" + identifier() );
140 Resource::writeConfig( config ); 140 Resource::writeConfig( config );
141 141
142 config->writeEntry( "FilePath", mPath ); 142 config->writeEntry( "FilePath", mPath );
143 config->writeEntry( "FileFormat", mFormatName ); 143 config->writeEntry( "FileFormat", mFormatName );
144} 144}
145 145
146Ticket *ResourceDir::requestSaveTicket() 146Ticket *ResourceDir::requestSaveTicket()
147{ 147{
148 148
149 149
150 if ( !addressBook() ) return 0; 150 if ( !addressBook() ) return 0;
151#ifdef ALLOW_LOCKING 151#ifdef ALLOW_LOCKING
152 if ( !lock( mPath ) ) { 152 if ( !lock( mPath ) ) {
153 153
154 return 0; 154 return 0;
155 } 155 }
156#endif 156#endif
157 return createTicket( this ); 157 return createTicket( this );
158 158
159} 159}
160 160
161 161
162bool ResourceDir::doOpen() 162bool ResourceDir::doOpen()
163{ 163{
164 QDir dir( mPath ); 164 QDir dir( mPath );
165 if ( !dir.exists() ) { // no directory available 165 if ( !dir.exists() ) { // no directory available
166 return dir.mkdir( dir.path() ); 166 return dir.mkdir( dir.path() );
167 } else { 167 } else {
168 QString testName = dir.entryList( QDir::Files )[0]; 168 QString testName = dir.entryList( QDir::Files )[0];
169 if ( testName.isNull() || testName.isEmpty() ) // no file in directory 169 if ( testName.isNull() || testName.isEmpty() ) // no file in directory
170 return true; 170 return true;
171 171
172 QFile file( mPath + "/" + testName ); 172 QFile file( mPath + "/" + testName );
173 if ( file.open( IO_ReadOnly ) ) 173 if ( file.open( QIODevice::ReadOnly ) )
174 return true; 174 return true;
175 175
176 if ( file.size() == 0 ) 176 if ( file.size() == 0 )
177 return true; 177 return true;
178 178
179 bool ok = mFormat->checkFormat( &file ); 179 bool ok = mFormat->checkFormat( &file );
180 file.close(); 180 file.close();
181 return ok; 181 return ok;
182 } 182 }
183} 183}
184 184
185void ResourceDir::doClose() 185void ResourceDir::doClose()
186{ 186{
187} 187}
188 188
189bool ResourceDir::load() 189bool ResourceDir::load()
190{ 190{
191 QDir dir( mPath ); 191 QDir dir( mPath );
192 QStringList files = dir.entryList( QDir::Files ); 192 QStringList files = dir.entryList( QDir::Files );
193 193
194 QStringList::Iterator it; 194 QStringList::Iterator it;
195 bool ok = true; 195 bool ok = true;
196 for ( it = files.begin(); it != files.end(); ++it ) { 196 for ( it = files.begin(); it != files.end(); ++it ) {
197 QFile file( mPath + "/" + (*it) ); 197 QFile file( mPath + "/" + (*it) );
198 198
199 if ( !file.open( IO_ReadOnly ) ) { 199 if ( !file.open( QIODevice::ReadOnly ) ) {
200 addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) ); 200 addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) );
201 ok = false; 201 ok = false;
202 continue; 202 continue;
203 } 203 }
204 204
205 if ( !mFormat->loadAll( addressBook(), this, &file ) ) 205 if ( !mFormat->loadAll( addressBook(), this, &file ) )
206 ok = false; 206 ok = false;
207 207
208 file.close(); 208 file.close();
209 } 209 }
210 210
211 return ok; 211 return ok;
212} 212}
213 213
214bool ResourceDir::save( Ticket *ticket ) 214bool ResourceDir::save( Ticket *ticket )
215{ 215{
216 AddressBook::Iterator it; 216 AddressBook::Iterator it;
217 bool ok = true; 217 bool ok = true;
218#ifndef NO_DIRWATCH 218#ifndef NO_DIRWATCH
219 mDirWatch.stopScan(); 219 mDirWatch.stopScan();
220#endif 220#endif
221 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 221 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
222 if ( (*it).resource() != this || !(*it).changed() ) 222 if ( (*it).resource() != this || !(*it).changed() )
223 continue; 223 continue;
224 224
225 QFile file( mPath + "/" + (*it).uid() ); 225 QFile file( mPath + "/" + (*it).uid() );
226 if ( !file.open( IO_WriteOnly ) ) { 226 if ( !file.open( QIODevice::WriteOnly ) ) {
227 addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); 227 addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) );
228 continue; 228 continue;
229 } 229 }
230 230
231 mFormat->save( *it, &file ); 231 mFormat->save( *it, &file );
232 232
233 // mark as unchanged 233 // mark as unchanged
234 (*it).setChanged( false ); 234 (*it).setChanged( false );
235 235
236 file.close(); 236 file.close();
237 } 237 }
238#ifndef NO_DIRWATCH 238#ifndef NO_DIRWATCH
239 mDirWatch.startScan(); 239 mDirWatch.startScan();
240#endif 240#endif
241 delete ticket; 241 delete ticket;
242#ifdef ALLOW_LOCKING 242#ifdef ALLOW_LOCKING
243 unlock( mPath ); 243 unlock( mPath );
244#endif 244#endif
245 return ok; 245 return ok;
246} 246}
247 247
248bool ResourceDir::lock( const QString &path ) 248bool ResourceDir::lock( const QString &path )
249{ 249{
250#ifdef ALLOW_LOCKING 250#ifdef ALLOW_LOCKING
251 QString p = path; 251 QString p = path;
252//US change the implementation how the lockfilename is getting created 252//US change the implementation how the lockfilename is getting created
253//US p.replace( QRegExp("/"), "_" ); 253//US p.replace( QRegExp("/"), "_" );
254//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); 254//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" );
255 KURL url(p); 255 KURL url(p);
256 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 256 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
257 257
258 258
259 if ( QFile::exists( lockName ) ) return false; 259 if ( QFile::exists( lockName ) ) return false;
260 260
261 QString lockUniqueName; 261 QString lockUniqueName;
262 lockUniqueName = p + KApplication::randomString( 8 ); 262 lockUniqueName = p + KApplication::randomString( 8 );
263 263
264 url = lockUniqueName; 264 url = lockUniqueName;
265//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 265//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
266 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 266 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
267 267
268 // Create unique file 268 // Create unique file
269 QFile file( mLockUniqueName ); 269 QFile file( mLockUniqueName );
270 file.open( IO_WriteOnly ); 270 file.open( QIODevice::WriteOnly );
271 file.close(); 271 file.close();
272 272
273 // Create lock file 273 // Create lock file
274 int result = 0; 274 int result = 0;
275#ifndef _WIN32_ 275#ifndef _WIN32_
276 result = ::link( QFile::encodeName( mLockUniqueName ), 276 result = ::link( QFile::encodeName( mLockUniqueName ),
277 QFile::encodeName( lockName ) ); 277 QFile::encodeName( lockName ) );
278#endif 278#endif
279 if ( result == 0 ) { 279 if ( result == 0 ) {
280 addressBook()->emitAddressBookLocked(); 280 addressBook()->emitAddressBookLocked();
281 return true; 281 return true;
282 } 282 }
283 283
284 // TODO: check stat 284 // TODO: check stat
285 285
286 return false; 286 return false;
287#else 287#else
288 return true; 288 return true;
289#endif 289#endif
290} 290}
291 291
292void ResourceDir::unlock( const QString &path ) 292void ResourceDir::unlock( const QString &path )
293{ 293{
294#ifdef ALLOW_LOCKING 294#ifdef ALLOW_LOCKING
295 QString p = path; 295 QString p = path;
296//US change the implementation how the lockfilename is getting created 296//US change the implementation how the lockfilename is getting created
297//US p.replace( QRegExp( "/" ), "_" ); 297//US p.replace( QRegExp( "/" ), "_" );
298//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); 298//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
299 KURL url(p); 299 KURL url(p);
300 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); 300 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
301 301
302 ::unlink( QFile::encodeName( lockName ) ); 302 ::unlink( QFile::encodeName( lockName ) );
303 QFile::remove( mLockUniqueName ); 303 QFile::remove( mLockUniqueName );
304 addressBook()->emitAddressBookUnlocked(); 304 addressBook()->emitAddressBookUnlocked();
305#else 305#else
306 return; 306 return;
307#endif 307#endif
308} 308}
309 309
310void ResourceDir::setPath( const QString &path ) 310void ResourceDir::setPath( const QString &path )
311{ 311{
312#ifndef NO_DIRWATCH 312#ifndef NO_DIRWATCH
313 mDirWatch.stopScan(); 313 mDirWatch.stopScan();
314 mDirWatch.removeDir( mPath ); 314 mDirWatch.removeDir( mPath );
315 315
316 mPath = path; 316 mPath = path;
317 317
318 mDirWatch.addDir( mPath, true ); 318 mDirWatch.addDir( mPath, true );
319 mDirWatch.startScan(); 319 mDirWatch.startScan();
320#else 320#else
321 mPath = path; 321 mPath = path;
322#endif 322#endif
323//US simulate KDirWatch event 323//US simulate KDirWatch event
324//US pathChanged(); 324//US pathChanged();
325 325
326} 326}
327 327
328QString ResourceDir::path() const 328QString ResourceDir::path() const
329{ 329{
330 return mPath; 330 return mPath;
331} 331}
332 332
333void ResourceDir::setFormat( const QString &format ) 333void ResourceDir::setFormat( const QString &format )
334{ 334{
diff --git a/kabc/plugins/dir/resourcedirconfig.cpp b/kabc/plugins/dir/resourcedirconfig.cpp
index 98d18fe..8fa48d0 100644
--- a/kabc/plugins/dir/resourcedirconfig.cpp
+++ b/kabc/plugins/dir/resourcedirconfig.cpp
@@ -1,111 +1,113 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
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//US #include "formatfactory.h" 38//US #include "formatfactory.h"
37#include "resourcedir.h" 39#include "resourcedir.h"
38#include "stdaddressbook.h" 40#include "stdaddressbook.h"
39 41
40#include "resourcedirconfig.h" 42#include "resourcedirconfig.h"
41 43
42using namespace KABC; 44using namespace KABC;
43 45
44ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name ) 46ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name )
45 : KRES::ConfigWidget( parent, name ) 47 : KRES::ConfigWidget( parent, name )
46{ 48{
47 QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0, 49 Q3GridLayout *mainLayout = new Q3GridLayout( this, 2, 2, 0,
48 KDialog::spacingHint() ); 50 KDialog::spacingHint() );
49 51
50 QLabel *label = new QLabel( i18n( "Format:" ), this ); 52 QLabel *label = new QLabel( i18n( "Format:" ), this );
51 mFormatBox = new KComboBox( this ); 53 mFormatBox = new KComboBox( this );
52 54
53 mainLayout->addWidget( label, 0, 0 ); 55 mainLayout->addWidget( label, 0, 0 );
54 mainLayout->addWidget( mFormatBox, 0, 1 ); 56 mainLayout->addWidget( mFormatBox, 0, 1 );
55 57
56 label = new QLabel( i18n( "Location:" ), this ); 58 label = new QLabel( i18n( "Location:" ), this );
57 mFileNameEdit = new KURLRequester( this ); 59 mFileNameEdit = new KURLRequester( this );
58//US mFileNameEdit->setMode( KFile::Directory ); 60//US mFileNameEdit->setMode( KFile::Directory );
59 61
60 mainLayout->addWidget( label, 1, 0 ); 62 mainLayout->addWidget( label, 1, 0 );
61 mainLayout->addWidget( mFileNameEdit, 1, 1 ); 63 mainLayout->addWidget( mFileNameEdit, 1, 1 );
62 64
63/*US lets hardcode the formats instead of using a factory 65/*US lets hardcode the formats instead of using a factory
64 FormatFactory *factory = FormatFactory::self(); 66 FormatFactory *factory = FormatFactory::self();
65 QStringList formats = factory->formats(); 67 QStringList formats = factory->formats();
66 QStringList::Iterator it; 68 QStringList::Iterator it;
67 for ( it = formats.begin(); it != formats.end(); ++it ) { 69 for ( it = formats.begin(); it != formats.end(); ++it ) {
68 FormatInfo *info = factory->info( *it ); 70 FormatInfo *info = factory->info( *it );
69 if ( info ) { 71 if ( info ) {
70 mFormatTypes << (*it); 72 mFormatTypes << (*it);
71 mFormatBox->insertItem( info->nameLabel ); 73 mFormatBox->insertItem( info->nameLabel );
72 } 74 }
73 } 75 }
74*/ 76*/
75 mFormatTypes << "vcard"; 77 mFormatTypes << "vcard";
76 mFormatTypes << "binary"; 78 mFormatTypes << "binary";
77 mFormatBox->insertItem( "vcard" ); 79 mFormatBox->insertItem( "vcard" );
78 mFormatBox->insertItem( "binary" ); 80 mFormatBox->insertItem( "binary" );
79 81
80 82
81 mInEditMode = false; 83 mInEditMode = false;
82} 84}
83 85
84void ResourceDirConfig::setEditMode( bool value ) 86void ResourceDirConfig::setEditMode( bool value )
85{ 87{
86 mFormatBox->setEnabled( !value ); 88 mFormatBox->setEnabled( !value );
87 mInEditMode = value; 89 mInEditMode = value;
88} 90}
89 91
90void ResourceDirConfig::loadSettings( KRES::Resource *res ) 92void ResourceDirConfig::loadSettings( KRES::Resource *res )
91{ 93{
92//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); 94//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
93 ResourceDir *resource = (ResourceDir*)( res ); 95 ResourceDir *resource = (ResourceDir*)( res );
94 96
95 if ( !resource ) { 97 if ( !resource ) {
96 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; 98 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
97 return; 99 return;
98 } 100 }
99 101
100 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); 102 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
101 103
102 mFileNameEdit->setURL( resource->path() ); 104 mFileNameEdit->setURL( resource->path() );
103 if ( mFileNameEdit->url().isEmpty() ) 105 if ( mFileNameEdit->url().isEmpty() )
104 mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() ); 106 mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() );
105} 107}
106 108
107void ResourceDirConfig::saveSettings( KRES::Resource *res ) 109void ResourceDirConfig::saveSettings( KRES::Resource *res )
108{ 110{
109//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); 111//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
110 ResourceDir *resource = (ResourceDir*)( res ); 112 ResourceDir *resource = (ResourceDir*)( res );
111 113
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
index 2d17313..e4f1270 100644
--- a/kabc/plugins/file/file.pro
+++ b/kabc/plugins/file/file.pro
@@ -1,37 +1,41 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5include( ../../../variables.pri ) 5include( ../../../variables.pri )
6 6
7TARGET = microkabc_file 7TARGET = xmicrokabc_file
8INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat 8INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
9 9
10DESTDIR = ../../../bin 10DESTDIR = ../../../bin
11#LIBS += -lmicrokde -lmicrokabc 11#LIBS += -lxmicrokde -lxmicrokabc
12#LIBS += -L$(QPEDIR)/lib 12#LIBS += -L$(QPEDIR)/lib
13 13
14INTERFACES = \ 14INTERFACES = \
15 15
16HEADERS = \ 16HEADERS = \
17 resourcefile.h \ 17 resourcefile.h \
18 resourcefileconfig.h 18 resourcefileconfig.h
19 19
20SOURCES = \ 20SOURCES = \
21 resourcefile.cpp \ 21 resourcefile.cpp \
22 resourcefileconfig.cpp 22 resourcefileconfig.cpp
23 23
24unix : { 24unix : {
25OBJECTS_DIR = obj/unix 25OBJECTS_DIR = obj/unix
26MOC_DIR = moc/unix 26MOC_DIR = moc/unix
27} 27}
28win32: { 28win32: {
29CONFIG += dll 29CONFIG += dll
30DEFINES += _WIN32_ 30DEFINES += _WIN32_
31OBJECTS_DIR = obj/win 31OBJECTS_DIR = obj/win
32MOC_DIR = moc/win 32MOC_DIR = moc/win
33LIBS += ../../../bin/microkdepim.lib 33LIBS += ../../../bin/xmicrokdepim.lib
34LIBS += ../../../bin/microkcal.lib 34LIBS += ../../../bin/xmicrokcal.lib
35LIBS += ../../../bin/microkde.lib 35LIBS += ../../../bin/xmicrokde.lib
36LIBS += ../../../bin/microkabc.lib 36LIBS += ../../../bin/microkabc.lib
37} 37}
38#The following line was inserted by qt3to4
39QT += qt3support
40#The following line was inserted by qt3to4
41QT += xml
diff --git a/kabc/plugins/file/fileE.pro b/kabc/plugins/file/fileE.pro
index 16707e5..5044cd9 100644
--- a/kabc/plugins/file/fileE.pro
+++ b/kabc/plugins/file/fileE.pro
@@ -1,21 +1,21 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5TARGET = microkabc_file 5TARGET = xmicrokabc_file
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat 6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde -lmicrokabc 10LIBS += -lxmicrokde -lxmicrokabc
11LIBS += -L$(QPEDIR)/lib 11LIBS += -L$(QPEDIR)/lib
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 resourcefile.h \ 16 resourcefile.h \
17 resourcefileconfig.h 17 resourcefileconfig.h
18 18
19SOURCES = \ 19SOURCES = \
20 resourcefile.cpp \ 20 resourcefile.cpp \
21 resourcefileconfig.cpp 21 resourcefileconfig.cpp
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index dad4571..3ed850c 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -140,291 +140,291 @@ void ResourceFile::init( const QString &fileName, const QString &formatName )
140 QFileInfo fi2 ( localname ); 140 QFileInfo fi2 ( localname );
141 if ( ! fi2.exists() || mFamily == "sync_res" ) { 141 if ( ! fi2.exists() || mFamily == "sync_res" ) {
142 if ( fi.exists() && mFamily == "sync_res") { 142 if ( fi.exists() && mFamily == "sync_res") {
143 qDebug("LOCAL mode SYNC mode using absolute file path "); 143 qDebug("LOCAL mode SYNC mode using absolute file path ");
144 setFileName( fileName ); 144 setFileName( fileName );
145 return; 145 return;
146 } else { 146 } else {
147 KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") ); 147 KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") );
148 setFileName( localname ); 148 setFileName( localname );
149 return; 149 return;
150 } 150 }
151 151
152 } else { 152 } else {
153 qDebug("Local resource file found. Changing filename to: %s",localname.latin1() ); 153 qDebug("Local resource file found. Changing filename to: %s",localname.latin1() );
154 setFileName( localname ); 154 setFileName( localname );
155 return; 155 return;
156 } 156 }
157 157
158 } 158 }
159 setFileName( fileName ); 159 setFileName( fileName );
160} 160}
161 161
162ResourceFile::~ResourceFile() 162ResourceFile::~ResourceFile()
163{ 163{
164 delete mFormat; 164 delete mFormat;
165 mFormat = 0; 165 mFormat = 0;
166} 166}
167 167
168void ResourceFile::writeConfig( KConfig *config ) 168void ResourceFile::writeConfig( KConfig *config )
169{ 169{
170 170
171 config->setGroup( "Resource_" + identifier() ); 171 config->setGroup( "Resource_" + identifier() );
172 Resource::writeConfig( config ); 172 Resource::writeConfig( config );
173 173
174 config->writeEntry( "FileName", fileName() ); 174 config->writeEntry( "FileName", fileName() );
175 config->writeEntry( "FileFormat", mFormatName ); 175 config->writeEntry( "FileFormat", mFormatName );
176 176
177// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 177// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
178 178
179} 179}
180 180
181Ticket *ResourceFile::requestSaveTicket() 181Ticket *ResourceFile::requestSaveTicket()
182{ 182{
183 kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; 183 kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl;
184 184
185 if ( !addressBook() ) return 0; 185 if ( !addressBook() ) return 0;
186 186
187#ifdef ALLOW_LOCKING 187#ifdef ALLOW_LOCKING
188 if ( !lock( mFileName ) ) { 188 if ( !lock( mFileName ) ) {
189 qDebug("unablt to lock file "); 189 qDebug("unablt to lock file ");
190 return 0; 190 return 0;
191 } 191 }
192#endif 192#endif
193 return createTicket( this ); 193 return createTicket( this );
194} 194}
195 195
196 196
197bool ResourceFile::doOpen() 197bool ResourceFile::doOpen()
198{ 198{
199 QFile file( fileName() ); 199 QFile file( fileName() );
200 qDebug("ResourceFile::openfile %s ", fileName().latin1()); 200 qDebug("ResourceFile::openfile %s ", fileName().latin1());
201 201
202 if ( !file.exists() ) { 202 if ( !file.exists() ) {
203 // try to create the file 203 // try to create the file
204 bool ok = file.open( IO_WriteOnly ); 204 bool ok = file.open( QIODevice::WriteOnly );
205 if ( ok ) 205 if ( ok )
206 file.close(); 206 file.close();
207 207
208 return ok; 208 return ok;
209 } else { 209 } else {
210 if ( !file.open( IO_ReadWrite ) ) 210 if ( !file.open( QIODevice::ReadWrite ) )
211 return false; 211 return false;
212 212
213 if ( file.size() < 10 ) { 213 if ( file.size() < 10 ) {
214 file.close(); 214 file.close();
215 return true; 215 return true;
216 } 216 }
217 217
218 bool ok = mFormat->checkFormat( &file ); 218 bool ok = mFormat->checkFormat( &file );
219 file.close(); 219 file.close();
220 220
221 return ok; 221 return ok;
222 } 222 }
223} 223}
224 224
225void ResourceFile::doClose() 225void ResourceFile::doClose()
226{ 226{
227} 227}
228 228
229bool ResourceFile::load() 229bool ResourceFile::load()
230{ 230{
231 231
232 QFile file( fileName() ); 232 QFile file( fileName() );
233 if ( !file.open( IO_ReadOnly ) ) { 233 if ( !file.open( QIODevice::ReadOnly ) ) {
234 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) ); 234 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) );
235 return false; 235 return false;
236 } 236 }
237 237
238// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); 238// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
239 239
240 return mFormat->loadAll( addressBook(), this, &file ); 240 return mFormat->loadAll( addressBook(), this, &file );
241} 241}
242 242
243bool ResourceFile::save( Ticket *ticket ) 243bool ResourceFile::save( Ticket *ticket )
244{ 244{
245// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); 245// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
246 246
247 247
248 // create backup file 248 // create backup file
249 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 249 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
250 250
251/*US we use a simpler method to create a backupfile 251/*US we use a simpler method to create a backupfile
252 252
253 (void) KSaveFile::backupFile( mFileName, QString::null 253 (void) KSaveFile::backupFile( mFileName, QString::null
254 ,extension ); 254 ,extension );
255 255
256 KSaveFile saveFile( mFileName ); 256 KSaveFile saveFile( mFileName );
257 bool ok = false; 257 bool ok = false;
258 if ( saveFile.status() == 0 && saveFile.file() ) 258 if ( saveFile.status() == 0 && saveFile.file() )
259 { 259 {
260 mFormat->saveAll( addressBook(), this, saveFile.file() ); 260 mFormat->saveAll( addressBook(), this, saveFile.file() );
261 ok = saveFile.close(); 261 ok = saveFile.close();
262 } 262 }
263*/ 263*/
264 264
265//US ToDo: write backupfile 265//US ToDo: write backupfile
266#ifndef NO_DIRWATCH 266#ifndef NO_DIRWATCH
267 mDirWatch.stopScan(); 267 mDirWatch.stopScan();
268#endif 268#endif
269 if ( mLastBackupDate >= 0 && mFamily != "sync_res") { 269 if ( mLastBackupDate >= 0 && mFamily != "sync_res") {
270 KConfig conf (locateLocal("config","microkdeglobalrc")); 270 KConfig conf (locateLocal("config","microkdeglobalrc"));
271 conf.setGroup( "BackupSettings" ); 271 conf.setGroup( "BackupSettings" );
272 bool b_enabled = conf.readBoolEntry( "BackupEnabled" ); 272 bool b_enabled = conf.readBoolEntry( "BackupEnabled" );
273 if ( b_enabled ) { 273 if ( b_enabled ) {
274 int num = conf.readNumEntry( "BackupNumbers" ); 274 int num = conf.readNumEntry( "BackupNumbers" );
275 int d_count = conf.readNumEntry( "BackupDayCount" ); 275 int d_count = conf.readNumEntry( "BackupDayCount" );
276 bool stdDir = conf.readBoolEntry( "BackupUseDefaultDir" ); 276 bool stdDir = conf.readBoolEntry( "BackupUseDefaultDir" );
277 QString bupDir = conf.readEntry( "BackupDatadir" ); 277 QString bupDir = conf.readEntry( "BackupDatadir" );
278 QDate reference ( 2000,1,1 ); 278 QDate reference ( 2000,1,1 );
279 int daysTo = reference.daysTo ( QDate::currentDate() ); 279 int daysTo = reference.daysTo ( QDate::currentDate() );
280 bool saveDate = false; 280 bool saveDate = false;
281 if ( daysTo - d_count >= mLastBackupDate ) { 281 if ( daysTo - d_count >= mLastBackupDate ) {
282 qDebug("KA: Last backup was %d days ago ", daysTo - mLastBackupDate ); 282 qDebug("KA: Last backup was %d days ago ", daysTo - mLastBackupDate );
283 if ( stdDir ) 283 if ( stdDir )
284 bupDir = KGlobalSettings::backupDataDir(); 284 bupDir = KGlobalSettings::backupDataDir();
285 int retval = KApplication::createBackup( fileName(), bupDir, num ); 285 int retval = KApplication::createBackup( fileName(), bupDir, num );
286 if ( retval == 0 ) { 286 if ( retval == 0 ) {
287 qDebug("KO: Backup cancelled. Will try again tomorrow "); 287 qDebug("KO: Backup cancelled. Will try again tomorrow ");
288 // retval == 0 : backup skipped for today, try again tomorrow 288 // retval == 0 : backup skipped for today, try again tomorrow
289 mLastBackupDate = daysTo - d_count+1; 289 mLastBackupDate = daysTo - d_count+1;
290 saveDate = true; 290 saveDate = true;
291 } else if ( retval == 1 ){ 291 } else if ( retval == 1 ){
292 qDebug("KO: Backup created."); 292 qDebug("KO: Backup created.");
293 // backup ok 293 // backup ok
294 mLastBackupDate = daysTo; 294 mLastBackupDate = daysTo;
295 saveDate = true; 295 saveDate = true;
296 } else if ( retval == 2 ){ 296 } else if ( retval == 2 ){
297 qDebug("KO: Backup globally cancelled."); 297 qDebug("KO: Backup globally cancelled.");
298 // backup globally cancelled 298 // backup globally cancelled
299 b_enabled = false; 299 b_enabled = false;
300 } 300 }
301 if ( !b_enabled ) { 301 if ( !b_enabled ) {
302 conf.writeEntry( "mBackupEnabled", false ); 302 conf.writeEntry( "mBackupEnabled", false );
303 } 303 }
304 if ( saveDate ) { 304 if ( saveDate ) {
305 KConfig config ( locateLocal("config","kabcrc") ); 305 KConfig config ( locateLocal("config","kabcrc") );
306 config.setGroup( "Resource_" + identifier() ); 306 config.setGroup( "Resource_" + identifier() );
307 config.writeEntry( "LastBackupDate", mLastBackupDate ); 307 config.writeEntry( "LastBackupDate", mLastBackupDate );
308 } 308 }
309 } 309 }
310 } 310 }
311 } 311 }
312 QFile info; 312 QFile info;
313 info.setName( fileName() ); 313 info.setName( fileName() );
314 bool ok = info.open( IO_WriteOnly ); 314 bool ok = info.open( QIODevice::WriteOnly );
315 if ( ok ) { 315 if ( ok ) {
316 mFormat->saveAll( addressBook(), this, &info ); 316 mFormat->saveAll( addressBook(), this, &info );
317 317
318 info.close(); 318 info.close();
319 ok = true; 319 ok = true;
320 } 320 }
321 else { 321 else {
322 322
323 } 323 }
324 324
325 if ( !ok ) 325 if ( !ok )
326 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( fileName() ) ); 326 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( fileName() ) );
327#ifndef NO_DIRWATCH 327#ifndef NO_DIRWATCH
328 mDirWatch.startScan(); 328 mDirWatch.startScan();
329#endif 329#endif
330 delete ticket; 330 delete ticket;
331#ifdef ALLOW_LOCKING 331#ifdef ALLOW_LOCKING
332 unlock( mFileName ); 332 unlock( mFileName );
333#endif 333#endif
334 334
335 return ok; 335 return ok;
336} 336}
337 337
338bool ResourceFile::lock( const QString &fileName ) 338bool ResourceFile::lock( const QString &fileName )
339{ 339{
340#ifdef ALLOW_LOCKING 340#ifdef ALLOW_LOCKING
341 341
342 342
343 QString fn = fileName; 343 QString fn = fileName;
344 344
345//US change the implementation how the lockfilename is getting created 345//US change the implementation how the lockfilename is getting created
346//US fn.replace( QRegExp("/"), "_" ); 346//US fn.replace( QRegExp("/"), "_" );
347//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 347//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
348 348
349 KURL url(fn); 349 KURL url(fn);
350 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 350 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
351 351
352 352
353 353
354 if (QFile::exists( lockName )) return false; 354 if (QFile::exists( lockName )) return false;
355 355
356 QString lockUniqueName; 356 QString lockUniqueName;
357 lockUniqueName = fn + KApplication::randomString( 8 ); 357 lockUniqueName = fn + KApplication::randomString( 8 );
358 358
359 url = lockUniqueName; 359 url = lockUniqueName;
360//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 360//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
361 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 361 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
362 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 362 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
363 363
364 // Create unique file 364 // Create unique file
365 QFile file( mLockUniqueName ); 365 QFile file( mLockUniqueName );
366 file.open( IO_WriteOnly ); 366 file.open( QIODevice::WriteOnly );
367 file.close(); 367 file.close();
368 368
369 // Create lock file 369 // Create lock file
370 int result = 0; 370 int result = 0;
371#ifndef _WIN32_ 371#ifndef _WIN32_
372 result = ::link( QFile::encodeName( mLockUniqueName ), 372 result = ::link( QFile::encodeName( mLockUniqueName ),
373 QFile::encodeName( lockName ) ); 373 QFile::encodeName( lockName ) );
374#endif 374#endif
375 if ( result == 0 ) { 375 if ( result == 0 ) {
376 addressBook()->emitAddressBookLocked(); 376 addressBook()->emitAddressBookLocked();
377 return true; 377 return true;
378 } 378 }
379 379
380 // TODO: check stat 380 // TODO: check stat
381 381
382 return false; 382 return false;
383#else 383#else
384 return true; 384 return true;
385#endif 385#endif
386} 386}
387 387
388void ResourceFile::unlock( const QString &fileName ) 388void ResourceFile::unlock( const QString &fileName )
389{ 389{
390#ifdef ALLOW_LOCKING 390#ifdef ALLOW_LOCKING
391 QString fn = fileName; 391 QString fn = fileName;
392//US change the implementation how the lockfilename is getting created 392//US change the implementation how the lockfilename is getting created
393//US fn.replace( QRegExp( "/" ), "_" ); 393//US fn.replace( QRegExp( "/" ), "_" );
394//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 394//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
395//US QString lockName = fn + ".lock"; 395//US QString lockName = fn + ".lock";
396 KURL url(fn); 396 KURL url(fn);
397 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 397 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
398 398
399 QFile::remove( lockName ); 399 QFile::remove( lockName );
400 QFile::remove( mLockUniqueName ); 400 QFile::remove( mLockUniqueName );
401 addressBook()->emitAddressBookUnlocked(); 401 addressBook()->emitAddressBookUnlocked();
402#else 402#else
403 return; 403 return;
404#endif 404#endif
405} 405}
406 406
407void ResourceFile::setFileName( const QString &fileName ) 407void ResourceFile::setFileName( const QString &fileName )
408{ 408{
409#ifndef NO_DIRWATCH 409#ifndef NO_DIRWATCH
410 mDirWatch.stopScan(); 410 mDirWatch.stopScan();
411 mDirWatch.removeFile( mFileName ); 411 mDirWatch.removeFile( mFileName );
412 mFileName = fileName; 412 mFileName = fileName;
413 413
414 414
415 mDirWatch.addFile( mFileName ); 415 mDirWatch.addFile( mFileName );
416 mDirWatch.startScan(); 416 mDirWatch.startScan();
417#else 417#else
418 mFileName2 = fileName; 418 mFileName2 = fileName;
419#endif 419#endif
420 420
421//US simulate KDirWatch event 421//US simulate KDirWatch event
422//US fileChanged(); 422//US fileChanged();
423} 423}
424 424
425QString ResourceFile::fileName() const 425QString ResourceFile::fileName() const
426{ 426{
427 return mFileName2; 427 return mFileName2;
428} 428}
429 429
430void ResourceFile::setFormat( const QString &format ) 430void ResourceFile::setFormat( const QString &format )
diff --git a/kabc/plugins/file/resourcefileconfig.cpp b/kabc/plugins/file/resourcefileconfig.cpp
index b63775d..70b0bac 100644
--- a/kabc/plugins/file/resourcefileconfig.cpp
+++ b/kabc/plugins/file/resourcefileconfig.cpp
@@ -1,117 +1,119 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
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#include <qfileinfo.h> 30#include <qfileinfo.h>
31//Added by qt3to4:
32#include <Q3GridLayout>
31 33
32#include <kdebug.h> 34#include <kdebug.h>
33#include <klocale.h> 35#include <klocale.h>
34#include <kstandarddirs.h> 36#include <kstandarddirs.h>
35#include <kdialog.h> 37#include <kdialog.h>
36#ifndef _WIN32_ 38#ifndef _WIN32_
37#include <unistd.h> 39#include <unistd.h>
38#endif 40#endif
39//US #include "formatfactory.h" 41//US #include "formatfactory.h"
40#include <qfile.h> 42#include <qfile.h>
41#include "resourcefile.h" 43#include "resourcefile.h"
42#include "stdaddressbook.h" 44#include "stdaddressbook.h"
43 45
44#include "resourcefileconfig.h" 46#include "resourcefileconfig.h"
45 47
46using namespace KABC; 48using namespace KABC;
47 49
48ResourceFileConfig::ResourceFileConfig( QWidget* parent, const char* name ) 50ResourceFileConfig::ResourceFileConfig( QWidget* parent, const char* name )
49 : ConfigWidget( parent, name ) 51 : ConfigWidget( parent, name )
50{ 52{
51//qDebug("ResourceFileConfig::ResourceFileConfig"); 53//qDebug("ResourceFileConfig::ResourceFileConfig");
52 54
53 QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0, 55 Q3GridLayout *mainLayout = new Q3GridLayout( this, 2, 2, 0,
54 KDialog::spacingHint() ); 56 KDialog::spacingHint() );
55 57
56 QLabel *label = new QLabel( i18n( "Format:" ), this ); 58 QLabel *label = new QLabel( i18n( "Format:" ), this );
57 mFormatBox = new KComboBox( this ); 59 mFormatBox = new KComboBox( this );
58 60
59 mainLayout->addWidget( label, 0, 0 ); 61 mainLayout->addWidget( label, 0, 0 );
60 mainLayout->addWidget( mFormatBox, 0, 1 ); 62 mainLayout->addWidget( mFormatBox, 0, 1 );
61 63
62 label = new QLabel( i18n( "Location:" ), this ); 64 label = new QLabel( i18n( "Location:" ), this );
63 mFileNameEdit = new KURLRequester( this ); 65 mFileNameEdit = new KURLRequester( this );
64 66
65 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 67 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
66 SLOT( checkFilePermissions( const QString & ) ) ); 68 SLOT( checkFilePermissions( const QString & ) ) );
67 69
68 mainLayout->addWidget( label, 1, 0 ); 70 mainLayout->addWidget( label, 1, 0 );
69 mainLayout->addWidget( mFileNameEdit, 1, 1 ); 71 mainLayout->addWidget( mFileNameEdit, 1, 1 );
70 72
71 73
72/*US lets hardcode the formats instead of using a factory 74/*US lets hardcode the formats instead of using a factory
73 FormatFactory *factory = FormatFactory::self(); 75 FormatFactory *factory = FormatFactory::self();
74 QStringList formats = factory->formats(); 76 QStringList formats = factory->formats();
75 QStringList::Iterator it; 77 QStringList::Iterator it;
76 78
77 for ( it = formats.begin(); it != formats.end(); ++it ) { 79 for ( it = formats.begin(); it != formats.end(); ++it ) {
78 FormatInfo *info = factory->info( *it ); 80 FormatInfo *info = factory->info( *it );
79 if ( info ) { 81 if ( info ) {
80 mFormatTypes << (*it); 82 mFormatTypes << (*it);
81 mFormatBox->insertItem( info->nameLabel ); 83 mFormatBox->insertItem( info->nameLabel );
82 } 84 }
83 } 85 }
84*/ 86*/
85 mFormatTypes << "vcard"; 87 mFormatTypes << "vcard";
86 mFormatTypes << "binary"; 88 mFormatTypes << "binary";
87 mFormatBox->insertItem( "vcard" ); 89 mFormatBox->insertItem( "vcard" );
88 mFormatBox->insertItem( "binary" ); 90 mFormatBox->insertItem( "binary" );
89 91
90 mInEditMode = false; 92 mInEditMode = false;
91} 93}
92 94
93void ResourceFileConfig::setEditMode( bool value ) 95void ResourceFileConfig::setEditMode( bool value )
94{ 96{
95 mFormatBox->setEnabled( !value ); 97 mFormatBox->setEnabled( !value );
96 mInEditMode = value; 98 mInEditMode = value;
97} 99}
98 100
99void ResourceFileConfig::loadSettings( KRES::Resource *res ) 101void ResourceFileConfig::loadSettings( KRES::Resource *res )
100{ 102{
101//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 103//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
102 ResourceFile *resource = (ResourceFile*)( res ); 104 ResourceFile *resource = (ResourceFile*)( res );
103 105
104 if ( !resource ) { 106 if ( !resource ) {
105 kdDebug(5700) << "ResourceFileConfig::loadSettings(): cast failed" << endl; 107 kdDebug(5700) << "ResourceFileConfig::loadSettings(): cast failed" << endl;
106 return; 108 return;
107 } 109 }
108 110
109 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); 111 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
110 112
111 mFileNameEdit->setURL( resource->fileName() ); 113 mFileNameEdit->setURL( resource->fileName() );
112 if ( mFileNameEdit->url().isEmpty() ) 114 if ( mFileNameEdit->url().isEmpty() )
113 mFileNameEdit->setURL( KABC::StdAddressBook::fileName() ); 115 mFileNameEdit->setURL( KABC::StdAddressBook::fileName() );
114} 116}
115 117
116void ResourceFileConfig::saveSettings( KRES::Resource *res ) 118void ResourceFileConfig::saveSettings( KRES::Resource *res )
117{ 119{
diff --git a/kabc/plugins/ldap/ldapE.pro b/kabc/plugins/ldap/ldapE.pro
index 57b6f84..c56d24d 100644
--- a/kabc/plugins/ldap/ldapE.pro
+++ b/kabc/plugins/ldap/ldapE.pro
@@ -1,21 +1,21 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5TARGET = microkabc_ldap 5TARGET = xmicrokabc_ldap
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde -lmicrokabc 10LIBS += -lxmicrokde -lxmicrokabc
11LIBS += -L$(QPEDIR)/lib 11LIBS += -L$(QPEDIR)/lib
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 resourceldap.h \ 16 resourceldap.h \
17 resourceldapconfig.h 17 resourceldapconfig.h
18 18
19SOURCES = \ 19SOURCES = \
20 resourceldap.cpp \ 20 resourceldap.cpp \
21 resourceldapconfig.cpp 21 resourceldapconfig.cpp
diff --git a/kabc/plugins/olaccess/olaccess.pro b/kabc/plugins/olaccess/olaccess.pro
index 9b95015..ad7e1ef 100644
--- a/kabc/plugins/olaccess/olaccess.pro
+++ b/kabc/plugins/olaccess/olaccess.pro
@@ -1,35 +1,35 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3TARGET = microkabc_olaccess 3TARGET = xmicrokabc_olaccess
4 4
5include( ../../../variables.pri ) 5include( ../../../variables.pri )
6 6
7INCLUDEPATH += ../../.. ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat 7INCLUDEPATH += ../../.. ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
8 8
9INTERFACES = \ 9INTERFACES = \
10 10
11DESTDIR = ../../../bin 11DESTDIR = ../../../bin
12HEADERS = \ 12HEADERS = \
13 resourceolaccess.h \ 13 resourceolaccess.h \
14 resourceolaccessconfig.h \ 14 resourceolaccessconfig.h \
15 olaccessconverter.h 15 olaccessconverter.h
16 16
17SOURCES = \ 17SOURCES = \
18 resourceolaccess.cpp \ 18 resourceolaccess.cpp \
19 resourceolaccessconfig.cpp \ 19 resourceolaccessconfig.cpp \
20 olaccessconverter.cpp 20 olaccessconverter.cpp
21 21
22unix : { 22unix : {
23OBJECTS_DIR = obj/unix 23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix 24MOC_DIR = moc/unix
25} 25}
26win32: { 26win32: {
27CONFIG += dll 27CONFIG += dll
28DEFINES += _WIN32_ 28DEFINES += _WIN32_
29OBJECTS_DIR = obj/win 29OBJECTS_DIR = obj/win
30MOC_DIR = moc/win 30MOC_DIR = moc/win
31LIBS += ../../../bin/microkdepim.lib 31LIBS += ../../../bin/xmicrokdepim.lib
32LIBS += ../../../bin/microkcal.lib 32LIBS += ../../../bin/xmicrokcal.lib
33LIBS += ../../../bin/microkde.lib 33LIBS += ../../../bin/xmicrokde.lib
34LIBS += ../../../bin/microkabc.lib 34LIBS += ../../../bin/microkabc.lib
35} 35}
diff --git a/kabc/plugins/opie/opieE.pro b/kabc/plugins/opie/opieE.pro
index b7ecbc0..aa6b8ea 100644
--- a/kabc/plugins/opie/opieE.pro
+++ b/kabc/plugins/opie/opieE.pro
@@ -1,31 +1,31 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3#release debug 3#release debug
4TARGET = microkabc_opie 4TARGET = xmicrokabc_opie
5 5
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include $(OPIEDIR)/include 6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include $(OPIEDIR)/include
7 7
8 8
9OBJECTS_DIR = obj/$(PLATFORM) 9OBJECTS_DIR = obj/$(PLATFORM)
10MOC_DIR = moc/$(PLATFORM) 10MOC_DIR = moc/$(PLATFORM)
11DESTDIR = $(QPEDIR)/lib 11DESTDIR = $(QPEDIR)/lib
12LIBS += -lmicrokde 12LIBS += -lxmicrokde
13LIBS += -lmicrokabc 13LIBS += -lxmicrokabc
14LIBS += -L$(QPEDIR)/lib 14LIBS += -L$(QPEDIR)/lib
15LIBS += -L$(OPIEDIR)/lib 15LIBS += -L$(OPIEDIR)/lib
16LIBS += -lopie 16LIBS += -lopie
17LIBS += -lqpe 17LIBS += -lqpe
18LIBS += -lqte 18LIBS += -lqte
19 19
20INTERFACES = \ 20INTERFACES = \
21 21
22HEADERS = \ 22HEADERS = \
23 resourceopie.h \ 23 resourceopie.h \
24 resourceopieconfig.h \ 24 resourceopieconfig.h \
25 opieconverter.h \ 25 opieconverter.h \
26 26
27SOURCES = \ 27SOURCES = \
28 resourceopie.cpp \ 28 resourceopie.cpp \
29 resourceopieconfig.cpp \ 29 resourceopieconfig.cpp \
30 opieconverter.cpp \ 30 opieconverter.cpp \
31 31
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
@@ -1,384 +1,386 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
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//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
100 goto startover; 102 goto startover;
101 } 103 }
102 } 104 }
103 105
104 return dummy.join(";"); 106 return dummy.join(";");
105} 107}
106 108
107 109
108// FROM TT timeconversion.cpp GPLed 110// FROM TT timeconversion.cpp GPLed
109QDate QtopiaConverter::fromString( const QString &datestr ) 111QDate QtopiaConverter::fromString( const QString &datestr )
110{ 112{
111 if (datestr.isEmpty() ) 113 if (datestr.isEmpty() )
112 return QDate(); 114 return QDate();
113 115
114 int monthPos = datestr.find('.'); 116 int monthPos = datestr.find('.');
115 int yearPos = datestr.find('.', monthPos+1 ); 117 int yearPos = datestr.find('.', monthPos+1 );
116 if ( monthPos == -1 || yearPos == -1 ) { 118 if ( monthPos == -1 || yearPos == -1 ) {
117 return QDate(); 119 return QDate();
118 } 120 }
119 int d = datestr.left( monthPos ).toInt(); 121 int d = datestr.left( monthPos ).toInt();
120 int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); 122 int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt();
121 int y = datestr.mid( yearPos+1 ).toInt(); 123 int y = datestr.mid( yearPos+1 ).toInt();
122 QDate date ( y,m,d ); 124 QDate date ( y,m,d );
123 125
124 126
125 return date; 127 return date;
126} 128}
127 129
128QDate QtopiaConverter::dateFromString( const QString& s ) 130QDate QtopiaConverter::dateFromString( const QString& s )
129{ 131{
130 QDate date; 132 QDate date;
131 133
132 if ( s.isEmpty() ) 134 if ( s.isEmpty() )
133 return date; 135 return date;
134 136
135 // Be backward compatible to old Opie format: 137 // Be backward compatible to old Opie format:
136 // Try to load old format. If it fails, try new ISO-Format! 138 // Try to load old format. If it fails, try new ISO-Format!
137 date = fromString ( s ); 139 date = fromString ( s );
138 if ( date.isValid() ) 140 if ( date.isValid() )
139 return date; 141 return date;
140 142
141 // Read ISO-Format (YYYYMMDD) 143 // Read ISO-Format (YYYYMMDD)
142 int year = s.mid(0, 4).toInt(); 144 int year = s.mid(0, 4).toInt();
143 int month = s.mid(4,2).toInt(); 145 int month = s.mid(4,2).toInt();
144 int day = s.mid(6,2).toInt(); 146 int day = s.mid(6,2).toInt();
145 147
146 // do some quick sanity checking 148 // do some quick sanity checking
147 if ( year < 1900 || year > 3000 ) 149 if ( year < 1900 || year > 3000 )
148 return date; 150 return date;
149 151
150 if ( month < 0 || month > 12 ) 152 if ( month < 0 || month > 12 )
151 return date; 153 return date;
152 154
153 if ( day < 0 || day > 31 ) 155 if ( day < 0 || day > 31 )
154 return date; 156 return date;
155 157
156 158
157 date.setYMD( year, month, day ); 159 date.setYMD( year, month, day );
158 160
159 if ( !date.isValid() ) 161 if ( !date.isValid() )
160 return QDate(); 162 return QDate();
161 163
162 164
163 return date; 165 return date;
164} 166}
165QString QtopiaConverter::dateToString( const QDate &d ) 167QString QtopiaConverter::dateToString( const QDate &d )
166{ 168{
167 if ( d.isNull() || !d.isValid() ) 169 if ( d.isNull() || !d.isValid() )
168 return QString::null; 170 return QString::null;
169 171
170 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 172 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
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
220 // Handle multiple mail addresses 222 // Handle multiple mail addresses
221 QString DefaultEmail = el.attribute( "DefaultEmail" ); 223 QString DefaultEmail = el.attribute( "DefaultEmail" );
222 if ( !DefaultEmail.isEmpty() ) 224 if ( !DefaultEmail.isEmpty() )
223 adr.insertEmail( DefaultEmail, true ); // preferred 225 adr.insertEmail( DefaultEmail, true ); // preferred
224 226
225 QStringList Emails = QStringList::split(" ",el.attribute("Emails")); 227 QStringList Emails = QStringList::split(" ",el.attribute("Emails"));
226 int i; 228 int i;
227 for (i = 0;i < Emails.count();++i) { 229 for (i = 0;i < Emails.count();++i) {
228 if ( Emails[i] != DefaultEmail ) 230 if ( Emails[i] != DefaultEmail )
229 adr.insertEmail( Emails[i], false ); 231 adr.insertEmail( Emails[i], false );
230 } 232 }
231 233
232 KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ), 234 KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ),
233 KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref); 235 KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref);
234 KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ), 236 KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ),
235 KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 237 KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
236 238
237 KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ), 239 KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ),
238 KABC::PhoneNumber::Cell ); 240 KABC::PhoneNumber::Cell );
239 241
240 if ( !homePhoneNum.number().isEmpty() ) 242 if ( !homePhoneNum.number().isEmpty() )
241 adr.insertPhoneNumber( homePhoneNum ); 243 adr.insertPhoneNumber( homePhoneNum );
242 if ( !homeFax.number().isEmpty() ) 244 if ( !homeFax.number().isEmpty() )
243 adr.insertPhoneNumber( homeFax ); 245 adr.insertPhoneNumber( homeFax );
244 if ( !homeMobile.number().isEmpty() ) 246 if ( !homeMobile.number().isEmpty() )
245 adr.insertPhoneNumber( homeMobile ); 247 adr.insertPhoneNumber( homeMobile );
246 248
247 KABC::Address business( KABC::Address::Work ); 249 KABC::Address business( KABC::Address::Work );
248 business.setStreet( el.attribute( "BusinessStreet" ) ); 250 business.setStreet( el.attribute( "BusinessStreet" ) );
249 business.setLocality( el.attribute( "BusinessCity" ) ); 251 business.setLocality( el.attribute( "BusinessCity" ) );
250 business.setRegion( el.attribute( "BusinessState" ) ); 252 business.setRegion( el.attribute( "BusinessState" ) );
251 business.setPostalCode( el.attribute( "BusinessZip" ) ); 253 business.setPostalCode( el.attribute( "BusinessZip" ) );
252 business.setCountry( el.attribute( "BusinessCountry" ) ); 254 business.setCountry( el.attribute( "BusinessCountry" ) );
253 255
254 if ( !business.isEmpty() ) 256 if ( !business.isEmpty() )
255 adr.insertAddress( business ); 257 adr.insertAddress( business );
256 258
257 KABC::Address home( KABC::Address::Home ); 259 KABC::Address home( KABC::Address::Home );
258 home.setStreet( el.attribute( "HomeStreet" ) ); 260 home.setStreet( el.attribute( "HomeStreet" ) );
259 home.setLocality( el.attribute( "HomeCity" ) ); 261 home.setLocality( el.attribute( "HomeCity" ) );
260 home.setRegion( el.attribute( "HomeState" ) ); 262 home.setRegion( el.attribute( "HomeState" ) );
261 home.setPostalCode( el.attribute( "HomeZip" ) ); 263 home.setPostalCode( el.attribute( "HomeZip" ) );
262 home.setCountry( el.attribute( "HomeCountry" ) ); 264 home.setCountry( el.attribute( "HomeCountry" ) );
263 265
264 if ( !home.isEmpty() ) 266 if ( !home.isEmpty() )
265 adr.insertAddress( home ); 267 adr.insertAddress( home );
266 268
267 adr.setNickName( el.attribute( "Nickname" ) ); 269 adr.setNickName( el.attribute( "Nickname" ) );
268 adr.setNote( el.attribute( "Notes" ) ); 270 adr.setNote( el.attribute( "Notes" ) );
269 271
270 { 272 {
271 QStringList categories = QStringList::split(";", el.attribute("Categories" ) ); 273 QStringList categories = QStringList::split(";", el.attribute("Categories" ) );
272 QString cat; 274 QString cat;
273 QStringList added; 275 QStringList added;
274 for ( uint i = 0; i < categories.count(); i++ ) { 276 for ( uint i = 0; i < categories.count(); i++ ) {
275 cat = m_edit->categoryById( categories[ i ], "Contacts" ); 277 cat = m_edit->categoryById( categories[ i ], "Contacts" );
276 278
277 // if name is not empty and we did not add the 279 // if name is not empty and we did not add the
278 // cat try to repair broken files 280 // cat try to repair broken files
279 if ( !cat.isEmpty() && !added.contains( cat ) ) { 281 if ( !cat.isEmpty() && !added.contains( cat ) ) {
280 adr.insertCategory( cat ); 282 adr.insertCategory( cat );
281 added << cat; 283 added << cat;
282 } 284 }
283 } 285 }
284 } 286 }
285 287
286 if ( !el.attribute( "Department" ).isEmpty() ) 288 if ( !el.attribute( "Department" ).isEmpty() )
287 adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) ); 289 adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) );
288 if ( !el.attribute( "HomeWebPage" ).isEmpty() ) 290 if ( !el.attribute( "HomeWebPage" ).isEmpty() )
289 adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) ); 291 adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) );
290 if ( !el.attribute( "Spouse" ).isEmpty() ) 292 if ( !el.attribute( "Spouse" ).isEmpty() )
291 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) ); 293 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) );
292 if ( !el.attribute( "Gender" ).isEmpty() ) { 294 if ( !el.attribute( "Gender" ).isEmpty() ) {
293 if ( el.attribute( "Gender" ) == "1" ) 295 if ( el.attribute( "Gender" ) == "1" )
294 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); 296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
295 else if ( el.attribute( "Gender" ) == "2" ) 297 else if ( el.attribute( "Gender" ) == "2" )
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
345 KABC::PhoneNumber businessMobile = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell ); 347 KABC::PhoneNumber businessMobile = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell );
346 *stream << "BusinessMobile=\"" << escape( businessMobile.number() ) << "\" "; 348 *stream << "BusinessMobile=\"" << escape( businessMobile.number() ) << "\" ";
347 349
348 *stream << "DefaultEmail=\"" << escape( ab.preferredEmail() ) << "\" "; 350 *stream << "DefaultEmail=\"" << escape( ab.preferredEmail() ) << "\" ";
349 QStringList list = ab.emails(); 351 QStringList list = ab.emails();
350 if ( list.count() > 0 ) { 352 if ( list.count() > 0 ) {
351 QStringList::Iterator it = list.begin(); 353 QStringList::Iterator it = list.begin();
352 *stream << "Emails=\"" << escape( *it ); 354 *stream << "Emails=\"" << escape( *it );
353 while (++it != list.end()) 355 while (++it != list.end())
354 *stream << ' ' << escape( *it ); 356 *stream << ' ' << escape( *it );
355 *stream << "\" "; 357 *stream << "\" ";
356 } 358 }
357 359
358 KABC::PhoneNumber homePhoneNum = ab.phoneNumber(KABC::PhoneNumber::Home ); 360 KABC::PhoneNumber homePhoneNum = ab.phoneNumber(KABC::PhoneNumber::Home );
359 *stream << "HomePhone=\"" << escape( homePhoneNum.number() ) << "\" "; 361 *stream << "HomePhone=\"" << escape( homePhoneNum.number() ) << "\" ";
360 362
361 KABC::PhoneNumber homeFax = ab.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 363 KABC::PhoneNumber homeFax = ab.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
362 *stream << "HomeFax=\"" << escape( homeFax.number() ) << "\" "; 364 *stream << "HomeFax=\"" << escape( homeFax.number() ) << "\" ";
363 365
364 KABC::PhoneNumber homeMobile = ab.phoneNumber( KABC::PhoneNumber::Cell ); 366 KABC::PhoneNumber homeMobile = ab.phoneNumber( KABC::PhoneNumber::Cell );
365 *stream << "HomeMobile=\"" << escape( homeMobile.number() ) << "\" "; 367 *stream << "HomeMobile=\"" << escape( homeMobile.number() ) << "\" ";
366 368
367 KABC::Address business = ab.address(KABC::Address::Work ); 369 KABC::Address business = ab.address(KABC::Address::Work );
368 *stream << "BusinessStreet=\"" << escape( business.street() ) << "\" "; 370 *stream << "BusinessStreet=\"" << escape( business.street() ) << "\" ";
369 *stream << "BusinessCity=\"" << escape( business.locality() ) << "\" "; 371 *stream << "BusinessCity=\"" << escape( business.locality() ) << "\" ";
370 *stream << "BusinessZip=\"" << escape( business.postalCode() ) << "\" "; 372 *stream << "BusinessZip=\"" << escape( business.postalCode() ) << "\" ";
371 *stream << "BusinessCountry=\"" << escape( business.country() ) << "\" "; 373 *stream << "BusinessCountry=\"" << escape( business.country() ) << "\" ";
372 *stream << "BusinessState=\"" << escape( business.region() ) << "\" "; 374 *stream << "BusinessState=\"" << escape( business.region() ) << "\" ";
373 //stream << "BusinessPager=\"" << << "\" "; 375 //stream << "BusinessPager=\"" << << "\" ";
374 *stream << "Office=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Office" ) ) << "\" "; 376 *stream << "Office=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Office" ) ) << "\" ";
375 *stream << "Profession=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Profession" ) ) << "\" "; 377 *stream << "Profession=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Profession" ) ) << "\" ";
376 *stream << "Assistant=\"" << escape( ab.custom( "KADDRESSBOOK", "X-AssistantsName") ) << "\" "; 378 *stream << "Assistant=\"" << escape( ab.custom( "KADDRESSBOOK", "X-AssistantsName") ) << "\" ";
377 *stream << "Manager=\"" << escape( ab.custom( "KADDRESSBOOK", "X-ManagersName" ) ) << "\" "; 379 *stream << "Manager=\"" << escape( ab.custom( "KADDRESSBOOK", "X-ManagersName" ) ) << "\" ";
378 380
379 KABC::Address home = ab.address( KABC::Address::Home ); 381 KABC::Address home = ab.address( KABC::Address::Home );
380 *stream << "HomeStreet=\"" << escape( home.street() ) << "\" "; 382 *stream << "HomeStreet=\"" << escape( home.street() ) << "\" ";
381 *stream << "HomeCity=\"" << escape( home.locality() ) << "\" "; 383 *stream << "HomeCity=\"" << escape( home.locality() ) << "\" ";
382 *stream << "HomeState=\"" << escape( home.region() ) << "\" "; 384 *stream << "HomeState=\"" << escape( home.region() ) << "\" ";
383 *stream << "HomeZip=\"" << escape( home.postalCode() ) << "\" "; 385 *stream << "HomeZip=\"" << escape( home.postalCode() ) << "\" ";
384 *stream << "HomeCountry=\"" << escape( home.country() ) << "\" "; 386 *stream << "HomeCountry=\"" << escape( home.country() ) << "\" ";
@@ -423,232 +425,232 @@ KTempFile* AddressBook::fromKDE( KSync::AddressBookSyncee *syncee, ExtraMap& map
423 425
424} 426}
425 427
426QStringList AddressBook::attributes()const { 428QStringList AddressBook::attributes()const {
427 QStringList lst; 429 QStringList lst;
428 lst << "FirstName"; 430 lst << "FirstName";
429 lst << "MiddleName"; 431 lst << "MiddleName";
430 lst << "LastName"; 432 lst << "LastName";
431 lst << "Suffix"; 433 lst << "Suffix";
432 lst << "FileAs"; 434 lst << "FileAs";
433 lst << "JobTitle"; 435 lst << "JobTitle";
434 lst << "Department"; 436 lst << "Department";
435 lst << "Company"; 437 lst << "Company";
436 lst << "BusinessPhone"; 438 lst << "BusinessPhone";
437 lst << "BusinessFax"; 439 lst << "BusinessFax";
438 lst << "BusinessMobile"; 440 lst << "BusinessMobile";
439 lst << "DefaultEmail"; 441 lst << "DefaultEmail";
440 lst << "Emails"; 442 lst << "Emails";
441 lst << "HomePhone"; 443 lst << "HomePhone";
442 lst << "HomeFax"; 444 lst << "HomeFax";
443 lst << "HomeMobile"; 445 lst << "HomeMobile";
444 lst << "BusinessStreet"; 446 lst << "BusinessStreet";
445 lst << "BusinessCity"; 447 lst << "BusinessCity";
446 lst << "BusinessZip"; 448 lst << "BusinessZip";
447 lst << "BusinessCountry"; 449 lst << "BusinessCountry";
448 lst << "BusinessState"; 450 lst << "BusinessState";
449 lst << "Office"; 451 lst << "Office";
450 lst << "Profession"; 452 lst << "Profession";
451 lst << "Assistant"; 453 lst << "Assistant";
452 lst << "Manager"; 454 lst << "Manager";
453 lst << "HomeStreet"; 455 lst << "HomeStreet";
454 lst << "HomeCity"; 456 lst << "HomeCity";
455 lst << "HomeState"; 457 lst << "HomeState";
456 lst << "HomeZip"; 458 lst << "HomeZip";
457 lst << "HomeCountry"; 459 lst << "HomeCountry";
458 lst << "HomeWebPage"; 460 lst << "HomeWebPage";
459 lst << "Spouse"; 461 lst << "Spouse";
460 lst << "Gender"; 462 lst << "Gender";
461 lst << "Anniversary"; 463 lst << "Anniversary";
462 lst << "Nickname"; 464 lst << "Nickname";
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
565 */ 567 */
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;
615 } 617 }
616 618
617 return list; 619 return list;
618} 620}
619void CategoryEdit::updateKDE( const QString& configFile, const QStringList& cats ) { 621void CategoryEdit::updateKDE( const QString& configFile, const QStringList& cats ) {
620 KConfig conf(configFile); 622 KConfig conf(configFile);
621 conf.setGroup("General"); 623 conf.setGroup("General");
622 QStringList avail = conf.readListEntry("Custom Categories"); 624 QStringList avail = conf.readListEntry("Custom Categories");
623 for (QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) { 625 for (QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it ) {
624 if (!avail.contains( (*it) ) ) 626 if (!avail.contains( (*it) ) )
625 avail << (*it); 627 avail << (*it);
626 } 628 }
627 conf.writeEntry("Custom Categories", avail ); 629 conf.writeEntry("Custom Categories", avail );
628} 630}
629 631
630 632
631 633
632OpieCategories::OpieCategories() 634OpieCategories::OpieCategories()
633{ 635{
634 636
635} 637}
636OpieCategories::OpieCategories(const QString &id, const QString &name, const QString &app ) 638OpieCategories::OpieCategories(const QString &id, const QString &name, const QString &app )
637{ 639{
638 m_name = name; 640 m_name = name;
639 m_id = id; 641 m_id = id;
640 m_app = app; 642 m_app = app;
641} 643}
642OpieCategories::OpieCategories(const OpieCategories &op ) 644OpieCategories::OpieCategories(const OpieCategories &op )
643{ 645{
644 (*this) = op; 646 (*this) = op;
645} 647}
646QString OpieCategories::id() const 648QString OpieCategories::id() const
647{ 649{
648 return m_id; 650 return m_id;
649} 651}
650QString OpieCategories::name() const 652QString OpieCategories::name() const
651{ 653{
652 return m_name; 654 return m_name;
653} 655}
654QString OpieCategories::app() const 656QString OpieCategories::app() const
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
@@ -1,133 +1,136 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
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$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
@@ -1,327 +1,327 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
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#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_
59__declspec(dllexport) 59__declspec(dllexport)
60#else 60#else
61{ 61{
62#endif 62#endif
63 void *init_microkabc_qtopia() 63 void *init_microkabc_qtopia()
64 { 64 {
65 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); 65 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
66 } 66 }
67#ifndef _WIN32_ 67#ifndef _WIN32_
68} 68}
69#endif 69#endif
70 70
71ResourceQtopia::ResourceQtopia( const KConfig *config ) 71ResourceQtopia::ResourceQtopia( const KConfig *config )
72 : Resource( config ), mConverter (0) 72 : Resource( config ), mConverter (0)
73{ 73{
74 // we can not choose the filename. Therefore use the default to display 74 // we can not choose the filename. Therefore use the default to display
75 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 75 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
76 init( fileName ); 76 init( fileName );
77} 77}
78 78
79ResourceQtopia::ResourceQtopia( const QString &fileName ) 79ResourceQtopia::ResourceQtopia( const QString &fileName )
80 : Resource( 0 ) 80 : Resource( 0 )
81{ 81{
82 init( fileName ); 82 init( fileName );
83} 83}
84 84
85void ResourceQtopia::init( const QString &fileName ) 85void ResourceQtopia::init( const QString &fileName )
86{ 86{
87#ifdef _USE_DIRWATCH_ 87#ifdef _USE_DIRWATCH_
88 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 88 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
89 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 89 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
90 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 90 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
91#endif 91#endif
92 setFileName( fileName ); 92 setFileName( fileName );
93} 93}
94 94
95ResourceQtopia::~ResourceQtopia() 95ResourceQtopia::~ResourceQtopia()
96{ 96{
97 if (mConverter != 0) 97 if (mConverter != 0)
98 delete mConverter; 98 delete mConverter;
99 99
100} 100}
101 101
102void ResourceQtopia::writeConfig( KConfig *config ) 102void ResourceQtopia::writeConfig( KConfig *config )
103{ 103{
104 Resource::writeConfig( config ); 104 Resource::writeConfig( config );
105} 105}
106 106
107Ticket *ResourceQtopia::requestSaveTicket() 107Ticket *ResourceQtopia::requestSaveTicket()
108{ 108{
109 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; 109 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
110 110
111 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); 111 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1());
112 112
113 if ( !addressBook() ) return 0; 113 if ( !addressBook() ) return 0;
114 114
115 if ( !lock( fileName() ) ) { 115 if ( !lock( fileName() ) ) {
116 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" 116 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
117 << fileName() << "'" << endl; 117 << fileName() << "'" << endl;
118 return 0; 118 return 0;
119 } 119 }
120 return createTicket( this ); 120 return createTicket( this );
121} 121}
122 122
123 123
124bool ResourceQtopia::doOpen() 124bool ResourceQtopia::doOpen()
125{ 125{
126 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); 126 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
127 127
128 128
129 if (mConverter == 0) 129 if (mConverter == 0)
130 { 130 {
131 mConverter = new QtopiaConverter(); 131 mConverter = new QtopiaConverter();
132 bool res = mConverter->init(); 132 bool res = mConverter->init();
133 if ( !res ) 133 if ( !res )
134 { 134 {
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}
236 236
237bool ResourceQtopia::lock( const QString &lockfileName ) 237bool ResourceQtopia::lock( const QString &lockfileName )
238{ 238{
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
288 QString fn = fileName; 288 QString fn = fileName;
289 KURL url(fn); 289 KURL url(fn);
290 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 290 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
291 291
292 QFile::remove( lockName ); 292 QFile::remove( lockName );
293 QFile::remove( mLockUniqueName ); 293 QFile::remove( mLockUniqueName );
294 addressBook()->emitAddressBookUnlocked(); 294 addressBook()->emitAddressBookUnlocked();
295} 295}
296 296
297void ResourceQtopia::setFileName( const QString &newFileName ) 297void ResourceQtopia::setFileName( const QString &newFileName )
298{ 298{
299#ifdef _USE_DIRWATCH_ 299#ifdef _USE_DIRWATCH_
300 mDirWatch.stopScan(); 300 mDirWatch.stopScan();
301#endif 301#endif
302 mDirWatch.removeFile( fileName() ); 302 mDirWatch.removeFile( fileName() );
303 303
304 Resource::setFileName( newFileName ); 304 Resource::setFileName( newFileName );
305 305
306 mDirWatch.addFile( fileName() ); 306 mDirWatch.addFile( fileName() );
307#ifdef _USE_DIRWATCH_ 307#ifdef _USE_DIRWATCH_
308 mDirWatch.startScan(); 308 mDirWatch.startScan();
309#endif 309#endif
310} 310}
311 311
312 312
313void ResourceQtopia::fileChanged() 313void ResourceQtopia::fileChanged()
314{ 314{
315 // There is a small theoretical chance that KDirWatch calls us before 315 // There is a small theoretical chance that KDirWatch calls us before
316 // we are fully constructed 316 // we are fully constructed
317 if (!addressBook()) 317 if (!addressBook())
318 return; 318 return;
319 319
320 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); 320 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
321 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 321 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
322 load(); 322 load();
323 addressBook()->emitAddressBookChanged(); 323 addressBook()->emitAddressBookChanged();
324 } 324 }
325} 325}
326 326
327void ResourceQtopia::removeAddressee( const Addressee &addr ) 327void ResourceQtopia::removeAddressee( const Addressee &addr )
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
@@ -1,107 +1,109 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
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() );
74 if ( mFileNameEdit->url().isEmpty() ) 76 if ( mFileNameEdit->url().isEmpty() )
75 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); 77 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
76 78
77 //US Qtopia resources are ReadOnly by definition 79 //US Qtopia resources are ReadOnly by definition
78 emit setPersistentReadOnly( true ); 80 emit setPersistentReadOnly( true );
79 81
80 //US we can not choose the filename for the qtopia backend => make it readonly. 82 //US we can not choose the filename for the qtopia backend => make it readonly.
81 mFileNameEdit->setEnabled( false ); 83 mFileNameEdit->setEnabled( false );
82 84
83} 85}
84 86
85void ResourceQtopiaConfig::saveSettings( KRES::Resource *res ) 87void ResourceQtopiaConfig::saveSettings( KRES::Resource *res )
86{ 88{
87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 89//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
88 ResourceQtopia *resource = (ResourceQtopia*)( res ); 90 ResourceQtopia *resource = (ResourceQtopia*)( res );
89 91
90 if ( !resource ) { 92 if ( !resource ) {
91 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl; 93 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl;
92 return; 94 return;
93 } 95 }
94 96
95 resource->setFileName( mFileNameEdit->url() ); 97 resource->setFileName( mFileNameEdit->url() );
96} 98}
97 99
98void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName ) 100void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName )
99{ 101{
100 // If file exist but is not writeable... 102 // If file exist but is not writeable...
101/*US 103/*US
102 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) 104 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
103 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); 105 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
104*/ 106*/
105} 107}
106 108
107//US #include "resourceopieconfig.moc" 109//US #include "resourceopieconfig.moc"
diff --git a/kabc/plugins/sharpdtm/sharpdtmE.pro b/kabc/plugins/sharpdtm/sharpdtmE.pro
index 23b0b76..7fc8ba8 100644
--- a/kabc/plugins/sharpdtm/sharpdtmE.pro
+++ b/kabc/plugins/sharpdtm/sharpdtmE.pro
@@ -1,35 +1,35 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3TARGET = microkabc_sharpdtm 3TARGET = xmicrokabc_sharpdtm
4 4
5INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(SHARPDTMSDK)/include $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 5INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(SHARPDTMSDK)/include $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
6 6
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 += -lmicrokdepim 13LIBS += -lxmicrokdepim
14LIBS += -lmicroqtcompat 14LIBS += -lmicroqtcompat
15LIBS += -L$(QPEDIR)/lib 15LIBS += -L$(QPEDIR)/lib
16LIBS += -ljpeg 16LIBS += -ljpeg
17LIBS += -lqpe 17LIBS += -lqpe
18LIBS += -lqte 18LIBS += -lqte
19LIBS += -lzdtm 19LIBS += -lzdtm
20LIBS += -lsl 20LIBS += -lsl
21 21
22 22
23 23
24INTERFACES = \ 24INTERFACES = \
25 25
26HEADERS = \ 26HEADERS = \
27 resourcesharpdtm.h \ 27 resourcesharpdtm.h \
28 resourcesharpdtmconfig.h \ 28 resourcesharpdtmconfig.h \
29 sharpdtmconverter.h 29 sharpdtmconverter.h
30 30
31SOURCES = \ 31SOURCES = \
32 resourcesharpdtm.cpp \ 32 resourcesharpdtm.cpp \
33 resourcesharpdtmconfig.cpp \ 33 resourcesharpdtmconfig.cpp \
34 sharpdtmconverter.cpp 34 sharpdtmconverter.cpp
35 35