From dd5c40a4fa4d73ca1f5234502c7ba67675c5b7f9 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 20 Dec 2003 17:24:21 +0000 Subject: use odebug classes --- (limited to 'libopie2/opiedb/osqlitedriver.cpp') diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp index 99fd218..b857534 100644 --- a/libopie2/opiedb/osqlitedriver.cpp +++ b/libopie2/opiedb/osqlitedriver.cpp @@ -1,10 +1,42 @@ -#include +/* +                 This file is part of the Opie Project + + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "osqlresult.h" #include "osqlquery.h" #include "osqlitedriver.h" -// fromLocal8Bit() does not work as expected. Thus it +#include + +#include + +// fromLocal8Bit() does not work as expected. Thus it // is replaced by fromLatin1() (eilers) #define __BUGGY_LOCAL8BIT_ @@ -17,34 +49,45 @@ namespace { }; } + OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) : OSQLDriver( lib ) { m_sqlite = 0l; } + + OSQLiteDriver::~OSQLiteDriver() { close(); } + QString OSQLiteDriver::id()const { return QString::fromLatin1("SQLite"); } void OSQLiteDriver::setUserName( const QString& ) {} + + void OSQLiteDriver::setPassword( const QString& ) {} + void OSQLiteDriver::setUrl( const QString& url ) { m_url = url; } + + void OSQLiteDriver::setOptions( const QStringList& ) { } + + /* * try to open a db specified via setUrl * and options */ bool OSQLiteDriver::open() { char *error; - qWarning("about to open"); + odebug << "OSQLiteDriver::open: about to open" << oendl; m_sqlite = sqlite_open(m_url.local8Bit(), 0, &error ); @@ -52,12 +95,14 @@ bool OSQLiteDriver::open() { /* failed to open */ if (m_sqlite == 0l ) { // FIXME set the last error - qWarning("error:%s", error ); + owarn << "OSQLiteDriver::open: " << error << oendl; free( error ); return false; } return true; } + + /* close the db * sqlite closes them without * telling failure or success @@ -68,6 +113,8 @@ bool OSQLiteDriver::close() { return true; } + + /* Query */ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { if ( !m_sqlite ) { @@ -80,40 +127,46 @@ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { char *err; /* SQLITE_OK 0 if return code > 0 == failure */ if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { - qWarning("Error while executing"); + owarn << "OSQLiteDriver::query: Error while executing" << oendl; free(err ); // FixMe Errors } - // qWarning("Item count is %d", query.items.count() ); + OSQLResult result(OSQLResult::Success, query.items, query.errors ); return result; } + + OSQLTable::ValueList OSQLiteDriver::tables() const { } + + OSQLError OSQLiteDriver::lastError() { OSQLError error; return error; }; + + /* handle a callback add the row to the global * OSQLResultItem */ int OSQLiteDriver::handleCallBack( int, char**, char** ) { return 0; } + + /* callback_handler add the values to the list*/ int OSQLiteDriver::call_back( void* voi, int argc, char** argv, char** columns) { - // qWarning("Callback with %d items", argc ); Query* qu = (Query*)voi; //copy them over to a OSQLResultItem QMap tableString; QMap tableInt; for (int i = 0; i < argc; i++ ) { - //qWarning("%s|%s", columns[i], argv[i] ); #ifdef __BUGGY_LOCAL8BIT_ tableInt.insert( i, QString::fromLatin1( argv[i] ) ); -- cgit v0.9.0.2