summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-23 17:33:10 (UTC)
committer zautrix <zautrix>2004-10-23 17:33:10 (UTC)
commit52b6fc17c0dcd1f13f701f698e0305440f26fc3e (patch) (unidiff)
treeb8d374e16c322f413e5809e55c45b8798190791d
parent13d274c37baaae48a1c93081077cf3035459c6a8 (diff)
downloadkdepimpi-52b6fc17c0dcd1f13f701f698e0305440f26fc3e.zip
kdepimpi-52b6fc17c0dcd1f13f701f698e0305440f26fc3e.tar.gz
kdepimpi-52b6fc17c0dcd1f13f701f698e0305440f26fc3e.tar.bz2
qtopia res windows fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopia.pro4
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp9
-rw-r--r--kabc/plugins/qtopia/resourceqtopiaconfig.cpp2
3 files changed, 13 insertions, 2 deletions
diff --git a/kabc/plugins/qtopia/qtopia.pro b/kabc/plugins/qtopia/qtopia.pro
index 6efb678..0360abf 100644
--- a/kabc/plugins/qtopia/qtopia.pro
+++ b/kabc/plugins/qtopia/qtopia.pro
@@ -1,37 +1,41 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 3
4TARGET = microkabc_qtopia 4TARGET = microkabc_qtopia
5 5
6INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources 6INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources
7 7
8DESTDIR = ../../../bin 8DESTDIR = ../../../bin
9#LIBS += -lmicrokde 9#LIBS += -lmicrokde
10#LIBS += -lkamicrokabc 10#LIBS += -lkamicrokabc
11 11
12DEFINES += KAB_EMBEDDED DESKTOP_VERSION 12DEFINES += KAB_EMBEDDED DESKTOP_VERSION
13 13
14INTERFACES = \ 14INTERFACES = \
15 15
16HEADERS = \ 16HEADERS = \
17 resourceqtopia.h \ 17 resourceqtopia.h \
18 resourceqtopiaconfig.h \ 18 resourceqtopiaconfig.h \
19 qtopiaconverter.h 19 qtopiaconverter.h
20 20
21SOURCES = \ 21SOURCES = \
22 resourceqtopia.cpp \ 22 resourceqtopia.cpp \
23 resourceqtopiaconfig.cpp \ 23 resourceqtopiaconfig.cpp \
24 qtopiaconverter.cpp 24 qtopiaconverter.cpp
25 25
26 26
27 27
28unix : { 28unix : {
29OBJECTS_DIR = obj/unix 29OBJECTS_DIR = obj/unix
30MOC_DIR = moc/unix 30MOC_DIR = moc/unix
31} 31}
32win32: { 32win32: {
33CONFIG += dll 33CONFIG += dll
34DEFINES += _WIN32_ 34DEFINES += _WIN32_
35OBJECTS_DIR = obj/win 35OBJECTS_DIR = obj/win
36MOC_DIR = moc/win 36MOC_DIR = moc/win
37LIBS += ../../../bin/microkdepim.lib
38LIBS += ../../../bin/microkcal.lib
39LIBS += ../../../bin/microkde.lib
40LIBS += ../../../bin/microkabc.lib
37} 41}
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 95fa541..99e8618 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -1,328 +1,335 @@
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#include <unistd.h> 29//#include <unistd.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qregexp.h> 35#include <qregexp.h>
36//US #include <qtimer.h> 36//US #include <qtimer.h>
37 37
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <klocale.h> 41#include <klocale.h>
42//US #include <ksavefile.h> 42//US #include <ksavefile.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46 46
47#include "resourceqtopiaconfig.h" 47#include "resourceqtopiaconfig.h"
48#include "stdaddressbook.h" 48#include "stdaddressbook.h"
49 49
50#include "qtopiaconverter.h" 50#include "qtopiaconverter.h"
51 51
52#include "resourceqtopia.h" 52#include "resourceqtopia.h"
53 53
54using namespace KABC; 54using namespace KABC;
55
55extern "C" 56extern "C"
57#ifdef _WIN32_
58__declspec(dllexport)
59#else
56{ 60{
61#endif
57 void *init_microkabc_qtopia() 62 void *init_microkabc_qtopia()
58 { 63 {
59 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); 64 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
60 } 65 }
66#ifndef _WIN32_
61} 67}
68#endif
62 69
63ResourceQtopia::ResourceQtopia( const KConfig *config ) 70ResourceQtopia::ResourceQtopia( const KConfig *config )
64 : Resource( config ), mConverter (0) 71 : Resource( config ), mConverter (0)
65{ 72{
66 // we can not choose the filename. Therefore use the default to display 73 // we can not choose the filename. Therefore use the default to display
67 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 74 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
68 init( fileName ); 75 init( fileName );
69} 76}
70 77
71ResourceQtopia::ResourceQtopia( const QString &fileName ) 78ResourceQtopia::ResourceQtopia( const QString &fileName )
72 : Resource( 0 ) 79 : Resource( 0 )
73{ 80{
74 init( fileName ); 81 init( fileName );
75} 82}
76 83
77void ResourceQtopia::init( const QString &fileName ) 84void ResourceQtopia::init( const QString &fileName )
78{ 85{
79#ifdef _USE_DIRWATCH_ 86#ifdef _USE_DIRWATCH_
80 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 87 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
81 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 88 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
82 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 89 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
83#endif 90#endif
84 setFileName( fileName ); 91 setFileName( fileName );
85} 92}
86 93
87ResourceQtopia::~ResourceQtopia() 94ResourceQtopia::~ResourceQtopia()
88{ 95{
89 if (mConverter != 0) 96 if (mConverter != 0)
90 delete mConverter; 97 delete mConverter;
91 98
92} 99}
93 100
94void ResourceQtopia::writeConfig( KConfig *config ) 101void ResourceQtopia::writeConfig( KConfig *config )
95{ 102{
96 Resource::writeConfig( config ); 103 Resource::writeConfig( config );
97} 104}
98 105
99Ticket *ResourceQtopia::requestSaveTicket() 106Ticket *ResourceQtopia::requestSaveTicket()
100{ 107{
101 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; 108 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
102 109
103 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); 110 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1());
104 111
105 if ( !addressBook() ) return 0; 112 if ( !addressBook() ) return 0;
106 113
107 if ( !lock( fileName() ) ) { 114 if ( !lock( fileName() ) ) {
108 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" 115 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
109 << fileName() << "'" << endl; 116 << fileName() << "'" << endl;
110 return 0; 117 return 0;
111 } 118 }
112 return createTicket( this ); 119 return createTicket( this );
113} 120}
114 121
115 122
116bool ResourceQtopia::doOpen() 123bool ResourceQtopia::doOpen()
117{ 124{
118 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); 125 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
119 126
120 127
121 if (mConverter == 0) 128 if (mConverter == 0)
122 { 129 {
123 mConverter = new QtopiaConverter(); 130 mConverter = new QtopiaConverter();
124 bool res = mConverter->init(); 131 bool res = mConverter->init();
125 if ( !res ) 132 if ( !res )
126 { 133 {
127 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); 134 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
128 qDebug(msg); 135 qDebug(msg);
129 return false; 136 return false;
130 } 137 }
131 } 138 }
132 139
133 return true; 140 return true;
134} 141}
135 142
136void ResourceQtopia::doClose() 143void ResourceQtopia::doClose()
137{ 144{
138 qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); 145 qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
139 146
140 147
141 // it seems so, that deletion of access deletes backend as well 148 // it seems so, that deletion of access deletes backend as well
142 //delete backend; 149 //delete backend;
143 150
144 return; 151 return;
145} 152}
146 153
147bool ResourceQtopia::load() 154bool ResourceQtopia::load()
148{ 155{
149 156
150 QFile file( fileName() ); 157 QFile file( fileName() );
151 if ( !file.open(IO_ReadOnly ) ) { 158 if ( !file.open(IO_ReadOnly ) ) {
152 return false; 159 return false;
153 } 160 }
154 161
155 QDomDocument doc("mydocument" ); 162 QDomDocument doc("mydocument" );
156 if ( !doc.setContent( &file ) ) { 163 if ( !doc.setContent( &file ) ) {
157 file.close(); 164 file.close();
158 return false; 165 return false;
159 } 166 }
160 bool res; 167 bool res;
161 QDomElement docElem = doc.documentElement( ); 168 QDomElement docElem = doc.documentElement( );
162 QDomNode n = docElem.firstChild(); 169 QDomNode n = docElem.firstChild();
163 while ( !n.isNull() ) { 170 while ( !n.isNull() ) {
164 QDomElement e = n.toElement(); 171 QDomElement e = n.toElement();
165 if ( !e.isNull() ) { 172 if ( !e.isNull() ) {
166 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { 173 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) {
167 QDomNode no = e.firstChild(); 174 QDomNode no = e.firstChild();
168 while ( !no.isNull() ) { 175 while ( !no.isNull() ) {
169 QDomElement el = no.toElement(); 176 QDomElement el = no.toElement();
170 if ( !el.isNull() ) { 177 if ( !el.isNull() ) {
171 KABC::Addressee addressee; 178 KABC::Addressee addressee;
172 res = mConverter->qtopiaToAddressee( el, addressee ); 179 res = mConverter->qtopiaToAddressee( el, addressee );
173 if ( !addressee.isEmpty() && res ) 180 if ( !addressee.isEmpty() && res )
174 { 181 {
175 addressee.setResource( this ); 182 addressee.setResource( this );
176 addressBook()->insertAddressee( addressee ); 183 addressBook()->insertAddressee( addressee );
177 } 184 }
178 } 185 }
179 186
180 no = no.nextSibling(); 187 no = no.nextSibling();
181 } 188 }
182 } 189 }
183 } 190 }
184 191
185 n = n.nextSibling(); 192 n = n.nextSibling();
186 } 193 }
187 return true; 194 return true;
188} 195}
189 196
190bool ResourceQtopia::save( Ticket *ticket ) 197bool ResourceQtopia::save( Ticket *ticket )
191{ 198{
192#ifdef _USE_DIRWATCH_ 199#ifdef _USE_DIRWATCH_
193 mDirWatch.stopScan(); 200 mDirWatch.stopScan();
194#endif 201#endif
195 KABC::AddressBook::Iterator it; 202 KABC::AddressBook::Iterator it;
196 bool res; 203 bool res;
197 QFile file( fileName() ); 204 QFile file( fileName() );
198 if (!file.open( IO_WriteOnly ) ) { 205 if (!file.open( IO_WriteOnly ) ) {
199 return false; 206 return false;
200 } 207 }
201 QTextStream ts( &file ); 208 QTextStream ts( &file );
202 QTextStream *stream = &ts; 209 QTextStream *stream = &ts;
203 stream->setEncoding( QTextStream::UnicodeUTF8 ); 210 stream->setEncoding( QTextStream::UnicodeUTF8 );
204 *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl; 211 *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl;
205 *stream << " <Groups>" << endl; 212 *stream << " <Groups>" << endl;
206 *stream << " </Groups>" << endl; 213 *stream << " </Groups>" << endl;
207 *stream << " <Contacts> " << endl; 214 *stream << " <Contacts> " << endl;
208 // for all entries 215 // for all entries
209 KABC::Addressee ab; 216 KABC::Addressee ab;
210 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 217 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
211 KABC::Addressee addressee = (*it); 218 KABC::Addressee addressee = (*it);
212 res = mConverter->addresseeToQtopia( addressee, stream ); 219 res = mConverter->addresseeToQtopia( addressee, stream );
213 if (!res == true) 220 if (!res == true)
214 { 221 {
215 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 222 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
216 } 223 }
217 } 224 }
218 *stream << "</Contacts>" << endl; 225 *stream << "</Contacts>" << endl;
219 *stream << "</AddressBook>" << endl; 226 *stream << "</AddressBook>" << endl;
220 file.close(); 227 file.close();
221#ifdef _USE_DIRWATCH_ 228#ifdef _USE_DIRWATCH_
222 mDirWatch.startScan(); 229 mDirWatch.startScan();
223#endif 230#endif
224 delete ticket; 231 delete ticket;
225 unlock( fileName() ); 232 unlock( fileName() );
226 return true; 233 return true;
227} 234}
228 235
229bool ResourceQtopia::lock( const QString &lockfileName ) 236bool ResourceQtopia::lock( const QString &lockfileName )
230{ 237{
231 //disabled 238 //disabled
232 return true; 239 return true;
233 qDebug("ResourceQtopia::lock: %s", fileName().latin1()); 240 qDebug("ResourceQtopia::lock: %s", fileName().latin1());
234 QString fn = lockfileName; 241 QString fn = lockfileName;
235 242
236 KURL url(fn); 243 KURL url(fn);
237 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 244 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
238 245
239 if (QFile::exists( lockName )) 246 if (QFile::exists( lockName ))
240 { 247 {
241 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); 248 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1());
242 return false; 249 return false;
243 } 250 }
244 251
245 QString lockUniqueName; 252 QString lockUniqueName;
246 lockUniqueName = fn + KApplication::randomString( 8 ); 253 lockUniqueName = fn + KApplication::randomString( 8 );
247 254
248 url = lockUniqueName; 255 url = lockUniqueName;
249//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 256//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
250 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 257 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
251 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 258 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
252 259
253 // Create unique file 260 // Create unique file
254 QFile file( mLockUniqueName ); 261 QFile file( mLockUniqueName );
255 file.open( IO_WriteOnly ); 262 file.open( IO_WriteOnly );
256 file.close(); 263 file.close();
257 264
258 // Create lock file 265 // Create lock file
259 int result = 0; 266 int result = 0;
260#ifndef _WIN32_ 267#ifndef _WIN32_
261 result = ::link( QFile::encodeName( mLockUniqueName ), 268 result = ::link( QFile::encodeName( mLockUniqueName ),
262 QFile::encodeName( lockName ) ); 269 QFile::encodeName( lockName ) );
263#endif 270#endif
264 if ( result == 0 ) { 271 if ( result == 0 ) {
265 addressBook()->emitAddressBookLocked(); 272 addressBook()->emitAddressBookLocked();
266 return true; 273 return true;
267 } 274 }
268 275
269 // TODO: check stat 276 // TODO: check stat
270 277
271 return false; 278 return false;
272} 279}
273 280
274void ResourceQtopia::unlock( const QString &fileName ) 281void ResourceQtopia::unlock( const QString &fileName )
275{ 282{
276 //disabled 283 //disabled
277 return; 284 return;
278 qDebug("ResourceQtopia::unlock() %s", fileName.latin1()); 285 qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
279 286
280 QString fn = fileName; 287 QString fn = fileName;
281 KURL url(fn); 288 KURL url(fn);
282 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 289 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
283 290
284 QFile::remove( lockName ); 291 QFile::remove( lockName );
285 QFile::remove( mLockUniqueName ); 292 QFile::remove( mLockUniqueName );
286 addressBook()->emitAddressBookUnlocked(); 293 addressBook()->emitAddressBookUnlocked();
287} 294}
288 295
289void ResourceQtopia::setFileName( const QString &newFileName ) 296void ResourceQtopia::setFileName( const QString &newFileName )
290{ 297{
291#ifdef _USE_DIRWATCH_ 298#ifdef _USE_DIRWATCH_
292 mDirWatch.stopScan(); 299 mDirWatch.stopScan();
293#endif 300#endif
294 mDirWatch.removeFile( fileName() ); 301 mDirWatch.removeFile( fileName() );
295 302
296 Resource::setFileName( newFileName ); 303 Resource::setFileName( newFileName );
297 304
298 mDirWatch.addFile( fileName() ); 305 mDirWatch.addFile( fileName() );
299#ifdef _USE_DIRWATCH_ 306#ifdef _USE_DIRWATCH_
300 mDirWatch.startScan(); 307 mDirWatch.startScan();
301#endif 308#endif
302} 309}
303 310
304 311
305void ResourceQtopia::fileChanged() 312void ResourceQtopia::fileChanged()
306{ 313{
307 // There is a small theoretical chance that KDirWatch calls us before 314 // There is a small theoretical chance that KDirWatch calls us before
308 // we are fully constructed 315 // we are fully constructed
309 if (!addressBook()) 316 if (!addressBook())
310 return; 317 return;
311 318
312 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); 319 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
313 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 320 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
314 load(); 321 load();
315 addressBook()->emitAddressBookChanged(); 322 addressBook()->emitAddressBookChanged();
316 } 323 }
317} 324}
318 325
319void ResourceQtopia::removeAddressee( const Addressee &addr ) 326void ResourceQtopia::removeAddressee( const Addressee &addr )
320{ 327{
321} 328}
322 329
323void ResourceQtopia::cleanUp() 330void ResourceQtopia::cleanUp()
324{ 331{
325 unlock( fileName() ); 332 unlock( fileName() );
326} 333}
327 334
328//US #include "resourceqtopia.moc" 335//US #include "resourceqtopia.moc"
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
index 0505d0b..d5d6141 100644
--- a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
+++ b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
@@ -1,107 +1,107 @@
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 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <kstandarddirs.h> 33#include <kstandarddirs.h>
34#include <kdialog.h> 34#include <kdialog.h>
35 35
36#include <unistd.h> 36//#include <unistd.h>
37 37
38#include <qdir.h> 38#include <qdir.h>
39#include <qfile.h> 39#include <qfile.h>
40#include "resourceqtopia.h" 40#include "resourceqtopia.h"
41 41
42#include "resourceqtopiaconfig.h" 42#include "resourceqtopiaconfig.h"
43 43
44using namespace KABC; 44using namespace KABC;
45 45
46ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name ) 46ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name )
47 : ConfigWidget( parent, name ) 47 : ConfigWidget( parent, name )
48{ 48{
49 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 49 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
50 KDialog::spacingHint() ); 50 KDialog::spacingHint() );
51 51
52 QLabel *label = new QLabel( i18n( "Location:" ), this ); 52 QLabel *label = new QLabel( i18n( "Location:" ), this );
53 mFileNameEdit = new KURLRequester( this ); 53 mFileNameEdit = new KURLRequester( this );
54 54
55 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 55 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
56 SLOT( checkFilePermissions( const QString & ) ) ); 56 SLOT( checkFilePermissions( const QString & ) ) );
57 57
58 mainLayout->addWidget( label, 0, 0 ); 58 mainLayout->addWidget( label, 0, 0 );
59 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 59 mainLayout->addWidget( mFileNameEdit, 0, 1 );
60 60
61} 61}
62 62
63void ResourceQtopiaConfig::loadSettings( KRES::Resource *res ) 63void ResourceQtopiaConfig::loadSettings( KRES::Resource *res )
64{ 64{
65//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 65//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
66 ResourceQtopia *resource = (ResourceQtopia*)( res ); 66 ResourceQtopia *resource = (ResourceQtopia*)( res );
67 67
68 if ( !resource ) { 68 if ( !resource ) {
69 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl; 69 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl;
70 return; 70 return;
71 } 71 }
72 72
73 mFileNameEdit->setURL( resource->fileName() ); 73 mFileNameEdit->setURL( resource->fileName() );
74 if ( mFileNameEdit->url().isEmpty() ) 74 if ( mFileNameEdit->url().isEmpty() )
75 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); 75 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
76 76
77 //US Qtopia resources are ReadOnly by definition 77 //US Qtopia resources are ReadOnly by definition
78 emit setPersistentReadOnly( true ); 78 emit setPersistentReadOnly( true );
79 79
80 //US we can not choose the filename for the qtopia backend => make it readonly. 80 //US we can not choose the filename for the qtopia backend => make it readonly.
81 mFileNameEdit->setEnabled( false ); 81 mFileNameEdit->setEnabled( false );
82 82
83} 83}
84 84
85void ResourceQtopiaConfig::saveSettings( KRES::Resource *res ) 85void ResourceQtopiaConfig::saveSettings( KRES::Resource *res )
86{ 86{
87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
88 ResourceQtopia *resource = (ResourceQtopia*)( res ); 88 ResourceQtopia *resource = (ResourceQtopia*)( res );
89 89
90 if ( !resource ) { 90 if ( !resource ) {
91 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl; 91 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl;
92 return; 92 return;
93 } 93 }
94 94
95 resource->setFileName( mFileNameEdit->url() ); 95 resource->setFileName( mFileNameEdit->url() );
96} 96}
97 97
98void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName ) 98void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName )
99{ 99{
100 // If file exist but is not writeable... 100 // If file exist but is not writeable...
101/*US 101/*US
102 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) 102 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
103 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); 103 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
104*/ 104*/
105} 105}
106 106
107//US #include "resourceopieconfig.moc" 107//US #include "resourceopieconfig.moc"