summaryrefslogtreecommitdiff
path: root/noncore/tools/pimconverter/converter.cpp
Unidiff
Diffstat (limited to 'noncore/tools/pimconverter/converter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/pimconverter/converter.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/noncore/tools/pimconverter/converter.cpp b/noncore/tools/pimconverter/converter.cpp
index e9de3c3..2cd6969 100644
--- a/noncore/tools/pimconverter/converter.cpp
+++ b/noncore/tools/pimconverter/converter.cpp
@@ -1,5 +1,7 @@
1#include "converter.h" 1#include "converter.h"
2 2
3#include <stdlib.h> // For "system()" command
4
3/* OPIE */ 5/* OPIE */
4#include <opie2/oapplicationfactory.h> 6#include <opie2/oapplicationfactory.h>
5#include <opie2/odebug.h> 7#include <opie2/odebug.h>
@@ -224,3 +226,88 @@ void Converter::closeEvent( QCloseEvent *e )
224 } 226 }
225 e->accept(); 227 e->accept();
226} 228}
229
230
231
232void Converter::start_upgrade()
233{
234 odebug << "Start upgrading" << oendl;
235 switch( QMessageBox::warning( this, "Pim-Converter",
236 "Are you really sure that you\n"
237 "want to convert your database from\n"
238 "sqlite V2 to sqlite V3?",
239 QMessageBox::Ok | QMessageBox::Default,
240 QMessageBox::Abort | QMessageBox::Escape )) {
241
242 case QMessageBox::Abort: // Abort clicked or Escape pressed
243 // abort
244 return;
245 break;
246 }
247 odebug << "Checking whether sqlite is installed" << oendl;
248 if ( system( "which sqlite" ) != 0 ){
249 QMessageBox::critical( this, "Pim-Converter",
250 QString("An internal error occurred:\n") +
251 "sqlite was not accessible!\n"+
252 "Please correct the PATH or install \n" +
253 "this packages!" );
254 return;
255 }
256 if ( system( "which sqlite3" ) != 0 ){
257 QMessageBox::critical( this, "Pim-Converter",
258 QString("An internal error occurred:\n") +
259 "sqlite3 was not accessible!\n"+
260 "Please correct the PATH or install \n" +
261 "this packages!" );
262 return;
263 }
264 if ( QFile::exists( "~/Applications/addressbook/addressbook.db" )
265 && !QFile::exists( "~/Applications/addressbook/addressbook.db_v2" ) ){
266 odebug << "Executing conversion commands" << oendl;
267 QString addr_convert_string = "cd ~/Applications/addressbook/;cp addressbook.db addressbook.db_v2;sqlite addressbook.db_v2 .dump | sqlite3 addressbook.db";
268 odebug << "1. Addressbook Command:" << addr_convert_string << oendl;
269 if ( system( addr_convert_string ) != 0 ){
270 QMessageBox::critical( this, "Pim-Converter",
271 QString("An internal error occurred:\n") +
272 "Converting the addressbook command was impossible!\n"+
273 "Executed the following command:\n" +
274 addr_convert_string );
275 return;
276 }
277 }
278 if ( QFile::exists( "~/Applications/datebook/datebook.db" )
279 && !QFile::exists( "~/Applications/datebook/datebook.db_v2" ) ){
280 QString dateb_convert_string = "cd ~/Applications/datebook/;cp datebook.db datebook.db_v2;sqlite datebook.db_v2 .dump | sqlite3 datebook.db";
281 odebug << "2. Datebook Command" << dateb_convert_string << oendl;
282 if ( system( dateb_convert_string ) != 0 ){
283 QMessageBox::critical( this, "Pim-Converter",
284 QString("An internal error occurred:\n") +
285 "Converting the datebook command was impossible!\n"+
286 "Executed the following command:\n" +
287 dateb_convert_string );
288 return;
289 }
290 }
291
292 if ( QFile::exists( "~/Applications/todolist/todolist.db" )
293 && !QFile::exists( "~/Applications/todolist/todolist.db_v2" ) ){
294 QString todo_convert_string = "cd ~/Applications/todolist/;cp todolist.db todolist.db_v2;sqlite todolist.db_v2 .dump | sqlite3 todolist.db";
295 odebug << "3. Todolist Command:" << todo_convert_string << oendl;
296 if ( system( todo_convert_string ) != 0 ){
297 QMessageBox::critical( this, "Pim-Converter",
298 QString("An internal error occurred:\n") +
299 "Converting the todolist command was impossible!\n"+
300 "Executed the following command:\n" +
301 todo_convert_string );
302 return;
303 }
304 }
305
306 QMessageBox::information( this, "Pim-Converter",
307 "Conversion is finished!",
308 "&OK", NULL, NULL,
309 0, // Enter == button 0
310 0 );
311
312
313}