Merge lp:~kaijanmaki/unity8/indicator-root-state-icons-fix into lp:unity8

Proposed by Antti Kaijanmäki
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 800
Merged at revision: 893
Proposed branch: lp:~kaijanmaki/unity8/indicator-root-state-icons-fix
Merge into: lp:unity8
Diff against target: 85 lines (+44/-8)
2 files modified
plugins/Unity/Indicators/rootactionstate.cpp (+7/-8)
tests/plugins/Unity/Indicators/rootactionstatetest.cpp (+37/-0)
To merge this branch: bzr merge lp:~kaijanmaki/unity8/indicator-root-state-icons-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Nick Dedekind (community) Approve
Michał Sawicz Abstain
Ted Gould (community) Approve
Antti Kaijanmäki (community) Approve
Review via email: mp+213727@code.launchpad.net

Commit message

Indicators/RootActionState: use g_variant_iter_loop to extract icons.

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
https://code.launchpad.net/~unity-api-team/indicator-network/indicator-network-cpp/+merge/210973

indicator-network is the only indicator that currently uses the "icons"

 * Did you perform an exploratory manual test run of your code change and any related functionality?

Yes.

 * Did you make sure that your branch does not contain spurious tags?

Yes.

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

No.

 * If you changed the UI, has there been a design review?

Ui didn't change.

silo:
https://launchpad.net/~ci-train-ppa-service/+archive/landing-009/

Testing instructions:

* install the silo, apt-get update, apt-get dist-upgrade
* reboot
* after startup on n4, you should see indicator-network showing pre-label (SIM Locked) and one icon
* unlock the sim
* now you should see two icons, one for the cellular strength and one for the networking (either wifi disconenected icon or a mobile broadband tech icon 2G, 3G, etc..)
* if you can see multiple icons coming from indicator-network, the MP is working.
* actually if you can even see one, it's working as even the single icon is passed through the 'icons' property, but I wanted to use the opportunity to get you to test the pin unlocking as well ;)

To post a comment you must log in.
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

Proposing this change as I noticed I was unable to get multiple icons working with my new indicator-network code base. Although the "icons" element in the root state is not documented in the "Indicators and Settings Protocol" document I figured it out that the variant in the VARDICT should contain an array of GVariants coming from g_icon_serialize(). Now, when my code did exactly that (see the dump below), the icon loading failed. For some reason the g_variant_get_child_value() returned a variant which contained another variant (the one coming from _serialize).

So the old code would have required an additional call:
    child = g_variant_get_variant(child);

Using iter_loop() gets the correct results and is also the way "GVariant Format Strings" manual shows as an example how to unpack arrays.

===

$ dbus-send --print-reply --session --dest=com.canonical.indicator.network /com/canonical/indicator/network org.gtk.Actions.Describe string:phone.network-status

method return sender=:1.430 -> dest=:1.468 reply_serial=2
struct {
    boolean true
    signature ""
    array [
        variant array [
            dict entry(
                string "icon"
                variant struct {
                    string "themed"
                    variant array [
                        string "nm-signal-50-secure"
                    ]
                }
            )
            dict entry(
                string "icons"
                variant array [
                    variant struct {
                        string "themed"
                        variant array [
                            string "nm-signal-75"
                        ]
                    }
                    variant struct {
                        string "themed"
                        variant array [
                            string "nm-signal-25"
                        ]
                    }
                ]
            )
            dict entry(
                string "title"
                variant string "Network"
            )
            dict entry(
                string "visible"
                variant boolean true
            )
        ]
    ]
}

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:797
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~kaijanmaki/unity8/indicator-root-state-icons-fix/+merge/213727/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity8-ci/2707/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4441/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4040
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1577
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/1228
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1232
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1232/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/1228
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3840/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4546
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4546/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4069
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4069/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6298
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5523

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2707/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:797
http://jenkins.qa.ubuntu.com/job/unity8-ci/2708/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4442/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4041
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1578
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/1229
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1233
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1233/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/1229
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3841/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4547
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4547/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4070
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4070/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6299
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5526

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2708/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

ted pointed me to this more up to date wiki page:
https://wiki.ubuntu.com/SystemComponents#Root_Item

icons : av
If there is more than one icon shown, this should be an array of serialized GIcons in the order they should appear. This item should take precedence over 'icon'.

AFAIK the dbus-send printout confirms that my code in the indicator-service side is exporting exactly this.

Here's a dump from the vala code base currently on phone images:
struct {
    boolean true
    signature ""
    array [
        variant array [
            dict entry(
                string "title"
                variant string "Network"
            )
            dict entry(
                string "icon"
                variant struct {
                    string "themed"
                    variant array [
                        string "network-cellular-3g"
                    ]
                }
            )
            dict entry(
                string "accessibility-desc"
                variant string "Network (cellular, 3g)"
            )
            dict entry(
                string "icons"
                variant array [
                    struct {
                        string "themed"
                        variant array [
                            string "gsm-3g-medium"
                        ]
                    }
                    struct {
                        string "themed"
                        variant array [
                            string "network-cellular-3g"
                        ]
                    }
                ]
            )
            dict entry(
                string "visible"
                variant boolean true
            )
        ]
    ]
}

