summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia
authorulf69 <ulf69>2004-07-14 18:42:43 (UTC)
committer ulf69 <ulf69>2004-07-14 18:42:43 (UTC)
commitb371433c634ad75d5a66cd876e062888f1b3c761 (patch) (unidiff)
tree614c319c5e752a7884b8a761cdc80541809c7584 /kabc/plugins/qtopia
parent7868ec2225272318048026a602b842b38a05347f (diff)
downloadkdepimpi-b371433c634ad75d5a66cd876e062888f1b3c761.zip
kdepimpi-b371433c634ad75d5a66cd876e062888f1b3c761.tar.gz
kdepimpi-b371433c634ad75d5a66cd876e062888f1b3c761.tar.bz2
implemented qtopia support
Diffstat (limited to 'kabc/plugins/qtopia') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro18
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp179
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h20
-rw-r--r--kabc/plugins/qtopia/resourceqtopiaconfig.cpp27
-rw-r--r--kabc/plugins/qtopia/resourceqtopiaconfig.h4
5 files changed, 92 insertions, 156 deletions
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index d945c31..d9fa87f 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -2,7 +2,6 @@ TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3#release debug
4TARGET = microkabc_qtopia
5 3
6INCLUDEPATH += ../.. ../../converter/opie ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include 4TARGET = microkabc_qtopia
7 5
6INCLUDEPATH += ../.. ../../converter/qtopia ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include
8 7
@@ -14,9 +13,5 @@ LIBS += -lmicrokabc
14LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
15LIBS += -L$(OPIEDIR)/lib 14LIBS += -lqpepim
16LIBS += -lopie
17LIBS += -lqpe 15LIBS += -lqpe
18LIBS += -lqte 16LIBS += -lmicrokabc_qtopiaconverter
19LIBS += -lmicrokabc_opieconverter
20#LIBS += -L../../lib/$(PLATFORM)
21
22 17
@@ -26,3 +21,3 @@ HEADERS = \
26 resourceqtopia.h \ 21 resourceqtopia.h \
27 resourceqtopiaconfig.h \ 22 resourceqtopiaconfig.h
28 23
@@ -30,3 +25,2 @@ SOURCES = \
30 resourceqtopia.cpp \ 25 resourceqtopia.cpp \
31 resourceqtopiaconfig.cpp \ 26 resourceqtopiaconfig.cpp
32
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 3d9d28b..4854197 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -26,3 +26,2 @@ $Id$
26*/ 26*/
27
28#include <sys/types.h> 27#include <sys/types.h>
@@ -35,3 +34,3 @@ $Id$
35#include <qregexp.h> 34#include <qregexp.h>
36#include <qtimer.h> 35//US #include <qtimer.h>
37 36
@@ -44,9 +43,5 @@ $Id$
44 43
45//US #include "formatfactory.h" 44#include <qpe/pim/addressbookaccess.h>
46//US #include <qpe/qpeapplication.h>
47 45
48#include <opie/ocontactaccess.h>
49#include <opie/ocontactaccessbackend_xml.h>
50 46
51#include "resource.h"
52#include "resourceqtopiaconfig.h" 47#include "resourceqtopiaconfig.h"
@@ -54,3 +49,3 @@ $Id$
54 49
55#include "opieconverter.h" 50#include "qtopiaconverter.h"
56 51
@@ -63,3 +58,3 @@ extern "C"
63 { 58 {
64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); 59 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
65 } 60 }
@@ -67,14 +62,7 @@ extern "C"
67 62
68ResourceOpie::ResourceOpie( const KConfig *config ) 63ResourceQtopia::ResourceQtopia( const KConfig *config )
69 : Resource( config ), mConverter (0) 64 : Resource( config ), mConverter (0)
70{ 65{
66 // we can not choose the filename. Therefore use the default to display
71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 67 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
72
73 KConfig *cfg = (KConfig *)config;
74 if ( cfg ) {
75 fileName = cfg->readEntry( "FileName", fileName );
76
77 }
78
79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
80 68
@@ -83,6 +71,6 @@ ResourceOpie::ResourceOpie( const KConfig *config )
83 71
84ResourceOpie::ResourceOpie( const QString &fileName ) 72ResourceQtopia::ResourceQtopia( const QString &fileName )
85 : Resource( 0 ) 73 : Resource( 0 )
86{ 74{
87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); 75// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
88 init( fileName ); 76 init( fileName );
@@ -90,6 +78,5 @@ ResourceOpie::ResourceOpie( const QString &fileName )
90 78
91void ResourceOpie::init( const QString &fileName ) 79void ResourceQtopia::init( const QString &fileName )
92{ 80{
93 81
94/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
95 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 82 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
@@ -97,11 +84,7 @@ void ResourceOpie::init( const QString &fileName )
97 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 84 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
98*/
99 //US opie addressbook is always readonly
100//US setReadOnly( true );
101 85
102 setFileName( fileName ); 86 setFileName( fileName );
103
104} 87}
105 88
106ResourceOpie::~ResourceOpie() 89ResourceQtopia::~ResourceQtopia()
107{ 90{
@@ -109,20 +92,13 @@ ResourceOpie::~ResourceOpie()
109 delete mConverter; 92 delete mConverter;
93
110} 94}
111 95
112void ResourceOpie::writeConfig( KConfig *config ) 96void ResourceQtopia::writeConfig( KConfig *config )
113{ 97{
114 //US opie addressbook is always readonly
115//US setReadOnly( true );
116
117 Resource::writeConfig( config ); 98 Resource::writeConfig( config );
118
119 config->writeEntry( "FileName", mFileName );
120
121// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
122
123} 99}
124 100
125Ticket *ResourceOpie::requestSaveTicket() 101Ticket *ResourceQtopia::requestSaveTicket()
126{ 102{
127 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; 103 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
128 104
@@ -131,3 +107,3 @@ Ticket *ResourceOpie::requestSaveTicket()
131 if ( !lock( mFileName ) ) { 107 if ( !lock( mFileName ) ) {
132 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" 108 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
133 << mFileName << "'" << endl; 109 << mFileName << "'" << endl;
@@ -139,6 +115,5 @@ Ticket *ResourceOpie::requestSaveTicket()
139 115
140bool ResourceOpie::doOpen() 116bool ResourceQtopia::doOpen()
141{ 117{
142// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1()); 118/*US
143/*US
144 QFile file( mFileName ); 119 QFile file( mFileName );
@@ -169,3 +144,2 @@ bool ResourceOpie::doOpen()
169*/ 144*/
170 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
171 return true; 145 return true;
@@ -173,17 +147,14 @@ bool ResourceOpie::doOpen()
173 147
174void ResourceOpie::doClose() 148void ResourceQtopia::doClose()
175{ 149{
176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
177} 150}
178 151
179bool ResourceOpie::load() 152bool ResourceQtopia::load()
180{ 153{
181// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 154 kdDebug(5700) << "ResourceQtopia::load(): '" << mFileName << "'" << endl;
182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 155
156// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1());
157
158 AddressBookAccess* access = new AddressBookAccess();
183 159
184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
185
186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
188
189 if ( !access ) { 160 if ( !access ) {
@@ -194,4 +165,2 @@ bool ResourceOpie::load()
194 165
195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
196
197 bool res = false; 166 bool res = false;
@@ -199,3 +168,3 @@ bool ResourceOpie::load()
199 { 168 {
200 mConverter = new OpieConverter(); 169 mConverter = new QtopiaConverter();
201 res = mConverter->init(); 170 res = mConverter->init();
@@ -203,4 +172,4 @@ bool ResourceOpie::load()
203 { 172 {
204 qDebug("Unable to initialize opie converter. Most likely a problem with the category file"); 173 qDebug("Unable to initialize qtopia converter. Most likely a problem with the category file");
205 addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) ); 174 addressBook()->error( i18n( "Unable to initialize qtopia converter. Most likely a problem with the category file" ) );
206 delete access; 175 delete access;
@@ -209,27 +178,23 @@ bool ResourceOpie::load()
209 } 178 }
179
180 { //create a new scope
181 AddressBookIterator it(*access);
182 const PimContact* contact;
210 183
211 184 for (contact=it.toFirst(); it.current(); ++it) {
212 OContactAccess::List::Iterator it; 185 contact = it.current();
213 OContactAccess::List allList = access->allRecords();
214 for ( it = allList.begin(); it != allList.end(); ++it )
215 {
216 OContact c = (*it);
217 186
218 KABC::Addressee addressee; 187 KABC::Addressee addressee;
219 188
220 res = mConverter->opieToAddressee( c, addressee ); 189 res = mConverter->qtopiaToAddressee( (*contact), addressee );
221 190
222 if ( !addressee.isEmpty() && res ) 191 if ( !addressee.isEmpty() && res )
223 { 192 {
224 addressee.setResource( this ); 193 addressee.setResource( this );
225 addressBook()->insertAddressee( addressee ); 194 addressBook()->insertAddressee( addressee );
195 }
226 } 196 }
227
228// qDebug("found %s", c.fullName().latin1());
229 } 197 }
230 198
231 delete access; 199 delete access;
232 // it seems so, that deletion of access deletes backend as well
233 //delete backend;
234
235 return true; 200 return true;
@@ -237,9 +202,7 @@ bool ResourceOpie::load()
237 202
238bool ResourceOpie::save( Ticket *ticket ) 203bool ResourceQtopia::save( Ticket *ticket )
239{ 204{
240 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); 205/*US
241/*US 206// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
242 207 kdDebug(5700) << "ResourceQtopia::save()" << endl;
243 qDebug("ResourceOpie::save %s", mFileName.latin1());
244 kdDebug(5700) << "ResourceOpie::save()" << endl;
245 208
@@ -247,3 +210,3 @@ bool ResourceOpie::save( Ticket *ticket )
247 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 210 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
248*/ 211
249/*US we use a simpler method to create a backupfile 212/*US we use a simpler method to create a backupfile
@@ -261,2 +224,3 @@ bool ResourceOpie::save( Ticket *ticket )
261*/ 224*/
225
262/*US 226/*US
@@ -284,15 +248,10 @@ bool ResourceOpie::save( Ticket *ticket )
284 248
285 qDebug("ResourceOpie::save has to be changed"); 249 qDebug("ResourceQtopia::save has to be changed");
286*/ 250*/
287 return true; 251 return true;
288
289} 252}
290 253
291bool ResourceOpie::lock( const QString &fileName ) 254bool ResourceQtopia::lock( const QString &fileName )
292{ 255{
293 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1()); 256 kdDebug(5700) << "ResourceQtopia::lock()" << endl;
294
295/*US
296// qDebug("ResourceOpie::lock() %s", fileName.latin1());
297 kdDebug(5700) << "ResourceOpie::lock()" << endl;
298 257
@@ -336,13 +295,6 @@ bool ResourceOpie::lock( const QString &fileName )
336 return false; 295 return false;
337*/
338
339 return true;
340} 296}
341 297
342void ResourceOpie::unlock( const QString &fileName ) 298void ResourceQtopia::unlock( const QString &fileName )
343{ 299{
344 qDebug("ResourceOpie::unlock() has to be fixed - %s", mFileName.latin1());
345/*US
346// qDebug("ResourceOpie::unlock() %s", fileName.latin1());
347
348 QString fn = fileName; 300 QString fn = fileName;
@@ -358,23 +310,19 @@ void ResourceOpie::unlock( const QString &fileName )
358 addressBook()->emitAddressBookUnlocked(); 310 addressBook()->emitAddressBookUnlocked();
359*/
360} 311}
361 312
362void ResourceOpie::setFileName( const QString &fileName ) 313void ResourceQtopia::setFileName( const QString &fileName )
363{ 314{
364/*US ToDo: no synchronization so far. Has to be changed in the future
365 mDirWatch.stopScan(); 315 mDirWatch.stopScan();
366 mDirWatch.removeFile( mFileName ); 316 mDirWatch.removeFile( mFileName );
367*/ 317
368 mFileName = fileName; 318 mFileName = fileName;
369 319
370
371/*US ToDo: no synchronization so far. Has to be changed in the future
372 mDirWatch.addFile( mFileName ); 320 mDirWatch.addFile( mFileName );
373 mDirWatch.startScan(); 321 mDirWatch.startScan();
374*/ 322
375//US simulate KDirWatch event 323//US simulate KDirWatch event
376 fileChanged(); 324//US fileChanged();
377} 325}
378 326
379QString ResourceOpie::fileName() const 327QString ResourceQtopia::fileName() const
380{ 328{
@@ -383,3 +331,3 @@ QString ResourceOpie::fileName() const
383 331
384void ResourceOpie::fileChanged() 332void ResourceQtopia::fileChanged()
385{ 333{
@@ -393,15 +341,8 @@ void ResourceOpie::fileChanged()
393 341
394void ResourceOpie::removeAddressee( const Addressee &addr ) 342void ResourceQtopia::removeAddressee( const Addressee &addr )
395{ 343{
396/*US
397 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
398 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
399 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
400*/
401} 344}
402 345
403void ResourceOpie::cleanUp() 346void ResourceQtopia::cleanUp()
404{ 347{
405// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
406
407 unlock( mFileName ); 348 unlock( mFileName );
@@ -409,2 +350,2 @@ void ResourceOpie::cleanUp()
409 350
410//US #include "resourceopie.moc" 351//US #include "resourceqtopia.moc"
diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h
index ea0b5ee..bf9dd45 100644
--- a/kabc/plugins/qtopia/resourceqtopia.h
+++ b/kabc/plugins/qtopia/resourceqtopia.h
@@ -28,4 +28,4 @@ $Id$
28 28
29#ifndef KABC_RESOURCEQTOPIA_H 29#ifndef KABC_RESOURCEOPIE_H
30#define KABC_RESOURCEQTOPIA_H 30#define KABC_RESOURCEOPIE_H
31 31
@@ -39,5 +39,2 @@ $Id$
39 39
40//class QTimer;
41//class FormatPlugin;
42
43namespace KABC { 40namespace KABC {
@@ -46,3 +43,4 @@ namespace KABC {
46class ResourceConfigWidget; 43class ResourceConfigWidget;
47class OpieConverter; 44class QtopiaConverter;
45
48/** 46/**
@@ -50,3 +48,3 @@ class OpieConverter;
50*/ 48*/
51class ResourceOpie : public Resource 49class ResourceQtopia : public Resource
52{ 50{
@@ -61,3 +59,3 @@ public:
61 */ 59 */
62 ResourceOpie( const KConfig *cfg ); 60 ResourceQtopia( const KConfig *cfg );
63 61
@@ -66,3 +64,3 @@ public:
66 */ 64 */
67 ResourceOpie( const QString &fileName ); 65 ResourceQtopia( const QString &fileName );
68 66
@@ -71,3 +69,3 @@ public:
71 */ 69 */
72 ~ResourceOpie(); 70 ~ResourceQtopia();
73 71
@@ -140,3 +138,3 @@ protected:
140private: 138private:
141 OpieConverter* mConverter; 139 QtopiaConverter* mConverter;
142 140
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
index 8cb8505..b2310c4 100644
--- a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
+++ b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
@@ -48,7 +48,5 @@ using namespace KABC;
48 48
49ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name ) 49ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name )
50 : ConfigWidget( parent, name ) 50 : ConfigWidget( parent, name )
51{ 51{
52//qDebug("ResourceFileConfig::ResourceFileConfig");
53
54 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 52 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
@@ -64,11 +62,12 @@ ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name )
64 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 62 mainLayout->addWidget( mFileNameEdit, 0, 1 );
63
65} 64}
66 65
67void ResourceOpieConfig::loadSettings( KRES::Resource *res ) 66void ResourceQtopiaConfig::loadSettings( KRES::Resource *res )
68{ 67{
69//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 68//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
70 ResourceOpie *resource = (ResourceOpie*)( res ); 69 ResourceQtopia *resource = (ResourceQtopia*)( res );
71 70
72 if ( !resource ) { 71 if ( !resource ) {
73 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl; 72 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl;
74 return; 73 return;
@@ -79,14 +78,18 @@ void ResourceOpieConfig::loadSettings( KRES::Resource *res )
79 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); 78 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
80 79
81 //US Opie resources are ReadOnly by definition 80 //US Qtopia resources are ReadOnly by definition
82 emit setPersistentReadOnly( true ); 81 emit setPersistentReadOnly( true );
82
83 //US we can not choose the filename for the qtopia backend => make it readonly.
84 mFileNameEdit->setEnabled( false );
85
83} 86}
84 87
85void ResourceOpieConfig::saveSettings( KRES::Resource *res ) 88void ResourceQtopiaConfig::saveSettings( KRES::Resource *res )
86{ 89{
87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 90//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
88 ResourceOpie *resource = (ResourceOpie*)( res ); 91 ResourceQtopia *resource = (ResourceQtopia*)( res );
89 92
90 if ( !resource ) { 93 if ( !resource ) {
91 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl; 94 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl;
92 return; 95 return;
@@ -97,3 +100,3 @@ void ResourceOpieConfig::saveSettings( KRES::Resource *res )
97 100
98void ResourceOpieConfig::checkFilePermissions( const QString& fileName ) 101void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName )
99{ 102{
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.h b/kabc/plugins/qtopia/resourceqtopiaconfig.h
index 0d80625..6b90b64 100644
--- a/kabc/plugins/qtopia/resourceqtopiaconfig.h
+++ b/kabc/plugins/qtopia/resourceqtopiaconfig.h
@@ -37,3 +37,3 @@ namespace KABC {
37 37
38class ResourceOpieConfig : public KRES::ConfigWidget 38class ResourceQtopiaConfig : public KRES::ConfigWidget
39{ 39{
@@ -42,3 +42,3 @@ class ResourceOpieConfig : public KRES::ConfigWidget
42public: 42public:
43 ResourceOpieConfig( QWidget* parent = 0, const char* name = 0 ); 43 ResourceQtopiaConfig( QWidget* parent = 0, const char* name = 0 );
44 44