author | eilers <eilers> | 2004-10-25 10:02:52 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-10-25 10:02:52 (UTC) |
commit | af0556afccb9df439bd826bb6028e05560d2910a (patch) (unidiff) | |
tree | 39a8f735e0d8d13da9c073e0407bae8431dbf138 | |
parent | ed6b09bab91bf21d33ebef1ea49fdb049e10453b (diff) | |
download | opie-af0556afccb9df439bd826bb6028e05560d2910a.zip opie-af0556afccb9df439bd826bb6028e05560d2910a.tar.gz opie-af0556afccb9df439bd826bb6028e05560d2910a.tar.bz2 |
Fixing some problems..
-rw-r--r-- | noncore/tools/pimconverter/converter.cpp | 98 | ||||
-rwxr-xr-x | noncore/tools/pimconverter/converter.h | 2 |
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 | |||
@@ -1,334 +1,342 @@ | |||
1 | #include "converter.h" | 1 | #include "converter.h" |
2 | 2 | ||
3 | #include <stdlib.h> // For "system()" command | 3 | #include <stdlib.h> // For "system()" command |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <opie2/oapplicationfactory.h> | 6 | #include <opie2/oapplicationfactory.h> |
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <opie2/opimglobal.h> | 8 | #include <opie2/opimglobal.h> |
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | // Include SQL related header files | 10 | // Include SQL related header files |
11 | #define __USE_SQL | 11 | #define __USE_SQL |
12 | #include <opie2/opimaccessfactory.h> | 12 | #include <opie2/opimaccessfactory.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qdatetime.h> | 15 | #include <qdatetime.h> |
16 | #include <qprogressbar.h> | 16 | #include <qprogressbar.h> |
17 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
18 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | 20 | ||
21 | 21 | ||
22 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<Converter> ) | 22 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<Converter> ) |
23 | 23 | ||
24 | using namespace Opie; | 24 | using namespace Opie; |
25 | using namespace Pim; | 25 | using namespace Pim; |
26 | 26 | ||
27 | Converter::Converter(QWidget *p, const char* n, WFlags fl): | 27 | Converter::Converter(QWidget *p, const char* n, WFlags fl): |
28 | converter_base( p, n, fl ), | 28 | converter_base( p, n, fl ), |
29 | m_selectedDatabase( ADDRESSBOOK ), | 29 | m_selectedDatabase( ADDRESSBOOK ), |
30 | m_selectedSourceFormat( XML ), | 30 | m_selectedSourceFormat( XML ), |
31 | m_selectedDestFormat( SQL ), | 31 | m_selectedDestFormat( SQL ), |
32 | m_criticalState( false ) | 32 | m_criticalState( false ) |
33 | { | 33 | { |
34 | m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); | 34 | m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); |
35 | m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); | 35 | m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); |
36 | m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); | 36 | m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); |
37 | m_eraseDB -> setChecked( true ); // Default erase on copy | 37 | m_eraseDB -> setChecked( true ); // Default erase on copy |
38 | } | 38 | } |
39 | 39 | ||
40 | void Converter::selectedDatabase( int num ) | 40 | void Converter::selectedDatabase( int num ) |
41 | { | 41 | { |
42 | m_selectedDatabase = num; | 42 | m_selectedDatabase = num; |
43 | } | 43 | } |
44 | 44 | ||
45 | void Converter::selectedDestFormat( int num ) | 45 | void Converter::selectedDestFormat( int num ) |
46 | { | 46 | { |
47 | m_selectedDestFormat = num; | 47 | m_selectedDestFormat = num; |
48 | } | 48 | } |
49 | 49 | ||
50 | void Converter::selectedSourceFormat( int num ) | 50 | void Converter::selectedSourceFormat( int num ) |
51 | { | 51 | { |
52 | m_selectedSourceFormat = num; | 52 | m_selectedSourceFormat = num; |
53 | } | 53 | } |
54 | 54 | ||
55 | void Converter::start_conversion(){ | 55 | void Converter::start_conversion(){ |
56 | 56 | ||
57 | // Creating backends to the requested databases.. | 57 | // Creating backends to the requested databases.. |
58 | OPimBase* sourceDB; | 58 | OPimBase* sourceDB; |
59 | OPimBase* destDB; | 59 | OPimBase* destDB; |
60 | 60 | ||
61 | odebug << "SourceFormat: " << m_selectedSourceFormat << oendl; | 61 | odebug << "SourceFormat: " << m_selectedSourceFormat << oendl; |
62 | odebug << "DestFormat: " << m_selectedDestFormat << oendl; | 62 | odebug << "DestFormat: " << m_selectedDestFormat << oendl; |
63 | if ( m_selectedSourceFormat == m_selectedDestFormat ){ | 63 | if ( m_selectedSourceFormat == m_selectedDestFormat ){ |
64 | 64 | ||
65 | QMessageBox::warning( this, tr("PimConverter"), | 65 | QMessageBox::warning( this, tr("PimConverter"), |
66 | tr( "<qt>It is not a good idea to use" | 66 | tr( "<qt>It is not a good idea to use" |
67 | "the same source and destformat !</qt>")); | 67 | "the same source and destformat !</qt>")); |
68 | return; | 68 | return; |
69 | } | 69 | } |
70 | 70 | ||
71 | switch( m_selectedSourceFormat ){ | 71 | switch( m_selectedSourceFormat ){ |
72 | case XML: | 72 | case XML: |
73 | odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; | 73 | odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; |
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" ); |
81 | }break; | 81 | }break; |
82 | case DATEBOOK:{ | 82 | case DATEBOOK:{ |
83 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); | 83 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
84 | } | 84 | } |
85 | break; | 85 | break; |
86 | default: | 86 | default: |
87 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 87 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
88 | return; | 88 | return; |
89 | } | 89 | } |
90 | break; | 90 | break; |
91 | case SQL: | 91 | case SQL: |
92 | odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; | 92 | odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; |
93 | switch( m_selectedDatabase ){ | 93 | switch( m_selectedDatabase ){ |
94 | case ADDRESSBOOK:{ | 94 | case ADDRESSBOOK:{ |
95 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); | 95 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
96 | } | 96 | } |
97 | break; | 97 | break; |
98 | case TODOLIST:{ | 98 | case TODOLIST:{ |
99 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); | 99 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
100 | }break; | 100 | }break; |
101 | case DATEBOOK:{ | 101 | case DATEBOOK:{ |
102 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); | 102 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
103 | } | 103 | } |
104 | break; | 104 | break; |
105 | default: | 105 | default: |
106 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 106 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | break; | 109 | break; |
110 | default: | 110 | default: |
111 | owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; | 111 | owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | 114 | ||
115 | switch ( m_selectedDestFormat ){ | 115 | switch ( m_selectedDestFormat ){ |
116 | case XML: | 116 | case XML: |
117 | odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; | 117 | odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; |
118 | switch( m_selectedDatabase ){ | 118 | switch( m_selectedDatabase ){ |
119 | case ADDRESSBOOK:{ | 119 | case ADDRESSBOOK:{ |
120 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); | 120 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
121 | } | 121 | } |
122 | break; | 122 | break; |
123 | case TODOLIST:{ | 123 | case TODOLIST:{ |
124 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); | 124 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
125 | }break; | 125 | }break; |
126 | case DATEBOOK:{ | 126 | case DATEBOOK:{ |
127 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); | 127 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
128 | } | 128 | } |
129 | break; | 129 | break; |
130 | default: | 130 | default: |
131 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 131 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | case SQL: | 135 | case SQL: |
136 | odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; | 136 | odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; |
137 | switch( m_selectedDatabase ){ | 137 | switch( m_selectedDatabase ){ |
138 | case ADDRESSBOOK:{ | 138 | case ADDRESSBOOK:{ |
139 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); | 139 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
140 | } | 140 | } |
141 | break; | 141 | break; |
142 | case TODOLIST:{ | 142 | case TODOLIST:{ |
143 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); | 143 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
144 | }break; | 144 | }break; |
145 | case DATEBOOK:{ | 145 | case DATEBOOK:{ |
146 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); | 146 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
147 | } | 147 | } |
148 | break; | 148 | break; |
149 | default: | 149 | default: |
150 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 150 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | break; | 153 | break; |
154 | default: | 154 | default: |
155 | owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; | 155 | owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | 158 | ||
159 | if ( !sourceDB || !destDB ) | 159 | if ( !sourceDB || !destDB ) |
160 | return; | 160 | return; |
161 | 161 | ||
162 | m_criticalState = true; | 162 | m_criticalState = true; |
163 | 163 | ||
164 | sourceDB -> load(); | 164 | sourceDB -> load(); |
165 | destDB -> load(); | 165 | destDB -> load(); |
166 | 166 | ||
167 | QTime t; | 167 | QTime t; |
168 | t.start(); | 168 | t.start(); |
169 | 169 | ||
170 | // Clean the dest-database if requested (isChecked) | 170 | // Clean the dest-database if requested (isChecked) |
171 | if ( m_eraseDB -> isChecked() ){ | 171 | if ( m_eraseDB -> isChecked() ){ |
172 | odebug << "Clearing destination database!" << oendl; | 172 | odebug << "Clearing destination database!" << oendl; |
173 | destDB -> clear(); | 173 | destDB -> clear(); |
174 | } | 174 | } |
175 | 175 | ||
176 | // Now transmit every pim-item from the source database to the destination -database | 176 | // Now transmit every pim-item from the source database to the destination -database |
177 | QArray<int> uidList = sourceDB->records(); | 177 | QArray<int> uidList = sourceDB->records(); |
178 | odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; | 178 | odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; |
179 | m_progressBar->setTotalSteps( uidList.count() ); | 179 | m_progressBar->setTotalSteps( uidList.count() ); |
180 | int count = 0; | 180 | int count = 0; |
181 | for ( uint i = 0; i < uidList.count(); ++i ){ | 181 | for ( uint i = 0; i < uidList.count(); ++i ){ |
182 | odebug << "Adding uid: " << uidList[i] << "" << oendl; | 182 | odebug << "Adding uid: " << uidList[i] << "" << oendl; |
183 | OPimRecord* rec = sourceDB -> record( uidList[i] ); | 183 | OPimRecord* rec = sourceDB -> record( uidList[i] ); |
184 | destDB -> add( rec ); | 184 | destDB -> add( rec ); |
185 | m_progressBar->setProgress( ++count ); | 185 | m_progressBar->setProgress( ++count ); |
186 | } | 186 | } |
187 | 187 | ||
188 | // Now commit data.. | 188 | // Now commit data.. |
189 | destDB -> save(); | 189 | destDB -> save(); |
190 | 190 | ||
191 | m_criticalState = false; | 191 | m_criticalState = false; |
192 | 192 | ||
193 | // Delete the frontends. Backends will be deleted automatically, too ! | 193 | // Delete the frontends. Backends will be deleted automatically, too ! |
194 | // We have to cast them back to delete them properly ! | 194 | // We have to cast them back to delete them properly ! |
195 | switch( m_selectedDatabase ){ | 195 | switch( m_selectedDatabase ){ |
196 | case ADDRESSBOOK: | 196 | case ADDRESSBOOK: |
197 | delete static_cast<OPimContactAccess*> (sourceDB); | 197 | delete static_cast<OPimContactAccess*> (sourceDB); |
198 | delete static_cast<OPimContactAccess*> (destDB); | 198 | delete static_cast<OPimContactAccess*> (destDB); |
199 | break; | 199 | break; |
200 | case TODOLIST: | 200 | case TODOLIST: |
201 | delete static_cast<OPimTodoAccess*> (sourceDB); | 201 | delete static_cast<OPimTodoAccess*> (sourceDB); |
202 | delete static_cast<OPimTodoAccess*> (destDB); | 202 | delete static_cast<OPimTodoAccess*> (destDB); |
203 | break; | 203 | break; |
204 | case DATEBOOK: | 204 | case DATEBOOK: |
205 | delete static_cast<ODateBookAccess*> (sourceDB); | 205 | delete static_cast<ODateBookAccess*> (sourceDB); |
206 | delete static_cast<ODateBookAccess*> (destDB); | 206 | delete static_cast<ODateBookAccess*> (destDB); |
207 | break; | 207 | break; |
208 | default: | 208 | default: |
209 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 209 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; | 214 | owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; |
215 | } | 215 | } |
216 | 216 | ||
217 | void Converter::closeEvent( QCloseEvent *e ) | 217 | void Converter::closeEvent( QCloseEvent *e ) |
218 | { | 218 | { |
219 | 219 | ||
220 | /* Due to the fact that we don't have multitasking here, this | 220 | /* Due to the fact that we don't have multitasking here, this |
221 | * critical handling don't make sense, but the future.. | 221 | * critical handling don't make sense, but the future.. |
222 | */ | 222 | */ |
223 | if ( m_criticalState ){ | 223 | if ( m_criticalState ){ |
224 | e->ignore(); | 224 | e->ignore(); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | e->accept(); | 227 | e->accept(); |
228 | } | 228 | } |
229 | 229 | ||
230 | bool Converter::sqliteCopyAndConvert(const QString& src, const QString &dest, QString &cmd) | 230 | bool 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 | ||
264 | 287 | ||
265 | void Converter::start_upgrade() | 288 | void Converter::start_upgrade() |
266 | { | 289 | { |
267 | odebug << "Start upgrading" << oendl; | 290 | odebug << "Start upgrading" << oendl; |
268 | switch( QMessageBox::warning( this, tr("Pim-Converter"), | 291 | switch( QMessageBox::warning( this, tr("Pim-Converter"), |
269 | tr("<qt>Are you really sure that you " | 292 | tr("<qt>Are you really sure that you " |
270 | "want to convert your database from " | 293 | "want to convert your database from " |
271 | "sqlite V2 to sqlite V3?</qt>"), | 294 | "sqlite V2 to sqlite V3?</qt>"), |
272 | QMessageBox::Ok | QMessageBox::Default, | 295 | QMessageBox::Ok | QMessageBox::Default, |
273 | QMessageBox::Abort | QMessageBox::Escape )) { | 296 | QMessageBox::Abort | QMessageBox::Escape )) { |
274 | 297 | ||
275 | case QMessageBox::Abort: // Abort clicked or Escape pressed | 298 | case QMessageBox::Abort: // Abort clicked or Escape pressed |
276 | // abort | 299 | // abort |
277 | return; | 300 | return; |
278 | break; | 301 | break; |
279 | } | 302 | } |
280 | odebug << "Checking whether sqlite is installed" << oendl; | 303 | odebug << "Checking whether sqlite is installed" << oendl; |
281 | if ( system( "which sqlite" ) != 0 ){ | 304 | if ( system( "which sqlite" ) != 0 ){ |
282 | QMessageBox::critical( this, tr("Pim-Converter"), | 305 | QMessageBox::critical( this, tr("Pim-Converter"), |
283 | tr("<qt>An internal error occurred: " | 306 | tr("<qt>An internal error occurred: " |
284 | "sqlite was not accessible! " | 307 | "sqlite was not accessible! " |
285 | "Please correct the PATH or install " | 308 | "Please correct the PATH or install " |
286 | "this packages!</qt>") ); | 309 | "this packages!</qt>") ); |
287 | return; | 310 | return; |
288 | } | 311 | } |
289 | if ( system( "which sqlite3" ) != 0 ){ | 312 | if ( system( "which sqlite3" ) != 0 ){ |
290 | QMessageBox::critical( this, tr("Pim-Converter"), | 313 | QMessageBox::critical( this, tr("Pim-Converter"), |
291 | tr("<qt>An internal error occurred: " | 314 | tr("<qt>An internal error occurred: " |
292 | "sqlite3 was not accessible! " | 315 | "sqlite3 was not accessible! " |
293 | "Please correct the PATH or install " | 316 | "Please correct the PATH or install " |
294 | "this packages!</qt>") ); | 317 | "this packages!</qt>") ); |
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 | |||
@@ -1,49 +1,49 @@ | |||
1 | #ifndef _CONVERTER_H_ | 1 | #ifndef _CONVERTER_H_ |
2 | #define _CONVERTER_H_ | 2 | #define _CONVERTER_H_ |
3 | 3 | ||
4 | 4 | ||
5 | #include "converter_base.h" | 5 | #include "converter_base.h" |
6 | 6 | ||
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 start_upgrade(); |
16 | void selectedDatabase( int num ); | 16 | void selectedDatabase( int num ); |
17 | void selectedDestFormat( int num ); | 17 | void selectedDestFormat( int num ); |
18 | void selectedSourceFormat( int num ); | 18 | void selectedSourceFormat( int num ); |
19 | 19 | ||
20 | void closeEvent( QCloseEvent *e ); | 20 | void closeEvent( QCloseEvent *e ); |
21 | 21 | ||
22 | private: | 22 | private: |
23 | // Caution: | 23 | // Caution: |
24 | // The order and value of the following enums must be regarding | 24 | // The order and value of the following enums must be regarding |
25 | // 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!! | 26 | // If you don't understand what I am talking about: Keep your fingers away!! |
27 | enum DataBases{ | 27 | enum DataBases{ |
28 | ADDRESSBOOK = 0, | 28 | ADDRESSBOOK = 0, |
29 | TODOLIST = 1, | 29 | TODOLIST = 1, |
30 | DATEBOOK = 2, | 30 | DATEBOOK = 2, |
31 | }; | 31 | }; |
32 | 32 | ||
33 | enum DbFormats{ | 33 | enum DbFormats{ |
34 | XML = 0, | 34 | XML = 0, |
35 | SQL = 1, | 35 | SQL = 1, |
36 | }; | 36 | }; |
37 | 37 | ||
38 | int m_selectedDatabase; | 38 | int m_selectedDatabase; |
39 | int m_selectedSourceFormat; | 39 | int m_selectedSourceFormat; |
40 | int m_selectedDestFormat; | 40 | int m_selectedDestFormat; |
41 | bool m_criticalState; | 41 | bool m_criticalState; |
42 | 42 | ||
43 | 43 | ||
44 | private: | 44 | private: |
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 | ||
49 | #endif | 49 | #endif |