#include <memory>
+#define GET_SIZE(x) (sizeof(x) / sizeof(*x))
+
+
+/**
+ * TODO:
+ * 1. Add calculator functionality:
+ * - increaseByOne
+ * - increaseByAnotherKeyValue
+ * 2. Atomic operation (change all, or none of values)
+ */
+
template <typename DerivedType>
-class ChangeIntTypeVconfKeyActivity : public Activity, private RegisterActivity<DerivedType>
+class ChangeIntTypeVconfKeysActivity : public Activity, private RegisterActivity<DerivedType>
{
public:
constexpr static const char *activityType = DerivedType::activityType;
- ChangeIntTypeVconfKeyActivity() : Activity(activityType) {}
+ ChangeIntTypeVconfKeysActivity() : Activity(activityType) {}
void process() override
{
- auto state = Singleton<VConfInterface>::instance().get(DerivedType::KEY, 0);
- if (!state) {
- markAsCompleted();
- return;
+ static_assert(GET_SIZE(DerivedType::KEYS) == GET_SIZE(DerivedType::STATES), "Incorrect activity");
+
+ for (auto i = 0u; i < GET_SIZE(DerivedType::KEYS); i++) {
+ auto state = Singleton<VConfInterface>::instance().get({DerivedType::KEYS[i]}, 0);
+ if (!state) {
+ markAsCompleted();
+ return;
+ }
+
+ state = state % DerivedType::STATES[i] + 1;
+ Singleton<VConfInterface>::instance().set({DerivedType::KEYS[i]}, state);
}
- state = state % DerivedType::STATES + 1;
- Singleton<VConfInterface>::instance().set(DerivedType::KEY, state);
markAsCompleted();
}
};
-class ChangeScanningMethodActivity : public ChangeIntTypeVconfKeyActivity<ChangeScanningMethodActivity>
+class ChangeScanningMethodActivity : public ChangeIntTypeVconfKeysActivity<ChangeScanningMethodActivity>
{
public:
static constexpr const char *activityType = "CHANGE_SCANNING_METHOD";
- static constexpr const char *KEY = VCONF_KEY_SCAN_METHOD;
- static constexpr int STATES = 2;
+ static constexpr const char *KEYS[] = {VCONF_KEY_SCAN_METHOD};
+ static constexpr const int STATES[] = {2};
};
-class ChangeTextEditionModeActivity : public ChangeIntTypeVconfKeyActivity<ChangeTextEditionModeActivity>
+class ChangeTextEditionModeActivity : public ChangeIntTypeVconfKeysActivity<ChangeTextEditionModeActivity>
{
public:
static constexpr const char *activityType = "CHANGE_TEXT_EDITION_MODE";
- static constexpr const char *KEY = VCONF_KEY_TEXT_EDITION_MODE;
- static constexpr int STATES = 2;
+ static constexpr const char *KEYS[] = {VCONF_KEY_TEXT_EDITION_MODE};
+ static constexpr const int STATES[] = {2};
};
+class ChangeScanningDirectionActivity : public ChangeIntTypeVconfKeysActivity<ChangeScanningDirectionActivity>
+{
+public:
+ static constexpr const char *activityType = "CHANGE_SCANNING_DIRECTION_MODE";
+ static constexpr const char *KEYS[] = {VCONF_KEY_SCAN_DIRECTION_VERTICAL, VCONF_KEY_SCAN_DIRECTION_HORIZONTAL};
+ static constexpr const int STATES[] = {2, 2};
+};
+
+constexpr const char *ChangeScanningDirectionActivity::KEYS[];
+constexpr const int ChangeScanningDirectionActivity::STATES[];
+
namespace
{
enum granularity {
auto scanVerticalDirection = std::make_shared<VconfIntTypeMenuItem>(
std::vector<std::string> {"IDS_BOTTOM_TO_TOP", "IDS_TOP_TO_BOTTOM"},
defaultImg,
- std::string {}/*TODO add activity*/,
+ "CHANGE_SCANNING_DIRECTION_MODE",
std::string {VCONF_KEY_SCAN_DIRECTION_VERTICAL});
auto turnOnOffVoice = std::make_shared<VconfBoolTypeMenuItem>(
std::vector<std::string> {"IDS_TURN_ON_VOICE", "IDS_TURN_OFF_VOICE"},