indicator-datetime-13.10.0+14.04.20140415.3/0000755000015301777760000000000012323331375020163 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/cmake/0000755000015301777760000000000012323331375021243 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/cmake/GCov.cmake0000644000015301777760000000533512323330715023106 0ustar pbusernogroup00000000000000if (CMAKE_BUILD_TYPE MATCHES coverage) set(GCOV_FLAGS "${GCOV_FLAGS} --coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}") set(GCOV_LIBS ${GCOV_LIBS} gcov) find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") if (NOT GCOVR_EXECUTABLE) message(STATUS "Gcovr binary was not found, can not generate XML coverage info.") else () message(STATUS "Gcovr found, can generate XML coverage info.") add_custom_target (coverage-xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}" --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml) endif() find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin") find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT}) if (NOT LCOV_EXECUTABLE) message(STATUS "Lcov binary was not found, can not generate HTML coverage info.") else () if(NOT GENHTML_EXECUTABLE) message(STATUS "Genthml binary not found, can not generate HTML coverage info.") else() message(STATUS "Lcov and genhtml found, can generate HTML coverage info.") add_custom_target (coverage-html WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info COMMAND "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-lcov.info COMMAND ${CMAKE_COMMAND} -E echo "" COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html" COMMAND ${CMAKE_COMMAND} -E echo "") #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\"" #) endif() endif() endif() #$(MAKE) $(AM_MAKEFLAGS) check #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info #@echo #@echo " file://$(abs_top_builddir)/lcov-html/index.html" #@echo indicator-datetime-13.10.0+14.04.20140415.3/cmake/GdbusCodegen.cmake0000644000015301777760000000246512323330715024602 0ustar pbusernogroup00000000000000cmake_minimum_required(VERSION 2.6) if(POLICY CMP0011) cmake_policy(SET CMP0011 NEW) endif(POLICY CMP0011) find_program(GDBUS_CODEGEN NAMES gdbus-codegen DOC "gdbus-codegen executable") if(NOT GDBUS_CODEGEN) message(FATAL_ERROR "Excutable gdbus-codegen not found") endif() macro(add_gdbus_codegen outfiles name prefix service_xml) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h" "${CMAKE_CURRENT_BINARY_DIR}/${name}.c" COMMAND "${GDBUS_CODEGEN}" --interface-prefix "${prefix}" --generate-c-code "${name}" "${service_xml}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${ARGN} "${service_xml}" ) list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c") endmacro(add_gdbus_codegen) macro(add_gdbus_codegen_with_namespace outfiles name prefix namespace service_xml) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h" "${CMAKE_CURRENT_BINARY_DIR}/${name}.c" COMMAND "${GDBUS_CODEGEN}" --interface-prefix "${prefix}" --generate-c-code "${name}" --c-namespace "${namespace}" "${service_xml}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${ARGN} "${service_xml}" ) list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c") endmacro(add_gdbus_codegen_with_namespace) indicator-datetime-13.10.0+14.04.20140415.3/cmake/Translations.cmake0000644000015301777760000000315712323330715024731 0ustar pbusernogroup00000000000000# Translations.cmake, CMake macros written for Marlin, feel free to re-use them macro(add_translations_directory NLS_PACKAGE) add_custom_target (i18n ALL) find_program (MSGFMT_EXECUTABLE msgfmt) file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po) foreach (PO_INPUT ${PO_FILES}) get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE) set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo) add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT}) install (FILES ${MO_OUTPUT} DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${PO_INPUT_BASE}/LC_MESSAGES RENAME ${NLS_PACKAGE}.mo) endforeach (PO_INPUT ${PO_FILES}) endmacro(add_translations_directory) macro(add_translations_catalog NLS_PACKAGE) add_custom_target (pot COMMENT “Building translation catalog.”) find_program (XGETTEXT_EXECUTABLE xgettext) set(C_SOURCE "") foreach(FILES_INPUT ${ARGN}) file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c) foreach(C_FILE ${SOURCE_FILES}) set(C_SOURCE ${C_SOURCE} ${C_FILE}) endforeach() file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala) foreach(C_FILE ${SOURCE_FILES}) set(C_SOURCE ${C_SOURCE} ${C_FILE}) endforeach() endforeach() add_custom_command (TARGET pot COMMAND ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8 ) endmacro() indicator-datetime-13.10.0+14.04.20140415.3/cmake/UseGSettings.cmake0000644000015301777760000000210212323330715024621 0ustar pbusernogroup00000000000000# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them. macro(add_schema SCHEMA_NAME) set(PKG_CONFIG_EXECUTABLE pkg-config) set(GSETTINGS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/glib-2.0/schemas") # Run the validator and error if it fails execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_compile_schemas OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND ${_glib_compile_schemas} --dry-run --schema-file=${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE) if (_schemas_invalid) message (SEND_ERROR "Schema validation error: ${_schemas_invalid}") endif (_schemas_invalid) # Actually install and recomple schemas message (STATUS "${GSETTINGS_DIR} is the GSettings install dir") install (FILES ${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL) install (CODE "message (STATUS \"Compiling GSettings schemas\")") install (CODE "execute_process (COMMAND ${_glib_compile_schemas} ${GSETTINGS_DIR})") endmacro() indicator-datetime-13.10.0+14.04.20140415.3/cmake/FindIntltool.cmake0000644000015301777760000000146112323330715024651 0ustar pbusernogroup00000000000000# FindIntltool.cmake # # Jim Nelson # Copyright 2012 Yorba Foundation find_program (INTLTOOL_MERGE_EXECUTABLE intltool-merge) if (INTLTOOL_MERGE_EXECUTABLE) set (INTLTOOL_MERGE_FOUND TRUE) else (INTLTOOL_MERGE_EXECUTABLE) set (INTLTOOL_MERGE_FOUND FALSE) endif (INTLTOOL_MERGE_EXECUTABLE) if (INTLTOOL_MERGE_FOUND) macro (INTLTOOL_MERGE_DESKTOP desktop_id po_dir) add_custom_target (geary.desktop ALL ${INTLTOOL_MERGE_EXECUTABLE} --desktop-style ${CMAKE_SOURCE_DIR}/${po_dir} ${CMAKE_CURRENT_SOURCE_DIR}/${desktop_id}.desktop.in ${desktop_id}.desktop ) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/geary.desktop DESTINATION /usr/share/applications) endmacro (INTLTOOL_MERGE_DESKTOP desktop_id po_dir) endif (INTLTOOL_MERGE_FOUND) indicator-datetime-13.10.0+14.04.20140415.3/tests/0000755000015301777760000000000012323331375021325 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/tests/glib-fixture.h0000644000015301777760000000754212323330715024104 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include #include #include #include #include #include // setlocale() class GlibFixture : public ::testing::Test { private: //GLogFunc realLogHandler; protected: std::map logCounts; void testLogCount(GLogLevelFlags log_level, int /*expected*/) { #if 0 EXPECT_EQ(expected, logCounts[log_level]); #endif logCounts.erase(log_level); } private: static void default_log_handler(const gchar * log_domain, GLogLevelFlags log_level, const gchar * message, gpointer self) { g_print("%s - %d - %s\n", log_domain, (int)log_level, message); static_cast(self)->logCounts[log_level]++; } protected: virtual void SetUp() { setlocale(LC_ALL, "C.UTF-8"); loop = g_main_loop_new(nullptr, false); //g_log_set_default_handler(default_log_handler, this); // only use local, temporary settings g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true)); g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true)); g_debug("SCHEMA_DIR is %s", SCHEMA_DIR); g_unsetenv("DISPLAY"); } virtual void TearDown() { #if 0 // confirm there aren't any unexpected log messages EXPECT_EQ(0, logCounts[G_LOG_LEVEL_ERROR]); EXPECT_EQ(0, logCounts[G_LOG_LEVEL_CRITICAL]); EXPECT_EQ(0, logCounts[G_LOG_LEVEL_WARNING]); EXPECT_EQ(0, logCounts[G_LOG_LEVEL_MESSAGE]); EXPECT_EQ(0, logCounts[G_LOG_LEVEL_INFO]); #endif // revert to glib's log handler //g_log_set_default_handler(realLogHandler, this); g_clear_pointer(&loop, g_main_loop_unref); } private: static gboolean wait_for_signal__timeout(gpointer name) { g_error("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name); return G_SOURCE_REMOVE; } static gboolean wait_msec__timeout(gpointer loop) { g_main_loop_quit(static_cast(loop)); return G_SOURCE_CONTINUE; } protected: /* convenience func to loop while waiting for a GObject's signal */ void wait_for_signal(gpointer o, const gchar * signal, const int timeout_seconds=5) { // wait for the signal or for timeout, whichever comes first const auto handler_id = g_signal_connect_swapped(o, signal, G_CALLBACK(g_main_loop_quit), loop); const auto timeout_id = g_timeout_add_seconds(timeout_seconds, wait_for_signal__timeout, loop); g_main_loop_run(loop); g_source_remove(timeout_id); g_signal_handler_disconnect(o, handler_id); } /* convenience func to loop for N msec */ void wait_msec(int msec=50) { const auto id = g_timeout_add(msec, wait_msec__timeout, loop); g_main_loop_run(loop); g_source_remove(id); } GMainLoop * loop; }; indicator-datetime-13.10.0+14.04.20140415.3/tests/test-exporter.cpp0000644000015301777760000001041412323330715024653 0ustar pbusernogroup00000000000000/* * 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 */ #include "actions-mock.h" #include "state-mock.h" #include "glib-fixture.h" #include #include #include #include #include using namespace unity::indicator::datetime; class ExporterFixture: public GlibFixture { private: typedef GlibFixture super; protected: GTestDBus* bus = nullptr; void SetUp() { super::SetUp(); // bring up the test bus bus = g_test_dbus_new(G_TEST_DBUS_NONE); g_test_dbus_up(bus); const auto address = g_test_dbus_get_bus_address(bus); g_setenv("DBUS_SYSTEM_BUS_ADDRESS", address, true); g_setenv("DBUS_SESSION_BUS_ADDRESS", address, true); } void TearDown() { GError * error = nullptr; GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); if(!g_dbus_connection_is_closed(connection)) g_dbus_connection_close_sync(connection, nullptr, &error); g_assert_no_error(error); g_clear_object(&connection); g_test_dbus_down(bus); g_clear_object(&bus); super::TearDown(); } }; TEST_F(ExporterFixture, HelloWorld) { // confirms that the Test DBus SetUp() and TearDown() works } TEST_F(ExporterFixture, Publish) { std::shared_ptr state(new MockState); std::shared_ptr actions(new MockActions(state)); std::vector> menus; MenuFactory menu_factory (actions, state); for(int i=0; i names; for(int i=0; names_strv && names_strv[i]; i++) names.insert(names_strv[i]); // confirm the actions that we expect EXPECT_EQ(1, names.count("desktop.open-alarm-app")); 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")); 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")); EXPECT_EQ(1, names.count("calendar")); EXPECT_EQ(1, names.count("desktop_greeter-header")); EXPECT_EQ(1, names.count("desktop-header")); EXPECT_EQ(1, names.count("phone_greeter-header")); EXPECT_EQ(1, names.count("phone-header")); EXPECT_EQ(1, names.count("set-location")); // try closing the connection prematurely // to test Exporter's name-lost signal bool name_lost = false; exporter.name_lost.connect([this,&name_lost](){ name_lost = true; g_main_loop_quit(loop); }); g_dbus_connection_close_sync(connection, nullptr, nullptr); g_main_loop_run(loop); EXPECT_TRUE(name_lost); // cleanup g_strfreev(names_strv); g_clear_object(&exported); g_clear_object(&connection); } indicator-datetime-13.10.0+14.04.20140415.3/tests/state-fixture.h0000644000015301777760000000306412323330715024302 0ustar pbusernogroup00000000000000/* * 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 */ #include "glib-fixture.h" #include "actions-mock.h" #include "state-mock.h" using namespace unity::indicator::datetime; class StateFixture: public GlibFixture { private: typedef GlibFixture super; protected: std::shared_ptr m_mock_state; std::shared_ptr m_state; std::shared_ptr m_mock_actions; std::shared_ptr m_actions; virtual void SetUp() { super::SetUp(); m_mock_state.reset(new MockState); m_state = std::dynamic_pointer_cast(m_mock_state); m_mock_actions.reset(new MockActions(m_state)); m_actions = std::dynamic_pointer_cast(m_mock_actions); } virtual void TearDown() { m_actions.reset(); m_mock_actions.reset(); m_state.reset(); m_mock_state.reset(); super::TearDown(); } }; indicator-datetime-13.10.0+14.04.20140415.3/tests/test-clock.cpp0000644000015301777760000001053412323330715024101 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include "test-dbus-fixture.h" /*** **** ***/ using namespace unity::indicator::datetime; class ClockFixture: public TestDBusFixture { private: typedef TestDBusFixture super; public: void emitPrepareForSleep() { g_dbus_connection_emit_signal(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, nullptr), nullptr, "/org/freedesktop/login1", // object path "org.freedesktop.login1.Manager", // interface "PrepareForSleep", // signal name g_variant_new("(b)", FALSE), nullptr); } }; TEST_F(ClockFixture, MinuteChangedSignalShouldTriggerOncePerMinute) { // start up a live clock std::shared_ptr zones(new Timezones); zones->timezone.set("America/New_York"); LiveClock clock(zones); wait_msec(500); // wait for the bus to set up // count how many times clock.minute_changed() is emitted over the next minute const DateTime now = clock.localtime(); const auto gnow = now.get(); auto gthen = g_date_time_add_minutes(gnow, 1); int count = 0; clock.minute_changed.connect([&count](){count++;}); const auto msec = g_date_time_difference(gthen,gnow) / 1000; wait_msec(msec); EXPECT_EQ(1, count); g_date_time_unref(gthen); } /*** **** ***/ #define TIMEZONE_FILE (SANDBOX"/timezone") TEST_F(ClockFixture, HelloFixture) { std::shared_ptr zones(new Timezones); zones->timezone.set("America/New_York"); LiveClock clock(zones); } TEST_F(ClockFixture, TimezoneChangeTriggersSkew) { std::shared_ptr zones(new Timezones); zones->timezone.set("America/New_York"); LiveClock clock(zones); auto tz_nyc = g_time_zone_new("America/New_York"); auto now_nyc = g_date_time_new_now(tz_nyc); auto now = clock.localtime(); EXPECT_EQ(g_date_time_get_utc_offset(now_nyc), g_date_time_get_utc_offset(now.get())); EXPECT_LE(abs(g_date_time_difference(now_nyc,now.get())), G_USEC_PER_SEC); g_date_time_unref(now_nyc); g_time_zone_unref(tz_nyc); /// change the timezones! clock.minute_changed.connect([this](){ g_main_loop_quit(loop); }); g_idle_add([](gpointer gs){ static_cast(gs)->timezone.set("America/Los_Angeles"); return G_SOURCE_REMOVE; }, zones.get()); g_main_loop_run(loop); auto tz_la = g_time_zone_new("America/Los_Angeles"); auto now_la = g_date_time_new_now(tz_la); now = clock.localtime(); EXPECT_EQ(g_date_time_get_utc_offset(now_la), g_date_time_get_utc_offset(now.get())); EXPECT_LE(abs(g_date_time_difference(now_la,now.get())), G_USEC_PER_SEC); g_date_time_unref(now_la); g_time_zone_unref(tz_la); } /** * Confirm that a "PrepareForSleep" event wil trigger a skew event */ TEST_F(ClockFixture, SleepTriggersSkew) { std::shared_ptr zones(new Timezones); zones->timezone.set("America/New_York"); LiveClock clock(zones); wait_msec(500); // wait for the bus to set up bool skewed = false; clock.minute_changed.connect([&skewed, this](){ skewed = true; g_main_loop_quit(loop); return G_SOURCE_REMOVE; }); g_idle_add([](gpointer gself){ static_cast(gself)->emitPrepareForSleep(); return G_SOURCE_REMOVE; }, this); g_main_loop_run(loop); EXPECT_TRUE(skewed); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-menus.cpp0000644000015301777760000005104012323330715024132 0ustar pbusernogroup00000000000000/* * 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 */ #include "actions-mock.h" #include "state-fixture.h" #include #include #include #include #include using namespace unity::indicator::datetime; class MenuFixture: public StateFixture { private: typedef StateFixture super; protected: std::shared_ptr m_menu_factory; std::vector> m_menus; virtual void SetUp() { super::SetUp(); // build the menus on top of the actions and state m_menu_factory.reset(new MenuFactory(m_actions, m_state)); for(int i=0; ibuildMenu(Menu::Profile(i))); } virtual void TearDown() { m_menus.clear(); m_menu_factory.reset(); super::TearDown(); } void InspectHeader(GMenuModel* menu_model, const std::string& name) { // check that there's a header menuitem EXPECT_EQ(1,g_menu_model_get_n_items(menu_model)); gchar* str = nullptr; g_menu_model_get_item_attribute(menu_model, 0, "x-canonical-type", "s", &str); EXPECT_STREQ("com.canonical.indicator.root", str); g_clear_pointer(&str, g_free); g_menu_model_get_item_attribute(menu_model, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str); const auto action_name = name + "-header"; EXPECT_EQ(std::string("indicator.")+action_name, str); g_clear_pointer(&str, g_free); // check the header auto dict = g_action_group_get_action_state(m_actions->action_group(), action_name.c_str()); EXPECT_TRUE(dict != nullptr); EXPECT_TRUE(g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT)); auto v = g_variant_lookup_value(dict, "accessible-desc", G_VARIANT_TYPE_STRING); EXPECT_TRUE(v != nullptr); g_variant_unref(v); v = g_variant_lookup_value(dict, "label", G_VARIANT_TYPE_STRING); EXPECT_TRUE(v != nullptr); g_variant_unref(v); v = g_variant_lookup_value(dict, "title", G_VARIANT_TYPE_STRING); EXPECT_TRUE(v != nullptr); g_variant_unref(v); v = g_variant_lookup_value(dict, "visible", G_VARIANT_TYPE_BOOLEAN); EXPECT_TRUE(v != nullptr); g_variant_unref(v); g_variant_unref(dict); } void InspectCalendar(GMenuModel* menu_model, Menu::Profile profile) { gchar* str = nullptr; const char * expected_action; if (profile == Menu::Desktop) expected_action = "indicator.desktop.open-calendar-app"; else if (profile == Menu::Phone) expected_action = "indicator.phone.open-calendar-app"; else expected_action = nullptr; const auto calendar_expected = ((profile == Menu::Desktop) || (profile == Menu::DesktopGreeter)) && (m_state->settings->show_calendar.get()); // get the calendar section auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); auto section = g_menu_model_get_item_link(submenu, Menu::Calendar, G_MENU_LINK_SECTION); // should be one or two items: a date label and maybe a calendar ASSERT_TRUE(section != nullptr); auto n_expected = calendar_expected ? 2 : 1; EXPECT_EQ(n_expected, g_menu_model_get_n_items(section)); // look at the date menuitem g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_LABEL, "s", &str); const auto now = m_state->clock->localtime(); EXPECT_EQ(now.format("%A, %e %B %Y"), str); g_clear_pointer(&str, g_free); g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str); if (expected_action != nullptr) EXPECT_STREQ(expected_action, str); else EXPECT_TRUE(str == nullptr); g_clear_pointer(&str, g_free); // look at the calendar menuitem if (calendar_expected) { g_menu_model_get_item_attribute(section, 1, "x-canonical-type", "s", &str); EXPECT_STREQ("com.canonical.indicator.calendar", str); g_clear_pointer(&str, g_free); g_menu_model_get_item_attribute(section, 1, G_MENU_ATTRIBUTE_ACTION, "s", &str); EXPECT_STREQ("indicator.calendar", str); g_clear_pointer(&str, g_free); g_menu_model_get_item_attribute(section, 1, "activation-action", "s", &str); if (expected_action != nullptr) EXPECT_STREQ(expected_action, str); else EXPECT_TRUE(str == nullptr); g_clear_pointer(&str, g_free); } g_clear_object(§ion); // now change the clock and see if the date label changes appropriately auto gdt_tomorrow = g_date_time_add_days(now.get(), 1); auto tomorrow = DateTime(gdt_tomorrow); g_date_time_unref(gdt_tomorrow); m_mock_state->mock_clock->set_localtime(tomorrow); wait_msec(); section = g_menu_model_get_item_link(submenu, Menu::Calendar, G_MENU_LINK_SECTION); g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_LABEL, "s", &str); EXPECT_EQ(tomorrow.format("%A, %e %B %Y"), str); g_clear_pointer(&str, g_free); g_clear_object(§ion); // cleanup g_object_unref(submenu); } private: void InspectEmptySection(GMenuModel* menu_model, Menu::Section section) { // get the Appointments section auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); auto menu_section = g_menu_model_get_item_link(submenu, section, G_MENU_LINK_SECTION); EXPECT_EQ(0, g_menu_model_get_n_items(menu_section)); g_clear_object(&menu_section); g_clear_object(&submenu); } std::vector build_some_appointments() { const auto now = m_state->clock->localtime(); auto gdt_tomorrow = g_date_time_add_days(now.get(), 1); const auto tomorrow = DateTime(gdt_tomorrow); g_date_time_unref(gdt_tomorrow); Appointment a1; // an alarm clock appointment a1.color = "red"; a1.summary = "Alarm"; a1.summary = "http://www.example.com/"; a1.uid = "example"; a1.has_alarms = true; a1.begin = a1.end = tomorrow; Appointment a2; // a non-alarm appointment a2.color = "green"; a2.summary = "Other Text"; a2.summary = "http://www.monkey.com/"; a2.uid = "monkey"; a2.has_alarms = false; a2.begin = a2.end = tomorrow; return std::vector({a1, a2}); } void InspectAppointmentMenuItem(GMenuModel* section, int index, const Appointment& appt) { // confirm it has the right x-canonical-type gchar * str = nullptr; g_menu_model_get_item_attribute(section, index, "x-canonical-type", "s", &str); if (appt.has_alarms) EXPECT_STREQ("com.canonical.indicator.alarm", str); else EXPECT_STREQ("com.canonical.indicator.appointment", str); g_clear_pointer(&str, g_free); // confirm it has a nonempty x-canonical-time-format g_menu_model_get_item_attribute(section, index, "x-canonical-time-format", "s", &str); EXPECT_TRUE(str && *str); g_clear_pointer(&str, g_free); // confirm the color hint, if it exists, // is in the x-canonical-color attribute if (appt.color.empty()) { EXPECT_FALSE(g_menu_model_get_item_attribute(section, index, "x-canonical-color", "s", &str)); } else { EXPECT_TRUE(g_menu_model_get_item_attribute(section, index, "x-canonical-color", "s", &str)); EXPECT_EQ(appt.color, str); } g_clear_pointer(&str, g_free); // confirm that alarms have an icon if (appt.has_alarms) { auto v = g_menu_model_get_item_attribute_value(section, index, G_MENU_ATTRIBUTE_ICON, nullptr); EXPECT_TRUE(v != nullptr); auto icon = g_icon_deserialize(v); EXPECT_TRUE(icon != nullptr); g_clear_object(&icon); g_clear_pointer(&v, g_variant_unref); } } void InspectAppointmentMenuItems(GMenuModel* section, int first_appt_index, const std::vector& appointments, bool can_open_planner) { // try adding a few appointments and see if the menu updates itself m_state->calendar_upcoming->appointments().set(appointments); wait_msec(); // wait a moment for the menu to update //auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); //auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION); const int n_add_event_buttons = can_open_planner ? 1 : 0; EXPECT_EQ(n_add_event_buttons + appointments.size(), g_menu_model_get_n_items(section)); for (int i=0, n=appointments.size(); isettings->show_events.set(false); wait_msec(); auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION); EXPECT_EQ(0, g_menu_model_get_n_items(section)); g_clear_object(§ion); std::vector appointments; m_state->settings->show_events.set(true); m_state->calendar_upcoming->appointments().set(appointments); wait_msec(); section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION); EXPECT_EQ(n_add_event_buttons, g_menu_model_get_n_items(section)); if (can_open_planner) { // when "show_events" is true, // there should be an "add event" button even if there aren't any appointments gchar* action = nullptr; EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action)); const char* expected_action = "desktop.open-calendar-app"; EXPECT_EQ(std::string("indicator.")+expected_action, action); EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action)); g_free(action); } g_clear_object(§ion); // try adding a few appointments and see if the menu updates itself appointments = build_some_appointments(); m_state->calendar_upcoming->appointments().set(appointments); wait_msec(); // wait a moment for the menu to update section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION); EXPECT_EQ(n_add_event_buttons + 2, g_menu_model_get_n_items(section)); InspectAppointmentMenuItems(section, 0, appointments, can_open_planner); g_clear_object(§ion); // cleanup g_clear_object(&submenu); } void InspectPhoneAppointments(GMenuModel* menu_model, bool can_open_planner) { auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); // clear all the appointments std::vector appointments; m_state->calendar_upcoming->appointments().set(appointments); wait_msec(); // wait a moment for the menu to update // check that there's a "clock app" menuitem even when there are no appointments auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION); const char* expected_action = "phone.open-alarm-app"; EXPECT_EQ(1, g_menu_model_get_n_items(section)); gchar* action = nullptr; EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action)); EXPECT_EQ(std::string("indicator.")+expected_action, action); EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action)); g_free(action); g_clear_object(§ion); // add some appointments and test them appointments = build_some_appointments(); m_state->calendar_upcoming->appointments().set(appointments); wait_msec(); // wait a moment for the menu to update section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION); EXPECT_EQ(3, g_menu_model_get_n_items(section)); InspectAppointmentMenuItems(section, 1, appointments, can_open_planner); g_clear_object(§ion); // cleanup g_clear_object(&submenu); } protected: void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile) { const auto can_open_planner = m_actions->desktop_has_calendar_app(); switch (profile) { case Menu::Desktop: InspectDesktopAppointments(menu_model, can_open_planner); break; case Menu::DesktopGreeter: InspectEmptySection(menu_model, Menu::Appointments); break; case Menu::Phone: InspectPhoneAppointments(menu_model, can_open_planner); break; case Menu::PhoneGreeter: InspectEmptySection(menu_model, Menu::Appointments); break; default: g_warn_if_reached(); break; } } void CompareLocationsTo(GMenuModel* menu_model, const std::vector& locations) { // get the Locations section auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); auto section = g_menu_model_get_item_link(submenu, Menu::Locations, G_MENU_LINK_SECTION); // confirm that section's menuitems mirror the "locations" vector const auto n = locations.size(); ASSERT_EQ(n, g_menu_model_get_n_items(section)); for (guint i=0; i empty; m_state->locations->locations.set(empty); wait_msec(); CompareLocationsTo(menu_model, empty); // add some locations and confirm the menu picked up our changes Location l1 ("America/Chicago", "Dallas"); Location l2 ("America/Arizona", "Phoenix"); std::vector locations({l1, l2}); m_state->locations->locations.set(locations); wait_msec(); CompareLocationsTo(menu_model, locations_expected ? locations : empty); // now remove one of the locations... locations.pop_back(); m_state->locations->locations.set(locations); wait_msec(); CompareLocationsTo(menu_model, locations_expected ? locations : empty); } void InspectSettings(GMenuModel* menu_model, Menu::Profile profile) { std::string expected_action; if (profile == Menu::Desktop) expected_action = "indicator.desktop.open-settings-app"; else if (profile == Menu::Phone) expected_action = "indicator.phone.open-settings-app"; // get the Settings section auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); auto section = g_menu_model_get_item_link(submenu, Menu::Settings, G_MENU_LINK_SECTION); if (expected_action.empty()) { EXPECT_EQ(0, g_menu_model_get_n_items(section)); } else { EXPECT_EQ(1, g_menu_model_get_n_items(section)); gchar* str = nullptr; g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str); EXPECT_EQ(expected_action, str); g_clear_pointer(&str, g_free); } g_clear_object(§ion); g_object_unref(submenu); } }; TEST_F(MenuFixture, HelloWorld) { EXPECT_EQ(Menu::NUM_PROFILES, m_menus.size()); for (int i=0; imenu_model() != nullptr); EXPECT_EQ(i, m_menus[i]->profile()); } EXPECT_EQ(m_menus[Menu::Desktop]->name(), "desktop"); } TEST_F(MenuFixture, Header) { for(auto& menu : m_menus) InspectHeader(menu->menu_model(), menu->name()); } TEST_F(MenuFixture, Sections) { for(auto& menu : m_menus) { // check that the header has a submenu auto menu_model = menu->menu_model(); auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); EXPECT_TRUE(submenu != nullptr); EXPECT_EQ(Menu::NUM_SECTIONS, g_menu_model_get_n_items(submenu)); g_object_unref(submenu); } } TEST_F(MenuFixture, Calendar) { m_state->settings->show_calendar.set(true); for(auto& menu : m_menus) InspectCalendar(menu->menu_model(), menu->profile()); m_state->settings->show_calendar.set(false); for(auto& menu : m_menus) InspectCalendar(menu->menu_model(), menu->profile()); } TEST_F(MenuFixture, Appointments) { for(auto& menu : m_menus) InspectAppointments(menu->menu_model(), menu->profile()); // toggle can_open_planner() and test the desktop again // to confirm that the "Add Event…" menuitem appears iff // there's a calendar available user-agent m_mock_actions->set_desktop_has_calendar_app (!m_actions->desktop_has_calendar_app()); std::shared_ptr menu = m_menu_factory->buildMenu(Menu::Desktop); InspectAppointments(menu->menu_model(), menu->profile()); } TEST_F(MenuFixture, Locations) { for(auto& menu : m_menus) InspectLocations(menu->menu_model(), menu->profile()); } TEST_F(MenuFixture, Settings) { for(auto& menu : m_menus) InspectSettings(menu->menu_model(), menu->profile()); } indicator-datetime-13.10.0+14.04.20140415.3/tests/timezone-mock.h0000644000015301777760000000213712323330715024257 0ustar pbusernogroup00000000000000/* * 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_TIMEZONE_MOCK_H #define INDICATOR_DATETIME_TIMEZONE_MOCK_H #include namespace unity { namespace indicator { namespace datetime { class MockTimezone: public Timezone { public: MockTimezone() =default; ~MockTimezone() =default; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_TIMEZONE_MOCK_H indicator-datetime-13.10.0+14.04.20140415.3/tests/planner-mock.h0000644000015301777760000000316512323330715024066 0ustar pbusernogroup00000000000000/* * 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_PLANNER_MOCK_H #define INDICATOR_DATETIME_PLANNER_MOCK_H #include namespace unity { namespace indicator { namespace datetime { /** * \brief #RangePlanner which does nothing on its own. * Its controller must set its appointments property. */ class MockRangePlanner: public RangePlanner { public: MockRangePlanner(): m_range(std::pair(DateTime::NowLocal(), DateTime::NowLocal())) { } ~MockRangePlanner() =default; core::Property>& appointments() { return m_appointments; } core::Property>& range() { return m_range; } private: core::Property> m_appointments; core::Property> m_range; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_PLANNER_MOCK_H indicator-datetime-13.10.0+14.04.20140415.3/tests/test-live-actions.cpp0000644000015301777760000003564612323330715025416 0ustar pbusernogroup00000000000000/* * 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 */ #include #include "state-mock.h" #include "glib-fixture.h" /*** **** ***/ class MockLiveActions: public LiveActions { public: std::string last_cmd; std::string last_url; MockLiveActions(const std::shared_ptr& state_in): LiveActions(state_in) {} virtual ~MockLiveActions() {} protected: void dispatch_url(const std::string& url) { last_url = url; } void execute_command(const std::string& cmd) { last_cmd = cmd; } }; /*** **** ***/ using namespace unity::indicator::datetime; class LiveActionsFixture: public GlibFixture { private: typedef GlibFixture super; static void on_bus_acquired(GDBusConnection* conn, const gchar* name, gpointer gself) { auto self = static_cast(gself); g_debug("bus acquired: %s, connection is %p", name, conn); // Set up a mock GSD. // All it really does is wait for calls to GetDevice and // returns the get_devices_retval variant static const GDBusInterfaceVTable vtable = { timedate1_handle_method_call, nullptr, /* GetProperty */ nullptr, /* SetProperty */ }; self->connection = G_DBUS_CONNECTION(g_object_ref(G_OBJECT(conn))); GError* error = nullptr; self->object_register_id = g_dbus_connection_register_object( conn, "/org/freedesktop/timedate1", self->node_info->interfaces[0], &vtable, self, nullptr, &error); g_assert_no_error(error); } static void on_name_acquired(GDBusConnection* /*conn*/, const gchar* /*name*/, gpointer gself) { auto self = static_cast(gself); self->name_acquired = true; g_main_loop_quit(self->loop); } static void on_name_lost(GDBusConnection* /*conn*/, const gchar* /*name*/, gpointer gself) { auto self = static_cast(gself); self->name_acquired = false; } static void on_bus_closed(GObject* /*object*/, GAsyncResult* res, gpointer gself) { auto self = static_cast(gself); GError* err = nullptr; g_dbus_connection_close_finish(self->connection, res, &err); g_assert_no_error(err); g_main_loop_quit(self->loop); } static void timedate1_handle_method_call(GDBusConnection * /*connection*/, const gchar * /*sender*/, const gchar * /*object_path*/, const gchar * /*interface_name*/, const gchar * method_name, GVariant * parameters, GDBusMethodInvocation * invocation, gpointer gself) { g_assert(!g_strcmp0(method_name, "SetTimezone")); g_assert(g_variant_is_of_type(parameters, G_VARIANT_TYPE_TUPLE)); g_assert(2 == g_variant_n_children(parameters)); auto child = g_variant_get_child_value(parameters, 0); g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING)); auto self = static_cast(gself); self->attempted_tzid = g_variant_get_string(child, nullptr); g_variant_unref(child); g_dbus_method_invocation_return_value(invocation, nullptr); g_main_loop_quit(self->loop); } protected: std::shared_ptr m_mock_state; std::shared_ptr m_state; std::shared_ptr m_live_actions; std::shared_ptr m_actions; bool name_acquired; std::string attempted_tzid; GTestDBus* bus; guint own_name; GDBusConnection* connection; GDBusNodeInfo* node_info; int object_register_id; void SetUp() { super::SetUp(); name_acquired = false; attempted_tzid.clear(); connection = nullptr; node_info = nullptr; object_register_id = 0; own_name = 0; // bring up the test bus bus = g_test_dbus_new(G_TEST_DBUS_NONE); g_test_dbus_up(bus); const auto address = g_test_dbus_get_bus_address(bus); g_setenv("DBUS_SYSTEM_BUS_ADDRESS", address, true); g_setenv("DBUS_SESSION_BUS_ADDRESS", address, true); g_debug("test_dbus's address is %s", address); // parse the org.freedesktop.timedate1 interface const gchar introspection_xml[] = "" " " " " " " " " " " " " ""; node_info = g_dbus_node_info_new_for_xml(introspection_xml, nullptr); ASSERT_TRUE(node_info != nullptr); ASSERT_TRUE(node_info->interfaces != nullptr); ASSERT_TRUE(node_info->interfaces[0] != nullptr); ASSERT_TRUE(node_info->interfaces[1] == nullptr); ASSERT_STREQ("org.freedesktop.timedate1", node_info->interfaces[0]->name); // own the bus own_name = g_bus_own_name(G_BUS_TYPE_SYSTEM, "org.freedesktop.timedate1", G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, this, nullptr); ASSERT_TRUE(object_register_id == 0); ASSERT_FALSE(name_acquired); ASSERT_TRUE(connection == nullptr); g_main_loop_run(loop); ASSERT_TRUE(object_register_id != 0); ASSERT_TRUE(name_acquired); ASSERT_TRUE(G_IS_DBUS_CONNECTION(connection)); // create the State and Actions m_mock_state.reset(new MockState); m_mock_state->settings.reset(new Settings); m_state = std::dynamic_pointer_cast(m_mock_state); m_live_actions.reset(new MockLiveActions(m_state)); m_actions = std::dynamic_pointer_cast(m_live_actions); } void TearDown() { m_actions.reset(); m_live_actions.reset(); m_state.reset(); m_mock_state.reset(); g_dbus_connection_unregister_object(connection, object_register_id); g_dbus_node_info_unref(node_info); g_bus_unown_name(own_name); g_dbus_connection_close(connection, nullptr, on_bus_closed, this); g_main_loop_run(loop); g_clear_object(&connection); g_test_dbus_down(bus); g_clear_object(&bus); super::TearDown(); } }; /*** **** ***/ TEST_F(LiveActionsFixture, HelloWorld) { EXPECT_TRUE(true); } TEST_F(LiveActionsFixture, SetLocation) { const std::string tzid = "America/Chicago"; const std::string name = "Oklahoma City"; const std::string expected = tzid + " " + name; EXPECT_NE(expected, m_state->settings->timezone_name.get()); m_actions->set_location(tzid, name); g_main_loop_run(loop); EXPECT_EQ(attempted_tzid, tzid); wait_msec(); EXPECT_EQ(expected, m_state->settings->timezone_name.get()); } /*** **** ***/ TEST_F(LiveActionsFixture, DesktopOpenAlarmApp) { m_actions->desktop_open_alarm_app(); const std::string expected = "evolution -c calendar"; EXPECT_EQ(expected, m_live_actions->last_cmd); } TEST_F(LiveActionsFixture, DesktopOpenAppointment) { Appointment a; a.uid = "some-uid"; a.begin = DateTime::NowLocal(); m_actions->desktop_open_appointment(a); const std::string expected_substr = "evolution \"calendar:///?startdate="; EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos); } TEST_F(LiveActionsFixture, DesktopOpenCalendarApp) { m_actions->desktop_open_calendar_app(DateTime::NowLocal()); const std::string expected_substr = "evolution \"calendar:///?startdate="; EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos); } TEST_F(LiveActionsFixture, DesktopOpenSettingsApp) { m_actions->desktop_open_settings_app(); const std::string expected_substr = "control-center"; EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos); } /*** **** ***/ namespace { const std::string clock_app_url = "appid://com.ubuntu.clock/clock/current-user-version"; const std::string calendar_app_url = "appid://com.ubuntu.calendar/calendar/current-user-version"; } TEST_F(LiveActionsFixture, PhoneOpenAlarmApp) { m_actions->phone_open_alarm_app(); EXPECT_EQ(clock_app_url, m_live_actions->last_url); } TEST_F(LiveActionsFixture, PhoneOpenAppointment) { Appointment a; a.uid = "some-uid"; a.begin = DateTime::NowLocal(); a.has_alarms = false; m_actions->phone_open_appointment(a); EXPECT_EQ(calendar_app_url, m_live_actions->last_url); a.has_alarms = true; m_actions->phone_open_appointment(a); EXPECT_EQ(clock_app_url, m_live_actions->last_url); a.url = "appid://blah"; m_actions->phone_open_appointment(a); EXPECT_EQ(a.url, m_live_actions->last_url); } TEST_F(LiveActionsFixture, PhoneOpenCalendarApp) { m_actions->phone_open_calendar_app(DateTime::NowLocal()); const std::string expected = "appid://com.ubuntu.calendar/calendar/current-user-version"; EXPECT_EQ(expected, m_live_actions->last_url); } TEST_F(LiveActionsFixture, PhoneOpenSettingsApp) { m_actions->phone_open_settings_app(); const std::string expected = "settings:///system/time-date"; EXPECT_EQ(expected, m_live_actions->last_url); } /*** **** ***/ TEST_F(LiveActionsFixture, CalendarState) { // init the clock auto tmp = g_date_time_new_local (2014, 1, 1, 0, 0, 0); const DateTime now (tmp); g_date_time_unref (tmp); m_mock_state->mock_clock->set_localtime (now); m_state->calendar_month->month().set(now); //m_state->planner->time.set(now); /// /// Test the default calendar state. /// auto action_group = m_actions->action_group(); auto calendar_state = g_action_group_get_action_state (action_group, "calendar"); EXPECT_TRUE (calendar_state != nullptr); EXPECT_TRUE (g_variant_is_of_type (calendar_state, G_VARIANT_TYPE_DICTIONARY)); // there's nothing in the planner yet, so appointment-days should be an empty array auto v = g_variant_lookup_value (calendar_state, "appointment-days", G_VARIANT_TYPE_ARRAY); EXPECT_TRUE (v != nullptr); EXPECT_EQ (0, g_variant_n_children (v)); g_clear_pointer (&v, g_variant_unref); // calendar-day should be in sync with m_state->calendar_day v = g_variant_lookup_value (calendar_state, "calendar-day", G_VARIANT_TYPE_INT64); EXPECT_TRUE (v != nullptr); EXPECT_EQ (m_state->calendar_month->month().get().to_unix(), g_variant_get_int64(v)); g_clear_pointer (&v, g_variant_unref); // show-week-numbers should be false because MockSettings defaults everything to 0 v = g_variant_lookup_value (calendar_state, "show-week-numbers", G_VARIANT_TYPE_BOOLEAN); EXPECT_TRUE (v != nullptr); EXPECT_FALSE (g_variant_get_boolean (v)); g_clear_pointer (&v, g_variant_unref); // cleanup this step g_clear_pointer (&calendar_state, g_variant_unref); /// /// Now add appointments to the planner and confirm that the state keeps in sync /// auto tomorrow = g_date_time_add_days (now.get(), 1); auto tomorrow_begin = g_date_time_add_full (tomorrow, 0, 0, 0, -g_date_time_get_hour(tomorrow), -g_date_time_get_minute(tomorrow), -g_date_time_get_seconds(tomorrow)); auto tomorrow_end = g_date_time_add_full (tomorrow_begin, 0, 0, 1, 0, 0, -1); Appointment a1; a1.color = "green"; a1.summary = "write unit tests"; a1.url = "http://www.ubuntu.com/"; a1.uid = "D4B57D50247291478ED31DED17FF0A9838DED402"; a1.begin = tomorrow_begin; a1.end = tomorrow_end; auto next_begin = g_date_time_add_days (tomorrow_begin, 1); auto next_end = g_date_time_add_full (next_begin, 0, 0, 1, 0, 0, -1); Appointment a2; a2.color = "orange"; a2.summary = "code review"; a2.url = "http://www.ubuntu.com/"; a2.uid = "2756ff7de3745bbffd65d2e4779c37c7ca60d843"; a2.begin = next_begin; a2.end = next_end; m_state->calendar_month->appointments().set(std::vector({a1, a2})); /// /// Now test the calendar state again. /// The this_month field should now contain the appointments we just added. /// calendar_state = g_action_group_get_action_state (action_group, "calendar"); v = g_variant_lookup_value (calendar_state, "appointment-days", G_VARIANT_TYPE_ARRAY); EXPECT_TRUE (v != nullptr); int i; g_variant_get_child (v, 0, "i", &i); EXPECT_EQ (g_date_time_get_day_of_month(a1.begin.get()), i); g_variant_get_child (v, 1, "i", &i); EXPECT_EQ (g_date_time_get_day_of_month(a2.begin.get()), i); g_clear_pointer(&v, g_variant_unref); g_clear_pointer(&calendar_state, g_variant_unref); // cleanup this step g_date_time_unref (next_end); g_date_time_unref (next_begin); g_date_time_unref (tomorrow_end); g_date_time_unref (tomorrow_begin); g_date_time_unref (tomorrow); /// /// Confirm that the action state's dictionary /// keeps in sync with settings.show_week_numbers /// auto b = m_state->settings->show_week_numbers.get(); for (i=0; i<2; i++) { b = !b; m_state->settings->show_week_numbers.set(b); calendar_state = g_action_group_get_action_state (action_group, "calendar"); v = g_variant_lookup_value (calendar_state, "show-week-numbers", G_VARIANT_TYPE_BOOLEAN); EXPECT_TRUE(v != nullptr); EXPECT_EQ(b, g_variant_get_boolean(v)); g_clear_pointer(&v, g_variant_unref); g_clear_pointer(&calendar_state, g_variant_unref); } } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-clock-watcher.cpp0000644000015301777760000001257712323330715025545 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include "state-fixture.h" using namespace unity::indicator::datetime; class ClockWatcherFixture: public StateFixture { private: typedef StateFixture super; protected: std::vector m_triggered; std::unique_ptr m_watcher; std::shared_ptr m_range_planner; std::shared_ptr m_upcoming; void SetUp() { super::SetUp(); m_range_planner.reset(new MockRangePlanner); m_upcoming.reset(new UpcomingPlanner(m_range_planner, m_state->clock->localtime())); m_watcher.reset(new ClockWatcherImpl(m_state->clock, m_upcoming)); m_watcher->alarm_reached().connect([this](const Appointment& appt){ m_triggered.push_back(appt.uid); }); EXPECT_TRUE(m_triggered.empty()); } void TearDown() { m_triggered.clear(); m_watcher.reset(); m_upcoming.reset(); m_range_planner.reset(); super::TearDown(); } std::vector build_some_appointments() { const auto now = m_state->clock->localtime(); auto tomorrow = g_date_time_add_days (now.get(), 1); auto tomorrow_begin = g_date_time_add_full (tomorrow, 0, 0, 0, -g_date_time_get_hour(tomorrow), -g_date_time_get_minute(tomorrow), -g_date_time_get_seconds(tomorrow)); auto tomorrow_end = g_date_time_add_full (tomorrow_begin, 0, 0, 1, 0, 0, -1); Appointment a1; // an alarm clock appointment a1.color = "red"; a1.summary = "Alarm"; a1.summary = "http://www.example.com/"; a1.uid = "example"; a1.has_alarms = true; a1.begin = tomorrow_begin; a1.end = tomorrow_end; auto ubermorgen_begin = g_date_time_add_days (tomorrow, 1); auto ubermorgen_end = g_date_time_add_full (tomorrow_begin, 0, 0, 1, 0, 0, -1); Appointment a2; // a non-alarm appointment a2.color = "green"; a2.summary = "Other Text"; a2.summary = "http://www.monkey.com/"; a2.uid = "monkey"; a2.has_alarms = false; a2.begin = ubermorgen_begin; a2.end = ubermorgen_end; // cleanup g_date_time_unref(ubermorgen_end); g_date_time_unref(ubermorgen_begin); g_date_time_unref(tomorrow_end); g_date_time_unref(tomorrow_begin); g_date_time_unref(tomorrow); return std::vector({a1, a2}); } }; /*** **** ***/ TEST_F(ClockWatcherFixture, AppointmentsChanged) { // Add some appointments to the planner. // One of these matches our state's localtime, so that should get triggered. std::vector a = build_some_appointments(); a[0].begin = m_state->clock->localtime(); m_range_planner->appointments().set(a); // Confirm that it got fired EXPECT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); } TEST_F(ClockWatcherFixture, TimeChanged) { // Add some appointments to the planner. // Neither of these match the state's localtime, so nothing should be triggered. std::vector a = build_some_appointments(); m_range_planner->appointments().set(a); EXPECT_TRUE(m_triggered.empty()); // Set the state's clock to a time that matches one of the appointments(). // That appointment should get triggered. m_mock_state->mock_clock->set_localtime(a[1].begin); EXPECT_EQ(1, m_triggered.size()); EXPECT_EQ(a[1].uid, m_triggered[0]); } TEST_F(ClockWatcherFixture, MoreThanOne) { const auto now = m_state->clock->localtime(); std::vector a = build_some_appointments(); a[0].begin = a[1].begin = now; m_range_planner->appointments().set(a); EXPECT_EQ(2, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); EXPECT_EQ(a[1].uid, m_triggered[1]); } TEST_F(ClockWatcherFixture, NoDuplicates) { // Setup: add an appointment that gets triggered. const auto now = m_state->clock->localtime(); const std::vector appointments = build_some_appointments(); std::vector a; a.push_back(appointments[0]); a[0].begin = now; m_range_planner->appointments().set(a); EXPECT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); // Now change the appointment vector by adding one to it. // Confirm that the ClockWatcher doesn't re-trigger a[0] a.push_back(appointments[1]); m_range_planner->appointments().set(a); EXPECT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-timezone-geoclue.cpp0000644000015301777760000000305012323330715026254 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "geoclue-fixture.h" #include using unity::indicator::datetime::GeoclueTimezone; // This test looks small because the interesting // work is all happening in GeoclueFixture... TEST_F(GeoclueFixture, ChangeDetected) { GeoclueTimezone tz; wait_msec(500); // wait for the bus to get set up EXPECT_EQ(timezone_1, tz.timezone.get()); // Start listening for a timezone change, then change the timezone. bool changed = false; auto connection = tz.timezone.changed().connect( [&changed, this](const std::string& s){ g_debug("timezone changed to %s", s.c_str()); changed = true; g_main_loop_quit(loop); }); const std::string timezone_2 = "America/Chicago"; setGeoclueTimezoneOnIdle(timezone_2); g_main_loop_run(loop); EXPECT_EQ(timezone_2, tz.timezone.get()); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-actions.cpp0000644000015301777760000002634312323330715024453 0ustar pbusernogroup00000000000000/* * 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 */ #include #include "state-fixture.h" using namespace unity::indicator::datetime; class ActionsFixture: public StateFixture { typedef StateFixture super; std::vector build_some_appointments() { const auto now = m_state->clock->localtime(); auto gdt_tomorrow = g_date_time_add_days(now.get(), 1); const auto tomorrow = DateTime(gdt_tomorrow); g_date_time_unref(gdt_tomorrow); Appointment a1; // an alarm clock appointment a1.color = "red"; a1.summary = "Alarm"; a1.summary = "http://www.example.com/"; a1.uid = "example"; a1.has_alarms = true; a1.begin = a1.end = tomorrow; Appointment a2; // a non-alarm appointment a2.color = "green"; a2.summary = "Other Text"; a2.summary = "http://www.monkey.com/"; a2.uid = "monkey"; a2.has_alarms = false; a2.begin = a2.end = tomorrow; return std::vector({a1, a2}); } protected: virtual void SetUp() { super::SetUp(); } virtual void TearDown() { super::TearDown(); } void test_action_with_no_args(const char * action_name, MockActions::Action expected_action) { // preconditions EXPECT_TRUE(m_mock_actions->history().empty()); auto action_group = m_actions->action_group(); EXPECT_TRUE(g_action_group_has_action(action_group, action_name)); // run the test g_action_group_activate_action(action_group, action_name, nullptr); // test the results EXPECT_EQ(std::vector({expected_action}), m_mock_actions->history()); } void test_action_with_time_arg(const char * action_name, MockActions::Action expected_action) { // preconditions EXPECT_TRUE(m_mock_actions->history().empty()); auto action_group = m_actions->action_group(); EXPECT_TRUE(g_action_group_has_action(action_group, action_name)); // activate the action const auto now = DateTime::NowLocal(); auto v = g_variant_new_int64(now.to_unix()); g_action_group_activate_action(action_group, action_name, v); // test the results EXPECT_EQ(std::vector({expected_action}), m_mock_actions->history()); EXPECT_EQ(now.format("%F %T"), m_mock_actions->date_time().format("%F %T")); } void test_action_with_appt_arg(const char * action_name, MockActions::Action expected_action) { /// /// Test 1: activate an appointment that we know about /// // preconditions EXPECT_TRUE(m_mock_actions->history().empty()); auto action_group = m_actions->action_group(); EXPECT_TRUE(g_action_group_has_action(action_group, action_name)); // init some appointments to the state const auto appointments = build_some_appointments(); m_mock_state->mock_range_planner->appointments().set(appointments); // activate the action auto v = g_variant_new_string(appointments[0].uid.c_str()); g_action_group_activate_action(action_group, action_name, v); // test the results EXPECT_EQ(std::vector({expected_action}), m_mock_actions->history()); EXPECT_EQ(appointments[0], m_mock_actions->appointment()); /// /// Test 2: activate an appointment we *don't* know about /// // setup m_mock_actions->clear(); EXPECT_TRUE(m_mock_actions->history().empty()); // activate the action v = g_variant_new_string("this-uid-is-not-one-that-we-have"); g_action_group_activate_action(action_group, action_name, v); // test the results EXPECT_TRUE(m_mock_actions->history().empty()); } }; /*** **** ***/ TEST_F(ActionsFixture, ActionsExist) { EXPECT_TRUE(m_actions != nullptr); const char* names[] = { "desktop-header", "calendar", "set-location", "desktop.open-appointment", "desktop.open-alarm-app", "desktop.open-calendar-app", "desktop.open-settings-app", "phone.open-appointment", "phone.open-alarm-app", "phone.open-calendar-app", "phone.open-settings-app" }; for(const auto& name: names) { EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), name)); } } /*** **** ***/ TEST_F(ActionsFixture, DesktopOpenAlarmApp) { test_action_with_no_args("desktop.open-alarm-app", MockActions::DesktopOpenAlarmApp); } TEST_F(ActionsFixture, DesktopOpenAppointment) { test_action_with_appt_arg("desktop.open-appointment", MockActions::DesktopOpenAppt); } TEST_F(ActionsFixture, DesktopOpenCalendarApp) { test_action_with_time_arg("desktop.open-calendar-app", MockActions::DesktopOpenCalendarApp); } TEST_F(ActionsFixture, DesktopOpenSettingsApp) { test_action_with_no_args("desktop.open-settings-app", MockActions::DesktopOpenSettingsApp); } /*** **** ***/ TEST_F(ActionsFixture, PhoneOpenAlarmApp) { test_action_with_no_args("phone.open-alarm-app", MockActions::PhoneOpenAlarmApp); } TEST_F(ActionsFixture, PhoneOpenAppointment) { test_action_with_appt_arg("phone.open-appointment", MockActions::PhoneOpenAppt); } TEST_F(ActionsFixture, PhoneOpenCalendarApp) { test_action_with_time_arg("phone.open-calendar-app", MockActions::PhoneOpenCalendarApp); } TEST_F(ActionsFixture, PhoneOpenSettingsApp) { test_action_with_no_args("phone.open-settings-app", MockActions::PhoneOpenSettingsApp); } /*** **** ***/ TEST_F(ActionsFixture, SetLocation) { const auto action_name = "set-location"; auto action_group = m_actions->action_group(); EXPECT_TRUE(m_mock_actions->history().empty()); EXPECT_TRUE(g_action_group_has_action(action_group, action_name)); auto v = g_variant_new_string("America/Chicago Oklahoma City"); g_action_group_activate_action(action_group, action_name, v); const auto expected_action = MockActions::SetLocation; ASSERT_EQ(1, m_mock_actions->history().size()); EXPECT_EQ(expected_action, m_mock_actions->history()[0]); EXPECT_EQ("America/Chicago", m_mock_actions->zone()); EXPECT_EQ("Oklahoma City", m_mock_actions->name()); } TEST_F(ActionsFixture, SetCalendarDate) { // confirm that such an action exists const auto action_name = "calendar"; auto action_group = m_actions->action_group(); EXPECT_TRUE(m_mock_actions->history().empty()); EXPECT_TRUE(g_action_group_has_action(action_group, action_name)); // pick an arbitrary DateTime... auto tmp = g_date_time_new_local(2010, 1, 2, 3, 4, 5); const auto now = DateTime(tmp); g_date_time_unref(tmp); // confirm that Planner.time gets changed to that date when we // activate the 'calendar' action with that date's time_t as the arg EXPECT_NE (now, m_state->calendar_month->month().get()); auto v = g_variant_new_int64(now.to_unix()); g_action_group_activate_action (action_group, action_name, v); EXPECT_TRUE(DateTime::is_same_day (now, m_state->calendar_month->month().get())); } TEST_F(ActionsFixture, ActivatingTheCalendarResetsItsDate) { // Confirm that the GActions exist auto action_group = m_actions->action_group(); EXPECT_TRUE(g_action_group_has_action(action_group, "calendar")); EXPECT_TRUE(g_action_group_has_action(action_group, "calendar-active")); /// /// Prerequisite for the test: move calendar-date away from today /// // move calendar-date a week into the future... const auto now = m_state->clock->localtime(); auto next_week = g_date_time_add_weeks(now.get(), 1); const auto next_week_unix = g_date_time_to_unix(next_week); g_action_group_activate_action (action_group, "calendar", g_variant_new_int64(next_week_unix)); // confirm the planner and calendar action state moved a week into the future // but that m_state->clock is unchanged auto expected = g_date_time_add_full (next_week, 0, 0, 0, -g_date_time_get_hour(next_week), -g_date_time_get_minute(next_week), -g_date_time_get_seconds(next_week)); const auto expected_unix = g_date_time_to_unix(expected); EXPECT_EQ(expected_unix, m_state->calendar_month->month().get().to_unix()); EXPECT_EQ(now, m_state->clock->localtime()); auto calendar_state = g_action_group_get_action_state(action_group, "calendar"); EXPECT_TRUE(calendar_state != nullptr); EXPECT_TRUE(g_variant_is_of_type(calendar_state, G_VARIANT_TYPE_DICTIONARY)); auto v = g_variant_lookup_value(calendar_state, "calendar-day", G_VARIANT_TYPE_INT64); EXPECT_TRUE(v != nullptr); EXPECT_EQ(expected_unix, g_variant_get_int64(v)); g_clear_pointer(&v, g_variant_unref); g_clear_pointer(&calendar_state, g_variant_unref); g_date_time_unref(expected); g_date_time_unref(next_week); /// /// Now the actual test. /// We set the state of 'calendar-active' to true, which should reset the calendar date. /// This is so the calendar always starts on today's date when the indicator's menu is pulled down. /// // change the state... g_action_group_change_action_state(action_group, "calendar-active", g_variant_new_boolean(true)); // confirm the planner and calendar action state were reset back to m_state->clock's time EXPECT_EQ(now.to_unix(), m_state->calendar_month->month().get().to_unix()); EXPECT_EQ(now, m_state->clock->localtime()); calendar_state = g_action_group_get_action_state(action_group, "calendar"); EXPECT_TRUE(calendar_state != nullptr); EXPECT_TRUE(g_variant_is_of_type(calendar_state, G_VARIANT_TYPE_DICTIONARY)); v = g_variant_lookup_value(calendar_state, "calendar-day", G_VARIANT_TYPE_INT64); EXPECT_TRUE(v != nullptr); EXPECT_EQ(now.to_unix(), g_variant_get_int64(v)); g_clear_pointer(&v, g_variant_unref); g_clear_pointer(&calendar_state, g_variant_unref); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-timezone-file.cpp0000644000015301777760000000607212323330715025557 0ustar pbusernogroup00000000000000 /* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "glib-fixture.h" #include //#include //#include //#include //#include //#include //#include //#include //#include #include // fopen() //#include // chmod() #include // sync() using unity::indicator::datetime::FileTimezone; /*** **** ***/ #define TIMEZONE_FILE (SANDBOX"/timezone") class TimezoneFixture: public GlibFixture { private: typedef GlibFixture super; protected: virtual void SetUp() { super::SetUp(); } virtual void TearDown() { super::TearDown(); } public: /* convenience func to set the timezone file */ void set_file(const std::string& text) { auto fp = fopen(TIMEZONE_FILE, "w+"); fprintf(fp, "%s\n", text.c_str()); fclose(fp); sync(); } }; /** * Test that timezone-file warns, but doesn't crash, if the timezone file doesn't exist */ TEST_F(TimezoneFixture, NoFile) { remove(TIMEZONE_FILE); ASSERT_FALSE(g_file_test(TIMEZONE_FILE, G_FILE_TEST_EXISTS)); FileTimezone tz(TIMEZONE_FILE); testLogCount(G_LOG_LEVEL_WARNING, 1); } /** * Test that timezone-file picks up the initial value */ TEST_F(TimezoneFixture, InitialValue) { const std::string expected_timezone = "America/Chicago"; set_file(expected_timezone); FileTimezone tz(TIMEZONE_FILE); ASSERT_EQ(expected_timezone, tz.timezone.get()); } /** * Test that clearing the timezone results in an empty string */ TEST_F(TimezoneFixture, ChangedValue) { const std::string initial_timezone = "America/Chicago"; const std::string changed_timezone = "America/New_York"; set_file(initial_timezone); FileTimezone tz(TIMEZONE_FILE); ASSERT_EQ(initial_timezone, tz.timezone.get()); bool changed = false; auto connection = tz.timezone.changed().connect( [&changed, this](const std::string& s){ g_message("timezone changed to %s", s.c_str()); changed = true; g_main_loop_quit(loop); }); g_idle_add([](gpointer gself){ static_cast(gself)->set_file("America/New_York"); // static_cast(gtz)->timezone.set("America/New_York"); return G_SOURCE_REMOVE; }, this);//&tz); g_main_loop_run(loop); ASSERT_TRUE(changed); ASSERT_EQ(changed_timezone, tz.timezone.get()); } indicator-datetime-13.10.0+14.04.20140415.3/tests/state-mock.h0000644000015301777760000000301512323330715023541 0ustar pbusernogroup00000000000000/* * 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 */ #include "planner-mock.h" #include #include using namespace unity::indicator::datetime; class MockState: public State { public: std::shared_ptr mock_clock; std::shared_ptr mock_range_planner; MockState() { const DateTime now = DateTime::NowLocal(); mock_clock.reset(new MockClock(now)); clock = std::dynamic_pointer_cast(mock_clock); settings.reset(new Settings); mock_range_planner.reset(new MockRangePlanner); auto range_planner = std::dynamic_pointer_cast(mock_range_planner); calendar_month.reset(new MonthPlanner(range_planner, now)); calendar_upcoming.reset(new UpcomingPlanner(range_planner, now)); locations.reset(new Locations); } }; indicator-datetime-13.10.0+14.04.20140415.3/tests/test-timezones.cpp0000644000015301777760000001004712323330715025022 0ustar pbusernogroup00000000000000/* * 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 */ #include "geoclue-fixture.h" #include #include #include // std::shared_ptr #include // fopen() #include // sync() using namespace unity::indicator::datetime; typedef GeoclueFixture TimezonesFixture; #define TIMEZONE_FILE (SANDBOX "/timezone") namespace { /* convenience func to set the timezone file */ void set_file(const std::string& text) { auto fp = fopen(TIMEZONE_FILE, "w+"); fprintf(fp, "%s\n", text.c_str()); fclose(fp); sync(); } } TEST_F(TimezonesFixture, ManagerTest) { std::string timezone_file = "America/New_York"; std::string timezone_geo = "America/Denver"; set_file(timezone_file); std::shared_ptr settings(new Settings); LiveTimezones z(settings, TIMEZONE_FILE); wait_msec(500); // wait for the bus to get set up EXPECT_EQ(timezone_file, z.timezone.get()); auto zones = z.timezones.get(); //std::set zones = z.timezones.get(); EXPECT_EQ(1, zones.size()); EXPECT_EQ(1, zones.count(timezone_file)); bool zone_changed = false; auto zone_connection = z.timezone.changed().connect([&zone_changed, this](const std::string&) { zone_changed = true; g_main_loop_quit(loop); }); // start listening for a timezone change, then change the timezone bool zones_changed = false; auto zones_connection = z.timezones.changed().connect([&zones_changed, &zones, this](const std::set& timezones) { zones_changed = true; zones = timezones; g_main_loop_quit(loop); }); g_idle_add([](gpointer s_in) { auto s = static_cast(s_in); g_message("geolocation was %d", (int)s->show_detected_location.get()); g_message("turning geolocation on"); s->show_detected_location.set(true); return G_SOURCE_REMOVE; }, settings.get()); // turn on geoclue during the idle... this should add timezone_1 to the 'timezones' property g_main_loop_run(loop); EXPECT_TRUE(zones_changed); EXPECT_EQ(timezone_file, z.timezone.get()); EXPECT_EQ(2, zones.size()); EXPECT_EQ(1, zones.count(timezone_file)); EXPECT_EQ(1, zones.count(timezone_geo)); zones_changed = false; // now tweak the geoclue value... the geoclue-detected timezone should change, // causing the 'timezones' property to change zone_changed = false; zones_changed = false; timezone_geo = "America/Chicago"; setGeoclueTimezoneOnIdle(timezone_geo); g_main_loop_run(loop); EXPECT_FALSE(zone_changed); EXPECT_TRUE(zones_changed); EXPECT_EQ(timezone_file, z.timezone.get()); EXPECT_EQ(2, zones.size()); EXPECT_EQ(1, zones.count(timezone_file)); EXPECT_EQ(1, zones.count(timezone_geo)); // now set the file value... this should change both the primary property and set property zone_changed = false; zones_changed = false; timezone_file = "America/Los_Angeles"; EXPECT_EQ(0, zones.count(timezone_file)); g_idle_add([](gpointer str) {set_file(static_cast(str)); return G_SOURCE_REMOVE;}, const_cast(timezone_file.c_str())); g_main_loop_run(loop); EXPECT_TRUE(zone_changed); EXPECT_TRUE(zones_changed); EXPECT_EQ(timezone_file, z.timezone.get()); EXPECT_EQ(2, zones.size()); EXPECT_EQ(1, zones.count(timezone_file)); EXPECT_EQ(1, zones.count(timezone_geo)); } indicator-datetime-13.10.0+14.04.20140415.3/tests/manual-test-snap.cpp0000644000015301777760000000324412323330727025225 0ustar pbusernogroup00000000000000 /* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include #include #include using namespace unity::indicator::datetime; /*** **** ***/ int main() { Appointment a; a.color = "green"; a.summary = "Alarm"; a.url = "alarm:///hello-world"; a.uid = "D4B57D50247291478ED31DED17FF0A9838DED402"; a.has_alarms = true; auto begin = g_date_time_new_local(2014,12,25,0,0,0); auto end = g_date_time_add_full(begin,0,0,1,0,0,-1); a.begin = begin; a.end = end; g_date_time_unref(end); g_date_time_unref(begin); auto loop = g_main_loop_new(nullptr, false); auto show = [loop](const Appointment& appt){ g_message("You clicked 'show' for appt url '%s'", appt.url.c_str()); g_main_loop_quit(loop); }; auto dismiss = [loop](const Appointment&){ g_message("You clicked 'dismiss'"); g_main_loop_quit(loop); }; Snap snap; snap(a, show, dismiss); g_main_loop_run(loop); return 0; } indicator-datetime-13.10.0+14.04.20140415.3/tests/manual0000644000015301777760000000143112323330715022521 0ustar pbusernogroup00000000000000 Test-case indicator-datetime/unity7-items-check
Log in to a Unity 7 user session
Go to the panel and click on the DateTime indicator
Ensure there are items in the menu
Test-case indicator-datetime/unity7-greeter-items-check
Start a system and wait for the greeter or logout of the current user session
Go to the panel and click on the DateTime indicator
Ensure there are items in the menu
Test-case indicator-datetime/unity8-items-check
Login to a user session running Unity 8
Pull down the top panel until it sticks open
Navigate through the tabs until "Upcoming" is shown
Upcoming is at the top of the menu
The menu is populated with items
indicator-datetime-13.10.0+14.04.20140415.3/tests/geoclue-fixture.h0000644000015301777760000001264112323330715024606 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "glib-fixture.h" #include class GeoclueFixture : public GlibFixture { private: typedef GlibFixture super; GDBusConnection * bus = nullptr; protected: DbusTestService * service = nullptr; DbusTestDbusMock * mock = nullptr; DbusTestDbusMockObject * obj_geo = nullptr; DbusTestDbusMockObject * obj_geo_m = nullptr; DbusTestDbusMockObject * obj_geo_mc = nullptr; DbusTestDbusMockObject * obj_geo_addr = nullptr; const std::string timezone_1 = "America/Denver"; void SetUp () { super::SetUp(); GError * error = nullptr; const auto master_path = "/org/freedesktop/Geoclue/Master"; const auto client_path = "/org/freedesktop/Geoclue/Master/client0"; GString * gstr = g_string_new (nullptr); service = dbus_test_service_new (nullptr); mock = dbus_test_dbus_mock_new ("org.freedesktop.Geoclue.Master"); auto interface = "org.freedesktop.Geoclue.Master"; obj_geo_m = dbus_test_dbus_mock_get_object (mock, master_path, interface, nullptr); g_string_printf (gstr, "ret = '%s'", client_path); dbus_test_dbus_mock_object_add_method (mock, obj_geo_m, "Create", nullptr, G_VARIANT_TYPE_OBJECT_PATH, gstr->str, &error); interface = "org.freedesktop.Geoclue.MasterClient"; obj_geo_mc = dbus_test_dbus_mock_get_object (mock, client_path, interface, nullptr); dbus_test_dbus_mock_object_add_method (mock, obj_geo_mc, "SetRequirements", G_VARIANT_TYPE("(iibi)"), nullptr, "", &error); dbus_test_dbus_mock_object_add_method (mock, obj_geo_mc, "AddressStart", nullptr, nullptr, "", &error); interface = "org.freedesktop.Geoclue"; obj_geo = dbus_test_dbus_mock_get_object (mock, client_path, interface, nullptr); dbus_test_dbus_mock_object_add_method (mock, obj_geo, "AddReference", nullptr, nullptr, "", &error); g_string_printf (gstr, "ret = (1385238033, {'timezone': '%s'}, (3, 0.0, 0.0))", timezone_1.c_str()); interface = "org.freedesktop.Geoclue.Address"; obj_geo_addr = dbus_test_dbus_mock_get_object (mock, client_path, interface, nullptr); dbus_test_dbus_mock_object_add_method (mock, obj_geo_addr, "GetAddress", nullptr, G_VARIANT_TYPE("(ia{ss}(idd))"), gstr->str, &error); dbus_test_service_add_task(service, DBUS_TEST_TASK(mock)); dbus_test_service_start_tasks(service); bus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr); g_dbus_connection_set_exit_on_close (bus, FALSE); g_object_add_weak_pointer (G_OBJECT(bus), (gpointer*)&bus); g_string_free (gstr, TRUE); } virtual void TearDown () { g_clear_object (&mock); g_clear_object (&service); g_object_unref (bus); unsigned int cleartry = 0; while (bus != nullptr && cleartry < 10) { wait_msec (100); cleartry++; } // I've looked and can't find where this extra ref is coming from. // is there an unbalanced ref to the bus in the test harness?! while (bus != nullptr) { g_object_unref (bus); wait_msec (1000); } super::TearDown (); } private: struct EmitAddressChangedData { DbusTestDbusMock * mock = nullptr; DbusTestDbusMockObject * obj_geo_addr = nullptr; std::string timezone; EmitAddressChangedData(DbusTestDbusMock* mock_, DbusTestDbusMockObject* obj_geo_addr_, const std::string& timezone_): mock(mock_), obj_geo_addr(obj_geo_addr_), timezone(timezone_) {} }; static gboolean emit_address_changed_idle (gpointer gdata) { auto data = static_cast(gdata); auto fmt = g_strdup_printf ("(1385238033, {'timezone': '%s'}, (3, 0.0, 0.0))", data->timezone.c_str()); GError * error = nullptr; dbus_test_dbus_mock_object_emit_signal(data->mock, data->obj_geo_addr, //"org.freedesktop.Geoclue.Address", "AddressChanged", G_VARIANT_TYPE("(ia{ss}(idd))"), g_variant_new_parsed (fmt), &error); if (error) { g_warning("%s: %s", G_STRFUNC, error->message); g_error_free (error); } g_free (fmt); delete data; return G_SOURCE_REMOVE; } public: void setGeoclueTimezoneOnIdle (const std::string& newZone) { g_timeout_add (50, emit_address_changed_idle, new EmitAddressChangedData(mock, obj_geo_addr, newZone.c_str())); } }; indicator-datetime-13.10.0+14.04.20140415.3/tests/test-planner.cpp0000644000015301777760000000367512323330715024455 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "glib-fixture.h" #include "timezone-mock.h" #include #include #include #include #include #include #include using namespace unity::indicator::datetime; /*** **** ***/ typedef GlibFixture PlannerFixture; TEST_F(PlannerFixture, HelloWorld) { auto halloween = g_date_time_new_local(2020, 10, 31, 18, 30, 59); auto christmas = g_date_time_new_local(2020, 12, 25, 0, 0, 0); Appointment a; a.summary = "Test"; a.begin = halloween; a.end = g_date_time_add_hours(halloween, 1); const Appointment b = a; a.summary = "Foo"; EXPECT_EQ(a.summary, "Foo"); EXPECT_EQ(b.summary, "Test"); EXPECT_EQ(0, g_date_time_compare(a.begin(), b.begin())); EXPECT_EQ(0, g_date_time_compare(a.end(), b.end())); Appointment c; c.begin = christmas; c.end = g_date_time_add_hours(christmas, 1); Appointment d; d = c; EXPECT_EQ(0, g_date_time_compare(c.begin(), d.begin())); EXPECT_EQ(0, g_date_time_compare(c.end(), d.end())); a = d; EXPECT_EQ(0, g_date_time_compare(d.begin(), a.begin())); EXPECT_EQ(0, g_date_time_compare(d.end(), a.end())); } indicator-datetime-13.10.0+14.04.20140415.3/tests/CMakeLists.txt0000644000015301777760000000641312323330715024066 0ustar pbusernogroup00000000000000# build libgtest add_library (gtest STATIC ${GTEST_SOURCE_DIR}/gtest-all.cc ${GTEST_SOURCE_DIR}/gtest_main.cc) set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR}) set_target_properties (gtest PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -w) SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -g ${CC_WARNING_ARGS}") # build the necessary schemas set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled) set_source_files_properties (gschemas.compiled GENERATED) # GSettings: # compile the indicator-datetime schema into a gschemas.compiled file in this directory, # and help the tests to find that file by setting -DSCHEMA_DIR set (SCHEMA_DIR ${CMAKE_CURRENT_BINARY_DIR}) add_definitions(-DSCHEMA_DIR="${SCHEMA_DIR}") execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_command (OUTPUT gschemas.compiled DEPENDS ${CMAKE_SOURCE_DIR}/data/com.canonical.indicator.datetime.gschema.xml COMMAND cp -f ${CMAKE_SOURCE_DIR}/data/*gschema.xml ${SCHEMA_DIR} COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR}) # look for headers in our src dir, and also in the directories where we autogenerate files... include_directories (${CMAKE_SOURCE_DIR}/src) include_directories (${CMAKE_CURRENT_BINARY_DIR}) include_directories (${DBUSTEST_INCLUDE_DIRS}) add_definitions (-DSANDBOX="${CMAKE_CURRENT_BINARY_DIR}") function(add_test_by_name name) set (TEST_NAME ${name}) add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled) add_test (${TEST_NAME} ${TEST_NAME}) add_dependencies (${TEST_NAME} libindicatordatetimeservice) target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS}) endfunction() add_test_by_name(test-actions) add_test_by_name(test-clock) add_test_by_name(test-clock-watcher) add_test_by_name(test-exporter) add_test_by_name(test-formatter) add_test_by_name(test-live-actions) add_test_by_name(test-locations) add_test_by_name(test-menus) add_test_by_name(test-planner) add_test_by_name(test-settings) add_test_by_name(test-timezone-file) add_test_by_name(test-utils) set (TEST_NAME manual-test-snap) add_executable (${TEST_NAME} ${TEST_NAME}.cpp) add_dependencies (${TEST_NAME} libindicatordatetimeservice) target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS}) # disabling the timezone unit tests because they require # https://code.launchpad.net/~ted/dbus-test-runner/multi-interface-test/+merge/199724 # which hasn't landed yet. These can be re-enabled as soon as that lands. #function(add_dbusmock_test_by_name name) # set (TEST_NAME ${name}) # add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled) # add_test (${TEST_NAME} ${TEST_NAME}) # add_dependencies (${TEST_NAME} libindicatordatetimeservice) # target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${DBUSTEST_LIBRARIES} ${GTEST_LIBS}) #endfunction() #add_dbusmock_test_by_name(test-timezone-geoclue) #add_dbusmock_test_by_name(test-timezones) indicator-datetime-13.10.0+14.04.20140415.3/tests/test-utils.cpp0000644000015301777760000000626112323330715024150 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include TEST(UtilsTest, SplitSettingsLocation) { struct { const char* location; const char* expected_zone; const char* expected_name; } test_cases[] = { { "America/Chicago Chicago", "America/Chicago", "Chicago" }, { "America/Chicago Oklahoma City", "America/Chicago", "Oklahoma City" }, { "America/Los_Angeles", "America/Los_Angeles", "Los Angeles" }, { "America/Los_Angeles ", "America/Los_Angeles", "Los Angeles" }, { " America/Los_Angeles", "America/Los_Angeles", "Los Angeles" }, { " America/Los_Angeles ", "America/Los_Angeles", "Los Angeles" }, { "UTC UTC", "UTC", "UTC" } }; for(const auto& test_case : test_cases) { char * zone = nullptr; char * name = nullptr; split_settings_location(test_case.location, &zone, &name); ASSERT_STREQ(test_case.expected_zone, zone); ASSERT_STREQ(test_case.expected_name, name); g_free(zone); g_free(name); } } namespace { struct { const char* timezone; const char* location; const char* expected_name; } beautify_timezone_test_cases[] = { { "America/Chicago", nullptr, "Chicago" }, { "America/Chicago", "America/Chicago", "Chicago" }, { "America/Chicago", "America/Chigago Chicago", "Chicago" }, { "America/Chicago", "America/Chicago Oklahoma City", "Oklahoma City" }, { "America/Chicago", "Europe/London London", "Chicago" } }; } TEST(UtilsTest, BeautifulTimezoneName) { for(const auto& test_case : beautify_timezone_test_cases) { auto name = get_beautified_timezone_name(test_case.timezone, test_case.location); EXPECT_STREQ(test_case.expected_name, name); g_free(name); } } TEST(UtilsTest, GetTimezonename) { // set up a local GSettings g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true)); g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true)); g_debug("SCHEMA_DIR is %s", SCHEMA_DIR); auto settings = g_settings_new(SETTINGS_INTERFACE); for(const auto& test_case : beautify_timezone_test_cases) { g_settings_set_string(settings, SETTINGS_TIMEZONE_NAME_S, test_case.location); auto name = get_timezone_name (test_case.timezone, settings); EXPECT_STREQ(test_case.expected_name, name); g_free(name); } g_clear_object(&settings); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-dbus-fixture.h0000644000015301777760000000534012323330715025073 0ustar pbusernogroup00000000000000/* * 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 */ #include "glib-fixture.h" /*** **** ***/ class TestDBusFixture: public GlibFixture { public: TestDBusFixture() {} TestDBusFixture(const std::vector& service_dirs_in): service_dirs(service_dirs_in) {} private: typedef GlibFixture super; static void on_bus_opened (GObject* /*object*/, GAsyncResult * res, gpointer gself) { auto self = static_cast(gself); GError * err = 0; self->system_bus = g_bus_get_finish (res, &err); g_assert_no_error (err); g_main_loop_quit (self->loop); } static void on_bus_closed (GObject* /*object*/, GAsyncResult * res, gpointer gself) { auto self = static_cast(gself); GError * err = 0; g_dbus_connection_close_finish (self->system_bus, res, &err); g_assert_no_error (err); g_main_loop_quit (self->loop); } protected: GTestDBus * test_dbus; GDBusConnection * system_bus; const std::vector service_dirs; virtual void SetUp () { super::SetUp (); // pull up a test dbus test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); for (const auto& dir : service_dirs) g_test_dbus_add_service_dir (test_dbus, dir.c_str()); g_test_dbus_up (test_dbus); const char * address = g_test_dbus_get_bus_address (test_dbus); g_setenv ("DBUS_SYSTEM_BUS_ADDRESS", address, true); g_setenv ("DBUS_SESSION_BUS_ADDRESS", address, true); g_debug ("test_dbus's address is %s", address); // wait for the GDBusConnection before returning g_bus_get (G_BUS_TYPE_SYSTEM, nullptr, on_bus_opened, this); g_main_loop_run (loop); } virtual void TearDown () { wait_msec(); // close the system bus g_dbus_connection_close(system_bus, nullptr, on_bus_closed, this); g_main_loop_run(loop); g_clear_object(&system_bus); // tear down the test dbus g_test_dbus_down(test_dbus); g_clear_object(&test_dbus); super::TearDown(); } }; indicator-datetime-13.10.0+14.04.20140415.3/tests/actions-mock.h0000644000015301777760000000643712323330715024074 0ustar pbusernogroup00000000000000/* * 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_MOCK_H #define INDICATOR_DATETIME_ACTIONS_MOCK_H #include #include namespace unity { namespace indicator { namespace datetime { class MockActions: public Actions { public: MockActions(std::shared_ptr& state_in): Actions(state_in) {} ~MockActions() =default; enum Action { DesktopOpenAlarmApp, DesktopOpenAppt, DesktopOpenCalendarApp, DesktopOpenSettingsApp, PhoneOpenAlarmApp, PhoneOpenAppt, PhoneOpenCalendarApp, PhoneOpenSettingsApp, SetLocation }; const std::vector& history() const { return m_history; } const DateTime& date_time() const { return m_date_time; } const std::string& zone() const { return m_zone; } const std::string& name() const { return m_name; } const Appointment& appointment() const { return m_appt; } void clear() { m_history.clear(); m_zone.clear(); m_name.clear(); } bool desktop_has_calendar_app() const { return m_desktop_has_calendar_app; } void desktop_open_alarm_app() { m_history.push_back(DesktopOpenAlarmApp); } void desktop_open_appointment(const Appointment& appt) { m_appt = appt; m_history.push_back(DesktopOpenAppt); } void desktop_open_calendar_app(const DateTime& dt) { m_date_time = dt; m_history.push_back(DesktopOpenCalendarApp); } void desktop_open_settings_app() { m_history.push_back(DesktopOpenSettingsApp); } void phone_open_alarm_app() { m_history.push_back(PhoneOpenAlarmApp); } void phone_open_appointment(const Appointment& appt) { m_appt = appt; m_history.push_back(PhoneOpenAppt); } void phone_open_calendar_app(const DateTime& dt) { m_date_time = dt; m_history.push_back(PhoneOpenCalendarApp); } void phone_open_settings_app() { m_history.push_back(PhoneOpenSettingsApp); } void set_location(const std::string& zone_, const std::string& name_) { m_history.push_back(SetLocation); m_zone = zone_; m_name = name_; } void set_desktop_has_calendar_app(bool b) { m_desktop_has_calendar_app = b; } private: bool m_desktop_has_calendar_app = true; Appointment m_appt; std::string m_zone; std::string m_name; DateTime m_date_time; std::vector m_history; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_ACTIONS_MOCK_H indicator-datetime-13.10.0+14.04.20140415.3/tests/test-settings.cpp0000644000015301777760000001332312323330715024645 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "glib-fixture.h" #include #include using namespace unity::indicator::datetime; /*** **** ***/ class SettingsFixture: public GlibFixture { private: typedef GlibFixture super; protected: std::shared_ptr m_live; std::shared_ptr m_settings; GSettings * m_gsettings; virtual void SetUp() { super::SetUp(); m_gsettings = g_settings_new(SETTINGS_INTERFACE); m_live.reset(new LiveSettings); m_settings = std::dynamic_pointer_cast(m_live); } virtual void TearDown() { g_clear_object(&m_gsettings); m_settings.reset(); m_live.reset(); super::TearDown(); } void TestBoolProperty(core::Property& property, const gchar* key) { EXPECT_EQ(g_settings_get_boolean(m_gsettings, key), property.get()); g_settings_set_boolean(m_gsettings, key, false); EXPECT_FALSE(property.get()); g_settings_set_boolean(m_gsettings, key, true); EXPECT_TRUE(property.get()); property.set(false); EXPECT_FALSE(g_settings_get_boolean(m_gsettings, key)); property.set(true); EXPECT_TRUE(g_settings_get_boolean(m_gsettings, key)); } void TestStringProperty(core::Property& property, const gchar* key) { gchar* tmp; std::string str; tmp = g_settings_get_string(m_gsettings, key); EXPECT_EQ(tmp, property.get()); g_clear_pointer(&tmp, g_free); str = "a"; g_settings_set_string(m_gsettings, key, str.c_str()); EXPECT_EQ(str, property.get()); str = "b"; g_settings_set_string(m_gsettings, key, str.c_str()); EXPECT_EQ(str, property.get()); str = "a"; property.set(str); tmp = g_settings_get_string(m_gsettings, key); EXPECT_EQ(str, tmp); g_clear_pointer(&tmp, g_free); str = "b"; property.set(str); tmp = g_settings_get_string(m_gsettings, key); EXPECT_EQ(str, tmp); g_clear_pointer(&tmp, g_free); } }; /*** **** ***/ TEST_F(SettingsFixture, HelloWorld) { EXPECT_TRUE(true); } TEST_F(SettingsFixture, BoolProperties) { TestBoolProperty(m_settings->show_seconds, SETTINGS_SHOW_SECONDS_S); TestBoolProperty(m_settings->show_calendar, SETTINGS_SHOW_CALENDAR_S); TestBoolProperty(m_settings->show_clock, SETTINGS_SHOW_CLOCK_S); TestBoolProperty(m_settings->show_date, SETTINGS_SHOW_DATE_S); TestBoolProperty(m_settings->show_day, SETTINGS_SHOW_DAY_S); TestBoolProperty(m_settings->show_detected_location, SETTINGS_SHOW_DETECTED_S); TestBoolProperty(m_settings->show_events, SETTINGS_SHOW_EVENTS_S); TestBoolProperty(m_settings->show_locations, SETTINGS_SHOW_LOCATIONS_S); TestBoolProperty(m_settings->show_week_numbers, SETTINGS_SHOW_WEEK_NUMBERS_S); TestBoolProperty(m_settings->show_year, SETTINGS_SHOW_YEAR_S); } TEST_F(SettingsFixture, StringProperties) { TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S); TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S); } TEST_F(SettingsFixture, TimeFormatMode) { const auto key = SETTINGS_TIME_FORMAT_S; const TimeFormatMode modes[] = { TIME_FORMAT_MODE_LOCALE_DEFAULT, TIME_FORMAT_MODE_12_HOUR, TIME_FORMAT_MODE_24_HOUR, TIME_FORMAT_MODE_CUSTOM }; for(const auto& mode : modes) { g_settings_set_enum(m_gsettings, key, mode); EXPECT_EQ(mode, m_settings->time_format_mode.get()); } for(const auto& mode : modes) { m_settings->time_format_mode.set(mode); EXPECT_EQ(mode, g_settings_get_enum(m_gsettings, key)); } } namespace { std::vector strv_to_vector(const gchar** strv) { std::vector v; for(int i=0; strv && strv[i]; i++) v.push_back(strv[i]); return v; } }; TEST_F(SettingsFixture, Locations) { const auto key = SETTINGS_LOCATIONS_S; const gchar* astrv[] = {"America/Los_Angeles Oakland", "America/Chicago Oklahoma City", "Europe/London London", nullptr}; const gchar* bstrv[] = {"America/Denver", "Europe/London London", "Europe/Berlin Berlin", nullptr}; const std::vector av = strv_to_vector(astrv); const std::vector bv = strv_to_vector(bstrv); g_settings_set_strv(m_gsettings, key, astrv); EXPECT_EQ(av, m_settings->locations.get()); g_settings_set_strv(m_gsettings, key, bstrv); EXPECT_EQ(bv, m_settings->locations.get()); m_settings->locations.set(av); auto tmp = g_settings_get_strv(m_gsettings, key); auto vtmp = strv_to_vector((const gchar**)tmp); g_strfreev(tmp); EXPECT_EQ(av, vtmp); m_settings->locations.set(bv); tmp = g_settings_get_strv(m_gsettings, key); vtmp = strv_to_vector((const gchar**)tmp); g_strfreev(tmp); EXPECT_EQ(bv, vtmp); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-formatter.cpp0000644000015301777760000002125112323330715025007 0ustar pbusernogroup00000000000000 /* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "glib-fixture.h" #include #include #include #include #include #include using namespace unity::indicator::datetime; /*** **** ***/ class FormatterFixture: public GlibFixture { private: typedef GlibFixture super; gchar* m_original_locale = nullptr; protected: std::shared_ptr m_settings; virtual void SetUp() { super::SetUp(); m_settings.reset(new Settings); m_original_locale = g_strdup(setlocale(LC_TIME, nullptr)); } virtual void TearDown() { m_settings.reset(); setlocale(LC_TIME, m_original_locale); g_clear_pointer(&m_original_locale, g_free); super::TearDown(); } bool SetLocale(const char* expected_locale, const char* name) { setlocale(LC_TIME, expected_locale); const auto actual_locale = setlocale(LC_TIME, nullptr); if (!g_strcmp0(expected_locale, actual_locale)) { return true; } else { g_warning("Unable to set locale to %s; skipping %s locale tests.", expected_locale, name); return false; } } inline bool Set24hLocale() { return SetLocale("C", "24h"); } inline bool Set12hLocale() { return SetLocale("en_US.utf8", "12h"); } }; /** * Test the phone header format */ TEST_F(FormatterFixture, TestPhoneHeader) { auto now = g_date_time_new_local(2020, 10, 31, 18, 30, 59); std::shared_ptr clock(new MockClock(DateTime(now))); g_date_time_unref(now); // test the default value in a 24h locale if(Set24hLocale()) { PhoneFormatter formatter(clock); EXPECT_EQ(std::string("%H:%M"), formatter.header_format.get()); EXPECT_EQ(std::string("18:30"), formatter.header.get()); } // test the default value in a 12h locale if(Set12hLocale()) { PhoneFormatter formatter(clock); EXPECT_EQ(std::string("%l:%M %p"), formatter.header_format.get()); EXPECT_EQ(std::string(" 6:30 PM"), formatter.header.get()); } } #define EM_SPACE "\u2003" /** * Test the default values of the desktop header format */ TEST_F(FormatterFixture, TestDesktopHeader) { struct { bool is_12h; bool show_day; bool show_date; bool show_year; const char* expected_format_string; } test_cases[] = { { false, false, false, false, "%H:%M" }, { false, false, false, true, "%H:%M" }, // show_year is ignored iff show_date is false { false, false, true, false, "%b %e" EM_SPACE "%H:%M" }, { false, false, true, true, "%b %e %Y" EM_SPACE "%H:%M" }, { false, true, false, false, "%a" EM_SPACE "%H:%M" }, { false, true, false, true, "%a" EM_SPACE "%H:%M" }, // show_year is ignored iff show_date is false { false, true, true, false, "%a %b %e" EM_SPACE "%H:%M" }, { false, true, true, true, "%a %b %e %Y" EM_SPACE "%H:%M" }, { true, false, false, false, "%l:%M %p" }, { true, false, false, true, "%l:%M %p" }, // show_year is ignored iff show_date is false { true, false, true, false, "%b %e" EM_SPACE "%l:%M %p" }, { true, false, true, true, "%b %e %Y" EM_SPACE "%l:%M %p" }, { true, true, false, false, "%a" EM_SPACE "%l:%M %p" }, { true, true, false, true, "%a" EM_SPACE "%l:%M %p" }, // show_year is ignored iff show_date is false { true, true, true, false, "%a %b %e" EM_SPACE "%l:%M %p" }, { true, true, true, true, "%a %b %e %Y" EM_SPACE "%l:%M %p" } }; auto now = g_date_time_new_local(2020, 10, 31, 18, 30, 59); std::shared_ptr clock(new MockClock(DateTime(now))); g_date_time_unref(now); for(const auto& test_case : test_cases) { if (test_case.is_12h ? Set12hLocale() : Set24hLocale()) { DesktopFormatter f(clock, m_settings); m_settings->show_day.set(test_case.show_day); m_settings->show_date.set(test_case.show_date); m_settings->show_year.set(test_case.show_year); ASSERT_STREQ(test_case.expected_format_string, f.header_format.get().c_str()); } } } /** * Test the default values of the desktop header format */ TEST_F(FormatterFixture, TestUpcomingTimes) { auto a = g_date_time_new_local(2020, 10, 31, 18, 30, 59); struct { gboolean is_12h; GDateTime* now; GDateTime* then; const char* expected_format_string; } test_cases[] = { { true, g_date_time_ref(a), g_date_time_ref(a), "%l:%M %p" }, // identical time { true, g_date_time_ref(a), g_date_time_add_hours(a,1), "%l:%M %p" }, // later today { true, g_date_time_ref(a), g_date_time_add_days(a,1), "Tomorrow" EM_SPACE "%l:%M %p" }, // tomorrow { true, g_date_time_ref(a), g_date_time_add_days(a,2), "%a" EM_SPACE "%l:%M %p" }, { true, g_date_time_ref(a), g_date_time_add_days(a,6), "%a" EM_SPACE "%l:%M %p" }, { true, g_date_time_ref(a), g_date_time_add_days(a,7), "%a %d %b" EM_SPACE "%l:%M %p" }, // over one week away { false, g_date_time_ref(a), g_date_time_ref(a), "%H:%M" }, // identical time { false, g_date_time_ref(a), g_date_time_add_hours(a,1), "%H:%M" }, // later today { false, g_date_time_ref(a), g_date_time_add_days(a,1), "Tomorrow" EM_SPACE "%H:%M" }, // tomorrow { false, g_date_time_ref(a), g_date_time_add_days(a,2), "%a" EM_SPACE "%H:%M" }, { false, g_date_time_ref(a), g_date_time_add_days(a,6), "%a" EM_SPACE "%H:%M" }, { false, g_date_time_ref(a), g_date_time_add_days(a,7), "%a %d %b" EM_SPACE "%H:%M" } // over one week away }; for(const auto& test_case : test_cases) { if (test_case.is_12h ? Set12hLocale() : Set24hLocale()) { std::shared_ptr clock (new MockClock(DateTime(test_case.now))); DesktopFormatter f(clock, m_settings); const auto fmt = f.relative_format(test_case.then); ASSERT_EQ(test_case.expected_format_string, fmt); g_clear_pointer(&test_case.now, g_date_time_unref); g_clear_pointer(&test_case.then, g_date_time_unref); } } g_date_time_unref(a); } /** * Test the default values of the desktop header format */ TEST_F(FormatterFixture, TestEventTimes) { auto day = g_date_time_new_local(2013, 1, 1, 13, 0, 0); auto day_begin = g_date_time_new_local(2013, 1, 1, 13, 0, 0); auto day_end = g_date_time_add_days(day_begin, 1); auto tomorrow_begin = g_date_time_add_days(day_begin, 1); auto tomorrow_end = g_date_time_add_days(tomorrow_begin, 1); struct { bool is_12h; GDateTime* now; GDateTime* then; GDateTime* then_end; const char* expected_format_string; } test_cases[] = { { false, g_date_time_ref(day), g_date_time_ref(day_begin), g_date_time_ref(day_end), _("Today") }, { true, g_date_time_ref(day), g_date_time_ref(day_begin), g_date_time_ref(day_end), _("Today") }, { false, g_date_time_ref(day), g_date_time_ref(tomorrow_begin), g_date_time_ref(tomorrow_end), _("Tomorrow") }, { true, g_date_time_ref(day), g_date_time_ref(tomorrow_begin), g_date_time_ref(tomorrow_end), _("Tomorrow") } }; for(const auto& test_case : test_cases) { if (test_case.is_12h ? Set12hLocale() : Set24hLocale()) { std::shared_ptr clock(new MockClock(DateTime(test_case.now))); DesktopFormatter f(clock, m_settings); const auto fmt = f.relative_format(test_case.then, test_case.then_end); ASSERT_STREQ(test_case.expected_format_string, fmt.c_str()); g_clear_pointer(&test_case.now, g_date_time_unref); g_clear_pointer(&test_case.then, g_date_time_unref); g_clear_pointer(&test_case.then_end, g_date_time_unref); } } g_date_time_unref(tomorrow_end); g_date_time_unref(tomorrow_begin); g_date_time_unref(day_end); g_date_time_unref(day_begin); g_date_time_unref(day); } indicator-datetime-13.10.0+14.04.20140415.3/tests/test-locations.cpp0000644000015301777760000001234112323330715024777 0ustar pbusernogroup00000000000000 /* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include "glib-fixture.h" #include using unity::indicator::datetime::Location; using unity::indicator::datetime::Locations; using unity::indicator::datetime::Settings; using unity::indicator::datetime::SettingsLocations; using unity::indicator::datetime::Timezones; /*** **** ***/ class LocationsFixture: public GlibFixture { private: typedef GlibFixture super; protected: //GSettings * settings = nullptr; std::shared_ptr m_settings; std::shared_ptr m_timezones; const std::string nyc = "America/New_York"; const std::string chicago = "America/Chicago"; virtual void SetUp() { super::SetUp(); m_settings.reset(new Settings); m_settings->show_locations.set(true); m_settings->locations.set({"America/Los_Angeles Oakland", "America/Chicago Chicago", "America/Chicago Oklahoma City", "America/Toronto Toronto", "Europe/London London", "Europe/Berlin Berlin"}); m_timezones.reset(new Timezones); m_timezones->timezone.set(chicago); m_timezones->timezones.set(std::set({ nyc, chicago })); } virtual void TearDown() { m_timezones.reset(); m_settings.reset(); super::TearDown(); } }; TEST_F(LocationsFixture, Timezones) { m_settings->show_locations.set(false); SettingsLocations locations(m_settings, m_timezones); const auto l = locations.locations.get(); EXPECT_EQ(2, l.size()); EXPECT_STREQ("Chicago", l[0].name().c_str()); EXPECT_EQ(chicago, l[0].zone()); EXPECT_EQ("New York", l[1].name()); EXPECT_EQ(nyc, l[1].zone()); } TEST_F(LocationsFixture, SettingsLocations) { SettingsLocations locations(m_settings, m_timezones); const auto l = locations.locations.get(); EXPECT_EQ(7, l.size()); EXPECT_EQ("Chicago", l[0].name()); EXPECT_EQ(chicago, l[0].zone()); EXPECT_EQ("New York", l[1].name()); EXPECT_EQ(nyc, l[1].zone()); EXPECT_EQ("Oakland", l[2].name()); EXPECT_EQ("America/Los_Angeles", l[2].zone()); EXPECT_EQ("Oklahoma City", l[3].name()); EXPECT_EQ("America/Chicago", l[3].zone()); EXPECT_EQ("Toronto", l[4].name()); EXPECT_EQ("America/Toronto", l[4].zone()); EXPECT_EQ("London", l[5].name()); EXPECT_EQ("Europe/London", l[5].zone()); EXPECT_EQ("Berlin", l[6].name()); EXPECT_EQ("Europe/Berlin", l[6].zone()); } TEST_F(LocationsFixture, ChangeLocationStrings) { SettingsLocations locations(m_settings, m_timezones); bool locations_changed = false; locations.locations.changed().connect([&locations_changed, this](const std::vector&){ locations_changed = true; g_main_loop_quit(loop); }); g_idle_add([](gpointer settings){ static_cast(settings)->locations.set({"America/Los_Angeles Oakland", "Europe/London London", "Europe/Berlin Berlin"}); return G_SOURCE_REMOVE; }, m_settings.get()); g_main_loop_run(loop); EXPECT_TRUE(locations_changed); const auto l = locations.locations.get(); EXPECT_EQ(5, l.size()); EXPECT_EQ("Chicago", l[0].name()); EXPECT_EQ(chicago, l[0].zone()); EXPECT_EQ("New York", l[1].name()); EXPECT_EQ(nyc, l[1].zone()); EXPECT_EQ("Oakland", l[2].name()); EXPECT_EQ("America/Los_Angeles", l[2].zone()); EXPECT_EQ("London", l[3].name()); EXPECT_EQ("Europe/London", l[3].zone()); EXPECT_EQ("Berlin", l[4].name()); EXPECT_EQ("Europe/Berlin", l[4].zone()); locations_changed = false; } TEST_F(LocationsFixture, ChangeLocationVisibility) { SettingsLocations locations(m_settings, m_timezones); bool locations_changed = false; locations.locations.changed().connect([&locations_changed, this](const std::vector&){ locations_changed = true; g_main_loop_quit(loop); }); g_idle_add([](gpointer settings){ static_cast(settings)->show_locations.set(false); return G_SOURCE_REMOVE; }, m_settings.get()); g_main_loop_run(loop); EXPECT_TRUE(locations_changed); const auto l = locations.locations.get(); EXPECT_EQ(2, l.size()); EXPECT_EQ("Chicago", l[0].name()); EXPECT_EQ(chicago, l[0].zone()); EXPECT_EQ("New York", l[1].name()); EXPECT_EQ(nyc, l[1].zone()); } indicator-datetime-13.10.0+14.04.20140415.3/trim-lcov.py0000755000015301777760000000267012323330715022456 0ustar pbusernogroup00000000000000#!/usr/bin/python # This script removes branch and/or line coverage data for lines that # contain a particular substring. # # In the interest of "fairness" it removes all branch or coverage data # when a match is found -- not just negative data. It is therefore # likely that running this script will actually reduce the total number # of lines and branches that are marked as covered (in absolute terms). # # This script intentionally avoids checking for errors. Any exceptions # will trigger make to fail. # # Author: Ryan Lortie import sys line_suppress = ['g_assert_not_reached'] branch_suppress = ['g_assert', 'g_return_if_fail', 'g_clear_object', 'g_clear_pointer', 'g_return_val_if_fail', 'G_DEFINE_TYPE'] def check_suppress(suppressions, source, data): line, _, rest = data.partition(',') line = int(line) - 1 assert line < len(source) for suppression in suppressions: if suppression in source[line]: return True return False source = [] for line in sys.stdin: line = line[:-1] keyword, _, rest = line.partition(':') # Source file if keyword == 'SF': source = file(rest).readlines() # Branch coverage data elif keyword == 'BRDA': if check_suppress(branch_suppress, source, rest): continue # Line coverage data elif keyword == 'DA': if check_suppress(line_suppress, source, rest): continue print line indicator-datetime-13.10.0+14.04.20140415.3/data/0000755000015301777760000000000012323331375021074 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/data/com.canonical.indicator.datetime0000644000015301777760000000072112323330715027266 0ustar pbusernogroup00000000000000[Indicator Service] Name=indicator-datetime ObjectPath=/com/canonical/indicator/datetime Position=20 [desktop] ObjectPath=/com/canonical/indicator/datetime/desktop [desktop_greeter] ObjectPath=/com/canonical/indicator/datetime/desktop_greeter [desktop_lockscreen] ObjectPath=/com/canonical/indicator/datetime/desktop_greeter [phone] ObjectPath=/com/canonical/indicator/datetime/phone [phone_greeter] ObjectPath=/com/canonical/indicator/datetime/phone_greeter indicator-datetime-13.10.0+14.04.20140415.3/data/indicator-datetime.upstart.desktop.in0000644000015301777760000000027412323330715030343 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Name=Indicator Date & Time Exec=@pkglibexecdir@/indicator-datetime-service OnlyShowIn=Unity; NoDisplay=true StartupNotify=false Terminal=false Hidden=true indicator-datetime-13.10.0+14.04.20140415.3/data/com.canonical.indicator.datetime.gschema.xml0000644000015301777760000001202512323330715031473 0ustar pbusernogroup00000000000000 true Show the clock in the panel Controls whether the clock indicator appears in the panel or not. 'locale-default' What the time format should be Controls the time format that is displayed in the indicator. For almost all users this should be the default for their locale. If you think the setting is wrong for your locale please join or talk to the translation team for your language. If you just want something different you can adjust this to be either 12 or 24 time. Or, you can use a custom format string and set the custom-time-format setting. "%l:%M %p" The format string passed to strftime The format of the time and/or date that is visible on the panel when using the indicator. For most users this will be a set of predefined values as determined by the configuration utility, but advanced users can change it to anything strftime can accept. Look at the man page on strftime for more information. false Show the number of seconds in the indicator Makes the datetime indicator show the number of seconds in the indicator. It's important to note that this will cause additional battery drain as the time will update 60 times as often, so it is not recommended. Also, this setting will be ignored if the time-format value is set to custom. false Show the day of the week in the indicator Puts the day of the week on the panel along with the time and/or date depending on settings. This setting will be ignored if the time-format value is set to custom. false Show the month and date in the indicator Puts the month and the date in the panel along with the time and/or day of the week depending on settings. This setting will be ignored if the time-format value is set to custom. false Show the year in the indicator Puts the year in the panel along with the month and the date. This setting will be ignored if either the time-format value is set to custom or if show-date is set to false. true Show the monthly calendar in the indicator Puts the monthly calendar in indicator-datetime's menu. false Show week numbers in calendar Shows the week numbers in the monthly calendar in indicator-datetime's menu. true Show events in the indicator Shows events from Evolution in indicator-datetime's menu. false Show the auto-detected location in the indicator Shows your current location (determined from geoclue and /etc/timezone) in indicator-datetime's menu. false Show locations in the indicator Shows custom defined locations in indicator-datetime's menu. ['UTC'] A List of locations Adds the list of locations the user has configured to display in the indicator-datetime menu. '' The name of the current timezone Some timezones can be known by many different cities or names. This setting describes how the current zone prefers to be named. Format is "TIMEZONE NAME" (e.g. "America/New_York Boston" to name the New_York zone Boston). indicator-datetime-13.10.0+14.04.20140415.3/data/CMakeLists.txt0000644000015301777760000000523512323330715023636 0ustar pbusernogroup00000000000000## ## GSettings schema ## include (UseGSettings) set (SCHEMA_NAME "com.canonical.indicator.datetime.gschema.xml") set (SCHEMA_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}") add_schema (${SCHEMA_FILE}) ## ## Upstart Job File ## # where to install set (UPSTART_JOB_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/sessions") message (STATUS "${UPSTART_JOB_DIR} is the Upstart Job File install dir") set (UPSTART_JOB_NAME "${CMAKE_PROJECT_NAME}.conf") set (UPSTART_JOB_FILE "${CMAKE_CURRENT_BINARY_DIR}/${UPSTART_JOB_NAME}") set (UPSTART_JOB_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${UPSTART_JOB_NAME}.in") # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${UPSTART_JOB_FILE_IN}" "${UPSTART_JOB_FILE}") # install it install (FILES "${UPSTART_JOB_FILE}" DESTINATION "${UPSTART_JOB_DIR}") ## ## XDG Autostart File ## # where to install set (XDG_AUTOSTART_DIR "/etc/xdg/autostart") message (STATUS "${XDG_AUTOSTART_DIR} is the DBus Service File install dir") set (XDG_AUTOSTART_NAME "${CMAKE_PROJECT_NAME}.desktop") set (XDG_AUTOSTART_FILE "${CMAKE_CURRENT_BINARY_DIR}/${XDG_AUTOSTART_NAME}") set (XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${XDG_AUTOSTART_NAME}.in") # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${XDG_AUTOSTART_FILE_IN}" "${XDG_AUTOSTART_FILE}") # install it install (FILES "${XDG_AUTOSTART_FILE}" DESTINATION "${XDG_AUTOSTART_DIR}") ## ## Upstart XDG Autostart Override ## # where to install set (UPSTART_XDG_AUTOSTART_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/upstart/xdg/autostart") message (STATUS "${UPSTART_XDG_AUTOSTART_DIR} is the Upstart XDG autostart override dir") set (UPSTART_XDG_AUTOSTART_NAME "${CMAKE_PROJECT_NAME}.upstart.desktop") set (UPSTART_XDG_AUTOSTART_FILE "${CMAKE_CURRENT_BINARY_DIR}/${UPSTART_XDG_AUTOSTART_NAME}") set (UPSTART_XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${UPSTART_XDG_AUTOSTART_NAME}.in") # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${UPSTART_XDG_AUTOSTART_FILE_IN}" "${UPSTART_XDG_AUTOSTART_FILE}") # install it install (FILES "${UPSTART_XDG_AUTOSTART_FILE}" DESTINATION "${UPSTART_XDG_AUTOSTART_DIR}" RENAME "${XDG_AUTOSTART_NAME}") ## ## Unity Indicator File ## # where to install set (UNITY_INDICATOR_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/unity/indicators") message (STATUS "${UNITY_INDICATOR_DIR} is the Unity Indicator install dir") set (UNITY_INDICATOR_NAME "com.canonical.indicator.datetime") set (UNITY_INDICATOR_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${UNITY_INDICATOR_NAME}") install (FILES "${UNITY_INDICATOR_FILE}" DESTINATION "${UNITY_INDICATOR_DIR}") indicator-datetime-13.10.0+14.04.20140415.3/data/indicator-datetime.desktop.in0000644000015301777760000000034512323330715026641 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Name=Indicator Date & Time Exec=@pkglibexecdir@/indicator-datetime-service OnlyShowIn=Unity;GNOME; NoDisplay=true StartupNotify=false Terminal=false AutostartCondition=GNOME3 unless-session gnome indicator-datetime-13.10.0+14.04.20140415.3/data/indicator-datetime.conf.in0000644000015301777760000000031212323330715026107 0ustar pbusernogroup00000000000000description "Indicator Date & Time Backend" start on indicator-services-start stop on desktop-end or indicator-services-end respawn respawn limit 2 10 exec @pkglibexecdir@/indicator-datetime-service indicator-datetime-13.10.0+14.04.20140415.3/NEWS0000644000015301777760000000141012323330715020653 0ustar pbusernogroup0000000000000012.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 indicator-datetime-13.10.0+14.04.20140415.3/INSTALL0000644000015301777760000000351112323330715021211 0ustar pbusernogroup00000000000000# # 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 indicator-datetime-13.10.0+14.04.20140415.3/po/0000755000015301777760000000000012323331375020601 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/po/ko.po0000644000015301777760000000247112323330715021553 0ustar pbusernogroup00000000000000# Korean translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Korean\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "시간 가져오기 오류" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "오전 %d%d:%d%d" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "오후 %d%d:%d%d" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "일정 열기" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "시간 및 날짜 설정..." indicator-datetime-13.10.0+14.04.20140415.3/po/zh_CN.po0000644000015301777760000000242412323330715022141 0ustar pbusernogroup00000000000000# Chinese translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Chinese (simplified)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "获取时间出错" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d 上午" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d 下午" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "打开日历" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "设置时间和日期..." indicator-datetime-13.10.0+14.04.20140415.3/po/it.po0000644000015301777760000000250012323330715021547 0ustar pbusernogroup00000000000000# Italian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Italian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Errore nell'acquisizione dell'orario" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Apri calendario" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Imposta data e ora..." indicator-datetime-13.10.0+14.04.20140415.3/po/es.po0000644000015301777760000000246712323330715021556 0ustar pbusernogroup00000000000000# Spanish translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Spanish\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Error al obtener la hora" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Abrir calendario" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Ajustar fecha y hora..." indicator-datetime-13.10.0+14.04.20140415.3/po/bg.po0000644000015301777760000000253512323330715021533 0ustar pbusernogroup00000000000000# Bulgarian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:05-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Bulgarian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Грешка при проверка на време" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d преди обяд" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d следобед" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Отвори календар" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Свери час и дата..." indicator-datetime-13.10.0+14.04.20140415.3/po/ro.po0000644000015301777760000000255712323330715021567 0ustar pbusernogroup00000000000000# Romanian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Romanian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " "20)) ? 1 : 2;\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Eroare la obținerea orei" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Deschide calendarul" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Setare oră și dată..." indicator-datetime-13.10.0+14.04.20140415.3/po/sr.po0000644000015301777760000000261312323330715021564 0ustar pbusernogroup00000000000000# Serbian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Serbian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" "10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Greška u prikazu vremena" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d%d%d pre podne" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d%d%d popodne" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Otvori kalendar" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Podesi vreme i datum" indicator-datetime-13.10.0+14.04.20140415.3/po/sv.po0000644000015301777760000000247512323330715021576 0ustar pbusernogroup00000000000000# Swedish translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Swedish\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Ett fel uppstod då tid hämtades" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d FM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d EM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Öppna kalender" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Ange tid och datum..." indicator-datetime-13.10.0+14.04.20140415.3/po/ja.po0000644000015301777760000000251412323330715021532 0ustar pbusernogroup00000000000000# Japanese translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "時刻を取得できません" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "午前 %d%d:%d%d" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "午後 %d%d:%d%d" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "カレンダーを開く" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "時刻と日付の設定..." indicator-datetime-13.10.0+14.04.20140415.3/po/nl.po0000644000015301777760000000246212323330715021553 0ustar pbusernogroup00000000000000# Dutch translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Dutch\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Fout bij lezen van tijd" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d%d%d VM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d%d%d NM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Kalender openen" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Datum en tijd instellen..." indicator-datetime-13.10.0+14.04.20140415.3/po/tr.po0000644000015301777760000000250312323330715021563 0ustar pbusernogroup00000000000000# Turkish translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Turkish\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Saati alma hatâsı" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "Öğleden Önce %d%d:%d%d" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "Öğleden Sonra %d%d:%d%d" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Takvimi Aç" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Saati ve Târihi Ayarla..." indicator-datetime-13.10.0+14.04.20140415.3/po/hr.po0000644000015301777760000000261512323330715021553 0ustar pbusernogroup00000000000000# Croatian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Croatian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" "10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Greška pri dohvaćanju vremena" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Otvori kalendar" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Postavi vrijeme i datum..." indicator-datetime-13.10.0+14.04.20140415.3/po/pl.po0000644000015301777760000000260112323330715021550 0ustar pbusernogroup00000000000000# Polish translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Polish\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Wystąpił błąd pobierania godziny" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Otwórz kalendarz" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Ustaw godzinę i datę..." indicator-datetime-13.10.0+14.04.20140415.3/po/de.po0000644000015301777760000000247712323330715021540 0ustar pbusernogroup00000000000000# German translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: German\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Fehler beim Abrufen der Zeit" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Kalender öffnen" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Datum und Uhrzeit einstellen." indicator-datetime-13.10.0+14.04.20140415.3/po/da.po0000644000015301777760000000250112323330715021520 0ustar pbusernogroup00000000000000# Danish translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Danish\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Fejl ved hentning af klokkeslæt" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d.%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d.%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Åbn Kalender" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Indstil klokkeslæt og dato..." indicator-datetime-13.10.0+14.04.20140415.3/po/sl.po0000644000015301777760000000260012323330715021552 0ustar pbusernogroup00000000000000# Slovenian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Slovenian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" "%100==4 ? 2 : 3);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Napaka pri pridobivanju podatka o času" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Odpri koledar" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Nastavi čas in datum ..." indicator-datetime-13.10.0+14.04.20140415.3/po/zh_TW.po0000644000015301777760000000243612323330715022176 0ustar pbusernogroup00000000000000# Chinese translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Chinese (traditional)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "獲得時間發生錯誤" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d 上午" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d 下午" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "開啟行事曆" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "設定時間和日期..." indicator-datetime-13.10.0+14.04.20140415.3/po/nb.po0000644000015301777760000000252412323330715021540 0ustar pbusernogroup00000000000000# Norwegian Bokmal translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Norwegian Bokmal\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Feil under henting av klokkeslett" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Åpne kalender" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Angi dato og klokkeslett..." indicator-datetime-13.10.0+14.04.20140415.3/po/LINGUAS0000644000015301777760000000014612323330715021624 0ustar pbusernogroup00000000000000ar bg cs da de el es fi fr he hi hr hu it ja ko nb nl pl pt pt_BR ro ru sk sl sr sv th tr zh_CN zh_TW indicator-datetime-13.10.0+14.04.20140415.3/po/cs.po0000644000015301777760000000252512323330715021547 0ustar pbusernogroup00000000000000# Czech translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Czech\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Chyba získání času" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d dop." #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d odp." #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Otevřít kalendář" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Nastavit čas a datum..." indicator-datetime-13.10.0+14.04.20140415.3/po/ar.po0000644000015301777760000000252112323330715021540 0ustar pbusernogroup00000000000000# Arabic translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:05-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Arabic\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "خطأ في الحصول على الوقت" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d صباحا" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d مساء" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "التقويم المفتوح (Open Calendar)" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "ضبط الوقت والتاريخ..." indicator-datetime-13.10.0+14.04.20140415.3/po/CMakeLists.txt0000644000015301777760000000020112323330715023327 0ustar pbusernogroup00000000000000include (Translations) add_translations_directory ("${GETTEXT_PACKAGE}") add_translations_catalog ("${GETTEXT_PACKAGE}" ../src/) indicator-datetime-13.10.0+14.04.20140415.3/po/fi.po0000644000015301777760000000250612323330715021537 0ustar pbusernogroup00000000000000# Finnish translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Finnish\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Virheen noudettaessa aikaa" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AP" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d IP" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Avaa kalenteri" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Aseta kellonaika ja päivämäärä..." indicator-datetime-13.10.0+14.04.20140415.3/po/POTFILES.in0000644000015301777760000000012212323330715022346 0ustar pbusernogroup00000000000000src/formatter.cpp src/formatter-desktop.cpp src/menu.cpp src/snap.cpp src/utils.c indicator-datetime-13.10.0+14.04.20140415.3/po/sk.po0000644000015301777760000000252012323330715021552 0ustar pbusernogroup00000000000000# Slovak translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Slovak\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Čas zistenia chyby" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Otvoriť kalendár" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Nastaviť čas a dátum..." indicator-datetime-13.10.0+14.04.20140415.3/po/pt_BR.po0000644000015301777760000000250212323330715022143 0ustar pbusernogroup00000000000000# Portuguese translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Brazilian Portuguese\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Erro ao obter hora" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Abrir o calendário" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Ajustar data e hora..." indicator-datetime-13.10.0+14.04.20140415.3/po/Makevars0000644000015301777760000000036212323330715022273 0ustar pbusernogroup00000000000000DOMAIN = $(PACKAGE) subdir = po top_builddir = .. XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=T_ --from-code=UTF-8 COPYRIGHT_HOLDER = Canonical Ltd. MSGID_BUGS_ADDRESS = ted@canonical.com EXTRA_LOCALE_CATEGORIES = indicator-datetime-13.10.0+14.04.20140415.3/po/pt.po0000644000015301777760000000250112323330715021557 0ustar pbusernogroup00000000000000# Portuguese translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Portuguese\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Erro na obtenção das horas" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Abrir Calendário" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Acertar Hora e Data..." indicator-datetime-13.10.0+14.04.20140415.3/po/fr.po0000644000015301777760000000251312323330715021546 0ustar pbusernogroup00000000000000# French translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: French\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Erreur lors de l'obtention de l'heure" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Ouvrir le calendrier" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Régler la date et l'heure..." indicator-datetime-13.10.0+14.04.20140415.3/po/el.po0000644000015301777760000000262012323330715021536 0ustar pbusernogroup00000000000000# Greek translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Greek\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Σφάλμα κατά τη λήψη του χρόνου" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d π.μ." #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d μ.μ." #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Άνοιγμα ημερολογίου" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Ορισμός ώρας και ημερομηνίας..." indicator-datetime-13.10.0+14.04.20140415.3/po/hi.po0000644000015301777760000000263012323330715021537 0ustar pbusernogroup00000000000000# Hindi translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Hindi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "समय प्राप्त करने में त्रुटि" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "प्रातः %d%d:%d%d बजे" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "सायं %d%d:%d%d बजे" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "कैलेंडर खोलें" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "समय और तिथि सेट करें..." indicator-datetime-13.10.0+14.04.20140415.3/po/hu.po0000644000015301777760000000251312323330715021553 0ustar pbusernogroup00000000000000# Hungarian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Hungarian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Hiba az idő lekérésekor" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d de." #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d du." #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Naptár megnyitása" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Idő és dátum beállítása..." indicator-datetime-13.10.0+14.04.20140415.3/po/ru.po0000644000015301777760000000270212323330715021565 0ustar pbusernogroup00000000000000# Russian translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Russian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" "10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "Ошибка получения времени" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "Открыть календарь" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "Установить время и дату..." indicator-datetime-13.10.0+14.04.20140415.3/po/th.po0000644000015301777760000000254212323330715021554 0ustar pbusernogroup00000000000000# Thai translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Thai\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "ข้อผิดพลาดการขอข้อมูลเวลา" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "เปิดปฏิทิน" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "ตั้งเวลาและวันที่..." indicator-datetime-13.10.0+14.04.20140415.3/po/he.po0000644000015301777760000000251112323330715021531 0ustar pbusernogroup00000000000000# Hebrew translations for PACKAGE package. # Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Canonical OEM, 2010. # msgid "" msgstr "" "Project-Id-Version: indicator-datetime\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-03-10 15:20-0500\n" "PO-Revision-Date: 2010-03-03 10:06-0500\n" "Last-Translator: Canonical OEM\n" "Language-Team: Hebrew\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../src/indicator-datetime.c:177 msgid "Error getting time" msgstr "שגיאה בקבלת השעה" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:259 #, c-format msgid "%d%d:%d%d AM" msgstr "%d%d:%d%d AM" #. TRANSLATORS: This string is used for measuring the size of #. the font used for showing the time and is not shown to the #. user anywhere. #: ../src/indicator-datetime.c:266 #, c-format msgid "%d%d:%d%d PM" msgstr "%d%d:%d%d PM" #: ../src/indicator-datetime.c:351 msgid "Open Calendar" msgstr "פתח לוח שנה" #: ../src/indicator-datetime.c:361 msgid "Set Time and Date..." msgstr "הגדרת שעה ותאריך..." indicator-datetime-13.10.0+14.04.20140415.3/ChangeLog0000644000015301777760000000003112323330715021724 0ustar pbusernogroup00000000000000# Generated by Makefile indicator-datetime-13.10.0+14.04.20140415.3/CMakeLists.txt0000644000015301777760000000547612323330715022734 0ustar pbusernogroup00000000000000project (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}") option (enable_tests "Build the package's automatic tests." ON) option (enable_lcov "Generate lcov code coverage reports." ON) ## ## 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 (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 libcanberra>=0.12 libnotify>=0.7.6 url-dispatcher-1>=1 properties-cpp>=0.0.1) 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 (clean-coverage COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f) 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) # testing & coverage if (${enable_tests}) pkg_check_modules (DBUSTEST REQUIRED dbustest-1>=14.04.0) set (GTEST_SOURCE_DIR /usr/src/gtest/src) set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..) set (GTEST_LIBS -lpthread) enable_testing () if (${enable_lcov}) include(GCov) endif () endif () # actually build things add_subdirectory(include) add_subdirectory(src) add_subdirectory(data) add_subdirectory(po) if (${enable_tests}) add_subdirectory(tests) endif () indicator-datetime-13.10.0+14.04.20140415.3/MERGE-REVIEW0000644000015301777760000000142012323330715021736 0ustar pbusernogroup00000000000000 This documents the expections that the project has on what both submitters and reviewers should ensure that they've done for a merge into the project. == Submitter Responsibilities == * Ensure the project compiles and the test suite executes without error * Ensure that non-obvious code has comments explaining it * If the change works on specific profiles, please include those in the merge description. == Reviewer Responsibilities == * Did the Jenkins build compile? Pass? Run unit tests successfully? * Are there appropriate tests to cover any new functionality? * If the description says this effects the phone profile: * Run tests indicator-datetime/unity8* * If the description says this effects the desktop profile: * Run tests indicator-datetime/unity7* indicator-datetime-13.10.0+14.04.20140415.3/COPYING0000644000015301777760000010451312323330715021217 0ustar pbusernogroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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 . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . indicator-datetime-13.10.0+14.04.20140415.3/src/0000755000015301777760000000000012323331375020752 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/src/timezones-live.cpp0000644000015301777760000000376712323330715024442 0ustar pbusernogroup00000000000000/* * 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 */ #include #include namespace unity { namespace indicator { namespace datetime { LiveTimezones::LiveTimezones(const std::shared_ptr& settings, const std::string& filename): m_file(filename), m_settings(settings) { m_file.timezone.changed().connect([this](const std::string&){update_timezones();}); m_settings->show_detected_location.changed().connect([this](bool){update_geolocation();}); update_geolocation(); update_timezones(); } void LiveTimezones::update_geolocation() { // clear the previous pointer, if any m_geo.reset(); // if location detection is enabled, turn on GeoClue if(m_settings->show_detected_location.get()) { auto geo = new GeoclueTimezone(); geo->timezone.changed().connect([this](const std::string&){update_timezones();}); m_geo.reset(geo); } } void LiveTimezones::update_timezones() { const auto a = m_file.timezone.get(); const auto b = m_geo ? m_geo->timezone.get() : ""; timezone.set(a.empty() ? b : a); std::set zones; if (!a.empty()) zones.insert(a); if (!b.empty()) zones.insert(b); timezones.set(zones); } } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/formatter.cpp0000644000015301777760000001655712323330715023474 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include // T_() #include #include #include // setlocale() #include // nl_langinfo() #include // strstr() namespace unity { namespace indicator { namespace datetime { /*** **** ***/ namespace { void clear_timer(guint& tag) { if (tag) { g_source_remove(tag); tag = 0; } } gint calculate_milliseconds_until_next_second(const DateTime& now) { gint interval_usec; guint interval_msec; interval_usec = G_USEC_PER_SEC - g_date_time_get_microsecond(now.get()); interval_msec = (interval_usec + 999) / 1000; return interval_msec; } /* * We periodically rebuild the sections that have time format strings * that are dependent on the current time: * * 1. appointment menuitems' time format strings depend on the * current time; for example, they don't show the day of week * if the appointment is today. * * 2. location menuitems' time format strings depend on the * current time; for example, they don't show the day of the week * if the local date and location date are the same. * * 3. the "local date" menuitem in the calendar section is, * obviously, dependent on the local time. * * In short, we want to update whenever the number of days between two zone * might have changed. We do that by updating when either zone's day changes. * * Since not all UTC offsets are evenly divisible by hours * (examples: Newfoundland UTC-03:30, Nepal UTC+05:45), refreshing on the hour * is not enough. We need to refresh at HH:00, HH:15, HH:30, and HH:45. */ guint calculate_seconds_until_next_fifteen_minutes(GDateTime * now) { char * str; gint minute; guint seconds; GTimeSpan diff; GDateTime * next; GDateTime * start_of_next; minute = g_date_time_get_minute(now); minute = 15 - (minute % 15); next = g_date_time_add_minutes(now, minute); start_of_next = g_date_time_new_local(g_date_time_get_year(next), g_date_time_get_month(next), g_date_time_get_day_of_month(next), g_date_time_get_hour(next), g_date_time_get_minute(next), 0.1); str = g_date_time_format(start_of_next, "%F %T"); g_debug("%s %s the next timestamp rebuild will be at %s", G_STRLOC, G_STRFUNC, str); g_free(str); diff = g_date_time_difference(start_of_next, now); seconds = (diff + (G_TIME_SPAN_SECOND-1)) / G_TIME_SPAN_SECOND; g_date_time_unref(start_of_next); g_date_time_unref(next); return seconds; } } // unnamed namespace class Formatter::Impl { public: Impl(Formatter* owner, const std::shared_ptr& clock): m_owner(owner), m_clock(clock) { m_owner->header_format.changed().connect([this](const std::string& /*fmt*/){update_header();}); m_clock->minute_changed.connect([this](){update_header();}); update_header(); restartRelativeTimer(); } ~Impl() { clear_timer(m_header_seconds_timer); clear_timer(m_relative_timer); } private: static bool format_shows_seconds(const std::string& fmt) { return (fmt.find("%s") != std::string::npos) || (fmt.find("%S") != std::string::npos) || (fmt.find("%T") != std::string::npos) || (fmt.find("%X") != std::string::npos) || (fmt.find("%c") != std::string::npos); } void update_header() { // update the header property const auto fmt = m_owner->header_format.get(); const auto str = m_clock->localtime().format(fmt); m_owner->header.set(str); // if the header needs to show seconds, set a timer. if (format_shows_seconds(fmt)) start_header_timer(); else clear_timer(m_header_seconds_timer); } // we've got a header format that shows seconds, // so we need to update it every second void start_header_timer() { clear_timer(m_header_seconds_timer); const auto now = m_clock->localtime(); auto interval_msec = calculate_milliseconds_until_next_second(now); interval_msec += 50; // add a small margin to ensure the callback // fires /after/ next is reached m_header_seconds_timer = g_timeout_add_full(G_PRIORITY_HIGH, interval_msec, on_header_timer, this, nullptr); } static gboolean on_header_timer(gpointer gself) { static_cast(gself)->update_header(); return G_SOURCE_REMOVE; } private: void restartRelativeTimer() { clear_timer(m_relative_timer); const auto now = m_clock->localtime(); const auto seconds = calculate_seconds_until_next_fifteen_minutes(now.get()); m_relative_timer = g_timeout_add_seconds(seconds, onRelativeTimer, this); } static gboolean onRelativeTimer(gpointer gself) { auto self = static_cast(gself); self->m_owner->relative_format_changed(); self->restartRelativeTimer(); return G_SOURCE_REMOVE; } private: Formatter* const m_owner; guint m_header_seconds_timer = 0; guint m_relative_timer = 0; public: std::shared_ptr m_clock; }; /*** **** ***/ Formatter::Formatter(const std::shared_ptr& clock): p(new Formatter::Impl(this, clock)) { } Formatter::~Formatter() { } const char* Formatter::default_header_time_format(bool twelvehour, bool show_seconds) { const char* fmt; if (twelvehour && show_seconds) /* TRANSLATORS: a strftime(3) format for 12hr time w/seconds */ fmt = T_("%l:%M:%S %p"); else if (twelvehour) /* TRANSLATORS: a strftime(3) format for 12hr time */ fmt = T_("%l:%M %p"); else if (show_seconds) /* TRANSLATORS: a strftime(3) format for 24hr time w/seconds */ fmt = T_("%H:%M:%S"); else /* TRANSLATORS: a strftime(3) format for 24hr time */ fmt = T_("%H:%M"); return fmt; } /*** **** ***/ std::string Formatter::relative_format(GDateTime* then_begin, GDateTime* then_end) const { auto cstr = generate_full_format_string_at_time (p->m_clock->localtime().get(), then_begin, then_end); const std::string ret = cstr; g_free (cstr); return ret; } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/actions.cpp0000644000015301777760000002223312323330715023115 0ustar pbusernogroup00000000000000/* * 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 */ #include #include // split_settings_location() #include #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ namespace { DateTime datetime_from_timet_variant(GVariant* v) { int64_t t = 0; if (v != nullptr) if (g_variant_type_equal(G_VARIANT_TYPE_INT64,g_variant_get_type(v))) t = g_variant_get_int64(v); if (t != 0) return DateTime(t); else return DateTime::NowLocal(); } bool lookup_appointment_by_uid_variant(const std::shared_ptr& state, GVariant* vuid, Appointment& setme) { g_return_val_if_fail(vuid != nullptr, false); g_return_val_if_fail(g_variant_type_equal(G_VARIANT_TYPE_STRING,g_variant_get_type(vuid)), false); const auto uid = g_variant_get_string(vuid, nullptr); g_return_val_if_fail(uid && *uid, false); for(const auto& appt : state->calendar_upcoming->appointments().get()) { if (appt.uid == uid) { setme = appt; return true; } } return false; } void on_desktop_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself) { auto self = static_cast(gself); Appointment appt; if (lookup_appointment_by_uid_variant(self->state(), vuid, appt)) self->desktop_open_appointment(appt); } void on_desktop_alarm_activated (GSimpleAction*, GVariant*, gpointer gself) { static_cast(gself)->desktop_open_alarm_app(); } void on_desktop_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself) { const auto dt = datetime_from_timet_variant(vt); static_cast(gself)->desktop_open_calendar_app(dt); } void on_desktop_settings_activated (GSimpleAction*, GVariant*, gpointer gself) { static_cast(gself)->desktop_open_settings_app(); } void on_phone_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself) { auto self = static_cast(gself); Appointment appt; if (lookup_appointment_by_uid_variant(self->state(), vuid, appt)) self->phone_open_appointment(appt); } void on_phone_alarm_activated (GSimpleAction*, GVariant*, gpointer gself) { static_cast(gself)->phone_open_alarm_app(); } void on_phone_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself) { const auto dt = datetime_from_timet_variant(vt); static_cast(gself)->phone_open_calendar_app(dt); } void on_phone_settings_activated (GSimpleAction*, GVariant*, gpointer gself) { static_cast(gself)->phone_open_settings_app(); } void on_set_location(GSimpleAction * /*action*/, GVariant * param, gpointer gself) { char * zone; char * name; split_settings_location(g_variant_get_string(param, nullptr), &zone, &name); static_cast(gself)->set_location(zone, name); g_free(name); g_free(zone); } void on_calendar_active_changed(GSimpleAction * /*action*/, GVariant * state, gpointer gself) { // reset the date when the menu is shown if (g_variant_get_boolean(state)) { auto self = static_cast(gself); self->set_calendar_date(self->state()->clock->localtime()); } } void on_calendar_activated(GSimpleAction * /*action*/, GVariant * state, gpointer gself) { const time_t t = g_variant_get_int64(state); g_return_if_fail(t != 0); // the client gave us a date; remove the HMS component from the resulting DateTime auto dt = DateTime(t); dt = dt.add_full (0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds()); static_cast(gself)->set_calendar_date(dt); } GVariant* create_default_header_state() { GVariantBuilder b; g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT); g_variant_builder_add(&b, "{sv}", "accessible-desc", g_variant_new_string("accessible-desc")); g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string("label")); g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string("title")); g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true)); return g_variant_builder_end(&b); } GVariant* create_calendar_state(const std::shared_ptr& state) { gboolean days[32] = { 0 }; for (const auto& appt : state->calendar_month->appointments().get()) days[appt.begin.day_of_month()] = true; GVariantBuilder day_builder; g_variant_builder_init(&day_builder, G_VARIANT_TYPE("ai")); for (guint i=0; icalendar_month->month().get().to_unix()); g_variant_builder_add(&dict_builder, "{sv}", key, v); key = "show-week-numbers"; v = g_variant_new_boolean(state->settings->show_week_numbers.get()); g_variant_builder_add(&dict_builder, "{sv}", key, v); return g_variant_builder_end(&dict_builder); } } // unnamed namespace /*** **** ***/ Actions::Actions(const std::shared_ptr& state): m_state(state), m_actions(g_simple_action_group_new()) { GActionEntry entries[] = { { "desktop.open-appointment", on_desktop_appointment_activated, "s", nullptr }, { "desktop.open-alarm-app", on_desktop_alarm_activated }, { "desktop.open-calendar-app", on_desktop_calendar_activated, "x", nullptr }, { "desktop.open-settings-app", on_desktop_settings_activated }, { "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 }, { "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed }, { "set-location", on_set_location, "s" } }; g_action_map_add_action_entries(G_ACTION_MAP(m_actions), entries, G_N_ELEMENTS(entries), this); // add the header actions auto gam = G_ACTION_MAP(m_actions); auto v = create_default_header_state(); auto a = g_simple_action_new_stateful("desktop-header", nullptr, v); g_action_map_add_action(gam, G_ACTION(a)); a = g_simple_action_new_stateful("desktop_greeter-header", nullptr, v); g_action_map_add_action(gam, G_ACTION(a)); a = g_simple_action_new_stateful("phone-header", nullptr, v); g_action_map_add_action(gam, G_ACTION(a)); a = g_simple_action_new_stateful("phone_greeter-header", nullptr, v); g_action_map_add_action(gam, G_ACTION(a)); // add the calendar action v = create_calendar_state(state); a = g_simple_action_new_stateful("calendar", G_VARIANT_TYPE_INT64, v); g_action_map_add_action(gam, G_ACTION(a)); g_signal_connect(a, "activate", G_CALLBACK(on_calendar_activated), this); /// /// Keep our GActionGroup's action's states in sync with m_state /// m_state->calendar_month->month().changed().connect([this](const DateTime&){ update_calendar_state(); }); m_state->calendar_month->appointments().changed().connect([this](const std::vector&){ update_calendar_state(); }); m_state->settings->show_week_numbers.changed().connect([this](bool){ update_calendar_state(); }); // FIXME: rebuild the calendar state when show-week-number changes } Actions::~Actions() { g_clear_object(&m_actions); } void Actions::update_calendar_state() { g_action_group_change_action_state(action_group(), "calendar", create_calendar_state(m_state)); } void Actions::set_calendar_date(const DateTime& date) { m_state->calendar_month->month().set(date); m_state->calendar_upcoming->date().set(date); } GActionGroup* Actions::action_group() { return G_ACTION_GROUP(m_actions); } const std::shared_ptr Actions::state() const { return m_state; } } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/snap.cpp0000644000015301777760000002005312323330715022414 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include #include #include #include #include #include #include #define ALARM_SOUND_FILENAME "/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg" namespace unity { namespace indicator { namespace datetime { /*** **** ***/ namespace { /** *** libcanberra -- play sounds **/ // arbitrary number, but we need a consistent id for play/cancel const int32_t alarm_ca_id = 1; gboolean media_cached = FALSE; ca_context *c_context = nullptr; guint timeout_tag = 0; ca_context* get_ca_context() { if (G_UNLIKELY(c_context == nullptr)) { int rv; if ((rv = ca_context_create(&c_context)) != CA_SUCCESS) { g_warning("Failed to create canberra context: %s\n", ca_strerror(rv)); c_context = nullptr; } else { const char* filename = ALARM_SOUND_FILENAME; rv = ca_context_cache(c_context, CA_PROP_EVENT_ID, "alarm", CA_PROP_MEDIA_FILENAME, filename, CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", NULL); media_cached = rv == CA_SUCCESS; if (rv != CA_SUCCESS) g_warning("Couldn't add '%s' to canberra cache: %s", filename, ca_strerror(rv)); } } return c_context; } void play_alarm_sound(); gboolean play_alarm_sound_idle (gpointer) { timeout_tag = 0; play_alarm_sound(); return G_SOURCE_REMOVE; } void on_alarm_play_done (ca_context* /*context*/, uint32_t /*id*/, int rv, void* /*user_data*/) { // wait one second, then play it again if ((rv == CA_SUCCESS) && (timeout_tag == 0)) timeout_tag = g_timeout_add_seconds (1, play_alarm_sound_idle, nullptr); } void play_alarm_sound() { const gchar* filename = ALARM_SOUND_FILENAME; auto context = get_ca_context(); g_return_if_fail(context != nullptr); ca_proplist* props = nullptr; ca_proplist_create(&props); if (media_cached) ca_proplist_sets(props, CA_PROP_EVENT_ID, "alarm"); ca_proplist_sets(props, CA_PROP_MEDIA_FILENAME, filename); const auto rv = ca_context_play_full(context, alarm_ca_id, props, on_alarm_play_done, nullptr); if (rv != CA_SUCCESS) g_warning("Failed to play file '%s': %s", filename, ca_strerror(rv)); g_clear_pointer(&props, ca_proplist_destroy); } void stop_alarm_sound() { auto context = get_ca_context(); if (context != nullptr) { const auto rv = ca_context_cancel(context, alarm_ca_id); if (rv != CA_SUCCESS) g_warning("Failed to cancel alarm sound: %s", ca_strerror(rv)); } if (timeout_tag != 0) { g_source_remove(timeout_tag); timeout_tag = 0; } } /** *** libnotify -- snap decisions **/ void first_time_init() { static bool inited = false; if (G_UNLIKELY(!inited)) { inited = true; if(!notify_init("indicator-datetime-service")) g_critical("libnotify initialization failed"); } } struct SnapData { Snap::appointment_func show; Snap::appointment_func dismiss; Appointment appointment; }; void on_snap_show(NotifyNotification*, gchar* /*action*/, gpointer gdata) { stop_alarm_sound(); auto data = static_cast(gdata); data->show(data->appointment); } void on_snap_dismiss(NotifyNotification*, gchar* /*action*/, gpointer gdata) { stop_alarm_sound(); auto data = static_cast(gdata); data->dismiss(data->appointment); } void on_snap_closed(NotifyNotification*, gpointer) { stop_alarm_sound(); } void snap_data_destroy_notify(gpointer gdata) { delete static_cast(gdata); } std::set get_server_caps() { std::set caps_set; auto caps_gl = notify_get_server_caps(); std::string caps_str; for(auto l=caps_gl; l!=nullptr; l=l->next) { caps_set.insert((const char*)l->data); caps_str += (const char*) l->data;; if (l->next != nullptr) caps_str += ", "; } g_debug ("%s notify_get_server() returned [%s]", G_STRFUNC, caps_str.c_str()); g_list_free_full(caps_gl, g_free); return caps_set; } typedef enum { // just a bubble... no actions, no audio NOTIFY_MODE_BUBBLE, // a snap decision popup dialog + audio NOTIFY_MODE_SNAP } NotifyMode; NotifyMode get_notify_mode() { static NotifyMode mode; static bool mode_inited = false; if (G_UNLIKELY(!mode_inited)) { const auto caps = get_server_caps(); if (caps.count("actions")) mode = NOTIFY_MODE_SNAP; else mode = NOTIFY_MODE_BUBBLE; mode_inited = true; } return mode; } bool show_notification (SnapData* data, NotifyMode mode) { const Appointment& appointment = data->appointment; const auto timestr = appointment.begin.format("%a, %X"); auto title = g_strdup_printf(_("Alarm %s"), timestr.c_str()); const auto body = appointment.summary; const gchar* icon_name = "alarm-clock"; auto nn = notify_notification_new(title, body.c_str(), icon_name); if (mode == NOTIFY_MODE_SNAP) { notify_notification_set_hint_string(nn, "x-canonical-snap-decisions", "true"); notify_notification_set_hint_string(nn, "x-canonical-private-button-tint", "true"); /* text for the alarm popup dialog's button to show the active alarm */ notify_notification_add_action(nn, "show", _("Show"), on_snap_show, data, nullptr); /* text for the alarm popup dialog's button to shut up the alarm */ notify_notification_add_action(nn, "dismiss", _("Dismiss"), on_snap_dismiss, data, nullptr); g_signal_connect(G_OBJECT(nn), "closed", G_CALLBACK(on_snap_closed), data); } g_object_set_data_full(G_OBJECT(nn), "snap-data", data, snap_data_destroy_notify); bool shown = true; GError * error = nullptr; notify_notification_show(nn, &error); if (error != NULL) { g_critical("Unable to show snap decision for '%s': %s", body.c_str(), error->message); g_error_free(error); data->show(data->appointment); shown = false; } g_free(title); return shown; } /** *** **/ void notify(const Appointment& appointment, Snap::appointment_func show, Snap::appointment_func dismiss) { auto data = new SnapData; data->appointment = appointment; data->show = show; data->dismiss = dismiss; switch (get_notify_mode()) { case NOTIFY_MODE_BUBBLE: show_notification(data, NOTIFY_MODE_BUBBLE); break; default: if (show_notification(data, NOTIFY_MODE_SNAP)) play_alarm_sound(); break; } } } // unnamed namespace /*** **** ***/ Snap::Snap() { first_time_init(); } Snap::~Snap() { media_cached = false; g_clear_pointer(&c_context, ca_context_destroy); } void Snap::operator()(const Appointment& appointment, appointment_func show, appointment_func dismiss) { if (appointment.has_alarms) notify(appointment, show, dismiss); else dismiss(appointment); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/appointment.cpp0000644000015301777760000000226312323330727024017 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /**** ***** ****/ bool Appointment::operator==(const Appointment& that) const { return (color==that.color) && (summary==that.summary) && (url==that.url) && (uid==that.uid) && (has_alarms==that.has_alarms) && (begin==that.begin) && (end==that.end); } /**** ***** ****/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/clock-live.cpp0000644000015301777760000000765212323330715023515 0ustar pbusernogroup00000000000000/* * 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 */ #include #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ namespace { void clearTimer(guint& tag) { if (tag) { g_source_remove(tag); tag = 0; } } guint calculate_milliseconds_until_next_minute(const DateTime& now) { auto next = g_date_time_add_minutes(now.get(), 1); auto start_of_next = g_date_time_add_seconds (next, -g_date_time_get_seconds(next)); const auto interval_usec = g_date_time_difference(start_of_next, now.get()); const guint interval_msec = (interval_usec + 999) / 1000; g_date_time_unref(start_of_next); g_date_time_unref(next); g_assert (interval_msec <= 60000); return interval_msec; } } // unnamed namespace class LiveClock::Impl { public: Impl(LiveClock& owner, const std::shared_ptr& tzd): m_owner(owner), m_timezones(tzd) { if (m_timezones) { m_timezones->timezone.changed().connect([this](const std::string& z) {setTimezone(z);}); setTimezone(m_timezones->timezone.get()); } restart_minute_timer(); } ~Impl() { clearTimer(m_timer); g_clear_pointer(&m_timezone, g_time_zone_unref); } DateTime localtime() const { g_assert(m_timezone != nullptr); auto gdt = g_date_time_new_now(m_timezone); DateTime ret(gdt); g_date_time_unref(gdt); return ret; } private: void setTimezone(const std::string& str) { g_clear_pointer(&m_timezone, g_time_zone_unref); m_timezone = g_time_zone_new(str.c_str()); m_owner.minute_changed(); } /*** **** ***/ void restart_minute_timer() { clearTimer(m_timer); // maybe emit change signals const auto now = localtime(); if (!DateTime::is_same_minute(m_prev_datetime, now)) m_owner.minute_changed(); if (!DateTime::is_same_day(m_prev_datetime, now)) m_owner.date_changed(); // queue up a timer to fire at the next minute m_prev_datetime = now; auto interval_msec = calculate_milliseconds_until_next_minute(now); interval_msec += 50; // add a small margin to ensure the callback // fires /after/ next is reached m_timer = g_timeout_add_full(G_PRIORITY_HIGH, interval_msec, on_minute_timer_reached, this, nullptr); } static gboolean on_minute_timer_reached(gpointer gself) { static_cast(gself)->restart_minute_timer(); return G_SOURCE_REMOVE; } protected: LiveClock& m_owner; GTimeZone* m_timezone = nullptr; std::shared_ptr m_timezones; DateTime m_prev_datetime; unsigned int m_timer = 0; }; LiveClock::LiveClock(const std::shared_ptr& tzd): p(new Impl(*this, tzd)) { } LiveClock::~LiveClock() =default; DateTime LiveClock::localtime() const { return p->localtime(); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/exporter.cpp0000644000015301777760000000727612323330715023337 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ Exporter::~Exporter() { if (m_dbus_connection != nullptr) { for(auto& id : m_exported_menu_ids) g_dbus_connection_unexport_menu_model(m_dbus_connection, id); if (m_exported_actions_id) g_dbus_connection_unexport_action_group(m_dbus_connection, m_exported_actions_id); } if (m_own_id) g_bus_unown_name(m_own_id); g_clear_object(&m_dbus_connection); } /*** **** ***/ void Exporter::on_bus_acquired(GDBusConnection* connection, const gchar* name, gpointer gthis) { g_debug("bus acquired: %s", name); static_cast(gthis)->on_bus_acquired(connection, name); } void Exporter::on_bus_acquired(GDBusConnection* connection, const gchar* /*name*/) { m_dbus_connection = static_cast(g_object_ref(G_OBJECT(connection))); // export the actions GError * error = nullptr; const auto id = g_dbus_connection_export_action_group(m_dbus_connection, BUS_PATH, m_actions->action_group(), &error); if (id) { m_exported_actions_id = id; } else { g_warning("cannot export action group: %s", error->message); g_clear_error(&error); } // export the menus for(auto& menu : m_menus) { const auto path = std::string(BUS_PATH) + "/" + menu->name(); const auto id = g_dbus_connection_export_menu_model(m_dbus_connection, path.c_str(), menu->menu_model(), &error); if (id) { m_exported_menu_ids.insert(id); } else { if (error != nullptr) g_warning("cannot export %s menu: %s", menu->name().c_str(), error->message); g_clear_error(&error); } } } /*** **** ***/ void Exporter::on_name_lost(GDBusConnection* connection, const gchar* name, gpointer gthis) { g_debug("name lost: %s", name); static_cast(gthis)->on_name_lost(connection, name); } void Exporter::on_name_lost(GDBusConnection* /*connection*/, const gchar* /*name*/) { name_lost(); } /*** **** ***/ void Exporter::publish(const std::shared_ptr& actions, const std::vector>& menus) { m_actions = actions; m_menus = menus; m_own_id = g_bus_own_name(G_BUS_TYPE_SESSION, BUS_NAME, G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, on_bus_acquired, nullptr, on_name_lost, this, nullptr); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/settings-live.cpp0000644000015301777760000001647612323330715024266 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ LiveSettings::~LiveSettings() { g_clear_object(&m_settings); } LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)) { g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed), this); // init the Properties from the GSettings backend update_custom_time_format(); update_locations(); update_show_calendar(); update_show_clock(); update_show_date(); update_show_day(); update_show_detected_locations(); update_show_events(); update_show_locations(); update_show_seconds(); update_show_week_numbers(); update_show_year(); update_time_format_mode(); update_timezone_name(); // now listen for clients to change the properties s.t. we can sync update GSettings custom_time_format.changed().connect([this](const std::string& value){ g_settings_set_string(m_settings, SETTINGS_CUSTOM_TIME_FORMAT_S, value.c_str()); }); locations.changed().connect([this](const std::vector& value){ const int n = value.size(); gchar** strv = g_new0(gchar*, n+1); for(int i=0; i(value[i].c_str()); g_settings_set_strv(m_settings, SETTINGS_LOCATIONS_S, strv); g_free(strv); }); show_calendar.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_CALENDAR_S, value); }); show_clock.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_CLOCK_S, value); }); show_date.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_DATE_S, value); }); show_day.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_DAY_S, value); }); show_detected_location.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_DETECTED_S, value); }); show_events.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_EVENTS_S, value); }); show_locations.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_LOCATIONS_S, value); }); show_seconds.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_SECONDS_S, value); }); show_week_numbers.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_WEEK_NUMBERS_S, value); }); show_year.changed().connect([this](bool value){ g_settings_set_boolean(m_settings, SETTINGS_SHOW_YEAR_S, value); }); time_format_mode.changed().connect([this](TimeFormatMode value){ g_settings_set_enum(m_settings, SETTINGS_TIME_FORMAT_S, gint(value)); }); timezone_name.changed().connect([this](const std::string& value){ g_settings_set_string(m_settings, SETTINGS_TIMEZONE_NAME_S, value.c_str()); }); } /*** **** ***/ void LiveSettings::update_custom_time_format() { auto val = g_settings_get_string(m_settings, SETTINGS_CUSTOM_TIME_FORMAT_S); custom_time_format.set(val); g_free(val); } void LiveSettings::update_locations() { auto strv = g_settings_get_strv(m_settings, SETTINGS_LOCATIONS_S); std::vector l; for(int i=0; strv && strv[i]; i++) l.push_back(strv[i]); g_strfreev(strv); locations.set(l); } void LiveSettings::update_show_calendar() { const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_CALENDAR_S); show_calendar.set(val); } void LiveSettings::update_show_clock() { show_clock.set(g_settings_get_boolean(m_settings, SETTINGS_SHOW_CLOCK_S)); } void LiveSettings::update_show_date() { show_date.set(g_settings_get_boolean(m_settings, SETTINGS_SHOW_DATE_S)); } void LiveSettings::update_show_day() { show_day.set(g_settings_get_boolean(m_settings, SETTINGS_SHOW_DAY_S)); } void LiveSettings::update_show_detected_locations() { const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_DETECTED_S); show_detected_location.set(val); } void LiveSettings::update_show_events() { const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_EVENTS_S); show_events.set(val); } void LiveSettings::update_show_locations() { const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_LOCATIONS_S); show_locations.set(val); } void LiveSettings::update_show_seconds() { show_seconds.set(g_settings_get_boolean(m_settings, SETTINGS_SHOW_SECONDS_S)); } void LiveSettings::update_show_week_numbers() { const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_WEEK_NUMBERS_S); show_week_numbers.set(val); } void LiveSettings::update_show_year() { show_year.set(g_settings_get_boolean(m_settings, SETTINGS_SHOW_YEAR_S)); } void LiveSettings::update_time_format_mode() { time_format_mode.set((TimeFormatMode)g_settings_get_enum(m_settings, SETTINGS_TIME_FORMAT_S)); } void LiveSettings::update_timezone_name() { auto val = g_settings_get_string(m_settings, SETTINGS_TIMEZONE_NAME_S); timezone_name.set(val); g_free(val); } /*** **** ***/ void LiveSettings::on_changed(GSettings* /*settings*/, gchar* key, gpointer gself) { static_cast(gself)->update_key(key); } void LiveSettings::update_key(const std::string& key) { if (key == SETTINGS_SHOW_CLOCK_S) update_show_clock(); else if (key == SETTINGS_LOCATIONS_S) update_locations(); else if (key == SETTINGS_TIME_FORMAT_S) update_time_format_mode(); else if (key == SETTINGS_SHOW_SECONDS_S) update_show_seconds(); else if (key == SETTINGS_SHOW_DAY_S) update_show_day(); else if (key == SETTINGS_SHOW_DATE_S) update_show_date(); else if (key == SETTINGS_SHOW_YEAR_S) update_show_year(); else if (key == SETTINGS_CUSTOM_TIME_FORMAT_S) update_custom_time_format(); else if (key == SETTINGS_SHOW_CALENDAR_S) update_show_calendar(); else if (key == SETTINGS_SHOW_WEEK_NUMBERS_S) update_show_week_numbers(); else if (key == SETTINGS_SHOW_EVENTS_S) update_show_events(); else if (key == SETTINGS_SHOW_LOCATIONS_S) update_show_locations(); else if (key == SETTINGS_SHOW_DETECTED_S) update_show_detected_locations(); else if (key == SETTINGS_TIMEZONE_NAME_S) update_timezone_name(); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/clock-watcher.cpp0000644000015301777760000000437312323330715024210 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ ClockWatcherImpl::ClockWatcherImpl(const std::shared_ptr& clock, const std::shared_ptr& upcoming_planner): m_clock(clock), m_upcoming_planner(upcoming_planner) { m_clock->date_changed.connect([this](){ const auto now = m_clock->localtime(); g_debug("ClockWatcher %p refretching appointments due to date change: %s", this, now.format("%F %T").c_str()); m_upcoming_planner->date().set(now); }); m_clock->minute_changed.connect([this](){ g_debug("ClockWatcher %p calling pulse() due to clock minute_changed", this); pulse(); }); m_upcoming_planner->appointments().changed().connect([this](const std::vector&){ g_debug("ClockWatcher %p calling pulse() due to appointments changed", this); pulse(); }); pulse(); } core::Signal& ClockWatcherImpl::alarm_reached() { return m_alarm_reached; } void ClockWatcherImpl::pulse() { const auto now = m_clock->localtime(); for(const auto& appointment : m_upcoming_planner->appointments().get()) { if (m_triggered.count(appointment.uid)) continue; if (!DateTime::is_same_minute(now, appointment.begin)) continue; m_triggered.insert(appointment.uid); m_alarm_reached(appointment); } } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/locations-settings.cpp0000644000015301777760000000552012323330715025306 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include #include #include // std::find() namespace unity { namespace indicator { namespace datetime { SettingsLocations::SettingsLocations(const std::shared_ptr& settings, const std::shared_ptr& timezones): m_settings(settings), m_timezones(timezones) { m_settings->locations.changed().connect([this](const std::vector&){reload();}); m_settings->show_locations.changed().connect([this](bool){reload();}); m_timezones->timezone.changed().connect([this](const std::string&){reload();}); m_timezones->timezones.changed().connect([this](const std::set&){reload();}); reload(); } void SettingsLocations::reload() { std::vector v; const std::string timezone_name = m_settings->timezone_name.get(); // add the primary timezone first auto zone = m_timezones->timezone.get(); if (!zone.empty()) { gchar * name = get_beautified_timezone_name(zone.c_str(), timezone_name.c_str()); Location l(zone, name); v.push_back(l); g_free(name); } // add the other detected timezones for(const auto& zone : m_timezones->timezones.get()) { gchar * name = get_beautified_timezone_name(zone.c_str(), timezone_name.c_str()); Location l(zone, name); if (std::find(v.begin(), v.end(), l) == v.end()) v.push_back(l); g_free(name); } // maybe add the user-specified locations if (m_settings->show_locations.get()) { for(const auto& locstr : m_settings->locations.get()) { gchar* zone; gchar* name; split_settings_location(locstr.c_str(), &zone, &name); Location loc(zone, name); if (std::find(v.begin(), v.end(), loc) == v.end()) v.push_back(loc); g_free(name); g_free(zone); } } locations.set(v); } } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/actions-live.cpp0000644000015301777760000001472412323330715024060 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ LiveActions::LiveActions(const std::shared_ptr& state_in): Actions(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)) { g_warning("Unable to start \"%s\": %s", cmd, error->message); g_error_free(error); } } void LiveActions::dispatch_url(const std::string& url) { g_debug("Dispatching url '%s'", url.c_str()); url_dispatch_send(url.c_str(), nullptr, nullptr); } /*** **** ***/ void LiveActions::desktop_open_settings_app() { auto path = g_find_program_in_path("unity-control-center"); if ((path != nullptr) && (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)) { execute_command("unity-control-center datetime"); } else { execute_command("gnome-control-center datetime"); } g_free (path); } bool LiveActions::desktop_has_calendar_app() const { static bool inited = false; static bool have_calendar = false; if (G_UNLIKELY(!inited)) { inited = true; #if 0 auto all = g_app_info_get_all_for_type ("text/calendar"); for(auto l=all; !have_calendar && l!=nullptr; l=l->next) { auto app_info = static_cast(l->data); if (!g_strcmp0("evolution.desktop", g_app_info_get_id(app_info))) have_calendar = true; } g_list_free_full(all, (GDestroyNotify)g_object_unref); #else /* Work around http://pad.lv/1296233 for Trusty... let's revert this when the GIO bug is fixed. */ auto executable = g_find_program_in_path("evolution"); have_calendar = executable != nullptr; g_free(executable); #endif } return have_calendar; } void LiveActions::desktop_open_alarm_app() { execute_command("evolution -c calendar"); } void LiveActions::desktop_open_appointment(const Appointment& appt) { desktop_open_calendar_app(appt.begin); } void LiveActions::desktop_open_calendar_app(const DateTime& dt) { const auto day_begins = dt.add_full(0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds()); const auto gmt = day_begins.to_timezone("UTC"); auto cmd = gmt.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) { if (!appt.url.empty()) dispatch_url(appt.url); else if (appt.has_alarms) phone_open_alarm_app(); else phone_open_calendar_app(DateTime::NowLocal()); } void LiveActions::phone_open_calendar_app(const DateTime&) { // does calendar app have a mechanism for specifying dates? dispatch_url("appid://com.ubuntu.calendar/calendar/current-user-version"); } void LiveActions::phone_open_settings_app() { dispatch_url("settings:///system/time-date"); } /*** **** ***/ namespace { struct setlocation_data { std::string tzid; std::string name; std::shared_ptr settings; }; static void on_datetime1_set_timezone_response(GObject * object, GAsyncResult * res, gpointer gdata) { GError* err = nullptr; auto response = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &err); auto data = static_cast(gdata); if (err != nullptr) { if (!g_error_matches(err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("Could not set new timezone: %s", err->message); g_error_free(err); } else { data->settings->timezone_name.set(data->tzid + " " + data->name); g_variant_unref(response); } delete data; } static void on_datetime1_proxy_ready (GObject * object G_GNUC_UNUSED, GAsyncResult * res, gpointer gdata) { auto data = static_cast(gdata); GError * err = nullptr; auto proxy = g_dbus_proxy_new_for_bus_finish(res, &err); if (err != nullptr) { if (!g_error_matches(err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("Could not grab DBus proxy for timedated: %s", err->message); g_error_free(err); delete data; } else { g_dbus_proxy_call(proxy, "SetTimezone", g_variant_new ("(sb)", data->tzid.c_str(), TRUE), G_DBUS_CALL_FLAGS_NONE, -1, nullptr, on_datetime1_set_timezone_response, data); g_object_unref (proxy); } } } // unnamed namespace void LiveActions::set_location(const std::string& tzid, const std::string& name) { g_return_if_fail(!tzid.empty()); g_return_if_fail(!name.empty()); auto data = new struct setlocation_data; data->tzid = tzid; data->name = name; data->settings = state()->settings; g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, nullptr, "org.freedesktop.timedate1", "/org/freedesktop/timedate1", "org.freedesktop.timedate1", nullptr, on_datetime1_proxy_ready, data); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/clock.cpp0000644000015301777760000000511712323330715022552 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ Clock::Clock(): m_cancellable(g_cancellable_new()) { g_bus_get(G_BUS_TYPE_SYSTEM, m_cancellable, on_system_bus_ready, this); } Clock::~Clock() { g_cancellable_cancel(m_cancellable); g_clear_object(&m_cancellable); if (m_sleep_subscription_id) g_dbus_connection_signal_unsubscribe(m_system_bus, m_sleep_subscription_id); g_clear_object(&m_system_bus); } void Clock::on_system_bus_ready(GObject*, GAsyncResult * res, gpointer gself) { GDBusConnection * system_bus; if ((system_bus = g_bus_get_finish(res, nullptr))) { auto self = static_cast(gself); self->m_system_bus = system_bus; self->m_sleep_subscription_id = g_dbus_connection_signal_subscribe( system_bus, nullptr, "org.freedesktop.login1.Manager", // interface "PrepareForSleep", // signal name "/org/freedesktop/login1", // object path nullptr, // arg0 G_DBUS_SIGNAL_FLAGS_NONE, on_prepare_for_sleep, self, nullptr); } } void Clock::on_prepare_for_sleep(GDBusConnection* /*connection*/, const gchar* /*sender_name*/, const gchar* /*object_path*/, const gchar* /*interface_name*/, const gchar* /*signal_name*/, GVariant* /*parameters*/, gpointer gself) { static_cast(gself)->minute_changed(); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/planner-upcoming.cpp0000644000015301777760000000334312323330715024734 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ UpcomingPlanner::UpcomingPlanner(const std::shared_ptr& range_planner, const DateTime& date_in): m_range_planner(range_planner) { date().changed().connect([this](const DateTime& dt){ // set the range to the upcoming month const auto b = dt.add_full(0, 0, -1, -dt.hour(), -dt.minute(), -dt.seconds()); const auto e = b.add_full(0, 1, 0, 0, 0, 0); g_debug("%p setting date range to [%s..%s]", this, b.format("%F %T").c_str(), e.format("%F %T").c_str()); m_range_planner->range().set(std::pair(b,e)); }); date().set(date_in); } core::Property& UpcomingPlanner::date() { return m_date; } core::Property>& UpcomingPlanner::appointments() { return m_range_planner->appointments(); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/locations.cpp0000644000015301777760000000276412323330715023457 0ustar pbusernogroup00000000000000/* * 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 */ #include #include namespace unity { namespace indicator { namespace datetime { const std::string& Location::zone() const { return m_zone; } const std::string& Location::name() const { return m_name; } bool Location::operator== (const Location& that) const { return (m_name == that.m_name) && (m_zone == that.m_zone) && (m_offset == that.m_offset); } Location::Location(const std::string& zone_, const std::string& name_): m_zone(zone_), m_name(name_) { auto gzone = g_time_zone_new (zone().c_str()); auto gtime = g_date_time_new_now (gzone); m_offset = g_date_time_get_utc_offset (gtime); g_date_time_unref (gtime); g_time_zone_unref (gzone); } } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/date-time.cpp0000644000015301777760000001077312323330715023334 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ DateTime::DateTime(GDateTime* gdt) { reset(gdt); } DateTime& DateTime::operator=(GDateTime* gdt) { reset(gdt); return *this; } DateTime& DateTime::operator=(const DateTime& that) { m_dt = that.m_dt; return *this; } DateTime::DateTime(time_t t) { auto gdt = g_date_time_new_from_unix_local(t); reset(gdt); g_date_time_unref(gdt); } DateTime DateTime::NowLocal() { auto gdt = g_date_time_new_now_local(); DateTime dt(gdt); g_date_time_unref(gdt); return dt; } DateTime DateTime::Local(int year, int month, int day, int hour, int minute, int seconds) { auto gdt = g_date_time_new_local (year, month, day, hour, minute, seconds); DateTime dt(gdt); g_date_time_unref(gdt); return dt; } DateTime DateTime::to_timezone(const std::string& zone) const { auto gtz = g_time_zone_new(zone.c_str()); auto gdt = g_date_time_to_timezone(get(), gtz); DateTime dt(gdt); g_time_zone_unref(gtz); g_date_time_unref(gdt); return dt; } DateTime DateTime::add_full(int years, int months, int days, int hours, int minutes, double seconds) const { auto gdt = g_date_time_add_full(get(), years, months, days, hours, minutes, seconds); DateTime dt(gdt); g_date_time_unref(gdt); return dt; } GDateTime* DateTime::get() const { g_assert(m_dt); return m_dt.get(); } std::string DateTime::format(const std::string& fmt) const { std::string ret; gchar* str = g_date_time_format(get(), fmt.c_str()); if (str) { ret = str; g_free(str); } return ret; } void DateTime::ymd(int& year, int& month, int& day) const { g_date_time_get_ymd(get(), &year, &month, &day); } int DateTime::day_of_month() const { return g_date_time_get_day_of_month(get()); } int DateTime::hour() const { return g_date_time_get_hour(get()); } int DateTime::minute() const { return g_date_time_get_minute(get()); } double DateTime::seconds() const { return g_date_time_get_seconds(get()); } int64_t DateTime::to_unix() const { return g_date_time_to_unix(get()); } void DateTime::reset(GDateTime* in) { if (in) { auto deleter = [](GDateTime* dt){g_date_time_unref(dt);}; m_dt = std::shared_ptr(g_date_time_ref(in), deleter); g_assert(m_dt); } else { m_dt.reset(); } } bool DateTime::operator<(const DateTime& that) const { return g_date_time_compare(get(), that.get()) < 0; } bool DateTime::operator<=(const DateTime& that) const { return g_date_time_compare(get(), that.get()) <= 0; } bool DateTime::operator!=(const DateTime& that) const { // return true if this isn't set, or if it's not equal return (!m_dt) || !(*this == that); } bool DateTime::operator==(const DateTime& that) const { auto dt = get(); auto tdt = that.get(); if (!dt && !tdt) return true; if (!dt || !tdt) return false; return g_date_time_compare(get(), that.get()) == 0; } bool DateTime::is_same_day(const DateTime& a, const DateTime& b) { // it's meaningless to compare uninitialized dates if (!a.m_dt || !b.m_dt) return false; const auto adt = a.get(); const auto bdt = b.get(); return (g_date_time_get_year(adt) == g_date_time_get_year(bdt)) && (g_date_time_get_day_of_year(adt) == g_date_time_get_day_of_year(bdt)); } bool DateTime::is_same_minute(const DateTime& a, const DateTime& b) { if (!is_same_day(a,b)) return false; const auto adt = a.get(); const auto bdt = b.get(); return (g_date_time_get_hour(adt) == g_date_time_get_hour(bdt)) && (g_date_time_get_minute(adt) == g_date_time_get_minute(bdt)); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/main.cpp0000644000015301777760000001050012323330715022373 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * 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 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // bindtextdomain() #include #include #include #include // exit() using namespace unity::indicator::datetime; int main(int /*argc*/, char** /*argv*/) { // Work around a deadlock in glib's type initialization. // It can be removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is fixed. g_type_ensure(G_TYPE_DBUS_CONNECTION); // boilerplate i18n setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain(GETTEXT_PACKAGE); // we don't show appointments in the greeter, // so no need to connect to EDS there... std::shared_ptr engine; if (!g_strcmp0("lightdm", g_get_user_name())) engine.reset(new MockEngine); else engine.reset(new EdsEngine); // build the state, actions, and menufactory std::shared_ptr state(new State); std::shared_ptr live_settings(new LiveSettings); std::shared_ptr live_timezones(new LiveTimezones(live_settings, TIMEZONE_FILE)); std::shared_ptr live_clock(new LiveClock(live_timezones)); std::shared_ptr file_timezone(new FileTimezone(TIMEZONE_FILE)); const auto now = live_clock->localtime(); state->settings = live_settings; state->clock = live_clock; state->locations.reset(new SettingsLocations(live_settings, live_timezones)); auto calendar_month = new MonthPlanner(std::shared_ptr(new SimpleRangePlanner(engine, file_timezone)), now); state->calendar_month.reset(calendar_month); state->calendar_upcoming.reset(new UpcomingPlanner(std::shared_ptr(new SimpleRangePlanner(engine, file_timezone)), now)); std::shared_ptr actions(new LiveActions(state)); MenuFactory factory(actions, state); // snap decisions std::shared_ptr upcoming_planner(new UpcomingPlanner(std::shared_ptr(new SimpleRangePlanner(engine, file_timezone)), now)); ClockWatcherImpl clock_watcher(live_clock, upcoming_planner); Snap snap; clock_watcher.alarm_reached().connect([&snap](const Appointment& appt){ auto snap_show = [](const Appointment& a){ const char* url; if(!a.url.empty()) url = a.url.c_str(); else // alarm doesn't have a URl associated with it; use a fallback url = "appid://com.ubuntu.clock/clock/current-user-version"; url_dispatch_send(url, nullptr, nullptr); }; auto snap_dismiss = [](const Appointment&){}; snap(appt, snap_show, snap_dismiss); }); // create the menus std::vector> menus; for(int i=0, n=Menu::NUM_PROFILES; i * * 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 . */ #include #define GEOCLUE_BUS_NAME "org.freedesktop.Geoclue.Master" namespace unity { namespace indicator { namespace datetime { GeoclueTimezone::GeoclueTimezone(): m_cancellable(g_cancellable_new()) { g_bus_get(G_BUS_TYPE_SESSION, m_cancellable, on_bus_got, this); } GeoclueTimezone::~GeoclueTimezone() { g_cancellable_cancel(m_cancellable); g_object_unref(m_cancellable); if (m_signal_subscription) g_dbus_connection_signal_unsubscribe(m_connection, m_signal_subscription); g_object_unref(m_connection); } /*** **** ***/ void GeoclueTimezone::on_bus_got(GObject* /*source*/, GAsyncResult* res, gpointer gself) { GError * error; GDBusConnection * connection; error = nullptr; connection = g_bus_get_finish(res, &error); if (error) { if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("Couldn't get bus: %s", error->message); g_error_free(error); } else { auto self = static_cast(gself); self->m_connection = connection; g_dbus_connection_call(self->m_connection, GEOCLUE_BUS_NAME, "/org/freedesktop/Geoclue/Master", "org.freedesktop.Geoclue.Master", "Create", nullptr, // parameters G_VARIANT_TYPE("(o)"), G_DBUS_CALL_FLAGS_NONE, -1, self->m_cancellable, on_client_created, self); } } void GeoclueTimezone::on_client_created(GObject * source, GAsyncResult * res, gpointer gself) { GVariant * result; if ((result = call_finish(source, res))) { auto self = static_cast(gself); GVariant * child = g_variant_get_child_value(result, 0); self->m_client_object_path = g_variant_get_string(child, nullptr); g_variant_unref(child); g_variant_unref(result); self->m_signal_subscription = g_dbus_connection_signal_subscribe( self->m_connection, GEOCLUE_BUS_NAME, "org.freedesktop.Geoclue.Address", // inteface "AddressChanged", // signal name self->m_client_object_path.c_str(), // object path nullptr, // arg0 G_DBUS_SIGNAL_FLAGS_NONE, on_address_changed, self, nullptr); g_dbus_connection_call(self->m_connection, GEOCLUE_BUS_NAME, self->m_client_object_path.c_str(), "org.freedesktop.Geoclue.MasterClient", "SetRequirements", g_variant_new("(iibi)", 2, 0, FALSE, 1023), nullptr, G_DBUS_CALL_FLAGS_NONE, -1, self->m_cancellable, on_requirements_set, self); } } void GeoclueTimezone::on_address_changed(GDBusConnection* /*connection*/, const gchar* /*sender_name*/, const gchar* /*object_path*/, const gchar* /*interface_name*/, const gchar* /*signal_name*/, GVariant* parameters, gpointer gself) { static_cast(gself)->setTimezoneFromAddressVariant(parameters); } void GeoclueTimezone::on_requirements_set(GObject* source, GAsyncResult* res, gpointer gself) { GVariant * result; if ((result = call_finish(source, res))) { auto self = static_cast(gself); g_dbus_connection_call(self->m_connection, GEOCLUE_BUS_NAME, self->m_client_object_path.c_str(), "org.freedesktop.Geoclue.MasterClient", "AddressStart", nullptr, nullptr, G_DBUS_CALL_FLAGS_NONE, -1, self->m_cancellable, on_address_started, self); g_variant_unref(result); } } void GeoclueTimezone::on_address_started(GObject * source, GAsyncResult * res, gpointer gself) { GVariant * result; if ((result = call_finish(source, res))) { auto self = static_cast(gself); g_dbus_connection_call(self->m_connection, GEOCLUE_BUS_NAME, self->m_client_object_path.c_str(), "org.freedesktop.Geoclue.Address", "GetAddress", nullptr, G_VARIANT_TYPE("(ia{ss}(idd))"), G_DBUS_CALL_FLAGS_NONE, -1, self->m_cancellable, on_address_got, self); g_variant_unref(result); } } void GeoclueTimezone::on_address_got(GObject * source, GAsyncResult * res, gpointer gself) { GVariant * result; if ((result = call_finish(source, res))) { static_cast(gself)->setTimezoneFromAddressVariant(result); g_variant_unref(result); } } void GeoclueTimezone::setTimezoneFromAddressVariant(GVariant * variant) { g_return_if_fail(g_variant_is_of_type(variant, G_VARIANT_TYPE("(ia{ss}(idd))"))); const gchar * timezone_string = nullptr; GVariant * dict = g_variant_get_child_value(variant, 1); if (dict) { if (g_variant_lookup(dict, "timezone", "&s", &timezone_string)) timezone.set(timezone_string); g_variant_unref(dict); } } GVariant* GeoclueTimezone::call_finish(GObject * source, GAsyncResult * res) { GError * error; GVariant * result; error = nullptr; result = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &error); if (error) { if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("AddressStart() failed: %s", error->message); g_error_free(error); g_clear_pointer(&result, g_variant_unref); } return result; } /**** ***** ****/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/planner-month.cpp0000644000015301777760000000372712323330715024246 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ MonthPlanner::MonthPlanner(const std::shared_ptr& range_planner, const DateTime& month_in): m_range_planner(range_planner) { month().changed().connect([this](const DateTime& m){ auto month_begin = m.add_full(0, // no years 0, // no months -(m.day_of_month()-1), -m.hour(), -m.minute(), -m.seconds()); auto month_end = month_begin.add_full(0, 1, 0, 0, 0, -0.1); g_debug("PlannerMonth %p setting calendar month range: [%s..%s]", this, month_begin.format("%F %T").c_str(), month_end.format("%F %T").c_str()); m_range_planner->range().set(std::pair(month_begin,month_end)); }); month().set(month_in); } core::Property& MonthPlanner::month() { return m_month; } core::Property>& MonthPlanner::appointments() { return m_range_planner->appointments(); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/planner-range.cpp0000644000015301777760000000522012323330715024203 0ustar pbusernogroup00000000000000/* * 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 */ #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ SimpleRangePlanner::SimpleRangePlanner(const std::shared_ptr& engine, const std::shared_ptr& timezone): m_engine(engine), m_timezone(timezone), m_range(std::pair(DateTime::NowLocal(), DateTime::NowLocal())) { engine->changed().connect([this](){ g_debug("RangePlanner %p rebuilding soon because Engine %p emitted 'changed' signal%p", this, m_engine.get()); rebuild_soon(); }); range().changed().connect([this](const std::pair&){ g_debug("rebuilding because the date range changed"); rebuild_soon(); }); } SimpleRangePlanner::~SimpleRangePlanner() { if (m_rebuild_tag) g_source_remove(m_rebuild_tag); } /*** **** ***/ void SimpleRangePlanner::rebuild_now() { const auto& r = range().get(); auto on_appointments_fetched = [this](const std::vector& a){ g_debug("RangePlanner %p got %zu appointments", this, a.size()); appointments().set(a); }; m_engine->get_appointments(r.first, r.second, *m_timezone.get(), on_appointments_fetched); } void SimpleRangePlanner::rebuild_soon() { static const int ARBITRARY_BATCH_MSEC = 200; if (m_rebuild_tag == 0) m_rebuild_tag = g_timeout_add(ARBITRARY_BATCH_MSEC, rebuild_now_static, this); } gboolean SimpleRangePlanner::rebuild_now_static(gpointer gself) { auto self = static_cast(gself); self->m_rebuild_tag = 0; self->rebuild_now(); return G_SOURCE_REMOVE; } /*** **** ***/ core::Property>& SimpleRangePlanner::appointments() { return m_appointments; } core::Property>& SimpleRangePlanner::range() { return m_range; } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/engine-eds.cpp0000644000015301777760000004304712323330727023504 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include #include #include #include // std::sort() #include // time() #include #include namespace unity { namespace indicator { namespace datetime { /**** ***** ****/ class EdsEngine::Impl { public: Impl(EdsEngine& owner): m_owner(owner), m_cancellable(g_cancellable_new()) { e_source_registry_new(m_cancellable, on_source_registry_ready, this); } ~Impl() { g_cancellable_cancel(m_cancellable); g_clear_object(&m_cancellable); while(!m_sources.empty()) remove_source(*m_sources.begin()); if (m_rebuild_tag) g_source_remove(m_rebuild_tag); if (m_source_registry) g_signal_handlers_disconnect_by_data(m_source_registry, this); g_clear_object(&m_source_registry); } core::Signal<>& changed() { return m_changed; } void get_appointments(const DateTime& begin, const DateTime& end, const Timezone& timezone, std::function&)> func) { const auto begin_timet = begin.to_unix(); const auto end_timet = end.to_unix(); const auto b_str = begin.format("%F %T"); const auto e_str = end.format("%F %T"); g_debug("getting all appointments from [%s ... %s]", b_str.c_str(), e_str.c_str()); /** *** init the default timezone **/ icaltimezone * default_timezone = nullptr; const auto tz = timezone.timezone.get().c_str(); if (tz && *tz) { default_timezone = icaltimezone_get_builtin_timezone(tz); if (default_timezone == nullptr) // maybe str is a tzid? default_timezone = icaltimezone_get_builtin_timezone_from_tzid(tz); g_debug("default_timezone is %p", (void*)default_timezone); } /** *** walk through the sources to build the appointment list **/ auto task_deleter = [](Task* task){ // give the caller the (sorted) finished product auto& a = task->appointments; std::sort(a.begin(), a.end(), [](const Appointment& a, const Appointment& b){return a.begin < b.begin;}); task->func(a); // we're done; delete the task g_debug("time to delete task %p", (void*)task); delete task; }; std::shared_ptr main_task(new Task(this, func), task_deleter); for (auto& kv : m_clients) { auto& client = kv.second; if (default_timezone != nullptr) e_cal_client_set_default_timezone(client, default_timezone); // start a new subtask to enumerate all the components in this client. auto& source = kv.first; auto extension = e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR); const auto color = e_source_selectable_get_color(E_SOURCE_SELECTABLE(extension)); g_debug("calling e_cal_client_generate_instances for %p", (void*)client); e_cal_client_generate_instances(client, begin_timet, end_timet, m_cancellable, my_get_appointments_foreach, new AppointmentSubtask (main_task, client, color), [](gpointer g){delete static_cast(g);}); } } private: void set_dirty_now() { m_changed(); } static gboolean set_dirty_now_static (gpointer gself) { auto self = static_cast(gself); self->m_rebuild_tag = 0; self->m_rebuild_deadline = 0; self->set_dirty_now(); return G_SOURCE_REMOVE; } void set_dirty_soon() { static constexpr int MIN_BATCH_SEC = 1; static constexpr int MAX_BATCH_SEC = 60; static_assert(MIN_BATCH_SEC <= MAX_BATCH_SEC, "bad boundaries"); const auto now = time(nullptr); if (m_rebuild_deadline == 0) // first pass { m_rebuild_deadline = now + MAX_BATCH_SEC; m_rebuild_tag = g_timeout_add_seconds(MIN_BATCH_SEC, set_dirty_now_static, this); } else if (now < m_rebuild_deadline) { g_source_remove (m_rebuild_tag); m_rebuild_tag = g_timeout_add_seconds(MIN_BATCH_SEC, set_dirty_now_static, this); } } static void on_source_registry_ready(GObject* /*source*/, GAsyncResult* res, gpointer gself) { GError * error = nullptr; auto r = e_source_registry_new_finish(res, &error); if (error != nullptr) { if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("indicator-datetime cannot show EDS appointments: %s", error->message); g_error_free(error); } else { g_signal_connect(r, "source-added", G_CALLBACK(on_source_added), gself); g_signal_connect(r, "source-removed", G_CALLBACK(on_source_removed), gself); g_signal_connect(r, "source-changed", G_CALLBACK(on_source_changed), gself); g_signal_connect(r, "source-disabled", G_CALLBACK(on_source_disabled), gself); g_signal_connect(r, "source-enabled", G_CALLBACK(on_source_enabled), gself); auto self = static_cast(gself); self->m_source_registry = r; self->add_sources_by_extension(E_SOURCE_EXTENSION_CALENDAR); self->add_sources_by_extension(E_SOURCE_EXTENSION_TASK_LIST); } } void add_sources_by_extension(const char* extension) { auto& r = m_source_registry; auto sources = e_source_registry_list_sources(r, extension); for (auto l=sources; l!=nullptr; l=l->next) on_source_added(r, E_SOURCE(l->data), this); g_list_free_full(sources, g_object_unref); } static void on_source_added(ESourceRegistry* registry, ESource* source, gpointer gself) { auto self = static_cast(gself); self->m_sources.insert(E_SOURCE(g_object_ref(source))); if (e_source_get_enabled(source)) on_source_enabled(registry, source, gself); } static void on_source_enabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) { auto self = static_cast(gself); ECalClientSourceType source_type; bool client_wanted = false; if (e_source_has_extension(source, E_SOURCE_EXTENSION_CALENDAR)) { source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; client_wanted = true; } else if (e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST)) { source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; client_wanted = true; } const auto source_uid = e_source_get_uid(source); if (client_wanted) { g_debug("%s connecting a client to source %s", G_STRFUNC, source_uid); e_cal_client_connect(source, source_type, self->m_cancellable, on_client_connected, gself); } else { g_debug("%s not using source %s -- no tasks/calendar", G_STRFUNC, source_uid); } } static void on_client_connected(GObject* /*source*/, GAsyncResult * res, gpointer gself) { GError * error = nullptr; EClient * client = e_cal_client_connect_finish(res, &error); if (error) { if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("indicator-datetime cannot connect to EDS source: %s", error->message); g_error_free(error); } else { // add the client to our collection auto self = static_cast(gself); g_debug("got a client for %s", e_cal_client_get_local_attachment_store(E_CAL_CLIENT(client))); self->m_clients[e_client_get_source(client)] = E_CAL_CLIENT(client); // now create a view for it so that we can listen for changes e_cal_client_get_view (E_CAL_CLIENT(client), "#t", // match all self->m_cancellable, on_client_view_ready, self); g_debug("client connected; calling set_dirty_soon()"); self->set_dirty_soon(); } } static void on_client_view_ready (GObject* client, GAsyncResult* res, gpointer gself) { GError* error = nullptr; ECalClientView* view = nullptr; if (e_cal_client_get_view_finish (E_CAL_CLIENT(client), res, &view, &error)) { // add the view to our collection e_cal_client_view_set_flags(view, E_CAL_CLIENT_VIEW_FLAGS_NONE, NULL); e_cal_client_view_start(view, &error); g_debug("got a view for %s", e_cal_client_get_local_attachment_store(E_CAL_CLIENT(client))); auto self = static_cast(gself); self->m_views[e_client_get_source(E_CLIENT(client))] = view; g_signal_connect(view, "objects-added", G_CALLBACK(on_view_objects_added), self); g_signal_connect(view, "objects-modified", G_CALLBACK(on_view_objects_modified), self); g_signal_connect(view, "objects-removed", G_CALLBACK(on_view_objects_removed), self); g_debug("view connected; calling set_dirty_soon()"); self->set_dirty_soon(); } else if(error != nullptr) { if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning("indicator-datetime cannot get View to EDS client: %s", error->message); g_error_free(error); } } static void on_view_objects_added(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) { g_debug("%s", G_STRFUNC); static_cast(gself)->set_dirty_soon(); } static void on_view_objects_modified(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) { g_debug("%s", G_STRFUNC); static_cast(gself)->set_dirty_soon(); } static void on_view_objects_removed(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) { g_debug("%s", G_STRFUNC); static_cast(gself)->set_dirty_soon(); } static void on_source_disabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) { static_cast(gself)->disable_source(source); } void disable_source(ESource* source) { // if an ECalClientView is associated with this source, remove it auto vit = m_views.find(source); if (vit != m_views.end()) { auto& view = vit->second; e_cal_client_view_stop(view, nullptr); const auto n_disconnected = g_signal_handlers_disconnect_by_data(view, this); g_warn_if_fail(n_disconnected == 3); g_object_unref(view); m_views.erase(vit); set_dirty_soon(); } // if an ECalClient is associated with this source, remove it auto cit = m_clients.find(source); if (cit != m_clients.end()) { auto& client = cit->second; g_object_unref(client); m_clients.erase(cit); set_dirty_soon(); } } static void on_source_removed(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) { static_cast(gself)->remove_source(source); } void remove_source(ESource* source) { disable_source(source); auto sit = m_sources.find(source); if (sit != m_sources.end()) { g_object_unref(*sit); m_sources.erase(sit); set_dirty_soon(); } } static void on_source_changed(ESourceRegistry* /*registry*/, ESource* /*source*/, gpointer gself) { g_debug("source changed; calling set_dirty_soon()"); static_cast(gself)->set_dirty_soon(); } private: typedef std::function&)> appointment_func; struct Task { Impl* p; appointment_func func; std::vector appointments; Task(Impl* p_in, const appointment_func& func_in): p(p_in), func(func_in) {} }; struct AppointmentSubtask { std::shared_ptr task; ECalClient* client; std::string color; AppointmentSubtask(const std::shared_ptr& task_in, ECalClient* client_in, const char* color_in): task(task_in), client(client_in) { if (color_in) color = color_in; } }; static gboolean my_get_appointments_foreach(ECalComponent* component, time_t begin, time_t end, gpointer gsubtask) { const auto vtype = e_cal_component_get_vtype(component); auto subtask = static_cast(gsubtask); if ((vtype == E_CAL_COMPONENT_EVENT) || (vtype == E_CAL_COMPONENT_TODO)) { const gchar* uid = nullptr; e_cal_component_get_uid(component, &uid); auto status = ICAL_STATUS_NONE; e_cal_component_get_status(component, &status); if ((uid != nullptr) && (status != ICAL_STATUS_COMPLETED) && (status != ICAL_STATUS_CANCELLED)) { Appointment appointment; ECalComponentText text; text.value = nullptr; e_cal_component_get_summary(component, &text); if (text.value) appointment.summary = text.value; appointment.begin = DateTime(begin); appointment.end = DateTime(end); appointment.color = subtask->color; appointment.uid = uid; // if the component has display alarms that have a url, // use the first one as our Appointment.url auto alarm_uids = e_cal_component_get_alarm_uids(component); appointment.has_alarms = alarm_uids != nullptr; for(auto walk=alarm_uids; appointment.url.empty() && walk!=nullptr; walk=walk->next) { auto alarm = e_cal_component_get_alarm(component, static_cast(walk->data)); ECalComponentAlarmAction action; e_cal_component_alarm_get_action(alarm, &action); if (action == E_CAL_COMPONENT_ALARM_DISPLAY) { icalattach* attach = nullptr; e_cal_component_alarm_get_attach(alarm, &attach); if (attach != nullptr) { if (icalattach_get_is_url (attach)) { const char* url = icalattach_get_url(attach); if (url != nullptr) appointment.url = url; } icalattach_unref(attach); } } e_cal_component_alarm_free(alarm); } cal_obj_uid_list_free(alarm_uids); g_debug("adding appointment '%s' '%s'", appointment.summary.c_str(), appointment.url.c_str()); subtask->task->appointments.push_back(appointment); } } return G_SOURCE_CONTINUE; } EdsEngine& m_owner; core::Signal<> m_changed; std::set m_sources; std::map m_clients; std::map m_views; GCancellable* m_cancellable = nullptr; ESourceRegistry* m_source_registry = nullptr; guint m_rebuild_tag = 0; time_t m_rebuild_deadline = 0; }; /*** **** ***/ EdsEngine::EdsEngine(): p(new Impl(*this)) { } EdsEngine::~EdsEngine() =default; core::Signal<>& EdsEngine::changed() { return p->changed(); } void EdsEngine::get_appointments(const DateTime& begin, const DateTime& end, const Timezone& tz, std::function&)> func) { p->get_appointments(begin, end, tz, func); } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/timezone-file.cpp0000644000015301777760000000531312323330715024224 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include namespace unity { namespace indicator { namespace datetime { FileTimezone::FileTimezone() { } FileTimezone::FileTimezone(const std::string& filename) { set_filename(filename); } FileTimezone::~FileTimezone() { clear(); } void FileTimezone::clear() { if (m_monitor_handler_id) g_signal_handler_disconnect(m_monitor, m_monitor_handler_id); g_clear_object (&m_monitor); m_filename.clear(); } void FileTimezone::set_filename(const std::string& filename) { clear(); auto tmp = realpath(filename.c_str(), nullptr); if(tmp != nullptr) { m_filename = tmp; free(tmp); } else { g_warning("Unable to resolve path '%s': %s", filename.c_str(), g_strerror(errno)); m_filename = filename; // better than nothing? } auto file = g_file_new_for_path(m_filename.c_str()); GError * err = nullptr; m_monitor = g_file_monitor_file(file, G_FILE_MONITOR_NONE, nullptr, &err); g_object_unref(file); if (err) { g_warning("%s Unable to monitor timezone file '%s': %s", G_STRLOC, TIMEZONE_FILE, err->message); g_error_free(err); } else { m_monitor_handler_id = g_signal_connect_swapped(m_monitor, "changed", G_CALLBACK(on_file_changed), this); g_debug("%s Monitoring timezone file '%s'", G_STRLOC, m_filename.c_str()); } reload(); } void FileTimezone::on_file_changed(gpointer gself) { static_cast(gself)->reload(); } void FileTimezone::reload() { GError * err = nullptr; gchar * str = nullptr; if (!g_file_get_contents(m_filename.c_str(), &str, nullptr, &err)) { g_warning("%s Unable to read timezone file '%s': %s", G_STRLOC, m_filename.c_str(), err->message); g_error_free(err); } else { g_strstrip(str); timezone.set(str); g_free(str); } } } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/menu.cpp0000644000015301777760000005003312323330715022420 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include #include #include #include namespace unity { namespace indicator { namespace datetime { /**** ***** ****/ Menu::Menu (Profile profile_in, const std::string& name_in): m_profile(profile_in), m_name(name_in) { } const std::string& Menu::name() const { return m_name; } Menu::Profile Menu::profile() const { return m_profile; } GMenuModel* Menu::menu_model() { return G_MENU_MODEL(m_menu); } /**** ***** ****/ #define ALARM_ICON_NAME "alarm-clock" #define CALENDAR_ICON_NAME "calendar" class MenuImpl: public Menu { protected: MenuImpl(const Menu::Profile profile_in, const std::string& name_in, std::shared_ptr& state, std::shared_ptr& actions, std::shared_ptr formatter): Menu(profile_in, name_in), m_state(state), m_actions(actions), m_formatter(formatter) { // initialize the menu create_gmenu(); for (int i=0; iheader.changed().connect([this](const std::string&){ update_header(); }); m_formatter->header_format.changed().connect([this](const std::string&){ update_section(Locations); // need to update x-canonical-time-format }); m_formatter->relative_format_changed.connect([this](){ update_section(Appointments); // uses formatter.relative_format() update_section(Locations); // uses formatter.relative_format() }); m_state->settings->show_clock.changed().connect([this](bool){ update_header(); // update header's label update_section(Locations); // locations' relative time may have changed }); m_state->settings->show_calendar.changed().connect([this](bool){ update_section(Calendar); }); m_state->settings->show_events.changed().connect([this](bool){ update_section(Appointments); // showing events got toggled }); m_state->calendar_upcoming->date().changed().connect([this](const DateTime&){ update_upcoming(); // our m_upcoming is planner->upcoming() filtered by time }); m_state->calendar_upcoming->appointments().changed().connect([this](const std::vector&){ update_upcoming(); // our m_upcoming is planner->upcoming() filtered by time }); m_state->clock->date_changed.connect([this](){ update_section(Calendar); // need to update the Date menuitem update_section(Locations); // locations' relative time may have changed }); m_state->clock->minute_changed.connect([this](){ update_upcoming(); // our m_upcoming is planner->upcoming() filtered by time }); m_state->locations->locations.changed().connect([this](const std::vector&) { update_section(Locations); // "locations" is the list of Locations we show }); } virtual ~MenuImpl() { g_clear_object(&m_menu); g_clear_pointer(&m_serialized_alarm_icon, g_variant_unref); g_clear_pointer(&m_serialized_calendar_icon, g_variant_unref); } virtual GVariant* create_header_state() =0; void update_header() { auto action_group = m_actions->action_group(); auto action_name = name() + "-header"; auto state = create_header_state(); g_action_group_change_action_state(action_group, action_name.c_str(), state); } void update_upcoming() { // The usual case is on desktop (and /only/ case on phone) // is that we're looking at the current date and want to see // "the next five calendar events, if any." // // However on the Desktop when the user clicks onto a different // calendar date, show the next five calendar events starting // from the beginning of that clicked day. DateTime begin; const auto now = m_state->clock->localtime(); const auto calendar_day = m_state->calendar_month->month().get(); if ((profile() == Desktop) && !DateTime::is_same_day(now, calendar_day)) begin = calendar_day.add_full (0, 0, 0, -calendar_day.hour(), -calendar_day.minute(), -calendar_day.seconds()); else begin = now.add_full (0, 0, 0, 0, 0, -now.seconds()); std::vector upcoming; for(const auto& a : m_state->calendar_upcoming->appointments().get()) if (begin <= a.begin) upcoming.push_back(a); if (m_upcoming != upcoming) { m_upcoming.swap(upcoming); update_header(); // show an 'alarm' icon if there are upcoming alarms update_section(Appointments); // "upcoming" is the list of Appointments we show } } std::shared_ptr m_state; std::shared_ptr m_actions; std::shared_ptr m_formatter; GMenu* m_submenu = nullptr; GVariant* get_serialized_alarm_icon() { if (G_UNLIKELY(m_serialized_alarm_icon == nullptr)) { auto i = g_themed_icon_new_with_default_fallbacks(ALARM_ICON_NAME); m_serialized_alarm_icon = g_icon_serialize(i); g_object_unref(i); } return m_serialized_alarm_icon; } std::vector m_upcoming; private: GVariant* get_serialized_calendar_icon() { if (G_UNLIKELY(m_serialized_calendar_icon == nullptr)) { auto i = g_themed_icon_new_with_default_fallbacks(CALENDAR_ICON_NAME); m_serialized_calendar_icon = g_icon_serialize(i); g_object_unref(i); } return m_serialized_calendar_icon; } void create_gmenu() { g_assert(m_submenu == nullptr); m_submenu = g_menu_new(); // build placeholders for the sections for(int i=0; isettings->show_calendar.get() && ((profile == Desktop) || (profile == DesktopGreeter)); auto menu = g_menu_new(); const char * action_name; if (profile == Phone) action_name = "indicator.phone.open-calendar-app"; else if (profile == Desktop) action_name = "indicator.desktop.open-calendar-app"; else action_name = nullptr; /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! Format string for the day on the first menuitem in the datetime indicator. This format string gives the full weekday, date, month, and year. en_US example: "%A, %B %e %Y" --> Saturday, October 31 2020" en_GB example: "%A, %e %B %Y" --> Saturday, 31 October 2020" */ auto label = m_state->clock->localtime().format(_("%A, %e %B %Y")); auto item = g_menu_item_new (label.c_str(), nullptr); auto v = get_serialized_calendar_icon(); g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_ICON, v); if (action_name != nullptr) { v = g_variant_new_int64(0); g_menu_item_set_action_and_target_value (item, action_name, v); } g_menu_append_item(menu, item); g_object_unref(item); // add calendar if (show_calendar) { item = g_menu_item_new ("[calendar]", nullptr); v = g_variant_new_int64(0); g_menu_item_set_action_and_target_value (item, "indicator.calendar", v); g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.calendar"); if (action_name != nullptr) g_menu_item_set_attribute (item, "activation-action", "s", action_name); g_menu_append_item (menu, item); g_object_unref (item); } return G_MENU_MODEL(menu); } void add_appointments(GMenu* menu, Profile profile) { const int MAX_APPTS = 5; std::set added; const char * action_name; if (profile == Phone) action_name = "indicator.phone.open-appointment"; else if ((profile == Desktop) && m_actions->desktop_has_calendar_app()) action_name = "indicator.desktop.open-appointment"; else action_name = nullptr; for (const auto& appt : m_upcoming) { // don't show duplicates if (added.count(appt.uid)) continue; // don't show too many if (g_menu_model_get_n_items (G_MENU_MODEL(menu)) >= MAX_APPTS) break; added.insert(appt.uid); GDateTime* begin = appt.begin(); GDateTime* end = appt.end(); auto fmt = m_formatter->relative_format(begin, end); auto unix_time = g_date_time_to_unix(begin); auto menu_item = g_menu_item_new (appt.summary.c_str(), nullptr); g_menu_item_set_attribute (menu_item, "x-canonical-time", "x", unix_time); g_menu_item_set_attribute (menu_item, "x-canonical-time-format", "s", fmt.c_str()); if (appt.has_alarms) { g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.alarm"); g_menu_item_set_attribute_value(menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon()); } else { g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.appointment"); } if (!appt.color.empty()) g_menu_item_set_attribute (menu_item, "x-canonical-color", "s", appt.color.c_str()); if (action_name != nullptr) g_menu_item_set_action_and_target_value (menu_item, action_name, g_variant_new_string (appt.uid.c_str())); g_menu_append_item (menu, menu_item); g_object_unref (menu_item); } } GMenuModel* create_appointments_section(Profile profile) { auto menu = g_menu_new(); if ((profile==Desktop) && m_state->settings->show_events.get()) { add_appointments (menu, profile); if (m_actions->desktop_has_calendar_app()) { // add the 'Add Event…' menuitem auto menu_item = g_menu_item_new(_("Add Event…"), nullptr); const gchar* action_name = "indicator.desktop.open-calendar-app"; auto v = g_variant_new_int64(0); g_menu_item_set_action_and_target_value(menu_item, action_name, v); g_menu_append_item(menu, menu_item); g_object_unref(menu_item); } } else if (profile==Phone) { auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app"); g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon()); g_menu_append_item (menu, menu_item); g_object_unref (menu_item); add_appointments (menu, profile); } return G_MENU_MODEL(menu); } GMenuModel* create_locations_section(Profile profile) { GMenu* menu = g_menu_new(); if (profile == Desktop) { const auto now = m_state->clock->localtime(); for(const auto& location : m_state->locations->locations.get()) { const auto& zone = location.zone(); const auto& name = location.name(); const auto zone_now = now.to_timezone(zone); const auto fmt = m_formatter->relative_format(zone_now.get()); auto detailed_action = g_strdup_printf("indicator.set-location::%s %s", zone.c_str(), name.c_str()); auto i = g_menu_item_new (name.c_str(), detailed_action); g_menu_item_set_attribute(i, "x-canonical-type", "s", "com.canonical.indicator.location"); g_menu_item_set_attribute(i, "x-canonical-timezone", "s", zone.c_str()); g_menu_item_set_attribute(i, "x-canonical-time-format", "s", fmt.c_str()); g_menu_append_item (menu, i); g_object_unref(i); g_free(detailed_action); } } return G_MENU_MODEL(menu); } GMenuModel* create_settings_section(Profile profile) { auto menu = g_menu_new(); const char * action_name; if (profile == Desktop) action_name = "indicator.desktop.open-settings-app"; else if (profile == Phone) action_name = "indicator.phone.open-settings-app"; else action_name = nullptr; if (action_name != nullptr) g_menu_append (menu, _("Time & Date settings…"), action_name); return G_MENU_MODEL (menu); } void update_section(Section section) { GMenuModel * model; const auto p = profile(); switch (section) { case Calendar: model = create_calendar_section(p); break; case Appointments: model = create_appointments_section(p); break; case Locations: model = create_locations_section(p); break; case Settings: model = create_settings_section(p); break; default: model = nullptr; g_warn_if_reached(); } if (model) { g_menu_remove(m_submenu, section); g_menu_insert_section(m_submenu, section, nullptr, model); g_object_unref(model); } } //private: GVariant * m_serialized_alarm_icon = nullptr; GVariant * m_serialized_calendar_icon = nullptr; }; // class MenuImpl /*** **** ***/ class DesktopBaseMenu: public MenuImpl { protected: DesktopBaseMenu(Menu::Profile profile_, const std::string& name_, std::shared_ptr& state_, std::shared_ptr& actions_): MenuImpl(profile_, name_, state_, actions_, std::shared_ptr(new DesktopFormatter(state_->clock, state_->settings))) { update_header(); } GVariant* create_header_state() { const auto visible = m_state->settings->show_clock.get(); const auto title = _("Date and Time"); auto label = g_variant_new_string(m_formatter->header.get().c_str()); GVariantBuilder b; g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT); g_variant_builder_add(&b, "{sv}", "accessible-desc", label); g_variant_builder_add(&b, "{sv}", "label", label); g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string(title)); g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(visible)); return g_variant_builder_end(&b); } }; class DesktopMenu: public DesktopBaseMenu { public: DesktopMenu(std::shared_ptr& state_, std::shared_ptr& actions_): DesktopBaseMenu(Desktop,"desktop", state_, actions_) {} }; class DesktopGreeterMenu: public DesktopBaseMenu { public: DesktopGreeterMenu(std::shared_ptr& state_, std::shared_ptr& actions_): DesktopBaseMenu(DesktopGreeter,"desktop_greeter", state_, actions_) {} }; class PhoneBaseMenu: public MenuImpl { protected: PhoneBaseMenu(Menu::Profile profile_, const std::string& name_, std::shared_ptr& state_, std::shared_ptr& actions_): MenuImpl(profile_, name_, state_, actions_, std::shared_ptr(new PhoneFormatter(state_->clock))) { update_header(); } GVariant* create_header_state() { // are there alarms? bool has_alarms = false; for(const auto& appointment : m_upcoming) if((has_alarms = appointment.has_alarms)) break; GVariantBuilder b; g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT); g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string (_("Upcoming"))); g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean (TRUE)); if (has_alarms) { auto label = m_formatter->header.get(); auto a11y = g_strdup_printf(_("%s (has alarms)"), label.c_str()); g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string(label.c_str())); g_variant_builder_add(&b, "{sv}", "accessible-desc", g_variant_new_take_string(a11y)); g_variant_builder_add(&b, "{sv}", "icon", get_serialized_alarm_icon()); } else { auto v = g_variant_new_string(m_formatter->header.get().c_str()); g_variant_builder_add(&b, "{sv}", "label", v); g_variant_builder_add(&b, "{sv}", "accessible-desc", v); } return g_variant_builder_end (&b); } }; class PhoneMenu: public PhoneBaseMenu { public: PhoneMenu(std::shared_ptr& state_, std::shared_ptr& actions_): PhoneBaseMenu(Phone, "phone", state_, actions_) {} }; class PhoneGreeterMenu: public PhoneBaseMenu { public: PhoneGreeterMenu(std::shared_ptr& state_, std::shared_ptr& actions_): PhoneBaseMenu(PhoneGreeter, "phone_greeter", state_, actions_) {} }; /**** ***** ****/ MenuFactory::MenuFactory(const std::shared_ptr& actions_, const std::shared_ptr& state_): m_actions(actions_), m_state(state_) { } std::shared_ptr MenuFactory::buildMenu(Menu::Profile profile) { std::shared_ptr menu; switch (profile) { case Menu::Desktop: menu.reset(new DesktopMenu(m_state, m_actions)); break; case Menu::DesktopGreeter: menu.reset(new DesktopGreeterMenu(m_state, m_actions)); break; case Menu::Phone: menu.reset(new PhoneMenu(m_state, m_actions)); break; case Menu::PhoneGreeter: menu.reset(new PhoneGreeterMenu(m_state, m_actions)); break; default: g_warn_if_reached(); break; } return menu; } /**** ***** ****/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/formatter-desktop.cpp0000644000015301777760000001444112323330715025131 0ustar pbusernogroup00000000000000/* * 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 */ #include #include // T_() namespace unity { namespace indicator { namespace datetime { /*** **** ***/ namespace { std::string joinDateAndTimeFormatStrings(const char* date_string, const char* time_string) { std::string str; if (date_string && time_string) { str = date_string; str += "\u2003"; str += time_string; } else if (date_string) { str = date_string; } else // time_string { str = time_string; } return str; } } // unnamed namespace /*** **** ***/ DesktopFormatter::DesktopFormatter(const std::shared_ptr& clock_in, const std::shared_ptr& settings_in): Formatter(clock_in), m_settings(settings_in) { m_settings->show_day.changed().connect([this](bool){rebuildHeaderFormat();}); m_settings->show_date.changed().connect([this](bool){rebuildHeaderFormat();}); m_settings->show_year.changed().connect([this](bool){rebuildHeaderFormat();}); m_settings->show_seconds.changed().connect([this](bool){rebuildHeaderFormat();}); m_settings->time_format_mode.changed().connect([this](TimeFormatMode){rebuildHeaderFormat();}); m_settings->custom_time_format.changed().connect([this](const std::string&){rebuildHeaderFormat();}); rebuildHeaderFormat(); } void DesktopFormatter::rebuildHeaderFormat() { header_format.set(getHeaderLabelFormatString()); } std::string DesktopFormatter::getHeaderLabelFormatString() const { std::string fmt; const auto mode = m_settings->time_format_mode.get(); if (mode == TIME_FORMAT_MODE_CUSTOM) { fmt = m_settings->custom_time_format.get(); } else { const auto show_day = m_settings->show_day.get(); const auto show_date = m_settings->show_date.get(); const auto show_year = show_date && m_settings->show_year.get(); const auto date_fmt = getDateFormat(show_day, show_date, show_year); const auto time_fmt = getFullTimeFormatString(); fmt = joinDateAndTimeFormatStrings(date_fmt, time_fmt); } return fmt; } const gchar* DesktopFormatter::getFullTimeFormatString() const { const auto show_seconds = m_settings->show_seconds.get(); bool twelvehour; switch (m_settings->time_format_mode.get()) { case TIME_FORMAT_MODE_LOCALE_DEFAULT: twelvehour = is_locale_12h(); break; case TIME_FORMAT_MODE_24_HOUR: twelvehour = false; break; default: twelvehour = true; break; } return default_header_time_format(twelvehour, show_seconds); } const gchar* DesktopFormatter::getDateFormat(bool show_day, bool show_date, bool show_year) const { const char * fmt; if (show_day && show_date && show_year) /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :) This format string shows the abbreviated weekday, day, abbreviated month, and year. en_US example: "%a %b %e %Y" --> "Sat Oct 31 2020" en_GB example: "%a %e %b %Y" --> "Sat 31 Oct 2020" zh_CN example(?): "%Y年%m月%d日 周%a" --> "2020年10月31日 周六" */ fmt = T_("%a %b %e %Y"); else if (show_day && show_date) /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :) This format string shows the abbreviated weekday, day, and abbreviated month. en_US example: "%a %b %e" --> "Sat Oct 31" en_GB example: "%a %e %b" --> "Sat 31 Oct" zh_CN example(?): "%m月%d日 周%a" --> "03月27日 周六" */ fmt = T_("%a %b %e"); else if (show_day) /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :) This format string shows the abbreviated weekday. zh_CN example(?): "周%a" --> "周六" */ fmt = T_("%a"); else if (show_date && show_year) /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :) This format string shows the day, abbreviated month, and year. en_US example: "%b %e %Y" --> "Oct 31 2020" en_GB example: "%e %b %Y" --> "31 Oct 2020" zh_CN example(?): "%Y年%m月%d日" --> "2020年10月31日" */ fmt = T_("%b %e %Y"); else if (show_date) /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :) This format string shows the abbreviated month and day. en_US example: "%b %e" --> "Mar 27" en_GB example: "%e %b" --> "27 Mar" zh_CN example(?): "%m月%d日" --> "03月27日" */ fmt = T_("%b %e"); else if (show_year) /* This strftime(3) format string shows the year. */ fmt = T_("%Y"); else fmt = nullptr; return fmt; } /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity indicator-datetime-13.10.0+14.04.20140415.3/src/utils.c0000644000015301777760000003407712323330715022266 0ustar pbusernogroup00000000000000/* * Copyright 2010, 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: * Michael Terry * Charles Kerr */ #include #include #include #include #include #include #include /* Check the system locale setting to see if the format is 24-hour time or 12-hour time */ gboolean is_locale_12h(void) { int i; static const char *formats_24h[] = {"%H", "%R", "%T", "%OH", "%k", NULL}; const char* t_fmt = nl_langinfo(T_FMT); for (i=0; formats_24h[i]!=NULL; i++) if (strstr(t_fmt, formats_24h[i]) != NULL) return FALSE; return TRUE; } void split_settings_location(const gchar* location, gchar** zone, gchar** name) { gchar* location_dup = g_strdup(location); if(location_dup != NULL) g_strstrip(location_dup); gchar* first = NULL; if(location_dup && (first = strchr(location_dup, ' '))) *first = '\0'; if(zone) *zone = location_dup; if(name != NULL) { gchar* after = first ? g_strstrip(first + 1) : NULL; if(after && *after) { *name = g_strdup(after); } else if (location_dup) // make the name from zone { gchar * chr = strrchr(location_dup, '/'); after = g_strdup(chr ? chr + 1 : location_dup); // replace underscores with spaces for(chr=after; chr && *chr; chr++) if(*chr == '_') *chr = ' '; *name = after; } else { *name = NULL; } } } /** * Our Locations come from two places: (1) direct user input and (2) ones * guessed by the system, such as from geoclue or timedate1. * * Since the latter only have a timezone (eg, "America/Chicago") and the * former have a descriptive name provided by the end user (eg, * "America/Chicago Oklahoma City"), this function tries to make a * more human-readable name by using the user-provided name if the guessed * timezone matches the last one the user manually clicked on. * * In the example above, this allows the menuitem for the system-guessed * timezone ("America/Chicago") to read "Oklahoma City" after the user clicks * on the "Oklahoma City" menuitem. */ gchar* get_beautified_timezone_name(const char* timezone_, const char* saved_location) { gchar* zone; gchar* name; split_settings_location(timezone_, &zone, &name); gchar* saved_zone; gchar* saved_name; split_settings_location(saved_location, &saved_zone, &saved_name); gchar* rv; if (g_strcmp0(zone, saved_zone) == 0) { rv = saved_name; saved_name = NULL; } else { rv = name; name = NULL; } g_free(zone); g_free(name); g_free(saved_zone); g_free(saved_name); return rv; } gchar* get_timezone_name(const gchar* timezone_, GSettings* settings) { gchar* saved_location = g_settings_get_string(settings, SETTINGS_TIMEZONE_NAME_S); gchar* rv = get_beautified_timezone_name(timezone_, saved_location); g_free(saved_location); return rv; } /*** **** ***/ typedef enum { DATE_PROXIMITY_TODAY, DATE_PROXIMITY_TOMORROW, DATE_PROXIMITY_WEEK, DATE_PROXIMITY_FAR } date_proximity_t; static date_proximity_t getDateProximity(GDateTime* now, GDateTime* time) { date_proximity_t prox = DATE_PROXIMITY_FAR; gint now_year, now_month, now_day; gint time_year, time_month, time_day; // did it already happen? if (g_date_time_difference(time, now) < -G_USEC_PER_SEC) return DATE_PROXIMITY_FAR; // does it happen today? g_date_time_get_ymd(now, &now_year, &now_month, &now_day); g_date_time_get_ymd(time, &time_year, &time_month, &time_day); if ((now_year == time_year) && (now_month == time_month) && (now_day == time_day)) prox = DATE_PROXIMITY_TODAY; // does it happen tomorrow? if (prox == DATE_PROXIMITY_FAR) { GDateTime* tomorrow = g_date_time_add_days(now, 1); gint tom_year, tom_month, tom_day; g_date_time_get_ymd(tomorrow, &tom_year, &tom_month, &tom_day); if ((tom_year == time_year) && (tom_month == time_month) && (tom_day == time_day)) prox = DATE_PROXIMITY_TOMORROW; g_date_time_unref(tomorrow); } // does it happen this week? if (prox == DATE_PROXIMITY_FAR) { GDateTime* week = g_date_time_add_days(now, 6); GDateTime* week_bound = g_date_time_new_local(g_date_time_get_year(week), g_date_time_get_month(week), g_date_time_get_day_of_month(week), 23, 59, 59.9); if (g_date_time_compare(time, week_bound) <= 0) prox = DATE_PROXIMITY_WEEK; g_date_time_unref(week_bound); g_date_time_unref(week); } return prox; } const char* T_(const char *msg) { /* General strategy here is to make sure LANGUAGE is empty (since that trumps all LC_* vars) and then to temporarily swap LC_TIME and LC_MESSAGES. Then have gettext translate msg. We strdup the strings because the setlocale & *env functions do not guarantee anything about the storage used for the string, and thus the string may not be portably safe after multiple calls. Note that while you might think g_dcgettext would do the trick here, that actually looks in /usr/share/locale/XX/LC_TIME, not the LC_MESSAGES directory, so we won't find any translation there. */ gchar* message_locale = g_strdup(setlocale(LC_MESSAGES, NULL)); const char* time_locale = setlocale(LC_TIME, NULL); gchar* language = g_strdup(g_getenv("LANGUAGE")); if (language) g_unsetenv("LANGUAGE"); setlocale(LC_MESSAGES, time_locale); /* Get the LC_TIME version */ const char* rv = _(msg); /* Put everything back the way it was */ setlocale(LC_MESSAGES, message_locale); if (language) g_setenv("LANGUAGE", language, TRUE); g_free(message_locale); g_free(language); return rv; } /** * _ a time today should be shown as just the time (e.g. “3:55 PM”) * _ a full-day event today should be shown as “Today” * _ a time any other day this week should be shown as the short version of the * day and time (e.g. “Wed 3:55 PM”) * _ a full-day event tomorrow should be shown as “Tomorrow” * _ a full-day event another day this week should be shown as the * weekday (e.g. “Friday”) * _ a time after this week should be shown as the short version of the day, * date, and time (e.g. “Wed 21 Apr 3:55 PM”) * _ a full-day event after this week should be shown as the short version of * the day and date (e.g. “Wed 21 Apr”). * _ in addition, when presenting the times of upcoming events, the time should * be followed by the timezone if it is different from the one the computer * is currently set to. For example, “Wed 3:55 PM UTC−5”. */ char* generate_full_format_string_at_time (GDateTime* now, GDateTime* then, GDateTime* then_end) { GString* ret = g_string_new (NULL); if (then != NULL) { const gboolean full_day = then_end && (g_date_time_difference(then_end, then) >= G_TIME_SPAN_DAY); const date_proximity_t prox = getDateProximity(now, then); if (full_day) { switch (prox) { case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("Today")); break; case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow")); break; case DATE_PROXIMITY_WEEK: /* This is a strftime(3) format string indicating the unabbreviated weekday. */ g_string_assign (ret, T_("%A")); break; case DATE_PROXIMITY_FAR: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing full-day events that are over a week away. en_US example: "%a %b %d" --> "Sat Oct 31" en_GB example: "%a %d %b" --> "Sat 31 Oct" zh_CN example(?): "%m月%d日 周%a" --> "10月31日 周六" */ g_string_assign (ret, T_("%a %d %b")); break; } } else if (is_locale_12h()) { switch (prox) { case DATE_PROXIMITY_TODAY: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 12-hour clock, events/appointments that happen today. en_US example: "%l:%M %p" --> "1:00 PM" */ g_string_assign (ret, T_("%l:%M %p")); break; case DATE_PROXIMITY_TOMORROW: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 12-hour clock, events/appointments that happen tomorrow. (\u2003 is a unicode em space which is slightly wider than a normal space.) en_US example: "Tomorrow\u2003%l:%M %p" --> "Tomorrow 1:00 PM" */ g_string_assign (ret, T_("Tomorrow\u2003%l:%M %p")); break; case DATE_PROXIMITY_WEEK: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 12-hour clock, events/appointments that happen this week. (\u2003 is a unicode em space which is slightly wider than a normal space.) en_US example: "Tomorrow\u2003%l:%M %p" --> "Fri 1:00 PM" */ g_string_assign (ret, T_("%a\u2003%l:%M %p")); break; case DATE_PROXIMITY_FAR: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 12-hour clock, events/appointments that happen over a week from now. (\u2003 is a unicode em space which is slightly wider than a normal space.) en_US example: "%a %d %b\u2003%l:%M %p" --> "Fri Oct 31 1:00 PM" en_GB example: "%a %b %d\u2003%l:%M %p" --> "Fri 31 Oct 1:00 PM" */ g_string_assign (ret, T_("%a %d %b\u2003%l:%M %p")); break; } } else { switch (prox) { case DATE_PROXIMITY_TODAY: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 24-hour clock, events/appointments that happen today. en_US example: "%H:%M" --> "13:00" */ g_string_assign (ret, T_("%H:%M")); break; case DATE_PROXIMITY_TOMORROW: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 24-hour clock, events/appointments that happen tomorrow. (\u2003 is a unicode em space which is slightly wider than a normal space.) en_US example: "Tomorrow\u2003%l:%M %p" --> "Tomorrow 13:00" */ g_string_assign (ret, T_("Tomorrow\u2003%H:%M")); break; case DATE_PROXIMITY_WEEK: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 24-hour clock, events/appointments that happen this week. (\u2003 is a unicode em space which is slightly wider than a normal space.) en_US example: "%a\u2003%H:%M" --> "Fri 13:00" */ g_string_assign (ret, T_("%a\u2003%H:%M")); break; case DATE_PROXIMITY_FAR: /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale! This format string is used for showing, on a 24-hour clock, events/appointments that happen over a week from now. (\u2003 is a unicode em space which is slightly wider than a normal space.) en_US example: "%a %d %b\u2003%H:%M" --> "Fri Oct 31 13:00" en_GB example: "%a %b %d\u2003%H:%M" --> "Fri 31 Oct 13:00" */ g_string_assign (ret, T_("%a %d %b\u2003%H:%M")); break; } } /* if it's an appointment in a different timezone (and doesn't run for a full day) then the time should be followed by its timezone. */ if ((then_end != NULL) && (!full_day) && ((g_date_time_get_utc_offset(now) != g_date_time_get_utc_offset(then)))) { g_string_append_printf (ret, " %s", g_date_time_get_timezone_abbreviation(then)); } } return g_string_free (ret, FALSE); } indicator-datetime-13.10.0+14.04.20140415.3/include/0000755000015301777760000000000012323331375021606 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/0000755000015301777760000000000012323331375023402 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/planner-range.h0000644000015301777760000000447112323330715026307 0ustar pbusernogroup00000000000000/* * 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_RANGE_H #define INDICATOR_DATETIME_PLANNER_RANGE_H #include #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief A #Planner that contains appointments in a specified date range * * @see Planner */ class RangePlanner: public Planner { public: virtual ~RangePlanner() =default; virtual core::Property>& range() =0; protected: RangePlanner() =default; }; /** * \brief A #RangePlanner that uses an #Engine to generate appointments * * @see Planner */ class SimpleRangePlanner: public RangePlanner { public: SimpleRangePlanner(const std::shared_ptr& engine, const std::shared_ptr& timezone); virtual ~SimpleRangePlanner(); core::Property>& appointments(); core::Property>& range(); private: // rebuild scaffolding void rebuild_soon(); virtual void rebuild_now(); static gboolean rebuild_now_static(gpointer); guint m_rebuild_tag = 0; std::shared_ptr m_engine; std::shared_ptr m_timezone; core::Property> m_range; core::Property> m_appointments; // we've got a GSignal tag here, so disable copying SimpleRangePlanner(const RangePlanner&) =delete; SimpleRangePlanner& operator=(const RangePlanner&) =delete; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_PLANNER_RANGE_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/actions-live.h0000644000015301777760000000356212323330715026153 0ustar pbusernogroup00000000000000/* * 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_LIVE_H #define INDICATOR_DATETIME_ACTIONS_LIVE_H #include namespace unity { namespace indicator { namespace datetime { /** * \brief Production implementation of the Actions interface. * * Delegates URLs, sets the timezone via org.freedesktop.timedate1, etc. * * @see MockActions */ class LiveActions: public Actions { public: LiveActions(const std::shared_ptr& state_in); ~LiveActions() =default; bool desktop_has_calendar_app() const; void desktop_open_alarm_app(); void desktop_open_appointment(const Appointment&); void desktop_open_calendar_app(const DateTime&); void desktop_open_settings_app(); void phone_open_alarm_app(); void phone_open_appointment(const Appointment&); void phone_open_calendar_app(const DateTime&); void phone_open_settings_app(); void set_location(const std::string& zone, const std::string& name); protected: virtual void execute_command(const std::string& command); virtual void dispatch_url(const std::string& url); }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_ACTIONS_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/timezone-geoclue.h0000644000015301777760000000427012323330715027026 0ustar pbusernogroup00000000000000/* * 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 #include #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief A #Timezone that gets its information from asking GeoClue */ class GeoclueTimezone: public Timezone { public: GeoclueTimezone(); ~GeoclueTimezone(); private: static void on_bus_got (GObject*, GAsyncResult*, gpointer); static void on_client_created (GObject*, GAsyncResult*, gpointer); static void on_address_changed (GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer); static void on_requirements_set (GObject*, GAsyncResult*, gpointer); static void on_address_started (GObject*, GAsyncResult*, gpointer); static void on_address_got (GObject*, GAsyncResult*, gpointer); void setTimezoneFromAddressVariant (GVariant*); static GVariant * call_finish (GObject*, GAsyncResult*); GCancellable * m_cancellable = nullptr; GDBusConnection * m_connection = nullptr; std::string m_client_object_path; guint m_signal_subscription = 0; // we've got pointers and gsignal tags 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 indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/locations.h0000644000015301777760000000360212323330715025544 0ustar pbusernogroup00000000000000/* * 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_LOCATIONS_H #define INDICATOR_DATETIME_LOCATIONS_H #include #include #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief A physical place and its timezone; eg, "America/Chicago" + "Oklahoma City" * * @see Locations */ class Location { public: Location (const std::string& zone, const std::string& name); const std::string& zone() const; const std::string& name() const; bool operator== (const Location& that) const; private: /** timezone; eg, "America/Chicago" */ std::string m_zone; /* human-readable location name; eg, "Oklahoma City" */ std::string m_name; /** offset from UTC in microseconds */ int64_t m_offset = 0; }; /** * Container which holds an ordered list of Locations * * @see Location * @see State */ class Locations { public: Locations() =default; virtual ~Locations() =default; /** \brief an ordered list of Location items */ core::Property> locations; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_LOCATIONS_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/clock-mock.h0000644000015301777760000000310312323330715025567 0ustar pbusernogroup00000000000000/* * 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_MOCK_H #define INDICATOR_DATETIME_CLOCK_MOCK_H #include namespace unity { namespace indicator { namespace datetime { /*** **** ***/ /** * \brief A clock that uses a client-provided time instead of the system time. */ class MockClock: public Clock { public: MockClock(const DateTime& dt): m_localtime(dt) {} ~MockClock() =default; DateTime localtime() const { return m_localtime; } void set_localtime(const DateTime& dt) { const auto old = m_localtime; m_localtime = dt; if (!DateTime::is_same_minute(old, m_localtime)) minute_changed(); if (!DateTime::is_same_day(old, m_localtime)) date_changed(); } private: DateTime m_localtime; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_CLOCK_MOCK_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/engine.h0000644000015301777760000000321212323330715025013 0ustar pbusernogroup00000000000000/* * 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__H #define INDICATOR_DATETIME_ENGINE__H #include #include #include #include #include namespace unity { namespace indicator { namespace datetime { /**** ***** ****/ /** * Class wrapper around the backend that generates appointments * * @see EdsEngine * @see EdsPlanner */ class Engine { public: virtual ~Engine() =default; virtual void get_appointments(const DateTime& begin, const DateTime& end, const Timezone& default_timezone, std::function&)> appointment_func) =0; virtual core::Signal<>& changed() =0; protected: Engine() =default; }; /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_ENGINE__H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/snap.h0000644000015301777760000000251412323330715024513 0ustar pbusernogroup00000000000000/* * 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 namespace unity { namespace indicator { namespace datetime { /** * \brief Pops up Snap Decisions for appointments */ class Snap { public: Snap(); virtual ~Snap(); typedef std::function appointment_func; void operator()(const Appointment& appointment, appointment_func show, appointment_func dismiss); }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_SNAP_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/engine-eds.h0000644000015301777760000000347312323330715025575 0ustar pbusernogroup00000000000000/* * 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 wrapper around EDS so multiple #EdsPlanners can share resources * * @see EdsPlanner */ class EdsEngine: public Engine { public: EdsEngine(); ~EdsEngine(); void get_appointments(const DateTime& begin, const DateTime& end, const Timezone& default_timezone, std::function&)> appointment_func); core::Signal<>& changed(); 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 indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/date-time.h0000644000015301777760000000447712323330715025435 0ustar pbusernogroup00000000000000/* * 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 // 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(int years, int months, int days, int hours, int minutes, int seconds); explicit DateTime(time_t t); explicit DateTime(GDateTime* in=nullptr); DateTime& operator=(GDateTime* in); DateTime& operator=(const DateTime& in); DateTime to_timezone(const std::string& zone) const; DateTime add_full(int years, int months, int days, int hours, int minutes, double seconds) const; void reset(GDateTime* in=nullptr); 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; static bool is_same_day(const DateTime& a, const DateTime& b); static bool is_same_minute(const DateTime& a, const DateTime& b); private: std::shared_ptr m_dt; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_DATETIME_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/settings.h0000644000015301777760000000362612323330715025417 0ustar pbusernogroup00000000000000/* * 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; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_SETTINGS_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/planner-month.h0000644000015301777760000000307412323330715026336 0ustar pbusernogroup00000000000000/* * 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_MONTH_H #define INDICATOR_DATETIME_PLANNER_MONTH_H #include #include #include #include // std::shared_ptr namespace unity { namespace indicator { namespace datetime { /** * \brief A #Planner that contains appointments for a specified calendar month */ class MonthPlanner: public Planner { public: MonthPlanner(const std::shared_ptr& range_planner, const DateTime& month_in); ~MonthPlanner() =default; core::Property>& appointments(); core::Property& month(); private: std::shared_ptr m_range_planner; core::Property m_month; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_PLANNER_MONTH_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/timezone.h0000644000015301777760000000223012323330715025377 0ustar pbusernogroup00000000000000/* * 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_TIMEZONE_H #define INDICATOR_DATETIME_TIMEZONE_H #include #include namespace unity { namespace indicator { namespace datetime { /** \brief Base a timezone, such as "America/Chicago". */ class Timezone { protected: Timezone() =default; public: core::Property timezone; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_TIMEZONE_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/utils.h0000644000015301777760000000416612323330715024717 0ustar pbusernogroup00000000000000/* * Copyright 2010, 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: * Michael Terry * Charles Kerr */ #ifndef INDICATOR_DATETIME_UTILS_H #define INDICATOR_DATETIME_UTILS_H #include #include /* GSettings */ G_BEGIN_DECLS /** \brief Returns true if the current locale prefers 12h display instead of 24h */ gboolean is_locale_12h (void); void split_settings_location (const char * location, char ** zone, char ** name); gchar * get_timezone_name (const char * timezone, GSettings * settings); gchar * get_beautified_timezone_name (const char * timezone, const char * saved_location); gchar * generate_full_format_string_at_time (GDateTime * now, GDateTime * then_begin, GDateTime * then_end); /** \brief Translate the string based on LC_TIME instead of LC_MESSAGES. The intent of this is to let users set LC_TIME to override their other locale settings when generating time format string */ const char* T_ (const char * msg); G_END_DECLS #endif /* INDICATOR_DATETIME_UTILS_H */ indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/actions.h0000644000015301777760000000466212323330715025220 0ustar pbusernogroup00000000000000/* * 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 desktop_open_alarm_app() =0; virtual void desktop_open_appointment(const Appointment&) =0; virtual void desktop_open_calendar_app(const DateTime&) =0; virtual void desktop_open_settings_app() =0; 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; 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: 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 indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/clock-watcher.h0000644000015301777760000000372112323330715026301 0ustar pbusernogroup00000000000000/* * 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_CLOCK_WATCHER_H #define INDICATOR_DATETIME_CLOCK_WATCHER_H #include #include #include #include #include #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief Watches the clock and appointments to notify when an * appointment's time is reached. */ class ClockWatcher { public: ClockWatcher() =default; virtual ~ClockWatcher() =default; virtual core::Signal& alarm_reached() = 0; }; /** * \brief A #ClockWatcher implementation */ class ClockWatcherImpl: public ClockWatcher { public: ClockWatcherImpl(const std::shared_ptr& clock, const std::shared_ptr& upcoming_planner); ~ClockWatcherImpl() =default; core::Signal& alarm_reached(); private: void pulse(); std::set m_triggered; const std::shared_ptr m_clock; const std::shared_ptr m_upcoming_planner; core::Signal m_alarm_reached; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_CLOCK_WATCHER_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/dbus-shared.h0000644000015301777760000000153012323330715025750 0ustar pbusernogroup00000000000000/* * 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 */ #define BUS_NAME "com.canonical.indicator.datetime" #define BUS_PATH "/com/canonical/indicator/datetime" indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/timezones.h0000644000015301777760000000273712323330715025576 0ustar pbusernogroup00000000000000/* * 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_TIMEZONES_H #define INDICATOR_DATETIME_TIMEZONES_H #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief Helper class which aggregates one or more timezones * * @see LiveClock * @see SettingsLocations */ class Timezones { public: Timezones() =default; virtual ~Timezones() =default; /** * \brief the current timezone */ core::Property timezone; /** * \brief all the detected timezones. * The count is >1 iff the detection mechamisms disagree. */ core::Property > timezones; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_TIMEZONES_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/timezone-file.h0000644000015301777760000000335712323330715026327 0ustar pbusernogroup00000000000000/* * 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_FILE_TIMEZONE_H #define INDICATOR_DATETIME_FILE_TIMEZONE_H #include // base class #include // std::string #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief A #Timezone that gets its information from monitoring a file, such as /etc/timezone */ class FileTimezone: public Timezone { public: FileTimezone(); FileTimezone(const std::string& filename); ~FileTimezone(); private: void set_filename(const std::string& filename); static void on_file_changed(gpointer gself); void clear(); void reload(); std::string m_filename; GFileMonitor * m_monitor = nullptr; unsigned long m_monitor_handler_id = 0; // we have raw pointers and glib tags in here, so disable copying FileTimezone(const FileTimezone&) =delete; FileTimezone& operator=(const FileTimezone&) =delete; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_FILE_TIMEZONE_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/timezones-live.h0000644000015301777760000000312212323330715026520 0ustar pbusernogroup00000000000000/* * 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 #include // shared_ptr<> namespace unity { namespace indicator { namespace datetime { /** * \brief #Timezones object that uses a #FileTimezone and #GeoclueTimezone * to detect what timezone we're in */ class LiveTimezones: public Timezones { public: LiveTimezones(const std::shared_ptr& settings, const std::string& filename); private: void update_geolocation(); void update_timezones(); FileTimezone m_file; std::shared_ptr m_settings; std::shared_ptr m_geo; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_LIVE_TIMEZONES_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/settings-live.h0000644000015301777760000000370712323330715026354 0ustar pbusernogroup00000000000000/* * 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(GSettings*, gchar*, gpointer); void update_key(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(); GSettings* m_settings; // 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 indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/locations-settings.h0000644000015301777760000000323412323330715027403 0ustar pbusernogroup00000000000000/* * 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_LOCATIONS_H #define INDICATOR_DATETIME_SETTINGS_LOCATIONS_H #include // base class #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief #Locations implementation which builds its list from the #Settings. */ class SettingsLocations: public Locations { public: /** * @param[in] settings the #Settings whose locations property is to be used * @param[in] timezones the #Timezones to always show first in the list */ SettingsLocations (const std::shared_ptr& settings, const std::shared_ptr& timezones); private: std::shared_ptr m_settings; std::shared_ptr m_timezones; void reload(); }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_SETTINGS_LOCATIONS_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/planner-upcoming.h0000644000015301777760000000311512323330715027026 0ustar pbusernogroup00000000000000/* * 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 indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/clock.h0000644000015301777760000000472112323330715024647 0ustar pbusernogroup00000000000000/* * 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 // GDBusConnection #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: static void on_system_bus_ready(GObject*, GAsyncResult*, gpointer); static void on_prepare_for_sleep(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer); GCancellable * m_cancellable = nullptr; GDBusConnection * m_system_bus = nullptr; unsigned int m_sleep_subscription_id = 0; // we've got raw pointers and GSignal tags in here, so disable copying Clock(const Clock&) =delete; Clock& operator=(const Clock&) =delete; }; /*** **** ***/ class Timezones; /** * \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; private: class Impl; std::unique_ptr p; }; /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_CLOCK_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/menu.h0000644000015301777760000000423712323330715024522 0ustar pbusernogroup00000000000000/* * 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 // 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(); 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 buildMenu(Menu::Profile profile); private: std::shared_ptr m_actions; std::shared_ptr m_state; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_MENU_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/planner.h0000644000015301777760000000242012323330715025205 0ustar pbusernogroup00000000000000/* * 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_PLANNER_H #define INDICATOR_DATETIME_PLANNER_H #include #include #include #include namespace unity { namespace indicator { namespace datetime { /** * \brief Simple collection of appointments */ class Planner { public: virtual ~Planner() =default; virtual core::Property>& appointments() =0; protected: Planner() =default; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_PLANNER_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/state.h0000644000015301777760000000474212323330715024677 0ustar pbusernogroup00000000000000/* * 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_STATE_H #define INDICATOR_DATETIME_STATE_H #include #include #include #include #include #include #include #include // std::shared_ptr namespace unity { namespace indicator { namespace datetime { /** * \brief Aggregates all the classes that represent the backend state. * * This is where the app comes together. It's a model that aggregates * all of the backend appointments/alarms, locations, timezones, * system time, and so on. The "view" code (ie, the Menus) need to * respond to Signals from the State and update themselves accordingly. * * @see Menu * @see MenuFactory * @see Timezones * @see Clock * @see Planner * @see Locations * @see Settings */ struct State { /** \brief The current time. Used by the header, by the date menuitem, and by the locations for relative timestamp */ std::shared_ptr clock; /** \brief The locations to be displayed in the Locations section of the #Menu */ std::shared_ptr locations; /** \brief Appointments in the month that's being displayed in the calendar section of the #Menu */ std::shared_ptr calendar_month; /** \brief The next appointments that follow highlighed date highlighted in the calendar section of the #Menu (default date = today) */ std::shared_ptr calendar_upcoming; /** \brief Configuration options that modify the view */ std::shared_ptr settings; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_STATE_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/CMakeLists.txt0000644000015301777760000000000212323330715026127 0ustar pbusernogroup00000000000000 indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/exporter.h0000644000015301777760000000412512323330715025422 0ustar pbusernogroup00000000000000/* * 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_EXPORTER_H #define INDICATOR_DATETIME_EXPORTER_H #include #include #include #include // GActionGroup #include // std::shared_ptr #include namespace unity { namespace indicator { namespace datetime { /** * \brief Exports actions and menus to DBus. */ class Exporter { public: Exporter() =default; ~Exporter(); core::Signal<> name_lost; void publish(const std::shared_ptr& actions, const std::vector>& menus); private: static void on_bus_acquired(GDBusConnection*, const gchar *name, gpointer gthis); void on_bus_acquired(GDBusConnection*, const gchar *name); static void on_name_lost(GDBusConnection*, const gchar *name, gpointer gthis); void on_name_lost(GDBusConnection*, const gchar *name); std::set m_exported_menu_ids; guint m_own_id = 0; guint m_exported_actions_id = 0; GDBusConnection * m_dbus_connection = nullptr; std::shared_ptr m_actions; std::vector> m_menus; // we've got raw pointers and gsignal tags in here, so disable copying Exporter(const Exporter&) =delete; Exporter& operator=(const Exporter&) =delete; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_EXPORTER_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/settings-shared.h0000644000015301777760000000354212323330715026660 0ustar pbusernogroup00000000000000/* * Copyright 2010 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_SETTINGS_SHARED #define INDICATOR_DATETIME_SETTINGS_SHARED typedef enum { TIME_FORMAT_MODE_LOCALE_DEFAULT, TIME_FORMAT_MODE_12_HOUR, TIME_FORMAT_MODE_24_HOUR, TIME_FORMAT_MODE_CUSTOM } TimeFormatMode; #define SETTINGS_INTERFACE "com.canonical.indicator.datetime" #define SETTINGS_SHOW_CLOCK_S "show-clock" #define SETTINGS_TIME_FORMAT_S "time-format" #define SETTINGS_SHOW_SECONDS_S "show-seconds" #define SETTINGS_SHOW_DAY_S "show-day" #define SETTINGS_SHOW_DATE_S "show-date" #define SETTINGS_SHOW_YEAR_S "show-year" #define SETTINGS_CUSTOM_TIME_FORMAT_S "custom-time-format" #define SETTINGS_SHOW_CALENDAR_S "show-calendar" #define SETTINGS_SHOW_WEEK_NUMBERS_S "show-week-numbers" #define SETTINGS_SHOW_EVENTS_S "show-events" #define SETTINGS_SHOW_LOCATIONS_S "show-locations" #define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location" #define SETTINGS_LOCATIONS_S "locations" #define SETTINGS_TIMEZONE_NAME_S "timezone-name" #endif // INDICATOR_DATETIME_SETTINGS_SHARED indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/engine-mock.h0000644000015301777760000000316512323330715025751 0ustar pbusernogroup00000000000000/* * 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) { appointment_func(m_appointments); } core::Signal<>& changed() { return m_changed; } private: core::Signal<> m_changed; std::vector m_appointments; }; /*** **** ***/ } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_ENGINE_NOOP__H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/appointment.h0000644000015301777760000000253212323330727026113 0ustar pbusernogroup00000000000000/* * 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 namespace unity { namespace indicator { namespace datetime { /** * \brief Plain Old Data Structure that represents a calendar appointment. * * @see Planner */ struct Appointment { public: std::string color; std::string summary; std::string url; std::string uid; bool has_alarms = false; DateTime begin; DateTime end; bool operator== (const Appointment& that) const; }; } // namespace datetime } // namespace indicator } // namespace unity #endif // INDICATOR_DATETIME_APPOINTMENT_H indicator-datetime-13.10.0+14.04.20140415.3/include/datetime/formatter.h0000644000015301777760000001002012323330715025544 0ustar pbusernogroup00000000000000/* * 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: 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: 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 indicator-datetime-13.10.0+14.04.20140415.3/include/CMakeLists.txt0000644000015301777760000000003312323330715024337 0ustar pbusernogroup00000000000000add_subdirectory(datetime) indicator-datetime-13.10.0+14.04.20140415.3/m4/0000755000015301777760000000000012323331375020503 5ustar pbusernogroup00000000000000indicator-datetime-13.10.0+14.04.20140415.3/m4/gcov.m40000644000015301777760000000470512323330715021706 0ustar pbusernogroup00000000000000# Checks for existence of coverage tools: # * gcov # * lcov # * genhtml # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present # and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], [ AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) if test "x$use_gcov" = "xyes"; then # we need gcc: if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-gcov]) fi # Check if ccache is being used AC_CHECK_PROG(SHTOOL, shtool, shtool) case `$SHTOOL path $CC` in *ccache*[)] gcc_ccache=yes;; *[)] gcc_ccache=no;; esac if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ glib_cv_lcov_version=invalid lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` for lcov_check_version in $lcov_version_list; do if test "$lcov_version" = "$lcov_check_version"; then glib_cv_lcov_version="$lcov_check_version (ok)" fi done ]) else lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi case $glib_cv_lcov_version in ""|invalid[)] lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." AC_MSG_ERROR([$lcov_msg]) LCOV="exit 0;" ;; esac if test -z "$GENHTML"; then AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi ac_cv_check_gcov=yes ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` changequote([,]) # Add the special gcc flags COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-lgcov" # Check availability of gcovr AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test -z "$GCOVR"; then ac_cv_check_gcovr=no else ac_cv_check_gcovr=yes fi fi ]) # AC_TDD_GCOV indicator-datetime-13.10.0+14.04.20140415.3/m4/gtest.m40000644000015301777760000000477112323330715022101 0ustar pbusernogroup00000000000000# Copyright (C) 2012 Canonical, Ltd. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice (including the next # paragraph) shall be included in all copies or substantial portions of the # Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # Checks whether the gtest source is available on the system. Allows for # adjusting the include and source path. Sets have_gtest=yes if the source is # present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and # source location respectively. AC_DEFUN([CHECK_GTEST], [ AC_ARG_WITH([gtest-include-path], [AS_HELP_STRING([--with-gtest-include-path], [location of the Google test headers])], [GTEST_CPPFLAGS="-I$withval"]) AC_ARG_WITH([gtest-source-path], [AS_HELP_STRING([--with-gtest-source-path], [location of the Google test sources, defaults to /usr/src/gtest])], [GTEST_SOURCE="$withval"], [GTEST_SOURCE="/usr/src/gtest"]) GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE" AC_LANG_PUSH([C++]) tmp_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS" AC_CHECK_HEADER([gtest/gtest.h]) CPPFLAGS="$tmp_CPPFLAGS" AC_LANG_POP AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc] [$GTEST_SOURCE/src/gtest_main.cc], [have_gtest_source=yes], [have_gtest_source=no]) AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \ "x$have_gtest_source" = xyes], [have_gtest=yes] [AC_SUBST(GTEST_CPPFLAGS)] [AC_SUBST(GTEST_SOURCE)], [have_gtest=no]) ]) # CHECK_GTEST indicator-datetime-13.10.0+14.04.20140415.3/AUTHORS0000644000015301777760000000003112323330715021222 0ustar pbusernogroup00000000000000# Generated by Makefile indicator-datetime-13.10.0+14.04.20140415.3/README0000644000015301777760000001147712323330715021052 0ustar pbusernogroup00000000000000ACTIONS ======= * "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