-rw-r--r-- | kabc/plugins/dir/dir.pro | 14 | ||||
-rw-r--r-- | kabc/plugins/dir/dirE.pro | 4 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 8 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedirconfig.cpp | 4 |
4 files changed, 18 insertions, 12 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 |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | include( ../../../variables.pri ) | 5 | include( ../../../variables.pri ) |
6 | 6 | ||
7 | TARGET = microkabc_dir | 7 | TARGET = xmicrokabc_dir |
8 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat | 8 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat |
9 | DESTDIR = ../../../bin | 9 | DESTDIR = ../../../bin |
10 | #LIBS += -lmicrokde -lmicrokabc | 10 | #LIBS += -lxmicrokde -lxmicrokabc |
11 | #LIBS += -L$(QPEDIR)/lib | 11 | #LIBS += -L$(QPEDIR)/lib |
12 | 12 | ||
13 | INTERFACES = \ | 13 | INTERFACES = \ |
14 | 14 | ||
15 | HEADERS = \ | 15 | HEADERS = \ |
16 | resourcedir.h \ | 16 | resourcedir.h \ |
17 | resourcedirconfig.h | 17 | resourcedirconfig.h |
18 | 18 | ||
19 | SOURCES = \ | 19 | SOURCES = \ |
20 | resourcedir.cpp \ | 20 | resourcedir.cpp \ |
21 | resourcedirconfig.cpp | 21 | resourcedirconfig.cpp |
22 | 22 | ||
23 | unix : { | 23 | unix : { |
24 | OBJECTS_DIR = obj/unix | 24 | OBJECTS_DIR = obj/unix |
25 | MOC_DIR = moc/unix | 25 | MOC_DIR = moc/unix |
26 | } | 26 | } |
27 | win32: { | 27 | win32: { |
28 | CONFIG += dll | 28 | CONFIG += dll |
29 | DEFINES += _WIN32_ | 29 | DEFINES += _WIN32_ |
30 | OBJECTS_DIR = obj/win | 30 | OBJECTS_DIR = obj/win |
31 | MOC_DIR = moc/win | 31 | MOC_DIR = moc/win |
32 | LIBS += ../../../bin/microkdepim.lib | 32 | LIBS += ../../../bin/xmicrokdepim.lib |
33 | LIBS += ../../../bin/microkcal.lib | 33 | LIBS += ../../../bin/xmicrokcal.lib |
34 | LIBS += ../../../bin/microkde.lib | 34 | LIBS += ../../../bin/xmicrokde.lib |
35 | LIBS += ../../../bin/microkabc.lib | 35 | LIBS += ../../../bin/microkabc.lib |
36 | } | 36 | } |
37 | #The following line was inserted by qt3to4 | ||
38 | QT += qt3support | ||
39 | #The following line was inserted by qt3to4 | ||
40 | QT += 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 |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | TARGET = microkabc_dir | 5 | TARGET = xmicrokabc_dir |
6 | INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat | 6 | INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/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 += -lxmicrokde -lxmicrokabc |
11 | LIBS += -L$(QPEDIR)/lib | 11 | LIBS += -L$(QPEDIR)/lib |
12 | 12 | ||
13 | INTERFACES = \ | 13 | INTERFACES = \ |
14 | 14 | ||
15 | HEADERS = \ | 15 | HEADERS = \ |
16 | resourcedir.h \ | 16 | resourcedir.h \ |
17 | resourcedirconfig.h | 17 | resourcedirconfig.h |
18 | 18 | ||
19 | SOURCES = \ | 19 | SOURCES = \ |
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 | |||
@@ -157,86 +157,86 @@ Ticket *ResourceDir::requestSaveTicket() | |||
157 | return createTicket( this ); | 157 | return createTicket( this ); |
158 | 158 | ||
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | bool ResourceDir::doOpen() | 162 | bool 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 | ||
185 | void ResourceDir::doClose() | 185 | void ResourceDir::doClose() |
186 | { | 186 | { |
187 | } | 187 | } |
188 | 188 | ||
189 | bool ResourceDir::load() | 189 | bool 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 | ||
214 | bool ResourceDir::save( Ticket *ticket ) | 214 | bool 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 |
@@ -254,33 +254,33 @@ bool ResourceDir::lock( const QString &path ) | |||
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; |
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 | |||
@@ -14,50 +14,52 @@ | |||
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 <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 | ||
42 | using namespace KABC; | 44 | using namespace KABC; |
43 | 45 | ||
44 | ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name ) | 46 | ResourceDirConfig::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 |