X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fqtmadsad.h;fp=src%2Fqtmadsad.h;h=3e1a25e941859c816feff367f1555b11a791c77c;hb=e494cd05f1809789fd03d888c5592753d04f2031;hp=0000000000000000000000000000000000000000;hpb=4c87a3c868d40870d0eed21fb6e01c014acd3062;p=qtmads diff --git a/src/qtmadsad.h b/src/qtmadsad.h new file mode 100644 index 0000000..3e1a25e --- /dev/null +++ b/src/qtmadsad.h @@ -0,0 +1,132 @@ +/* + * 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 . + * + */ + +#ifndef QTMADSAD_H_ +#define QTMADSAD_H_ + +#include + +#include +#include + +#include +#include +#include +#include + +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 &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 &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_