./ 0000755 0000041 0000041 00000000000 13151304763 011246 5 ustar www-data www-data ./CMakeLists.txt 0000644 0000041 0000041 00000005657 13151304762 014022 0 ustar www-data www-data project (indicator-datetime C CXX)
cmake_minimum_required (VERSION 2.8.9)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set (PROJECT_VERSION "14.04.0")
set (PACKAGE ${CMAKE_PROJECT_NAME})
set (GETTEXT_PACKAGE "indicator-datetime")
add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}"
-DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
set(ALARM_DEFAULT_SOUND "/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg")
set(CALENDAR_DEFAULT_SOUND "/usr/share/sounds/ubuntu/ringtones/Marimbach.ogg")
add_definitions(-DALARM_DEFAULT_SOUND="${ALARM_DEFAULT_SOUND}"
-DCALENDAR_DEFAULT_SOUND="${CALENDAR_DEFAULT_SOUND}")
##
## Always Be Testing
##
enable_testing()
##
## GNU standard installation directories
##
include (GNUInstallDirs)
if (EXISTS "/etc/debian_version") # Workaround for libexecdir on debian
set (CMAKE_INSTALL_LIBEXECDIR "${CMAKE_INSTALL_LIBDIR}")
set (CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif ()
set (CMAKE_INSTALL_PKGLIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}")
set (CMAKE_INSTALL_FULL_PKGLIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}")
##
## Check for prerequisites
##
find_package (PkgConfig REQUIRED)
include (CheckIncludeFile)
include (FindPkgConfig)
pkg_check_modules (SERVICE_DEPS REQUIRED
glib-2.0>=2.36
gio-unix-2.0>=2.36
libical>=0.48
libecal-1.2>=3.5
libedataserver-1.2>=3.5
gstreamer-1.0>=1.2
libnotify>=0.7.6
url-dispatcher-1>=1
properties-cpp>=0.0.1
libaccounts-glib>=1.18
messaging-menu>=12.10
uuid>=2.25)
include_directories (SYSTEM ${SERVICE_DEPS_INCLUDE_DIRS})
##
## custom targets
##
set (ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
add_custom_target (dist
COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/tests)
##
## Actual building
##
set (CC_WARNING_ARGS " -Wall -Wshadow -Wextra -Wunused -Wformat=2 -Wno-missing-field-initializers")
set (CXX_WARNING_ARGS " -Wall -Wextra -pedantic -Wno-missing-field-initializers")
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
# actually build things
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(data)
add_subdirectory(po)
add_subdirectory(tests)
# testing & coverage
find_package(CoverageReport)
ENABLE_COVERAGE_REPORT(
TARGETS indicatordatetimeservice indicator-datetime-service
TESTS ${COVERAGE_TEST_TARGETS}
FILTER /usr/include ${CMAKE_BINARY_DIR}/*
)
./NEWS 0000644 0000041 0000041 00000001410 13151304754 011741 0 ustar www-data www-data 12.10.2
- Fix 12.10.0 appointment calendar regression. (LP: #1060263)
12.10.1
- Gracefully handle clock skew (LP: #917236)
- Raise the version number of our EDS dependency (LP: #1024437)
- Fix X-Ubuntu-Gettext-Domain entries in the .desktop file (LP: #1048834)
- Remove unnecessary watching for geoclue address provider changes
12.10.0
- Support EDS 3.6's API (cyphermox)
- Apply an 'en space' between the date and time strings. (LP #749847)
lp:~bobowen/indicator-datetime/fix-for-749847
- Sort locations as spec'ed by https://wiki.ubuntu.com/TimeAndDate (LP #833325)
lp:~charlesk/indicator-datetime/lp-833325
- Fix a bug that caused location settings to be re-saved each 2 seconds
lp:~charlesk/indicator-datetime/unnecessary-saves
- Drop GTK+ 2 support
./INSTALL 0000644 0000041 0000041 00000003511 13151304754 012277 0 ustar www-data www-data #
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
BUILD DEPENDENCIES
==================
build dependencies for indicator-datetime-service
* glib-2.0 >= 2.36
* gio-unix-2.0 >= 2.36
* geoclue >= 0.12
* libical >= 0.48
* libecal-1.2 >= 3.5
* libedataserver-1.2 >= 3.5
* libnotify >= 0.7.6
* url-dispatcher-1 >= 1
* json-glib-1.0 >= 0.16.2
Additional build dependencies for the gnome-control-center panel:
* gtk+-3.0>=3.1.4
* timezonemap
* libgnome-control-center
* polkit-gobject-1
Build dependencies for testing / code coverage:
* gcovr (gcovr, 2.4 or later)
* lcov (lcov, 1.9 or later)
* google test (libgtest-dev, 1.6.0 or later)
* cppcheck (cppcheck)
Building the code
-----------------
1. $ cd indicator-datetime-X.Y.Z
2. $ mkdir build
3. $ cd build
4. $ cmake ..
or
$ cmake -DCMAKE_INSTALL_PREFIX=/your/install/prefix/here ..
or
$ cmake -GNinja ..
5. $ make
Running the tests
-----------------
1. $ cd indicator-datetime-X.Y.Z
2. $ mkdir build
3. $ cd build
4. $ cmake ..
5. $ make
6. $ make test
7. $ make cppcheck
Generating Test Coverage Reports
--------------------------------
1. $ cd indicator-datetime-X.Y.Z
2. $ mkdir build-coverage
3. $ cd build-coverage
4. $ cmake -DCMAKE_BUILD_TYPE=coverage ..
5. $ make
6. $ make coverage-html
./README 0000644 0000041 0000041 00000011477 13151304754 012140 0 ustar www-data www-data ACTIONS
=======
* "desktop.open-settings-app"
* "phone.open-settings-app"
Description: open the settings application.
State: None
Parameter: None
* "desktop.open-alarm-app"
* "phone.open-alarm-app"
Description: open the application for creating new alarms.
State: None
Parameter: None
* "desktop.open-calendar-app"
* "phone.open-calendar-app"
State: None
Parameter: int64, a time_t hinting which day/time to show in the planner,
or 0 for the current day
* "desktop.open-appointment"
* "phone.open-appointment"
Description: opens an appointment editor to the specified appointment.
State: None
Parameter: string, an opaque uid to specify which appointment to use.
This uid comes from the menuitems' target values.
* "set-location"
Description: Set the current location. This will try to set the current
timezone to the new location's timezone.
State: None
Parameter: a timezone id string followed by a space and location name.
Example: "America/Chicago Oklahoma City"
* "calendar"
Description: set which month/day should be given focus in the indicator's
calendar. The planner will look for appointments from this
day to the end of the same month.
Client code implementing the calendar view should call this
when the user clicks on a new day, month, or year.
State: a dictionary containing these key value/pairs:
"appointment-days": an array of day-of-month ints. Used by the
calendar menuitem to mark appointment days.
"calendar-day": int64, a time_t. Used by the calendar menuitem
to know which year/month should be visible
and which day should have the cursor.
"show-week-numbers": if true, show week numbers in the calendar.
Parameter: int64, a time_t specifying which year/month should be visible
and which day should have the cursor.
CUSTOM MENUITEMS
================
* Calendar
- x-canonical-type s "com.canonical.indicator.calendar"
* Alarm
- label s short summary of the appointment
- x-canonical-type s "com.canonical.indicator.alarm"
- x-canonical-time x the date of the appointment
- x-canonical-time-format s strftime format string
* Appointment
- label s short summary of the appointment
- x-canonical-type s "com.canonical.indicator.appointment"
- x-canonical-color s color of the appt's type, to give a visual cue
- x-canonical-time x the date of the appointment
- x-canonical-time-format s strftime format string
* Location
- label s the location's name, eg "Oklahoma City"
- x-canonical-type s "com.canonical.indicator.location"
- x-canonical-timezone s timezone that the location is in
- x-canonical-time-format s strftime format string
CODE
====
Model
The app's model is represented by the "State" class, and "Menu" objects
are the corresponding views. "State" is a simple container for various
properties, and menus connect to those properties' changed() signals to
know when the view needs to be refreshed.
As one can see in main.c, the app's very simple flow is to instantiate
a state and its properties, build menus that correspond to the state,
and export the menus on DBus.
Because State is a simple aggregate of its components (such as a "Clock"
or "Planner" object to get the current time and upcoming appointments,
respectively), one can plug in live components for production and mock
components for unit tests. The entire backend can be mix-and-matched by
adding the desired test-or-production components.
Start with:
include/datetime/state.h
include/datetime/clock.h
include/datetime/locations.h
include/datetime/planner.h
include/datetime/settings.h
include/datetime/timezones.h
Implementations:
include/datetime/settings-live.h
include/datetime/locations-settings.h
include/datetime/planner-eds.h
include/datetime/timezones-live.h
View
Menu is a mostly-opaque class to wrap GMenu code. Its subclasses contain
the per-profile logic of which sections/menuitems to show and which to hide.
Menus are instantiated via the MenuFactory, which takes a state and profile.
Actions is a mostly-opaque class to wrap our GActionGroup. Its subclasses
contain the code that actually executed when an action is triggered (ie,
LiveActions for production and MockActions for testing).
Exporter exports the Actions and Menus onto the DBus, and also emits a
signal if/when the busname is lost so indicator-datetime-service knows
when to exit.
include/datetime/menu.h
include/datetime/actions.h
include/datetime/exporter.h
./include/ 0000755 0000041 0000041 00000000000 13151304754 012671 5 ustar www-data www-data ./include/datetime/ 0000755 0000041 0000041 00000000000 13151304754 014465 5 ustar www-data www-data ./include/datetime/planner-aggregate.h 0000644 0000041 0000041 00000002543 13151304754 020225 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_PLANNER_AGGREGATE_H
#define INDICATOR_DATETIME_PLANNER_AGGREGATE_H
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief Aggregates one or more Planners
*/
class AggregatePlanner: public Planner
{
public:
AggregatePlanner();
virtual ~AggregatePlanner();
void add(const std::shared_ptr&);
core::Property>& appointments() override;
protected:
class Impl;
std::unique_ptr impl;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_PLANNER_AGGREGATE_H
./include/datetime/date-time.h 0000644 0000041 0000041 00000005756 13151304754 016524 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_DATETIME_H
#define INDICATOR_DATETIME_DATETIME_H
#include // GDateTime
#include
#include // time_t
#include // std::shared_ptr
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief A simple C++ wrapper for GDateTime to simplify ownership/refcounts
*/
class DateTime
{
public:
static DateTime NowLocal();
static DateTime Local(time_t);
static DateTime Local(int year, int month, int day, int hour, int minute, double seconds);
DateTime();
DateTime(GTimeZone* tz, time_t t);
DateTime(GTimeZone* tz, GDateTime* dt);
DateTime(GTimeZone* tz, int year, int month, int day, int hour, int minute, double seconds);
DateTime& operator=(const DateTime& in);
DateTime& operator+=(const std::chrono::minutes&);
DateTime& operator+=(const std::chrono::seconds&);
DateTime to_timezone(const std::string& zone) const;
DateTime start_of_month() const;
DateTime start_of_day() const;
DateTime start_of_minute() const;
DateTime end_of_day() const;
DateTime end_of_month() const;
DateTime add_days(int days) const;
DateTime add_full(int year, int month, int day, int hour, int minute, double seconds) const;
GDateTime* get() const;
GDateTime* operator()() const {return get();}
std::string format(const std::string& fmt) const;
void ymd(int& year, int& month, int& day) const;
int day_of_month() const;
int hour() const;
int minute() const;
double seconds() const;
int64_t to_unix() const;
bool operator<(const DateTime& that) const;
bool operator>(const DateTime& that) const;
bool operator<=(const DateTime& that) const;
bool operator>=(const DateTime& that) const;
bool operator!=(const DateTime& that) const;
bool operator==(const DateTime& that) const;
int64_t operator- (const DateTime& that) const;
static bool is_same_day(const DateTime& a, const DateTime& b);
static bool is_same_minute(const DateTime& a, const DateTime& b);
bool is_set() const { return m_tz && m_dt; }
private:
void reset(GTimeZone*, GDateTime*);
std::shared_ptr m_tz;
std::shared_ptr m_dt;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_DATETIME_H
./include/datetime/CMakeLists.txt 0000644 0000041 0000041 00000000002 13151304754 017215 0 ustar www-data www-data
./include/datetime/actions.h 0000644 0000041 0000041 00000004323 13151304754 016300 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_ACTIONS_H
#define INDICATOR_DATETIME_ACTIONS_H
#include
#include
#include // shared_ptr
#include
#include // GSimpleActionGroup
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief Interface for all the actions that can be activated by users.
*
* This is a simple C++ wrapper around our GActionGroup that gets exported
* onto the bus. Subclasses implement the actual code that should be run
* when a particular action is triggered.
*/
class Actions
{
public:
virtual bool desktop_has_calendar_app() const =0;
virtual void open_alarm_app() =0;
virtual void open_appointment(const Appointment&, const DateTime&) =0;
virtual void open_calendar_app(const DateTime&) =0;
virtual void open_settings_app() =0;
virtual void set_location(const std::string& zone, const std::string& name)=0;
void set_calendar_date(const DateTime&);
GActionGroup* action_group();
const std::shared_ptr state() const;
protected:
explicit Actions(const std::shared_ptr& state);
virtual ~Actions();
private:
std::shared_ptr m_state;
GSimpleActionGroup* m_actions = nullptr;
void update_calendar_state();
// we've got raw pointers in here, so disable copying
Actions(const Actions&) =delete;
Actions& operator=(const Actions&) =delete;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_ACTIONS_H
./include/datetime/wakeup-timer.h 0000644 0000041 0000041 00000002500 13151304754 017245 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_WAKEUP_TIMER_H
#define INDICATOR_DATETIME_WAKEUP_TIMER_H
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
/***
****
***/
/**
* \brief A one-shot timer that emits a signal when its timeout is reached.
*/
class WakeupTimer
{
public:
WakeupTimer() =default;
virtual ~WakeupTimer() =default;
virtual void set_wakeup_time (const DateTime&) =0;
virtual core::Signal<>& timeout() =0;
};
/***
****
***/
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_WAKEUP_TIMER_H
./include/datetime/timezone-geoclue.h 0000644 0000041 0000041 00000002646 13151304754 020121 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_GEOCLUE_TIMEZONE_H
#define INDICATOR_DATETIME_GEOCLUE_TIMEZONE_H
#include // base class
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief A #Timezone that gets its information from asking GeoClue
*/
class GeoclueTimezone: public Timezone
{
public:
GeoclueTimezone();
~GeoclueTimezone();
private:
struct Impl;
std::unique_ptr impl;
// we've got pointers in here, so don't allow copying
GeoclueTimezone(const GeoclueTimezone&) =delete;
GeoclueTimezone& operator=(const GeoclueTimezone&) =delete;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_GEOCLUE_TIMEZONE_H
./include/datetime/settings.h 0000644 0000041 0000041 00000004737 13151304754 016511 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_SETTINGS_H
#define INDICATOR_DATETIME_SETTINGS_H
#include
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief Interface that represents user-configurable settings.
*
* See the descriptions in data/com.canonical.indicator.datetime.gschema.xml
* for more information on specific properties.
*/
class Settings
{
public:
Settings() =default;
virtual ~Settings() =default;
core::Property custom_time_format;
core::Property> locations;
core::Property show_calendar;
core::Property show_clock;
core::Property show_date;
core::Property show_day;
core::Property show_detected_location;
core::Property show_events;
core::Property show_locations;
core::Property show_seconds;
core::Property show_week_numbers;
core::Property show_year;
core::Property time_format_mode;
core::Property timezone_name;
core::Property calendar_sound;
core::Property alarm_sound;
core::Property alarm_haptic;
core::Property alarm_volume;
core::Property alarm_duration;
core::Property snooze_duration;
core::Property cal_notification_enabled;
core::Property cal_notification_sounds;
core::Property cal_notification_vibrations;
core::Property cal_notification_bubbles;
core::Property cal_notification_list;
core::Property vibrate_silent_mode;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_SETTINGS_H
./include/datetime/clock.h 0000644 0000041 0000041 00000004242 13151304754 015733 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_CLOCK_H
#define INDICATOR_DATETIME_CLOCK_H
#include
#include
#include
#include // std::shared_ptr, std::unique_ptr
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief A clock.
*/
class Clock
{
public:
virtual ~Clock();
virtual DateTime localtime() const =0;
/** \brief A signal which fires when the clock's minute changes */
core::Signal<> minute_changed;
/** \brief A signal which fires when the clock's date changes */
core::Signal<> date_changed;
protected:
Clock();
/** \brief Compares old and new times, emits minute_changed() or date_changed() signals if appropriate */
void maybe_emit (const DateTime& a, const DateTime& b);
private:
class Impl;
friend class Impl;
std::unique_ptr m_impl;
// we've got raw pointers and GSignal tags in here, so disable copying
Clock(const Clock&) =delete;
Clock& operator=(const Clock&) =delete;
};
/***
****
***/
class Timezone;
/**
* \brief A live #Clock that provides the actual system time.
*/
class LiveClock: public Clock
{
public:
LiveClock (const std::shared_ptr& zones);
virtual ~LiveClock();
virtual DateTime localtime() const override;
private:
class Impl;
std::unique_ptr p;
};
/***
****
***/
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_CLOCK_H
./include/datetime/planner-upcoming.h 0000644 0000041 0000041 00000003115 13151304754 020114 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_PLANNER_UPCOMING_H
#define INDICATOR_DATETIME_PLANNER_UPCOMING_H
#include
#include
#include
#include // std::shared_ptr
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief A collection of upcoming appointments starting from the specified date
*/
class UpcomingPlanner: public Planner
{
public:
UpcomingPlanner(const std::shared_ptr& range_planner,
const DateTime& date);
~UpcomingPlanner() =default;
core::Property>& appointments();
core::Property& date();
private:
std::shared_ptr m_range_planner;
core::Property m_date;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_PLANNER_UPCOMING_H
./include/datetime/dbus-shared.h 0000644 0000041 0000041 00000003761 13151304754 017046 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Ted Gould
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_DBUS_SHARED_H
#define INDICATOR_DATETIME_DBUS_SHARED_H
#define BUS_DATETIME_NAME "com.canonical.indicator.datetime"
#define BUS_DATETIME_PATH "/com/canonical/indicator/datetime"
#define BUS_POWERD_NAME "com.canonical.powerd"
#define BUS_POWERD_PATH "/com/canonical/powerd"
#define BUS_POWERD_INTERFACE "com.canonical.powerd"
namespace Bus
{
namespace Timedate1
{
static constexpr char const * BUSNAME {"org.freedesktop.timedate1"};
static constexpr char const * ADDR {"/org/freedesktop/timedate1"};
static constexpr char const * IFACE {"org.freedesktop.timedate1"};
namespace Properties
{
static constexpr char const * TIMEZONE {"Timezone"};
}
namespace Methods
{
static constexpr char const * SET_TIMEZONE {"SetTimezone"};
}
}
namespace Properties
{
static constexpr char const * IFACE {"org.freedesktop.DBus.Properties"};
namespace Methods
{
static constexpr char const * GET {"Get"};
}
namespace Signals
{
static constexpr char const * PROPERTIES_CHANGED {"PropertiesChanged"};
}
}
}
#endif /* INDICATOR_DATETIME_DBUS_SHARED_H */
./include/datetime/snap.h 0000644 0000041 0000041 00000003552 13151304754 015604 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_SNAP_H
#define INDICATOR_DATETIME_SNAP_H
#include
#include
#include
#include
#include // GDBusConnection
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief Pops up Snap Decisions for appointments
*/
class Snap
{
public:
Snap(const std::shared_ptr& engine,
const std::shared_ptr& sound_builder,
const std::shared_ptr& settings,
GDBusConnection* system_bus);
virtual ~Snap();
enum class Response { None, Snooze, ShowApp };
typedef std::function response_func;
void operator()(const Appointment& appointment,
const Alarm& alarm,
response_func on_response);
private:
class Impl;
std::unique_ptr impl;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_SNAP_H
./include/datetime/timezones-live.h 0000644 0000041 0000041 00000003142 13151304754 017610 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_LIVE_TIMEZONES_H
#define INDICATOR_DATETIME_LIVE_TIMEZONES_H
#include
#include
#include
#include // shared_ptr<>
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief #Timezones object that uses a #TimedatedTimezone and #GeoclueTimezone
* to detect what timezone we're in
*/
class LiveTimezones: public Timezones
{
public:
LiveTimezones(const std::shared_ptr& settings, const std::shared_ptr& primary_timezone);
private:
void update_geolocation();
void update_timezones();
std::shared_ptr m_primary_timezone;
std::shared_ptr m_settings;
std::shared_ptr m_geo;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_LIVE_TIMEZONES_H
./include/datetime/settings-live.h 0000644 0000041 0000041 00000005417 13151304754 017442 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_SETTINGS_LIVE_H
#define INDICATOR_DATETIME_SETTINGS_LIVE_H
#include // parent class
#include // GSettings
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief #Settings implementation which uses GSettings.
*/
class LiveSettings: public Settings
{
public:
LiveSettings();
virtual ~LiveSettings();
private:
static void on_changed_ccid(GSettings*, gchar*, gpointer);
static void on_changed_cal_notification(GSettings*, gchar*, gpointer);
static void on_changed_general_notification(GSettings*, gchar*, gpointer);
void update_key_ccid(const std::string& key);
void update_key_cal_notification(const std::string& key);
void update_key_general_notification(const std::string& key);
void update_custom_time_format();
void update_locations();
void update_show_calendar();
void update_show_clock();
void update_show_date();
void update_show_day();
void update_show_detected_locations();
void update_show_events();
void update_show_locations();
void update_show_seconds();
void update_show_week_numbers();
void update_show_year();
void update_time_format_mode();
void update_timezone_name();
void update_calendar_sound();
void update_alarm_sound();
void update_alarm_volume();
void update_alarm_duration();
void update_alarm_haptic();
void update_snooze_duration();
void update_cal_notification_enabled();
void update_cal_notification_sounds();
void update_cal_notification_vibrations();
void update_cal_notification_bubbles();
void update_cal_notification_list();
void update_vibrate_silent_mode();
GSettings* m_settings;
GSettings* m_settings_cal_notification;
GSettings* m_settings_general_notification;
// we've got a raw pointer here, so disable copying
LiveSettings(const LiveSettings&) =delete;
LiveSettings& operator=(const LiveSettings&) =delete;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_SETTINGS_LIVE_H
./include/datetime/appointment.h 0000644 0000041 0000041 00000003471 13151304754 017201 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_APPOINTMENT_H
#define INDICATOR_DATETIME_APPOINTMENT_H
#include
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief Basic information required to raise a notification about some Appointment.
*/
struct Alarm
{
std::string text;
std::string audio_url;
DateTime time;
bool operator== (const Alarm& that) const;
bool has_sound() const;
bool has_text() const;
};
/**
* \brief An instance of an appointment; e.g. a calendar event or clock-app alarm
*
* @see Planner
*/
struct Appointment
{
public:
enum Type { EVENT, UBUNTU_ALARM };
Type type = EVENT;
bool is_ubuntu_alarm() const { return type == UBUNTU_ALARM; }
std::string uid;
std::string source_uid;
std::string color;
std::string summary;
std::string activation_url;
DateTime begin;
DateTime end;
std::vector alarms;
bool operator== (const Appointment& that) const;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_APPOINTMENT_H
./include/datetime/formatter.h 0000644 0000041 0000041 00000010042 13151304754 016636 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_FORMATTER_H
#define INDICATOR_DATETIME_FORMATTER_H
#include
#include
#include
#include
#include // is_locale_12h()
#include
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
class Clock;
class DateTime;
/***
****
***/
/**
* \brief Provide the strftime() format strings
*
* This is a simple goal, but getting there has a lot of options and edge cases:
*
* - The default time format can change based on the locale.
*
* - The user's settings can change or completely override the format string.
*
* - The time formats are different on the Phone and Desktop profiles.
*
* - The time format string in the Locations' menuitems uses (mostly)
* the same time format as the header, except for some changes.
*
* - The 'current time' format string in the Locations' menuitems also
* prepends the string 'Yesterday' or 'Today' if it differs from the
* local time, so Formatter needs to have a Clock for its state.
*
* So the Formatter monitors system settings, the current timezone, etc.
* and upate its time format properties appropriately.
*/
class Formatter
{
public:
/** \brief The time format string for the menu header */
core::Property header_format;
/** \brief The time string for the menu header. (eg, the header_format + the clock's time */
core::Property header;
/** \brief Signal to denote when the relativeFormat has changed.
When this is emitted, clients will want to rebuild their
menuitems that contain relative time strings
(ie, the Appointments and Locations menuitems) */
core::Signal<> relative_format_changed;
/** \brief Generate a relative time format for some time (or time range)
from the current clock's value. For example, a full-day interval
starting at the end of the current clock's day yields "Tomorrow" */
std::string relative_format(GDateTime* then, GDateTime* then_end=nullptr) const;
protected:
explicit Formatter(const std::shared_ptr&);
virtual ~Formatter();
static const char* default_header_time_format(bool twelvehour, bool show_seconds);
private:
Formatter(const Formatter&) =delete;
Formatter& operator=(const Formatter&) =delete;
class Impl;
std::unique_ptr p;
};
/**
* \brief A Formatter for the Desktop and DesktopGreeter profiles.
*/
class DesktopFormatter: public Formatter
{
public:
DesktopFormatter(const std::shared_ptr&, const std::shared_ptr&);
private:
std::shared_ptr m_settings;
void rebuildHeaderFormat();
const gchar* getFullTimeFormatString() const;
std::string getHeaderLabelFormatString() const;
const gchar* getDateFormat(bool show_day, bool show_date, bool show_year) const;
};
/**
* \brief A Formatter for Phone and PhoneGreeter profiles.
*/
class PhoneFormatter: public Formatter
{
public:
explicit PhoneFormatter(const std::shared_ptr& clock): Formatter(clock) {
header_format.set(default_header_time_format(is_locale_12h(), false));
}
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_CLOCK_H
./include/datetime/engine-mock.h 0000644 0000041 0000041 00000003310 13151304754 017027 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_ENGINE_MOCK_H
#define INDICATOR_DATETIME_ENGINE_MOCK_H
#include
namespace unity {
namespace indicator {
namespace datetime {
/****
*****
****/
/**
* A no-op #Engine
*
* @see Engine
*/
class MockEngine: public Engine
{
public:
MockEngine() =default;
~MockEngine() =default;
void get_appointments(const DateTime& /*begin*/,
const DateTime& /*end*/,
const Timezone& /*default_timezone*/,
std::function&)> appointment_func) override {
appointment_func(m_appointments);
}
core::Signal<>& changed() override {
return m_changed;
}
void disable_ubuntu_alarm(const Appointment&) override {
}
private:
core::Signal<> m_changed;
std::vector m_appointments;
};
/***
****
***/
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_ENGINE_MOCK_H
./include/datetime/timezone-timedated.h 0000644 0000041 0000041 00000003064 13151304754 020431 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_TIMEDATED_TIMEZONE_H
#define INDICATOR_DATETIME_TIMEDATED_TIMEZONE_H
#include // base class
#include // GDBusConnection*
#include // std::string
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief A #Timezone that gets its information from org.freedesktop.timedate1
*/
class TimedatedTimezone: public Timezone
{
public:
TimedatedTimezone(GDBusConnection* connection);
~TimedatedTimezone();
private:
class Impl;
friend Impl;
std::unique_ptr impl;
// we have pointers in here, so disable copying
TimedatedTimezone(const TimedatedTimezone&) =delete;
TimedatedTimezone& operator=(const TimedatedTimezone&) =delete;
};
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_TIMEDATED_TIMEZONE_H
./include/datetime/engine-eds.h 0000644 0000041 0000041 00000003670 13151304754 016662 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_ENGINE_EDS_H
#define INDICATOR_DATETIME_ENGINE_EDS_H
#include
#include
#include
#include
#include
#include
namespace unity {
namespace indicator {
namespace datetime {
/****
*****
****/
class Myself;
/**
* Class wrapper around EDS so multiple #EdsPlanners can share resources
*
* @see EdsPlanner
*/
class EdsEngine: public Engine
{
public:
EdsEngine(const std::shared_ptr &myself);
~EdsEngine();
void get_appointments(const DateTime& begin,
const DateTime& end,
const Timezone& default_timezone,
std::function&)> appointment_func) override;
void disable_ubuntu_alarm(const Appointment&) override;
core::Signal<>& changed() override;
private:
class Impl;
std::unique_ptr p;
// we've got a unique_ptr here, disable copying...
EdsEngine(const EdsEngine&) =delete;
EdsEngine& operator=(const EdsEngine&) =delete;
};
/***
****
***/
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_ENGINE_EDS_H
./include/datetime/wakeup-timer-mainloop.h 0000644 0000041 0000041 00000003166 13151304754 021072 0 ustar www-data www-data /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_WAKEUP_TIMER_MAINLOOP_H
#define INDICATOR_DATETIME_WAKEUP_TIMER_MAINLOOP_H
#include
#include
#include // std::unique_ptr, std::shared_ptr
namespace unity {
namespace indicator {
namespace datetime {
/***
****
***/
/**
* \brief a WakeupTimer implemented with g_timeout_add()
*/
class MainloopWakeupTimer: public WakeupTimer
{
public:
explicit MainloopWakeupTimer(const std::shared_ptr&);
~MainloopWakeupTimer();
void set_wakeup_time (const DateTime&) override;
core::Signal<>& timeout() override;
private:
MainloopWakeupTimer(const MainloopWakeupTimer&) =delete;
MainloopWakeupTimer& operator= (const MainloopWakeupTimer&) =delete;
class Impl;
std::unique_ptr p;
};
/***
****
***/
} // namespace datetime
} // namespace indicator
} // namespace unity
#endif // INDICATOR_DATETIME_WAKEUP_TIMER_MAINLOOP_H
./include/datetime/menu.h 0000644 0000041 0000041 00000004553 13151304754 015611 0 ustar www-data www-data /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Authors:
* Charles Kerr
*/
#ifndef INDICATOR_DATETIME_MENU_H
#define INDICATOR_DATETIME_MENU_H
#include
#include
#include
#include // std::shared_ptr
#include
#include // GMenuModel
namespace unity {
namespace indicator {
namespace datetime {
/**
* \brief A menu for a specific profile; eg, Desktop or Phone.
*
* @see MenuFactory
* @see Exporter
*/
class Menu
{
public:
enum Profile { Desktop, DesktopGreeter, Phone, PhoneGreeter, NUM_PROFILES };
enum Section { Calendar, Appointments, Locations, Settings, NUM_SECTIONS };
const std::string& name() const;
Profile profile() const;
GMenuModel* menu_model();
static std::vector get_display_appointments(
const std::vector&,
const DateTime& start,
unsigned int max_items=5);
protected:
Menu (Profile profile_in, const std::string& name_in);
virtual ~Menu() =default;
GMenu* m_menu = nullptr;
private:
const Profile m_profile;
const std::string m_name;
// we've got raw pointers in here, so disable copying
Menu(const Menu&) =delete;
Menu& operator=(const Menu&) =delete;
};
/**
* \brief Builds a Menu for a given state and profile
*
* @see Menu
* @see Exporter
*/
class MenuFactory
{
public:
MenuFactory (const std::shared_ptr& actions, const std::shared_ptr& state);
std::shared_ptr