* @{
*/
-namespace worldclock {
- namespace controller {
-
+namespace controller {
/**
* @brief Application lifecycle main controller singleton class
* @remarks This is singleton class.
*/
- class MainController {
- public:
- /**
- * @brief Retrieves singleton instance.
- */
- static MainController &GetInstance();
-
- /**
- * @brief Destructor.
- */
- ~MainController();
-
- /**
- * @brief Initializes application.
- */
- int Init();
-
- /**
- * @brief Denitializes application.
- */
- void Deinit();
-
- /**
- * @brief Pause application.
- */
- void Pause();
-
- /**
- * @brief Resume application.
- */
- void Resume();
-
- /**
- * @briefs Copies this class object instance.
- * @remarks Customized for singleton purpose - make no effect.
- */
- MainController(MainController const&) = delete;
-
- /**
- * @briefs Overloads equation mark.
- * @remarks Customized for singleton purpose - make no effect.
- */
- void operator=(MainController const&) = delete;
-
- private:
- /**
- * @brief Constructs MainController class object.
- */
- MainController() {};
- };
-
- }
+ class MainController {
+ public:
+ /**
+ * @brief Retrieves singleton instance.
+ */
+ static MainController &GetInstance();
+
+ /**
+ * @brief Destructor.
+ */
+ ~MainController();
+
+ /**
+ * @brief Initializes application.
+ */
+ int Init();
+
+ /**
+ * @brief Denitializes application.
+ */
+ void Deinit();
+
+ /**
+ * @brief Pause application.
+ */
+ void Pause();
+
+ /**
+ * @brief Resume application.
+ */
+ void Resume();
+
+ /**
+ * @briefs Copies this class object instance.
+ * @remarks Customized for singleton purpose - make no effect.
+ */
+ MainController(MainController const&) = delete;
+
+ /**
+ * @briefs Overloads equation mark.
+ * @remarks Customized for singleton purpose - make no effect.
+ */
+ void operator=(MainController const&) = delete;
+
+ private:
+ /**
+ * @brief Constructs MainController class object.
+ */
+ MainController() {};
+ };
}
/**
#include "Model/AlarmProvider.h"
namespace internal {
- namespace model {
- class AlarmProviderFile : public common::model::AlarmProvider
- {
- public:
- std::vector<std::reference_wrapper<common::model::Alarm>> GetAlarms();
- common::model::Alarm* GetAlarmWithId(common::model::AlarmId id);
- void Add(common::model::Alarm& alarm);
- void Remove(common::model::Alarm& alarm);
- AlarmProviderFile(common::utils::IReader &r);
- ~AlarmProviderFile();
- void Serialize(common::utils::IWriter &w) const;
- private:
- std::list<common::model::Alarm> alarms;
- static const int db_schema_version;
- };
- } /* model */
+ class AlarmProviderFile : public model::AlarmProvider
+ {
+ public:
+ std::vector<std::reference_wrapper<model::Alarm>> GetAlarms();
+ model::Alarm* GetAlarmWithId(model::AlarmId id);
+ void Add(model::Alarm& alarm);
+ void Remove(model::Alarm& alarm);
+ AlarmProviderFile(utils::IReader &r);
+ ~AlarmProviderFile();
+ void Serialize(utils::IWriter &w) const;
+ private:
+ std::list<model::Alarm> alarms;
+ static const int db_schema_version;
+ };
} /* internal */
#endif
#include "Model/AlarmProvider.h"
namespace internal {
- namespace model {
- class AlarmProviderStub : public common::model::AlarmProvider
- {
- public:
- std::vector<std::reference_wrapper<common::model::Alarm>> GetAlarms();
- common::model::Alarm* GetAlarmWithId(common::model::AlarmId id);
- void Add(common::model::Alarm& alarm);
- void Remove(common::model::Alarm& alarm);
- AlarmProviderStub(common::utils::IReader &r);
- void Serialize(common::utils::IWriter &w) const {}
- private:
- std::vector<common::model::Alarm> alarms;
- };
- } /* model */
+ class AlarmProviderStub : public model::AlarmProvider
+ {
+ public:
+ std::vector<std::reference_wrapper<model::Alarm>> GetAlarms();
+ model::Alarm* GetAlarmWithId(model::AlarmId id);
+ void Add(model::Alarm& alarm);
+ void Remove(model::Alarm& alarm);
+ AlarmProviderStub(utils::IReader &r);
+ void Serialize(utils::IWriter &w) const {}
+ private:
+ std::vector<model::Alarm> alarms;
+ };
} /* internal */
#endif
#include "Utils/Serialization.h"
#include "Utils/Time.h"
-namespace common {
- namespace model {
- typedef int AlarmId;
- enum class AlarmType {
- SOUND_ONLY,
- VIBRATION,
- VIBRATION_AND_SOUND
- };
- void Serialize(utils::IWriter &w, AlarmType type);
- void Deserialize(utils::IReader &w, AlarmType &type);
- class CLOCK_EXPORT_API Alarm : public utils::ISerializable {
- public:
- Alarm();
- Alarm(utils::IReader &);
- void Activate();
- bool IsActivated() const;
- void Deactivate();
- void Snooze();
- void EnableSnooze();
- void DisableSnooze();
- bool IsSnoozeEnabled();
- void SetSnoozeInterval(unsigned int seconds);
- unsigned int GetSnoozeInterval() const;
- void SetSnoozeMaxAttemps(unsigned int attemps);
- unsigned int GetSnoozeMaxAttempts() const;
- std::string GetName() const;
- void SetName(std::string name);
- utils::Time GetTime() const;
- void SetTime(utils::Time time);
- std::string GetMelody() const;
- void SetMelody(std::string path);
- AlarmType GetType() const;
- void SetType(AlarmType pattern);
- WeekFlags GetWeekFlags() const;
- void SetWeekFlags(WeekFlags flags);
- void Serialize(utils::IWriter &w) const;
- unsigned int GetVolume() const;
- void SetVolume(unsigned int volume);
+namespace model {
+ typedef int AlarmId;
+ enum class AlarmType {
+ SOUND_ONLY,
+ VIBRATION,
+ VIBRATION_AND_SOUND
+ };
+ void Serialize(utils::IWriter &w, AlarmType type);
+ void Deserialize(utils::IReader &w, AlarmType &type);
+ class CLOCK_EXPORT_API Alarm : public utils::ISerializable {
+ public:
+ Alarm();
+ Alarm(utils::IReader &);
+ void Activate();
+ bool IsActivated() const;
+ void Deactivate();
+ void Snooze();
+ void EnableSnooze();
+ void DisableSnooze();
+ bool IsSnoozeEnabled();
+ void SetSnoozeInterval(unsigned int seconds);
+ unsigned int GetSnoozeInterval() const;
+ void SetSnoozeMaxAttemps(unsigned int attemps);
+ unsigned int GetSnoozeMaxAttempts() const;
+ std::string GetName() const;
+ void SetName(std::string name);
+ utils::Time GetTime() const;
+ void SetTime(utils::Time time);
+ std::string GetMelody() const;
+ void SetMelody(std::string path);
+ AlarmType GetType() const;
+ void SetType(AlarmType pattern);
+ WeekFlags GetWeekFlags() const;
+ void SetWeekFlags(WeekFlags flags);
+ void Serialize(utils::IWriter &w) const;
+ unsigned int GetVolume() const;
+ void SetVolume(unsigned int volume);
- /** Implement guideline requirement. Two alarms are considered
- * same if they have same time and name */
- inline bool operator==(const Alarm &a) { return (time == a.time) && (a.name == name); }
- inline bool operator==(const AlarmId id) { return this->alarm_id == id; }
- private:
- int alarm_id;
- std::string name;
- struct {
- std::string melody;
- unsigned int volume;
- } sound;
- AlarmType type_;
- WeekFlags flags;
- bool activated;
- bool snooze_enabled;
- struct {
- int alarm_id;
- unsigned int interval;
- unsigned int attempt;
- unsigned int attempts_max;
- } snooze;
- utils::Time time;
- };
- } /* model */
-} /* common */
+ /** Implement guideline requirement. Two alarms are considered
+ * same if they have same time and name */
+ inline bool operator==(const Alarm &a) { return (time == a.time) && (a.name == name); }
+ inline bool operator==(const AlarmId id) { return this->alarm_id == id; }
+ private:
+ int alarm_id;
+ std::string name;
+ struct {
+ std::string melody;
+ unsigned int volume;
+ } sound;
+ std::string vibration;
+ WeekFlags flags;
+ bool activated;
+ bool snooze_enabled;
+ AlarmType type_;
+ struct {
+ int alarm_id;
+ unsigned int interval;
+ unsigned int attempt;
+ unsigned int attempts_max;
+ } snooze;
+ utils::Time time;
+ };
+} /* model */
#endif
#include <functional>
-namespace common {
- namespace model {
- class CLOCK_EXPORT_API AlarmProvider : public utils::ISerializable {
- public:
- static AlarmProvider *GetInstance();
- static void Sync();
+namespace model {
+ class CLOCK_EXPORT_API AlarmProvider : public utils::ISerializable {
+ public:
+ static AlarmProvider *GetInstance();
+ static void Sync();
- virtual std::vector<std::reference_wrapper<Alarm>> GetAlarms() = 0;
- virtual Alarm *GetAlarmWithId(AlarmId id) = 0;
- virtual void Add(Alarm& alarm) = 0;
- virtual void Remove(Alarm& alarm) = 0;
- protected:
- AlarmProvider() {}
- virtual ~AlarmProvider() {}
- };
- } /* model */
-} /* common */
+ virtual std::vector<std::reference_wrapper<Alarm>> GetAlarms() = 0;
+ virtual Alarm *GetAlarmWithId(AlarmId id) = 0;
+ virtual void Add(Alarm& alarm) = 0;
+ virtual void Remove(Alarm& alarm) = 0;
+ protected:
+ AlarmProvider() {}
+ virtual ~AlarmProvider() {}
+ };
+} /* model */
#endif
#ifndef _CLOCK_LOCATION_H_
#define _CLOCK_LOCATION_H_
-namespace clock {
- namespace model {
- struct Location {
- std::string Name;
- std::string Country;
- std::string Timezone;
- std::string TzPath;
- };
- } /* model */
-} /* clock */
+#include <string>
+
+namespace model {
+ struct Location {
+ std::string Name;
+ std::string Country;
+ std::string Timezone;
+ std::string TzPath;
+ };
+} /* model */
+
#endif
#ifndef _CLOCK_STOPWATCH_H_
#define _CLOCK_STOPWATCH_H_
-namespace clock {
- namespace model {
- class StopWatch {
- public:
- void Start();
- void Stop();
- void EndLap();
- void Reset();
- time_t ElapsedTime();
- std::vector<StopWatchLap> GetLaps();
- private:
- time_t start_time;
- std::vector<StopWatchLap> laps;
- };
- } /* model */
-} /* clock */
+namespace model {
+ class StopWatch {
+ public:
+ void Start();
+ void Stop();
+ void EndLap();
+ void Reset();
+ time_t ElapsedTime();
+ std::vector<StopWatchLap> GetLaps();
+ private:
+ time_t start_time;
+ std::vector<StopWatchLap> laps;
+ };
+} /* model */
#endif
#ifndef _CLOCK_STOPWATCH_LAP_H_
#define _CLOCK_STOPWATCH_LA_H_
-namespace clock {
- namespace model {
- class StopWatchLap {
- public:
- StopWatchLap(time_t start, time_t duration);
- ~StopWatchLap();
- time_t LapDuration();
- time_t LapStartTime();
- };
- } /* model */
-} /* clock */
+namespace model {
+ class StopWatchLap {
+ public:
+ StopWatchLap(time_t start, time_t duration);
+ ~StopWatchLap();
+ time_t LapDuration();
+ time_t LapStartTime();
+ };
+} /* model */
#endif
#ifndef _CLOCK_TIMER_H_
#define _CLOCK_TIMER_H_
-namespace clock {
- namespace model {
- class Timer {
- public:
- Start(time_t delay);
- time_t StartTime();
- time_t RemainingTime();
- };
- } /* model */
-} /* clock */
+namespace model {
+ class Timer {
+ public:
+ Start(time_t delay);
+ time_t StartTime();
+ time_t RemainingTime();
+ };
+} /* model */
#endif
#include <app_alarm.h>
-namespace common {
- namespace model {
- enum class WeekDay : int {
- MONDAY = ALARM_WEEK_FLAG_MONDAY,
- TUESDAY = ALARM_WEEK_FLAG_TUESDAY,
- WEDNESDAY = ALARM_WEEK_FLAG_WEDNESDAY,
- THURSDAY = ALARM_WEEK_FLAG_THURSDAY,
- FRIDAY = ALARM_WEEK_FLAG_FRIDAY,
- SATURDAY = ALARM_WEEK_FLAG_SATURDAY,
- SUNDAY = ALARM_WEEK_FLAG_SUNDAY,
- ALL_WEEK = (MONDAY | TUESDAY | WEDNESDAY | THURSDAY | FRIDAY | SATURDAY | SUNDAY),
- WEEKEND = (SATURDAY | SUNDAY),
- };
- inline constexpr WeekDay
- operator|(WeekDay a, WeekDay b)
- {
- return static_cast<WeekDay>(static_cast<int>(a) | static_cast<int>(b));
- }
- class CLOCK_EXPORT_API WeekFlags : public utils::ISerializable {
- public:
- WeekFlags();
- WeekFlags(utils::IReader &r);
- WeekFlags(WeekDay day);
- void AddDay(WeekDay day);
- void RemoveDay(WeekDay day);
- bool IsOn(WeekDay day);
- void Serialize(utils::IWriter &w) const;
- int GetBitMask() const;
- inline bool operator==(const WeekFlags &a) { return a.raw_flags == raw_flags; }
- private:
- int raw_flags;
- };
- } /* model */
-} /* common */
+namespace model {
+ enum class WeekDay : int {
+ MONDAY = ALARM_WEEK_FLAG_MONDAY,
+ TUESDAY = ALARM_WEEK_FLAG_TUESDAY,
+ WEDNESDAY = ALARM_WEEK_FLAG_WEDNESDAY,
+ THURSDAY = ALARM_WEEK_FLAG_THURSDAY,
+ FRIDAY = ALARM_WEEK_FLAG_FRIDAY,
+ SATURDAY = ALARM_WEEK_FLAG_SATURDAY,
+ SUNDAY = ALARM_WEEK_FLAG_SUNDAY,
+ ALL_WEEK = (MONDAY | TUESDAY | WEDNESDAY | THURSDAY | FRIDAY | SATURDAY | SUNDAY),
+ WEEKEND = (SATURDAY | SUNDAY),
+ };
+ inline constexpr WeekDay
+ operator|(WeekDay a, WeekDay b)
+ {
+ return static_cast<WeekDay>(static_cast<int>(a) | static_cast<int>(b));
+ }
+ class CLOCK_EXPORT_API WeekFlags : public utils::ISerializable {
+ public:
+ WeekFlags();
+ WeekFlags(utils::IReader &r);
+ WeekFlags(WeekDay day);
+ void AddDay(WeekDay day);
+ void RemoveDay(WeekDay day);
+ bool IsOn(WeekDay day);
+ void Serialize(utils::IWriter &w) const;
+ int GetBitMask() const;
+ inline bool operator==(const WeekFlags &a) { return a.raw_flags == raw_flags; }
+ private:
+ int raw_flags;
+ };
+} /* model */
#endif
#include <vector>
-namespace clock {
- namespace model {
- class WorldClock {
- public:
- const std::vector<Location> Locations;
- const std::vector<Location> UserLocations;
+namespace model {
+ class WorldClock {
+ public:
+ const std::vector<Location> Locations;
+ const std::vector<Location> UserLocations;
+
+ void AddUserLocation(Location loc);
+ void RemoveUserLocation(Location loc);
+ };
+} /* model */
- void AddUserLocation(Location loc);
- void RemoveUserLocation(Location loc);
- };
- } /* model */
-} /* clock */
#endif
#include "View/AlarmView.h"
#include "Model/AlarmProvider.h"
-namespace worldclock {
- namespace presenters {
- class AlarmPresenter {
- public:
- AlarmPresenter(view::AlarmView *view, common::model::AlarmProvider *model);
- private:
- view::AlarmView *view;
- common::model::AlarmProvider *model;
- void ShowAll();
- void OnItemSelected(int idx);
- void OnItemActiveStatusChanged(int idx);
- };
- } /* presenters */
-} /* worldclock */
+namespace presenter {
+ class AlarmPresenter {
+ public:
+ AlarmPresenter(view::AlarmView *view, model::AlarmProvider *model);
+ private:
+ view::AlarmView *view;
+ model::AlarmProvider *model;
+ void ShowAll();
+ void OnItemSelected(int idx);
+ void OnItemActiveStatusChanged(int idx);
+ };
+} /* presenters */
#endif
+++ /dev/null
-#ifndef _CLOCK_TIME_H_
-#define _CLOCK_TIME_H_
-
-#include <time.h>
-
-time_t MakeTime(int day, int month, int year, int hour, int min);
-
-#endif
#include <Elementary.h>
-namespace common {
namespace ui {
class IView {
public:
virtual Evas_Object *GetEvasObject() = 0;
};
};
-};
#endif
#include "Utils/Utils.h"
#include <vector>
-namespace common {
- namespace utils {
- class BinaryFileReader : public IReader {
- public:
- BinaryFileReader(Utils::AppSubdirectory dir, const char *filename);
- ~BinaryFileReader() {}
- void Read(void *buffer, size_t size);
- private:
- std::vector<unsigned char> buffer;
- unsigned int offset;
- };
- } /* utils */
-} /* common */
+namespace utils {
+ class BinaryFileReader : public IReader {
+ public:
+ BinaryFileReader(Utils::AppSubdirectory dir, const char *filename);
+ ~BinaryFileReader() {}
+ void Read(void *buffer, size_t size);
+ private:
+ std::vector<unsigned char> buffer;
+ unsigned int offset;
+ };
+} /* utils */
#endif
#include <fstream>
-namespace common {
- namespace utils {
- class BinaryFileWriter : public IWriter {
- public:
- BinaryFileWriter(Utils::AppSubdirectory dir, const char *filename);
- ~BinaryFileWriter();
- void Write(const void *buffer, size_t size);
- void Flush();
- private:
- std::ofstream file;
- };
- } /* utils */
-} /* common */
+namespace utils {
+ class BinaryFileWriter : public IWriter {
+ public:
+ BinaryFileWriter(Utils::AppSubdirectory dir, const char *filename);
+ ~BinaryFileWriter();
+ void Write(const void *buffer, size_t size);
+ void Flush();
+ private:
+ std::ofstream file;
+ };
+} /* utils */
#endif
#ifndef _CLOCK_LOC
#define _CLOCK_LOC
-namespace clock {
- namespace utils {
- class Log {
- };
- } /* utils */
-} /* clock */
+namespace utils {
+ class Log {
+ };
+} /* utils */
+
#endif
#include <cstdlib>
-namespace common {
- namespace utils {
- class IReader {
- public:
- virtual void Read(void *buffer, size_t size) = 0;
- virtual ~IReader() {}
- };
- } /* utils */
-} /* common */
+namespace utils {
+ class IReader {
+ public:
+ virtual void Read(void *buffer, size_t size) = 0;
+ virtual ~IReader() {}
+ };
+} /* utils */
+
#endif
#include <list>
#include <string>
-namespace common {
- namespace utils {
- class ISerializable {
- public:
- ISerializable() {}
- ISerializable(IReader &reader) {}
- virtual void Serialize(IWriter &writer) const = 0;
- virtual ~ISerializable() {}
- };
+namespace utils {
+ class ISerializable {
+ public:
+ ISerializable() {}
+ ISerializable(IReader &reader) {}
+ virtual void Serialize(IWriter &writer) const = 0;
+ virtual ~ISerializable() {}
+ };
- // serialization/deserialization for basic types
- // ISerializable
- inline void Serialize(IWriter &w, const ISerializable &o) {
- o.Serialize(w);
- }
- template<typename T>
- inline void Deserialize(IReader &r, T &obj) {
- obj = T(r);
- }
+ // serialization/deserialization for basic types
+ // ISerializable
+ inline void Serialize(IWriter &w, const ISerializable &o) {
+ o.Serialize(w);
+ }
+ template<typename T>
+ inline void Deserialize(IReader &r, T &obj) {
+ obj = T(r);
+ }
- // int
- inline void Serialize(IWriter &w, const int v) {
- w.Write(&v, sizeof(v));
- }
- inline void Deserialize(IReader &r, int *v) {
- r.Read(v, sizeof(v));
- }
- inline void Deserialize(IReader &r, int &v) {
- r.Read(&v, sizeof(v));
- }
+ // int
+ inline void Serialize(IWriter &w, const int v) {
+ w.Write(&v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, int *v) {
+ r.Read(v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, int &v) {
+ r.Read(&v, sizeof(v));
+ }
- // unsigned int
- inline void Serialize(IWriter &w, const unsigned int v) {
- w.Write(&v, sizeof(v));
- }
- inline void Deserialize(IReader &r, unsigned int *v) {
- r.Read(v, sizeof(v));
- }
- inline void Deserialize(IReader &r, unsigned int &v) {
- r.Read(&v, sizeof(v));
- }
+ // unsigned int
+ inline void Serialize(IWriter &w, const unsigned int v) {
+ w.Write(&v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, unsigned int *v) {
+ r.Read(v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, unsigned int &v) {
+ r.Read(&v, sizeof(v));
+ }
- // bool
- inline void Serialize(IWriter &w, const bool v) {
- w.Write(&v, sizeof(v));
- }
- inline void Deserialize(IReader &r, bool *v) {
- r.Read(v, sizeof(v));
- }
- inline void Deserialize(IReader &r, bool &v) {
- r.Read(&v, sizeof(v));
- }
+ // bool
+ inline void Serialize(IWriter &w, const bool v) {
+ w.Write(&v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, bool *v) {
+ r.Read(v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, bool &v) {
+ r.Read(&v, sizeof(v));
+ }
- // time_t
- inline void Serialize(IWriter &w, const time_t v) {
- w.Write(&v, sizeof(v));
- }
- inline void Deserialize(IReader &r, time_t *v) {
- r.Read(v, sizeof(v));
- }
- inline void Deserialize(IReader &r, time_t &v) {
- r.Read(&v, sizeof(v));
- }
+ // time_t
+ inline void Serialize(IWriter &w, const time_t v) {
+ w.Write(&v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, time_t *v) {
+ r.Read(v, sizeof(v));
+ }
+ inline void Deserialize(IReader &r, time_t &v) {
+ r.Read(&v, sizeof(v));
+ }
- // serialization for std::string
- inline void Serialize(IWriter &w, const std::string &v) {
- int len = v.size();
- w.Write(&len, sizeof(len));
- w.Write(v.c_str(), len);
- }
- inline void Deserialize(IReader &r, std::string &v) {
- int len;
- r.Read(&len, sizeof(len));
- char *buf = new char[len + 1];
- r.Read(buf, len);
- buf[len] = '\0';
- v = std::string(buf);
- delete buf;
- };
+ // serialization for std::string
+ inline void Serialize(IWriter &w, const std::string &v) {
+ int len = v.size();
+ w.Write(&len, sizeof(len));
+ w.Write(v.c_str(), len);
+ }
+ inline void Deserialize(IReader &r, std::string &v) {
+ int len;
+ r.Read(&len, sizeof(len));
+ char *buf = new char[len + 1];
+ r.Read(buf, len);
+ buf[len] = '\0';
+ v = std::string(buf);
+ delete buf;
+ };
+
+ // serialization for std::list
+ template <typename T>
+ inline void Serialize(IWriter &w, const std::list<T> &list) {
+ int len = list.size();
+ w.Write(&len, sizeof(len));
+ for (auto it = list.begin(); it != list.end(); ++it) {
+ Serialize(w, *it);
+ }
+ }
+ template <typename T>
+ inline void Deserialize(IReader &r, std::list<T> &list) {
+ int len;
+ r.Read(&len, sizeof(len));
+ for (int i = 0; i < len; i++) {
+ T obj(r);
+ list.push_back(std::move(obj));
+ }
+ }
+} /* utils */
- // serialization for std::list
- template <typename T>
- inline void Serialize(IWriter &w, const std::list<T> &list) {
- int len = list.size();
- w.Write(&len, sizeof(len));
- for (auto it = list.begin(); it != list.end(); ++it) {
- Serialize(w, *it);
- }
- }
- template <typename T>
- inline void Deserialize(IReader &r, std::list<T> &list) {
- int len;
- r.Read(&len, sizeof(len));
- for (int i = 0; i < len; i++) {
- T obj(r);
- list.push_back(std::move(obj));
- }
- }
- } /* utils */
-} /* common */
#endif
#include "Common/Defines.h"
#include "Utils/Serialization.h"
-namespace common {
- namespace utils {
- enum Format {
- FORMAT_12H,
- FORMAT_24H
- };
- class CLOCK_EXPORT_API Time : public utils::ISerializable {
- public:
- unsigned int Hour, Min, Sec;
- Time() : Hour(0), Min(0), Sec(0) {}
- Time(unsigned int h, unsigned int m, unsigned int s) : Hour(h), Min(m), Sec(s) {}
- Time(utils::IReader &);
- void Serialize(utils::IWriter &w) const;
- inline bool operator==(const Time &a) { return (a.Hour == Hour ) &&
- (a.Min == Min) && (a.Sec == Sec); }
- std::string Format(enum Format format) const;
- std::string Meridiem() const;
- std::string getFormattedTime(const char *icu_format) const;
- };
- } /* utils */
-} /* common */
+namespace utils {
+ enum Format {
+ FORMAT_12H,
+ FORMAT_24H
+ };
+ class CLOCK_EXPORT_API Time : public utils::ISerializable {
+ public:
+ unsigned int Hour, Min, Sec;
+ Time() : Hour(0), Min(0), Sec(0) {}
+ Time(unsigned int h, unsigned int m, unsigned int s) : Hour(h), Min(m), Sec(s) {}
+ Time(utils::IReader &);
+ void Serialize(utils::IWriter &w) const;
+ inline bool operator==(const Time &a) { return (a.Hour == Hour ) &&
+ (a.Min == Min) && (a.Sec == Sec); }
+ std::string Format(enum Format format) const;
+ std::string Meridiem() const;
+ std::string getFormattedTime(const char *icu_format) const;
+ };
+} /* utils */
#endif
#define _CLOCK_UTILS_H_
-namespace common {
- namespace utils {
-
- class Utils {
- public:
- /*
- * @brief Application sub-directories type.
- */
- enum AppSubdirectory {
- APP_DIR_DATA,
- APP_DIR_CACHE,
- APP_DIR_RESOURCE,
- APP_DIR_SHARED_DATA,
- APP_DIR_SHARED_RESOURCE,
- APP_DIR_SHARED_TRUSTED,
- APP_DIR_EXTERNAL_DATA,
- APP_DIR_EXTERNAL_CACHE,
- APP_DIR_EXTERNAL_SHARED_DATA,
- };
-
- /**
- * @brief Returns absolute path to resource file located in applications directory.
- *
- * @param dir type of subdirectory
- * @param relative path of resource from starting from given sub dir.
- * eg. for APP_DATA_DIR subdir and relative "database.db" => "/home/owner/apps/org.tizen.clock/data/database.db"
- * @return absolute path string.
- *
- * @note returns statically allocated string
- */
- static const char *GetAppResourcePath(enum AppSubdirectory dir, const char *relative);
+namespace utils {
+ class Utils {
+ public:
+ /*
+ * @brief Application sub-directories type.
+ */
+ enum AppSubdirectory {
+ APP_DIR_DATA,
+ APP_DIR_CACHE,
+ APP_DIR_RESOURCE,
+ APP_DIR_SHARED_DATA,
+ APP_DIR_SHARED_RESOURCE,
+ APP_DIR_SHARED_TRUSTED,
+ APP_DIR_EXTERNAL_DATA,
+ APP_DIR_EXTERNAL_CACHE,
+ APP_DIR_EXTERNAL_SHARED_DATA,
};
- }
-}
+ /**
+ * @brief Returns absolute path to resource file located in applications directory.
+ *
+ * @param dir type of subdirectory
+ * @param relative path of resource from starting from given sub dir.
+ * eg. for APP_DATA_DIR subdir and relative "database.db" => "/home/owner/apps/org.tizen.clock/data/database.db"
+ * @return absolute path string.
+ *
+ * @note returns statically allocated string
+ */
+ static const char *GetAppResourcePath(enum AppSubdirectory dir, const char *relative);
+ };
+}
#endif /* _CLOCK_UTILS_H_ */
#include <cstdlib>
-namespace common {
- namespace utils {
- class IWriter {
- public:
- virtual void Write(const void *buffer, size_t size) = 0;
- virtual ~IWriter() {}
- };
- } /* utils */
-} /* common */
+namespace utils {
+ class IWriter {
+ public:
+ virtual void Write(const void *buffer, size_t size) = 0;
+ virtual ~IWriter() {}
+ };
+} /* utils */
+
#endif
#include <functional>
-namespace worldclock {
- namespace view {
- class AlarmView : public common::ui::IView {
- public:
- typedef std::function<void(int)> SelectCallback;
- typedef std::function<void(int)> ToggleCallback;
- typedef std::function<void(void)> ButtonClickedCallback;
-
- AlarmView();
- void Clear();
- int ItemAppend(common::utils::Time time, const char *name,
- const common::model::WeekFlags flags, bool active);
- void RemoveItem(int idx);
- void ItemUpdate(int idx, common::utils::Time time, const char *name,
- const common::model::WeekFlags flags, bool active);
- void ItemEnable(int idx);
- void ItemDisable(int idx);
-
- void SetItemToggleCallback(ToggleCallback func);
- void SetItemSelectCallback(SelectCallback func);;
- void SetButtonClickedCallback(ButtonClickedCallback func);
- Evas_Object *GetEvasObject();
- private:
- static Elm_Genlist_Item_Class alarm_itc;
- static Evas_Object *ContentGet(void *data, Evas_Object *obj, const char *part);
- static char *TextGet(void *data, Evas_Object *obj, const char *part);
- static void ItemClicked(void *data, Evas_Object *obj, void *info);
- static void ItemRealized(void *data, Evas_Object *obj, void *info);
- Evas_Object *genlist;
- SelectCallback onSelected;
- ToggleCallback onToggled;
- ButtonClickedCallback onClicked;;
- };
- }
+namespace view {
+ class AlarmView : public ui::IView {
+ public:
+ typedef std::function<void(int)> SelectCallback;
+ typedef std::function<void(int)> ToggleCallback;
+ typedef std::function<void(void)> ButtonClickedCallback;
+
+ AlarmView();
+ void Clear();
+ int ItemAppend(utils::Time time, const char *name,
+ const model::WeekFlags flags, bool active);
+ void RemoveItem(int idx);
+ void ItemUpdate(int idx, utils::Time time, const char *name,
+ const model::WeekFlags flags, bool active);
+ void ItemEnable(int idx);
+ void ItemDisable(int idx);
+
+ void SetItemToggleCallback(ToggleCallback func);
+ void SetItemSelectCallback(SelectCallback func);;
+ void SetButtonClickedCallback(ButtonClickedCallback func);
+ Evas_Object *GetEvasObject();
+ private:
+ static Elm_Genlist_Item_Class alarm_itc;
+ static Evas_Object *ContentGet(void *data, Evas_Object *obj, const char *part);
+ static char *TextGet(void *data, Evas_Object *obj, const char *part);
+ static void ItemClicked(void *data, Evas_Object *obj, void *info);
+ static void ItemRealized(void *data, Evas_Object *obj, void *info);
+ Evas_Object *genlist;
+ SelectCallback onSelected;
+ ToggleCallback onToggled;
+ ButtonClickedCallback onClicked;;
+ };
}
-
#endif /* ALARMVIEW_H_ */
* @{
*/
-namespace worldclock {
- namespace view {
-
- /**
- * @brief Application main view class
- * @remarks This is singleton class.
- */
- class MainView : public common::ui::IView {
- public:
-
- /**
- * @brief Retrieves singleton instance.
- */
- static MainView &GetInstance();
-
- /**
- * @brief Destructor
- */
- ~MainView();
-
- /**
- * @brief Creates content of application
- * @remarks It not creates base GUI
- */
- void CreateContent();
-
- /**
- * @brief Retrieves naviframe object.
- */
- Evas_Object *GetEvasObject();
-
- /**
- * @briefs Copies this class object instance.
- * @remarks Customized for singleton purpose - make no effect.
- */
- MainView(MainView const&) = delete;
- /**
- * @briefs Overloads equation mark.
- * @remarks Customized for singleton purpose - make no effect.
- */
- void operator=(MainView const&) = delete;
- private:
-
- /**
- * @brief Constructs MainView class object
- * @remarks Creates base GUI
- */
- MainView();
-
- /**
- * Adds conformant to window.
- */
- void ConformantAdd();
-
- /**
- * @brief Adds naviframe to conformant
- * @remarks it also fills indicator_bg part in conformant
- */
- void NaviframeAdd();
-
- /**
- * @brief Creates content for Alarm, World Clock, Stopwatch and Timer pages
- */
- void CreatePages();
-
- /**
- * @brief Creates toolbar buttons.
- */
- void CreateToolbarButtons();
-
- /**
- * @brief Creates toolbar.
- */
- void CreateToolbar();
-
- Evas_Object *window_;
- Evas_Object *conformant_;
- Evas_Object *naviframe_;
-
- /* Content */
- Evas_Object *toolbar_;
-
- IView *alarm_;
- IView *world_clock_;
- IView *stop_watch_;
- IView *timer_;
- };
- }
+namespace view {
+
+ /**
+ * @brief Application main view class
+ * @remarks This is singleton class.
+ */
+ class MainView : public ui::IView {
+ public:
+
+ /**
+ * @brief Retrieves singleton instance.
+ */
+ static MainView &GetInstance();
+
+ /**
+ * @brief Destructor
+ */
+ ~MainView();
+
+ /**
+ * @brief Creates content of application
+ * @remarks It not creates base GUI
+ */
+ void CreateContent();
+
+ /**
+ * @brief Retrieves naviframe object.
+ */
+ Evas_Object *GetEvasObject();
+
+ /**
+ * @briefs Copies this class object instance.
+ * @remarks Customized for singleton purpose - make no effect.
+ */
+ MainView(MainView const&) = delete;
+ /**
+ * @briefs Overloads equation mark.
+ * @remarks Customized for singleton purpose - make no effect.
+ */
+ void operator=(MainView const&) = delete;
+ private:
+
+ /**
+ * @brief Constructs MainView class object
+ * @remarks Creates base GUI
+ */
+ MainView();
+
+ /**
+ * Adds conformant to window.
+ */
+ void ConformantAdd();
+
+ /**
+ * @brief Adds naviframe to conformant
+ * @remarks it also fills indicator_bg part in conformant
+ */
+ void NaviframeAdd();
+
+ /**
+ * @brief Creates content for Alarm, World Clock, Stopwatch and Timer pages
+ */
+ void CreatePages();
+
+ /**
+ * @brief Creates toolbar buttons.
+ */
+ void CreateToolbarButtons();
+
+ /**
+ * @brief Creates toolbar.
+ */
+ void CreateToolbar();
+
+ Evas_Object *window_;
+ Evas_Object *conformant_;
+ Evas_Object *naviframe_;
+
+ /* Content */
+ Evas_Object *toolbar_;
+
+ IView *alarm_;
+ IView *world_clock_;
+ IView *stop_watch_;
+ IView *timer_;
+ };
}
/**
* @{
*/
-namespace worldclock {
- namespace view {
-
- /*
- * @brief Base class for pages(Alarm, World Clock, StopWatch and Timer)
- */
- class PageView : public common::ui::IView {
- public:
-
- /**
- * @brief Constructs class object.
- */
- PageView(const char *title_label, Evas_Object *left_button, Evas_Object *right_button, Evas_Object *content);
- /**
- * @brief Cleans all resources needed to be cleaned up.
- */
- ~PageView();
-
- /**
- * @brief Gets object of the page.
- */
- virtual Evas_Object *GetEvasObject();
-
- /**
- * @brief Creates page content.
- */
- virtual void CreateContent(){};
-
- /**
- * @brief Requests data refresh.
- */
- virtual void RefreshContent(){};
-
- /**
- * @brief Creates new naviframe item page.
- * @remarks Used to create "Add ..." pages in Alarm or World Clock
- */
- virtual void CreateNewNaviPage(){};
-
- protected:
-
- /**
- * Requestes and retrives new naviframe item pushed to naviframe.
- */
- void PushNewNaviPage();
-
- Elm_Object_Item *subpage_;
- const char *title_label_;
- Evas_Object *left_button_;
- Evas_Object *right_button_;
- Evas_Object *content_;
- };
+namespace view {
+
+ /*
+ * @brief Base class for pages(Alarm, World Clock, StopWatch and Timer)
+ */
+ class PageView : public ui::IView {
+ public:
+
+ /**
+ * @brief Constructs class object.
+ */
+ PageView(const char *title_label, Evas_Object *left_button, Evas_Object *right_button, Evas_Object *content);
+ /**
+ * @brief Cleans all resources needed to be cleaned up.
+ */
+ ~PageView();
+
+ /**
+ * @brief Gets object of the page.
+ */
+ virtual Evas_Object *GetEvasObject();
+
+ /**
+ * @brief Creates page content.
+ */
+ virtual void CreateContent(){};
+
+ /**
+ * @brief Requests data refresh.
+ */
+ virtual void RefreshContent(){};
+
+ /**
+ * @brief Creates new naviframe item page.
+ * @remarks Used to create "Add ..." pages in Alarm or World Clock
+ */
+ virtual void CreateNewNaviPage(){};
+
+ protected:
+
+ /**
+ * Requestes and retrives new naviframe item pushed to naviframe.
+ */
+ void PushNewNaviPage();
+
+ Elm_Object_Item *subpage_;
+ const char *title_label_;
+ Evas_Object *left_button_;
+ Evas_Object *right_button_;
+ Evas_Object *content_;
};
};
#include "View/PageView.h"
#include "UI/View.h"
-namespace worldclock {
- namespace view {
+namespace view {
- class StopWatchView : public common::ui::IView {
- public:
- StopWatchView();
- Evas_Object *GetEvasObject(){return stopwatch_;};
+ class StopWatchView : public ui::IView {
+ public:
+ StopWatchView();
+ Evas_Object *GetEvasObject(){return stopwatch_;};
- private:
- Evas_Object *stopwatch_;
- };
- }
+ private:
+ Evas_Object *stopwatch_;
+ };
}
-
#endif /* STOPWATCHVIEW_H_ */
#include "View/PageView.h"
#include "UI/View.h"
-namespace worldclock {
- namespace view {
- class TimerView : public common::ui::IView {
- public:
- TimerView();
- Evas_Object *GetEvasObject(){return timer_;};
+namespace view {
+ class TimerView : public ui::IView {
+ public:
+ TimerView();
+ Evas_Object *GetEvasObject(){return timer_;};
- private:
- Evas_Object *timer_;
- };
- }
+ private:
+ Evas_Object *timer_;
+ };
}
-
#endif /* TIMERVIEW_H_ */
#include "View/PageView.h"
#include "UI/View.h"
-namespace worldclock {
- namespace view {
- class WorldClockView : public common::ui::IView {
- public:
- WorldClockView();
- Evas_Object *GetEvasObject(){return world_clock_;};
+namespace view {
+ class WorldClockView : public ui::IView {
+ public:
+ WorldClockView();
+ Evas_Object *GetEvasObject(){return world_clock_;};
- private:
- Evas_Object *world_clock_;
- };
- }
+ private:
+ Evas_Object *world_clock_;
+ };
}
-
#endif /* WORLDCLOCKVIEW_H_ */
#include "Clock.h"
#include "Controller/MainController.h"
-using namespace worldclock::controller;
+using namespace controller;
static bool
#include "View/MainView.h"
#include "Controller/MainController.h"
-using namespace worldclock::controller;
-using namespace worldclock::view;
+using namespace controller;
+using namespace view;
MainController &MainController::GetInstance()
{
#include "Model/Alarm.h"
#include "Common/Defines.h"
-using namespace common::model;
-using namespace common::utils;
+using namespace model;
+using namespace utils;
static app_control_h AppControlCreate()
{
return activated;
}
-void common::model::Serialize(IWriter &w, AlarmType type)
+void model::Serialize(IWriter &w, AlarmType type)
{
- common::utils::Serialize(w, static_cast<int>(type));
+ utils::Serialize(w, static_cast<int>(type));
}
-void common::model::Deserialize(IReader &r, AlarmType &type)
+void model::Deserialize(IReader &r, AlarmType &type)
{
int tmp;
utils::Deserialize(r, tmp);
utils::Deserialize(r, name);
utils::Deserialize(r, sound.melody);
utils::Deserialize(r, sound.volume);
- common::model::Deserialize(r, type_);
+ model::Deserialize(r, type_);
utils::Deserialize(r, flags);
utils::Deserialize(r, activated);
utils::Deserialize(r, snooze_enabled);
utils::Serialize(w, name);
utils::Serialize(w, sound.melody);
utils::Serialize(w, sound.volume);
- common::model::Serialize(w, type_);
+ model::Serialize(w, type_);
utils::Serialize(w, flags);
utils::Serialize(w, activated);
utils::Serialize(w, snooze_enabled);
static const char DATABASE_FILE[] = "alarmsdb.cfg";
-using namespace common::model;
-using namespace common::utils;
-using namespace internal::model;
+using namespace model;
+using namespace utils;
+using namespace internal;
AlarmProvider *AlarmProvider::GetInstance()
{
#include <cstdlib>
#include <algorithm>
-using namespace internal::model;
-using namespace common::model;
-using namespace common::utils;
+using namespace internal;
+using namespace model;
+using namespace utils;
const int AlarmProviderFile::db_schema_version = 1;
-void AlarmProviderFile::Add(common::model::Alarm& alarm)
+void AlarmProviderFile::Add(model::Alarm& alarm)
{
auto it = std::find(alarms.begin(), alarms.end(), alarm);
//FIXME emit AlarmAddedEvent
}
-void AlarmProviderFile::Remove(common::model::Alarm& alarm)
+void AlarmProviderFile::Remove(model::Alarm& alarm)
{
auto it = std::find(alarms.begin(), alarms.end(), alarm);
AlarmProviderFile::AlarmProviderFile(IReader &r)
{
- common::utils::Deserialize(r, alarms);
+ utils::Deserialize(r, alarms);
}
AlarmProviderFile::~AlarmProviderFile()
{
}
-std::vector<std::reference_wrapper<common::model::Alarm>> AlarmProviderFile::GetAlarms()
+std::vector<std::reference_wrapper<model::Alarm>> AlarmProviderFile::GetAlarms()
{
- return std::vector<std::reference_wrapper<common::model::Alarm>>(
+ return std::vector<std::reference_wrapper<model::Alarm>>(
alarms.begin(),
alarms.end());
}
return nullptr;
}
-void AlarmProviderFile::Serialize(common::utils::IWriter &w) const
+void AlarmProviderFile::Serialize(utils::IWriter &w) const
{
- common::utils::Serialize(w, alarms);
+ utils::Serialize(w, alarms);
}
#include <algorithm>
-using namespace internal::model;
-using namespace common::model;
-using namespace common::utils;
+using namespace internal;
+using namespace model;
+using namespace utils;
AlarmProviderStub::AlarmProviderStub(IReader &r)
{
#include <Model/WeekFlags.h>
-using namespace common::model;
+using namespace model;
WeekFlags::WeekFlags() {
raw_flags = 0;
#include "Presenter/AlarmPresenter.h"
#include "log.h"
-using namespace worldclock::presenters;
-using namespace worldclock::view;
-using namespace common::model;
+using namespace presenter;
+using namespace view;
+using namespace model;
AlarmPresenter::AlarmPresenter(AlarmView *v, AlarmProvider *m) : model(m), view(v)
{
#include <cstdlib>
#include <cstring>
-using namespace common::utils;
+using namespace utils;
using namespace std;
BinaryFileReader::BinaryFileReader(Utils::AppSubdirectory dir, const char *filename)
#include <fstream>
-using namespace common::utils;
+using namespace utils;
using namespace std;
BinaryFileWriter::BinaryFileWriter(Utils::AppSubdirectory dir, const char *filename) :
#include "Utils/Time.h"
#include <utils_i18n.h>
-using namespace common::utils;
+using namespace utils;
Time::Time(utils::IReader &r)
{
#include <Elementary.h>
#include <limits.h>
-using namespace common::utils;
+using namespace utils;
const char *Utils::GetAppResourcePath(enum AppSubdirectory dir, const char *relative)
{
#include "log.h"
-using namespace worldclock::view;
-using namespace common::model;
-using namespace common::utils;
+using namespace view;
+using namespace model;
+using namespace utils;
struct ItemData {
AlarmView *instance;
#include "Presenter/AlarmPresenter.h"
#include "Model/AlarmProvider.h"
-using namespace worldclock::view;
-using namespace worldclock::presenters;
-using namespace common::utils;
-using namespace common::model;
+using namespace view;
+using namespace presenter;
+using namespace utils;
+using namespace model;
static void WinDeleteRequestCb(void *data, Evas_Object *obj, void *event_info)
#include <stdlib.h>
-using namespace worldclock::view;
-using namespace common::utils;
+using namespace view;
+using namespace utils;
PageView::PageView(const char *title_label, Evas_Object *left_button, Evas_Object *right_button, Evas_Object *content) :
title_label_(title_label), left_button_(left_button), right_button_(right_button), content_(content)
#include "View/MainView.h"
#include "Utils/Utils.h"
-using namespace worldclock::view;
-using namespace common::utils;
+using namespace view;
+using namespace utils;
StopWatchView::StopWatchView()
{
#include "View/MainView.h"
#include "Utils/Utils.h"
-using namespace worldclock::view;
-using namespace common::utils;
+using namespace view;
+using namespace utils;
TimerView::TimerView()
#include "View/MainView.h"
#include "Utils/Utils.h"
-using namespace worldclock::view;
-using namespace common::utils;
+using namespace view;
+using namespace utils;
WorldClockView::WorldClockView()
{