To me that looks like the signature of "icons" is a(sv).

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

My indicator-network is giving a variant of type: a(sv)
Multi-icon is not working for me.

review: Needs Information
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

yes, as I said the old vala code is sending a(sv) which is not what the wikipage specifies.

This MP is part of a landing slot that fixes indicator-network side also to send a(v).

Also, by sending a(v) we can also provide plain strings inside a variant to implement the FIXME: should send URL.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Ok. In that case it looks ok; but cannot approve until the indicator-network code is available to test alongside it.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

> Ok. In that case it looks ok; but cannot approve until the indicator-network
> code is available to test alongside it.

I will link to a silo once we have it available.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Antti, we'll also need you to copy&paste the top part of https://wiki.ubuntu.com/Process/Merges/Checklists/Unity8 as description and answer the questions.

Revision history for this message
Michał Sawicz (saviq) wrote :

Please strip tags: http://people.canonical.com/~msawicz/unity8/strip-u8-tags.sh

Do the same on your local checkout(s), too!

review: Needs Fixing
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

and stripped tags.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

needs test

review: Needs Fixing
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

merged tests and deleted the old tags from this remote branch as well for real.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve
Revision history for this message
Michał Sawicz (saviq) :
review: Abstain
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

I ran the whole unite8-autopilot tests on n4:

Ran 49 tests in 1782.995s
OK

Revision history for this message
Nick Dedekind (nick-dedekind) :
review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes.

 * Did CI run pass? If not, please explain why.
Unrelated failure.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
801. By Antti Kaijanmäki

merge upstream

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/Indicators/rootactionstate.cpp'
2--- plugins/Unity/Indicators/rootactionstate.cpp 2013-10-11 15:51:46 +0000
3+++ plugins/Unity/Indicators/rootactionstate.cpp 2014-05-14 05:50:30 +0000
4@@ -240,19 +240,18 @@
5
6 QStringList icons;
7
8- if (g_variant_type_is_array(g_variant_get_type(vvalue))) {
9-
10-
11- for (int i = 0, iMax = g_variant_n_children(vvalue); i < iMax; i++) {
12- GVariant *child = g_variant_get_child_value(vvalue, i);
13-
14+ if (g_variant_is_of_type(vvalue, G_VARIANT_TYPE("av"))) {
15+ GVariantIter iter;
16+ GVariant *val = 0;
17+ g_variant_iter_init (&iter, vvalue);
18+ while (g_variant_iter_loop (&iter, "v", &val))
19+ {
20 // FIXME - should be sending a url.
21- GIcon *gicon = g_icon_deserialize (child);
22+ GIcon *gicon = g_icon_deserialize (val);
23 if (gicon) {
24 icons << iconUri(gicon);
25 g_object_unref (gicon);
26 }
27- g_variant_unref(child);
28 }
29 }
30 // will overwrite icon.
31
32=== modified file 'tests/plugins/Unity/Indicators/rootactionstatetest.cpp'
33--- tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2013-10-11 15:06:09 +0000
34+++ tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2014-05-14 05:50:30 +0000
35@@ -21,6 +21,7 @@
36
37 #include <unitymenumodel.h>
38 #include <QtTest>
39+#include <gio/gio.h>
40
41 class RootActionStateTest : public QObject
42 {
43@@ -52,6 +53,42 @@
44 QVERIFY(rootState->menu() == NULL);
45 delete rootState;
46 }
47+
48+ void testToQVariantIcons()
49+ {
50+ GVariantBuilder builderIcons;
51+ g_variant_builder_init(&builderIcons, G_VARIANT_TYPE("av"));
52+ for (int i = 0; i < 3; i ++) {
53+
54+ GIcon* icon = NULL;
55+ icon = g_icon_new_for_string (QString("testIcon%1").arg(i).toUtf8().constData(), NULL);
56+
57+ g_variant_builder_add(&builderIcons,
58+ "v",
59+ g_icon_serialize (icon));
60+ g_object_unref(icon);
61+ }
62+
63+ GVariantBuilder builderParams;
64+ g_variant_builder_init(&builderParams, G_VARIANT_TYPE_ARRAY);
65+ GVariant* icons = g_variant_builder_end (&builderIcons);
66+ g_variant_ref_sink (icons);
67+ g_variant_builder_add (&builderParams, "{sv}", g_strdup ("icons"), icons, NULL);
68+
69+ GVariant* params = g_variant_builder_end (&builderParams);
70+
71+ RootActionState rootState;
72+ QVariant result = rootState.toQVariant(params);
73+ g_variant_unref(params);
74+
75+ QVariantMap paramResult = result.toMap();
76+ QVERIFY(paramResult.contains("icons"));
77+
78+ QStringList serializedIcons = paramResult["icons"].toStringList();
79+ QVERIFY(serializedIcons[0] == "image://theme/testIcon0");
80+ QVERIFY(serializedIcons[1] == "image://theme/testIcon1");
81+ QVERIFY(serializedIcons[2] == "image://theme/testIcon2");
82+ }
83 };
84
85 QTEST_GUILESS_MAIN(RootActionStateTest)

Subscribers

People subscribed via source and target branches