qiap_p.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef QIAP_P_H
  2. #define QIAP_P_H
  3. #define INVALID_VALUE -1
  4. #include <iapclient.h>
  5. #include <QStringList>
  6. class QIap;
  7. /**
  8. * @class QIapPrivate
  9. *
  10. * @brief In App Purchase Private wrapper implementation
  11. *
  12. */
  13. class QIapPrivate : public QObject
  14. {
  15. Q_OBJECT
  16. public:
  17. /**
  18. * @brief constructor
  19. *
  20. */
  21. explicit QIapPrivate(QIap* aPublicAPI = 0);
  22. /**
  23. * @brief destructor
  24. *
  25. */
  26. virtual ~QIapPrivate();
  27. void getProducts();
  28. int purchaseProductByID(QString productId, IAPClient::ForceRestorationFlag restoration);
  29. public:
  30. /**
  31. * List of product items as read from app's config file.
  32. */
  33. QStringList products;
  34. /**
  35. * Index in *products* list indicating which is the last product for which
  36. * info was requested from Ovi
  37. */
  38. int productsRequested;
  39. /**
  40. * Holds the requestId returned by the current In-Application Purchase call
  41. */
  42. int current_requestId;
  43. QString current_productId;
  44. QString productId;
  45. /**
  46. * In-Application Purchase API
  47. */
  48. IAPClient *iap_client;
  49. /**
  50. * List of availble products as retrieved from Ovi
  51. */
  52. QList<IAPClient::ProductDataHash> available_products;
  53. IAPClient::ProductDataList restorableProductItems;
  54. private:
  55. bool isPurchased(int drmErrCode, QString& fileName);
  56. QString getProductId(const QString& path);
  57. void requestNextProduct();
  58. bool isProductActivated(QString product);
  59. static bool readTicket(const QString&);
  60. static void saveTicket(const QString& purchaseTicket, QString& productID);
  61. static QString getTicketDir();
  62. static QString getTicketUri(const QString& productID);
  63. static void resetPurchases();
  64. private slots:
  65. /**
  66. * In-Application Purchase specific slots
  67. *
  68. * Slots matching the signals of the In-Application Purchase API, allowing
  69. * the application to receive callbacks
  70. */
  71. void productDataReceived( int requestId, QString status, IAPClient::ProductDataHash productData );
  72. void purchaseCompleted( int requestId, QString status, QString purchaseTicket );
  73. void purchaseFlowFinished( int requestId );
  74. void userAndDeviceDataReceived( int requestId, QString status, IAPClient::UserAndDeviceDataHash userdata );
  75. void restorableProductsReceived( int requestId, QString status,IAPClient::ProductDataList items );
  76. void restorationFlowFinished( int requestId );
  77. void restorationCompleted( int requestId, QString status, QString purchaseTicket );
  78. /**
  79. * Slot to handle user's tap on the Restore button on a catalog's product item.
  80. */
  81. void restoreProducts();
  82. private:
  83. QIap* d;
  84. friend class QIap;
  85. };
  86. #endif // QIAP_P_H