[Exif] Changing plugin to generator convention
authorRyszard Matuszyk <r.matuszyk@samsung.com>
Fri, 30 Jan 2015 12:59:24 +0000 (13:59 +0100)
committerRafal Galka <r.galka@samsung.com>
Mon, 2 Feb 2015 10:37:16 +0000 (19:37 +0900)
[Verification] TCT without change

Change-Id: I2eaf0d23be99cc17af59d933d4b5d084b858142f
Signed-off-by: Ryszard Matuszyk <r.matuszyk@samsung.com>
src/exif/exif_api.js
src/exif/exif_extension.cc
src/exif/exif_extension.h
src/exif/exif_instance.cc
src/exif/exif_instance.h

index df9687be7133df0cda9fcbe69d91c1ec769e9335..f9623ccaae8d7cfd482520436516bbc82f7fc833 100644 (file)
@@ -193,7 +193,7 @@ ExifManager.prototype.getExifInfo = function() {
     }
   };
 
-  native_.call('Exif_getExifInfo', callArgs, callback);
+  native_.call('ExifManager_getExifInfo', callArgs, callback);
 };
 
 ExifManager.prototype.saveExifInfo = function() {
@@ -230,7 +230,7 @@ ExifManager.prototype.saveExifInfo = function() {
     }
   };
 
-  native_.call('Exif_saveExifInfo', json, callback);
+  native_.call('ExifManager_saveExifInfo', json, callback);
 };
 
 ExifManager.prototype.getThumbnail = function() {
@@ -265,7 +265,7 @@ ExifManager.prototype.getThumbnail = function() {
     }
   };
 
