buycatalog.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef BUYCATALOG_H
  2. #define BUYCATALOG_H
  3. #include "ui_buycatalog.h"
  4. #include <QtGui/QDialog>
  5. #include <iapclient.h>
  6. class ProductInfo;
  7. class QProgressDialog;
  8. class BuyCatalog : public QDialog
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit BuyCatalog(QWidget *parent = NULL);
  13. virtual ~BuyCatalog();
  14. inline void setDefaultProduct(QString& product){
  15. defaultProduct = product;
  16. }
  17. private:
  18. void requestNextProduct();
  19. bool isProductActivated(QString product);
  20. private slots:
  21. /*
  22. * In-Application Purchase specific slots
  23. *
  24. * Slots matching the signals of the In-Application Purchase API, allowing
  25. * the application to receive callbacks
  26. */
  27. void productDataReceived( int requestId, QString status,
  28. IAPClient::ProductDataHash productData );
  29. void purchaseCompleted( int requestId, QString status, QString purchaseTicket );
  30. void purchaseFlowFinished( int requestId );
  31. void userAndDeviceDataReceived( int requestId, QString status,
  32. IAPClient::UserAndDeviceDataHash userdata );
  33. void restorableProductsReceived( int requestId, QString status,
  34. IAPClient::ProductDataList items );
  35. void restorationFlowFinished( int requestId );
  36. void restorationCompleted( int requestId, QString status, QString purchaseTicket );
  37. private slots:
  38. /*
  39. * Slot to handle user's tap on the Buy button on a catalog's product item.
  40. */
  41. void buyProduct();
  42. /*
  43. * Slot to handle user's tap on a catalog's product item, as a way of
  44. * accessing more information about it.
  45. *
  46. * QListWidgetItem* item - the list item on which the tap occured
  47. */
  48. void moreProductInfo(QListWidgetItem* item);
  49. /*
  50. * infoDialogClosed will be closed when the opened infoDialog gets closed.
  51. *
  52. * int result - the reason (positive or negative choice) for which the dialog was closed
  53. */
  54. void infoDialogClosed(int result);
  55. /*
  56. * Slot to handle user's tap on the Restore button on a catalog's product item.
  57. */
  58. void restoreProducts();
  59. private:
  60. /*
  61. * UI class.
  62. */
  63. Ui::BuyCatalogClass ui;
  64. QString defaultProduct;
  65. /*
  66. * List of product items as read from app's config file.
  67. */
  68. QStringList products;
  69. /*
  70. * Index in *products* list indicating which is the last product for which
  71. * info was requested from Ovi
  72. */
  73. int productsRequested;
  74. /*
  75. * Holds the requestId returned by the current In-Application Purchase call
  76. */
  77. int current_requestId;
  78. QString current_productId;
  79. /*
  80. * In-Application Purchase API
  81. */
  82. IAPClient *iap_client;
  83. /*
  84. * List of availble products as retrieved from Ovi
  85. */
  86. QList<IAPClient::ProductDataHash> available_products;
  87. /*
  88. * Dialog showing the full IAPClient::ProductData product description
  89. */
  90. ProductInfo* infoDialog;
  91. /*
  92. * The index of the product for which more info is displayed.
  93. */
  94. int current_product_index;
  95. IAPClient::ProductDataList restorableProductItems;
  96. QProgressDialog* busyIndicator;
  97. };
  98. #endif // BUYCATALOG_H