summaryrefslogtreecommitdiff
path: root/noncore
authoreilers <eilers>2004-10-25 10:02:52 (UTC)
committer eilers <eilers>2004-10-25 10:02:52 (UTC)
commitaf0556afccb9df439bd826bb6028e05560d2910a (patch) (unidiff)
tree39a8f735e0d8d13da9c073e0407bae8431dbf138 /noncore
parented6b09bab91bf21d33ebef1ea49fdb049e10453b (diff)
downloadopie-af0556afccb9df439bd826bb6028e05560d2910a.zip
opie-af0556afccb9df439bd826bb6028e05560d2910a.tar.gz
opie-af0556afccb9df439bd826bb6028e05560d2910a.tar.bz2
Fixing some problems..
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/pimconverter/converter.cpp98
-rwxr-xr-xnoncore/tools/pimconverter/converter.h2
2 files changed, 54 insertions, 46 deletions
diff --git a/noncore/tools/pimconverter/converter.cpp b/noncore/tools/pimconverter/converter.cpp
index fa3e714..e8bd475 100644
--- a/noncore/tools/pimconverter/converter.cpp
+++ b/noncore/tools/pimconverter/converter.cpp
@@ -74,7 +74,7 @@ void Converter::start_conversion(){
74 switch( m_selectedDatabase ){ 74 switch( m_selectedDatabase ){
75 case ADDRESSBOOK:{ 75 case ADDRESSBOOK:{
76 sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); 76 sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
77 } 77 }
78 break; 78 break;
79 case TODOLIST:{ 79 case TODOLIST:{
80 sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); 80 sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
@@ -227,37 +227,60 @@ void Converter::closeEvent( QCloseEvent *e )
227 e->accept(); 227 e->accept();
228} 228}
229 229
230bool Converter::sqliteCopyAndConvert(const QString& src, const QString &dest, QString &cmd) 230bool Converter::sqliteMoveAndConvert( const QString& name, const QString& src, const QString &dest )
231{ 231{
232
233 QMessageBox::information( this, tr( "Pim-Converter" ),
234 tr( "<qt>Starting to convert the database for %1</qt>" ).arg( name ) );
235
236
237 bool error = false;
238 QString cmd;
232 if (!QFile::exists( src ) ) { 239 if (!QFile::exists( src ) ) {
233 cmd = tr("No SQLite2 database exists"); 240 cmd = tr( "No SQLite2 database could be found!" );
234 return false; 241 error = true;
235 } 242 }
236 243
237 if( QFile::exists( dest ) ) { 244 if( QFile::exists( dest ) ) {
238 cmd = tr("A copy of the SQLite2 exists"); 245 cmd = tr( "The database is already converted!" );
239 return false; 246 error = true;
240 } 247 }
241 248
242 /* 249
243 * Copy it over 250 if ( error ){
244 */ 251 QMessageBox::critical( this, tr("Pim-Converter"),
245 cmd = "cp " + Global::shellQuote(src) + " " + Global::shellQuote(dest); 252 tr("<qt>Conversion not possible: \n"
246 if( ::system( cmd ) != 0 ) 253 "Problem: %1</qt>").arg(cmd) );
247 return false; 254 return error;
255 }
256
248 257
249 /* 258 /*
250 * Delete it to make place for the new file 259 * Move it over
251 */ 260 */
252 cmd = "rm " + Global::shellQuote(src); 261 cmd = "mv " + Global::shellQuote(src) + " " + Global::shellQuote(dest);
253 if( ::system( cmd ) != 0 ) 262 if( ::system( cmd ) != 0 ){
254 return false; 263 error = true;
264 }
265
255 266
256 /* 267 /*
257 * Convert it 268 * Convert it
258 */ 269 */
259 cmd = "sqlite " + Global::shellQuote(dest) + " .dump | sqlite3 " + Global::shellQuote(src); 270 if ( !error ){
260 return ::system( cmd ) == 0; 271 cmd = "sqlite " + Global::shellQuote(dest) + " .dump | sqlite3 " + Global::shellQuote(src);
272 if ( ::system( cmd ) != 0 ){
273 error = true;
274 }
275 }
276
277 if ( error ){
278 QMessageBox::critical( this, tr("Pim-Converter"),
279 tr("<qt>An internal error occurred: "
280 "Converting the database was impossible! "
281 "Command: '%1' </qt>").arg(cmd) );
282
283 }
261} 284}
262 285
263 286
@@ -295,40 +318,25 @@ void Converter::start_upgrade()
295 return; 318 return;
296 } 319 }
297 320
298 QString src, dest, cmd; 321 QString src, dest;
322 bool error = false;
323
299 src = Global::applicationFileName("addressbook", "addressbook.db" ); 324 src = Global::applicationFileName("addressbook", "addressbook.db" );
300 dest = Global::applicationFileName("addressbook", "addressbook.db_v2" ); 325 dest = Global::applicationFileName("addressbook", "addressbook.db_v2" );
301 326 error = sqliteMoveAndConvert( "Addressbook", src, dest );
302 if(!sqliteCopyAndConvert(src, dest, cmd)) {
303 QMessageBox::critical( this, tr("Pim-Converter"),
304 tr("<qt>An internal error occurred: "
305 "Converting the addressbook command was impossible! "
306 "Executed the following command: %1</qt>").arg(cmd) );
307 return;
308 }
309 327
310 src = Global::applicationFileName("datebook", "datebook.db" ); 328 src = Global::applicationFileName("datebook", "datebook.db" );
311 dest = Global::applicationFileName("datebook", "datebook.db_v2" ); 329 dest = Global::applicationFileName("datebook", "datebook.db_v2" );
312 if(!sqliteCopyAndConvert(src, dest, cmd)) { 330 error = sqliteMoveAndConvert( "Datebook", src, dest );
313 QMessageBox::critical( this, tr("Pim-Converter"), 331
314 tr("<qt>An internal error occurred: "
315 "Converting the datebook command was impossible! "
316 "Executed the following command: '%1' </qt>").arg(cmd)
317 );
318 return;
319 }
320 332
321 src = Global::applicationFileName("todolist", "todolist.db" ); 333 src = Global::applicationFileName("todolist", "todolist.db" );
322 dest = Global::applicationFileName("todolist", "todolist.db_v2" ); 334 dest = Global::applicationFileName("todolist", "todolist.db_v2" );
323 if(!sqliteCopyAndConvert(src, dest, cmd)) { 335 error = sqliteMoveAndConvert( "TodoList", src, dest );
324 QMessageBox::critical( this, tr("Pim-Converter"),
325 tr("<qt>An internal error occurred: "
326 "Converting the todolist command was impossible! "
327 "Executed the following command: '%1' </qt>").arg(cmd) );
328 return;
329 }
330 336
331 QMessageBox::information( this, tr("Pim-Converter"), 337 if ( !error ){
332 tr("Conversion is finished!"), 338 QMessageBox::information( this, tr("Pim-Converter"),
333 QMessageBox::Ok ); 339 tr("Conversion is finished!"),
340 QMessageBox::Ok );
341 }
334} 342}
diff --git a/noncore/tools/pimconverter/converter.h b/noncore/tools/pimconverter/converter.h
index e9035e7..cfd315c 100755
--- a/noncore/tools/pimconverter/converter.h
+++ b/noncore/tools/pimconverter/converter.h
@@ -42,7 +42,7 @@ private:
42 42
43 43
44private: 44private:
45 static bool sqliteCopyAndConvert( const QString &src, const QString &destination, QString &lastCommand ); 45 bool sqliteMoveAndConvert( const QString& name, const QString &src, const QString &destination );
46}; 46};
47 47
48 48