markAsCompleted();
}
+ static int addExtraDataToCall(app_control_h handle)
+ {
+ return APP_CONTROL_ERROR_NONE;
+ }
+
protected:
app_control_h appControlHandle;
private:
- int addExtraDataToCall()
- {
- return APP_CONTROL_ERROR_NONE;
- }
void launch()
{
status = app_control_set_app_id(appControlHandle, DerivedType::appToLaunch);
RETURN_IF(status != APP_CONTROL_ERROR_NONE);
- status = static_cast<DerivedType *>(this)->addExtraDataToCall();
+ status = DerivedType::addExtraDataToCall(appControlHandle);
RETURN_IF(status != APP_CONTROL_ERROR_NONE);
status = app_control_send_launch_request(appControlHandle, NULL, NULL);
class StartSettingsActivity : public AppControlActivity<StartSettingsActivity, false>
{
public:
- friend AppControlActivity<StartSettingsActivity, false>;
-
static constexpr const char *activityType = "START_SETTINGS";
static constexpr const char *appToLaunch = "org.tizen.setting-accessibility";
-protected:
- int addExtraDataToCall()
+ static int addExtraDataToCall(app_control_h handle)
{
- return app_control_add_extra_data(appControlHandle, "SHOW_US_SETTINGS", "1");
+ return app_control_add_extra_data(handle, "SHOW_US_SETTINGS", "1");
}
};
#include <sound_manager.h>
-#define RETURN_DEFAULT_SOUND_TYPE_ON_ERROR(status) do { \
- if (status != SOUND_MANAGER_ERROR_NONE) { \
- if (status == SOUND_MANAGER_ERROR_NO_PLAYING_SOUND) \
- DEBUG("Sound isn't playing on any channel"); \
- else \
- ERROR("sound_manager_get_current_sound_type error: %d", status); \
- return soundType; \
- } \
- } while (false)
-
template <typename DerivedType, bool bindable>
class VolumeControlActivity : public Activity, private RegisterActivity<DerivedType, bindable>
{
markAsCompleted();
}
- virtual sound_type_e getSoundType() const
+ static sound_type_e getSoundType()
{
return DerivedType::soundType;
}
auto volume = 0;
auto maxVolume = 0;
auto minVolume = 0;
- auto soundType = getSoundType();
+ auto soundType = DerivedType::getSoundType();
auto status = sound_manager_get_max_volume(soundType, &maxVolume);
RETURN_IF(status != SOUND_MANAGER_ERROR_NONE);
static constexpr const sound_type_e soundType = SOUND_TYPE_NOTIFICATION;
};
-class IncreaseVolumeActivity : public VolumeControlActivity<IncreaseVolumeActivity, true>
+template <typename DerivedType, bool bindable>
+class ChangeVolumeActivity : public VolumeControlActivity<DerivedType, bindable>
{
public:
- sound_type_e getSoundType() const override
+ static sound_type_e getSoundType()
{
sound_type_e type;
- RETURN_DEFAULT_SOUND_TYPE_ON_ERROR(sound_manager_get_current_sound_type(&type));
+ auto status = sound_manager_get_current_sound_type(&type);
+ if (status != SOUND_MANAGER_ERROR_NONE) {
+ if (status == SOUND_MANAGER_ERROR_NO_PLAYING_SOUND)
+ DEBUG("Sound isn't playing on any channel");
+ else
+ ERROR("sound_manager_get_current_sound_type error: %d", status);
+
+ type = SOUND_TYPE_RINGTONE;
+ }
+
return type;
}
+};
+class IncreaseVolumeActivity : public ChangeVolumeActivity<IncreaseVolumeActivity, true>
+{
+public:
static constexpr const char *activityType = "INCREASE_VOLUME";
static constexpr const int step = 1;
- static constexpr const sound_type_e soundType = SOUND_TYPE_RINGTONE;
};
-class DecreaseVolumeActivity : public VolumeControlActivity<DecreaseVolumeActivity, true>
+class DecreaseVolumeActivity : public ChangeVolumeActivity<DecreaseVolumeActivity, true>
{
public:
- sound_type_e getSoundType() const override
- {
- sound_type_e type;
- RETURN_DEFAULT_SOUND_TYPE_ON_ERROR(sound_manager_get_current_sound_type(&type));
- return type;
- }
-
static constexpr const char *activityType = "DECREASE_VOLUME";
static constexpr const int step = -1;
- static constexpr const sound_type_e soundType = SOUND_TYPE_RINGTONE;
};