summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp2
-rw-r--r--kaddressbook/xxport/qtopia_xxport.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index cf6b11a..79ddaea 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -1,336 +1,336 @@
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 <qtextstream.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(IO_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 true; 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( IO_WriteOnly ) ) {
207 return false; 207 return false;
208 } 208 }
209 QTextStream ts( &file ); 209 QTextStream ts( &file );
210 QTextStream *stream = &ts; 210 QTextStream *stream = &ts;
211 stream->setEncoding( QTextStream::UnicodeUTF8 ); 211 stream->setEncoding( QTextStream::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( IO_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 )
328{ 328{
329} 329}
330 330
331void ResourceQtopia::cleanUp() 331void ResourceQtopia::cleanUp()
332{ 332{
333 unlock( fileName() ); 333 unlock( fileName() );
334} 334}
335 335
336//US #include "resourceqtopia.moc" 336//US #include "resourceqtopia.moc"
diff --git a/kaddressbook/xxport/qtopia_xxport.cpp b/kaddressbook/xxport/qtopia_xxport.cpp
index fc4abbb..e3457a1 100644
--- a/kaddressbook/xxport/qtopia_xxport.cpp
+++ b/kaddressbook/xxport/qtopia_xxport.cpp
@@ -1,86 +1,86 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qdir.h> 31#include <qdir.h>
32 32
33#include "addressee.h" 33#include "addressee.h"
34#include "xxportmanager.h" 34#include "xxportmanager.h"
35#include "qtopia_xxport.h" 35#include "qtopia_xxport.h"
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37 37
38/*US 38/*US
39class QtopiaXXPortFactory : public XXPortFactory 39class QtopiaXXPortFactory : public XXPortFactory
40{ 40{
41 public: 41 public:
42 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 42 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
43 { 43 {
44 return new QtopiaXXPort( ab, parent, name ); 44 return new QtopiaXXPort( ab, parent, name );
45 } 45 }
46}; 46};
47*/ 47*/
48 48
49extern "C" 49extern "C"
50{ 50{
51 void *init_microkaddrbk_qtopia_xxport() 51 void *init_microkaddrbk_qtopia_xxport()
52 { 52 {
53 return ( new QtopiaXXPortFactory() ); 53 return ( new QtopiaXXPortFactory() );
54 } 54 }
55} 55}
56 56
57 57
58 58
59QtopiaXXPort::QtopiaXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 59QtopiaXXPort::QtopiaXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
60 : XXPortResourceObject( ab, parent, name ) 60 : XXPortResourceObject( ab, parent, name )
61{ 61{
62 defaultFileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 62 defaultFileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
63 63
64 if ( mFactory && !mFactory->typeName( "qtopia" ).isEmpty() ) 64 if ( mFactory && !mFactory->typeName( "qtopia" ).isEmpty() )
65 { 65 {
66 createImportAction( i18n( "Import xml (Qtopia)..." ) ); 66 createImportAction( i18n( "Import xml (Qtopia)..." ) );
67 createExportAction( i18n( "Export xml (Qtopia)..." ) ); 67 createExportAction( i18n( "Export xml (Qtopia)..." ) );
68 } 68 }
69} 69}
70 70
71bool QtopiaXXPort::exportContacts( const KABC::AddresseeList &list, const QString &identifier ) 71bool QtopiaXXPort::exportContacts( const KABC::AddresseeList &list, const QString &identifier )
72{ 72{
73 QString fn =KFileDialog::getSaveFileName( defaultFileName, i18n("Import xml file"), 0 ); 73 QString fn =KFileDialog::getSaveFileName( defaultFileName, i18n("Import xml file"), 0 );
74 if ( fn == "" ) 74 if ( fn == "" )
75 return false; 75 return false;
76 76
77 return _exportContacts( list, identifier, fn ); 77 return _exportContacts( list, identifier, fn );
78} 78}
79 79
80KABC::AddresseeList QtopiaXXPort::importContacts( const QString &identifier ) const 80KABC::AddresseeList QtopiaXXPort::importContacts( const QString &identifier ) const
81{ 81{
82 QString fn =KFileDialog::getOpenFileName( defaultFileName, i18n("Import xml file"), 0 ); 82 QString fn =KFileDialog::getOpenFileName( defaultFileName, i18n("Import xml file"), 0 );
83 if ( fn == "" ) 83 if ( fn == "" )
84 return KABC::AddresseeList() ; 84 return KABC::AddresseeList() ;
85 return _importContacts( identifier, fn ); 85 return _importContacts( identifier, fn );
86} 86}