-  native_.call('Exif_getThumbnail', {'uri': args.uri}, callback);
+  native_.call('ExifManager_getThumbnail', {'uri': args.uri}, callback);
 };
 
 tizen.ExifInformation = function() {
index 782d12d2c62784c822947f98cba7874512783ca6..d751d5cf0914b3f095265565740394f4d3b471ff 100644 (file)
@@ -1,35 +1,23 @@
-// Copyright (c) 2014 Samsung Electronics Co., Ltd. All Rights Reserved.
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "exif/exif_extension.h"
 #include "exif/exif_instance.h"
 
-namespace {
-const char kExtensionName[] = "tizen.exif";
-const char kExifInformationEntryPoint[] = "tizen.ExifInformation";
-}  // namespace
-
-common::Extension* CreateExtension() {
-  return new ExifExtension;
-}
+common::Extension* CreateExtension() { return new ExifExtension; }
 
 // This will be generated from exif_api.js.
 extern const char kSource_exif_api[];
 
 ExifExtension::ExifExtension() {
-  SetExtensionName(kExtensionName);
+  SetExtensionName("tizen.exif");
   SetJavaScriptAPI(kSource_exif_api);
 
-  const char* entry_points[] = {
-    kExifInformationEntryPoint,
-    NULL
-  };
+  const char* entry_points[] = {"tizen.ExifInformation", NULL};
   SetExtraJSEntryPoints(entry_points);
 }
 
 ExifExtension::~ExifExtension() {}
 
-common::Instance* ExifExtension::CreateInstance() {
-  return new extension::exif::ExifInstance;
-}
+common::Instance* ExifExtension::CreateInstance() { return new extension::exif::ExifInstance; }
index 3afc6ca376271850ba7dd62754fb35bf995b6841..b9b5983b19425bfd2ea6d33d1c024a04e9cb18dc 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2014 Samsung Electronics Co., Ltd. All Rights Reserved.
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
index f7e200f4a68012c0159fecbcab10badab066c757..6d041138505b234357415d7369c0a7d5b7347374 100644 (file)
@@ -29,66 +29,55 @@ typedef picojson::object JsonObject;
 typedef picojson::array JsonArray;
 typedef std::string JsonString;
 
-namespace {
-const char kGetExifInfoCmd[] = "Exif_getExifInfo";
-const char kSaveExifInfoCmd[] = "Exif_saveExifInfo";
-const char kGetThumbnailCmd[] = "Exif_getThumbnail";
-}  // namespace
-
 ExifInstance::ExifInstance() {
   using namespace std::placeholders;
-
-#define REGISTER_ASYNC(c, x) \
-  RegisterHandler(c, std::bind(&ExifInstance::x, this, _1, _2));
-  REGISTER_ASYNC(kGetExifInfoCmd, getExifInfo);
-  REGISTER_ASYNC(kSaveExifInfoCmd, saveExifInfo);
-  REGISTER_ASYNC(kGetThumbnailCmd, getThumbnail);
+#define REGISTER_ASYNC(c, x) RegisterHandler(c, std::bind(&ExifInstance::x, this, _1, _2));
+  REGISTER_ASYNC("ExifManager_getExifInfo", ExifManagerGetExifInfo);
+  REGISTER_ASYNC("ExifManager_saveExifInfo", ExifManagerSaveExifInfo);
+  REGISTER_ASYNC("ExifManager_getThumbnail", ExifManagerGetThumbnail);
 #undef REGISTER_ASYNC
 }
 
-ExifInstance::~ExifInstance() { }
+ExifInstance::~ExifInstance() {}
 
-void ExifInstance::getExifInfo(const picojson::value& args,
-                               picojson::object& out) {
+void ExifInstance::ExifManagerGetExifInfo(const picojson::value& args, picojson::object& out) {
   LoggerD("enter");
 
   const std::string& uri = args.get("uri").get<std::string>();
 
   const double callback_id = args.get("callbackId").get<double>();
-  auto get = [=](const std::shared_ptr<JsonValue>& response) -> void {
+  auto get = [=](const std::shared_ptr<JsonValue>& response)->void {
     try {
       const std::string file_path = ExifUtil::convertUriToPath(uri);
       LoggerD("file_path = %s\n", file_path.c_str());
 
       JsonValue result_direct = GetExifInfo::LoadFromURI(uri);
       ReportSuccess(result_direct, response->get<picojson::object>());
-    } catch (const common::PlatformException& e) {
+    }
+    catch (const common::PlatformException& e) {
       ReportError(e, response->get<picojson::object>());
     }
   };
 
-  auto get_response =
-      [callback_id, this](const std::shared_ptr<JsonValue>& response) -> void {
-        picojson::object& obj = response->get<picojson::object>();
-        obj.insert(std::make_pair("callbackId", picojson::value(callback_id)));
-        LoggerD("callback is %s", response->serialize().c_str());
-        PostMessage(response->serialize().c_str());
-      };
+  auto get_response = [callback_id, this](const std::shared_ptr<JsonValue>& response)->void {
+    picojson::object& obj = response->get<picojson::object>();
+    obj.insert(std::make_pair("callbackId", picojson::value(callback_id)));
+    LoggerD("callback is %s", response->serialize().c_str());
+    PostMessage(response->serialize().c_str());
+  };
 
   common::TaskQueue::GetInstance().Queue<JsonValue>(
-      get, get_response,
-      std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
+      get, get_response, std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
 
   LoggerD("exit");
 }
 
-void ExifInstance::saveExifInfo(const picojson::value& args,
-                                picojson::object& out) {
+void ExifInstance::ExifManagerSaveExifInfo(const picojson::value& args, picojson::object& out) {
   LoggerD("Entered");
   const std::string& uri = args.get("uri").get<std::string>();
 
   const double callback_id = args.get("callbackId").get<double>();
-  auto get = [=](const std::shared_ptr<JsonValue>& response) -> void {
+  auto get = [=](const std::shared_ptr<JsonValue>& response)->void {
     try {
       ExifInformationPtr exifInfo(new ExifInformation(args));
       std::string uri = exifInfo->getUri();
@@ -96,35 +85,33 @@ void ExifInstance::saveExifInfo(const picojson::value& args,
       exifInfo->saveToFile(path);
 
       ReportSuccess(args, response->get<picojson::object>());
-    } catch (const common::PlatformException& e) {
+    }
+    catch (const common::PlatformException& e) {
       ReportError(e, response->get<picojson::object>());
     }
   };
 
-  auto get_response =
-      [callback_id, this](const std::shared_ptr<JsonValue>& response) -> void {
-        picojson::object& obj = response->get<picojson::object>();
-        obj.insert(std::make_pair("callbackId", picojson::value(callback_id)));
-        LoggerD("callback is %s", response->serialize().c_str());
-        PostMessage(response->serialize().c_str());
-      };
+  auto get_response = [callback_id, this](const std::shared_ptr<JsonValue>& response)->void {
+    picojson::object& obj = response->get<picojson::object>();
+    obj.insert(std::make_pair("callbackId", picojson::value(callback_id)));
+    LoggerD("callback is %s", response->serialize().c_str());
+    PostMessage(response->serialize().c_str());
+  };
 
   common::TaskQueue::GetInstance().Queue<JsonValue>(
-      get, get_response,
-      std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
+      get, get_response, std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
 }
 
-void ExifInstance::getThumbnail(const picojson::value& args,
-                                picojson::object& out) {
+void ExifInstance::ExifManagerGetThumbnail(const picojson::value& args, picojson::object& out) {
   LoggerD("Entered");
   const std::string& uri = args.get("uri").get<std::string>();
 
   const double callback_id = args.get("callbackId").get<double>();
-  auto get = [=](const std::shared_ptr<JsonValue>& response) -> void {
+  auto get = [=](const std::shared_ptr<JsonValue>& response)->void {
     try {
       const std::string file_path = ExifUtil::convertUriToPath(uri);
       ExifData* exif_data = nullptr;
-      JsonValue result = JsonValue(JsonObject());;
+      JsonValue result = JsonValue(JsonObject());
       JsonObject& result_obj = result.get<JsonObject>();
 
       std::string ext = file_path.substr(file_path.find_last_of(".") + 1);
@@ -144,7 +131,7 @@ void ExifInstance::getThumbnail(const picojson::value& args,
 
         if (exif_data->data && exif_data->size) {
           gchar* ch_uri = g_base64_encode(exif_data->data, exif_data->size);
-          std::string base64 = "data:image/"+ext+";base64," + ch_uri;
+          std::string base64 = "data:image/" + ext + ";base64," + ch_uri;
 
           exif_data_unref(exif_data);
 
@@ -154,33 +141,29 @@ void ExifInstance::getThumbnail(const picojson::value& args,
         } else {
           exif_data_unref(exif_data);
           LoggerE("File [%s] doesn't contain thumbnail", file_path.c_str());
-          throw common::InvalidValuesException("File doesn't contain"
-              " thumbnail");
+          throw common::InvalidValuesException("File doesn't contain thumbnail");
         }
       } else {
-        LoggerE("extension: %s is not valid (jpeg/jpg/png/gif is supported)",
-            ext.c_str());
-        throw common::NotSupportedException("getThumbnail support only"
-            " jpeg/jpg/png/gif");
+        LoggerE("extension: %s is not valid (jpeg/jpg/png/gif is supported)", ext.c_str());
+        throw common::NotSupportedException("getThumbnail support only jpeg/jpg/png/gif");
       }
 
       ReportSuccess(result, response->get<picojson::object>());
-    } catch (const common::PlatformException& e) {
+    }
+    catch (const common::PlatformException& e) {
       ReportError(e, response->get<picojson::object>());
     }
   };
 
-  auto get_response =
-      [callback_id, this](const std::shared_ptr<JsonValue>& response) -> void {
-        picojson::object& obj = response->get<picojson::object>();
-        obj.insert(std::make_pair("callbackId", picojson::value(callback_id)));
-        LoggerD("callback is %s", response->serialize().c_str());
-        PostMessage(response->serialize().c_str());
-      };
+  auto get_response = [callback_id, this](const std::shared_ptr<JsonValue>& response)->void {
+    picojson::object& obj = response->get<picojson::object>();
+    obj.insert(std::make_pair("callbackId", picojson::value(callback_id)));
+    LoggerD("callback is %s", response->serialize().c_str());
+    PostMessage(response->serialize().c_str());
+  };
 
   common::TaskQueue::GetInstance().Queue<JsonValue>(
-      get, get_response,
-      std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
+      get, get_response, std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
 }
 
 }  // namespace exif
index 1cf86a49ff060ff1de06d3a1ee34b2c4ffe49e51..2e5bb41bf6f2b68dcacfcc2bfdc1db37a96ff0de 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2014 Samsung Electronics Co., Ltd. All Rights Reserved.
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 
 namespace extension {
 namespace exif {
+
 class ExifInstance : public common::ParsedInstance {
  public:
   ExifInstance();
   virtual ~ExifInstance();
 
  private:
-  void getExifInfo(const picojson::value& args, picojson::object& out);
-  void saveExifInfo(const picojson::value& args, picojson::object& out);
-  void getThumbnail(const picojson::value& args, picojson::object& out);
+  void ExifManagerGetExifInfo(const picojson::value& args, picojson::object& out);
+  void ExifManagerSaveExifInfo(const picojson::value& args, picojson::object& out);
+  void ExifManagerGetThumbnail(const picojson::value& args, picojson::object& out);
 };
 
 }  // namespace exif
 }  // namespace extension
+
 #endif  // EXIF_EXIF_INSTANCE_H_