# spaces.
# Note: If this tag is empty the current directory is searched.
-INPUT = clock/inc/Utils clock/inc/Model clock/inc/View clock/inc/Controller clock/inc/Presenter clock/inc/Common clock/src/Utils clock/src/Model clock/src/View clock/src/Controller clock/src/Presenter clock/src/Common
+INPUT = clock/inc/Utils clock/inc/Model clock/inc/View clock/inc/Controller clock/inc/Presenter clock/inc/Common clock/inc/Internal clock/src/Utils clock/src/Model clock/src/View clock/src/Controller clock/src/Presenter clock/src/Common
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
#include "Utils/Serialization.h"
namespace internal {
+ /**
+ * @brief Binary storage for Alarm list
+ */
class AlarmBinaryStorage : utils::ISerializable
{
public:
+ /**
+ * @brief Fetch alarms from database
+ */
std::vector<std::reference_wrapper<model::Alarm>> GetAlarms();
+
+ /**
+ * @brief Fetch alarms with id from database
+ * @param[in] id id of the alarm.
+ */
model::Alarm* GetAlarmWithId(model::AlarmId id);
+
+ /**
+ * @brief Add alarm to database
+ * @param[in] alarm reference.
+ */
void Add(model::Alarm& alarm);
+
+ /**
+ * @brief Remove alarm from database
+ * @param[in] alarm reference obtained from GetAlarms()
+ */
void Remove(std::reference_wrapper<model::Alarm> alarm);
+
+ /**
+ * @brief Constructor
+ * @param[in] r reader interface.
+ */
AlarmBinaryStorage(utils::IReader &r);
+
+ /**
+ * @brief Default destructor
+ */
virtual ~AlarmBinaryStorage();
+
void Serialize(utils::IWriter &w) const;
+
+ /**
+ * @brief Return capactiy of database.
+ * @return max number of elements possible to append to database.
+ */
int Capacity() const;
+
+ /**
+ * @brief Return if database capacity is reached.
+ * @return true if strage capacity is reached, false otherwise.
+ */
bool IsFull() const;
- bool HasActiveAlarms();
private:
std::list<model::Alarm> alarms;
- static const int db_schema_version;
};
} /* internal */
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);
+ /**
+ * @brief Alarm is a wrapper class arount platform's alarm system.
+ * It implements scheduling, rescheduling, canceling alarms and also
+ * managing snoozing feature.
+ */
class Alarm : public utils::ISerializable {
public:
+ /**
+ * @brief Alarm type
+ */
+ enum class Type {
+ SOUND_ONLY, /** Sound only on trigger */
+ VIBRATION, /** Vibration only on trigger */
+ VIBRATION_AND_SOUND /** Vibration and sound on trigger */
+ };
+ /**
+ * @brief Defaul constructor
+ */
Alarm();
- Alarm(utils::IReader &);
+
+ /**
+ * @brief Constructs Alarm instance from reader's data.
+ * @param[in] r reader inteface.
+ */
+ Alarm(utils::IReader &r);
+
+ /**
+ * @brief Activates alarm
+ * @details Activates means that alarm is scheduled.
+ */
void Activate();
+
+ /**
+ * @brief Check activation status
+ * @return activated status.
+ */
bool IsActivated() const;
+
+ /**
+ * @brief Deactivates alarm
+ * @details Removes alarm from scheduled alarms.
+ */
void Deactivate();
+
+ /**
+ * @brief Snooze alarm
+ *
+ * @details This function schedules additional alarm that will be called
+ * after GetSnoozeInterval seconds.
+ *
+ * If IsSnoozeEnabled returns false, this function do nothing.
+ * Function increases also also internal snooze attempt counter.
+ * If snooze attempt counter exceeds GetSnoozeMaxAttempts this function
+ * do nothing.
+ */
void Snooze();
+
+ /**
+ * @brief Enable snoozing feature on alarm
+ */
void EnableSnooze();
+
+ /**
+ * @brief Disable snoozing feature on alarm
+ */
void DisableSnooze();
+
+ /**
+ * @brief Check if snoozing feature is enabled
+ * @return true if snooze is enabled for alarm, false otherwise.
+ */
bool IsSnoozeEnabled() const;
+
+ /**
+ * @brief Check if snoozing is possible.
+ *
+ * @details This means that IsSnoozeEnabled must return true
+ * and snooze attempts hasn't been exceeded.
+ *
+ * @return true if 'Snooze' can be invoked on alarm, false otherwise.
+ */
bool CanSnooze() const;
+
+ /**
+ * @brief Sets time interval between snooze alarms
+ * @param[in] seconds number of seconds for Snooze to be scheduled.
+ */
void SetSnoozeInterval(unsigned int seconds);
+
+ /**
+ * @brief Gets time interval between snooze alarms
+ * @return number of seconds till snooze alarm fires.
+ */
unsigned int GetSnoozeInterval() const;
- void SetSnoozeMaxAttemps(unsigned int attemps);
+
+ /**
+ * @brief Sets snooze max attempts.
+ * @param[in] attempts number of possible attempts of Snooze.
+ */
+ void SetSnoozeMaxAttemps(unsigned int attempts);
+
+ /**
+ * @brief Get snooze max attempts.
+ * @return maximum possible attempts of 'Snooze' for alarm.
+ */
unsigned int GetSnoozeMaxAttempts() const;
+
+ /**
+ * @brief Get alarm human-readable name.
+ * @return alarm's current name.
+ */
std::string GetName() const;
+
+ /**
+ * @brief Set alarm human-readable name.
+ * @param[in] name new alarm name.
+ */
void SetName(std::string name);
+
+ /**
+ * @brief Get alarm schedule time.
+ * @return time
+ */
utils::Time GetTime() const;
+
+ /**
+ * @brief Set alarm schedule time.
+ * @param time alarm's time.
+ */
void SetTime(utils::Time time);
+
+ /**
+ * @brief Get melody file filepath.
+ * @return melody file path.
+ */
std::string GetMelody() const;
+
+ /**
+ * @brief Set melody file filepath.
+ * @param[in] path file path.
+ */
void SetMelody(std::string path);
- AlarmType GetType() const;
- void SetType(AlarmType pattern);
+
+ /**
+ * @brief Get type of alarm.
+ * @return alarm type.
+ */
+ Type GetType() const;
+
+ /**
+ * @brief Set type of alarm.
+ * @param[in] type new alarm type
+ */
+ void SetType(Type type);
+
+ /**
+ * @brief Get week flags of alarm.
+ *
+ * @details The alarms can be scheduled on given time returned by GetTime
+ * for particular days of the week.
+ *
+ * @return current week flags of the alarm.
+ *
+ * @see GetTime()
+ */
WeekFlags GetWeekFlags() const;
+
+ /**
+ * @brief Set week flags of alarm.
+ * @param[in] flags new week flags for alarm.
+ */
void SetWeekFlags(WeekFlags flags);
+
+ /**
+ * @brief Serialize Alarm using writer interface
+ * @param[in] w writer interface.
+ */
void Serialize(utils::IWriter &w) const;
+
+ /**
+ * @brief Gets volume value, between 0.0 - 1.0
+ * @return volume value.
+ */
double GetVolume() const;
+
+ /**
+ * @brief Set volume value, between 0.0 - 1.0
+ *
+ * @remarks If value exceed 0.0 - 1.0 bounds it will adjusted
+ * to nearest bound.
+ *
+ * @param[in] volume new volume value.
+ */
void SetVolume(double volume);
+
+ /**
+ * @brief Dismiss alarm
+ *
+ * @details This means that alarm snooze attempts counter has been reseted.
+ */
void Dismiss();
- /** 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) || (this->snooze.alarm_id == id); }
- private:
- int alarm_id;
- std::string name;
- struct {
- std::string melody;
- double volume;
- } sound;
- std::string vibration;
- WeekFlags flags;
- bool activated;
- bool snooze_enabled;
- AlarmType type_;
- struct {
+ /** 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); }
+ /** Two alarms are considered same if they have same AlarmId */
+ inline bool operator==(const AlarmId id) { return (this->alarm_id == id) || (this->snooze.alarm_id == id); }
+ private:
int alarm_id;
- unsigned int interval;
- unsigned int attempt;
- unsigned int attempts_max;
- } snooze;
- utils::Time time;
+ std::string name;
+ struct {
+ std::string melody;
+ double volume;
+ } sound;
+ std::string vibration;
+ WeekFlags flags;
+ bool activated;
+ bool snooze_enabled;
+ Type type_;
+ struct {
+ int alarm_id;
+ unsigned int interval;
+ unsigned int attempt;
+ unsigned int attempts_max;
+ } snooze;
+ utils::Time time;
};
+ void Deserialize(utils::IReader &w, Alarm::Type &type);
+ void Serialize(utils::IWriter &w, Alarm::Type type);
} /* model */
#endif
#include "Model/Alarm.h"
namespace model {
+ /**
+ * @brief Global event that is broadcast request to create new
+ * alarm.
+ */
class AlarmCreateRequestEvent : public utils::Event {
};
+
+ /**
+ * @brief Global event that is broadcast request to delete alarms.
+ */
class AlarmDeleteRequestEvent : public utils::Event {
};
+
+ /**
+ * @brief Global event that is broadcast information that alarm
+ * data should be modified.
+ */
class AlarmEditRequestEvent : public utils::Event {
public:
+ /**
+ * @brief Creates AlarmEditRequestEvent instance
+ * @param[in] alarm alarm which is a target of edition.
+ */
AlarmEditRequestEvent(model::Alarm& alarm) : alarm_(alarm) {}
+ /**
+ * @brief Gets modification target
+ * @return Alarm to be edited.
+ */
Alarm &GetAlarm() const { return alarm_;}
private:
Alarm &alarm_;
};
+
+ /**
+ * @brief Global event that is broadcast information that alarm
+ * data has been modified.
+ */
class AlarmEditedEvent : public utils::Event {
public:
+ /**
+ * @brief Creates AlarmEditedEvent instance
+ * @param[in] alarm alarm which has been edited.
+ */
AlarmEditedEvent(model::Alarm& alarm) : alarm_(alarm) {}
+ /**
+ * @brief Gets modification target
+ * @return Alarm which have been edited.
+ */
Alarm &GetAlarm() const { return alarm_;}
private:
Alarm &alarm_;
#include <functional>
namespace model {
+ /**
+ * @brief Class providing list of currently registered alarms.
+ */
class AlarmProvider {
public:
/**
/**
* @brief Fetch alarms from provider's internal storage
+ * @return vector of alarm references.
*/
std::vector<std::reference_wrapper<Alarm>> GetAlarms();
/**
* @brief Get Alarms with specific id.
+ * @param[in] id alarm id.
*/
Alarm *GetAlarmWithId(AlarmId id);
/**
* @brief Add alarm to provider database.
+ * @param[in] alarm alarm's reference.
*/
void Add(Alarm& alarm);
/**
* @brief Remove alarm from provider's database.
+ * @param[in] alarm alarm's reference.
*/
void Remove(std::reference_wrapper<Alarm> alarm);
/**
* @brief Return capactiy of provider's internal storage
+ * @return capacity of provider's storage.
*/
int Capacity() const;
/**
- * @brief Check if provider's internal storage is full.
+ * @brief Checks if provider's internal storage is full.
+ * @return true if strage capacity is reached, false otherwise.
*/
bool IsFull() const;
/**
* @brief returns true if container have any active alarms.
+ * @return true if any active if container have any active alarms,
+ * false otherwise.
*/
bool HasActiveAlarms();
private:
#include "Model/Alarm.h"
namespace model {
+ /**
+ * @brief Global event that is announce that alarm was added to Provider
+ */
class AlarmAddedEvent : public utils::Event {
public:
+ /**
+ * @brief Creates AlarmAddedEvent instance
+ * @param alarm added alarm.
+ */
AlarmAddedEvent(Alarm &alarm) : alarm_(alarm) {}
+ /**
+ * @brief Gets event target
+ * @return added alarm.
+ */
Alarm& GetAlarm() { return alarm_; }
private:
Alarm &alarm_;
};
+
+ /**
+ * @brief Global event that is announce that alarm was removed from Provider
+ */
class AlarmRemovedEvent : public utils::Event {
public:
+ /**
+ * @brief Creates AlarmRemovedEvent instance
+ * @param alarm removed alarm reference.
+ */
AlarmRemovedEvent(Alarm &alarm) : alarm_(alarm) {}
+ /**
+ * @brief Gets event target
+ * @return removed alarm reference.
+ */
Alarm& GetAlarm() { return alarm_; }
private:
Alarm &alarm_;
#include <app_alarm.h>
namespace model {
+ /** @brief Week flag enumarator */
enum class WeekDay : int {
MONDAY = ALARM_WEEK_FLAG_MONDAY,
TUESDAY = ALARM_WEEK_FLAG_TUESDAY,
ALL_WEEK = (MONDAY | TUESDAY | WEDNESDAY | THURSDAY | FRIDAY | SATURDAY | SUNDAY),
WEEKEND = (SATURDAY | SUNDAY),
};
+ /** @brief Day mask creation */
inline constexpr WeekDay
operator|(WeekDay a, WeekDay b)
{
return static_cast<WeekDay>(static_cast<int>(a) | static_cast<int>(b));
}
+ /**
+ * @brief WeekFlags is a set for WeekDay values.
+ */
class WeekFlags : public utils::ISerializable {
public:
+ /**
+ * @brief Default constructor. None week flag is set
+ */
WeekFlags();
+
+ /**
+ * @brief Constructos WeekFlags instance from reader interface.
+ * @param[in] r reader inteface.
+ */
WeekFlags(utils::IReader &r);
+
+ /**
+ * @brief Default constructor using WeekDay flags
+ * @param[in] day day mask.
+ */
WeekFlags(WeekDay day);
+
+ /**
+ * @brief Add day to flags
+ * @param[in] day flag to be added.
+ */
void AddDay(WeekDay day);
+
+ /**
+ * @brief Remove day flag from week flags
+ * @param[in] day to remove.
+ */
void RemoveDay(WeekDay day);
+
+ /**
+ * @brief Check if flag is set for given day
+ * @param[in] day to check.
+ * @return true, if week flag is set for particular day, false
+ * otherwise.
+ */
bool IsOn(WeekDay day);
+
+ /**
+ * @brief Check if week flags is empty
+ * @return true if week flags empty.
+ */
bool Empty() const;
+
void Serialize(utils::IWriter &w) const;
+
+ /**
+ * @brief Check raw representation (int) of week flags
+ * @return bit mask with WeekDay flags.
+ */
int GetBitMask() const;
+
+ /**
+ * @brief Comparing operator
+ * @param[in] a WeekFlags reference.
+ */
inline bool operator==(const WeekFlags &a) const { return a.raw_flags == raw_flags; }
private:
int raw_flags;
#include <vector>
namespace presenter {
+ /**
+ * @brief class managing displaying information on AlarmView and updating data in
+ * AlarmProvider class.
+ */
class AlarmPresenter {
public:
+ /**
+ * @brief Constructs object instance
+ * @param view AlarmView instance which presenter will be managing
+ * @param model AlarmProvider instance which presenter will be managing
+ */
AlarmPresenter(view::AlarmView *view, model::AlarmProvider *model);
~AlarmPresenter();
private:
#include <map>
namespace presenter {
+ /**
+ * @brief class managing displaying information on DeleteAlarmView and updating data in
+ * AlarmProvider class.
+ */
class DeleteAlarmPresenter {
public:
+ /**
+ * @brief Constructs object instance
+ * @param view DeleteAlarmView instance which presenter will be managing
+ * @param model AlarmProvider instance which presenter will be managing
+ */
DeleteAlarmPresenter(view::DeleteAlarmView *view, model::AlarmProvider *model);
~DeleteAlarmPresenter();
private:
#include "Model/AlarmProvider.h"
namespace presenter {
+ /**
+ * @brief Class managing displaying information on EditAlarmView and updating data in
+ * AlarmProvider model.
+ */
class EditAlarmPresenter {
public:
+ /**
+ * @brief Constructs object instance
+ *
+ * @param provider AlarmProvider instance which presenter will be managing
+ * @param alarm the instance of Alarm which should be edited
+ * @param view Einstance which presenter will be managing
+ */
EditAlarmPresenter(model::AlarmProvider *provider, model::Alarm *alarm, view::EditAlarmView& view);
~EditAlarmPresenter();
private:
#include <vector>
namespace utils {
+ /**
+ * @brief class allowing to read binary data from file.
+ */
class BinaryFileReader : public IReader {
public:
+ /**
+ * @brief Constructs object instance
+ * @param dir the application accessible directory
+ * @param filename file name.
+ */
BinaryFileReader(Utils::AppSubdirectory dir, const char *filename);
~BinaryFileReader() {}
void Read(void *buffer, size_t size);
#include <fstream>
namespace utils {
+ /**
+ * @brief class allowing to write binary data to file.
+ */
class BinaryFileWriter : public IWriter {
public:
+ /**
+ * @brief Constructs object instance
+ * @param dir the application accessible directory
+ * @param filename file name.
+ */
BinaryFileWriter(Utils::AppSubdirectory dir, const char *filename);
~BinaryFileWriter();
void Write(const void *buffer, size_t size);
+ /**
+ * @brief Flushes data to file.
+ */
void Flush();
private:
std::ofstream file;
/**
* @brief Fire event. This means running all listener registered
- * with @AddListener function.
+ * with AddListener function.
+ *
+ * @param[in] event to fire.
*/
static void FireEvent(Event&);
#include <cstdlib>
namespace utils {
+ /**
+ * @brief Abstract interface for reading binary data
+ */
class IReader {
public:
+ /**
+ * @brief reads size bytes to buffer
+ *
+ * @param[in] buffer to copy data to.
+ * @param[in] size number of bytes to copy.
+ */
virtual void Read(void *buffer, size_t size) = 0;
virtual ~IReader() {}
};
namespace utils {
+/**
+ * @brief Utility class simpifying requesting ringtones from system dialogs.
+ */
class RingtonePicker {
public:
/**
#include <string>
namespace utils {
+ /**
+ * @brief Abstract interface serializing data.
+ */
class ISerializable {
public:
ISerializable() {}
+ /**
+ * @brief constructs object using reader interface.
+ *
+ * @param[in] reader interface
+ */
ISerializable(IReader &reader) {}
+
+ /**
+ * @brief Serializes object using writer interface.
+ *
+ * @param writer interface
+ */
virtual void Serialize(IWriter &writer) const = 0;
virtual ~ISerializable() {}
};
#include <utils_i18n.h>
namespace utils {
+ /**
+ * @brief Utility class for managing time/dates using Gregorian calendar.
+ */
class Time : public utils::ISerializable {
public:
/**
*/
class PreferedTimeFormatChanged : public utils::Event {
};
- /** Predefined formats for convenience */
+ /** @brief Predefined string for 12-hour format */
static const char *FORMAT_TIME_12H;// = "h:mm";
+ /** @brief Predefined string for 32-hour format */
static const char *FORMAT_TIME_24H; // = "HH:mm";
+ /** @brief Predefined string for meridiem */
static const char *FORMAT_TIME_AMPM; // = "a";
+ /** @brief Year's month. */
enum class Month {
January = I18N_UCALENDAR_JANUARY,
Febuary = I18N_UCALENDAR_FEBRUARY,
December = I18N_UCALENDAR_DECEMBER,
};
+ /** @brief Default constructor */
Time() : timezone_(GetCurrentTimezone()), milliseconds_(0) {}
/**
*
* @param[in] timezone valid timezone id.
*
- * @ret difference in minutes between "timezone" and GMT:+00
+ * @return difference in minutes between "timezone" and GMT:+00
* @note return INT_MAX when timezone string is invalid.
*/
static int GetTimezoneOffset(const char *timezone);
#include <cstdlib>
namespace utils {
+ /**
+ * @brief Abstract interface for writing binary data
+ */
class IWriter {
public:
+ /**
+ * @brief Writes size bytes from buffer
+ *
+ * @param[in] buffer to copy data from.
+ * @param[in] size number of bytes to copy.
+ */
virtual void Write(const void *buffer, size_t size) = 0;
virtual ~IWriter() {}
};
#include <functional>
namespace view {
+ /**
+ * @brief View showing list of items which can be clicked.
+ *
+ * @note additionally displays "+" button and can display menu popup
+ */
class AlarmView : public ui::IView {
public:
+ /** @brief Generic event function */
typedef std::function<void(int)> SelectCallback;
+ /** @brief Selected event. Selected item identifier is passed in parameter. */
typedef std::function<void(int)> ToggleCallback;
+ /** @brief Generic event function */
typedef std::function<void(void)> ButtonClickedCallback;
+ /** @brief Generic event function */
typedef std::function<void(void)> MenuButtonClickedCallback;
+ /**
+ * @brief Creates AlarmView instance
+ * @param main MainView instance
+ */
AlarmView(ui::IView &main);
+
+ /**
+ * @brief Clear all items.
+ */
void Clear();
+
+ /**
+ * @brief Appends item to view.
+ *
+ * @param[in] time time to be displayed.
+ * @param[in] name name to be displayed.
+ * @param[in] flags weekflags to be displayed.
+ * @param[in] active item active status.
+ *
+ * @return return item identiefier.
+ */
int ItemAppend(utils::Time time, const char *name,
const model::WeekFlags flags, bool active);
+
+ /**
+ * @brief Remove item from view.
+ * @param idx item identifier.
+ */
void RemoveItem(int idx);
+
+ /**
+ * @brief Updates item.
+ *
+ * @param[in] idx index of item to be updated.
+ * @param[in] time time to be displayed.
+ * @param[in] name name to be displayed.
+ * @param[in] flags weekflags to be displayed.
+ * @param[in] active item active status.
+ */
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);
+ /**
+ * @brief Registers callback emitted when user has cancelled edit
+ * operation.
+ *
+ * @param[in] func callback to register.
+ */
+ void SetItemToggleCallback(ToggleCallback func) { onToggled_ = func; }
+
+ /**
+ * @brief Registers callback emitted when user has selected item on
+ * list.
+ *
+ * @param[in] func callback to register.
+ */
+ void SetItemSelectCallback(SelectCallback func) { onSelected_ = func; }
+
+ /**
+ * @brief Registers callback emitted when user has clicked "+" floating button
+ *
+ * @param[in] func callback to register.
+ */
+ void SetButtonClickedCallback(ButtonClickedCallback func) { onClicked_ = func; }
+
+ /**
+ * @brief Registers callback emitted when user clicked Delete Item
+ * on Delete popup
+ *
+ * @param[in] func callback to register.
+ */
void SetDeleteItemClickedCallback(ButtonClickedCallback func) { onDeleteClicked_ = func;}
+ /**
+ * @brief Registers callback emitted when user clicked "Menu" hardware button
+ *
+ * @param[in] func callback to register.
+ */
void SetMenuButtonClickedCallback(MenuButtonClickedCallback func) { onMenuClicked_ = func;}
Evas_Object *GetEvasObject();
+ /**
+ * @brief Shows "No Alarms" message in list background
+ */
void ShowNoAlarmsBackgroundLabel();
+
+ /**
+ * @brief Hides "No Alarms" message in list background
+ */
void HideNoAlarmsBackgroundLabel();
/**
* @brief Shows popup window with specified text
+ *
+ * @param[in] text text to be displayed on popup.
*/
void ShowPopup(const std::string &text);
#include <vector>
namespace view {
+ /**
+ * @brief View showing list of items which can be selected/unselected
+ */
class DeleteAlarmView : public PageView {
public:
+ /** @brief Generic event function */
typedef std::function<void(void)> ButtonClickedCallback;
- DeleteAlarmView(ui::IView &main);
+ /**
+ * @brief Creates DeleteAlarmView instance
+ *
+ * @param main MainView instance
+ */
+ DeleteAlarmView(view::MainView &main);
+
+ /**
+ * @brief Destructor
+ */
~DeleteAlarmView();
+ /**
+ * @brief Registers callback emitted when cancel button is clicked
+ *
+ * @param[in] cb callback to register.
+ */
void RegisterCancelButtonClickedCallback(ButtonClickedCallback cb) { onCancelButtonClicked_ = cb; }
+
+ /**
+ * @brief Registers callback emitted when delete button is clicked
+ *
+ * @param[in] cb callback to register.
+ */
void RegisterDeleteButtonClickedCallback(ButtonClickedCallback cb) { onDeleteButtonClicked_ = cb; }
Evas_Object *GetEvasObject() { return content_; }
+ /**
+ * @brief Appends item to view.
+ *
+ * @param[in] time time to be displayed.
+ * @param[in] name name to be displayed.
+ * @param[in] flags weekflags to be displayed.
+ * @param[in] active item active status.
+ *
+ * @return item identifier.
+ */
int ItemAppend(utils::Time time, const char *name,
const model::WeekFlags flags, bool active);
+
+ /**
+ * @brief Gets identifiers of selected items.
+ *
+ * @return vector of selected items indentifiers.
+ */
std::vector<int> GetSelectedItems() const;
protected:
virtual void CreateContent(Evas_Object *parent);
#include "Utils/RingtonePicker.h"
namespace view {
+ /**
+ * @brief Displays PageView with alarm information data.
+ */
class EditAlarmView : public PageView {
public:
+ /**
+ * @brief Data model displayed on EditAlarmView
+ */
struct AlarmViewInfo {
+ /** @brief Time to be set on datetime widget */
utils::Time time;
+ /** @brief WeekFlags to be displayed on list item */
model::WeekFlags flags;
+ /** @brief volume value to be set on slider */
double volume;
+ /** @brief snooze flag to set on checkbox */
bool snooze;
+ /** @brief name to be displayed in entry field. */
std::string name;
+ /** @brief path to be displayed on list item */
std::string melody;
- model::AlarmType type;
+ /** @brief type to be displayed on list item */
+ model::Alarm::Type type;
};
/**
* @brief Possible view modes.
Edit, /* Edit existing alarm mode */
Create, /* Create new alarm mode */
};
+
+ /**
+ * @brief Option enumerator
+ */
enum class DiscardPopupOption {
- CANCEL,
- DISCARD
+ CANCEL, /** User has requested to cancel discard operation */
+ CONFIRM /** User has requested to confirmed discard operation */
};
- typedef std::function<void(AlarmViewInfo)> EditDoneCallback;
+
+ /** @brief Generic event function */
+ typedef std::function<void(void)> EditDoneCallback;
+ /** @brief Generic event function */
typedef std::function<void(void)> EditCancelCallback;
+ /** @brief Generic event function */
typedef std::function<void(void)> BackButtonCallback;
+ /** @brief Event with operation result */
typedef std::function<void(DiscardPopupOption)> DiscardPopupCallback;
+ /**
+ * @brief Registers callback emitted when user has finished edit
+ * operation.
+ *
+ * @param[in] cb callback to register.
+ */
void RegisterEditDoneCallback(EditDoneCallback cb) { onEditDone_ = cb; }
+
+ /**
+ * @brief Registers callback emitted when user has cancelled edit
+ * operation.
+ *
+ * @param[in] cb callback to register.
+ */
void RegisterEditCancelCallback(EditCancelCallback cb) { onEditCancel_ = cb; }
/**
* @brief Registers callback emitted when back button is clicked
+ *
+ * @param[in] cb callback to register.
*/
void RegisterBackButtonCallback(BackButtonCallback cb) { onBackButton = cb; }
/**
* @brief Registers callback emitted when option has been chosen on
* discard popup
+ *
+ * @param[in] cb callback to register.
*/
void RegisterDiscardPopupCallback(DiscardPopupCallback cb) { onDiscardPopupCallback = cb; }
- EditAlarmView(ui::IView &main);
+ /**
+ * @brief Constructor
+ * @param main MainView instance
+ */
+ EditAlarmView(view::MainView &main);
+ /**
+ * @brief Destructor
+ */
~EditAlarmView();
+
Evas_Object *GetEvasObject();
+ /**
+ * @brief Get current values of edited data.
+ * @return AlarmViewInfo containing data from UI.
+ */
const AlarmViewInfo& GetData() const { return data_; }
+
+ /**
+ * @brief Set data to be displayed on view.
+ *
+ * @param info data to be displayed.
+ */
void SetData(const AlarmViewInfo &info);
/**
* @brief Set view mode.
+ *
+ * @param mode new view mode.
*/
void SetMode(Mode mode) { mode_ = mode; }
/**
* @brief Get view mode.
+ *
+ * @return view mode.
*/
Mode GetMode() const { return mode_; }
/**
* @brief Shows toast popup window
+ *
+ * @param[in] text text to be displayed on popup.
*/
void ShowPopup(const std::string &text);
/**
* @brief Check if disard popup is visible
+ *
+ * @return true if discard popup is visible, false otherwise.
*/
bool IsDiscardPopupVisible() const;
#include <Evas.h>
-#include "View/PageView.h"
#include "View/View.h"
/**
#define NAVIFRAME_PAGE_VIEW_H_
#include <Elementary.h>
+#include "View/MainView.h"
#include "View/View.h"
#include <vector>
#include <functional>
/**
- * @file pageView.h
+ * @file PageView.h
*/
/**
namespace view {
- /*
- * @brief Base class for pages(Alarm, World Clock, StopWatch and Timer)
+ /**
+ * @brief Base class for pages (Alarm, World Clock, StopWatch and Timer)
*/
class PageView : public ui::IView {
public:
-
/**
* @brief Constructs class object.
+ *
+ * @param main MainView instance
*/
- PageView(ui::IView &main);
+ PageView(view::MainView &main);
/**
* @brief Cleans all resources needed to be cleaned up.
virtual Evas_Object *GetEvasObject() = 0;
/**
- * Requestes and retrives new naviframe item pushed to naviframe.
+ * @brief Pushed page on MainView.
+ * @details The PageView becomes top-level on pages stack.
+ * Function calls CreateContent virtual methods.
*/
void PushPage();
/**
- * Requestes naviframe to pop page.
+ * @brief Pops page from MainView.
+ *
+ * @details Function calls CreateContent virtual methods.
*/
void PopPage();
- /*
- * Registers page popped callback
+ /**
+ * @brief Registers page popped callback
*/
void RegisterPoppedCallback(std::function<void(void)>);
protected:
+ /**
+ * @brief elm_naviframe item handle
+ */
Elm_Object_Item *navi_item_;
/**
- * Returns naviframe parent of the page.
+ * @brief Returns naviframe parent of the page.
*/
Evas_Object *GetNaviframe();
private:
#include <Elementary.h>
namespace ui {
+ /**
+ * @brief Abstract interface representing Native UI toolkit object.
+ */
class IView {
public:
+ /**
+ * @brief Get Native UI toolkit representation
+ */
virtual Evas_Object *GetEvasObject() = 0;
virtual ~IView() {}
};
#include <list>
namespace view {
+ /**
+ * @brief WeekFlags class is a PagView view that
+ * enables user to edit WeekFlags data.
+ */
class WeekFlagsView : public PageView {
public:
- WeekFlagsView(ui::IView &main, model::WeekFlags &flags);
+ /**
+ * @brief Creates instance of WeekFlags view
+ *
+ * @param main parent view
+ * @param flags model::WeekFlags to be edited
+ */
+ WeekFlagsView(view::MainView &main, model::WeekFlags &flags);
Evas_Object *GetEvasObject();
protected:
virtual void CreateContent(Evas_Object *parent);
/**
* @brief Creates Class object, push new page and invokes CreateContent().
+ * @param main MainView reference.
*/
- WorldClockDeleteItemsView(ui::IView &main);
+ WorldClockDeleteItemsView(view::MainView &main);
/**
* @brief Destroy all resources that can not be deleted automatically
};
/**
- * @brief Creates Class object, push new page and invokes CreateContent().
+ * @brief Creates Class object.
*/
- WorldClockReorderView(ui::IView &main);
+ WorldClockReorderView(view::MainView &main);
/**
* @brief Destroy all resources that can not be deleted automatically
sound.melody = path;
}
-AlarmType Alarm::GetType() const
+Alarm::Type Alarm::GetType() const
{
return type_;
}
-void Alarm::SetType(AlarmType type)
+void Alarm::SetType(Alarm::Type type)
{
type_ = type;
}
return activated;
}
-void model::Serialize(IWriter &w, AlarmType type)
+void model::Serialize(IWriter &w, Alarm::Type type)
{
utils::Serialize(w, static_cast<int>(type));
}
-void model::Deserialize(IReader &r, AlarmType &type)
+void model::Deserialize(IReader &r, Alarm::Type &type)
{
int tmp;
utils::Deserialize(r, tmp);
- type = static_cast<AlarmType>(tmp);
+ type = static_cast<Alarm::Type>(tmp);
}
Alarm::Alarm(IReader &r)
void Alarm::SetVolume(double volume)
{
+ if (volume < 0.0) volume = 0.0;
+ if (volume > 1.0) volume = 1.0;
sound.volume = volume;
}
using namespace model;
using namespace utils;
-const int AlarmBinaryStorage::db_schema_version = 1;
const int AVAILABLE_ALARMS_MAX = 20;
data.volume = 0.7;
data.melody = Utils::GetAppResourcePath(
Utils::APP_DIR_RESOURCE, SOUND_DEFAULT);
- data.type = AlarmType::SOUND_ONLY;
+ data.type = Alarm::Type::SOUND_ONLY;
data.name = "";
return data;
case EditAlarmView::DiscardPopupOption::CANCEL:
view_.HideDiscardPopup();
break;
- case EditAlarmView::DiscardPopupOption::DISCARD:
+ case EditAlarmView::DiscardPopupOption::CONFIRM:
view_.HideDiscardPopup();
view_.PopPage();
break;
utils::Serialize(w, milliseconds_);
}
-// Simple wrapper around i18n_uchar strings to simplify i18n_uchar strings
-// management
+/**
+ * @brief Simple wrapper around i18n_uchar (unicode) strings to simplify i18n_uchar strings
+ * management.
+ */
class I18nString {
public:
+ /** @brief Creates I18nString from UTF-8 string */
I18nString(const char *str = nullptr);
+ /** @brief Creates I18nString std::string */
I18nString(const std::string &str);
~I18nString();
+ /** @brief Reserves space for max_characters */
void reserve(size_t max_characters);
+ /** @brief Returns c-string representation of I18N string */
const i18n_uchar *i18n_str() const { return data_;}
+ /** @brief Returns std::string representation of I18N string */
std::string std_string() const;
+ /** @brief Gets i18n_uchar on given index */
i18n_uchar& operator[](int index);
+ /** @brief Returns current size of I18NString */
size_t size() const { return size_;}
private:
i18n_uchar *data_;
using namespace model;
using namespace utils;
+/**
+ * Genlist data
+ */
struct ItemData {
+ /** Owner of data */
AlarmView *instance;
+ /** Display text */
char *name;
+ /** Activation flag */
bool active;
+ /** Week flags to display */
WeekFlags flags;
+ /** Time to display */
Time time;
+ /** Iternal EFL handle */
Elm_Object_Item *it;
};
if (it) elm_object_item_del(it);
}
-void AlarmView::SetItemToggleCallback(ToggleCallback func)
-{
- onToggled_ = std::move(func);
-}
-
-void AlarmView::SetItemSelectCallback(SelectCallback func)
-{
- onSelected_ = std::move(func);
-}
-
-void AlarmView::SetButtonClickedCallback(ButtonClickedCallback func)
-{
- onClicked_ = std::move(func);
-}
-
Evas_Object *AlarmView::GetEvasObject()
{
return content_;
namespace view {
+/**
+ * @brief Genlist data
+ */
struct ItemData {
+ /** Owner of ItemData */
DeleteAlarmView *instance;
+ /** Name to be displyed on list item */
char *name;
+ /** True if list item should be disabled (shadowed) */
bool active;
+ /** True if item is selected */
bool selected;
+ /** Week flags to be displayed */
WeekFlags flags;
+ /** Time of alarm to be displayed */
Time time;
+ /** Genlist item handle */
Elm_Object_Item *it;
+ /** Checkbox displayed on list */
Evas_Object *check;
};
return strdup(formatted_time.str().c_str());
}
-DeleteAlarmView::DeleteAlarmView(ui::IView &main)
+DeleteAlarmView::DeleteAlarmView(view::MainView &main)
: PageView(main), all_selected_(false)
{
time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
#define VIBRATION_ICON_PATH "images/01_volume_vibration.png"
#define SOUND_ICON_PATH "images/00_volume_icon.png"
-EditAlarmView::EditAlarmView(ui::IView &main)
+EditAlarmView::EditAlarmView(view::MainView &main)
: PageView(main), week_flags_view_(main, data_.flags), is_muted_(false), main_(main)
{
week_flags_view_.RegisterPoppedCallback(
time.tm_hour, time.tm_min, 0, 0);
}
-static std::string GetLabelForAlarmType(AlarmType type)
+static std::string GetLabelForAlarmType(Alarm::Type type)
{
switch (type) {
- case AlarmType::SOUND_ONLY:
+ case Alarm::Type::SOUND_ONLY:
return Translate::Sprintf("IDS_ALM_BODY_ALERTTYEP_SOUND");
- case AlarmType::VIBRATION:
+ case Alarm::Type::VIBRATION:
return Translate::Sprintf("IDS_ALM_BODY_ALERTTYEP_VIBRATION");
- case AlarmType::VIBRATION_AND_SOUND:
+ case Alarm::Type::VIBRATION_AND_SOUND:
return Translate::Sprintf("IDS_ALM_BODY_ALERTTYEP_VIBRATION_AND_SOUND");
default:
return Translate::Sprintf("IDS_COM_BODY_UNKNOWN");
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
if (view->onEditCancel_) view->onEditCancel_();
- view->PopPage();
}
void EditAlarmView::OnConfirmButtonClickedCb(void *data, Evas_Object *obj, void *event_info)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onEditDone_) view->onEditDone_(view->data_);
- view->PopPage();
+ if (view->onEditDone_) view->onEditDone_();
}
const char *EditAlarmView::GetTitle()
void EditAlarmView::PopupHide(void *data, Evas_Object *obj, void *event)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- view->data_.type = static_cast<AlarmType>(elm_radio_value_get(view->main_radio_));
+ view->data_.type = static_cast<Alarm::Type>(elm_radio_value_get(view->main_radio_));
// refresh type item
elm_genlist_item_update(view->type_it_);
evas_object_del(obj);
main_radio_ = elm_radio_add(list);
elm_radio_state_value_set(main_radio_, 0);
- elm_list_item_append(list, GetLabelForAlarmType(AlarmType::SOUND_ONLY).c_str(),
+ elm_list_item_append(list, GetLabelForAlarmType(Alarm::Type::SOUND_ONLY).c_str(),
NULL, main_radio_, EditAlarmView::PopupListItemSelectedCallback, main_radio_);
Evas_Object *radio = elm_radio_add(list);
elm_radio_state_value_set(radio, 1);
elm_radio_group_add(radio, main_radio_);
- elm_list_item_append(list, GetLabelForAlarmType(AlarmType::VIBRATION).c_str(),
+ elm_list_item_append(list, GetLabelForAlarmType(Alarm::Type::VIBRATION).c_str(),
NULL, radio, EditAlarmView::PopupListItemSelectedCallback, radio);
radio = elm_radio_add(list);
elm_radio_state_value_set(radio, 2);
elm_radio_group_add(radio, main_radio_);
- elm_list_item_append(list, GetLabelForAlarmType(AlarmType::VIBRATION_AND_SOUND).c_str(),
+ elm_list_item_append(list, GetLabelForAlarmType(Alarm::Type::VIBRATION_AND_SOUND).c_str(),
NULL, radio, EditAlarmView::PopupListItemSelectedCallback, radio);
eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
void EditAlarmView::PopupDiscardButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onDiscardPopupCallback) view->onDiscardPopupCallback(DiscardPopupOption::DISCARD);
+ if (view->onDiscardPopupCallback) view->onDiscardPopupCallback(DiscardPopupOption::CONFIRM);
}
void EditAlarmView::PopupCancelButtonClicked(void *data, Evas_Object *obj, void *event_info)
}
}
-PageView::PageView(ui::IView &main)
+PageView::PageView(view::MainView &main)
: navi_item_(nullptr), naviframe_(main.GetEvasObject())
{
}
using namespace model;
-WeekFlagsView::WeekFlagsView(ui::IView &main, WeekFlags &flags)
+WeekFlagsView::WeekFlagsView(view::MainView &main, WeekFlags &flags)
: PageView(main), flags_(flags)
{
}
/*[END] Delete list View */
-WorldClockDeleteItemsView::WorldClockDeleteItemsView(ui::IView &main):
+WorldClockDeleteItemsView::WorldClockDeleteItemsView(view::MainView &main):
PageView(main), all_selected_(false)
{
time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
-WorldClockReorderView::WorldClockReorderView(ui::IView &main) :
+WorldClockReorderView::WorldClockReorderView(view::MainView &main) :
PageView(main)
{
time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(