Merge lp:~charlesk/indicator-location/lp-1535353-remove-here-tos into lp:indicator-location/16.04

Proposed by Charles Kerr
Status: Merged
Approved by: Xavi Garcia
Approved revision: 151
Merged at revision: 151
Proposed branch: lp:~charlesk/indicator-location/lp-1535353-remove-here-tos
Merge into: lp:indicator-location/16.04
Diff against target: 655 lines (+8/-466)
12 files modified
src/CMakeLists.txt (+0/-2)
src/accounts-service-license-controller.cc (+0/-168)
src/accounts-service-license-controller.h (+0/-52)
src/license-controller.cc (+0/-50)
src/license-controller.h (+0/-75)
src/main.cc (+1/-3)
src/mock-license-controller.h (+0/-46)
src/phone.cc (+2/-57)
src/phone.h (+1/-6)
src/service.cc (+2/-2)
src/service.h (+1/-2)
tests/phone-test.cc (+1/-3)
To merge this branch: bzr merge lp:~charlesk/indicator-location/lp-1535353-remove-here-tos
Reviewer Review Type Date Requested Status
Xavi Garcia Approve
Matthew Paul Thomas (community) design Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+283509@code.launchpad.net

Commit message

Remove the "View HERE terms and conditions" menuitem

Description of the change

Remove the "View HERE terms and conditions" menuitem

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
Matthew Paul Thomas (mpt) wrote :

That sweet, sweet smell of menu simplification ... and code removal, of course.

