aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-26 19:55:23 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-26 19:55:23 +0000
commitb39526c27c44302c34fce26163919a0c4c7aecd3 (patch)
treebe0d3759a081f90b73aa90e0cf1b5a2a6a9783f3
parent8dbc66cab4eadfdde3809340d03c4cc10b2032eb (diff)
downloadayatana-indicator-datetime-b39526c27c44302c34fce26163919a0c4c7aecd3.tar.gz
ayatana-indicator-datetime-b39526c27c44302c34fce26163919a0c4c7aecd3.tar.bz2
ayatana-indicator-datetime-b39526c27c44302c34fce26163919a0c4c7aecd3.zip
URL dispatcher support: Build phone code, even if URL dispatcher is unavailable.
-rw-r--r--include/datetime/actions-live.h2
-rw-r--r--include/datetime/actions.h2
-rw-r--r--include/datetime/menu.h2
-rw-r--r--src/actions-live.cpp18
-rw-r--r--src/actions.cpp5
-rw-r--r--src/menu.cpp18
-rw-r--r--tests/manual-test-snap.cpp4
-rw-r--r--tests/test-actions.cpp4
-rw-r--r--tests/test-exporter.cpp8
-rw-r--r--tests/test-formatter.cpp2
-rw-r--r--tests/test-live-actions.cpp2
-rw-r--r--tests/test-menus.cpp8
12 files changed, 23 insertions, 52 deletions
diff --git a/include/datetime/actions-live.h b/include/datetime/actions-live.h
index 1dcb122..ea27f36 100644
--- a/include/datetime/actions-live.h
+++ b/include/datetime/actions-live.h
@@ -45,12 +45,10 @@ public:
void desktop_open_calendar_app(const DateTime&) override;
void desktop_open_settings_app() override;
-#ifdef HAS_URLDISPATCHER
void phone_open_alarm_app() override;
void phone_open_appointment(const Appointment&) override;
void phone_open_calendar_app(const DateTime&) override;
void phone_open_settings_app() override;
-#endif
void set_location(const std::string& zone, const std::string& name) override;
diff --git a/include/datetime/actions.h b/include/datetime/actions.h
index 1a47adb..4780990 100644
--- a/include/datetime/actions.h
+++ b/include/datetime/actions.h
@@ -49,12 +49,10 @@ public:
virtual void desktop_open_calendar_app(const DateTime&) =0;
virtual void desktop_open_settings_app() =0;
-#ifdef HAS_URLDISPATCHER
virtual void phone_open_alarm_app() =0;
virtual void phone_open_appointment(const Appointment&) =0;
virtual void phone_open_calendar_app(const DateTime&) =0;
virtual void phone_open_settings_app() =0;
-#endif
virtual void set_location(const std::string& zone, const std::string& name)=0;
diff --git a/include/datetime/menu.h b/include/datetime/menu.h
index acb0c89..acd9ed8 100644
--- a/include/datetime/menu.h
+++ b/include/datetime/menu.h
@@ -42,9 +42,7 @@ class Menu
{
public:
enum Profile { Desktop, DesktopGreeter,
-#ifdef HAS_URLDISPATCHER
Phone, PhoneGreeter,
-#endif
NUM_PROFILES };
enum Section { Calendar, Appointments, Locations, Settings, NUM_SECTIONS };
const std::string& name() const;
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index 994fc3c..9225d30 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -135,10 +135,13 @@ void LiveActions::desktop_open_calendar_app(const DateTime& dt)
****
***/
-#ifdef HAS_URLDISPATCHER
void LiveActions::phone_open_alarm_app()
{
+#ifdef HAS_URLDISPATCHER
dispatch_url("appid://com.ubuntu.clock/clock/current-user-version");
+#else
+ // FIXME: Deal with this, if we build without liburl-dispatcher...
+#endif
}
void LiveActions::phone_open_appointment(const Appointment& appt)
@@ -146,7 +149,11 @@ void LiveActions::phone_open_appointment(const Appointment& appt)
if (!appt.activation_url.empty())
{
+#ifdef HAS_URLDISPATCHER
dispatch_url(appt.activation_url);
+#else
+ // FIXME: Deal with this, if we build without liburl-dispatcher...
+#endif
}
else switch (appt.type)
{
@@ -161,15 +168,22 @@ void LiveActions::phone_open_appointment(const Appointment& appt)
void LiveActions::phone_open_calendar_app(const DateTime&)
{
+#ifdef HAS_URLDISPATCHER
// does calendar app have a mechanism for specifying dates?
dispatch_url("appid://com.ubuntu.calendar/calendar/current-user-version");
+#else
+ // FIXME: Deal with this, if we build without liburl-dispatcher...
+#endif
}
void LiveActions::phone_open_settings_app()
{
+#ifdef HAS_URLDISPATCHER
dispatch_url("settings:///system/time-date");
-}
+#else
+ // FIXME: Deal with this, if we build without liburl-dispatcher...
#endif
+}
/***
****
diff --git a/src/actions.cpp b/src/actions.cpp
index d288a0e..663812c 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -88,7 +88,6 @@ void on_desktop_settings_activated (GSimpleAction*, GVariant*, gpointer gself)
static_cast<Actions*>(gself)->desktop_open_settings_app();
}
-#ifdef HAS_URLDISPATCHER
void on_phone_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself)
{
auto self = static_cast<Actions*>(gself);
@@ -109,7 +108,6 @@ void on_phone_settings_activated (GSimpleAction*, GVariant*, gpointer gself)
{
static_cast<Actions*>(gself)->phone_open_settings_app();
}
-#endif
void on_set_location(GSimpleAction * /*action*/,
GVariant * param,
@@ -205,12 +203,11 @@ Actions::Actions(const std::shared_ptr<State>& state):
{ "desktop.open-calendar-app", on_desktop_calendar_activated, "x", nullptr },
{ "desktop.open-settings-app", on_desktop_settings_activated },
-#ifdef HAS_URLDISPATCHER
{ "phone.open-appointment", on_phone_appointment_activated, "s", nullptr },
{ "phone.open-alarm-app", on_phone_alarm_activated },
{ "phone.open-calendar-app", on_phone_calendar_activated, "x", nullptr },
{ "phone.open-settings-app", on_phone_settings_activated },
-#endif
+
{ "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed },
{ "set-location", on_set_location, "s" }
};
diff --git a/src/menu.cpp b/src/menu.cpp
index c778963..1bf8111 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -240,12 +240,9 @@ private:
const char * action_name;
-#ifdef HAS_URLDISPATCHER
if (profile == Phone)
action_name = "indicator.phone.open-calendar-app";
- else
-#endif
- if (profile == Desktop)
+ else if (profile == Desktop)
action_name = "indicator.desktop.open-calendar-app";
else
action_name = nullptr;
@@ -291,12 +288,9 @@ private:
const char * action_name;
-#ifdef HAS_URLDISPATCHER
if (profile == Phone)
action_name = "indicator.phone.open-appointment";
- else
-#endif
- if ((profile == Desktop) && m_actions->desktop_has_calendar_app())
+ else if ((profile == Desktop) && m_actions->desktop_has_calendar_app())
action_name = "indicator.desktop.open-appointment";
else
action_name = nullptr;
@@ -363,7 +357,6 @@ private:
g_object_unref(menu_item);
}
}
-#ifdef HAS_URLDISPATCHER
else if (profile==Phone)
{
auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app");
@@ -373,7 +366,6 @@ private:
add_appointments (menu, profile);
}
-#endif
return G_MENU_MODEL(menu);
}
@@ -413,10 +405,8 @@ private:
if (profile == Desktop)
action_name = "indicator.desktop.open-settings-app";
-#ifdef HAS_URLDISPATCHER
else if (profile == Phone)
action_name = "indicator.phone.open-settings-app";
-#endif
else
action_name = nullptr;
@@ -504,7 +494,6 @@ public:
};
-#ifdef HAS_URLDISPATCHER
class PhoneBaseMenu: public MenuImpl
{
protected:
@@ -563,7 +552,6 @@ public:
std::shared_ptr<Actions>& actions_):
PhoneBaseMenu(PhoneGreeter, "phone_greeter", state_, actions_) {}
};
-#endif
/****
*****
@@ -591,7 +579,6 @@ MenuFactory::buildMenu(Menu::Profile profile)
menu.reset(new DesktopGreeterMenu(m_state, m_actions));
break;
-#ifdef HAS_URLDISPATCHER
case Menu::Phone:
menu.reset(new PhoneMenu(m_state, m_actions));
break;
@@ -599,7 +586,6 @@ MenuFactory::buildMenu(Menu::Profile profile)
case Menu::PhoneGreeter:
menu.reset(new PhoneGreeterMenu(m_state, m_actions));
break;
-#endif
default:
g_warn_if_reached();
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index 04ba2c3..a0f80f2 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -18,8 +18,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef HAS_URLDISPATCHER
-
#include <datetime/appointment.h>
#include <datetime/settings-live.h>
#include <datetime/snap.h>
@@ -101,5 +99,3 @@ int main(int argc, const char* argv[])
g_main_loop_unref(loop);
return 0;
}
-
-#endif
diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp
index 1352ddb..f8d1102 100644
--- a/tests/test-actions.cpp
+++ b/tests/test-actions.cpp
@@ -157,12 +157,10 @@ TEST_F(ActionsFixture, ActionsExist)
"desktop.open-alarm-app",
"desktop.open-calendar-app",
"desktop.open-settings-app",
-#ifdef HAS_URLDISPATCHER
"phone.open-appointment",
"phone.open-alarm-app",
"phone.open-calendar-app",
"phone.open-settings-app"
-#endif
};
for(const auto& name: names)
@@ -203,7 +201,6 @@ TEST_F(ActionsFixture, DesktopOpenSettingsApp)
****
***/
-#ifdef HAS_URLDISPATCHER
TEST_F(ActionsFixture, PhoneOpenAlarmApp)
{
test_action_with_no_args("phone.open-alarm-app",
@@ -227,7 +224,6 @@ TEST_F(ActionsFixture, PhoneOpenSettingsApp)
test_action_with_no_args("phone.open-settings-app",
MockActions::PhoneOpenSettingsApp);
}
-#endif
/***
****
diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp
index 04c8445..647d6ff 100644
--- a/tests/test-exporter.cpp
+++ b/tests/test-exporter.cpp
@@ -111,19 +111,19 @@ TEST_F(ExporterFixture, Publish)
EXPECT_EQ(1, names.count("desktop.open-appointment"));
EXPECT_EQ(1, names.count("desktop.open-calendar-app"));
EXPECT_EQ(1, names.count("desktop.open-settings-app"));
-#ifdef HAS_URLDISPATCHER
+
EXPECT_EQ(1, names.count("phone.open-alarm-app"));
EXPECT_EQ(1, names.count("phone.open-appointment"));
EXPECT_EQ(1, names.count("phone.open-calendar-app"));
EXPECT_EQ(1, names.count("phone.open-settings-app"));
-#endif
+
EXPECT_EQ(1, names.count("calendar"));
EXPECT_EQ(1, names.count("desktop_greeter-header"));
EXPECT_EQ(1, names.count("desktop-header"));
-#ifdef HAS_URLDISPATCHER
+
EXPECT_EQ(1, names.count("phone_greeter-header"));
EXPECT_EQ(1, names.count("phone-header"));
-#endif
+
EXPECT_EQ(1, names.count("set-location"));
// try closing the connection prematurely
diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp
index 4436ed1..855d4c5 100644
--- a/tests/test-formatter.cpp
+++ b/tests/test-formatter.cpp
@@ -84,7 +84,6 @@ class FormatterFixture: public GlibFixture
};
-#ifdef HAS_URLDISPATCHER
/**
* Test the phone header format
*/
@@ -109,7 +108,6 @@ TEST_F(FormatterFixture, TestPhoneHeader)
EXPECT_EQ(std::string(" 6:30 PM"), formatter.header.get());
}
}
-#endif
#define EM_SPACE "\u2003"
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index aade9c7..9f17001 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -94,7 +94,6 @@ namespace
const std::string calendar_app_url = "appid://com.ubuntu.calendar/calendar/current-user-version";
}
-#ifdef HAS_URLDISPATCHER
TEST_F(TimedateFixture, PhoneOpenAlarmApp)
{
m_actions->phone_open_alarm_app();
@@ -129,7 +128,6 @@ TEST_F(TimedateFixture, PhoneOpenSettingsApp)
const std::string expected = "settings:///system/time-date";
EXPECT_EQ(expected, m_live_actions->last_url);
}
-#endif
/***
****
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index e6d222a..c1dbb2d 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -97,10 +97,8 @@ protected:
if (profile == Menu::Desktop)
expected_action = "indicator.desktop.open-calendar-app";
-#ifdef HAS_URLDISPATCHER
else if (profile == Menu::Phone)
expected_action = "indicator.phone.open-calendar-app";
-#endif
else
expected_action = nullptr;
@@ -324,7 +322,6 @@ private:
g_clear_object(&submenu);
}
-#ifdef HAS_URLDISPATCHER
void InspectPhoneAppointments(GMenuModel* menu_model, bool can_open_planner)
{
auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
@@ -357,7 +354,6 @@ private:
// cleanup
g_clear_object(&submenu);
}
-#endif
protected:
@@ -375,7 +371,6 @@ protected:
InspectEmptySection(menu_model, Menu::Appointments);
break;
-#ifdef HAS_URLDISPATCHER
case Menu::Phone:
InspectPhoneAppointments(menu_model, can_open_planner);
break;
@@ -383,7 +378,6 @@ protected:
case Menu::PhoneGreeter:
InspectEmptySection(menu_model, Menu::Appointments);
break;
-#endif
default:
g_warn_if_reached();
@@ -455,10 +449,8 @@ protected:
if (profile == Menu::Desktop)
expected_action = "indicator.desktop.open-settings-app";
-#ifdef HAS_URLDISPATCHER
else if (profile == Menu::Phone)
expected_action = "indicator.phone.open-settings-app";
-#endif
// get the Settings section
auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);