Merge lp:~charlesk/pay-service/downgrade-g-warnings into lp:pay-service/15.04

Proposed by Charles Kerr
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 177
Merged at revision: 52
Proposed branch: lp:~charlesk/pay-service/downgrade-g-warnings
Merge into: lp:pay-service/15.04
Prerequisite: lp:~dobey/pay-service/cgo-flags
Diff against target: 180 lines (+89/-79)
1 file modified
libpay/internal/package.cpp (+89/-79)
To merge this branch: bzr merge lp:~charlesk/pay-service/downgrade-g-warnings
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+274572@code.launchpad.net

Commit message

downgrade some g_critical() log messages to g_warning()

Description of the change

downgrade some g_critical() log messages to g_warning()

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libpay/internal/package.cpp'
2--- libpay/internal/package.cpp 2015-10-15 14:40:42 +0000
3+++ libpay/internal/package.cpp 2015-10-15 14:40:43 +0000
4@@ -202,88 +202,98 @@
5 {
6 std::shared_ptr<PayItem> item;
7
8- // test the inputs
9- g_return_val_if_fail(item_properties != nullptr, item);
10- g_return_val_if_fail(g_variant_is_of_type(item_properties, G_VARIANT_TYPE_VARDICT), item);
11-
12- // make sure we've got a valid sku to construct the PayItem with
13- const char* sku {};
14- g_variant_lookup(item_properties, "sku", "&s", &sku);
15- if (sku == nullptr)
16- {
17- g_variant_lookup(item_properties, "package_name", "&s", &sku);
18- }
19- g_return_val_if_fail(sku != nullptr, item);
20- g_return_val_if_fail(*sku != '\0', item);
21-
22- auto pay_item_deleter = [](PayItem* p){p->unref();};
23- item.reset(new PayItem(sku), pay_item_deleter);
24-
25- // now loop through the dict to build the PayItem's properties
26- GVariantIter iter;
27- gchar* key;
28- GVariant* value;
29- g_variant_iter_init(&iter, item_properties);
30- while (g_variant_iter_loop(&iter, "{sv}", &key, &value))
31- {
32- if (!g_strcmp0(key, "acknowledged_timestamp"))
33- {
34- item->set_acknowledged_timestamp(g_variant_get_uint64(value));
35- }
36- else if (!g_strcmp0(key, "description"))
37- {
38- item->set_description(g_variant_get_string(value, nullptr));
39- }
40- else if (!g_strcmp0(key, "sku") || !g_strcmp0(key, "package_name"))
41- {
42- // no-op; we handled the sku/package_name first
43- }
44- else if (!g_strcmp0(key, "price"))
45- {
46- item->set_price(g_variant_get_string(value, nullptr));
47- }
48- else if (!g_strcmp0(key, "completed_timestamp"))
49- {
50- item->set_completed_timestamp(g_variant_get_uint64(value));
51- }
52- else if (!g_strcmp0(key, "refundable_until"))
53- {
54- item->set_refundable_until(g_variant_get_uint64(value));
55- }
56- else if (!g_strcmp0(key, "purchase_id"))
57- {
58- item->set_purchase_id(g_variant_get_uint64(value));
59- }
60- else if (!g_strcmp0(key, "state"))
61- {
62- auto state = g_variant_get_string(value, nullptr);
63-
64- if (!g_strcmp0(state, "purchased"))
65- {
66- item->set_status(PAY_PACKAGE_ITEM_STATUS_PURCHASED);
67- }
68- else if (!g_strcmp0(state, "approved"))
69- {
70- item->set_status(PAY_PACKAGE_ITEM_STATUS_APPROVED);
71- }
72- else
73- {
74- item->set_status(PAY_PACKAGE_ITEM_STATUS_NOT_PURCHASED);
75- }
76- }
77- else if (!g_strcmp0(key, "type"))
78- {
79- item->set_type(type_from_string(g_variant_get_string(value, nullptr)));
80- }
81- else if (!g_strcmp0(key, "title"))
82- {
83- item->set_title(g_variant_get_string(value, nullptr));
84+ if (item_properties == nullptr)
85+ {
86+ g_warning("%s item_properties variant is NULL", G_STRLOC);
87+ }
88+ else if (!g_variant_is_of_type(item_properties, G_VARIANT_TYPE_VARDICT))
89+ {
90+ g_warning("%s item_properties variant is not a vardict", G_STRLOC);
91+ }
92+ else
93+ {
94+ // make sure we've got a valid sku to construct the PayItem with
95+ const char* sku {};
96+ g_variant_lookup(item_properties, "sku", "&s", &sku);
97+ if (sku == nullptr)
98+ g_variant_lookup(item_properties, "package_name", "&s", &sku);
99+
100+ if (!sku || !*sku)
101+ {
102+ g_warning("%s item_properties variant has no sku or package_name entry", G_STRLOC);
103 }
104 else
105 {
106- auto valstr = g_variant_print(value, true);
107- g_warning("Unhandled item property '%s': '%s'", key, valstr);
108- g_free(valstr);
109+ auto pay_item_deleter = [](PayItem* p){p->unref();};
110+ item.reset(new PayItem(sku), pay_item_deleter);
111+
112+ // now loop through the dict to build the PayItem's properties
113+ GVariantIter iter;
114+ gchar* key;
115+ GVariant* value;
116+ g_variant_iter_init(&iter, item_properties);
117+ while (g_variant_iter_loop(&iter, "{sv}", &key, &value))
118+ {
119+ if (!g_strcmp0(key, "acknowledged_timestamp"))
120+ {
121+ item->set_acknowledged_timestamp(g_variant_get_uint64(value));
122+ }
123+ else if (!g_strcmp0(key, "description"))
124+ {
125+ item->set_description(g_variant_get_string(value, nullptr));
126+ }
127+ else if (!g_strcmp0(key, "sku") || !g_strcmp0(key, "package_name"))
128+ {
129+ // no-op; we handled the sku/package_name first
130+ }
131+ else if (!g_strcmp0(key, "price"))
132+ {
133+ item->set_price(g_variant_get_string(value, nullptr));
134+ }
135+ else if (!g_strcmp0(key, "completed_timestamp"))
136+ {
137+ item->set_completed_timestamp(g_variant_get_uint64(value));
138+ }
139+ else if (!g_strcmp0(key, "refundable_until"))
140+ {
141+ item->set_refundable_until(g_variant_get_uint64(value));
142+ }
143+ else if (!g_strcmp0(key, "purchase_id"))
144+ {
145+ item->set_purchase_id(g_variant_get_uint64(value));
146+ }
147+ else if (!g_strcmp0(key, "state"))
148+ {
149+ auto state = g_variant_get_string(value, nullptr);
150+
151+ if (!g_strcmp0(state, "purchased"))
152+ {
153+ item->set_status(PAY_PACKAGE_ITEM_STATUS_PURCHASED);
154+ }
155+ else if (!g_strcmp0(state, "approved"))
156+ {
157+ item->set_status(PAY_PACKAGE_ITEM_STATUS_APPROVED);
158+ }
159+ else
160+ {
161+ item->set_status(PAY_PACKAGE_ITEM_STATUS_NOT_PURCHASED);
162+ }
163+ }
164+ else if (!g_strcmp0(key, "type"))
165+ {
166+ item->set_type(type_from_string(g_variant_get_string(value, nullptr)));
167+ }
168+ else if (!g_strcmp0(key, "title"))
169+ {
170+ item->set_title(g_variant_get_string(value, nullptr));
171+ }
172+ else
173+ {
174+ auto valstr = g_variant_print(value, true);
175+ g_warning("Unhandled item property '%s': '%s'", key, valstr);
176+ g_free(valstr);
177+ }
178+ }
179 }
180 }
181

Subscribers

People subscribed via source and target branches

to all changes: