author | zecke <zecke> | 2004-03-13 19:51:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-13 19:51:45 (UTC) |
commit | 6d08277737e22b7a1527124623f3571969073ddf (patch) (side-by-side diff) | |
tree | 4129e674e21df767b31299e873dd44e33a308e1b /libopie2/opiedb | |
parent | 8e28911f7199f4450ac5eef09482069f9b9caea2 (diff) | |
download | opie-6d08277737e22b7a1527124623f3571969073ddf.zip opie-6d08277737e22b7a1527124623f3571969073ddf.tar.gz opie-6d08277737e22b7a1527124623f3571969073ddf.tar.bz2 |
Move XML class to internal PIM
Add namespaces!!!
Opie::Core and Opie::Core::Private
Opie::Net and Opie::Net::Private
Opie::Ui and Opie::Ui::Private
Opie::MM and Opie::MM::Private
Opie::DB and Opie::DB::Private
PIM classes are not yet converted because we will do other work
on it as well
-rw-r--r-- | libopie2/opiedb/TODO | 1 | ||||
-rw-r--r-- | libopie2/opiedb/opiedb.pro | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlbackend.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlbackend.h | 8 | ||||
-rw-r--r-- | libopie2/opiedb/osqlbackendmanager.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiedb/osqlbackendmanager.h | 6 | ||||
-rw-r--r-- | libopie2/opiedb/osqldriver.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqldriver.h | 7 | ||||
-rw-r--r-- | libopie2/opiedb/osqlerror.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlerror.h | 5 | ||||
-rw-r--r-- | libopie2/opiedb/osqlitedriver.cpp | 9 | ||||
-rw-r--r-- | libopie2/opiedb/osqlitedriver.h | 8 | ||||
-rw-r--r-- | libopie2/opiedb/osqlmanager.cpp | 6 | ||||
-rw-r--r-- | libopie2/opiedb/osqlmanager.h | 6 | ||||
-rw-r--r-- | libopie2/opiedb/osqlquery.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlquery.h | 8 | ||||
-rw-r--r-- | libopie2/opiedb/osqlresult.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlresult.h | 8 | ||||
-rw-r--r-- | libopie2/opiedb/osqltable.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqltable.h | 7 |
20 files changed, 95 insertions, 6 deletions
diff --git a/libopie2/opiedb/TODO b/libopie2/opiedb/TODO index ca04ac6..8b86187 100644 --- a/libopie2/opiedb/TODO +++ b/libopie2/opiedb/TODO @@ -1,9 +1,10 @@ * something like Capabilities of a Driver - ROWID - How to declare INTEGER PRIMARY KEY - Abstract from implementation of some dbs - provides( Type::What ) + - emit signals directly on arriving of data * OSQLDriver DriverVersion - DatabaseVersion * Better OSQLQueries - more than OSQLRawQuery
\ No newline at end of file diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro index c773d6c..147435a 100644 --- a/libopie2/opiedb/opiedb.pro +++ b/libopie2/opiedb/opiedb.pro @@ -12,25 +12,25 @@ HEADERS = osqlbackend.h \ osqlitedriver.h SOURCES = osqlbackend.cpp \ osqldriver.cpp \ osqlerror.cpp \ osqlmanager.cpp \ osqlquery.cpp \ osqlresult.cpp \ osqltable.cpp \ osqlbackendmanager.cpp \ osqlitedriver.cpp INTERFACES = TARGET = opiedb2 -VERSION = 1.8.2 +VERSION = 1.9.0 INCLUDEPATH = $(OPIEDIR)/include DEPENDPATH = $(OPIEDIR)/include LIBS += -lopiecore2 -lqpe -lsqlite !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opiedb/osqlbackend.cpp b/libopie2/opiedb/osqlbackend.cpp index d6c39a9..6e5159f 100644 --- a/libopie2/opiedb/osqlbackend.cpp +++ b/libopie2/opiedb/osqlbackend.cpp @@ -1,15 +1,17 @@ #include "osqlbackend.h" +using namespace Opie::DB; + OSQLBackEnd::OSQLBackEnd( const QString& name, const QString& vendor, const QString& license, const QCString& lib ) : m_name( name), m_vendor( vendor), m_license( license ), m_lib( lib ) { m_default = false; m_pref = -1; } OSQLBackEnd::OSQLBackEnd( const OSQLBackEnd& back ) { (*this) = back; diff --git a/libopie2/opiedb/osqlbackend.h b/libopie2/opiedb/osqlbackend.h index ad879a4..28451b6 100644 --- a/libopie2/opiedb/osqlbackend.h +++ b/libopie2/opiedb/osqlbackend.h @@ -1,20 +1,23 @@ #ifndef OSQL_BACKEND_H #define OSQL_BACKEND_H #include <qcstring.h> #include <qstring.h> #include <qvaluelist.h> + +namespace Opie { +namespace DB { /** * OSQLBackEnd represents an available backend * to the Opie Database Service * It's used to easily extend OSQL services by * 3rd party plugins. * It's used to show */ class OSQLBackEnd /*: public QShared */ { public: typedef QValueList<OSQLBackEnd> ValueList; /** * A basic c'tor @@ -61,15 +64,20 @@ public: void setLibrary( const QCString& lib ); void setDefault( bool ); void setPreference( int ); private: QString m_name; QString m_vendor; QString m_license; QCString m_lib; bool m_default :1; int m_pref; + class Private; + Private *d; }; +} +} + #endif diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp index 95ed77b..fc18e07 100644 --- a/libopie2/opiedb/osqlbackendmanager.cpp +++ b/libopie2/opiedb/osqlbackendmanager.cpp @@ -1,17 +1,21 @@ #include <qdir.h> #include <qmap.h> #include "osqlbackendmanager.h" +/** + * \todo FIXME CONFIG!!! + */ + namespace { class Config { typedef QMap<QString, QString> List; public: Config( const QString& fileName ); /** * Quite simple layout in nature * BeginFile * Key = Value */ bool load(); QString value( const QString& key ); @@ -35,24 +39,28 @@ namespace { for (it = list.begin(); it != list.end(); ++it ) { line = (*it).stripWhiteSpace(); qWarning("Anonymous::Config:" + line ); QStringList test = QStringList::split(' ', line ); m_list.insert( test[0], test[2] ); } return true; } QString Config::value( const QString& key ) { return m_list[key]; } }; + + +using namespace Opie::DB; + OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) :m_path( path ) { } OSQLBackEndManager::~OSQLBackEndManager() { } /** * scan dirs */ OSQLBackEnd::ValueList OSQLBackEndManager::scan() { OSQLBackEnd::ValueList list; if (!m_path.isEmpty() ) { diff --git a/libopie2/opiedb/osqlbackendmanager.h b/libopie2/opiedb/osqlbackendmanager.h index bc357a9..00e81fc 100644 --- a/libopie2/opiedb/osqlbackendmanager.h +++ b/libopie2/opiedb/osqlbackendmanager.h @@ -1,20 +1,26 @@ #ifndef OSQL_BACKEND_MANAGER_H #define OSQL_BACKEND_MANAGER_H #include <qstringlist.h> #include "osqlbackend.h" +namespace Opie { +namespace DB { + class OSQLBackEndManager { public: OSQLBackEndManager(const QStringList& path ); ~OSQLBackEndManager(); OSQLBackEnd::ValueList scan(); private: OSQLBackEnd::ValueList scanDir( const QString& dir ); OSQLBackEnd file2backend( const QString& file ); class OSQLBackEndManagerPrivate; OSQLBackEndManagerPrivate* d; QStringList m_path; }; +} +} + #endif diff --git a/libopie2/opiedb/osqldriver.cpp b/libopie2/opiedb/osqldriver.cpp index 258c116..a6dae77 100644 --- a/libopie2/opiedb/osqldriver.cpp +++ b/libopie2/opiedb/osqldriver.cpp @@ -1,13 +1,15 @@ #include <qpe/qlibrary.h> #include "osqldriver.h" +using namespace Opie::DB; + OSQLDriver::OSQLDriver( QLibrary* lib ) : QObject(), m_lib(lib) { } OSQLDriver::~OSQLDriver() { delete m_lib; } bool OSQLDriver::sync() { return true; } diff --git a/libopie2/opiedb/osqldriver.h b/libopie2/opiedb/osqldriver.h index 68d8ee6..492b8dd 100644 --- a/libopie2/opiedb/osqldriver.h +++ b/libopie2/opiedb/osqldriver.h @@ -1,21 +1,25 @@ #ifndef OSQL_DRIVER_H #define OSQL_DRIVER_H #include <qobject.h> #include <qstring.h> #include "osqltable.h" class QLibrary; + +namespace Opie { +namespace DB { + class OSQLResult; class OSQLQuery; class OSQLError; /** * A OSQLDriver implements the communication with * a database. * After you queried and loaded a driver you can * set some informations and finally try to open * the database * */ @@ -75,13 +79,16 @@ public: */ virtual OSQLTable::ValueList tables() const = 0l; virtual bool sync(); private: QLibrary* m_lib; class OSQLDriverPrivate; OSQLDriverPrivate *d; }; +} +} + #endif diff --git a/libopie2/opiedb/osqlerror.cpp b/libopie2/opiedb/osqlerror.cpp index 3890a50..165ba65 100644 --- a/libopie2/opiedb/osqlerror.cpp +++ b/libopie2/opiedb/osqlerror.cpp @@ -1,14 +1,16 @@ #include "osqlerror.h" +using namespace Opie::DB; + OSQLError::OSQLError( const QString& driverText, const QString& driverDatabaseText, int type, int subType ) : m_drvText( driverText ), m_drvDBText( driverDatabaseText ), m_type( type ), m_number( subType ) { } OSQLError::~OSQLError() { } QString OSQLError::driverText()const { return m_drvText; } diff --git a/libopie2/opiedb/osqlerror.h b/libopie2/opiedb/osqlerror.h index 35a4368..8fa973d 100644 --- a/libopie2/opiedb/osqlerror.h +++ b/libopie2/opiedb/osqlerror.h @@ -1,18 +1,21 @@ #ifndef OSQL_ERROR_H #define OSQL_ERROR_H #include <qstring.h> #include <qvaluelist.h> + +namespace Opie { +namespace DB { /** * OSQLError is the base class of all errors */ class OSQLError { public: typedef QValueList<OSQLError> ValueList; enum Type { None = 0, // NoError Internal, // Internal Error in OSQL Unknown, // Unknown Error Transaction, // Transaction Error Statement, // Wrong Statement Connection, // Connection Error( lost ) @@ -47,13 +50,15 @@ public: QString databaseText()const; int type()const; int subNumber()const; private: QString m_drvText; QString m_drvDBText; int m_type; int m_number; class OSQLErrorPrivate; OSQLErrorPrivate* d; }; +} +} #endif diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp index 6141504..47bc250 100644 --- a/libopie2/opiedb/osqlitedriver.cpp +++ b/libopie2/opiedb/osqlitedriver.cpp @@ -31,24 +31,27 @@ #include "osqlquery.h" #include "osqlitedriver.h" #include <opie2/odebug.h> #include <stdlib.h> // fromLocal8Bit() does not work as expected. Thus it // is replaced by fromLatin1() (eilers) #define __BUGGY_LOCAL8BIT_ +using namespace Opie::DB; +using namespace Opie::DB::Private; + namespace { struct Query { OSQLError::ValueList errors; OSQLResultItem::ValueList items; OSQLiteDriver *driver; }; } OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) : OSQLDriver( lib ) { @@ -77,33 +80,33 @@ void OSQLiteDriver::setUrl( const QString& url ) { void OSQLiteDriver::setOptions( const QStringList& ) { } /* * try to open a db specified via setUrl * and options */ bool OSQLiteDriver::open() { char *error; - odebug << "OSQLiteDriver::open: about to open" << oendl; + qDebug("OSQLiteDriver::open: about to open"); m_sqlite = sqlite_open(m_url.local8Bit(), 0, &error ); /* failed to open */ if (m_sqlite == 0l ) { // FIXME set the last error - owarn << "OSQLiteDriver::open: " << error << oendl; + qWarning("OSQLiteDriver::open: %s", error ); free( error ); return false; } return true; } /* close the db * sqlite closes them without * telling failure or success */ bool OSQLiteDriver::close() { @@ -117,25 +120,25 @@ bool OSQLiteDriver::close() { /* Query */ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { if ( !m_sqlite ) { // FIXME set error code OSQLResult result( OSQLResult::Failure ); return result; } Query query; query.driver = this; char *err; /* SQLITE_OK 0 if return code > 0 == failure */ if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { - owarn << "OSQLiteDriver::query: Error while executing" << oendl; + qWarning("OSQLiteDriver::query: Error while executing"); free(err ); // FixMe Errors } OSQLResult result(OSQLResult::Success, query.items, query.errors ); return result; } OSQLTable::ValueList OSQLiteDriver::tables() const { diff --git a/libopie2/opiedb/osqlitedriver.h b/libopie2/opiedb/osqlitedriver.h index 6984539..3e1325b 100644 --- a/libopie2/opiedb/osqlitedriver.h +++ b/libopie2/opiedb/osqlitedriver.h @@ -1,34 +1,42 @@ #ifndef OSQL_LITE_DRIVER_H #define OSQL_LITE_DRIVER_H #include <sqlite.h> #include "osqldriver.h" #include "osqlerror.h" #include "osqlresult.h" +namespace Opie { +namespace DB { +namespace Private { + class OSQLiteDriver : public OSQLDriver { Q_OBJECT public: OSQLiteDriver( QLibrary *lib = 0l ); ~OSQLiteDriver(); QString id()const; void setUserName( const QString& ); void setPassword( const QString& ); void setUrl( const QString& url ); void setOptions( const QStringList& ); bool open(); bool close(); OSQLError lastError(); OSQLResult query( OSQLQuery* ); OSQLTable::ValueList tables()const; private: OSQLError m_lastE; OSQLResult m_result; OSQLResultItem m_items; int handleCallBack( int, char**, char** ); static int call_back( void*, int, char**, char** ); QString m_url; sqlite *m_sqlite; }; +} +} +} + #endif diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp index 766ebe1..990d258 100644 --- a/libopie2/opiedb/osqlmanager.cpp +++ b/libopie2/opiedb/osqlmanager.cpp @@ -1,19 +1,21 @@ #include <stdlib.h> #include "osqlmanager.h" #include "osqlbackendmanager.h" #include "osqlitedriver.h" +using namespace Opie::DB; + OSQLManager::OSQLManager() { } OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { m_list.clear(); QString opie = QString::fromLatin1( getenv("OPIEDIR") ); QString qpe = QString::fromLatin1( getenv("QPEDIR") ); if ( !m_path.contains(opie) && !opie.isEmpty() ) m_path << opie; if ( !m_path.contains(qpe) && !qpe.isEmpty() ) m_path << qpe; @@ -22,36 +24,36 @@ OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { m_list += builtIn(); return m_list; } /* * loading dso's is currently not enabled due problems with QLibrary * beeing in libqpe and not libqte */ OSQLDriver* OSQLManager::load( const QString& name ) { OSQLDriver* driver = 0l; if ( name == "SQLite" ) { - driver = new OSQLiteDriver(); + driver = new Opie::DB::Private::OSQLiteDriver; } return driver; } /* * same as above */ OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { OSQLDriver *driver = 0l; if ( end.library() == "builtin" && end.name() == "SQLite" ) - driver = new OSQLiteDriver(); + driver = new Opie::DB::Private::OSQLiteDriver; return driver; } /* * let's find the a default with the highes preference */ OSQLDriver* OSQLManager::standard() { OSQLDriver* driver =0l; if ( m_list.isEmpty() ) queryBackEnd(); OSQLBackEnd::ValueList::Iterator it; OSQLBackEnd back; for ( it = m_list.begin(); it != m_list.end(); ++it ) { diff --git a/libopie2/opiedb/osqlmanager.h b/libopie2/opiedb/osqlmanager.h index 5323b14..ca73c64 100644 --- a/libopie2/opiedb/osqlmanager.h +++ b/libopie2/opiedb/osqlmanager.h @@ -1,22 +1,24 @@ #ifndef OSQL_MANAGER_H #define OSQL_MANAGER_H #include <qobject.h> #include <qstringlist.h> #include "osqlbackend.h" +namespace Opie { +namespace DB { /** * OSQLManager is responsible for loading * and unloading, querying different OSQL * services * Load a OSQLDriver and delete it yourself * */ class OSQLDriver; class OSQLManager : public QObject { Q_OBJECT public: /** @@ -50,15 +52,19 @@ public: * registered path for backends */ void registerPath( const QString& path ); /** * unregisterPath from the search path list */ bool unregisterPath( const QString& path ); private: OSQLBackEnd::ValueList builtIn()const; OSQLBackEnd::ValueList m_list; QStringList m_path; + class Private; + Private *d; }; +} +} #endif diff --git a/libopie2/opiedb/osqlquery.cpp b/libopie2/opiedb/osqlquery.cpp index ecd53f2..8270c4c 100644 --- a/libopie2/opiedb/osqlquery.cpp +++ b/libopie2/opiedb/osqlquery.cpp @@ -1,15 +1,17 @@ #include "osqlquery.h" +using namespace Opie::DB; + OSQLQuery::OSQLQuery() { } OSQLQuery::~OSQLQuery() { } OSQLRawQuery::OSQLRawQuery(const QString& query) : OSQLQuery(), m_query( query ) { } OSQLRawQuery::~OSQLRawQuery() { } QString OSQLRawQuery::query()const { diff --git a/libopie2/opiedb/osqlquery.h b/libopie2/opiedb/osqlquery.h index 63c26b0..0265d2b 100644 --- a/libopie2/opiedb/osqlquery.h +++ b/libopie2/opiedb/osqlquery.h @@ -1,21 +1,24 @@ #ifndef OSQL_QUERY_H #define OSQL_QUERY_H #include <qmap.h> #include <qvaluelist.h> #include <qstring.h> +namespace Opie { +namespace DB { + /** I'm not happy with them class OSQLQueryOrder { public: typedef QValueList<OSQLQueryOrder> ValueList; OSQLQueryOrder(const QString& table = QString::null ); OSQLQueryOrder( const OSQLQueryOrder& ); ~OSQLQueryOrder(); void setOrderFields( const QStringList& list ); void setValue( const QString& fieldName, const QString& Value ); void setValues( const QMap<QString, QString>& ); QMap<QString, QString> orders() const; QString orderStatement()const; @@ -38,24 +41,27 @@ private: int m_vergleich; const QString& m_left; const QString& m_right; }; */ class OSQLQuery { public: OSQLQuery(); virtual ~OSQLQuery(); virtual QString query()const = 0; +private: + class Private; + Private *d; }; class OSQLRawQuery : public OSQLQuery { public: OSQLRawQuery( const QString& query ); ~OSQLRawQuery(); QString query() const; private: class OSQLRawQueryPrivate; OSQLRawQueryPrivate* d; QString m_query; @@ -110,13 +116,15 @@ public: OSQLUpdateQuery( const QString& table ); ~OSQLUpdateQuery(); void setWhere( const OSQLWhere& ); void setWheres( const OSQLWhere::ValueList& ); */ /* replaces all previous set Values */ /* void setValue( const QString& field, const QString& value ); void setValue( const QMap<QString, QString> &fields ); QString query() const; }; */ +} +} #endif diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp index 42da356..bad7d8b 100644 --- a/libopie2/opiedb/osqlresult.cpp +++ b/libopie2/opiedb/osqlresult.cpp @@ -1,15 +1,17 @@ #include "osqlresult.h" +using namespace Opie::DB; + OSQLResultItem::OSQLResultItem( const TableString& string, const TableInt& Int) : m_string( string ), m_int( Int ) { } OSQLResultItem::~OSQLResultItem() { } OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { *this = item; } OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { diff --git a/libopie2/opiedb/osqlresult.h b/libopie2/opiedb/osqlresult.h index 9c9efa2..fc6f01a 100644 --- a/libopie2/opiedb/osqlresult.h +++ b/libopie2/opiedb/osqlresult.h @@ -1,21 +1,25 @@ #ifndef OSQL_RESULT_H #define OSQL_RESULT_H #include <qdatetime.h> #include <qmap.h> #include <qvaluelist.h> #include "osqlerror.h" + +namespace Opie { +namespace DB { + /** * ResultItem represents one row of the resulting answer */ class OSQLResultItem { public: typedef QValueList<OSQLResultItem> ValueList; /** * TableString is used to establish the relations * between the column name and the real item */ typedef QMap<QString, QString> TableString; @@ -98,15 +102,19 @@ public: void setErrors( const OSQLError::ValueList& error ); void setResults( const OSQLResultItem::ValueList& result ); OSQLResultItem first(); OSQLResultItem next(); bool atEnd(); OSQLResultItem::ValueList::ConstIterator iterator()const; private: enum State m_state; OSQLResultItem::ValueList m_list; OSQLError::ValueList m_error; OSQLResultItem::ValueList::Iterator it; + class Private; + Private *d; }; +} +} #endif diff --git a/libopie2/opiedb/osqltable.cpp b/libopie2/opiedb/osqltable.cpp index cde40f4..117cf21 100644 --- a/libopie2/opiedb/osqltable.cpp +++ b/libopie2/opiedb/osqltable.cpp @@ -1,14 +1,16 @@ #include "osqltable.h" +using namespace Opie::DB; + OSQLTableItem::OSQLTableItem() {} OSQLTableItem::OSQLTableItem( enum Type type, const QString& field, const QVariant& var) : m_type( type ), m_field( field ), m_var( var ) { } OSQLTableItem::~OSQLTableItem() {} OSQLTableItem::OSQLTableItem( const OSQLTableItem& item) { *this = item; } diff --git a/libopie2/opiedb/osqltable.h b/libopie2/opiedb/osqltable.h index 87f7e74..86c30dd 100644 --- a/libopie2/opiedb/osqltable.h +++ b/libopie2/opiedb/osqltable.h @@ -1,19 +1,21 @@ #ifndef OSQL_TABLE_H #define OSQL_TABLE_H #include <qstring.h> #include <qvaluelist.h> #include <qvariant.h> +namespace Opie { +namespace DB { /** * OSQLTableItem saves one column of a complete * table */ class OSQLTableItem { public: typedef QValueList<OSQLTableItem> ValueList; /** * Type kinds ( to be extended ) */ enum Type { Undefined=-1, Integer=0, BigInteger =1, Float = 2, VarChar = 4 }; @@ -81,15 +83,20 @@ public: void setColumns( const OSQLTableItem::ValueList& ); /** * returns all columns of the table */ OSQLTableItem::ValueList columns() const; QString tableName()const; private: QString m_table; OSQLTableItem::ValueList m_list; + class Private; + Private *d; }; +} +} + #endif |