review: Approve (design)
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Looks good to me, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2015-07-15 18:54:31 +0000
3+++ src/CMakeLists.txt 2016-01-21 16:59:41 +0000
4@@ -18,8 +18,6 @@
5 phone.cc
6 service.cc
7 location-service-controller.cc
8- accounts-service-license-controller.cc
9- license-controller.cc
10 )
11 include_directories (${CMAKE_SOURCE_DIR})
12 link_directories (${SERVICE_DEPS_LIBRARY_DIRS})
13
14=== removed file 'src/accounts-service-license-controller.cc'
15--- src/accounts-service-license-controller.cc 2014-09-02 17:33:44 +0000
16+++ src/accounts-service-license-controller.cc 1970-01-01 00:00:00 +0000
17@@ -1,168 +0,0 @@
18-/*
19- * Copyright 2014 Canonical Ltd.
20- *
21- * This program is free software; you can redistribute it and/or modify
22- * it under the terms of the GNU General Public License as published by
23- * the Free Software Foundation; version 3.
24- *
25- * This program is distributed in the hope that it will be useful,
26- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28- * GNU Lesser General Public License for more details.
29- *
30- * You should have received a copy of the GNU Lesser General Public License
31- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32- *
33- * Authors:
34- * Pete Woods <pete.woods@canonical.com>
35- */
36-
37-#include "accounts-service-license-controller.h"
38-#include "utils.h"
39-
40-#define ACCOUNTS_NAME "org.freedesktop.Accounts"
41-#define ACCOUNTS_SERVICE "com.ubuntu.location.providers.here.AccountsService"
42-
43-namespace
44-{
45-
46-std::string
47-user_path()
48-{
49- return "/org/freedesktop/Accounts/User" + std::to_string(getuid());
50-}
51-
52-std::string
53-make_path(const std::string& path, const std::string& lang)
54-{
55- return path + "/" + lang + ".html";
56-}
57-
58-std::string
59-build_full_path(const std::string & path)
60-{
61- std::string result;
62- char * lang_char = getenv("LANG");
63- if (lang_char)
64- {
65- std::string lang = lang_char;
66- auto pos = lang.find('.');
67- if (pos != std::string::npos)
68- {
69- lang = lang.substr(0, pos);
70- }
71- result = make_path(path, lang);
72- }
73-
74- if (!g_file_test(result.c_str(), G_FILE_TEST_EXISTS))
75- {
76- result = make_path(path, "en_US");
77- }
78-
79- return std::string("file://") + result;
80-}
81-
82-}
83-
84-AccountsServiceLicenseController::AccountsServiceLicenseController()
85-{
86- GError * error = nullptr;
87- proxy.reset(
88- g_dbus_proxy_new_for_bus_sync(
89- G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
90- nullptr, ACCOUNTS_NAME, user_path().c_str(),
91- ACCOUNTS_SERVICE,
92- nullptr, &error),
93- GObjectDeleter());
94-
95- if (proxy.get() == nullptr)
96- {
97- g_warning("Could not get AccountsService proxy '%s'", error->message);
98- g_error_free(error);
99- return;
100- }
101-
102- g_signal_connect(proxy.get(), "g-properties-changed",
103- G_CALLBACK (on_properties_changed),
104- static_cast<void*>(this));
105-}
106-
107-bool
108-AccountsServiceLicenseController::license_accepted() const
109-{
110- bool result = false;
111-
112- GVariant * accepted_variant = g_dbus_proxy_get_cached_property(
113- proxy.get(), "LicenseAccepted");
114- if (accepted_variant)
115- {
116- result = g_variant_get_boolean(accepted_variant);
117- g_variant_unref(accepted_variant);
118- }
119-
120- return result;
121-}
122-
123-std::string
124-AccountsServiceLicenseController::license_path() const
125-{
126- std::string path;
127-
128- GVariant * base_path_variant = g_dbus_proxy_get_cached_property(
129- proxy.get(), "LicenseBasePath");
130- if (base_path_variant)
131- {
132- const char * temp = g_variant_get_string(base_path_variant, NULL);
133- if (temp)
134- {
135- path = temp;
136- }
137- g_variant_unref(base_path_variant);
138- }
139-
140- return build_full_path(path);
141-}
142-
143-void
144-AccountsServiceLicenseController::on_properties_changed(
145- GDBusProxy *proxy, GVariant *changed_properties,
146- const gchar* const *invalidated_properties, gpointer user_data)
147-{
148- AccountsServiceLicenseController * self =
149- static_cast<AccountsServiceLicenseController *>(user_data);
150-
151- if (g_variant_n_children(changed_properties) > 0)
152- {
153- GVariantIter *iter;
154- const gchar *key;
155- GVariant *value;
156- std::string property_name;
157-
158- g_variant_get(changed_properties, "a{sv}", &iter);
159- while (g_variant_iter_loop(iter, "{&sv}", &key, &value))
160- {
161- if (!key)
162- {
163- continue;
164- }
165-
166- property_name = key;
167-
168- if (property_name == "LicenseAccepted")
169- {
170- self->notify_license_accepted(g_variant_get_boolean(value));
171- }
172- else if (property_name == "LicenseBasePath")
173- {
174- const gchar * temp = g_variant_get_string(value, NULL);
175- std::string path;
176- if (temp)
177- {
178- path = temp;
179- }
180- self->notify_license_path(build_full_path(path));
181- }
182- }
183- g_variant_iter_free(iter);
184- }
185-}
186
187=== removed file 'src/accounts-service-license-controller.h'
188--- src/accounts-service-license-controller.h 2014-09-02 16:34:36 +0000
189+++ src/accounts-service-license-controller.h 1970-01-01 00:00:00 +0000
190@@ -1,52 +0,0 @@
191-/*
192- * Copyright 2014 Canonical Ltd.
193- *
194- * This program is free software; you can redistribute it and/or modify
195- * it under the terms of the GNU General Public License as published by
196- * the Free Software Foundation; version 3.
197- *
198- * This program is distributed in the hope that it will be useful,
199- * but WITHOUT ANY WARRANTY; without even the implied warranty of
200- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201- * GNU Lesser General Public License for more details.
202- *
203- * You should have received a copy of the GNU Lesser General Public License
204- * along with this program. If not, see <http://www.gnu.org/licenses/>.
205- *
206- * Authors:
207- * Pete Woods <pete.woods@canonical.com>
208- */
209-
210-#ifndef __INDICATOR_LOCATION_ACCOUNTS_SERVICE_LICENSE_CONTROLLER__H__
211-#define __INDICATOR_LOCATION_ACCOUNTS_SERVICE_LICENSE_CONTROLLER__H__
212-
213-#include "license-controller.h"
214-
215-#include <gio/gio.h>
216-#include <memory>
217-
218-class AccountsServiceLicenseController : public LicenseController
219-{
220-public:
221- AccountsServiceLicenseController();
222-
223- ~AccountsServiceLicenseController()
224- {
225- }
226-
227- bool
228- license_accepted() const override;
229-
230- std::string
231- license_path() const override;
232-
233-private:
234- std::shared_ptr<GDBusProxy> proxy;
235-
236- static void
237- on_properties_changed(GDBusProxy *proxy, GVariant *changed_properties,
238- const gchar* const *invalidated_properties,
239- gpointer user_data);
240-};
241-
242-#endif // __INDICATOR_LOCATION_ACCOUNTS_SERVICE_LICENSE_CONTROLLER__H__
243
244=== removed file 'src/license-controller.cc'
245--- src/license-controller.cc 2014-09-02 16:34:36 +0000
246+++ src/license-controller.cc 1970-01-01 00:00:00 +0000
247@@ -1,50 +0,0 @@
248-/*
249- * Copyright 2014 Canonical Ltd.
250- *
251- * This program is free software; you can redistribute it and/or modify
252- * it under the terms of the GNU General Public License as published by
253- * the Free Software Foundation; version 3.
254- *
255- * This program is distributed in the hope that it will be useful,
256- * but WITHOUT ANY WARRANTY; without even the implied warranty of
257- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
258- * GNU Lesser General Public License for more details.
259- *
260- * You should have received a copy of the GNU Lesser General Public License
261- * along with this program. If not, see <http://www.gnu.org/licenses/>.
262- *
263- * Authors:
264- * Pete Woods <pete.woods@canonical.com>
265- */
266-
267-#include "license-controller.h"
268-
269-void
270-LicenseController::add_listener(LicenseControllerListener * const l)
271-{
272- listeners.insert(l);
273-}
274-
275-void
276-LicenseController::remove_listener(LicenseControllerListener * const l)
277-{
278- listeners.erase(l);
279-}
280-
281-void
282-LicenseController::notify_license_accepted(bool license_accepted)
283-{
284- for (auto it : listeners)
285- {
286- it->on_license_accepted_changed(license_accepted);
287- }
288-}
289-
290-void
291-LicenseController::notify_license_path(const std::string & license_path)
292-{
293- for (auto it : listeners)
294- {
295- it->on_license_path_changed(license_path);
296- }
297-}
298
299=== removed file 'src/license-controller.h'
300--- src/license-controller.h 2014-09-02 16:34:36 +0000
301+++ src/license-controller.h 1970-01-01 00:00:00 +0000
302@@ -1,75 +0,0 @@
303-/*
304- * Copyright 2014 Canonical Ltd.
305- *
306- * This program is free software; you can redistribute it and/or modify
307- * it under the terms of the GNU General Public License as published by
308- * the Free Software Foundation; version 3.
309- *
310- * This program is distributed in the hope that it will be useful,
311- * but WITHOUT ANY WARRANTY; without even the implied warranty of
312- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
313- * GNU Lesser General Public License for more details.
314- *
315- * You should have received a copy of the GNU Lesser General Public License
316- * along with this program. If not, see <http://www.gnu.org/licenses/>.
317- *
318- * Authors:
319- * Pete Woods <pete.woods@canonical.com>
320- */
321-
322-#ifndef __INDICATOR_LOCATION_LICENSE_CONTROLLER__H__
323-#define __INDICATOR_LOCATION_LICENSE_CONTROLLER__H__
324-
325-#include <memory>
326-#include <string>
327-#include <unordered_set>
328-
329-class LicenseControllerListener
330-{
331-public:
332- LicenseControllerListener() = default;
333-
334- virtual
335- ~LicenseControllerListener() = default;
336-
337-public:
338- virtual void
339- on_license_accepted_changed(bool license_accepted) = 0;
340-
341- virtual void
342- on_license_path_changed(const std::string & license_path) = 0;
343-};
344-
345-class LicenseController
346-{
347-public:
348- LicenseController() = default;
349-
350- virtual
351- ~LicenseController() = default;
352-
353- virtual bool
354- license_accepted() const = 0;
355-
356- virtual std::string
357- license_path() const = 0;
358-
359- void
360- add_listener(LicenseControllerListener * const);
361-
362- void
363- remove_listener(LicenseControllerListener * const);
364-
365-protected:
366-
367- void
368- notify_license_accepted(bool);
369-
370- void
371- notify_license_path(const std::string & license_path);
372-
373-private:
374- std::unordered_set<LicenseControllerListener *> listeners;
375-};
376-
377-#endif // __INDICATOR_LOCATION_LICENSE_CONTROLLER__H__
378
379=== modified file 'src/main.cc'
380--- src/main.cc 2015-04-16 01:54:48 +0000
381+++ src/main.cc 2016-01-21 16:59:41 +0000
382@@ -21,7 +21,6 @@
383 #include <glib/gi18n.h>
384 #include <glib.h>
385
386-#include "accounts-service-license-controller.h"
387 #include "location-service-controller.h"
388 #include "service.h"
389
390@@ -44,8 +43,7 @@
391 /* set up the service */
392 loop = g_main_loop_new (nullptr, false);
393 auto controller = std::make_shared<LocationServiceController>();
394- auto license_controller = std::make_shared<AccountsServiceLicenseController>();
395- Service service (controller, license_controller);
396+ Service service (controller);
397 service.set_name_lost_callback (on_name_lost, loop);
398 g_main_loop_run (loop);
399
400
401=== removed file 'src/mock-license-controller.h'
402--- src/mock-license-controller.h 2014-09-02 16:34:36 +0000
403+++ src/mock-license-controller.h 1970-01-01 00:00:00 +0000
404@@ -1,46 +0,0 @@
405-/*
406- * Copyright 2014 Canonical Ltd.
407- *
408- * This program is free software; you can redistribute it and/or modify
409- * it under the terms of the GNU General Public License as published by
410- * the Free Software Foundation; version 3.
411- *
412- * This program is distributed in the hope that it will be useful,
413- * but WITHOUT ANY WARRANTY; without even the implied warranty of
414- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
415- * GNU Lesser General Public License for more details.
416- *
417- * You should have received a copy of the GNU Lesser General Public License
418- * along with this program. If not, see <http://www.gnu.org/licenses/>.
419- *
420- * Authors:
421- * Pete Woods <pete.woods@canonical.com>
422- */
423-
424-#ifndef __INDICATOR_LOCATION_MOCK_LICENSE_CONTROLLER__H__
425-#define __INDICATOR_LOCATION_MOCK_LICENSE_CONTROLLER__H__
426-
427-#include "license-controller.h"
428-
429-class MockLicenseController : public LicenseController
430-{
431-public:
432- MockLicenseController() = default;
433-
434- ~MockLicenseController()
435- {
436- }
437-
438- bool
439- license_accepted() const override
440- {
441- return true;
442- }
443-
444- std::string
445- license_path() const override{
446- return "file:///foo/bar/en_US.html";
447- }
448-};
449-
450-#endif // __INDICATOR_LOCATION_MOCK_LICENSE_CONTROLLER__H__
451
452=== modified file 'src/phone.cc'
453--- src/phone.cc 2015-11-27 11:07:17 +0000
454+++ src/phone.cc 2016-01-21 16:59:41 +0000
455@@ -33,22 +33,18 @@
456 #define GPS_ACTION_KEY "gps-detection-enabled"
457
458 Phone :: Phone (const std::shared_ptr<Controller>& controller_,
459- const std::shared_ptr<LicenseController>& license_controller_,
460 const std::shared_ptr<GSimpleActionGroup>& action_group_):
461 controller (controller_),
462- license_controller (license_controller_),
463 action_group (action_group_)
464 {
465 create_menu ();
466 controller->add_listener (this);
467- license_controller->add_listener (this);
468
469 /* create the actions & add them to the group */
470- std::array<GSimpleAction*, 5> actions = { create_root_action(),
471+ std::array<GSimpleAction*, 4> actions = { create_root_action(),
472 create_detection_enabled_action(),
473 create_gps_enabled_action(),
474- create_settings_action(),
475- create_licence_action() };
476+ create_settings_action() };
477 for (auto a : actions)
478 {
479 g_action_map_add_action (G_ACTION_MAP(action_group.get()), G_ACTION(a));
480@@ -63,7 +59,6 @@
481 Phone :: ~Phone ()
482 {
483 controller->remove_listener (this);
484- license_controller->remove_listener (this);
485 }
486
487 /***
488@@ -158,17 +153,6 @@
489 }
490
491 void
492-Phone::on_license_accepted_changed(bool license_accepted)
493-{
494- rebuild_submenu();
495-}
496-
497-void
498-Phone::on_license_path_changed(const std::string & license_path)
499-{
500-}
501-
502-void
503 Phone :: on_detection_location_activated (GSimpleAction * action,
504 GVariant * parameter G_GNUC_UNUSED,
505 gpointer gself)
506@@ -240,39 +224,6 @@
507 ****
508 ***/
509
510-#define LICENCE_ACTION_KEY "licence"
511-
512-namespace
513-{
514- void
515- on_licence_activated (GSimpleAction * simple G_GNUC_UNUSED,
516- GVariant * parameter,
517- gpointer user_data G_GNUC_UNUSED)
518- {
519- LicenseController * license_controller = static_cast<LicenseController *>(user_data);
520- std::string path = license_controller->license_path();
521- const gchar * urls[2] = {path.c_str(), nullptr};
522- ubuntu_app_launch_start_application("webbrowser-app", urls);
523- }
524-}
525-
526-GSimpleAction *
527-Phone :: create_licence_action ()
528-{
529- GSimpleAction * action;
530-
531- action = g_simple_action_new (LICENCE_ACTION_KEY, nullptr);
532-
533- g_signal_connect(action, "activate", G_CALLBACK(on_licence_activated),
534- static_cast<void *>(license_controller.get()));
535-
536- return action;
537-}
538-
539-/***
540-****
541-***/
542-
543 #define SETTINGS_ACTION_KEY "settings"
544
545 namespace
546@@ -349,11 +300,5 @@
547 g_menu_append_item(submenu.get(), location);
548 g_object_unref(location);
549
550- if (license_controller->license_accepted())
551- {
552- g_menu_append(submenu.get(), _("View HERE terms and conditions"),
553- "indicator." LICENCE_ACTION_KEY);
554- }
555-
556 g_menu_append (submenu.get(), _("Location settingsā€¦"), "indicator." SETTINGS_ACTION_KEY "::security-privacy");
557 }
558
559=== modified file 'src/phone.h'
560--- src/phone.h 2015-04-15 14:23:25 +0000
561+++ src/phone.h 2016-01-21 16:59:41 +0000
562@@ -25,26 +25,21 @@
563 #include <glib.h>
564 #include <gio/gio.h>
565
566-#include "license-controller.h"
567 #include "controller.h"
568
569-class Phone: public ControllerListener, public LicenseControllerListener
570+class Phone: public ControllerListener
571 {
572 public:
573 Phone (const std::shared_ptr<Controller>& controller,
574- const std::shared_ptr<LicenseController>& license_controller,
575 const std::shared_ptr<GSimpleActionGroup>& action_group);
576 virtual ~Phone ();
577 std::shared_ptr<GMenu> get_menu () { return menu; }
578
579 protected:
580 std::shared_ptr<Controller> controller;
581- std::shared_ptr<LicenseController> license_controller;
582 virtual void on_is_valid_changed();
583 virtual void on_gps_enabled_changed (bool is_enabled);
584 virtual void on_location_service_enabled_changed (bool is_enabled);
585- void on_license_accepted_changed(bool license_accepted) override;
586- void on_license_path_changed(const std::string & license_path) override;
587
588 private:
589 std::shared_ptr<GMenu> menu;
590
591=== modified file 'src/service.cc'
592--- src/service.cc 2014-10-03 16:48:12 +0000
593+++ src/service.cc 2016-01-21 16:59:41 +0000
594@@ -27,9 +27,9 @@
595 ***
596 **/
597
598-Service :: Service (const std::shared_ptr<Controller>& controller, const std::shared_ptr<LicenseController>& license_controller):
599+Service :: Service (const std::shared_ptr<Controller>& controller):
600 action_group (g_simple_action_group_new(), GObjectDeleter()),
601- phone_profile (controller, license_controller, action_group),
602+ phone_profile (controller, action_group),
603 name_lost_callback (nullptr),
604 name_lost_user_data (0),
605 action_group_export_id (0),
606
607=== modified file 'src/service.h'
608--- src/service.h 2014-09-02 16:34:36 +0000
609+++ src/service.h 2016-01-21 16:59:41 +0000
610@@ -23,7 +23,6 @@
611 #include <memory>
612 #include <set>
613
614-#include "license-controller.h"
615 #include "controller.h"
616 #include "phone.h"
617 #include "utils.h" // GObjectDeleter
618@@ -31,7 +30,7 @@
619 class Service
620 {
621 public:
622- Service (const std::shared_ptr<Controller>& controller, const std::shared_ptr<LicenseController>& license_controller);
623+ Service (const std::shared_ptr<Controller>& controller);
624 virtual ~Service ();
625
626 private:
627
628=== modified file 'tests/phone-test.cc'
629--- tests/phone-test.cc 2015-11-20 15:44:19 +0000
630+++ tests/phone-test.cc 2016-01-21 16:59:41 +0000
631@@ -22,7 +22,6 @@
632 #include "gtest-dbus-indicator-fixture.h"
633
634 #include "src/dbus-shared.h"
635-#include "src/mock-license-controller.h"
636 #include "src/controller-mock.h"
637 #include "src/service.h"
638
639@@ -74,7 +73,7 @@
640 {
641 myController.reset (new MockController ());
642 myController->add_listener (this);
643- myService.reset (new Service (myController, std::make_shared<MockLicenseController>()));
644+ myService.reset (new Service (myController));
645 }
646
647 virtual void teardown_service ()
648@@ -91,7 +90,6 @@
649 ASSERT_TRUE (action_exists ("location-detection-enabled"));
650 ASSERT_TRUE (action_exists ("phone-header"));
651 ASSERT_TRUE (action_exists ("settings"));
652- ASSERT_TRUE (action_exists ("licence"));
653 }
654
655 TEST_F (PhoneTest, MenuitemsExist)

Subscribers

People subscribed via source and target branches