--- /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 QTMADSAD_H_
+#define QTMADSAD_H_
+
+#include <QtGui/QWidget>
+
+#include <QUrl>
+#include <QMainWindow>
+
+#include <Phonon/AudioOutput>
+#include <Phonon/MediaObject>
+#include <Phonon/BackendCapabilities>
+#include <Phonon/ObjectDescriptionModel>
+
+class QtmadsService;
+class QLabel;
+class QBoxLayout;
+class QWebView;
+class QTimer;
+
+enum AdType{
+ anyAd = 1,
+ txtAd,
+ imageAd,
+ txtBannerAd,
+ imageBannerAd,
+ audioAd,
+ videoAd
+};
+
+enum AdFit{
+ noFit = 1,
+ fitWidgetToAd,
+ fitAdToWidget
+};
+
+static QString PLUGINS_PATH = "../plugins";
+
+class QtmadsAd : public QObject
+{
+ Q_OBJECT
+
+public:
+ QtmadsAd(QString service, AdType defaultType = anyAd, quint32 id = 0, AdFit fitting = noFit);
+ ~QtmadsAd();
+
+ void startAd(quint32 adChangeIntervalInSecs = 0);
+ void getHash(QHash<QString, QVariant> &adParams);
+
+ void setAsTextAd(const QFont &font, bool isOnlyTextAd = true, Qt::Alignment alignment = Qt::AlignCenter);
+ void setAsImageAd(bool isOnlyImageAd = true);
+ void setAsBannerAd(bool isOnlyImageAd = true);
+ void setAsTextBannerAd(bool isOnlyTextBannerAd = true);
+ void setAsAudioAd(bool isOnlyAudioAd = true);
+ void setAsVideoAd();
+
+private:
+ bool loadPlugin(QString serviceName);
+
+public slots:
+ void getNewAd();
+
+ void adRequestSucceeded(QHash<QString, QVariant> &ad);
+ void adRequestFailed();
+ void imageRequestSucceeded(QImage *img);
+ void imageRequestFailed();
+ void readyToShow();
+ void showFailed();
+
+ void adClicked(const QUrl &url = QUrl());
+ void clear();
+
+ void phononPlayerStateChanged(Phonon::State newstate, Phonon::State oldstate);
+
+signals:
+ void newAdReady();
+ void newAdFailed();
+
+private:
+ QBoxLayout *layout;
+ QLabel *label;
+ QWebView *htmlView;
+
+ QtmadsService *service;
+
+ Phonon::MediaObject *player;
+
+ QTimer *adTimer;
+
+ AdFit adFit;
+ AdType adType;
+ qint32 adID;
+ QString text;
+ QImage *image;
+ QString imageUrl;
+ QString mediaContentUrl;
+
+ // banner url that is opened when ad is clicked
+ QUrl adUrl;
+ QFont adFont;
+
+ QString htmlContent;
+
+ Qt::Alignment textAlignment;
+
+ quint32 adClickedAmount;
+
+ qint32 shownOnScreenStart;
+ qint32 shownOnScreenEnd;
+ qint32 shownTime;
+};
+
+#endif // QTMADSAD_H_