00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (ivan.frade@nokia.com) 00006 ** 00007 ** This file is part of the QtSparql module (not yet part of the Qt Toolkit). 00008 ** 00009 ** $QT_BEGIN_LICENSE:LGPL$ 00010 ** GNU Lesser General Public License Usage 00011 ** This file may be used under the terms of the GNU Lesser General Public 00012 ** License version 2.1 as published by the Free Software Foundation and 00013 ** appearing in the file LICENSE.LGPL included in the packaging of this 00014 ** file. Please review the following information to ensure the GNU Lesser 00015 ** General Public License version 2.1 requirements will be met: 00016 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00017 ** 00018 ** In addition, as a special exception, Nokia gives you certain additional 00019 ** rights. These rights are described in the Nokia Qt LGPL Exception 00020 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 00021 ** 00022 ** GNU General Public License Usage 00023 ** Alternatively, this file may be used under the terms of the GNU General 00024 ** Public License version 3.0 as published by the Free Software Foundation 00025 ** and appearing in the file LICENSE.GPL included in the packaging of this 00026 ** file. Please review the following information to ensure the GNU General 00027 ** Public License version 3.0 requirements will be met: 00028 ** http://www.gnu.org/copyleft/gpl.html. 00029 ** 00030 ** Other Usage 00031 ** Alternatively, this file may be used in accordance with the terms and 00032 ** conditions contained in a signed written agreement between you and Nokia. 00033 ** 00034 ** If you have questions regarding the use of this file, please contact 00035 ** Nokia at ivan.frade@nokia.com. 00036 ** $QT_END_LICENSE$ 00037 ** 00038 ****************************************************************************/ 00039 00040 #ifndef QSPARQL_TRACKER_DIRECT_DRIVER_P_H 00041 #define QSPARQL_TRACKER_DIRECT_DRIVER_P_H 00042 00043 #include <tracker-sparql.h> 00044 00045 #include <QtSparql/qsparqlquery.h> 00046 #include <QtSparql/qsparqlqueryoptions.h> 00047 #include <QtSparql/qsparqlerror.h> 00048 00049 #include <QtCore/qlist.h> 00050 #include <QtCore/qpointer.h> 00051 #include <QtCore/qmutex.h> 00052 #include <QThreadPool> 00053 00054 #ifdef QT_PLUGIN 00055 #define Q_EXPORT_SPARQLDRIVER_TRACKER_DIRECT 00056 #else 00057 #define Q_EXPORT_SPARQLDRIVER_TRACKER_DIRECT Q_SPARQL_EXPORT 00058 #endif 00059 00060 QT_BEGIN_HEADER 00061 00062 QT_BEGIN_NAMESPACE 00063 00064 class QTrackerDirectDriver; 00065 class QTrackerDirectResult; 00066 00067 class QTrackerDirectDriverPrivate { 00068 public: 00069 QTrackerDirectDriverPrivate(QTrackerDirectDriver *driver); 00070 ~QTrackerDirectDriverPrivate(); 00071 00072 void asyncOpenComplete(GAsyncResult* result); 00073 void onConnectionOpen(QObject* object, const char* method, const char* slot); 00074 void waitForConnectionOpen(); 00075 void openConnectionSync(); 00076 00077 TrackerSparqlConnection *connection; 00078 int dataReadyInterval; 00079 // This mutex is for ensuring that only one thread at a time 00080 // is using the connection to make tracker queries. This mutex 00081 // probably isn't needed as a TrackerSparqlConnection is 00082 // already thread safe. 00083 QMutex connectionMutex; 00084 QTrackerDirectDriver *driver; 00085 QString error; 00086 00087 QThreadPool threadPool; 00088 00089 private: 00090 bool asyncOpenCalled; 00091 void checkConnectionError(TrackerSparqlConnection *conn, GError* gerr); 00092 }; 00093 00094 QVariant readVariant(TrackerSparqlCursor* cursor, int col); 00095 QSparqlError::ErrorType errorCodeToType(gint code); 00096 gint qSparqlPriorityToGlib(QSparqlQueryOptions::Priority priority); 00097 00098 QT_END_NAMESPACE 00099 00100 QT_END_HEADER 00101 00102 #endif // QSPARQL_TRACKER_DIRECT_DRIVER_P_H