123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- /*
- * Copyright (c) 2011 Nokia Corporation.
- */
- #ifndef LEVELCONTROLLER_HPP
- #define LEVELCONTROLLER_HPP
- #include <QObject>
- #include <QStringList>
- #include <QHash>
- #include <QVariant>
- #if defined(IAP_ENABLED)
- #include <iapclient.h>
- #endif
- class LevelModel;
- class Level;
- /***************************************************************************************************
- *Class used for handling IAP(in application purchasing) and level/theme loading. *
- ***************************************************************************************************/
- class LevelController : public QObject
- {
- Q_OBJECT
- /***********************************************************************************************
- *A read-only property used to control the game characters look. *
- ***********************************************************************************************/
- Q_PROPERTY(QString face READ getFace NOTIFY faceChanged)
- public:
- /***********************************************************************************************
- *The constructor, requiring a mandatory level object. *
- ***********************************************************************************************/
- explicit LevelController(Level *level,QObject *parent = 0);
- /***********************************************************************************************
- *An invokable method used to trigger level/theme loading form qml. *
- ***********************************************************************************************/
- Q_INVOKABLE void load(int index);
- /***********************************************************************************************
- *An invokable method used to trigger IAP purchase form qml. *
- ***********************************************************************************************/
- Q_INVOKABLE void buy(int index);
- /***********************************************************************************************
- *A method used to access the model used to represent purchasable items. *
- ***********************************************************************************************/
- LevelModel* getLevelModel() const;
- /***********************************************************************************************
- *A method returning the current value of the face property. *
- ***********************************************************************************************/
- QString getFace() const;
- private slots:
- #if defined(IAP_ENABLED)
- /***************************************************************************************************
- *IAP data received handling slots. *
- ***************************************************************************************************/
- /***********************************************************************************************
- *A slot triggered by the IAPClients productDataReceved signal. *
- ***********************************************************************************************/
- void productDataReceved(int requestId,QString status,IAPClient::ProductData data);
- /***********************************************************************************************
- *A slot triggered by the IAPClients restorableProductsReceived signal. *
- ***********************************************************************************************/
- void restorableProductsReceived(int requestId,QString status,IAPClient::ProductList data);
- /***********************************************************************************************
- *A slot triggered by the IAPClients userAndDeviceDataReceived signal. *
- ***********************************************************************************************/
- void userAndDeviceDataReceived(int requestId,QString account,QString imei,QString imsi,
- QString country,QString language,QString deviceModel);
- /**************************************************************************************************/
- /***************************************************************************************************
- *IAP purchase flow handling slots. *
- ***************************************************************************************************/
- /***********************************************************************************************
- *A slot triggered by the IAPClients purchaseCompleted signal. *
- ***********************************************************************************************/
- void purchaseCompleted(int requsetId,QString status,QString ticket);
- /***********************************************************************************************
- *A slot triggered by the IAPClients purchaseFlowFinished signal. *
- ***********************************************************************************************/
- void purchaseFlowFinished(int requsetId);
- /**************************************************************************************************/
- /***************************************************************************************************
- *IAP restoration flow handling slots. *
- ***************************************************************************************************/
- /***********************************************************************************************
- *A slot triggered by the IAPClients restorationCompleted signal. *
- ***********************************************************************************************/
- void restorationCompleted(int requsetId,QString status,QString ticket);
- /***********************************************************************************************
- *A slot triggered by the IAPClients restorationFlowFinished signal. *
- ***********************************************************************************************/
- void restorationFlowFinished(int requsetId);
- /**************************************************************************************************/
- #endif
- signals:
- /***********************************************************************************************
- *A signal emitted after the purchase/restore has been finished, to hide the software keys. *
- ***********************************************************************************************/
- void hack();
- /***********************************************************************************************
- *A signal emitted after successfully loading a new level, used to trigger qml level reload. *
- ***********************************************************************************************/
- void levelReload();
- /***********************************************************************************************
- *A signal emitted after loading a theme, notifies that the face properties value has changed. *
- ***********************************************************************************************/
- void faceChanged();
- private:
- /***********************************************************************************************
- *A private method used to trigger purchasable item loading. *
- ***********************************************************************************************/
- void loadItems();
- /***********************************************************************************************
- *A private method used request IAP data for a single item. *
- ***********************************************************************************************/
- void requestItemData();
- /***********************************************************************************************
- *A private method used unlock purchasable items. *
- ***********************************************************************************************/
- void unlock(QString itemId,QString purchaseTicket);
- /***********************************************************************************************
- *The level model object. *
- ***********************************************************************************************/
- LevelModel *m_Model;
- /***********************************************************************************************
- *The IAPClient object. *
- ***********************************************************************************************/
- #if defined(IAP_ENABLED)
- IAPClient *m_IAPClient;
- #endif
- /***********************************************************************************************
- *The level object. *
- ***********************************************************************************************/
- Level *m_level;
- /***********************************************************************************************
- *A list used to hold the strings defining items loaded from the Items.data file. * *
- ***********************************************************************************************/
- QStringList itemLines;
- /***********************************************************************************************
- *A request queue for the level items, int request id, QString product id QString level name. *
- ***********************************************************************************************/
- QHash<int,QPair<QString,QString> > levelRequests;
- /***********************************************************************************************
- *A request queue for theme items, int request id, QString product id QString theme name. *
- ***********************************************************************************************/
- QHash<int,QPair<QString,QString> > themeRequests;
- /***********************************************************************************************
- *A string holding the value of the face property. *
- ***********************************************************************************************/
- QString face;
- };
- #endif // LEVELCONTROLLER_HPP
|