author | ulf69 <ulf69> | 2004-07-15 23:52:53 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-15 23:52:53 (UTC) |
commit | d6589bebc11011fa7c4a96383e278202424b42eb (patch) (unidiff) | |
tree | 97525a4625a6cdb308edbba9a0792cbad59924a2 /kabc/plugins | |
parent | 7268894251d348b482dc21735ff331b0088f903f (diff) | |
download | kdepimpi-d6589bebc11011fa7c4a96383e278202424b42eb.zip kdepimpi-d6589bebc11011fa7c4a96383e278202424b42eb.tar.gz kdepimpi-d6589bebc11011fa7c4a96383e278202424b42eb.tar.bz2 |
added first revision for sharp DTM access. (is not working yet)
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 355 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.h | 149 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtmconfig.cpp | 108 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtmconfig.h | 58 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmE.pro | 30 |
5 files changed, 700 insertions, 0 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp new file mode 100644 index 0000000..347d51c --- a/dev/null +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -0,0 +1,355 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #include <sys/types.h> | ||
29 | #include <sys/stat.h> | ||
30 | #include <unistd.h> | ||
31 | |||
32 | #include <qdir.h> | ||
33 | #include <qfile.h> | ||
34 | #include <qfileinfo.h> | ||
35 | #include <qregexp.h> | ||
36 | //US #include <qtimer.h> | ||
37 | |||
38 | #include <kapplication.h> | ||
39 | #include <kconfig.h> | ||
40 | #include <kdebug.h> | ||
41 | #include <klocale.h> | ||
42 | //US #include <ksavefile.h> | ||
43 | #include <kstandarddirs.h> | ||
44 | #include <kmessagebox.h> | ||
45 | |||
46 | #include <sl/slzdb.h> | ||
47 | |||
48 | |||
49 | #include "resourcesharpdtmconfig.h" | ||
50 | #include "stdaddressbook.h" | ||
51 | |||
52 | //#include "qtopiaconverter.h" | ||
53 | |||
54 | #include "resourcesharpdtm.h" | ||
55 | |||
56 | using namespace KABC; | ||
57 | extern "C" | ||
58 | { | ||
59 | void *init_microkabc_sharpdtm() | ||
60 | { | ||
61 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) | ||
66 | : Resource( config ), mConverter (0) | ||
67 | { | ||
68 | // we can not choose the filename. Therefore use the default to display | ||
69 | |||
70 | QString fileName = SlZDataBase::addressbookFileName(); | ||
71 | init( fileName ); | ||
72 | } | ||
73 | |||
74 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) | ||
75 | : Resource( 0 ) | ||
76 | { | ||
77 | // qDebug("ResourceFile::ResourceSharpDTM : 3 %s, %s", fileName.latin1(), formatName.latin1()); | ||
78 | init( fileName ); | ||
79 | } | ||
80 | |||
81 | void ResourceSharpDTM::init( const QString &fileName ) | ||
82 | { | ||
83 | |||
84 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | ||
85 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | ||
86 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | ||
87 | |||
88 | setFileName( fileName ); | ||
89 | } | ||
90 | |||
91 | ResourceSharpDTM::~ResourceSharpDTM() | ||
92 | { | ||
93 | // if (mConverter != 0) | ||
94 | // delete mConverter; | ||
95 | |||
96 | } | ||
97 | |||
98 | void ResourceSharpDTM::writeConfig( KConfig *config ) | ||
99 | { | ||
100 | Resource::writeConfig( config ); | ||
101 | } | ||
102 | |||
103 | Ticket *ResourceSharpDTM::requestSaveTicket() | ||
104 | { | ||
105 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; | ||
106 | |||
107 | if ( !addressBook() ) return 0; | ||
108 | |||
109 | if ( !lock( mFileName ) ) { | ||
110 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" | ||
111 | << mFileName << "'" << endl; | ||
112 | return 0; | ||
113 | } | ||
114 | return createTicket( this ); | ||
115 | } | ||
116 | |||
117 | |||
118 | bool ResourceSharpDTM::doOpen() | ||
119 | { | ||
120 | /*US | ||
121 | QFile file( mFileName ); | ||
122 | |||
123 | if ( !file.exists() ) { | ||
124 | // try to create the file | ||
125 | bool ok = file.open( IO_WriteOnly ); | ||
126 | if ( ok ) | ||
127 | file.close(); | ||
128 | |||
129 | return ok; | ||
130 | } else { | ||
131 | if ( !file.open( IO_ReadWrite ) ) | ||
132 | return false; | ||
133 | |||
134 | if ( file.size() == 0 ) { | ||
135 | file.close(); | ||
136 | return true; | ||
137 | } | ||
138 | |||
139 | //US bool ok = mFormat->checkFormat( &file ); | ||
140 | bool ok = true; | ||
141 | |||
142 | file.close(); | ||
143 | |||
144 | return ok; | ||
145 | } | ||
146 | */ | ||
147 | return true; | ||
148 | } | ||
149 | |||
150 | void ResourceSharpDTM::doClose() | ||
151 | { | ||
152 | } | ||
153 | |||
154 | bool ResourceSharpDTM::load() | ||
155 | { | ||
156 | kdDebug(5700) << "ResourcSharpDTM::load(): '" << mFileName << "'" << endl; | ||
157 | |||
158 | // qDebug("ResourceSharpDTM::load: Try to load file() %s", mFileName.latin1()); | ||
159 | |||
160 | SlZDataBase* access = new SlZDataBase(mFileName, | ||
161 | SlZDataBase::addressbookItems()); | ||
162 | if ( !access ) { | ||
163 | qDebug("Unable to load file() %s", mFileName.latin1()); | ||
164 | addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | bool res = false; | ||
169 | if (mConverter == 0) | ||
170 | { | ||
171 | // mConverter = new QtopiaConverter(); | ||
172 | // res = mConverter->init(); | ||
173 | res = true; | ||
174 | if ( !res ) | ||
175 | { | ||
176 | qDebug("Unable to initialize qtopia converter. Most likely a problem with the category file"); | ||
177 | addressBook()->error( i18n( "Unable to initialize qtopia converter. Most likely a problem with the category file" ) ); | ||
178 | delete access; | ||
179 | return false; | ||
180 | } | ||
181 | } | ||
182 | /* | ||
183 | { //create a new scope | ||
184 | AddressBookIterator it(*access); | ||
185 | const PimContact* contact; | ||
186 | |||
187 | for (contact=it.toFirst(); it.current(); ++it) { | ||
188 | contact = it.current(); | ||
189 | |||
190 | KABC::Addressee addressee; | ||
191 | |||
192 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); | ||
193 | |||
194 | if ( !addressee.isEmpty() && res ) | ||
195 | { | ||
196 | addressee.setResource( this ); | ||
197 | addressBook()->insertAddressee( addressee ); | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | */ | ||
202 | delete access; | ||
203 | return true; | ||
204 | } | ||
205 | |||
206 | bool ResourceSharpDTM::save( Ticket *ticket ) | ||
207 | { | ||
208 | /*US | ||
209 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | ||
210 | kdDebug(5700) << "ResourceQtopia::save()" << endl; | ||
211 | |||
212 | // create backup file | ||
213 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | ||
214 | |||
215 | /*US we use a simpler method to create a backupfile | ||
216 | |||
217 | (void) KSaveFile::backupFile( mFileName, QString::null | ||
218 | ,extension ); | ||
219 | |||
220 | KSaveFile saveFile( mFileName ); | ||
221 | bool ok = false; | ||
222 | if ( saveFile.status() == 0 && saveFile.file() ) | ||
223 | { | ||
224 | mFormat->saveAll( addressBook(), this, saveFile.file() ); | ||
225 | ok = saveFile.close(); | ||
226 | } | ||
227 | */ | ||
228 | |||
229 | /*US | ||
230 | //US ToDo: write backupfile | ||
231 | QFile info; | ||
232 | info.setName( mFileName ); | ||
233 | bool ok = info.open( IO_WriteOnly ); | ||
234 | if ( ok ) { | ||
235 | //US mFormat->saveAll( addressBook(), this, &info ); | ||
236 | |||
237 | info.close(); | ||
238 | ok = true; | ||
239 | } | ||
240 | else { | ||
241 | |||
242 | } | ||
243 | |||
244 | if ( !ok ) | ||
245 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); | ||
246 | |||
247 | delete ticket; | ||
248 | unlock( mFileName ); | ||
249 | |||
250 | return ok; | ||
251 | |||
252 | qDebug("ResourceQtopia::save has to be changed"); | ||
253 | */ | ||
254 | return true; | ||
255 | } | ||
256 | |||
257 | bool ResourceSharpDTM::lock( const QString &fileName ) | ||
258 | { | ||
259 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | ||
260 | |||
261 | QString fn = fileName; | ||
262 | |||
263 | //US change the implementation how the lockfilename is getting created | ||
264 | //US fn.replace( QRegExp("/"), "_" ); | ||
265 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | ||
266 | |||
267 | KURL url(fn); | ||
268 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | ||
269 | |||
270 | kdDebug(5700) << "-- lock name: " << lockName << endl; | ||
271 | |||
272 | if (QFile::exists( lockName )) return false; | ||
273 | |||
274 | QString lockUniqueName; | ||
275 | lockUniqueName = fn + KApplication::randomString( 8 ); | ||
276 | |||
277 | url = lockUniqueName; | ||
278 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | ||
279 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | ||
280 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | ||
281 | |||
282 | // Create unique file | ||
283 | QFile file( mLockUniqueName ); | ||
284 | file.open( IO_WriteOnly ); | ||
285 | file.close(); | ||
286 | |||
287 | // Create lock file | ||
288 | int result = ::link( QFile::encodeName( mLockUniqueName ), | ||
289 | QFile::encodeName( lockName ) ); | ||
290 | |||
291 | if ( result == 0 ) { | ||
292 | addressBook()->emitAddressBookLocked(); | ||
293 | return true; | ||
294 | } | ||
295 | |||
296 | // TODO: check stat | ||
297 | |||
298 | return false; | ||
299 | } | ||
300 | |||
301 | void ResourceSharpDTM::unlock( const QString &fileName ) | ||
302 | { | ||
303 | QString fn = fileName; | ||
304 | //US change the implementation how the lockfilename is getting created | ||
305 | //US fn.replace( QRegExp( "/" ), "_" ); | ||
306 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | ||
307 | //US QString lockName = fn + ".lock"; | ||
308 | KURL url(fn); | ||
309 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | ||
310 | |||
311 | QFile::remove( lockName ); | ||
312 | QFile::remove( mLockUniqueName ); | ||
313 | addressBook()->emitAddressBookUnlocked(); | ||
314 | } | ||
315 | |||
316 | void ResourceSharpDTM::setFileName( const QString &fileName ) | ||
317 | { | ||
318 | mDirWatch.stopScan(); | ||
319 | mDirWatch.removeFile( mFileName ); | ||
320 | |||
321 | mFileName = fileName; | ||
322 | |||
323 | mDirWatch.addFile( mFileName ); | ||
324 | mDirWatch.startScan(); | ||
325 | |||
326 | } | ||
327 | |||
328 | QString ResourceSharpDTM::fileName() const | ||
329 | { | ||
330 | return mFileName; | ||
331 | } | ||
332 | |||
333 | void ResourceSharpDTM::fileChanged() | ||
334 | { | ||
335 | // There is a small theoretical chance that KDirWatch calls us before | ||
336 | // we are fully constructed | ||
337 | if (!addressBook()) | ||
338 | return; | ||
339 | |||
340 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); | ||
341 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { | ||
342 | load(); | ||
343 | addressBook()->emitAddressBookChanged(); | ||
344 | } | ||
345 | } | ||
346 | |||
347 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) | ||
348 | { | ||
349 | } | ||
350 | |||
351 | void ResourceSharpDTM::cleanUp() | ||
352 | { | ||
353 | unlock( mFileName ); | ||
354 | } | ||
355 | |||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h new file mode 100644 index 0000000..32d0be1 --- a/dev/null +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | |||
29 | #ifndef KABC_RESOURCESHARPDTM_H | ||
30 | #define KABC_RESOURCESHARPDTM_H | ||
31 | |||
32 | #include <kconfig.h> | ||
33 | #include <kdirwatch.h> | ||
34 | |||
35 | #include <sys/types.h> | ||
36 | |||
37 | #include "resource.h" | ||
38 | |||
39 | |||
40 | namespace KABC { | ||
41 | |||
42 | class ResourceConfigWidget; | ||
43 | class QtopiaConverter; | ||
44 | |||
45 | /** | ||
46 | @internal | ||
47 | */ | ||
48 | class ResourceSharpDTM : public Resource | ||
49 | { | ||
50 | Q_OBJECT | ||
51 | |||
52 | public: | ||
53 | |||
54 | /** | ||
55 | Constructor. | ||
56 | |||
57 | @param cfg The config object where custom resource settings are stored. | ||
58 | */ | ||
59 | ResourceSharpDTM( const KConfig *cfg ); | ||
60 | |||
61 | /** | ||
62 | Construct file resource on file @arg fileName using format @arg formatName. | ||
63 | */ | ||
64 | ResourceSharpDTM( const QString &fileName ); | ||
65 | |||
66 | /** | ||
67 | * Destructor. | ||
68 | */ | ||
69 | ~ResourceSharpDTM(); | ||
70 | |||
71 | /** | ||
72 | Writes the config back. | ||
73 | */ | ||
74 | virtual void writeConfig( KConfig *cfg ); | ||
75 | |||
76 | /** | ||
77 | * Tries to open the file and checks for the proper format. | ||
78 | * This method should be called before @ref load(). | ||
79 | */ | ||
80 | virtual bool doOpen(); | ||
81 | |||
82 | /** | ||
83 | * Closes the file again. | ||
84 | */ | ||
85 | virtual void doClose(); | ||
86 | |||
87 | /** | ||
88 | * Requests a save ticket, that is used by @ref save() | ||
89 | */ | ||
90 | virtual Ticket *requestSaveTicket(); | ||
91 | |||
92 | /** | ||
93 | * Loads all addressees from file to the address book. | ||
94 | * Returns true if all addressees could be loaded otherwise false. | ||
95 | */ | ||
96 | virtual bool load(); | ||
97 | |||
98 | /** | ||
99 | * Saves all addresses from address book to file. | ||
100 | * Returns true if all addressees could be saved otherwise false. | ||
101 | * | ||
102 | * @param ticket The ticket returned by @ref requestSaveTicket() | ||
103 | */ | ||
104 | virtual bool save( Ticket *ticket ); | ||
105 | |||
106 | /** | ||
107 | * Set name of file to be used for saving. | ||
108 | */ | ||
109 | void setFileName( const QString & ); | ||
110 | |||
111 | /** | ||
112 | * Return name of file used for loading and saving the address book. | ||
113 | */ | ||
114 | QString fileName() const; | ||
115 | |||
116 | /** | ||
117 | * Remove a addressee from its source. | ||
118 | * This method is mainly called by KABC::AddressBook. | ||
119 | */ | ||
120 | virtual void removeAddressee( const Addressee& addr ); | ||
121 | |||
122 | /** | ||
123 | * This method is called by an error handler if the application | ||
124 | * crashed | ||
125 | */ | ||
126 | virtual void cleanUp(); | ||
127 | |||
128 | protected slots: | ||
129 | void fileChanged(); | ||
130 | |||
131 | protected: | ||
132 | void init( const QString &fileName ); | ||
133 | |||
134 | bool lock( const QString &fileName ); | ||
135 | void unlock( const QString &fileName ); | ||
136 | |||
137 | private: | ||
138 | QtopiaConverter* mConverter; | ||
139 | |||
140 | QString mFileName; | ||
141 | |||
142 | QString mLockUniqueName; | ||
143 | |||
144 | KDirWatch mDirWatch; | ||
145 | }; | ||
146 | |||
147 | } | ||
148 | |||
149 | #endif | ||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtmconfig.cpp b/kabc/plugins/sharpdtm/resourcesharpdtmconfig.cpp new file mode 100644 index 0000000..240f1d7 --- a/dev/null +++ b/kabc/plugins/sharpdtm/resourcesharpdtmconfig.cpp | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #include <qlabel.h> | ||
29 | #include <qlayout.h> | ||
30 | |||
31 | #include <kdebug.h> | ||
32 | #include <klocale.h> | ||
33 | #include <kstandarddirs.h> | ||
34 | #include <kdialog.h> | ||
35 | |||
36 | #include <unistd.h> | ||
37 | |||
38 | #include <qdir.h> | ||
39 | #include <qfile.h> | ||
40 | #include "resourcesharpdtm.h" | ||
41 | |||
42 | #include "resourcesharpdtmconfig.h" | ||
43 | |||
44 | #include <sl/slzdb.h> | ||
45 | |||
46 | using namespace KABC; | ||
47 | |||
48 | ResourceSharpDTMConfig::ResourceSharpDTMConfig( QWidget* parent, const char* name ) | ||
49 | : ConfigWidget( parent, name ) | ||
50 | { | ||
51 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, | ||
52 | KDialog::spacingHint() ); | ||
53 | |||
54 | QLabel *label = new QLabel( i18n( "Location:" ), this ); | ||
55 | mFileNameEdit = new KURLRequester( this ); | ||
56 | |||
57 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), | ||
58 | SLOT( checkFilePermissions( const QString & ) ) ); | ||
59 | |||
60 | mainLayout->addWidget( label, 0, 0 ); | ||
61 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); | ||
62 | |||
63 | } | ||
64 | |||
65 | void ResourceSharpDTMConfig::loadSettings( KRES::Resource *res ) | ||
66 | { | ||
67 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | ||
68 | ResourceSharpDTM *resource = (ResourceSharpDTM*)( res ); | ||
69 | |||
70 | if ( !resource ) { | ||
71 | kdDebug(5700) << "ResourceSharpDTMConfig::loadSettings(): cast failed" << endl; | ||
72 | return; | ||
73 | } | ||
74 | |||
75 | mFileNameEdit->setURL( resource->fileName() ); | ||
76 | if ( mFileNameEdit->url().isEmpty() ) | ||
77 | mFileNameEdit->setURL( SlZDataBase::addressbookFileName() ); | ||
78 | |||
79 | //US Sharp DTM resources are ReadOnly by definition | ||
80 | emit setPersistentReadOnly( true ); | ||
81 | |||
82 | //US we can not choose the filename for the sharp backend => make it readonly. | ||
83 | mFileNameEdit->setEnabled( false ); | ||
84 | |||
85 | } | ||
86 | |||
87 | void ResourceSharpDTMConfig::saveSettings( KRES::Resource *res ) | ||
88 | { | ||
89 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | ||
90 | ResourceSharpDTM *resource = (ResourceSharpDTM*)( res ); | ||
91 | |||
92 | if ( !resource ) { | ||
93 | kdDebug(5700) << "ResourceSharpDTMConfig::saveSettings(): cast failed" << endl; | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | resource->setFileName( mFileNameEdit->url() ); | ||
98 | } | ||
99 | |||
100 | void ResourceSharpDTMConfig::checkFilePermissions( const QString& fileName ) | ||
101 | { | ||
102 | // If file exist but is not writeable... | ||
103 | /*US | ||
104 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) | ||
105 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); | ||
106 | */ | ||
107 | } | ||
108 | |||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtmconfig.h b/kabc/plugins/sharpdtm/resourcesharpdtmconfig.h new file mode 100644 index 0000000..29765c8 --- a/dev/null +++ b/kabc/plugins/sharpdtm/resourcesharpdtmconfig.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | |||
22 | /* | ||
23 | Enhanced Version of the file for platform independent KDE tools. | ||
24 | Copyright (c) 2004 Ulf Schenk | ||
25 | |||
26 | $Id$ | ||
27 | */ | ||
28 | |||
29 | #ifndef RESOURCESHARPDTMCONFIG_H | ||
30 | #define RESOURCESHARPDTMCONFIG_H | ||
31 | |||
32 | #include <kurlrequester.h> | ||
33 | |||
34 | #include <kresources/configwidget.h> | ||
35 | |||
36 | namespace KABC { | ||
37 | |||
38 | class ResourceSharpDTMConfig : public KRES::ConfigWidget | ||
39 | { | ||
40 | Q_OBJECT | ||
41 | |||
42 | public: | ||
43 | ResourceSharpDTMConfig( QWidget* parent = 0, const char* name = 0 ); | ||
44 | |||
45 | public slots: | ||
46 | void loadSettings( KRES::Resource *resource ); | ||
47 | void saveSettings( KRES::Resource *resource ); | ||
48 | |||
49 | protected slots: | ||
50 | void checkFilePermissions( const QString& fileName ); | ||
51 | |||
52 | private: | ||
53 | KURLRequester* mFileNameEdit; | ||
54 | }; | ||
55 | |||
56 | } | ||
57 | |||
58 | #endif | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmE.pro b/kabc/plugins/sharpdtm/sharpdtmE.pro new file mode 100644 index 0000000..0164b80 --- a/dev/null +++ b/kabc/plugins/sharpdtm/sharpdtmE.pro | |||
@@ -0,0 +1,30 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt warn_on | ||
3 | #release debug | ||
4 | TARGET = microkabc_sharpdtm | ||
5 | |||
6 | INCLUDEPATH += ../.. ../../../external/sharpdtm/include ../../converter/qtopia ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include | ||
7 | |||
8 | |||
9 | OBJECTS_DIR = obj/$(PLATFORM) | ||
10 | MOC_DIR = moc/$(PLATFORM) | ||
11 | DESTDIR = $(QPEDIR)/lib | ||
12 | LIBS += -lmicrokde | ||
13 | LIBS += -lmicrokabc | ||
14 | LIBS += -L$(QPEDIR)/lib | ||
15 | LIBS += -lqpe | ||
16 | LIBS += -lqte | ||
17 | LIBS += -lmicrokabc_opieconverter | ||
18 | #LIBS += -L../../lib/$(PLATFORM) | ||
19 | |||
20 | |||
21 | INTERFACES = \ | ||
22 | |||
23 | HEADERS = \ | ||
24 | resourcesharpdtm.h \ | ||
25 | resourcesharpdtmconfig.h \ | ||
26 | |||
27 | SOURCES = \ | ||
28 | resourcesharpdtm.cpp \ | ||
29 | resourcesharpdtmconfig.cpp \ | ||
30 | |||