@@ -28,7 +28,7 @@
30// The observer callback for the package we are watching.
30// The observer callback for the package we are watching.
31−static void observer(PayPackage* /* package */, const char* /*itemid*/, PayPackageItemStatus status, void* user_data) {
31+static void observer(PayPackage* /* package */, const char* itemid, PayPackageItemStatus status, void* user_data) {
32 // This function is called in libpay's thread, so be careful what you call
32 // This function is called in libpay's thread, so be careful what you call
33 // Emitting signals should be fine as long as they use Queued or Auto
33 // Emitting signals should be fine as long as they use Queued or Auto
34 // connections (the default)
34 // connections (the default)
@@ -36,6 +36,11 @@ static void observer(PayPackage* /* package */, const char* /*itemid*/, PayPacka
37 Payments *self = static_cast<Payments*>(user_data);
37 Payments *self = static_cast<Payments*>(user_data);
39+ // If the item ID is different, ignore it.
40+ if (itemid != self->storeItemId()) {
39 // FIXME: No error reporting from libpay, but we need to show some
44 // FIXME: No error reporting from libpay, but we need to show some
40 // types of errors to the user. https://launchpad.net/bugs/1333403
45 // types of errors to the user. https://launchpad.net/bugs/1333403
41 switch (status) {
46 switch (status) {
@@ -51,11 +56,13 @@ Payments::Payments(QObject *parent)
51 : QObject(parent)
56 : QObject(parent)
53 m_package = pay_package_new("click-scope");
58 m_package = pay_package_new("click-scope");
59+ pay_package_item_observer_install(m_package, observer, this);
56Payments::~Payments()
62Payments::~Payments()
58 pay_package_item_observer_uninstall(m_package, observer, this);
64 pay_package_item_observer_uninstall(m_package, observer, this);
65+ pay_package_delete(m_package);
61QString Payments::currency() const
68QString Payments::currency() const
@@ -108,8 +115,6 @@ void Payments::setStoreItemId(const QString &store_item_id)
111− pay_package_item_observer_uninstall(m_package, observer, this);
112− pay_package_item_observer_install(m_package, observer, this);
113 pay_package_item_start_verification(m_package,
118 pay_package_item_start_verification(m_package,
114 m_store_item_id.toLocal8Bit().data());
119 m_store_item_id.toLocal8Bit().data());