Merge lp:~pete-woods/indicator-network/add-ethernet-settings-export into lp:indicator-network

Proposed by Pete Woods on 2017-03-20
Status: Approved
Approved by: dobey on 2017-04-05
Approved revision: 672
Proposed branch: lp:~pete-woods/indicator-network/add-ethernet-settings-export
Merge into: lp:indicator-network
Prerequisite: lp:~pete-woods/indicator-network/clean-up-menu-exports
Diff against target: 389 lines (+101/-29)
14 files modified
src/indicator/factory.cpp (+6/-1)
src/indicator/factory.h (+2/-0)
src/indicator/menu-builder.cpp (+6/-0)
src/indicator/menuitems/ethernet-item.cpp (+2/-2)
src/indicator/menuitems/ethernet-item.h (+1/-1)
src/indicator/menuitems/ethernet-link-item.cpp (+2/-2)
src/indicator/menuitems/ethernet-link-item.h (+1/-1)
src/indicator/sections/ethernet-link-section.cpp (+7/-4)
src/indicator/sections/ethernet-link-section.h (+1/-1)
src/indicator/sections/ethernet-section.cpp (+42/-16)
src/indicator/sections/ethernet-section.h (+1/-1)
tests/integration/indicator-network-test-base.cpp (+8/-0)
tests/integration/indicator-network-test-base.h (+2/-0)
tests/integration/test-indicator-phone.cpp (+20/-0)
To merge this branch: bzr merge lp:~pete-woods/indicator-network/add-ethernet-settings-export
Reviewer Review Type Date Requested Status
dobey (community) 2017-03-20 Approve on 2017-04-05
unity-api-1-bot continuous-integration Approve on 2017-03-20
Review via email: mp+320340@code.launchpad.net

Commit message

Add basic ethernet settings menu export

Description of the change

Add basic ethernet settings menu export

To post a comment you must log in.
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:672
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-network-ci/40/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1837
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1844
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1621
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1621/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1621
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1621/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1621
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1621/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1621
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1621/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1621
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1621/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1621
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1621/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-network-ci/40/rebuild

review: Approve (continuous-integration)
dobey (dobey) wrote :

Approving as the code looks ok, but I'm not sure it makes too much sense on design level.

review: Approve

Unmerged revisions

672. By Pete Woods on 2017-03-20

Add basic ethernet settings menu export

671. By Pete Woods on 2017-03-17

