author | ulf69 <ulf69> | 2004-06-30 22:02:19 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-30 22:02:19 (UTC) |
commit | 570dc8214a4b43ca89e71901f48deea2b53492bb (patch) (unidiff) | |
tree | d3eb25840e1e0e29541c0005ed7950b84557c34c | |
parent | 2de4aeb0272fa7d96a55332196a11e52b2f27539 (diff) | |
download | kdepimpi-570dc8214a4b43ca89e71901f48deea2b53492bb.zip kdepimpi-570dc8214a4b43ca89e71901f48deea2b53492bb.tar.gz kdepimpi-570dc8214a4b43ca89e71901f48deea2b53492bb.tar.bz2 |
implemented loading of opie resources
-rw-r--r-- | kabc/plugins/opie/kabc_opieE.pro | 24 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 115 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.h | 9 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopieconfig.cpp | 9 |
4 files changed, 112 insertions, 45 deletions
diff --git a/kabc/plugins/opie/kabc_opieE.pro b/kabc/plugins/opie/kabc_opieE.pro index 7341ca8..f3e2ac4 100644 --- a/kabc/plugins/opie/kabc_opieE.pro +++ b/kabc/plugins/opie/kabc_opieE.pro | |||
@@ -1,12 +1,21 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on |
3 | #release debug | 3 | #release debug |
4 | |||
5 | TARGET = microkabc_opie | 4 | TARGET = microkabc_opie |
6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat | 5 | |
6 | INCLUDEPATH += ../.. ../../converter/opie ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include | ||
7 | |||
8 | |||
7 | OBJECTS_DIR = obj/$(PLATFORM) | 9 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc | 10 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 11 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde -lmicrokabc | 12 | LIBS += -lmicrokde |
13 | LIBS += -lmicrokabc | ||
11 | LIBS += -L$(QPEDIR)/lib | 14 | LIBS += -L$(QPEDIR)/lib |
15 | LIBS += -lopie | ||
16 | LIBS += -lqpe | ||
17 | LIBS += -lqte | ||
18 | LIBS += -lmicrokabc_opieconverter | ||
19 | #LIBS += -L../../lib/$(PLATFORM) | ||
20 | |||
12 | 21 | ||
@@ -16,3 +25,3 @@ HEADERS = \ | |||
16 | resourceopie.h \ | 25 | resourceopie.h \ |
17 | resourceopieconfig.h | 26 | resourceopieconfig.h \ |
18 | 27 | ||
@@ -20,2 +29,3 @@ SOURCES = \ | |||
20 | resourceopie.cpp \ | 29 | resourceopie.cpp \ |
21 | resourceopieconfig.cpp | 30 | resourceopieconfig.cpp \ |
31 | |||
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp index 47e22b4..f992301 100644 --- a/kabc/plugins/opie/resourceopie.cpp +++ b/kabc/plugins/opie/resourceopie.cpp | |||
@@ -31,2 +31,3 @@ $Id$ | |||
31 | 31 | ||
32 | #include <qdir.h> | ||
32 | #include <qfile.h> | 33 | #include <qfile.h> |
@@ -44,2 +45,5 @@ $Id$ | |||
44 | //US #include "formatfactory.h" | 45 | //US #include "formatfactory.h" |
46 | //US #include <qpe/qpeapplication.h> | ||
47 | |||
48 | #include <opie/ocontactaccess.h> | ||
45 | 49 | ||
@@ -49,2 +53,4 @@ $Id$ | |||
49 | 53 | ||
54 | #include "opieconverter.h" | ||
55 | |||
50 | #include "resourceopie.h" | 56 | #include "resourceopie.h" |
@@ -54,3 +60,2 @@ extern "C" | |||
54 | { | 60 | { |
55 | //US void *init_kabc_file() | ||
56 | void *init_microkabc_opie() | 61 | void *init_microkabc_opie() |
@@ -62,5 +67,5 @@ extern "C" | |||
62 | ResourceOpie::ResourceOpie( const KConfig *config ) | 67 | ResourceOpie::ResourceOpie( const KConfig *config ) |
63 | : Resource( config ) | 68 | : Resource( config ), mConverter (0) |
64 | { | 69 | { |
65 | QString fileName; | 70 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
66 | 71 | ||
@@ -68,9 +73,8 @@ ResourceOpie::ResourceOpie( const KConfig *config ) | |||
68 | if ( cfg ) { | 73 | if ( cfg ) { |
69 | fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); | 74 | fileName = cfg->readEntry( "FileName", fileName ); |
70 | // qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); | 75 | |
71 | } else { | ||
72 | fileName = StdAddressBook::fileName(); | ||
73 | // qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); | ||
74 | } | 76 | } |
75 | 77 | ||
78 | // qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() ); | ||
79 | |||
76 | init( fileName ); | 80 | init( fileName ); |
@@ -81,3 +85,3 @@ ResourceOpie::ResourceOpie( const QString &fileName ) | |||
81 | { | 85 | { |
82 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 86 | // qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); |
83 | init( fileName ); | 87 | init( fileName ); |
@@ -93,4 +97,7 @@ void ResourceOpie::init( const QString &fileName ) | |||
93 | */ | 97 | */ |
98 | //US opie addressbook is always readonly | ||
99 | setReadOnly( true ); | ||
94 | 100 | ||
95 | setFileName( fileName ); | 101 | setFileName( fileName ); |
102 | |||
96 | } | 103 | } |
@@ -99,2 +106,4 @@ ResourceOpie::~ResourceOpie() | |||
99 | { | 106 | { |
107 | if (mConverter != 0) | ||
108 | delete mConverter; | ||
100 | } | 109 | } |
@@ -103,2 +112,5 @@ void ResourceOpie::writeConfig( KConfig *config ) | |||
103 | { | 112 | { |
113 | //US opie addressbook is always readonly | ||
114 | setReadOnly( true ); | ||
115 | |||
104 | Resource::writeConfig( config ); | 116 | Resource::writeConfig( config ); |
@@ -128,2 +140,4 @@ bool ResourceOpie::doOpen() | |||
128 | { | 140 | { |
141 | // qDebug("ResourceOpie::doOpen() %s", mFileName.latin1()); | ||
142 | /*US | ||
129 | QFile file( mFileName ); | 143 | QFile file( mFileName ); |
@@ -153,2 +167,5 @@ bool ResourceOpie::doOpen() | |||
153 | } | 167 | } |
168 | */ | ||
169 | qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1()); | ||
170 | return true; | ||
154 | } | 171 | } |
@@ -157,2 +174,3 @@ void ResourceOpie::doClose() | |||
157 | { | 174 | { |
175 | // qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); | ||
158 | } | 176 | } |
@@ -161,7 +179,10 @@ bool ResourceOpie::load() | |||
161 | { | 179 | { |
180 | // qDebug("ResourceOpie::load() %s", mFileName.latin1()); | ||
162 | kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; | 181 | kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; |
163 | 182 | ||
164 | QFile file( mFileName ); | 183 | OContactAccess* access = new OContactAccess("KDEPim/Pi", mFileName, 0l, false); |
165 | if ( !file.open( IO_ReadOnly ) ) { | 184 | |
166 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); | 185 | if ( !access ) { |
186 | qDebug("Unable to load file() %s", mFileName.latin1()); | ||
187 | addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); | ||
167 | return false; | 188 | return false; |
@@ -169,5 +190,30 @@ bool ResourceOpie::load() | |||
169 | 190 | ||
170 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 191 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available |
192 | |||
193 | if (mConverter == 0) | ||
194 | mConverter = new OpieConverter(); | ||
195 | |||
196 | |||
197 | OContactAccess::List::Iterator it; | ||
198 | OContactAccess::List allList = access->allRecords(); | ||
199 | bool res = false; | ||
200 | for ( it = allList.begin(); it != allList.end(); ++it ) | ||
201 | { | ||
202 | OContact c = (*it); | ||
203 | |||
204 | KABC::Addressee addressee; | ||
205 | |||
206 | res = mConverter->opieToAddressee( c, addressee ); | ||
207 | |||
208 | if ( !addressee.isEmpty() && res ) | ||
209 | { | ||
210 | addressee.setResource( this ); | ||
211 | addressBook()->insertAddressee( addressee ); | ||
212 | } | ||
213 | |||
214 | // qDebug("found %s", c.fullName().latin1()); | ||
215 | } | ||
216 | |||
217 | delete access; | ||
171 | 218 | ||
172 | //US return mFormat->loadAll( addressBook(), this, &file ); | ||
173 | return true; | 219 | return true; |
@@ -177,3 +223,6 @@ bool ResourceOpie::save( Ticket *ticket ) | |||
177 | { | 223 | { |
178 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 224 | qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); |
225 | /*US | ||
226 | |||
227 | qDebug("ResourceOpie::save %s", mFileName.latin1()); | ||
179 | kdDebug(5700) << "ResourceOpie::save()" << endl; | 228 | kdDebug(5700) << "ResourceOpie::save()" << endl; |
@@ -182,3 +231,3 @@ bool ResourceOpie::save( Ticket *ticket ) | |||
182 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | 231 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); |
183 | 232 | */ | |
184 | /*US we use a simpler method to create a backupfile | 233 | /*US we use a simpler method to create a backupfile |
@@ -196,3 +245,3 @@ bool ResourceOpie::save( Ticket *ticket ) | |||
196 | */ | 245 | */ |
197 | 246 | /*US | |
198 | //US ToDo: write backupfile | 247 | //US ToDo: write backupfile |
@@ -220,3 +269,5 @@ bool ResourceOpie::save( Ticket *ticket ) | |||
220 | qDebug("ResourceOpie::save has to be changed"); | 269 | qDebug("ResourceOpie::save has to be changed"); |
270 | */ | ||
221 | return true; | 271 | return true; |
272 | |||
222 | } | 273 | } |
@@ -225,2 +276,6 @@ bool ResourceOpie::lock( const QString &fileName ) | |||
225 | { | 276 | { |
277 | qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1()); | ||
278 | |||
279 | /*US | ||
280 | // qDebug("ResourceOpie::lock() %s", fileName.latin1()); | ||
226 | kdDebug(5700) << "ResourceOpie::lock()" << endl; | 281 | kdDebug(5700) << "ResourceOpie::lock()" << endl; |
@@ -265,2 +320,5 @@ bool ResourceOpie::lock( const QString &fileName ) | |||
265 | return false; | 320 | return false; |
321 | */ | ||
322 | |||
323 | return true; | ||
266 | } | 324 | } |
@@ -269,2 +327,6 @@ void ResourceOpie::unlock( const QString &fileName ) | |||
269 | { | 327 | { |
328 | qDebug("ResourceOpie::unlock() has to be fixed - %s", mFileName.latin1()); | ||
329 | /*US | ||
330 | // qDebug("ResourceOpie::unlock() %s", fileName.latin1()); | ||
331 | |||
270 | QString fn = fileName; | 332 | QString fn = fileName; |
@@ -280,2 +342,3 @@ void ResourceOpie::unlock( const QString &fileName ) | |||
280 | addressBook()->emitAddressBookUnlocked(); | 342 | addressBook()->emitAddressBookUnlocked(); |
343 | */ | ||
281 | } | 344 | } |
@@ -304,18 +367,2 @@ QString ResourceOpie::fileName() const | |||
304 | 367 | ||
305 | /*US | ||
306 | void ResourceOpie::setFormat( const QString &format ) | ||
307 | { | ||
308 | mFormatName = format; | ||
309 | delete mFormat; | ||
310 | |||
311 | FormatFactory *factory = FormatFactory::self(); | ||
312 | mFormat = factory->format( mFormatName ); | ||
313 | } | ||
314 | |||
315 | QString ResourceOpie::format() const | ||
316 | { | ||
317 | return mFormatName; | ||
318 | } | ||
319 | */ | ||
320 | |||
321 | void ResourceOpie::fileChanged() | 368 | void ResourceOpie::fileChanged() |
@@ -341,2 +388,4 @@ void ResourceOpie::cleanUp() | |||
341 | { | 388 | { |
389 | // qDebug("ResourceOpie::cleanup() %s", mFileName.latin1()); | ||
390 | |||
342 | unlock( mFileName ); | 391 | unlock( mFileName ); |
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h index d21272a..9db9485 100644 --- a/kabc/plugins/opie/resourceopie.h +++ b/kabc/plugins/opie/resourceopie.h | |||
@@ -38,4 +38,5 @@ $Id$ | |||
38 | 38 | ||
39 | class QTimer; | 39 | |
40 | class FormatPlugin; | 40 | //class QTimer; |
41 | //class FormatPlugin; | ||
41 | 42 | ||
@@ -45,3 +46,3 @@ namespace KABC { | |||
45 | class ResourceConfigWidget; | 46 | class ResourceConfigWidget; |
46 | 47 | class OpieConverter; | |
47 | /** | 48 | /** |
@@ -139,2 +140,4 @@ protected: | |||
139 | private: | 140 | private: |
141 | OpieConverter* mConverter; | ||
142 | |||
140 | QString mFileName; | 143 | QString mFileName; |
diff --git a/kabc/plugins/opie/resourceopieconfig.cpp b/kabc/plugins/opie/resourceopieconfig.cpp index b92cfa1..f4cc4f9 100644 --- a/kabc/plugins/opie/resourceopieconfig.cpp +++ b/kabc/plugins/opie/resourceopieconfig.cpp | |||
@@ -37,5 +37,8 @@ $Id$ | |||
37 | 37 | ||
38 | #include <qdir.h> | ||
38 | #include <qfile.h> | 39 | #include <qfile.h> |
39 | #include "resourceopie.h" | 40 | #include "resourceopie.h" |
40 | #include "stdaddressbook.h" | 41 | //US #include <qpe/qpeapplication.h> |
42 | |||
43 | //US #include "stdaddressbook.h" | ||
41 | 44 | ||
@@ -83,3 +86,3 @@ void ResourceOpieConfig::loadSettings( KRES::Resource *res ) | |||
83 | if ( mFileNameEdit->url().isEmpty() ) | 86 | if ( mFileNameEdit->url().isEmpty() ) |
84 | mFileNameEdit->setURL( KABC::StdAddressBook::fileName() ); | 87 | mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); |
85 | } | 88 | } |
@@ -102,4 +105,6 @@ void ResourceOpieConfig::checkFilePermissions( const QString& fileName ) | |||
102 | // If file exist but is not writeable... | 105 | // If file exist but is not writeable... |
106 | /*US | ||
103 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) | 107 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) |
104 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); | 108 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); |
109 | */ | ||
105 | } | 110 | } |