2 * Copyright (c) 2009 Eetu Lehmusvuo.
4 * This file is part of QtMAds.
6 * QtMAds is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * QtMAds is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with QtMAds. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef QTMADSSERVICE_H_
22 #define QTMADSSERVICE_H_
24 #include "qtmadsadwidget.h"
33 static QString CONF_PATH = "plugins/confs/";
34 static QString CONF_FILE_POSTFIX = "_adconfigure.xml";
36 static QString TAG_SERVICE = "service";
37 static QString TAG_CAMPAIGN = "campaign";
38 static QString TAG_ACCOUNTID = "accountid";
39 static QString TAG_PASSWORD = "password";
41 static QString TAG_USERID = "userid";
42 static QString TAG_LANGUAGE = "language";
43 static QString TAG_TRANSACTIONID = "transactionid";
45 static QString TAG_ADTYPE = "adtype";
46 static QString TAG_TEXT = "text";
47 static QString TAG_CONTENT_URL = "content_url";
48 static QString TAG_URL = "url";
49 static QString TAG_HTML = "html";
50 static QString TAG_PREFERRED_SIZE = "preferredsize";
52 static QString TAG_KEY = "key";
53 static QString TAG_VALUE = "value";
55 class QtmadsService : public QObject
61 virtual ~QtmadsService();
63 void getAd(QHash<QString,QVariant> &adParameters);
64 void getRemoteImage(QString urlString);
66 bool initializeService(QString service, quint32 campaingId = 0, AdType defaultAdType = anyAd);
67 void setDefaultAdType(AdType type);
68 AdType defaultAdType();
70 virtual AdType getAdTypeFromString(QString adType);
71 virtual QString getStringFromAdType(AdType adType);
74 virtual bool parseUrlParameters(const QHash<QString, QVariant> &dynamicParameters, QList<QPair<QString,QString> > &parsedParameters) = 0;
75 virtual bool parseReceivedAd(const QByteArray &response, QHash<QString, QVariant> &parsedAd) = 0;
76 virtual bool parseXmlConfFile(QFile &file);
79 void adRequestFinished(int, bool);
80 void imageRequestFinished(int, bool);
83 void adRequestReady(QHash<QString,QVariant> &ad);
84 void adRequestFailed();
85 void imageRequestReady(const QImage *image);
86 void imageRequestFailed();
96 QString transactionId;
102 QHash<QString,QString> parameterTags;
106 qint32 adTrasactionId;
107 qint32 imageTrasactionId;
112 #endif /* QTMADSSERVICE_H_ */