<accountid key="accountid" value="1"/>
<password key="password" value="Testi1Test2"/>
<campaign id="0">
- <adtype key="messagetype" value="txtAd"/>
+ <adtypedefault key="messagetype" value="txtAd"/>
<transactionid key="transactionid" value="10:20:00:1"/>
<language key="language" value="en"/>
</campaign>
-<?xml version="1.0"?>
-<service name="ADHERE" url="http://www.j2madverts.com/adhere/adserver/adserver/www/delivery/requestad.php">
- <accountid key="accountid" value="1"/>
- <password key="password" value="Testi1Test2"/>
- <campaign id="0">
- <adtype key="messagetype" value="txtAd"/>
- <transactionid key="transactionid" value="10:20:00:1"/>
- <language key="language" value="en"/>
- </campaign>
-</service>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>
-<service name="SERVICE_NAME" url="SERVICE_URL">
- <accountid key="ACCOUNDTID_KEY" value="ACCOUNTID_VALUE"/>
- <password key="PASSWORD_KEY" value="PASSWORD_VALUE"/>
- <campaign id="CAMPAIGN_ID">
- <adgroup key="ADGROUP_KEY" value="ADGROUP_VALUE"/>
- <adtype key="ADTYPE_KEY" value="DEFAULT_ADTYPE_VALUE"/>
- <adformats key="ADFORMATS_KEY" value="ADFORMAT_VALUE1, ADFORMAT_VALUE2"/>
-
- <adsizeconstraint key="ADSIZECONSTRAINT_KEY" value="ADSIZECONSTRAINT_VALUE"/>
- <adsize key="ADSIZE_KEY" value="ADSIZE_VALUE"/>
- <adheight key="ADHEIGHT_KEY" value="ADHEIGHT_VALUE"/>
- <adwidth key="ADWIDTH_KEY" value="ADWIDTH_VALUE"/>
-
- <userid key="USERID_KEY" value="USERID_VALUE"/>
- <transactionid key="TRANSACTION_KEY"/>
- <language key="LANGUAGE_KEY" value="LANGUAGE_VALUE1, LANGUAGE_VALUE2"/>
- <keywords key="KEYWORDS_KEY" value="KEYWORDS_VALUE1, KEYWORDS_VALUE2"/>
-
- <parameter1 key="PARAMETER_KEY" value="PARAMETER_VALUE1, PARAMETER_VALUE2"/>
- <parameterX key="PARAMETER_KEY" value="PARAMETER_VALUE1, PARAMETER_VALUE2"/>
- </campaign>
-</service>
-
-
-<?xml version="1.0"?>
-<service name="SOMA" url="http://dev.soma.smaato.com:8080/wap/reqAd.jsp">
- <accountid key="pub" value="0"/>
- <campaign id="0">
- <adgroup key="adspace" value="0"/>
- <adformats key="format" value="JPG,PNG"/>
- </campaign>
-</service>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+ Dynamic values always overrides these settings.
+ As default all parameters (except service name & url) are optional.
+ Only used ad service define which parameters and values are mandatory.
+ Dynamic values always overrides these settings.
+-->
+
+<service name="" url="">
+ <accountid key="" value=""/>
+ <password key="" value=""/>
+ <campaign id="">
+ <!-- Ad concerning parameters. -->
+ <adgroup key="" value=""/>
+ <adtypedefault key="" value=""/>
+ <adformats key="" value="1, 2"/>
+ <adsizeconstraint key="" value=""/>
+ <adsize key="" value=""/>
+ <adheight key="" value=""/>
+ <adwidth key="" value=""/>
+
+ <!-- User and session concerning parameters. -->
+ <userid key="" value=""/>
+ <transactionid key="" value=""/> <!-- value should contain transactionid format -->
+ <language key="" value="1, 2"/>
+ <keywords key="" value="1, 2"/>
+
+ <!-- These parameters can be used to assign static values for ad parameters. -->
+ <parameter1 key="" value="1, 2"/>
+ <parameterX key="" value="1, 2"/>
+ </campaign>
+</service>
\ No newline at end of file
#include <QWidget>
#include <QUrl>
#include <QDesktopServices>
+#include <QTimerEvent>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
- QWidget *widget = new QWidget(this);
- QGridLayout *layout = new QGridLayout(widget);
+ widget = new QWidget(this);
+ mainLayout = new QGridLayout(widget);
- QtmadsBannerAd *adWidget1 = new QtmadsBannerAd("ADHERE", 0, noFit, this);
- adWidget1->setAsBannerAd();
- adWidget1->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
- adWidget1->setMaximumSize(QSize(216,36));
- layout->addWidget(adWidget1, 0, 0, 1, 2, Qt::AlignCenter);
+ splashScreenAd = new QtmadsLabelAd("ADHERE", 0, noFit, this);
+ splashScreenAd->setAsImageAd();
+ mainLayout->addWidget(splashScreenAd);
+ splashScreenAd->startSingleShotAd(10);
+ connect(splashScreenAd, SIGNAL(adStopped()),this, SLOT(splashStopped()));
+
+ widget->setLayout(mainLayout);
+
+ this->setCentralWidget(widget);
+}
+
+void MainWindow::splashStopped()
+{
+ qDebug() << "splashStopped()";
+ this->mainLayout->removeWidget(splashScreenAd);
+ splashScreenAd->clearAd();
+ this->init();
+}
+
+void MainWindow::init()
+{
+ QtmadsBannerAd *adWidget1 = new QtmadsBannerAd("ADHERE", 0, noFit, this);
+ adWidget1->setAsBannerAd();
+ adWidget1->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
+ adWidget1->setMaximumSize(QSize(216,36));
+ mainLayout->addWidget(adWidget1, 0, 0, 1, 2, Qt::AlignCenter);
QtmadsBannerAd *adWidget2 = new QtmadsBannerAd("ADHERE", 0, noFit, this);
adWidget2->setAsBannerAd();
adWidget2->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
adWidget2->setMaximumSize(QSize(216,36));
- layout->addWidget(adWidget2, 0, 2, 1, 2, Qt::AlignCenter);
+ mainLayout->addWidget(adWidget2, 0, 2, 1, 2, Qt::AlignCenter);
QtmadsBannerAd *adWidget3 = new QtmadsBannerAd("ADHERE", 0, noFit, this);
adWidget3->setAsTextBannerAd();
adWidget3->setAdFontSize(18);
adWidget3->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
adWidget3->setMaximumSize(QSize(216,36));
- layout->addWidget(adWidget3, 1, 0, 1, 2, Qt::AlignCenter);
+ mainLayout->addWidget(adWidget3, 1, 0, 1, 2, Qt::AlignCenter);
QtmadsBannerAd *adWidget4 = new QtmadsBannerAd("ADHERE", 0, noFit, this);
adWidget4->setAsTextBannerAd();
adWidget4->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
adWidget4->setMaximumSize(QSize(216,36));
- layout->addWidget(adWidget4, 1, 2, 1, 2, Qt::AlignCenter);
+ mainLayout->addWidget(adWidget4, 1, 2, 1, 2, Qt::AlignCenter);
- QtmadsLabelAd *adWidget5 = new QtmadsLabelAd("ADHERE", 0, noFit, this);
+ /*QtmadsLabelAd *adWidget5 = new QtmadsLabelAd("ADHERE", 0, noFit, this);
adWidget5->setAsImageAd();
- layout->addWidget(adWidget5, 2, 1, 1, 2, Qt::AlignCenter);
+ mainLayout->addWidget(adWidget5, 2, 1, 1, 2, Qt::AlignCenter);
QtmadsMediaAd *audioAd = new QtmadsMediaAd("ADHERE", 0, noFit, this);
audioAd->setAsAudioAd();
- layout->addWidget(audioAd);
+ layout->addWidget(audioAd);*/
adWidget1->startAd(30);
adWidget2->startAd(40);
adWidget3->startAd(30);
adWidget4->startAd(40);
- adWidget5->startAd();
- audioAd->startAd(30);
-
- widget->setLayout(layout);
-
- this->setCentralWidget(widget);
+ /*adWidget5->startAd();
+ audioAd->startAd(30);*/
}
MainWindow::~MainWindow()
#include <QtGui/QMainWindow>
+class QtmadsLabelAd;
+class QGridLayout;
+
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
+
+ void init();
+
+public slots:
+ void splashStopped();
+
+private:
+ QWidget *widget;
+ QGridLayout *mainLayout;
+ QtmadsLabelAd *splashScreenAd;
};
#endif // MAINWINDOW_H
/****************************************************************************
** Resource object code
**
-** Created: Wed Oct 28 18:03:00 2009
+** Created: Sat Nov 7 09:25:02 2009
** by: The Resource Compiler for Qt version 4.5.3
**
** WARNING! All changes made in this file will be lost!
+++ /dev/null
-<?xml version="1.0"?>
-<service name="ADHERE" url="http://www.j2madverts.com/adhere/adserver/adserver/www/delivery/requestad.php">
- <accountid key="accountid" value="1"/>
- <password key="password" value="Testi1Test2"/>
- <campaign id="0">
- <adtype key="messagetype" value="txtAd"/>
- <transactionid key="transactionid" value="10:20:00:1"/>
- <language key="language" value="en"/>
- </campaign>
-</service>
\ No newline at end of file
#ifndef ADHERESERVICEPLUGINLOADER_H_
#define ADHERESERVICEPLUGINLOADER_H_
-#include "qtmadsserviceinterface.h"
+#include "qtmadsserviceloaderinterface.h"
#include <QObject>
#include "ADHERE_serviceplugin.h"
-class AdhereServicePluginLoader : public QObject, QtmadsServiceInterface
+class AdhereServicePluginLoader : public QObject, QtmadsServiceLoaderInterface
{
Q_OBJECT
- Q_INTERFACES(QtmadsServiceInterface)
+ Q_INTERFACES(QtmadsServiceLoaderInterface)
public:
AdhereServicePluginLoader(){};
+++ /dev/null
-<?xml version="1.0"?>
-<service name="ADHERE" url="http://www.j2madverts.com/adhere/adserver/adserver/www/delivery/requestad.php">
- <accountid key="accountid" value="1"/>
- <password key="password" value="Testi1Test2"/>
- <campaign id="0">
- <adtype key="messagetype" value="txtAd"/>
- <transactionid key="transactionid" value="10:20:00:1"/>
- <language key="language" value="en"/>
- </campaign>
-</service>
\ No newline at end of file
#ifndef SOMASERVICEPLUGINLOADER_H_
#define SOMASERVICEPLUGINLOADER_H_
-#include "qtmadsserviceinterface.h"
+#include "qtmadsserviceloaderinterface.h"
#include <QObject>
#include "SOMA_serviceplugin.h"
-class SomaServicePluginLoader : public QObject, QtmadsServiceInterface
+class SomaServicePluginLoader : public QObject, QtmadsServiceLoaderInterface
{
Q_OBJECT
- Q_INTERFACES(QtmadsServiceInterface)
+ Q_INTERFACES(QtmadsServiceLoaderInterface)
public:
SomaServicePluginLoader(){};
/****************************************************************************
** Resource object code
**
-** Created: Wed Oct 28 18:02:54 2009
+** Created: Sat Nov 7 09:18:26 2009
** by: The Resource Compiler for Qt version 4.5.3
**
** WARNING! All changes made in this file will be lost!
#include <QTimer>
#include <QDir>
#include <QPluginLoader>
+#include <QMessageBox>
+#include <QAbstractButton>
#include "qtmadsservice.h"
-#include "qtmadsserviceinterface.h"
+#include "qtmadsserviceloaderinterface.h"
QtmadsAdWidget::QtmadsAdWidget(QString serviceName, AdType defaultType, quint32 groupId, AdFit fitting, QWidget *parent)
: type(defaultType), adFit(fitting), QWidget(parent)
{
- this->loadPlugin(serviceName);
+ this->loadServicePlugin(serviceName);
this->service->initializeService(serviceName, groupId, defaultType);
adTimer = 0;
+ msgBox = 0;
}
QtmadsAdWidget::~QtmadsAdWidget()
{
this->clearAd();
+ emit adStopped();
}
void QtmadsAdWidget::startAd(quint32 adChangeIntervalInSecs)
{
getNewAd();
-
+ qDebug() << "ee";
if(0 != adChangeIntervalInSecs){
if(adTimer == 0){
adTimer = new QTimer(this);
- connect(adTimer, SIGNAL(timeout()), this, SLOT(getNewAd()));
}else{
+ if(adTimer->isSingleShot()){
+ disconnect(adTimer, SIGNAL(timeout()), this, SLOT(singleShotEnded()));
+ }else{
+ disconnect(adTimer, SIGNAL(timeout()), this, SLOT(getNewAd()));
+ }
adTimer->stop();
}
+ connect(adTimer, SIGNAL(timeout()), this, SLOT(getNewAd()));
+ adTimer->setSingleShot(false);
adTimer->start(adChangeIntervalInSecs*1000);
}
}
+void QtmadsAdWidget::startSingleShotAd(quint32 durationInSecs)
+{
+ getNewAd();
+
+ if(0 != durationInSecs){
+ if(adTimer == 0){
+ adTimer = new QTimer(this);
+ }else{
+ if(adTimer->isSingleShot()){
+ disconnect(adTimer, SIGNAL(timeout()), this, SLOT(singleShotEnded()));
+ }else{
+ disconnect(adTimer, SIGNAL(timeout()), this, SLOT(getNewAd()));
+ }
+ adTimer->stop();
+ }
+ connect(adTimer, SIGNAL(timeout()), this, SLOT(singleShotEnded()));
+ adTimer->setSingleShot(true);
+ adTimer->start(durationInSecs*1000);
+ }
+}
+
void QtmadsAdWidget::setAdType(AdType adType)
{
this->type = adType;
void QtmadsAdWidget::adClicked(const QUrl &url)
{
if(url.isValid()){
- qDebug() << "Browser opened to urli: " << url.toString();
+ qDebug() << "Browser opened to url: " << url.toString();
+ if(msgBox == 0){
+ msgBox = new QMessageBox(QMessageBox::NoIcon, tr("Opening ad"),
+ tr("Opening ad to browser..."), QMessageBox::Cancel, this);
+ }
+ // just fixed wait time for now..
+ startTimer(10000);
+ msgBox->exec();
+
QDesktopServices::openUrl(url);
}
}
type = noAd;
}
-bool QtmadsAdWidget::loadPlugin(QString serviceName)
+void QtmadsAdWidget::singleShotEnded()
+{
+ qDebug() << "singleShotEnded()";
+ adTimer->stop();
+ delete adTimer;
+ adTimer = 0;
+
+ this->clearAd();
+ emit adStopped();
+}
+
+void QtmadsAdWidget::timerEvent(QTimerEvent *event)
+{
+ qDebug() << "timerEvent()";
+ this->killTimer(event->timerId());
+ if(msgBox)
+ msgBox->close();
+}
+
+bool QtmadsAdWidget::loadServicePlugin(QString serviceName)
{
bool pluginFound = false;
QDir pluginsDir(qApp->applicationDirPath());
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = pluginLoader.instance();
if (plugin) {
- QtmadsServiceInterface *plugLoader = qobject_cast<QtmadsServiceInterface *>(plugin);
+ QtmadsServiceLoaderInterface *plugLoader = qobject_cast<QtmadsServiceLoaderInterface *>(plugin);
this->service = plugLoader->loadService();
- if (this->service)
+ if (this->service){
pluginFound = true;
- else{
+ qDebug() << "Plugin loaded";
+ }else{
qDebug() << "Plugin load failed: " << pluginLoader.errorString();
- }
+ }
plugLoader = 0;
delete plugin;
}else{
class QBoxLayout;
class QWebView;
class QTimer;
+class QMessageBox;
enum AdType{
anyAd = 1,
~QtmadsAdWidget();
void startAd(quint32 adChangeIntervalInSecs = 0);
+ void startSingleShotAd(quint32 durationInSecs);
//TODO: default getAdAsHash()?
virtual void getAdAsHash(QHash<QString, QVariant> &adParams) = 0;
AdType adType();
private:
- bool loadPlugin(QString serviceName);
+ bool loadServicePlugin(QString serviceName);
public slots:
void getNewAd();
+ virtual void clearAd() = 0;
+ void timerEvent(QTimerEvent */*event*/);
+private slots:
void adRequestSucceeded(QHash<QString, QVariant> &ad);
void adRequestFailed();
void adClicked(const QUrl &url = QUrl());
- virtual void clearAd() = 0;
+
+ void singleShotEnded();
signals:
void newAdReady();
void newAdFailed();
+ void adStopped();
protected:
private:
QTimer *adTimer;
+ QMessageBox *msgBox;
+
quint32 adClickedAmount;
//TODO: shown on screen
bool parseSuccess = true;
// ../plugins/SERVICE_NAME_adconfigure.xml
- QFile file(CONF_PATH + this->serviceName + CONF_FILE_POSTFIX );
+ QString path("plugins/confs/");
+ path.append(this->serviceName);
+ path.append("_adconfigure.xml");
+ QFile file(path);
parseSuccess = file.exists();
/*if(!file.exists()){
if(parseSuccess){
initialized = true;
}else{
- qDebug() << "Ad service configure failed. " << CONF_PATH + this->serviceName + CONF_FILE_POSTFIX ;
initialized = false;
//TODO: parse failed
}
bool QtmadsService::parseXmlConfFile(QFile &file)
{
- qDebug() << "QtmadsService::parseXmlConfFile()";
+ //qDebug() << "QtmadsService::parseXmlConfFile()";
+ //TODO: apply some sanity to if-hell
bool success = false;
QXmlStreamReader xmlReader(&file);
class QFile;
-static QString CONF_PATH = "plugins/confs/";
-static QString CONF_FILE_POSTFIX = "_adconfigure.xml";
-
+// SERVICE TAGS
static QString TAG_SERVICE = "service";
static QString TAG_CAMPAIGN = "campaign";
static QString TAG_ACCOUNTID = "accountid";
static QString TAG_LANGUAGE = "language";
static QString TAG_TRANSACTIONID = "transactionid";
-static QString TAG_ADTYPE = "adtype";
+static QString TAG_ADTYPE = "adtypedefault";
static QString TAG_TEXT = "text";
static QString TAG_CONTENT_URL = "content_url";
static QString TAG_URL = "url";
static QString TAG_HTML = "html";
+
+// AD TAGS
static QString TAG_PREFERRED_SIZE = "preferredsize";
+// GENERAL TAGS
static QString TAG_KEY = "key";
static QString TAG_VALUE = "value";
+++ /dev/null
-/*
- * Copyright (c) 2009 Eetu Lehmusvuo.
- *
- * This file is part of QtMAds.
- *
- * QtMAds is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * QtMAds is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with QtMAds. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef QTMADSSERVICEINTERFACE_H_
-#define QTMADSSERVICEINTERFACE_H_
-
-#include "qtmadsservice.h"
-
-//class QtmadsService;
-
-class QtmadsServiceInterface
-{
-public:
- virtual ~QtmadsServiceInterface(){};
- virtual QtmadsService* loadService() = 0;
-};
-
-Q_DECLARE_INTERFACE(QtmadsServiceInterface, "com.qtmads.plugin.QtmadsServiceInterface/1.0");
-
-#endif /* QTMADSSERVICEINTERFACE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2009 Eetu Lehmusvuo.
+ *
+ * This file is part of QtMAds.
+ *
+ * QtMAds is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * QtMAds is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with QtMAds. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef QTMADSSERVICELOADERINTERFACE_H_
+#define QTMADSSERVICELOADERNITERFACE_H_
+
+#include "qtmadsservice.h"
+
+class QtmadsServiceLoaderInterface
+{
+public:
+ virtual ~QtmadsServiceLoaderInterface(){};
+ virtual QtmadsService* loadService() = 0;
+};
+
+Q_DECLARE_INTERFACE(QtmadsServiceLoaderInterface, "com.qtmads.plugin.QtmadsServiceLoaderInterface/1.0");
+
+#endif
network \
webkit \
xml
-HEADERS += \
+HEADERS += qtmadsserviceloaderinterface.h \
qtmadsmediaad.h \
qtmadslabelad.h \
qtmadsbannerad.h \
qtmadsadwidget.h \
- qtmadsserviceinterface.h \
qtmadsservice.h
SOURCES += qtmadsmediaad.cpp \
qtmadslabelad.cpp \