summaryrefslogtreecommitdiff
path: root/libopie/pim/test/converter.cpp
Unidiff
Diffstat (limited to 'libopie/pim/test/converter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/test/converter.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp
new file mode 100644
index 0000000..0a488f2
--- a/dev/null
+++ b/libopie/pim/test/converter.cpp
@@ -0,0 +1,64 @@
1#include <qpe/qpeapplication.h>
2
3#include <opie/ocontactaccess.h>
4#include <opie/ocontactaccessbackend_xml.h>
5#include <opie/ocontactaccessbackend_sql.h>
6
7#include "converter_base.h"
8
9class ConvertXMLToSQL: public converter_base {
10public:
11 ConvertXMLToSQL()
12 {
13 convertContact();
14 }
15private:
16 void convertContact();
17
18};
19
20
21void ConvertXMLToSQL::convertContact(){
22 qWarning("Converting Contacts from XML to SQL..");
23
24 // Creating backends to the requested databases..
25 OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
26 QString::null );
27
28 OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null,
29 QString::null );
30 // Put the created backends into frontends to access them
31 OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml",
32 QString::null , xmlBackend, true );
33
34 OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql",
35 QString::null , sqlBackend, true );
36
37 // Clean the sql-database..
38 sqlAccess->clear();
39
40 // Now trasmit every contact from the xml database to the sql-database
41 OContactAccess::List contactList = xmlAccess->allRecords();
42 if ( sqlAccess && xmlAccess ){
43 OContactAccess::List::Iterator it;
44 for ( it = contactList.begin(); it != contactList.end(); ++it )
45 sqlAccess->add( *it );
46 }
47
48 // Delete the frontends. Backends will be deleted automatically, too !
49 delete sqlAccess;
50 delete xmlAccess;
51}
52
53int main( int argc, char** argv ) {
54
55 QPEApplication a( argc, argv );
56
57 ConvertXMLToSQL dlg;
58
59 a.showMainWidget( &dlg );
60 // dlg. showMaximized ( );
61
62 return a.exec();
63
64}