-rw-r--r-- | noncore/tools/pimconverter/converter.cpp | 87 | ||||
-rwxr-xr-x | noncore/tools/pimconverter/converter.h | 2 | ||||
-rw-r--r-- | noncore/tools/pimconverter/converter_base.ui | 62 |
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,10 +1,12 @@ | |||
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> |
6 | #include <opie2/opimglobal.h> | 8 | #include <opie2/opimglobal.h> |
7 | // Include SQL related header files | 9 | // Include SQL related header files |
8 | #define __USE_SQL | 10 | #define __USE_SQL |
9 | #include <opie2/opimaccessfactory.h> | 11 | #include <opie2/opimaccessfactory.h> |
10 | 12 | ||
@@ -219,8 +221,93 @@ void Converter::closeEvent( QCloseEvent *e ) | |||
219 | * critical handling don't make sense, but the future.. | 221 | * critical handling don't make sense, but the future.. |
220 | */ | 222 | */ |
221 | if ( m_criticalState ){ | 223 | if ( m_criticalState ){ |
222 | e->ignore(); | 224 | e->ignore(); |
223 | return; | 225 | return; |
224 | } | 226 | } |
225 | e->accept(); | 227 | e->accept(); |
226 | } | 228 | } |
229 | |||
230 | |||
231 | |||
232 | void 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 | |||
@@ -7,26 +7,28 @@ | |||
7 | 7 | ||
8 | class Converter: public converter_base { | 8 | class Converter: public converter_base { |
9 | public: | 9 | public: |
10 | Converter(QWidget *parent, const char* name, WFlags fl); | 10 | Converter(QWidget *parent, const char* name, WFlags fl); |
11 | static QString appName() { return QString::fromLatin1("opimconverter");} | 11 | static QString appName() { return QString::fromLatin1("opimconverter");} |
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 ); |
18 | 19 | ||
19 | void closeEvent( QCloseEvent *e ); | 20 | void closeEvent( QCloseEvent *e ); |
20 | 21 | ||
21 | private: | 22 | 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, |
28 | DATEBOOK = 2, | 30 | DATEBOOK = 2, |
29 | }; | 31 | }; |
30 | 32 | ||
31 | enum DbFormats{ | 33 | enum DbFormats{ |
32 | XML = 0, | 34 | XML = 0, |
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 | |||
@@ -6,18 +6,18 @@ | |||
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>converter_base</cstring> | 7 | <cstring>converter_base</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
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"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>PIM-Database Converter</string> | 20 | <string>PIM-Database Converter</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
@@ -52,33 +52,50 @@ | |||
52 | <name>margin</name> | 52 | <name>margin</name> |
53 | <number>4</number> | 53 | <number>4</number> |
54 | </property> | 54 | </property> |
55 | <property stdset="1"> | 55 | <property stdset="1"> |
56 | <name>spacing</name> | 56 | <name>spacing</name> |
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> |
63 | <cstring>GroupBox1</cstring> | 74 | <cstring>GroupBox1</cstring> |
64 | </property> | 75 | </property> |
65 | <property stdset="1"> | 76 | <property stdset="1"> |
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> |
80 | <item> | 97 | <item> |
81 | <property> | 98 | <property> |
82 | <name>text</name> | 99 | <name>text</name> |
83 | <string>Addressbook</string> | 100 | <string>Addressbook</string> |
84 | </property> | 101 | </property> |
@@ -107,24 +124,30 @@ | |||
107 | <property stdset="1"> | 124 | <property stdset="1"> |
108 | <name>name</name> | 125 | <name>name</name> |
109 | <cstring>GroupBox2</cstring> | 126 | <cstring>GroupBox2</cstring> |
110 | </property> | 127 | </property> |
111 | <property stdset="1"> | 128 | <property stdset="1"> |
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> |
126 | <property stdset="1"> | 149 | <property stdset="1"> |
127 | <name>name</name> | 150 | <name>name</name> |
128 | <cstring>TextLabel3_2</cstring> | 151 | <cstring>TextLabel3_2</cstring> |
129 | </property> | 152 | </property> |
130 | <property stdset="1"> | 153 | <property stdset="1"> |
@@ -188,24 +211,30 @@ | |||
188 | <property stdset="1"> | 211 | <property stdset="1"> |
189 | <name>name</name> | 212 | <name>name</name> |
190 | <cstring>GroupBox5</cstring> | 213 | <cstring>GroupBox5</cstring> |
191 | </property> | 214 | </property> |
192 | <property stdset="1"> | 215 | <property stdset="1"> |
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> |
207 | <property stdset="1"> | 236 | <property stdset="1"> |
208 | <name>name</name> | 237 | <name>name</name> |
209 | <cstring>m_eraseDB</cstring> | 238 | <cstring>m_eraseDB</cstring> |
210 | </property> | 239 | </property> |
211 | <property stdset="1"> | 240 | <property stdset="1"> |
@@ -220,24 +249,30 @@ | |||
220 | <property stdset="1"> | 249 | <property stdset="1"> |
221 | <name>name</name> | 250 | <name>name</name> |
222 | <cstring>GroupBox4</cstring> | 251 | <cstring>GroupBox4</cstring> |
223 | </property> | 252 | </property> |
224 | <property stdset="1"> | 253 | <property stdset="1"> |
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> |
239 | <property stdset="1"> | 274 | <property stdset="1"> |
240 | <name>name</name> | 275 | <name>name</name> |
241 | <cstring>m_progressBar</cstring> | 276 | <cstring>m_progressBar</cstring> |
242 | </property> | 277 | </property> |
243 | </widget> | 278 | </widget> |
@@ -278,14 +313,21 @@ | |||
278 | <slot>selectedDatabase(int)</slot> | 313 | <slot>selectedDatabase(int)</slot> |
279 | </connection> | 314 | </connection> |
280 | <connection> | 315 | <connection> |
281 | <sender>m_destFormatSelector</sender> | 316 | <sender>m_destFormatSelector</sender> |
282 | <signal>activated(int)</signal> | 317 | <signal>activated(int)</signal> |
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> |