summaryrefslogtreecommitdiff
path: root/noncore/tools
authoreilers <eilers>2004-10-23 12:05:13 (UTC)
committer eilers <eilers>2004-10-23 12:05:13 (UTC)
commitaac8188fde70fc5cfa9f44c6a80a907e44f0f1eb (patch) (unidiff)
tree37b683afa01b06245f81ff13cf8362e9f6ab9378 /noncore/tools
parentf2a2eca1870e1fd88c82a6ccb039610949daa72c (diff)
downloadopie-aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb.zip
opie-aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb.tar.gz
opie-aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb.tar.bz2
Pimconverter got a button to convert databases from sqlite 2->3.
If correct implementation is confirmed, I will commit the rest..
Diffstat (limited to 'noncore/tools') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/pimconverter/converter.cpp87
-rwxr-xr-xnoncore/tools/pimconverter/converter.h2
-rw-r--r--noncore/tools/pimconverter/converter_base.ui62
3 files changed, 141 insertions, 10 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}
diff --git a/noncore/tools/pimconverter/converter.h b/noncore/tools/pimconverter/converter.h
index 344562a..9d75d79 100755
--- a/noncore/tools/pimconverter/converter.h
+++ b/noncore/tools/pimconverter/converter.h
@@ -12,6 +12,7 @@ public:
12 12
13 // Slots defined in the ui-description file 13 // Slots defined in the ui-description file
14 void start_conversion(); 14 void start_conversion();
15 void start_upgrade();
15 void selectedDatabase( int num ); 16 void selectedDatabase( int num );
16 void selectedDestFormat( int num ); 17 void selectedDestFormat( int num );
17 void selectedSourceFormat( int num ); 18 void selectedSourceFormat( int num );
@@ -22,6 +23,7 @@ private:
22 // Caution: 23 // Caution:
23 // The order and value of the following enums must be regarding 24 // The order and value of the following enums must be regarding
24 // the predefinition in the UI-File !! 25 // the predefinition in the UI-File !!
26 // If you don't understand what I am talking about: Keep your fingers away!!
25 enum DataBases{ 27 enum DataBases{
26 ADDRESSBOOK = 0, 28 ADDRESSBOOK = 0,
27 TODOLIST = 1, 29 TODOLIST = 1,
diff --git a/noncore/tools/pimconverter/converter_base.ui b/noncore/tools/pimconverter/converter_base.ui
index a5b22c9..b519f2e 100644
--- a/noncore/tools/pimconverter/converter_base.ui
+++ b/noncore/tools/pimconverter/converter_base.ui
@@ -11,8 +11,8 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>269</width> 14 <width>308</width>
15 <height>324</height> 15 <height>323</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
@@ -57,6 +57,17 @@
57 <number>2</number> 57 <number>2</number>
58 </property> 58 </property>
59 <widget> 59 <widget>
60 <class>QPushButton</class>
61 <property stdset="1">
62 <name>name</name>
63 <cstring>PushButton2</cstring>
64 </property>
65 <property stdset="1">
66 <name>text</name>
67 <string>Upgrade to SQLite3</string>
68 </property>
69 </widget>
70 <widget>
60 <class>QGroupBox</class> 71 <class>QGroupBox</class>
61 <property stdset="1"> 72 <property stdset="1">
62 <name>name</name> 73 <name>name</name>
@@ -66,14 +77,20 @@
66 <name>title</name> 77 <name>title</name>
67 <string>Select Database:</string> 78 <string>Select Database:</string>
68 </property> 79 </property>
80 <property>
81 <name>layoutMargin</name>
82 </property>
83 <property>
84 <name>layoutSpacing</name>
85 </property>
69 <grid> 86 <grid>
70 <property stdset="1"> 87 <property stdset="1">
71 <name>margin</name> 88 <name>margin</name>
72 <number>11</number> 89 <number>4</number>
73 </property> 90 </property>
74 <property stdset="1"> 91 <property stdset="1">
75 <name>spacing</name> 92 <name>spacing</name>
76 <number>6</number> 93 <number>2</number>
77 </property> 94 </property>
78 <widget row="0" column="1" > 95 <widget row="0" column="1" >
79 <class>QComboBox</class> 96 <class>QComboBox</class>
@@ -112,14 +129,20 @@
112 <name>title</name> 129 <name>title</name>
113 <string>Source/Destination:</string> 130 <string>Source/Destination:</string>
114 </property> 131 </property>
132 <property>
133 <name>layoutMargin</name>
134 </property>
135 <property>
136 <name>layoutSpacing</name>
137 </property>
115 <grid> 138 <grid>
116 <property stdset="1"> 139 <property stdset="1">
117 <name>margin</name> 140 <name>margin</name>
118 <number>11</number> 141 <number>4</number>
119 </property> 142 </property>
120 <property stdset="1"> 143 <property stdset="1">
121 <name>spacing</name> 144 <name>spacing</name>
122 <number>6</number> 145 <number>2</number>
123 </property> 146 </property>
124 <widget row="1" column="0" > 147 <widget row="1" column="0" >
125 <class>QLabel</class> 148 <class>QLabel</class>
@@ -193,14 +216,20 @@
193 <name>title</name> 216 <name>title</name>
194 <string>Config:</string> 217 <string>Config:</string>
195 </property> 218 </property>
219 <property>
220 <name>layoutMargin</name>
221 </property>
222 <property>
223 <name>layoutSpacing</name>
224 </property>
196 <grid> 225 <grid>
197 <property stdset="1"> 226 <property stdset="1">
198 <name>margin</name> 227 <name>margin</name>
199 <number>11</number> 228 <number>4</number>
200 </property> 229 </property>
201 <property stdset="1"> 230 <property stdset="1">
202 <name>spacing</name> 231 <name>spacing</name>
203 <number>6</number> 232 <number>4</number>
204 </property> 233 </property>
205 <widget row="0" column="0" > 234 <widget row="0" column="0" >
206 <class>QCheckBox</class> 235 <class>QCheckBox</class>
@@ -225,14 +254,20 @@
225 <name>title</name> 254 <name>title</name>
226 <string>Progress:</string> 255 <string>Progress:</string>
227 </property> 256 </property>
257 <property>
258 <name>layoutMargin</name>
259 </property>
260 <property>
261 <name>layoutSpacing</name>
262 </property>
228 <vbox> 263 <vbox>
229 <property stdset="1"> 264 <property stdset="1">
230 <name>margin</name> 265 <name>margin</name>
231 <number>11</number> 266 <number>4</number>
232 </property> 267 </property>
233 <property stdset="1"> 268 <property stdset="1">
234 <name>spacing</name> 269 <name>spacing</name>
235 <number>6</number> 270 <number>2</number>
236 </property> 271 </property>
237 <widget> 272 <widget>
238 <class>QProgressBar</class> 273 <class>QProgressBar</class>
@@ -283,9 +318,16 @@
283 <receiver>converter_base</receiver> 318 <receiver>converter_base</receiver>
284 <slot>selectedDestFormat(int)</slot> 319 <slot>selectedDestFormat(int)</slot>
285 </connection> 320 </connection>
321 <connection>
322 <sender>PushButton2</sender>
323 <signal>clicked()</signal>
324 <receiver>converter_base</receiver>
325 <slot>start_upgrade()</slot>
326 </connection>
286 <slot access="public">selectedDatabase(int)</slot> 327 <slot access="public">selectedDatabase(int)</slot>
287 <slot access="public">selectedDestFormat(int)</slot> 328 <slot access="public">selectedDestFormat(int)</slot>
288 <slot access="public">selectedSourceFormat(int)</slot> 329 <slot access="public">selectedSourceFormat(int)</slot>
289 <slot access="public">start_conversion()</slot> 330 <slot access="public">start_conversion()</slot>
331 <slot access="public">start_upgrade()</slot>
290</connections> 332</connections>
291</UI> 333</UI>