summaryrefslogtreecommitdiff
path: root/wearable_src/Filesystem/StorageStaticController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'wearable_src/Filesystem/StorageStaticController.cpp')
-rw-r--r--wearable_src/Filesystem/StorageStaticController.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/wearable_src/Filesystem/StorageStaticController.cpp b/wearable_src/Filesystem/StorageStaticController.cpp
new file mode 100644
index 0000000..b20ab82
--- /dev/null
+++ b/wearable_src/Filesystem/StorageStaticController.cpp
@@ -0,0 +1,65 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Converter.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "EventStorageStateChanged.h"
+#include "StorageStaticController.h"
+#include "JSStorage.h"
+#include "Converter.h"
+#include <Logger.h>
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace DeviceAPI {
+namespace Filesystem {
+StorageStaticController& StorageStaticController::getInstance()
+{
+ static StorageStaticController controller;
+ return controller;
+}
+
+StorageStaticController::StorageStaticController() :
+ EventListener<EventStorageStateChanged>(ThreadEnum::NULL_THREAD)
+{
+}
+
+void StorageStaticController::onAnswerReceived(
+ const EventStorageStateChangedPtr& event)
+{
+ JSCallbackManagerPtr callbackManager =
+ DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+
+ JSContextRef context = callbackManager->getContext();
+ Converter converter(context);
+ try {
+ JSValueRef result = converter.toJSValueRef(event->getResult(), context);
+ callbackManager->callOnSuccess(result);
+ } catch(Commons::ConversionException) {
+ LoggerE("Conversion exception while processing EventStorageStateChanged");
+ }
+}
+
+}
+} \ No newline at end of file