Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osqlmanager.cpp

Go to the documentation of this file.
00001 #include "osqlmanager.h"
00002 #include "osqlbackendmanager.h"
00003 #include "osqlitedriver.h"
00004 
00005 #include <stdlib.h>
00006 
00007 namespace Opie {
00008 namespace DB {
00009 
00010 OSQLManager::OSQLManager() {
00011 }
00012 OSQLBackEnd::ValueList OSQLManager::queryBackEnd() {
00013     m_list.clear();
00014     QString opie = QString::fromLatin1( getenv("OPIEDIR") );
00015 
00016     if ( !m_path.contains(opie) && !opie.isEmpty() )
00017         m_path << opie;
00018 
00019 
00020     OSQLBackEndManager mng( m_path );
00021     m_list = mng.scan();
00022     m_list += builtIn();
00023 
00024     return m_list;
00025 }
00026 /*
00027  * loading dso's is currently not enabled due problems with QLibrary
00028  * beeing in libqpe and not libqte
00029  */
00030 OSQLDriver* OSQLManager::load( const QString& name ) {
00031     OSQLDriver* driver = 0l;
00032 
00033     if ( name == "SQLite" ) {
00034         driver = new Opie::DB::Internal::OSQLiteDriver;
00035     }
00036     return driver;
00037 }
00038 /*
00039  * same as above
00040  */
00041 OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) {
00042     OSQLDriver *driver = 0l;
00043     if ( end.library() == "builtin" &&
00044          end.name() == "SQLite" )
00045         driver = new Opie::DB::Internal::OSQLiteDriver;
00046 
00047     return driver;
00048 }
00049 /*
00050  * let's find the a default with the highes preference
00051  */
00052 OSQLDriver* OSQLManager::standard() {
00053     OSQLDriver* driver =0l;
00054     if ( m_list.isEmpty() ) queryBackEnd();
00055     OSQLBackEnd::ValueList::Iterator it;
00056     OSQLBackEnd back;
00057     for ( it = m_list.begin(); it != m_list.end(); ++it ) {
00058         if ( (*it).isDefault() &&
00059              back.preference() < (*it).preference() ) {
00060             back = (*it);
00061         }
00062     }
00063     driver = load( back );
00064     return driver;
00065 }
00066 void OSQLManager::registerPath( const QString& path ) {
00067     m_path << path;
00068 }
00069 bool OSQLManager::unregisterPath( const QString& path ) {
00070     m_path.remove( path );
00071     return true;
00072 }
00073 OSQLBackEnd::ValueList OSQLManager::builtIn()const {
00074     OSQLBackEnd::ValueList list;
00075     // create the OSQLiteBackend
00076     OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" );
00077     back.setDefault( true );
00078     back.setPreference( 50 );
00079     list.append( back );
00080     return list;
00081 }
00082 
00083 
00084 }
00085 }

Generated on Sat Nov 5 16:16:10 2005 for OPIE by  doxygen 1.4.2