author | eilers <eilers> | 2004-05-16 15:24:11 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-05-16 15:24:11 (UTC) |
commit | 680c8c7a6db8f5b79a6541629f54465709b79b02 (patch) (unidiff) | |
tree | 9d9b4c0d913ba14ac73bf5339ce2f259a10b33fa | |
parent | 703b468052367682959f0e1494eec4b3d12754a8 (diff) | |
download | opie-680c8c7a6db8f5b79a6541629f54465709b79b02.zip opie-680c8c7a6db8f5b79a6541629f54465709b79b02.tar.gz opie-680c8c7a6db8f5b79a6541629f54465709b79b02.tar.bz2 |
Opie PIM-Converter now uses the new OPimAccessFactory template..
-rw-r--r-- | noncore/tools/pimconverter/converter.cpp | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/noncore/tools/pimconverter/converter.cpp b/noncore/tools/pimconverter/converter.cpp index 1091f4a..2bd47a4 100644 --- a/noncore/tools/pimconverter/converter.cpp +++ b/noncore/tools/pimconverter/converter.cpp | |||
@@ -4,27 +4,19 @@ | |||
4 | #include <qprogressbar.h> | 4 | #include <qprogressbar.h> |
5 | #include <qcombobox.h> | 5 | #include <qcombobox.h> |
6 | #include <qcheckbox.h> | 6 | #include <qcheckbox.h> |
7 | 7 | ||
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | #include <opie2/ocontactaccess.h> | 10 | #include <opie2/opimglobal.h> |
11 | #include <opie2/ocontactaccessbackend_xml.h> | 11 | // Include SQL related header files |
12 | #include <opie2/ocontactaccessbackend_sql.h> | 12 | #define __USE_SQL |
13 | 13 | #include <opie2/opimaccessfactory.h> | |
14 | #include <opie2/otodoaccess.h> | ||
15 | #include <opie2/otodoaccessxml.h> | ||
16 | #include <opie2/otodoaccesssql.h> | ||
17 | |||
18 | #include <opie2/odatebookaccess.h> | ||
19 | #include <opie2/odatebookaccessbackend_xml.h> | ||
20 | #include <opie2/odatebookaccessbackend_sql.h> | ||
21 | |||
22 | // #define _ADDRESSBOOK_ACCESS | ||
23 | 14 | ||
24 | using namespace Opie; | 15 | using namespace Opie; |
16 | using namespace Pim; | ||
25 | 17 | ||
26 | Converter::Converter(): | 18 | Converter::Converter(): |
27 | m_selectedDatabase( ADDRESSBOOK ), | 19 | m_selectedDatabase( ADDRESSBOOK ), |
28 | m_selectedSourceFormat( XML ), | 20 | m_selectedSourceFormat( XML ), |
29 | m_selectedDestFormat( SQL ) | 21 | m_selectedDestFormat( SQL ) |
30 | { | 22 | { |
@@ -57,47 +49,40 @@ void Converter::start_conversion(){ | |||
57 | 49 | ||
58 | switch( m_selectedSourceFormat ){ | 50 | switch( m_selectedSourceFormat ){ |
59 | case XML: | 51 | case XML: |
60 | qDebug("XMLSourceDB = %d", m_selectedDatabase); | 52 | qDebug("XMLSourceDB = %d", m_selectedDatabase); |
61 | switch( m_selectedDatabase ){ | 53 | switch( m_selectedDatabase ){ |
62 | case ADDRESSBOOK:{ | 54 | case ADDRESSBOOK:{ |
63 | OPimContactAccessBackend* sourceBackend = new OPimContactAccessBackend_XML( "Converter", QString::null ); | 55 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
64 | sourceDB = new OPimContactAccess ( "addressbook_xml", QString::null , sourceBackend, true ); | ||
65 | } | 56 | } |
66 | break; | 57 | break; |
67 | case TODOLIST:{ | 58 | case TODOLIST:{ |
68 | OPimTodoAccessBackend* sourceBackend = new OPimTodoAccessXML( "Converter" ); | 59 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
69 | sourceDB = new OPimTodoAccess( sourceBackend ); | ||
70 | }break; | 60 | }break; |
71 | case DATEBOOK:{ | 61 | case DATEBOOK:{ |
72 | ODateBookAccessBackend_XML* sourceBackend = new ODateBookAccessBackend_XML( "Converter", QString::null ); | 62 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
73 | sourceDB = new ODateBookAccess ( sourceBackend ); | ||
74 | } | 63 | } |
75 | break; | 64 | break; |
76 | default: | 65 | default: |
77 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 66 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); |
78 | return; | 67 | return; |
79 | } | 68 | } |
80 | break; | 69 | break; |
81 | case SQL: | 70 | case SQL: |
82 | qDebug("SQLSourceDB = %d", m_selectedDatabase); | 71 | qDebug("SQLSourceDB = %d", m_selectedDatabase); |
83 | switch( m_selectedDatabase ){ | 72 | switch( m_selectedDatabase ){ |
84 | case ADDRESSBOOK:{ | 73 | case ADDRESSBOOK:{ |
85 | qDebug("SQLSourceDB = %d", m_selectedDatabase); | 74 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
86 | OPimContactAccessBackend* sourceBackend = new OPimContactAccessBackend_SQL( QString::null, QString::null ); | 75 | } |
87 | sourceDB = new OPimContactAccess ( "Converter", QString::null, sourceBackend, true ); | ||
88 | } | ||
89 | break; | 76 | break; |
90 | case TODOLIST:{ | 77 | case TODOLIST:{ |
91 | OPimTodoAccessBackend* sourceBackend = new OPimTodoAccessBackendSQL( QString::null ); | 78 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
92 | sourceDB = new OPimTodoAccess( sourceBackend ); | ||
93 | }break; | 79 | }break; |
94 | case DATEBOOK: { | 80 | case DATEBOOK:{ |
95 | ODateBookAccessBackend_SQL* sourceBackend = new ODateBookAccessBackend_SQL( "Converter", QString::null ); | 81 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
96 | sourceDB = new ODateBookAccess ( sourceBackend ); | 82 | } |
97 | } | ||
98 | break; | 83 | break; |
99 | default: | 84 | default: |
100 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 85 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); |
101 | return; | 86 | return; |
102 | } | 87 | } |
103 | break; | 88 | break; |
@@ -108,46 +93,40 @@ void Converter::start_conversion(){ | |||
108 | 93 | ||
109 | switch ( m_selectedDestFormat ){ | 94 | switch ( m_selectedDestFormat ){ |
110 | case XML: | 95 | case XML: |
111 | qDebug("XMLDestDB = %d", m_selectedDatabase); | 96 | qDebug("XMLDestDB = %d", m_selectedDatabase); |
112 | switch( m_selectedDatabase ){ | 97 | switch( m_selectedDatabase ){ |
113 | case ADDRESSBOOK:{ | 98 | case ADDRESSBOOK:{ |
114 | OPimContactAccessBackend* destBackend = new OPimContactAccessBackend_XML( "Converter", QString::null ); | 99 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
115 | destDB = new OPimContactAccess ( "Converter", QString::null , destBackend, true ); | 100 | } |
116 | } | ||
117 | break; | 101 | break; |
118 | case TODOLIST:{ | 102 | case TODOLIST:{ |
119 | OPimTodoAccessBackend* destBackend = new OPimTodoAccessXML( "Converter" ); | 103 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
120 | destDB = new OPimTodoAccess( destBackend ); | ||
121 | }break; | 104 | }break; |
122 | case DATEBOOK:{ | 105 | case DATEBOOK:{ |
123 | ODateBookAccessBackend_XML* destBackend = new ODateBookAccessBackend_XML( "Converter", QString::null ); | 106 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
124 | destDB = new ODateBookAccess ( destBackend ); | 107 | } |
125 | } | ||
126 | break; | 108 | break; |
127 | default: | 109 | default: |
128 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 110 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); |
129 | return; | 111 | return; |
130 | } | 112 | } |
131 | break; | 113 | break; |
132 | case SQL: | 114 | case SQL: |
133 | qDebug("SQLDestDB = %d", m_selectedDatabase); | 115 | qDebug("SQLDestDB = %d", m_selectedDatabase); |
134 | switch( m_selectedDatabase ){ | 116 | switch( m_selectedDatabase ){ |
135 | case ADDRESSBOOK:{ | 117 | case ADDRESSBOOK:{ |
136 | OPimContactAccessBackend* destBackend = new OPimContactAccessBackend_SQL( QString::null, QString::null ); | 118 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
137 | destDB = new OPimContactAccess ( "addressbook_xml", QString::null , destBackend, true ); | 119 | } |
138 | } | ||
139 | break; | 120 | break; |
140 | case TODOLIST:{ | 121 | case TODOLIST:{ |
141 | OPimTodoAccessBackend* destBackend = new OPimTodoAccessBackendSQL( QString::null ); | 122 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
142 | destDB = new OPimTodoAccess( destBackend ); | ||
143 | }break; | 123 | }break; |
144 | case DATEBOOK:{ | 124 | case DATEBOOK:{ |
145 | ODateBookAccessBackend_SQL* destBackend = new ODateBookAccessBackend_SQL( "Converter", QString::null ); | 125 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
146 | destDB = new ODateBookAccess ( destBackend ); | 126 | } |
147 | } | ||
148 | break; | 127 | break; |
149 | default: | 128 | default: |
150 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 129 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); |
151 | return; | 130 | return; |
152 | } | 131 | } |
153 | break; | 132 | break; |