Diffstat (limited to 'kabc/plugins/sharpdtm/resourcesharpdtm.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 48b7d91..7069f5d 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -82,4 +82,14 @@ ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) | |||
82 | void ResourceSharpDTM::init( const QString &fileName ) | 82 | void ResourceSharpDTM::init( const QString &fileName ) |
83 | { | 83 | { |
84 | if (mConverter == 0) { | ||
85 | mConverter = new SharpDTMConverter(); | ||
86 | bool res = mConverter->init(); | ||
87 | if ( !res ) | ||
88 | { | ||
89 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | ||
90 | qDebug(msg); | ||
91 | return; | ||
92 | } | ||
93 | } | ||
84 | setFileName( fileName ); | 94 | setFileName( fileName ); |
85 | } | 95 | } |
@@ -111,28 +121,6 @@ Ticket *ResourceSharpDTM::requestSaveTicket() | |||
111 | bool ResourceSharpDTM::doOpen() | 121 | bool ResourceSharpDTM::doOpen() |
112 | { | 122 | { |
113 | qDebug("%xResourceSharpDTM::doOpen: %s", this,fileName().latin1()); | 123 | if (!mConverter) |
114 | |||
115 | if ( ! mAccess ) { | ||
116 | // the last parameter in the SlZDataBase constructor means "readonly" | ||
117 | mAccess = new SlZDataBase(fileName(), | ||
118 | SlZDataBase::addressbookItems(), | ||
119 | NULL, false); | ||
120 | } | ||
121 | if ( !mAccess ) { | ||
122 | qDebug("Unable to load file() %s", fileName().latin1()); | ||
123 | return false; | 124 | return false; |
124 | } | ||
125 | if (mConverter == 0) { | ||
126 | mConverter = new SharpDTMConverter(); | ||
127 | bool res = mConverter->init(); | ||
128 | if ( !res ) | ||
129 | { | ||
130 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | ||
131 | qDebug(msg); | ||
132 | delete mAccess; | ||
133 | mAccess = 0; | ||
134 | return false; | ||
135 | } | ||
136 | } | ||
137 | return true; | 125 | return true; |
138 | } | 126 | } |
@@ -145,4 +133,15 @@ void ResourceSharpDTM::doClose() | |||
145 | bool ResourceSharpDTM::load() | 133 | bool ResourceSharpDTM::load() |
146 | { | 134 | { |
135 | if (!mConverter) | ||
136 | return false; | ||
137 | QString fileN = SlZDataBase::addressbookFileName(); | ||
138 | if ( ! mAccess ) { | ||
139 | mAccess = new SlZDataBase(fileN, | ||
140 | SlZDataBase::addressbookItems(), | ||
141 | 0, false); | ||
142 | } | ||
143 | if(mAccess == 0) | ||
144 | return false; | ||
145 | |||
147 | qDebug("%xResourceSharpDTM::load: %s",this, fileName().latin1()); | 146 | qDebug("%xResourceSharpDTM::load: %s",this, fileName().latin1()); |
148 | bool res = false; | 147 | bool res = false; |
@@ -159,4 +158,8 @@ bool ResourceSharpDTM::load() | |||
159 | } | 158 | } |
160 | } | 159 | } |
160 | if(mAccess != 0) | ||
161 | delete mAccess; | ||
162 | mAccess = 0; | ||
163 | |||
161 | return true; | 164 | return true; |
162 | } | 165 | } |
@@ -164,4 +167,14 @@ bool ResourceSharpDTM::load() | |||
164 | bool ResourceSharpDTM::save( Ticket *ticket ) | 167 | bool ResourceSharpDTM::save( Ticket *ticket ) |
165 | { | 168 | { |
169 | if (!mConverter) | ||
170 | return false; | ||
171 | QString fileN = SlZDataBase::addressbookFileName(); | ||
172 | if ( ! mAccess ) { | ||
173 | mAccess = new SlZDataBase(fileN, | ||
174 | SlZDataBase::addressbookItems(), | ||
175 | 0, false); | ||
176 | } | ||
177 | if(mAccess == 0) | ||
178 | return false; | ||
166 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 179 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
167 | KABC::AddressBook::Iterator it; | 180 | KABC::AddressBook::Iterator it; |
@@ -250,5 +263,7 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
250 | } | 263 | } |
251 | delete ticket; | 264 | delete ticket; |
252 | 265 | if(mAccess != 0) | |
266 | delete mAccess; | ||
267 | mAccess = 0; | ||
253 | return true; | 268 | return true; |
254 | } | 269 | } |
@@ -256,4 +271,5 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
256 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 271 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
257 | { | 272 | { |
273 | return true; | ||
258 | } | 274 | } |
259 | 275 | ||
@@ -279,5 +295,5 @@ void ResourceSharpDTM::removeAddressee( const Addressee &addr ) | |||
279 | void ResourceSharpDTM::cleanUp() | 295 | void ResourceSharpDTM::cleanUp() |
280 | { | 296 | { |
281 | unlock( fileName() ); | 297 | |
282 | } | 298 | } |
283 | 299 | ||