From 34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 22 Sep 2003 14:31:15 +0000 Subject: Added first experimental incarnation of sql-backend for addressbook. Some modifications to be able to compile the todo sql-backend. A lot of changes fill follow... --- (limited to 'libopie/pim/test/converter.cpp') 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 @@ +#include + +#include +#include +#include + +#include "converter_base.h" + +class ConvertXMLToSQL: public converter_base { +public: + ConvertXMLToSQL() + { + convertContact(); + } +private: + void convertContact(); + +}; + + +void ConvertXMLToSQL::convertContact(){ + qWarning("Converting Contacts from XML to SQL.."); + + // Creating backends to the requested databases.. + OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter", + QString::null ); + + OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null, + QString::null ); + // Put the created backends into frontends to access them + OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml", + QString::null , xmlBackend, true ); + + OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", + QString::null , sqlBackend, true ); + + // Clean the sql-database.. + sqlAccess->clear(); + + // Now trasmit every contact from the xml database to the sql-database + OContactAccess::List contactList = xmlAccess->allRecords(); + if ( sqlAccess && xmlAccess ){ + OContactAccess::List::Iterator it; + for ( it = contactList.begin(); it != contactList.end(); ++it ) + sqlAccess->add( *it ); + } + + // Delete the frontends. Backends will be deleted automatically, too ! + delete sqlAccess; + delete xmlAccess; +} + +int main( int argc, char** argv ) { + + QPEApplication a( argc, argv ); + + ConvertXMLToSQL dlg; + + a.showMainWidget( &dlg ); + // dlg. showMaximized ( ); + + return a.exec(); + +} -- cgit v0.9.0.2