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"
34 static QString TAG_SERVICE = "service";
35 static QString TAG_CAMPAIGN = "campaign";
36 static QString TAG_ACCOUNTID = "accountid";
37 static QString TAG_PASSWORD = "password";
39 static QString TAG_USERID = "userid";
40 static QString TAG_LANGUAGE = "language";
41 static QString TAG_TRANSACTIONID = "transactionid";
43 static QString TAG_ADTYPE = "adtypedefault";
44 static QString TAG_TEXT = "text";
45 static QString TAG_CONTENT_URL = "content_url";
46 static QString TAG_URL = "url";
47 static QString TAG_HTML = "html";
50 static QString TAG_PREFERRED_SIZE = "preferredsize";
53 static QString TAG_KEY = "key";
54 static QString TAG_VALUE = "value";
56 class QtmadsService : public QObject
62 virtual ~QtmadsService();
64 void getAd(QHash<QString,QVariant> &adParameters);
65 void getRemoteImage(QString urlString);
67 bool initializeService(QString service, quint32 campaingId = 0, AdType defaultAdType = anyAd);
68 void setDefaultAdType(AdType type);
69 AdType defaultAdType();
71 virtual AdType getAdTypeFromString(QString adType);
72 virtual QString getStringFromAdType(AdType adType);
75 virtual bool parseUrlParameters(const QHash<QString, QVariant> &dynamicParameters, QList<QPair<QString,QString> > &parsedParameters) = 0;
76 virtual bool parseReceivedAd(const QByteArray &response, QHash<QString, QVariant> &parsedAd) = 0;
77 virtual bool parseXmlConfFile(QFile &file);
80 void adRequestFinished(int, bool);
81 void imageRequestFinished(int, bool);
84 void adRequestReady(QHash<QString,QVariant> &ad);
85 void adRequestFailed();
86 void imageRequestReady(const QImage *image);
87 void imageRequestFailed();
97 QString transactionId;
103 QHash<QString,QString> parameterTags;
107 qint32 adTrasactionId;
108 qint32 imageTrasactionId;
113 #endif /* QTMADSSERVICE_H_ */