-rw-r--r-- | kabc/plugins/file/file.pro | 4 | ||||
-rw-r--r-- | kabc/plugins/file/fileE.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 14 |
3 files changed, 6 insertions, 14 deletions
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro index 7cf7c58..32555a2 100644 --- a/kabc/plugins/file/file.pro +++ b/kabc/plugins/file/file.pro | |||
@@ -1,35 +1,35 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | TARGET = microkabc_file | 5 | TARGET = microkabc_file |
6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat | 6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat |
7 | 7 | ||
8 | DESTDIR = ../../../bin | 8 | DESTDIR = ../../../bin |
9 | #LIBS += -lmicrokde -lmicrokabc | 9 | #LIBS += -lmicrokde -lmicrokabc |
10 | #LIBS += -L$(QPEDIR)/lib | 10 | #LIBS += -L$(QPEDIR)/lib |
11 | 11 | ||
12 | INTERFACES = \ | 12 | INTERFACES = \ |
13 | 13 | ||
14 | HEADERS = \ | 14 | HEADERS = \ |
15 | resourcefile.h \ | 15 | resourcefile.h \ |
16 | resourcefileconfig.h | 16 | resourcefileconfig.h |
17 | 17 | ||
18 | SOURCES = \ | 18 | SOURCES = \ |
19 | resourcefile.cpp \ | 19 | resourcefile.cpp \ |
20 | resourcefileconfig.cpp | 20 | resourcefileconfig.cpp |
21 | 21 | ||
22 | unix : { | 22 | unix : { |
23 | OBJECTS_DIR = obj/unix | 23 | OBJECTS_DIR = obj/unix |
24 | MOC_DIR = moc/unix | 24 | MOC_DIR = moc/unix |
25 | } | 25 | } |
26 | win32: { | 26 | win32: { |
27 | CONFIG += dll | 27 | CONFIG += dll |
28 | DEFINES += _WIN32_ | 28 | DEFINES += _WIN32_ |
29 | OBJECTS_DIR = obj/win | 29 | OBJECTS_DIR = obj/win |
30 | MOC_DIR = moc/win | 30 | MOC_DIR = moc/win |
31 | LIBS += ../../../bin/microkdepim.lib | 31 | LIBS += ../../../bin/microkdepim.lib |
32 | LIBS += ../../../bin/microkcal.lib | 32 | LIBS += ../../../bin/microkcal.lib |
33 | LIBS += ../../../bin/microkde.lib | 33 | LIBS += ../../../bin/microkde.lib |
34 | LIBS += ../../../bin/microkabc.lib | 34 | LIBS += ../../../bin/microkabc.lib |
35 | } \ No newline at end of file | 35 | } |
diff --git a/kabc/plugins/file/fileE.pro b/kabc/plugins/file/fileE.pro index 2d17a8f..d19a26d 100644 --- a/kabc/plugins/file/fileE.pro +++ b/kabc/plugins/file/fileE.pro | |||
@@ -1,21 +1,21 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | TARGET = microkabc_file | 5 | TARGET = microkabc_file |
6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat | 6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde -lmicrokabc | 10 | LIBS += -lmicrokde -lmicrokabc |
11 | LIBS += -L$(QPEDIR)/lib | 11 | LIBS += -L$(QPEDIR)/lib |
12 | 12 | ||
13 | INTERFACES = \ | 13 | INTERFACES = \ |
14 | 14 | ||
15 | HEADERS = \ | 15 | HEADERS = \ |
16 | resourcefile.h \ | 16 | resourcefile.h \ |
17 | resourcefileconfig.h | 17 | resourcefileconfig.h |
18 | 18 | ||
19 | SOURCES = \ | 19 | SOURCES = \ |
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 2d20706..9f9b00f 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -4,178 +4,172 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #ifndef _WIN32_ | 30 | #ifndef _WIN32_ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtimer.h> | 37 | #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 | 45 | ||
46 | #include "formatfactory.h" | 46 | #include "formatfactory.h" |
47 | 47 | ||
48 | #include "resource.h" | 48 | #include "resource.h" |
49 | #include "resourcefileconfig.h" | 49 | #include "resourcefileconfig.h" |
50 | #include "stdaddressbook.h" | 50 | #include "stdaddressbook.h" |
51 | 51 | ||
52 | //US #include "../../formats/vcardformatplugin2.h" | ||
53 | //US #include "../../formats/binaryformat.h" | ||
54 | |||
55 | |||
56 | #include "resourcefile.h" | 52 | #include "resourcefile.h" |
57 | 53 | ||
58 | using namespace KABC; | 54 | using namespace KABC; |
59 | 55 | ||
60 | extern "C" | 56 | extern "C" |
61 | #ifdef _WIN32_ | 57 | #ifdef _WIN32_ |
62 | __declspec(dllexport) | 58 | __declspec(dllexport) |
63 | #else | 59 | #else |
64 | { | 60 | { |
65 | #endif | 61 | #endif |
66 | 62 | ||
67 | //US void *init_kabc_file() | 63 | //US void *init_kabc_file() |
68 | void *init_microkabc_file() | 64 | void *init_microkabc_file() |
69 | { | 65 | { |
70 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); | 66 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); |
71 | } | 67 | } |
72 | #ifndef _WIN32_ | 68 | #ifndef _WIN32_ |
73 | } | 69 | } |
74 | #endif | 70 | #endif |
75 | 71 | ||
76 | ResourceFile::ResourceFile( const KConfig *config ) | 72 | ResourceFile::ResourceFile( const KConfig *config ) |
77 | : Resource( config ) , mFormat( 0 ) | 73 | : Resource( config ) , mFormat( 0 ) |
78 | { | 74 | { |
79 | QString fileName, formatName; | 75 | QString fileName, formatName; |
80 | 76 | ||
81 | KConfig *cfg = (KConfig *)config; | 77 | KConfig *cfg = (KConfig *)config; |
82 | if ( cfg ) { | 78 | if ( cfg ) { |
83 | fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); | 79 | fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); |
84 | formatName = cfg->readEntry( "FileFormat", "vcard" ); | 80 | formatName = cfg->readEntry( "FileFormat", "vcard" ); |
85 | // qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); | 81 | // qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); |
86 | } else { | 82 | } else { |
87 | fileName = StdAddressBook::fileName(); | 83 | fileName = StdAddressBook::fileName(); |
88 | formatName = "vcard"; | 84 | formatName = "vcard"; |
89 | // qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); | 85 | // qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); |
90 | } | 86 | } |
91 | 87 | ||
92 | init( fileName, formatName ); | 88 | init( fileName, formatName ); |
93 | } | 89 | } |
94 | 90 | ||
95 | ResourceFile::ResourceFile( const QString &fileName, | 91 | ResourceFile::ResourceFile( const QString &fileName, |
96 | const QString &formatName ) | 92 | const QString &formatName ) |
97 | : Resource( 0 ) | 93 | : Resource( 0 ) |
98 | { | 94 | { |
99 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 95 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
100 | init( fileName, formatName ); | 96 | init( fileName, formatName ); |
101 | } | 97 | } |
102 | 98 | ||
103 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 99 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
104 | { | 100 | { |
105 | mFormatName = formatName; | 101 | mFormatName = formatName; |
106 | 102 | ||
107 | FormatFactory *factory = FormatFactory::self(); | 103 | FormatFactory *factory = FormatFactory::self(); |
108 | mFormat = factory->format( mFormatName ); | 104 | mFormat = factory->format( mFormatName ); |
109 | 105 | ||
110 | if ( !mFormat ) { | 106 | if ( !mFormat ) { |
111 | mFormatName = "vcard"; | 107 | mFormatName = "vcard"; |
112 | mFormat = factory->format( mFormatName ); | 108 | mFormat = factory->format( mFormatName ); |
113 | } | 109 | } |
114 | 110 | ||
115 | /*US | 111 | /*US |
116 | //US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); | 112 | //US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); |
117 | if (mFormatName == "vcard") { | 113 | if (mFormatName == "vcard") { |
118 | mFormat = new VCardFormatPlugin2(); | 114 | mFormat = new VCardFormatPlugin2(); |
119 | // qDebug("ResourceFile::init format VCardFormatPlugin2"); | 115 | // qDebug("ResourceFile::init format VCardFormatPlugin2"); |
120 | } | 116 | } |
121 | else if (mFormatName == "binary") { | 117 | else if (mFormatName == "binary") { |
122 | mFormat = new BinaryFormat(); | 118 | mFormat = new BinaryFormat(); |
123 | // qDebug("ResourceFile::init format BinaryFormat"); | 119 | // qDebug("ResourceFile::init format BinaryFormat"); |
124 | } | 120 | } |
125 | else | 121 | else |
126 | qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); | 122 | qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); |
127 | */ | 123 | */ |
128 | 124 | ||
129 | /*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods | ||
130 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 125 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
131 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 126 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
132 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 127 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
133 | */ | ||
134 | 128 | ||
135 | setFileName( fileName ); | 129 | setFileName( fileName ); |
136 | } | 130 | } |
137 | 131 | ||
138 | ResourceFile::~ResourceFile() | 132 | ResourceFile::~ResourceFile() |
139 | { | 133 | { |
140 | delete mFormat; | 134 | delete mFormat; |
141 | mFormat = 0; | 135 | mFormat = 0; |
142 | } | 136 | } |
143 | 137 | ||
144 | void ResourceFile::writeConfig( KConfig *config ) | 138 | void ResourceFile::writeConfig( KConfig *config ) |
145 | { | 139 | { |
146 | 140 | ||
147 | config->setGroup( "Resource_" + identifier() ); | 141 | config->setGroup( "Resource_" + identifier() ); |
148 | Resource::writeConfig( config ); | 142 | Resource::writeConfig( config ); |
149 | 143 | ||
150 | config->writeEntry( "FileName", mFileName ); | 144 | config->writeEntry( "FileName", mFileName ); |
151 | config->writeEntry( "FileFormat", mFormatName ); | 145 | config->writeEntry( "FileFormat", mFormatName ); |
152 | 146 | ||
153 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 147 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
154 | 148 | ||
155 | } | 149 | } |
156 | 150 | ||
157 | Ticket *ResourceFile::requestSaveTicket() | 151 | Ticket *ResourceFile::requestSaveTicket() |
158 | { | 152 | { |
159 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; | 153 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; |
160 | 154 | ||
161 | if ( !addressBook() ) return 0; | 155 | if ( !addressBook() ) return 0; |
162 | 156 | ||
163 | if ( !lock( mFileName ) ) { | 157 | if ( !lock( mFileName ) ) { |
164 | kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" | 158 | kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" |
165 | << mFileName << "'" << endl; | 159 | << mFileName << "'" << endl; |
166 | return 0; | 160 | return 0; |
167 | } | 161 | } |
168 | return createTicket( this ); | 162 | return createTicket( this ); |
169 | } | 163 | } |
170 | 164 | ||
171 | 165 | ||
172 | bool ResourceFile::doOpen() | 166 | bool ResourceFile::doOpen() |
173 | { | 167 | { |
174 | QFile file( mFileName ); | 168 | QFile file( mFileName ); |
175 | 169 | ||
176 | if ( !file.exists() ) { | 170 | if ( !file.exists() ) { |
177 | // try to create the file | 171 | // try to create the file |
178 | bool ok = file.open( IO_WriteOnly ); | 172 | bool ok = file.open( IO_WriteOnly ); |
179 | if ( ok ) | 173 | if ( ok ) |
180 | file.close(); | 174 | file.close(); |
181 | 175 | ||
@@ -281,109 +275,107 @@ bool ResourceFile::lock( const QString &fileName ) | |||
281 | if (QFile::exists( lockName )) return false; | 275 | if (QFile::exists( lockName )) return false; |
282 | 276 | ||
283 | QString lockUniqueName; | 277 | QString lockUniqueName; |
284 | lockUniqueName = fn + KApplication::randomString( 8 ); | 278 | lockUniqueName = fn + KApplication::randomString( 8 ); |
285 | 279 | ||
286 | url = lockUniqueName; | 280 | url = lockUniqueName; |
287 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | 281 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); |
288 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | 282 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); |
289 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | 283 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; |
290 | 284 | ||
291 | // Create unique file | 285 | // Create unique file |
292 | QFile file( mLockUniqueName ); | 286 | QFile file( mLockUniqueName ); |
293 | file.open( IO_WriteOnly ); | 287 | file.open( IO_WriteOnly ); |
294 | file.close(); | 288 | file.close(); |
295 | 289 | ||
296 | // Create lock file | 290 | // Create lock file |
297 | int result = 0; | 291 | int result = 0; |
298 | #ifndef _WIN32_ | 292 | #ifndef _WIN32_ |
299 | result = ::link( QFile::encodeName( mLockUniqueName ), | 293 | result = ::link( QFile::encodeName( mLockUniqueName ), |
300 | QFile::encodeName( lockName ) ); | 294 | QFile::encodeName( lockName ) ); |
301 | #endif | 295 | #endif |
302 | if ( result == 0 ) { | 296 | if ( result == 0 ) { |
303 | addressBook()->emitAddressBookLocked(); | 297 | addressBook()->emitAddressBookLocked(); |
304 | return true; | 298 | return true; |
305 | } | 299 | } |
306 | 300 | ||
307 | // TODO: check stat | 301 | // TODO: check stat |
308 | 302 | ||
309 | return false; | 303 | return false; |
310 | } | 304 | } |
311 | 305 | ||
312 | void ResourceFile::unlock( const QString &fileName ) | 306 | void ResourceFile::unlock( const QString &fileName ) |
313 | { | 307 | { |
314 | QString fn = fileName; | 308 | QString fn = fileName; |
315 | //US change the implementation how the lockfilename is getting created | 309 | //US change the implementation how the lockfilename is getting created |
316 | //US fn.replace( QRegExp( "/" ), "_" ); | 310 | //US fn.replace( QRegExp( "/" ), "_" ); |
317 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | 311 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); |
318 | //US QString lockName = fn + ".lock"; | 312 | //US QString lockName = fn + ".lock"; |
319 | KURL url(fn); | 313 | KURL url(fn); |
320 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 314 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
321 | 315 | ||
322 | QFile::remove( lockName ); | 316 | QFile::remove( lockName ); |
323 | QFile::remove( mLockUniqueName ); | 317 | QFile::remove( mLockUniqueName ); |
324 | addressBook()->emitAddressBookUnlocked(); | 318 | addressBook()->emitAddressBookUnlocked(); |
325 | } | 319 | } |
326 | 320 | ||
327 | void ResourceFile::setFileName( const QString &fileName ) | 321 | void ResourceFile::setFileName( const QString &fileName ) |
328 | { | 322 | { |
329 | /*US ToDo: no synchronization so far. Has to be changed in the future | ||
330 | mDirWatch.stopScan(); | 323 | mDirWatch.stopScan(); |
331 | mDirWatch.removeFile( mFileName ); | 324 | mDirWatch.removeFile( mFileName ); |
332 | */ | 325 | |
333 | mFileName = fileName; | 326 | mFileName = fileName; |
334 | 327 | ||
335 | 328 | ||
336 | /*US ToDo: no synchronization so far. Has to be changed in the future | ||
337 | mDirWatch.addFile( mFileName ); | 329 | mDirWatch.addFile( mFileName ); |
338 | mDirWatch.startScan(); | 330 | mDirWatch.startScan(); |
339 | */ | 331 | |
340 | //US simulate KDirWatch event | 332 | //US simulate KDirWatch event |
341 | fileChanged(); | 333 | //US fileChanged(); |
342 | } | 334 | } |
343 | 335 | ||
344 | QString ResourceFile::fileName() const | 336 | QString ResourceFile::fileName() const |
345 | { | 337 | { |
346 | return mFileName; | 338 | return mFileName; |
347 | } | 339 | } |
348 | 340 | ||
349 | void ResourceFile::setFormat( const QString &format ) | 341 | void ResourceFile::setFormat( const QString &format ) |
350 | { | 342 | { |
351 | mFormatName = format; | 343 | mFormatName = format; |
352 | delete mFormat; | 344 | delete mFormat; |
353 | 345 | ||
354 | FormatFactory *factory = FormatFactory::self(); | 346 | FormatFactory *factory = FormatFactory::self(); |
355 | mFormat = factory->format( mFormatName ); | 347 | mFormat = factory->format( mFormatName ); |
356 | /*US | 348 | /*US |
357 | //qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); | 349 | //qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); |
358 | if (mFormatName == "vcard") { | 350 | if (mFormatName == "vcard") { |
359 | mFormat = new VCardFormatPlugin2(); | 351 | mFormat = new VCardFormatPlugin2(); |
360 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); | 352 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); |
361 | } | 353 | } |
362 | else if (mFormatName == "binary") { | 354 | else if (mFormatName == "binary") { |
363 | mFormat = new BinaryFormat(); | 355 | mFormat = new BinaryFormat(); |
364 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); | 356 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); |
365 | } | 357 | } |
366 | else | 358 | else |
367 | qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1()); | 359 | qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1()); |
368 | */ | 360 | */ |
369 | 361 | ||
370 | } | 362 | } |
371 | 363 | ||
372 | QString ResourceFile::format() const | 364 | QString ResourceFile::format() const |
373 | { | 365 | { |
374 | return mFormatName; | 366 | return mFormatName; |
375 | } | 367 | } |
376 | 368 | ||
377 | void ResourceFile::fileChanged() | 369 | void ResourceFile::fileChanged() |
378 | { | 370 | { |
379 | // There is a small theoretical chance that KDirWatch calls us before | 371 | // There is a small theoretical chance that KDirWatch calls us before |
380 | // we are fully constructed | 372 | // we are fully constructed |
381 | if (!addressBook()) | 373 | if (!addressBook()) |
382 | return; | 374 | return; |
383 | load(); | 375 | load(); |
384 | addressBook()->emitAddressBookChanged(); | 376 | addressBook()->emitAddressBookChanged(); |
385 | } | 377 | } |
386 | 378 | ||
387 | void ResourceFile::removeAddressee( const Addressee &addr ) | 379 | void ResourceFile::removeAddressee( const Addressee &addr ) |
388 | { | 380 | { |
389 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); | 381 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); |