summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/kabc.pro4
-rw-r--r--kabc/plugins/dir/dir.pro29
-rw-r--r--kabc/plugins/dir/resourcedir.cpp6
-rw-r--r--kabc/plugins/file/file.pro30
-rw-r--r--kabc/plugins/file/resourcefile.cpp6
5 files changed, 69 insertions, 6 deletions
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index ea4bbb7..4a8d73a 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -1,214 +1,214 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3#release debug 3#release debug
4DESTDIR=../bin 4DESTDIR=../bin
5 5
6TARGET = microkabc 6TARGET = microkabc
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../qtcompat ../microkde/kdeui 10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../qtcompat ../microkde/kdeui
11 11
12#LIBS += -lmicrokde -lldap 12#LIBS += -lmicrokde -lldap
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14DEFINES += KAB_EMBEDDED DESKTOP_VERSION 14DEFINES += KAB_EMBEDDED DESKTOP_VERSION
15unix : { 15unix : {
16 16
17OBJECTS_DIR = obj/unix 17OBJECTS_DIR = obj/unix
18MOC_DIR = moc/unix 18MOC_DIR = moc/unix
19} 19}
20win32: { 20win32: {
21DEFINES += _WIN32_ 21DEFINES += _WIN32_
22OBJECTS_DIR = obj/win 22OBJECTS_DIR = obj/win
23MOC_DIR = moc/win 23MOC_DIR = moc/win
24} 24}
25INTERFACES = \ 25INTERFACES = \
26 26
27 27
28HEADERS = \ 28HEADERS = \
29 resource.h \ 29 resource.h \
30 stdaddressbook.h \ 30 stdaddressbook.h \
31 agent.h \ 31 agent.h \
32 geo.h \ 32 geo.h \
33 key.h \ 33 key.h \
34 field.h \ 34 field.h \
35 plugin.h \ 35 plugin.h \
36 address.h \ 36 address.h \
37 addresseelist.h \ 37 addresseelist.h \
38formatfactory.h \ 38formatfactory.h \
39 formatplugin.h \ 39 formatplugin.h \
40 phonenumber.h \ 40 phonenumber.h \
41distributionlist.h \ 41distributionlist.h \
42distributionlistdialog.h \ 42distributionlistdialog.h \
43distributionlisteditor.h \ 43distributionlisteditor.h \
44vcardformatplugin.h \ 44vcardformatplugin.h \
45formats/binaryformat.h \
46formats/vcardformatplugin2.h \ 45formats/vcardformatplugin2.h \
47 picture.h \ 46 picture.h \
48 secrecy.h \ 47 secrecy.h \
49 sound.h \ 48 sound.h \
50 addressbook.h \ 49 addressbook.h \
51 timezone.h \ 50 timezone.h \
52 addressee.h \ 51 addressee.h \
53 addresseedialog.h \ 52 addresseedialog.h \
54 vcardconverter.h \ 53 vcardconverter.h \
55 vcard21parser.h \ 54 vcard21parser.h \
56 vcardformatimpl.h \ 55 vcardformatimpl.h \
57 plugins/file/resourcefile.h \ 56 plugins/file/resourcefile.h \
58 plugins/file/resourcefileconfig.h \ 57 plugins/file/resourcefileconfig.h \
59 plugins/dir/resourcedir.h \ 58 plugins/dir/resourcedir.h \
60 plugins/dir/resourcedirconfig.h \ 59 plugins/dir/resourcedirconfig.h \
61 vcardparser/vcardline.h \ 60 vcardparser/vcardline.h \
62 vcardparser/vcard.h \ 61 vcardparser/vcard.h \
63 vcardparser/vcardtool.h \ 62 vcardparser/vcardtool.h \
64 vcardparser/vcardparser.h \ 63 vcardparser/vcardparser.h \
65vcard/include/VCardAdrParam.h \ 64vcard/include/VCardAdrParam.h \
66vcard/include/VCardAdrValue.h \ 65vcard/include/VCardAdrValue.h \
67vcard/include/VCardAgentParam.h \ 66vcard/include/VCardAgentParam.h \
68vcard/include/VCardContentLine.h \ 67vcard/include/VCardContentLine.h \
69vcard/include/VCardDateParam.h \ 68vcard/include/VCardDateParam.h \
70vcard/include/VCardDateValue.h \ 69vcard/include/VCardDateValue.h \
71vcard/include/VCardEmailParam.h \ 70vcard/include/VCardEmailParam.h \
72vcard/include/VCardGeoValue.h \ 71vcard/include/VCardGeoValue.h \
73vcard/include/VCardGroup.h \ 72vcard/include/VCardGroup.h \
74vcard/include/VCardImageParam.h \ 73vcard/include/VCardImageParam.h \
75vcard/include/VCardImageValue.h \ 74vcard/include/VCardImageValue.h \
76vcard/include/VCardLangValue.h \ 75vcard/include/VCardLangValue.h \
77vcard/include/VCardNValue.h \ 76vcard/include/VCardNValue.h \
78vcard/include/VCardParam.h \ 77vcard/include/VCardParam.h \
79vcard/include/VCardPhoneNumberValue.h \ 78vcard/include/VCardPhoneNumberValue.h \
80vcard/include/VCardSourceParam.h \ 79vcard/include/VCardSourceParam.h \
81vcard/include/VCardTelParam.h \ 80vcard/include/VCardTelParam.h \
82vcard/include/VCardTextParam.h \ 81vcard/include/VCardTextParam.h \
83vcard/include/VCardTextNSParam.h \ 82vcard/include/VCardTextNSParam.h \
84vcard/include/VCardTextValue.h \ 83vcard/include/VCardTextValue.h \
85vcard/include/VCardTextBinParam.h \ 84vcard/include/VCardTextBinParam.h \
86vcard/include/VCardURIValue.h \ 85vcard/include/VCardURIValue.h \
87vcard/include/VCardVCard.h \ 86vcard/include/VCardVCard.h \
88vcard/include/VCardEntity.h \ 87vcard/include/VCardEntity.h \
89vcard/include/VCardValue.h \ 88vcard/include/VCardValue.h \
90vcard/include/VCardSoundValue.h \ 89vcard/include/VCardSoundValue.h \
91vcard/include/VCardAgentValue.h \ 90vcard/include/VCardAgentValue.h \
92vcard/include/VCardTelValue.h \ 91vcard/include/VCardTelValue.h \
93vcard/include/VCardTextBinValue.h \ 92vcard/include/VCardTextBinValue.h \
94vcard/include/VCardOrgValue.h \ 93vcard/include/VCardOrgValue.h \
95vcard/include/VCardUTCValue.h \ 94vcard/include/VCardUTCValue.h \
96vcard/include/VCardClassValue.h \ 95vcard/include/VCardClassValue.h \
97vcard/include/VCardFloatValue.h \ 96vcard/include/VCardFloatValue.h \
98vcard/include/VCardTextListValue.h \ 97vcard/include/VCardTextListValue.h \
99vcard/include/generated/AdrParam-generated.h \ 98vcard/include/generated/AdrParam-generated.h \
100vcard/include/generated/AdrValue-generated.h \ 99vcard/include/generated/AdrValue-generated.h \
101vcard/include/generated/AgentParam-generated.h \ 100vcard/include/generated/AgentParam-generated.h \
102vcard/include/generated/ContentLine-generated.h \ 101vcard/include/generated/ContentLine-generated.h \
103vcard/include/generated/DateParam-generated.h \ 102vcard/include/generated/DateParam-generated.h \
104vcard/include/generated/DateValue-generated.h \ 103vcard/include/generated/DateValue-generated.h \
105vcard/include/generated/EmailParam-generated.h \ 104vcard/include/generated/EmailParam-generated.h \
106vcard/include/generated/GeoValue-generated.h \ 105vcard/include/generated/GeoValue-generated.h \
107vcard/include/generated/Group-generated.h \ 106vcard/include/generated/Group-generated.h \
108vcard/include/generated/ImageParam-generated.h \ 107vcard/include/generated/ImageParam-generated.h \
109vcard/include/generated/ImageValue-generated.h \ 108vcard/include/generated/ImageValue-generated.h \
110vcard/include/generated/LangValue-generated.h \ 109vcard/include/generated/LangValue-generated.h \
111vcard/include/generated/NValue-generated.h \ 110vcard/include/generated/NValue-generated.h \
112vcard/include/generated/Param-generated.h \ 111vcard/include/generated/Param-generated.h \
113vcard/include/generated/PhoneNumberValue-generated.h \ 112vcard/include/generated/PhoneNumberValue-generated.h \
114vcard/include/generated/SourceParam-generated.h \ 113vcard/include/generated/SourceParam-generated.h \
115vcard/include/generated/TelParam-generated.h \ 114vcard/include/generated/TelParam-generated.h \
116vcard/include/generated/TextParam-generated.h \ 115vcard/include/generated/TextParam-generated.h \
117vcard/include/generated/TextNSParam-generated.h \ 116vcard/include/generated/TextNSParam-generated.h \
118vcard/include/generated/TextValue-generated.h \ 117vcard/include/generated/TextValue-generated.h \
119vcard/include/generated/TextBinParam-generated.h \ 118vcard/include/generated/TextBinParam-generated.h \
120vcard/include/generated/URIValue-generated.h \ 119vcard/include/generated/URIValue-generated.h \
121vcard/include/generated/VCard-generated.h \ 120vcard/include/generated/VCard-generated.h \
122vcard/include/generated/VCardEntity-generated.h \ 121vcard/include/generated/VCardEntity-generated.h \
123vcard/include/generated/Value-generated.h \ 122vcard/include/generated/Value-generated.h \
124vcard/include/generated/SoundValue-generated.h \ 123vcard/include/generated/SoundValue-generated.h \
125vcard/include/generated/AgentValue-generated.h \ 124vcard/include/generated/AgentValue-generated.h \
126vcard/include/generated/TelValue-generated.h \ 125vcard/include/generated/TelValue-generated.h \
127vcard/include/generated/TextBinValue-generated.h \ 126vcard/include/generated/TextBinValue-generated.h \
128vcard/include/generated/OrgValue-generated.h \ 127vcard/include/generated/OrgValue-generated.h \
129vcard/include/generated/UTCValue-generated.h \ 128vcard/include/generated/UTCValue-generated.h \
130vcard/include/generated/ClassValue-generated.h \ 129vcard/include/generated/ClassValue-generated.h \
131vcard/include/generated/FloatValue-generated.h \ 130vcard/include/generated/FloatValue-generated.h \
132vcard/include/generated/TextListValue-generated.h 131vcard/include/generated/TextListValue-generated.h
133 132
134 133
135# plugins/ldap/resourceldap.h \ 134# plugins/ldap/resourceldap.h \
136# plugins/ldap/resourceldapconfig.h \ 135# plugins/ldap/resourceldapconfig.h \
136#formats/binary/binaryformat.h \
137 137
138 138
139SOURCES = \ 139SOURCES = \
140distributionlist.cpp \ 140distributionlist.cpp \
141distributionlistdialog.cpp \ 141distributionlistdialog.cpp \
142distributionlisteditor.cpp \ 142distributionlisteditor.cpp \
143vcardformatplugin.cpp \ 143vcardformatplugin.cpp \
144formats/binaryformat.cpp \
145formats/vcardformatplugin2.cpp \ 144formats/vcardformatplugin2.cpp \
146formatfactory.cpp \ 145formatfactory.cpp \
147 resource.cpp \ 146 resource.cpp \
148 stdaddressbook.cpp \ 147 stdaddressbook.cpp \
149 plugin.cpp \ 148 plugin.cpp \
150 agent.cpp \ 149 agent.cpp \
151 geo.cpp \ 150 geo.cpp \
152 key.cpp \ 151 key.cpp \
153 field.cpp \ 152 field.cpp \
154 address.cpp \ 153 address.cpp \
155 phonenumber.cpp \ 154 phonenumber.cpp \
156 picture.cpp \ 155 picture.cpp \
157 secrecy.cpp \ 156 secrecy.cpp \
158 sound.cpp \ 157 sound.cpp \
159 addressbook.cpp \ 158 addressbook.cpp \
160 timezone.cpp \ 159 timezone.cpp \
161 addressee.cpp \ 160 addressee.cpp \
162 addresseelist.cpp \ 161 addresseelist.cpp \
163 addresseedialog.cpp \ 162 addresseedialog.cpp \
164 vcardconverter.cpp \ 163 vcardconverter.cpp \
165 vcard21parser.cpp \ 164 vcard21parser.cpp \
166 vcardformatimpl.cpp \ 165 vcardformatimpl.cpp \
167 plugins/file/resourcefile.cpp \ 166 plugins/file/resourcefile.cpp \
168 plugins/file/resourcefileconfig.cpp \ 167 plugins/file/resourcefileconfig.cpp \
169 plugins/dir/resourcedir.cpp \ 168 plugins/dir/resourcedir.cpp \
170 plugins/dir/resourcedirconfig.cpp \ 169 plugins/dir/resourcedirconfig.cpp \
171 vcardparser/vcardline.cpp \ 170 vcardparser/vcardline.cpp \
172 vcardparser/vcard.cpp \ 171 vcardparser/vcard.cpp \
173 vcardparser/vcardtool.cpp \ 172 vcardparser/vcardtool.cpp \
174 vcardparser/vcardparser.cpp \ 173 vcardparser/vcardparser.cpp \
175vcard/AdrParam.cpp \ 174vcard/AdrParam.cpp \
176vcard/AdrValue.cpp \ 175vcard/AdrValue.cpp \
177vcard/AgentParam.cpp \ 176vcard/AgentParam.cpp \
178vcard/ContentLine.cpp \ 177vcard/ContentLine.cpp \
179vcard/DateParam.cpp \ 178vcard/DateParam.cpp \
180vcard/DateValue.cpp \ 179vcard/DateValue.cpp \
181vcard/EmailParam.cpp \ 180vcard/EmailParam.cpp \
182vcard/Entity.cpp \ 181vcard/Entity.cpp \
183vcard/Enum.cpp \ 182vcard/Enum.cpp \
184vcard/GeoValue.cpp \ 183vcard/GeoValue.cpp \
185vcard/ImageParam.cpp \ 184vcard/ImageParam.cpp \
186vcard/ImageValue.cpp \ 185vcard/ImageValue.cpp \
187vcard/LangValue.cpp \ 186vcard/LangValue.cpp \
188vcard/NValue.cpp \ 187vcard/NValue.cpp \
189vcard/Param.cpp \ 188vcard/Param.cpp \
190vcard/PhoneNumberValue.cpp \ 189vcard/PhoneNumberValue.cpp \
191vcard/RToken.cpp \ 190vcard/RToken.cpp \
192vcard/SourceParam.cpp \ 191vcard/SourceParam.cpp \
193vcard/TelParam.cpp \ 192vcard/TelParam.cpp \
194vcard/TextParam.cpp \ 193vcard/TextParam.cpp \
195vcard/TextValue.cpp \ 194vcard/TextValue.cpp \
196vcard/TextBinParam.cpp \ 195vcard/TextBinParam.cpp \
197vcard/URIValue.cpp \ 196vcard/URIValue.cpp \
198vcard/VCardv.cpp \ 197vcard/VCardv.cpp \
199vcard/VCardEntity.cpp \ 198vcard/VCardEntity.cpp \
200vcard/Value.cpp \ 199vcard/Value.cpp \
201vcard/SoundValue.cpp \ 200vcard/SoundValue.cpp \
202vcard/AgentValue.cpp \ 201vcard/AgentValue.cpp \
203vcard/TelValue.cpp \ 202vcard/TelValue.cpp \
204vcard/TextBinValue.cpp \ 203vcard/TextBinValue.cpp \
205vcard/OrgValue.cpp \ 204vcard/OrgValue.cpp \
206vcard/UTCValue.cpp \ 205vcard/UTCValue.cpp \
207vcard/ClassValue.cpp \ 206vcard/ClassValue.cpp \
208vcard/FloatValue.cpp \ 207vcard/FloatValue.cpp \
209vcard/TextListValue.cpp 208vcard/TextListValue.cpp
210 209
211 210
212# plugins/ldap/resourceldap.cpp \ 211# plugins/ldap/resourceldap.cpp \
213# plugins/ldap/resourceldapconfig.cpp \ 212# plugins/ldap/resourceldapconfig.cpp \
214 213
214#formats/binary/binaryformat.cpp \
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro
new file mode 100644
index 0000000..3db201f
--- a/dev/null
+++ b/kabc/plugins/dir/dir.pro
@@ -0,0 +1,29 @@
1 TEMPLATE= lib
2CONFIG += qt warn_on release
3#release debug
4
5TARGET = microkabc_dir
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
7DESTDIR = ../../../bin
8#LIBS += -lmicrokde -lmicrokabc
9#LIBS += -L$(QPEDIR)/lib
10
11INTERFACES = \
12
13HEADERS = \
14 resourcedir.h \
15 resourcedirconfig.h
16
17SOURCES = \
18 resourcedir.cpp \
19 resourcedirconfig.cpp
20
21unix : {
22OBJECTS_DIR = obj/unix
23MOC_DIR = moc/unix
24}
25win32: {
26DEFINES += _WIN32_
27OBJECTS_DIR = obj/win
28MOC_DIR = moc/win
29} \ No newline at end of file
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index be19821..6ea2f4b 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -215,99 +215,101 @@ bool ResourceDir::save( Ticket *ticket )
215 continue; 215 continue;
216 } 216 }
217 217
218 mFormat->save( *it, &file ); 218 mFormat->save( *it, &file );
219 219
220 // mark as unchanged 220 // mark as unchanged
221 (*it).setChanged( false ); 221 (*it).setChanged( false );
222 222
223 file.close(); 223 file.close();
224 } 224 }
225 225
226 delete ticket; 226 delete ticket;
227 unlock( mPath ); 227 unlock( mPath );
228 228
229 return ok; 229 return ok;
230} 230}
231 231
232bool ResourceDir::lock( const QString &path ) 232bool ResourceDir::lock( const QString &path )
233{ 233{
234 kdDebug(5700) << "ResourceDir::lock()" << endl; 234 kdDebug(5700) << "ResourceDir::lock()" << endl;
235 235
236 QString p = path; 236 QString p = path;
237//US change the implementation how the lockfilename is getting created 237//US change the implementation how the lockfilename is getting created
238//US p.replace( QRegExp("/"), "_" ); 238//US p.replace( QRegExp("/"), "_" );
239//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); 239//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" );
240 KURL url(p); 240 KURL url(p);
241 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 241 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
242 242
243 243
244 kdDebug(5700) << "-- lock name: " << lockName << endl; 244 kdDebug(5700) << "-- lock name: " << lockName << endl;
245 245
246 if ( QFile::exists( lockName ) ) return false; 246 if ( QFile::exists( lockName ) ) return false;
247 247
248 QString lockUniqueName; 248 QString lockUniqueName;
249 lockUniqueName = p + KApplication::randomString( 8 ); 249 lockUniqueName = p + KApplication::randomString( 8 );
250 250
251 url = lockUniqueName; 251 url = lockUniqueName;
252//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 252//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
253 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 253 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
254 254
255 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 255 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
256 256
257 // Create unique file 257 // Create unique file
258 QFile file( mLockUniqueName ); 258 QFile file( mLockUniqueName );
259 file.open( IO_WriteOnly ); 259 file.open( IO_WriteOnly );
260 file.close(); 260 file.close();
261 261
262 // Create lock file 262 // Create lock file
263 int result = ::link( QFile::encodeName( mLockUniqueName ), 263 int result = 0;
264#ifndef _WIN32_
265 result = ::link( QFile::encodeName( mLockUniqueName ),
264 QFile::encodeName( lockName ) ); 266 QFile::encodeName( lockName ) );
265 267#endif
266 if ( result == 0 ) { 268 if ( result == 0 ) {
267 addressBook()->emitAddressBookLocked(); 269 addressBook()->emitAddressBookLocked();
268 return true; 270 return true;
269 } 271 }
270 272
271 // TODO: check stat 273 // TODO: check stat
272 274
273 return false; 275 return false;
274} 276}
275 277
276void ResourceDir::unlock( const QString &path ) 278void ResourceDir::unlock( const QString &path )
277{ 279{
278 QString p = path; 280 QString p = path;
279//US change the implementation how the lockfilename is getting created 281//US change the implementation how the lockfilename is getting created
280//US p.replace( QRegExp( "/" ), "_" ); 282//US p.replace( QRegExp( "/" ), "_" );
281//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); 283//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
282 KURL url(p); 284 KURL url(p);
283 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); 285 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
284 286
285 ::unlink( QFile::encodeName( lockName ) ); 287 ::unlink( QFile::encodeName( lockName ) );
286 QFile::remove( mLockUniqueName ); 288 QFile::remove( mLockUniqueName );
287 addressBook()->emitAddressBookUnlocked(); 289 addressBook()->emitAddressBookUnlocked();
288} 290}
289 291
290void ResourceDir::setPath( const QString &path ) 292void ResourceDir::setPath( const QString &path )
291{ 293{
292/*US ToDo: no synchronization so far. Has to be changed in the future 294/*US ToDo: no synchronization so far. Has to be changed in the future
293 mDirWatch.stopScan(); 295 mDirWatch.stopScan();
294 mDirWatch.removeDir( mPath ); 296 mDirWatch.removeDir( mPath );
295*/ 297*/
296 mPath = path; 298 mPath = path;
297 299
298/*US ToDo: no synchronization so far. Has to be changed in the future 300/*US ToDo: no synchronization so far. Has to be changed in the future
299 mDirWatch.addDir( mPath, true ); 301 mDirWatch.addDir( mPath, true );
300 mDirWatch.startScan(); 302 mDirWatch.startScan();
301*/ 303*/
302 304
303//US simulate KDirWatch event 305//US simulate KDirWatch event
304 pathChanged(); 306 pathChanged();
305 307
306} 308}
307 309
308QString ResourceDir::path() const 310QString ResourceDir::path() const
309{ 311{
310 return mPath; 312 return mPath;
311} 313}
312 314
313void ResourceDir::setFormat( const QString &format ) 315void ResourceDir::setFormat( const QString &format )
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
new file mode 100644
index 0000000..a5ade93
--- a/dev/null
+++ b/kabc/plugins/file/file.pro
@@ -0,0 +1,30 @@
1 TEMPLATE= lib
2CONFIG += qt warn_on release
3#release debug
4
5TARGET = microkabc_file
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
7
8DESTDIR = ../../../bin
9#LIBS += -lmicrokde -lmicrokabc
10#LIBS += -L$(QPEDIR)/lib
11
12INTERFACES = \
13
14HEADERS = \
15 resourcefile.h \
16 resourcefileconfig.h
17
18SOURCES = \
19 resourcefile.cpp \
20 resourcefileconfig.cpp
21
22unix : {
23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix
25}
26win32: {
27DEFINES += _WIN32_
28OBJECTS_DIR = obj/win
29MOC_DIR = moc/win
30} \ No newline at end of file
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 3920f69..4b4c935 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -241,99 +241,101 @@ bool ResourceFile::save( Ticket *ticket )
241 } 241 }
242 else { 242 else {
243 243
244 } 244 }
245 245
246 if ( !ok ) 246 if ( !ok )
247 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 247 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
248 248
249 delete ticket; 249 delete ticket;
250 unlock( mFileName ); 250 unlock( mFileName );
251 251
252 return ok; 252 return ok;
253 253
254 qDebug("ResourceFile::save has to be changed"); 254 qDebug("ResourceFile::save has to be changed");
255 return true; 255 return true;
256} 256}
257 257
258bool ResourceFile::lock( const QString &fileName ) 258bool ResourceFile::lock( const QString &fileName )
259{ 259{
260 260
261 261
262 QString fn = fileName; 262 QString fn = fileName;
263 263
264//US change the implementation how the lockfilename is getting created 264//US change the implementation how the lockfilename is getting created
265//US fn.replace( QRegExp("/"), "_" ); 265//US fn.replace( QRegExp("/"), "_" );
266//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 266//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
267 267
268 KURL url(fn); 268 KURL url(fn);
269 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 269 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
270 270
271 271
272 272
273 if (QFile::exists( lockName )) return false; 273 if (QFile::exists( lockName )) return false;
274 274
275 QString lockUniqueName; 275 QString lockUniqueName;
276 lockUniqueName = fn + KApplication::randomString( 8 ); 276 lockUniqueName = fn + KApplication::randomString( 8 );
277 277
278 url = lockUniqueName; 278 url = lockUniqueName;
279//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 279//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
280 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 280 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
281 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 281 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
282 282
283 // Create unique file 283 // Create unique file
284 QFile file( mLockUniqueName ); 284 QFile file( mLockUniqueName );
285 file.open( IO_WriteOnly ); 285 file.open( IO_WriteOnly );
286 file.close(); 286 file.close();
287 287
288 // Create lock file 288 // Create lock file
289 int result = ::link( QFile::encodeName( mLockUniqueName ), 289 int result = 0;
290#ifndef _WIN32_
291 result = ::link( QFile::encodeName( mLockUniqueName ),
290 QFile::encodeName( lockName ) ); 292 QFile::encodeName( lockName ) );
291 293#endif
292 if ( result == 0 ) { 294 if ( result == 0 ) {
293 addressBook()->emitAddressBookLocked(); 295 addressBook()->emitAddressBookLocked();
294 return true; 296 return true;
295 } 297 }
296 298
297 // TODO: check stat 299 // TODO: check stat
298 300
299 return false; 301 return false;
300} 302}
301 303
302void ResourceFile::unlock( const QString &fileName ) 304void ResourceFile::unlock( const QString &fileName )
303{ 305{
304 QString fn = fileName; 306 QString fn = fileName;
305//US change the implementation how the lockfilename is getting created 307//US change the implementation how the lockfilename is getting created
306//US fn.replace( QRegExp( "/" ), "_" ); 308//US fn.replace( QRegExp( "/" ), "_" );
307//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 309//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
308//US QString lockName = fn + ".lock"; 310//US QString lockName = fn + ".lock";
309 KURL url(fn); 311 KURL url(fn);
310 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 312 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
311 313
312 QFile::remove( lockName ); 314 QFile::remove( lockName );
313 QFile::remove( mLockUniqueName ); 315 QFile::remove( mLockUniqueName );
314 addressBook()->emitAddressBookUnlocked(); 316 addressBook()->emitAddressBookUnlocked();
315} 317}
316 318
317void ResourceFile::setFileName( const QString &fileName ) 319void ResourceFile::setFileName( const QString &fileName )
318{ 320{
319/*US ToDo: no synchronization so far. Has to be changed in the future 321/*US ToDo: no synchronization so far. Has to be changed in the future
320 mDirWatch.stopScan(); 322 mDirWatch.stopScan();
321 mDirWatch.removeFile( mFileName ); 323 mDirWatch.removeFile( mFileName );
322*/ 324*/
323 mFileName = fileName; 325 mFileName = fileName;
324 326
325 327
326/*US ToDo: no synchronization so far. Has to be changed in the future 328/*US ToDo: no synchronization so far. Has to be changed in the future
327 mDirWatch.addFile( mFileName ); 329 mDirWatch.addFile( mFileName );
328 mDirWatch.startScan(); 330 mDirWatch.startScan();
329*/ 331*/
330//US simulate KDirWatch event 332//US simulate KDirWatch event
331 fileChanged(); 333 fileChanged();
332} 334}
333 335
334QString ResourceFile::fileName() const 336QString ResourceFile::fileName() const
335{ 337{
336 return mFileName; 338 return mFileName;
337} 339}
338 340
339void ResourceFile::setFormat( const QString &format ) 341void ResourceFile::setFormat( const QString &format )