Only physically export a single "phone" and tweak the indicator config file so it's used everywhere

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator/factory.cpp'
2--- src/indicator/factory.cpp 2016-12-23 13:48:02 +0000
3+++ src/indicator/factory.cpp 2017-03-20 12:14:57 +0000
4@@ -172,7 +172,12 @@
5
6 unique_ptr<EthernetSection> Factory::newEthernetSection()
7 {
8- return make_unique<EthernetSection>(d->singletonNmofono());
9+ return make_unique<EthernetSection>(d->singletonNmofono(), false);
10+}
11+
12+unique_ptr<EthernetSection> Factory::newEthernetSettings()
13+{
14+ return make_unique<EthernetSection>(d->singletonNmofono(), true);
15 }
16
17 unique_ptr<WwanSection> Factory::newWwanSection(SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch)
18
19=== modified file 'src/indicator/factory.h'
20--- src/indicator/factory.h 2016-12-01 11:40:00 +0000
21+++ src/indicator/factory.h 2017-03-20 12:14:57 +0000
22@@ -61,6 +61,8 @@
23
24 virtual EthernetSection::UPtr newEthernetSection();
25
26+ virtual EthernetSection::UPtr newEthernetSettings();
27+
28 virtual std::unique_ptr<WifiSection> newWiFiSection(SwitchItem::Ptr wifiSwitch);
29
30 virtual std::unique_ptr<VpnSection> newVpnSection();
31
32=== modified file 'src/indicator/menu-builder.cpp'
33--- src/indicator/menu-builder.cpp 2017-03-20 12:14:57 +0000
34+++ src/indicator/menu-builder.cpp 2017-03-20 12:14:57 +0000
35@@ -46,10 +46,12 @@
36 WifiSection::SPtr m_wifiSection;
37 WwanSection::SPtr m_wwanSection;
38 VpnSection::SPtr m_vpnSection;
39+ EthernetSection::SPtr m_ethernetSettings;
40
41 MenuExporter::UPtr m_menuExporter;
42 MenuExporter::UPtr m_greeterMenuExporter;
43 MenuExporter::UPtr m_wifiSettingsMenuExporter;
44+ MenuExporter::UPtr m_ethernetSettingsMenuExporter;
45
46 MenuExporter::UPtr m_ubiquityMenuExporter;
47
48@@ -156,6 +158,8 @@
49 d->m_mainMenu->addSection(d->m_vpnSection);
50 d->m_greeterMenu->addSection(d->m_vpnSection);
51
52+ d->m_ethernetSettings = factory.newEthernetSettings();
53+
54 // we have a single actiongroup for all the menus.
55 d->m_actionGroupMerger = factory.newActionGroupMerger();
56 d->m_actionGroupMerger->add(d->m_flightModeSwitch->actionGroup());
57@@ -163,12 +167,14 @@
58 d->m_actionGroupMerger->add(d->m_hotspotSwitch->actionGroup());
59 d->m_actionGroupMerger->add(d->m_mainMenu->actionGroup());
60 d->m_actionGroupMerger->add(d->m_greeterMenu->actionGroup());
61+ d->m_actionGroupMerger->add(d->m_ethernetSettings->actionGroup());
62 d->m_actionGroupExporter = factory.newActionGroupExporter(d->m_actionGroupMerger->actionGroup(),
63 "/com/canonical/indicator/network");
64
65 d->m_menuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone", d->m_mainMenu->menu());
66 d->m_greeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_greeter", d->m_greeterMenu->menu());
67 d->m_wifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_wifi_settings", d->m_wifiSection->settingsModel());
68+ d->m_ethernetSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_ethernet_settings", d->m_ethernetSettings->menuModel());
69
70 d->m_ubiquityMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/ubiquity", d->m_ubiquityMenu->menu());
71
72
73=== modified file 'src/indicator/menuitems/ethernet-item.cpp'
74--- src/indicator/menuitems/ethernet-item.cpp 2016-12-05 11:07:31 +0000
75+++ src/indicator/menuitems/ethernet-item.cpp 2017-03-20 12:14:57 +0000
76@@ -49,11 +49,11 @@
77 MenuItem::Ptr m_item;
78 };
79
80-EthernetItem::EthernetItem(unsigned int id)
81+EthernetItem::EthernetItem(unsigned int id, bool isSettingsMenu)
82 {
83 d.reset(new Private(*this));
84
85- QString actionIdBase = "ethernet." + QString::number(id);
86+ QString actionIdBase = "ethernet." + QString::number(id) + (isSettingsMenu? "-settings": "");
87
88 QString statusConnectedActionId = actionIdBase;
89 QString statusLabelActionId = actionIdBase + "::status-label";
90
91=== modified file 'src/indicator/menuitems/ethernet-item.h'
92--- src/indicator/menuitems/ethernet-item.h 2016-12-01 11:40:00 +0000
93+++ src/indicator/menuitems/ethernet-item.h 2017-03-20 12:14:57 +0000
94@@ -37,7 +37,7 @@
95 public:
96 typedef std::shared_ptr<EthernetItem> Ptr;
97
98- EthernetItem(unsigned int id);
99+ EthernetItem(unsigned int id, bool isSettingsMenu);
100 virtual ~EthernetItem();
101
102 virtual MenuItem::Ptr menuItem();
103
104=== modified file 'src/indicator/menuitems/ethernet-link-item.cpp'
105--- src/indicator/menuitems/ethernet-link-item.cpp 2016-12-01 11:40:00 +0000
106+++ src/indicator/menuitems/ethernet-link-item.cpp 2017-03-20 12:14:57 +0000
107@@ -69,12 +69,12 @@
108 bool m_showInterface = true;
109 };
110
111-EthernetLinkItem::EthernetLinkItem(EthernetLink::SPtr ethernetLink) :
112+EthernetLinkItem::EthernetLinkItem(EthernetLink::SPtr ethernetLink, bool isSettingsMenu) :
113 d(new Private)
114 {
115 d->m_ethernetLink = ethernetLink;
116
117- d->m_item = make_shared<EthernetItem>(ethernetLink->id());
118+ d->m_item = make_shared<EthernetItem>(ethernetLink->id(), isSettingsMenu);
119
120 m_actionGroupMerger->add(d->m_item->actionGroup());
121
122
123=== modified file 'src/indicator/menuitems/ethernet-link-item.h'
124--- src/indicator/menuitems/ethernet-link-item.h 2016-12-01 11:40:00 +0000
125+++ src/indicator/menuitems/ethernet-link-item.h 2017-03-20 12:14:57 +0000
126@@ -31,7 +31,7 @@
127 public:
128 UNITY_DEFINES_PTRS(EthernetLinkItem);
129
130- EthernetLinkItem(nmofono::ethernet::EthernetLink::SPtr link);
131+ EthernetLinkItem(nmofono::ethernet::EthernetLink::SPtr link, bool isSettingsMenu);
132 ~EthernetLinkItem() = default;
133
134 MenuItem::Ptr menuItem() override;
135
136=== modified file 'src/indicator/sections/ethernet-link-section.cpp'
137--- src/indicator/sections/ethernet-link-section.cpp 2016-12-01 11:40:00 +0000
138+++ src/indicator/sections/ethernet-link-section.cpp 2017-03-20 12:14:57 +0000
139@@ -41,6 +41,8 @@
140
141 EthernetLink::SPtr m_link;
142
143+ bool m_isSettingsMenu = false;
144+
145 ActionGroupMerger::Ptr m_actionGroupMerger;
146
147 ActionGroup::Ptr m_actionGroup;
148@@ -102,7 +104,7 @@
149
150 m_connectionsMenu->clear();
151
152- if (connections.size() <= 1)
153+ if (!m_isSettingsMenu && connections.size() <= 1)
154 {
155 return;
156 }
157@@ -151,11 +153,12 @@
158 }
159 };
160
161-EthernetLinkSection::EthernetLinkSection(Manager::Ptr manager, EthernetLink::SPtr link) :
162+EthernetLinkSection::EthernetLinkSection(Manager::Ptr manager, EthernetLink::SPtr link, bool isSettingsMenu) :
163 d(new Private())
164 {
165 d->m_manager = manager;
166 d->m_link = link;
167+ d->m_isSettingsMenu = isSettingsMenu;
168
169 d->m_actionGroupMerger = make_shared<ActionGroupMerger>();
170 d->m_actionGroup = make_shared<ActionGroup>();
171@@ -164,7 +167,7 @@
172 d->m_menuMerger = make_shared<MenuMerger>();
173
174 d->m_linkMenu = make_shared<Menu>();
175- d->m_linkItem = make_shared<EthernetLinkItem>(d->m_link);
176+ d->m_linkItem = make_shared<EthernetLinkItem>(d->m_link, isSettingsMenu);
177 d->m_linkMenu->append(d->m_linkItem->menuItem());
178 d->m_actionGroupMerger->add(d->m_linkItem->actionGroup());
179
180@@ -178,7 +181,7 @@
181 d->m_menuMerger->append(d->m_linkMenu);
182 d->m_menuMerger->append(d->m_connectionsMenu);
183
184- QString actionName = "ethernet." + QString::number(link->id()) + "::connection";
185+ QString actionName = "ethernet." + QString::number(link->id()) + "::connection" + (isSettingsMenu? "-settings": "");
186 d->m_connectionAction = make_shared<Action>(actionName, G_VARIANT_TYPE_STRING, TypedVariant<string>(""));
187 d->m_actionGroup->add(d->m_connectionAction);
188
189
190=== modified file 'src/indicator/sections/ethernet-link-section.h'
191--- src/indicator/sections/ethernet-link-section.h 2016-12-05 11:07:31 +0000
192+++ src/indicator/sections/ethernet-link-section.h 2017-03-20 12:14:57 +0000
193@@ -29,7 +29,7 @@
194 public:
195 UNITY_DEFINES_PTRS(EthernetLinkSection);
196
197- explicit EthernetLinkSection(nmofono::Manager::Ptr manager, nmofono::ethernet::EthernetLink::SPtr link);
198+ explicit EthernetLinkSection(nmofono::Manager::Ptr manager, nmofono::ethernet::EthernetLink::SPtr link, bool isSettingsMenu);
199
200 ~EthernetLinkSection();
201
202
203=== modified file 'src/indicator/sections/ethernet-section.cpp'
204--- src/indicator/sections/ethernet-section.cpp 2016-12-01 11:40:00 +0000
205+++ src/indicator/sections/ethernet-section.cpp 2017-03-20 12:14:57 +0000
206@@ -40,14 +40,20 @@
207 public:
208 Manager::Ptr m_manager;
209
210+ bool m_isSettingsMenu = false;
211+
212 Menu::Ptr m_settingsMenu;
213
214 ActionGroupMerger::Ptr m_actionGroupMerger;
215
216 MenuMerger::Ptr m_menuMerger;
217
218+ MenuMerger::Ptr m_links;
219+
220 QMap<EthernetLink::SPtr, EthernetLinkSection::SPtr> m_items;
221
222+ TextItem::Ptr m_openEthernetSettings;
223+
224 Private()
225 {
226 }
227@@ -69,6 +75,8 @@
228 return;
229 }
230
231+ m_links->clear();
232+
233 for (auto connection : removed)
234 {
235 m_actionGroupMerger->remove(m_items[connection]->actionGroup());
236@@ -77,13 +85,11 @@
237
238 for (auto link : added)
239 {
240- auto section = make_shared<EthernetLinkSection>(m_manager, link);
241+ auto section = make_shared<EthernetLinkSection>(m_manager, link, m_isSettingsMenu);
242 m_items[link] = section;
243 m_actionGroupMerger->add(section->actionGroup());
244 }
245
246- m_menuMerger->clear();
247-
248 multimap<Link::Id, EthernetLinkSection::SPtr> sorted;
249 QMapIterator<EthernetLink::SPtr, EthernetLinkSection::SPtr> it(m_items);
250 while (it.hasNext())
251@@ -93,29 +99,49 @@
252 }
253 for (auto pair : sorted)
254 {
255- m_menuMerger->append(pair.second->menuModel());
256- }
257-
258- if (!links.isEmpty())
259- {
260- m_menuMerger->append(m_settingsMenu);
261+ m_links->append(pair.second->menuModel());
262+ }
263+
264+ if (m_isSettingsMenu)
265+ {
266+ return;
267+ }
268+
269+ if (links.isEmpty())
270+ {
271+ m_settingsMenu->removeAll(m_openEthernetSettings->menuItem());
272+ }
273+ else
274+ {
275+ if (m_settingsMenu->find(m_openEthernetSettings->menuItem()) == m_settingsMenu->end())
276+ {
277+ m_settingsMenu->append(m_openEthernetSettings->menuItem());
278+ }
279 }
280 }
281 };
282
283-EthernetSection::EthernetSection(Manager::Ptr manager)
284+EthernetSection::EthernetSection(Manager::Ptr manager, bool isSettingsMenu)
285 : d{new Private()}
286 {
287 d->m_manager = manager;
288+ d->m_isSettingsMenu = isSettingsMenu;
289
290 d->m_actionGroupMerger = make_shared<ActionGroupMerger>();
291 d->m_menuMerger = make_shared<MenuMerger>();
292-
293- auto settingsItem = make_shared<TextItem>(_("Ethernet settingsā€¦"), "ethernet", "settings");
294- d->m_actionGroupMerger->add(settingsItem->actionGroup());
295-
296- d->m_settingsMenu = make_shared<Menu>();
297- d->m_settingsMenu->append(settingsItem->menuItem());
298+ d->m_links = make_shared<MenuMerger>();
299+
300+ d->m_menuMerger->append(d->m_links);
301+
302+ // Don't include a link to the settings in the settings themselves
303+ if (!isSettingsMenu)
304+ {
305+ d->m_settingsMenu = make_shared<Menu>();
306+ d->m_menuMerger->append(d->m_settingsMenu);
307+
308+ d->m_openEthernetSettings = make_shared<TextItem>(_("Ethernet settingsā€¦"), "ethernet", "settings");
309+ d->m_actionGroupMerger->add(d->m_openEthernetSettings->actionGroup());
310+ }
311
312 QObject::connect(d->m_manager.get(), &Manager::linksUpdated, d.get(), &Private::linksChanged);
313 d->linksChanged();
314
315=== modified file 'src/indicator/sections/ethernet-section.h'
316--- src/indicator/sections/ethernet-section.h 2016-12-05 11:07:31 +0000
317+++ src/indicator/sections/ethernet-section.h 2017-03-20 12:14:57 +0000
318@@ -28,7 +28,7 @@
319 public:
320 UNITY_DEFINES_PTRS(EthernetSection);
321
322- explicit EthernetSection(nmofono::Manager::Ptr manager);
323+ explicit EthernetSection(nmofono::Manager::Ptr manager, bool isSettingsMenu);
324
325 ~EthernetSection();
326
327
328=== modified file 'tests/integration/indicator-network-test-base.cpp'
329--- tests/integration/indicator-network-test-base.cpp 2016-12-23 13:48:02 +0000
330+++ tests/integration/indicator-network-test-base.cpp 2017-03-20 12:14:57 +0000
331@@ -212,6 +212,14 @@
332 "/com/canonical/indicator/network/phone");
333 }
334
335+mh::MenuMatcher::Parameters IndicatorNetworkTestBase::phoneEthernetSettingsParameters()
336+{
337+ return mh::MenuMatcher::Parameters(
338+ "com.canonical.indicator.network",
339+ { { "indicator", "/com/canonical/indicator/network" } },
340+ "/com/canonical/indicator/network/phone_ethernet_settings");
341+}
342+
343 mh::MenuMatcher::Parameters IndicatorNetworkTestBase::phoneWifiSettingsParameters()
344 {
345 return mh::MenuMatcher::Parameters(
346
347=== modified file 'tests/integration/indicator-network-test-base.h'
348--- tests/integration/indicator-network-test-base.h 2016-12-23 13:48:02 +0000
349+++ tests/integration/indicator-network-test-base.h 2017-03-20 12:14:57 +0000
350@@ -164,6 +164,8 @@
351
352 static unity::gmenuharness::MenuMatcher::Parameters phoneParameters();
353
354+ static unity::gmenuharness::MenuMatcher::Parameters phoneEthernetSettingsParameters();
355+
356 static unity::gmenuharness::MenuMatcher::Parameters phoneWifiSettingsParameters();
357
358 static unity::gmenuharness::MenuMatcher::Parameters unlockSimParameters(std::string const& busName, int exportId);
359
360=== modified file 'tests/integration/test-indicator-phone.cpp'
361--- tests/integration/test-indicator-phone.cpp 2016-12-23 13:48:02 +0000
362+++ tests/integration/test-indicator-phone.cpp 2017-03-20 12:14:57 +0000
363@@ -120,6 +120,26 @@
364 ).match());
365 }
366
367+TEST_F(TestIndicatorPhone, OneConnectedEthernetAtStartupInSettingsMenu)
368+{
369+ setGlobalConnectedState(NM_STATE_CONNECTED_GLOBAL);
370+ auto device = createEthernetDevice(NM_DEVICE_STATE_ACTIVATED);
371+ auto connection = createEthernetConnection("Home", device);
372+ createActiveConnection("0", device, connection);
373+
374+ ASSERT_NO_THROW(startIndicator());
375+
376+ EXPECT_MATCHRESULT(mh::MenuMatcher(phoneEthernetSettingsParameters())
377+ .item(mh::MenuItemMatcher()
378+ .section()
379+ .item(ethernetInfo("Ethernet",
380+ "Connected",
381+ Toggle::enabled)
382+ )
383+ .item(radio("Home", Toggle::enabled))
384+ ).match());
385+}
386+
387 TEST_F(TestIndicatorPhone, TwoEthernetAtStartupConnectedAndDisconnected)
388 {
389 setGlobalConnectedState(NM_STATE_CONNECTED_GLOBAL);

Subscribers

People subscribed via source and target branches