00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef DBPHOTOSERVICE
00025 #define DBPHOTOSERVICE
00026
00027 # include <QDomDocument>
00028 # include <QHash>
00029 # include <QMap>
00030 # include <QMutex>
00031 # include <QSqlDatabase>
00032 # include <QString>
00033 # include <QVariant>
00034 # include "QcjHttpService.h"
00035
00036 class DbPhotoService : public QcjHttpService
00037 {
00038 Q_OBJECT
00039
00040 public:
00041 DbPhotoService(int sockDescripter, QDomDocument *pdoc, long ttl = 0, QObject *parent = 0) :
00042 QcjHttpService(sockDescripter, parent, 20, 0, ttl)
00043 {
00044 printf("DbPhotoService::DbPhotoService(%s): sockDescripter = %d\n", qPrintable(QString::number(currentThreadId())), sockDescripter);
00045 if ( pdoc != 0 )
00046 doc = *pdoc;
00047 cacheDimension = 256;
00048 maxDimension = 1024;
00049 };
00050 void setMaxCache(int n);
00051
00052 protected:
00053 void processRequest(QMap<QString, QVariant> *req, QMap<QString, QVariant> *rsp);
00054 void clearLocks();
00055
00056
00057 QSqlDatabase getServerParms(QString host);
00058
00059 private:
00060 QSqlDatabase db;
00061 QDomDocument doc;
00062 QString imageFormat;
00063 QString sqlTemplate;
00064 QString photoTable;
00065 QString htmlTemplate;
00066 QHash<QString, QSqlDatabase> dbCache;
00067 unsigned int cacheDimension;
00068 unsigned int maxDimension;
00069
00070 };
00071
00072 #endif