[Sound] getSoundMode
authorRyszard Matuszyk <r.matuszyk@samsung.com>
Mon, 9 Feb 2015 10:04:28 +0000 (11:04 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Tue, 10 Feb 2015 16:20:51 +0000 (01:20 +0900)
[Verification] Build required

Change-Id: I9e467d88ecafd88ab992127522fb7eb2454682f2
Signed-off-by: Ryszard Matuszyk <r.matuszyk@samsung.com>
src/sound/sound_instance.cc
src/sound/sound_manager.cc
src/sound/sound_manager.h

index eddd366..46b669c 100644 (file)
@@ -50,17 +50,9 @@ SoundInstance::~SoundInstance() {
       return;\
     }
 
-
-void SoundInstance::SoundManagerGetSoundMode(const picojson::value& args, picojson::object& out) {
-
-
-  // implement it
-
-
-  // if success
-  // ReportSuccess(out);
-  // if error
-  // ReportError(out);
+void SoundInstance::SoundManagerGetSoundMode(const picojson::value& args,
+                                             picojson::object& out) {
+  ReportSuccess(picojson::value(manager_->GetSoundMode()), out);
 }
 
 void SoundInstance::SoundManagerSetVolume(const picojson::value& args,
index 7cce879..f892416 100644 (file)
@@ -5,6 +5,8 @@
 #include "sound/sound_manager.h"
 
 #include <tizen/tizen.h>
+#include <vconf.h>
+#include <vconf-keys.h>
 
 #include "sound/sound_instance.h"
 #include "common/logger.h"
@@ -70,7 +72,39 @@ void SoundManager::FillMaxVolumeMap() {
   }
 }
 
-int SoundManager::GetSoundMode() {}
+std::string SoundManager::GetSoundMode() {
+  std::string sound_mode_type = "MUTE";
+  int isEnableSound = 0;
+  int isEnableVibrate = 0;
+
+  int ret = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &isEnableSound);
+  if (VCONF_OK != ret) {
+    LoggerE("Unknown error : %d", ret);
+    // TODO: throw UnknownException(("Unknown error:
+    // logSoundModeError(ret)).c_str());
+  }
+
+  ret =
+      vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &isEnableVibrate);
+  if (VCONF_OK != ret) {
+    LoggerE("Unknown error : %d", ret);
+    // TODO: throw UnknownException(("Unknown error:
+    // logSoundModeError(ret)).c_str());
+  }
+
+  if (isEnableSound && isEnableVibrate) {
+    LoggerE("Wrong state (sound && vibration)");
+    // TODO: throw UnknownException("Platform has wrong state.");
+  }
+
+  if (isEnableSound) {
+    sound_mode_type = "SOUND";
+  } else if (isEnableVibrate) {
+    sound_mode_type = "VIBRATE";
+  }
+
+  return sound_mode_type;
+}
 
 void SoundManager::SetVolume(const picojson::object& args) {
   const std::string& type = FromJson<std::string>(args, "type");
index 7d58b83..f7d63e7 100644 (file)
@@ -16,7 +16,7 @@ class SoundManager {
  public:
   static SoundManager* GetInstance();
 
-  int GetSoundMode();
+  std::string GetSoundMode();
   void SetVolume(const picojson::object& args);
   double GetVolume(const picojson::object& args);
   void SetSoundModeChangeListener(const picojson::object& args);