aboutsummaryrefslogtreecommitdiff
path: root/src/actions-live.cpp
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2016-04-28 11:56:11 -0300
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:39 +0200
commita6422822a9b9a18bae705e56f2b53ee0b61ff1dc (patch)
tree87b245835da758b195fca2228db01dceae04f003 /src/actions-live.cpp
parent0fb4679e9043ba2591055f46445294cf508be0fb (diff)
downloadayatana-indicator-datetime-a6422822a9b9a18bae705e56f2b53ee0b61ff1dc.tar.gz
ayatana-indicator-datetime-a6422822a9b9a18bae705e56f2b53ee0b61ff1dc.tar.bz2
ayatana-indicator-datetime-a6422822a9b9a18bae705e56f2b53ee0b61ff1dc.zip
Detect desktop to launch applications.
Diffstat (limited to 'src/actions-live.cpp')
-rw-r--r--src/actions-live.cpp126
1 files changed, 45 insertions, 81 deletions
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index e3237b7..11643cd 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -20,14 +20,15 @@
#include <datetime/dbus-shared.h>
#include <datetime/actions-live.h>
-#ifdef HAS_URLDISPATCHER
-#include <lomiri-url-dispatcher.h>
-#endif
-
#include <glib.h>
#include <sstream>
+extern "C"
+{
+ #include <ayatana/common/utils.h>
+}
+
namespace ayatana {
namespace indicator {
namespace datetime {
@@ -41,53 +42,55 @@ LiveActions::LiveActions(const std::shared_ptr<State>& state_in):
{
}
-void LiveActions::execute_command(const std::string& cmdstr)
-{
- const auto cmd = cmdstr.c_str();
- g_debug("Issuing command '%s'", cmd);
+/***
+****
+***/
- GError* error = nullptr;
- if (!g_spawn_command_line_async(cmd, &error))
+void LiveActions::open_alarm_app()
+{
+ if (ayatana_common_utils_is_lomiri())
{
- g_warning("Unable to start \"%s\": %s", cmd, error->message);
- g_error_free(error);
+ ayatana_common_utils_open_url("appid://com.lomiri.clock/clock/current-user-version");
+ }
+ else
+ {
+ ayatana_common_utils_execute_command("evolution -c calendar");
}
}
-void LiveActions::dispatch_url(const std::string& url)
+void LiveActions::open_calendar_app(const DateTime& dt)
{
- g_debug("Dispatching url '%s'", url.c_str());
-#ifdef HAS_URLDISPATCHER
- lomiri_url_dispatch_send(url.c_str(), nullptr, nullptr);
-#else
- // FIXME: Deal with this, if we build without liburl-dispatcher...
-#endif
+ if (ayatana_common_utils_is_lomiri())
+ {
+ const auto utc = dt.to_timezone("UTC");
+ auto cmd = utc.format("calendar://startdate=%Y-%m-%dT%H:%M:%S+00:00");
+ ayatana_common_utils_open_url(cmd.c_str());
+ }
+ else
+ {
+ const auto utc = dt.start_of_day().to_timezone("UTC");
+ auto cmd = utc.format("evolution \"calendar:///?startdate=%Y%m%dT%H%M%SZ\"");
+ ayatana_common_utils_execute_command(cmd.c_str());
+ }
}
-/***
-****
-***/
-
-void LiveActions::desktop_open_settings_app()
+void LiveActions::open_settings_app()
{
- if (g_getenv ("MIR_SOCKET") != nullptr)
+ if (ayatana_common_utils_is_lomiri())
+ {
+ ayatana_common_utils_open_url("settings:///system/time-date");
+ }
+ else if (ayatana_common_utils_is_unity())
{
- dispatch_url("settings:///system/time-date");
+ ayatana_common_utils_execute_command("unity-control-center datetime");
+ }
+ else if (ayatana_common_utils_is_mate())
+ {
+ ayatana_common_utils_execute_command("mate-time-admin");
}
else
{
- if ((g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0))
- {
- execute_command("unity-control-center datetime");
- }
- else if ((g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") == 0))
- {
- execute_command("mate-time-admin");
- }
- else
- {
- execute_command("gnome-control-center datetime");
- }
+ ayatana_common_utils_execute_command("gnome-control-center datetime");
}
}
@@ -123,64 +126,25 @@ bool LiveActions::desktop_has_calendar_app() const
return have_calendar;
}
-void LiveActions::desktop_open_alarm_app()
-{
- execute_command("evolution -c calendar");
-}
-
-void LiveActions::desktop_open_appointment(const Appointment&, const DateTime& date)
-{
- desktop_open_calendar_app(date);
-}
-
-void LiveActions::desktop_open_calendar_app(const DateTime& dt)
-{
- const auto utc = dt.start_of_day().to_timezone("UTC");
- auto cmd = utc.format("evolution \"calendar:///?startdate=%Y%m%dT%H%M%SZ\"");
- execute_command(cmd.c_str());
-}
-
-/***
-****
-***/
-
-void LiveActions::phone_open_alarm_app()
-{
- dispatch_url("appid://com.ubuntu.clock/clock/current-user-version");
-}
-
-void LiveActions::phone_open_appointment(const Appointment& appt, const DateTime& date)
+void LiveActions::open_appointment(const Appointment& appt, const DateTime& date)
{
-
if (!appt.activation_url.empty())
{
- dispatch_url(appt.activation_url);
+ ayatana_common_utils_open_url(appt.activation_url.c_str());
}
else switch (appt.type)
{
case Appointment::UBUNTU_ALARM:
- phone_open_alarm_app();
+ open_alarm_app();
break;
case Appointment::EVENT:
default:
- phone_open_calendar_app(date);
+ open_calendar_app(date);
break;
}
}
-void LiveActions::phone_open_calendar_app(const DateTime& dt)
-{
- const auto utc = dt.to_timezone("UTC");
- auto cmd = utc.format("calendar://startdate=%Y-%m-%dT%H:%M:%S+00:00");
- dispatch_url(cmd);
-}
-
-void LiveActions::phone_open_settings_app()
-{
- dispatch_url("settings:///system/time-date");
-}
-
/***
****
***/