qiap.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef QIAP_H
  2. #define QIAP_H
  3. #include <QObject>
  4. #include <QList>
  5. #include <QProgressDialog>
  6. #include <iapclient.h>
  7. class QIapPrivate;
  8. /**
  9. * @class QIap
  10. *
  11. * @brief In App Purchase wrapper implementation for local stored content
  12. *
  13. */
  14. class QIap : public QObject
  15. {
  16. Q_OBJECT
  17. Q_DECLARE_PRIVATE(QIap)
  18. Q_CLASSINFO("Author", "Sebastiano Galazzo")
  19. Q_CLASSINFO("Email", "sebastiano.galazzo@gmail.com")
  20. public:
  21. /**
  22. * @brief Constructor
  23. *
  24. * @param parent
  25. */
  26. explicit QIap(QObject *parent = 0);
  27. /**
  28. * @brief Destructor
  29. */
  30. virtual ~QIap();
  31. /**
  32. * @brief List of available IAP products on OVI Store
  33. */
  34. QList<IAPClient::ProductDataHash>& availableProducts();
  35. /**
  36. * @brief Purchase a product by In-app ID
  37. * @param productId
  38. * @param restoration
  39. */
  40. Q_INVOKABLE int purchaseProductByID(QString productId, IAPClient::ForceRestorationFlag restoration=IAPClient::ForcedAutomaticRestoration);
  41. /**
  42. * @brief Purchase a product by product name ( info field )
  43. * @param productName
  44. * @param restoration
  45. */
  46. Q_INVOKABLE int purchaseProductByName(QString productName, IAPClient::ForceRestorationFlag restoration=IAPClient::ForcedAutomaticRestoration);
  47. /**
  48. * @brief
  49. * @param fileName
  50. * @return true if file is purchased
  51. */
  52. Q_INVOKABLE bool isPurchased(QString fileName);
  53. /**
  54. * @brief Get DRM file content if the device can access the encrypted file
  55. *
  56. * @param productID
  57. * @param fileName
  58. *
  59. */
  60. Q_INVOKABLE QByteArray getDRMFileContent(QString productID,QString fileName);
  61. signals:
  62. void purchaseCompleted(QString status, QString productID);
  63. void purchaseFlowFinished( int requestId );
  64. void getProductsCompleted();
  65. void restoreProductsCompleted();
  66. void itemRestored(QString productID);
  67. public slots:
  68. /**
  69. * @brief Get available IAP products on OVI Store
  70. */
  71. void getProducts();
  72. /**
  73. * @brief Retrieve previously purchased products
  74. */
  75. void restoreProducts();
  76. /**
  77. * @brief Reset purchased products
  78. */
  79. void resetPurchases();
  80. protected:
  81. /**
  82. * @variable Private implementation of the API
  83. */
  84. QIapPrivate* const d_ptr;
  85. private:
  86. QProgressDialog* busyIndicator;
  87. };
  88. #endif // QIAP_H