add log for debugging
authorHyunjin Park <hj.na.park@samsung.com>
Tue, 2 Jun 2015 03:30:51 +0000 (12:30 +0900)
committerHyunjin Park <hj.na.park@samsung.com>
Tue, 2 Jun 2015 03:30:51 +0000 (12:30 +0900)
- FS, msgport, common

Change-Id: I64da93dcb25cbb8be89905dc6d34f51df81507d0

14 files changed:
src/common/XW_Extension.cc
src/common/converter.cc
src/common/current_application.cc
src/common/dbus_operation.cc
src/common/extension.cc
src/common/filter-utils.cc
src/common/platform_result.cc
src/common/virtual_fs.cc
src/filesystem/filesystem_file.cc
src/filesystem/filesystem_instance.cc
src/filesystem/filesystem_manager.cc
src/filesystem/filesystem_stat.cc
src/filesystem/filesystem_utils.cc
src/messageport/messageport_instance.cc

index e849c8c3e4c77e418d1e0ce0dcfe1463464bdf84..f85beb7e5fbf19ef1df2104460aac51c3c0d4a48 100755 (executable)
@@ -6,6 +6,7 @@
 // This file is compiled into each plugin, hence its size should be minimized.
 
 #include "common/extension.h"
+#include "common/logger.h"
 
 namespace {
 
@@ -33,6 +34,7 @@ class Extension::Detail {
 };
 
 int32_t Extension::Detail::XW_Initialize(XW_Extension extension, XW_GetInterface get_interface) {
+  LoggerD("Enter");
   g_extension = CreateExtension();
   if (!g_extension) {
     std::cerr << "Can't initialize extension: "
@@ -43,6 +45,7 @@ int32_t Extension::Detail::XW_Initialize(XW_Extension extension, XW_GetInterface
 }
 
 void Extension::Detail::OnInstanceCreated(XW_Instance xw_instance) {
+  LoggerD("Enter");
   if (!g_extension) {
     return;
   }
@@ -54,6 +57,7 @@ void Extension::Detail::OnInstanceCreated(XW_Instance xw_instance) {
 }
 
 void Extension::Detail::OnShutdown(XW_Extension) {
+  LoggerD("Enter");
   delete g_extension;
   g_extension = nullptr;
 }
index 2f9562cd527362610677d9d2df611398e0af7b75..edb62bf3e362313dec66feaa211ad190869de0fc 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 #include "common/converter.h"
+#include "common/logger.h"
 #include <stdexcept>
 #include <string>
 
@@ -22,6 +23,7 @@ namespace common {
 
 const picojson::value& FindValue(const picojson::object& in,
                                      const char* name) {
+  LoggerD("Enter");
   auto it = in.find(name);
   if (it == in.end()) {
     throw common::UnknownException(
@@ -35,9 +37,11 @@ long stol(const std::string& str, std::size_t* pos, int base) {
     return std::stol(str, pos, base);
   }
   catch (const std::invalid_argument& e) {
+    LoggerE("invalid_argument");
     throw common::InvalidValuesException(e.what());
   }
   catch (const std::out_of_range& e) {
+    LoggerE("InvalidValuesException");
     throw common::InvalidValuesException(e.what());
   }
 }
index e4b4099fc7174de8613c5c252b996ce69f1e10e6..fc08be08d58c1efebe22a04316ce3f1e919aeb86 100755 (executable)
 namespace common {
 
 CurrentApplication& CurrentApplication::GetInstance() {
+  LoggerD("Enter");
   static CurrentApplication current_application;
   return current_application;
 }
 
 pid_t CurrentApplication::GetProcessId() const {
+  LoggerD("Enter");
   return pid_;
 }
 
 std::string CurrentApplication::GetApplicationId() const {
+  LoggerD("Enter");
   return app_id_;
 }
 
 std::string CurrentApplication::GetPackageId() const {
+  LoggerD("Enter");
   return package_id_;
 }
 
@@ -45,9 +49,11 @@ CurrentApplication::CurrentApplication() :
     pid_(getpid()),
     app_id_(FetchApplicationId()),
     package_id_(FetchPackageId()) {
+  LoggerD("Enter");
 }
 
 std::string CurrentApplication::FetchApplicationId() const {
+  LoggerD("Enter");
   std::string app_id;
   char* tmp_str = nullptr;
 
@@ -65,6 +71,7 @@ std::string CurrentApplication::FetchApplicationId() const {
 }
 
 std::string CurrentApplication::FetchPackageId() const {
+  LoggerD("Enter");
   std::string package_id;
   char* tmp_str = nullptr;
 
index bcbe9fa349513f16f27613405b8562bf6ccae5b0..ecded9f3d4e441fd6e00e598c742334f8ed3ac73 100755 (executable)
 namespace common {
 
 DBusOperationArguments::DBusOperationArguments() {
+  LoggerD("Enter");
 }
 
 DBusOperationArguments::~DBusOperationArguments() {
+    LoggerD("Enter");
     for (auto iter = arguments_.begin(); iter != arguments_.end(); ++iter) {
         ArgType type = iter->first;
         void* p_val = iter->second;
@@ -67,6 +69,7 @@ DBusOperationArguments::~DBusOperationArguments() {
 }
 
 void DBusOperationArguments::AddArgumentBool(bool val) {
+    LoggerD("Enter");
     int32_t* p_val = new int32_t;
     *p_val = val;
 
@@ -74,6 +77,7 @@ void DBusOperationArguments::AddArgumentBool(bool val) {
 }
 
 void DBusOperationArguments::AddArgumentInt32(int val) {
+    LoggerD("Enter");
     int32_t* p_val = new int32_t;
     *p_val = val;
 
@@ -81,6 +85,7 @@ void DBusOperationArguments::AddArgumentInt32(int val) {
 }
 
 void DBusOperationArguments::AddArgumentUInt32(unsigned int val) {
+    LoggerD("Enter");
     uint32_t* p_val = new uint32_t;
     *p_val = val;
 
@@ -88,6 +93,7 @@ void DBusOperationArguments::AddArgumentUInt32(unsigned int val) {
 }
 
 void DBusOperationArguments::AddArgumentUInt64(uint64_t val) {
+    LoggerD("Enter");
     uint64_t* p_val = new uint64_t;
     *p_val = val;
 
@@ -95,6 +101,7 @@ void DBusOperationArguments::AddArgumentUInt64(uint64_t val) {
 }
 
 void DBusOperationArguments::AddArgumentString(const std::string& val) {
+    LoggerD("Enter");
     const int length = val.length();
 
     char* p_val = new char[length * 2];
@@ -104,6 +111,7 @@ void DBusOperationArguments::AddArgumentString(const std::string& val) {
 }
 
 PlatformResult DBusOperationArguments::AppendVariant(DBusMessageIter* bus_msg_iter) {
+    LoggerD("Enter");
     for (auto iter = arguments_.begin(); iter != arguments_.end(); ++iter) {
         ArgType type = iter->first;
         void *p_val = iter->second;
@@ -151,10 +159,12 @@ DBusOperation::DBusOperation(const std::string& destination,
                              path_(path),
                              interface_(interface),
                              connection_(nullptr) {
+    LoggerD("Enter");
     s_objects_.insert(this);
 }
 
 DBusOperation::~DBusOperation() {
+    LoggerD("Enter");
     if (connection_) {
         dbus_connection_close(connection_);
         dbus_connection_unref(connection_);
@@ -172,6 +182,7 @@ DBusOperation::~DBusOperation() {
 int DBusOperation::InvokeSyncGetInt(const std::string& method,
                                     DBusOperationArguments* args) {
 
+    LoggerD("Enter");
     if (!connection_) {
         connection_ = dbus_bus_get_private(DBUS_BUS_SYSTEM, nullptr);
     }
@@ -238,6 +249,7 @@ int DBusOperation::InvokeSyncGetInt(const std::string& method,
 PlatformResult DBusOperation::InvokeSyncGetInt(const std::string& method,
                                     DBusOperationArguments* args, int* result) {
 
+    LoggerD("Enter");
     if (!connection_) {
         connection_ = dbus_bus_get_private(DBUS_BUS_SYSTEM, nullptr);
     }
@@ -302,6 +314,7 @@ PlatformResult DBusOperation::InvokeSyncGetInt(const std::string& method,
 
 PlatformResult DBusOperation::RegisterSignalListener(const std::string& signal_name,
                                            DBusOperationListener* listener) {
+    LoggerD("Enter");
     PlatformResult ret = AddDBusSignalFilter();
     if (ret.IsError()) return ret;
 
@@ -311,6 +324,7 @@ PlatformResult DBusOperation::RegisterSignalListener(const std::string& signal_n
 
 PlatformResult DBusOperation::UnregisterSignalListener(const std::string& signal_name,
                                              DBusOperationListener* listener) {
+    LoggerD("Enter");
     bool signal_found = false;
 
     for (auto iter = listeners_.begin(); iter != listeners_.end(); ++iter) {
@@ -335,6 +349,7 @@ PlatformResult DBusOperation::UnregisterSignalListener(const std::string& signal
 }
 
 PlatformResult DBusOperation::AddDBusSignalFilter() {
+    LoggerD("Enter");
     if (!connection_) {
         connection_ = dbus_bus_get_private(DBUS_BUS_SYSTEM, nullptr);
     }
@@ -372,6 +387,7 @@ PlatformResult DBusOperation::AddDBusSignalFilter() {
 }
 
 PlatformResult DBusOperation::RemoveDBusSignalFilter() {
+    LoggerD("Enter");
     DBusError err;
     dbus_error_init(&err);
     dbus_bus_remove_match(connection_, rule_.c_str(), &err);
@@ -388,6 +404,7 @@ PlatformResult DBusOperation::RemoveDBusSignalFilter() {
 
 DBusHandlerResult DBusOperation::DBusSignalFilter(DBusConnection* /* conn */,
                                                   DBusMessage* message) {
+    LoggerD("Enter");
     DBusError err;
     dbus_error_init(&err);
 
@@ -409,6 +426,7 @@ DBusHandlerResult DBusOperation::DBusSignalFilter(DBusConnection* /* conn */,
 DBusHandlerResult DBusOperation::DBusSignalFilterHandler(DBusConnection* conn,
                                                          DBusMessage* message,
                                                          void* user_data) {
+    LoggerD("Enter");
     DBusOperation* that = static_cast<DBusOperation *>(user_data);
 
     if (s_objects_.end() == s_objects_.find(that)) {
index d6e50548814399f791355dc743fdd458a9089d20..f054e5fe46b86d68d6f9a0373c835f76fe197f4c 100755 (executable)
@@ -47,6 +47,7 @@ const XW_Internal_RuntimeInterface* g_runtime = NULL;
 const XW_Internal_PermissionsInterface* g_permission = NULL;
 
 bool InitializeInterfaces(XW_GetInterface get_interface) {
+  LoggerD("Enter");
   static bool initialized = false;
 
   if (!initialized) {
@@ -106,40 +107,50 @@ bool InitializeInterfaces(XW_GetInterface get_interface) {
 namespace common {
 
 Extension::Extension() : xw_extension_(g_xw_extension_) {
+  LoggerD("Enter");
 }
 
-Extension::~Extension() {}
+Extension::~Extension() {
+  LoggerD("Enter");
+}
 
 void Extension::SetExtensionName(const char* name) {
+  LoggerD("Enter");
   g_core->SetExtensionName(xw_extension_, name);
 }
 
 void Extension::SetJavaScriptAPI(const char* api) {
+  LoggerD("Enter");
   g_core->SetJavaScriptAPI(xw_extension_, api);
 }
 
 void Extension::SetExtraJSEntryPoints(const char** entry_points) {
+  LoggerD("Enter");
   if (g_entry_points)
     g_entry_points->SetExtraJSEntryPoints(xw_extension_, entry_points);
 }
 
 bool Extension::RegisterPermissions(const char* perm_table) {
+  LoggerD("Enter");
   if (g_permission)
     return g_permission->RegisterPermissions(xw_extension_, perm_table);
   return false;
 }
 
 bool Extension::CheckAPIAccessControl(const char* api_name) {
+  LoggerD("Enter");
   if (g_permission)
     return g_permission->CheckAPIAccessControl(xw_extension_, api_name);
   return false;
 }
 
 Instance* Extension::CreateInstance() {
+  LoggerD("Enter");
   return NULL;
 }
 
 std::string Extension::GetRuntimeVariable(const char* var_name, unsigned len) {
+  LoggerD("Enter");
   if (!g_runtime)
     return "";
 
@@ -163,6 +174,7 @@ std::string Extension::GetRuntimeVariable(const char* var_name, unsigned len) {
 
 // static
 void Extension::OnInstanceCreated(XW_Instance xw_instance, Instance* instance) {
+  LoggerD("Enter");
   assert(!g_core->GetInstanceData(xw_instance));
   if (!instance)
     return;
@@ -173,6 +185,7 @@ void Extension::OnInstanceCreated(XW_Instance xw_instance, Instance* instance) {
 
 // static
 void Extension::OnInstanceDestroyed(XW_Instance xw_instance) {
+  LoggerD("Enter");
   Instance* instance =
       reinterpret_cast<Instance*>(g_core->GetInstanceData(xw_instance));
   if (!instance)
@@ -183,6 +196,7 @@ void Extension::OnInstanceDestroyed(XW_Instance xw_instance) {
 
 // static
 void Extension::HandleMessage(XW_Instance xw_instance, const char* msg) {
+  LoggerD("Enter");
   Instance* instance =
       reinterpret_cast<Instance*>(g_core->GetInstanceData(xw_instance));
   if (!instance)
@@ -192,6 +206,7 @@ void Extension::HandleMessage(XW_Instance xw_instance, const char* msg) {
 
 // static
 void Extension::HandleSyncMessage(XW_Instance xw_instance, const char* msg) {
+  LoggerD("Enter");
   Instance* instance =
       reinterpret_cast<Instance*>(g_core->GetInstanceData(xw_instance));
   if (!instance)
@@ -205,6 +220,7 @@ int32_t Extension::XW_Initialize(XW_Extension extension,
                                  XW_Initialize_Func initialize,
                                  XW_CreatedInstanceCallback created_instance,
                                  XW_ShutdownCallback shutdown) {
+  LoggerD("Enter");
   assert(extension);
 
   if (!InitializeInterfaces(get_interface)) {
@@ -229,14 +245,19 @@ int32_t Extension::XW_Initialize(XW_Extension extension,
 }
 
 
-Instance::Instance()
-    : xw_instance_(0) {}
+Instance::Instance() :
+    xw_instance_(0)
+{
+  LoggerD("Enter");
+}
 
 Instance::~Instance() {
+  LoggerD("Enter");
   assert(xw_instance_ == 0);
 }
 
 void Instance::PostMessage(const char* msg) {
+  LoggerD("Enter");
   if (!xw_instance_) {
     std::cerr << "Ignoring PostMessage() in the constructor or after the "
               << "instance was destroyed.";
@@ -246,6 +267,7 @@ void Instance::PostMessage(const char* msg) {
 }
 
 void Instance::SendSyncReply(const char* reply) {
+  LoggerD("Enter");
   if (!xw_instance_) {
     std::cerr << "Ignoring SendSyncReply() in the constructor or after the "
               << "instance was destroyed.";
@@ -256,48 +278,60 @@ void Instance::SendSyncReply(const char* reply) {
 
 
 ParsedInstance::ParsedInstance() {
+  LoggerD("Enter");
 }
 
 ParsedInstance::~ParsedInstance() {
+  LoggerD("Enter");
 }
 
 void ParsedInstance::RegisterHandler(const std::string& name, const NativeHandler& func) {
+  LoggerD("Enter");
   handler_map_.insert(std::make_pair(name, func));
 }
 
 void ParsedInstance::RegisterSyncHandler(const std::string& name, const NativeHandler& func) {
+  LoggerD("Enter");
   handler_map_.insert(std::make_pair("#SYNC#" + name, func));
 }
 
 void ParsedInstance::ReportSuccess(picojson::object& out) {
+  LoggerD("Enter");
   tools::ReportSuccess(out);
 }
 
 void ParsedInstance::ReportSuccess(const picojson::value& result, picojson::object& out) {
+  LoggerD("Enter");
   tools::ReportSuccess(result, out);
 }
 
 void ParsedInstance::ReportError(picojson::object& out) {
+  LoggerD("Enter");
   tools::ReportError(out);
 }
 
 void ParsedInstance::ReportError(const PlatformException& ex, picojson::object& out) {
+  LoggerD("Enter");
   tools::ReportError(ex, out);
 }
 
 void ParsedInstance::ReportError(const PlatformResult& error, picojson::object* out) {
+  LoggerD("Enter");
   tools::ReportError(error, out);
 }
 
 void ParsedInstance::HandleMessage(const char* msg) {
+  LoggerD("Enter");
   HandleMessage(msg, false);
 }
 
 void ParsedInstance::HandleSyncMessage(const char* msg) {
+  LoggerD("Enter");
   HandleMessage(msg, true);
 }
 
 void ParsedInstance::HandleMessage(const char* msg, bool is_sync) {
+  LoggerD("Enter");
   try {
     picojson::value value;
     std::string err;
@@ -347,6 +381,7 @@ void ParsedInstance::HandleMessage(const char* msg, bool is_sync) {
 }
 
 void ParsedInstance::HandleException(const PlatformException& ex) {
+  LoggerD("Enter");
   std::cerr << "Exception: " << ex.message();
   picojson::value result = picojson::value(picojson::object());
   ReportError(ex, result.get<picojson::object>());
@@ -362,24 +397,29 @@ void ParsedInstance::HandleError(const PlatformResult& e) {
 
 namespace tools {
 void ReportSuccess(picojson::object& out) {
+  LoggerD("Enter");
   out.insert(std::make_pair("status", picojson::value("success")));
 }
 
 void ReportSuccess(const picojson::value& result, picojson::object& out) {
+  LoggerD("Enter");
   out.insert(std::make_pair("status", picojson::value("success")));
   out.insert(std::make_pair("result", result));
 }
 
 void ReportError(picojson::object& out) {
+  LoggerD("Enter");
   out.insert(std::make_pair("status", picojson::value("error")));
 }
 
 void ReportError(const PlatformException& ex, picojson::object& out) {
+  LoggerD("Enter");
   out.insert(std::make_pair("status", picojson::value("error")));
   out.insert(std::make_pair("error", ex.ToJSON()));
 }
 
 void ReportError(const PlatformResult& error, picojson::object* out) {
+  LoggerD("Enter");
   out->insert(std::make_pair("status", picojson::value("error")));
   out->insert(std::make_pair("error", error.ToJSON()));
 }
@@ -434,6 +474,7 @@ class AccessControlImpl {
   ~AccessControlImpl() {}
 
   bool CheckAccess(const std::vector<std::string>& privileges) {
+    LoggerD("Enter");
     if (!initialized_) {
       return false;
     }
@@ -464,6 +505,7 @@ class AccessControlImpl {
   }
 
   bool CheckAccess(const std::vector<std::string>& privileges) {
+    LoggerD("Enter");
     int ret = 0;
     for (size_t i = 0; i < privileges.size(); ++i) {
       ret = privilege_checker_check_privilege(privileges[i].c_str());
@@ -584,6 +626,7 @@ PlatformResult CheckAccess(const std::string& privilege) {
 }
 
 PlatformResult CheckAccess(const std::vector<std::string>& privileges) {
+  LoggerD("Enter");
   if (AccessControl::GetInstance().CheckAccess(privileges)) {
     return PlatformResult(ErrorCode::NO_ERROR);
   } else {
index ebace20a1501d5d8e02f379209282a9bb70c3561..9859d90b72d6abc04135811b7937780360d53ad9 100755 (executable)
@@ -23,6 +23,7 @@ namespace common {
 
 PlatformResult AttributeMatchFlagFromString(
     const std::string &str, AttributeMatchFlag *filter_match_flag) {
+  LoggerD("Enter");
   if (str == "EXACTLY") {
     *filter_match_flag = AttributeMatchFlag::kExactly;
   } else if (str == "FULLSTRING") {
@@ -46,6 +47,7 @@ PlatformResult AttributeMatchFlagFromString(
 
 PlatformResult CompositeFilterTypeFromString(
     const std::string &str, CompositeFilterType *comp_filter_type) {
+  LoggerD("Enter");
   if (str == "UNION") {
     *comp_filter_type = CompositeFilterType::kUnion;
   } else if (str == "INTERSECTION") {
@@ -61,22 +63,27 @@ PlatformResult CompositeFilterTypeFromString(
 }
 
 void FilterVisitor::SetOnAttributeFilter(const AttributeFilterOnVisit &func) {
-    m_attributeFilterOnVisit = func;
+  LoggerD("Enter");
+  m_attributeFilterOnVisit = func;
 }
 
 void FilterVisitor::SetOnAttributeRangeFilter(const AttributeRangeFilterOnVisit &func) {
-    m_attributeRangeFilterOnVisit = func;
+  LoggerD("Enter");
+  m_attributeRangeFilterOnVisit = func;
 }
 
 void FilterVisitor::SetOnCompositeFilterBegin(const CompositeFilterOnBegin &func) {
-    m_compositeFilterOnBegin = func;
+  LoggerD("Enter");
+  m_compositeFilterOnBegin = func;
 }
 
 void FilterVisitor::SetOnCompositeFilterEnd(const CompositeFilterOnEnd &func) {
-    m_compositeFilterOnEnd = func;
+  LoggerD("Enter");
+  m_compositeFilterOnEnd = func;
 }
 
 PlatformResult FilterVisitor::Visit(const picojson::object &filter) {
+  LoggerD("Enter");
   const std::string &filterType = FromJson<std::string>(filter, "filterType");
   if (filterType == "AttributeFilter") {
     PlatformResult status = VisitAttributeFilter(filter);
@@ -98,6 +105,7 @@ PlatformResult FilterVisitor::Visit(const picojson::object &filter) {
 
 PlatformResult FilterVisitor::VisitAttributeFilter(
     const picojson::object &filter) {
+  LoggerD("Enter");
   const std::string &attribute_name =
       FromJson<std::string>(filter, "attributeName");
 
@@ -118,6 +126,7 @@ PlatformResult FilterVisitor::VisitAttributeFilter(
 
 PlatformResult FilterVisitor::VisitAttributeRangeFilter(
     const picojson::object &filter) {
+  LoggerD("Enter");
   const std::string &attributeName =
       FromJson<std::string>(filter, "attributeName");
   const picojson::value &initialValue = FindValue(filter, "initialValue");
@@ -134,6 +143,7 @@ PlatformResult FilterVisitor::VisitAttributeRangeFilter(
 
 PlatformResult FilterVisitor::VisitCompositeFilter(
     const picojson::object &filter) {
+  LoggerD("Enter");
   CompositeFilterType filter_type;
   PlatformResult status = CompositeFilterTypeFromString(
       FromJson<std::string>(filter, "type"), &filter_type);
index fbcce87f19d99be7f6d0cc99fd702a6463a3d056..cf091b346543bc2ee5ab16dcdc762cebc7dca8b9 100755 (executable)
  */
 
 #include "common/platform_result.h"
+#include "common/logger.h"
 
 namespace common {
 
-PlatformResult::PlatformResult(const ErrorCode& error_code,
-                               const std::string& message)
-  : error_code_(error_code), message_(message) {
+PlatformResult::PlatformResult(const ErrorCode& error_code, const std::string& message) :
+    error_code_(error_code),
+    message_(message)
+{
+  LoggerD("Enter");
 }
 
 picojson::value PlatformResult::ToJSON() const {
+  LoggerD("Enter");
   picojson::value::object obj;
   obj["code"] = picojson::value(static_cast<double>(error_code_));
   if (!message_.empty())
index d32bd0c3c7e48802c12b4a177c8f21590d4dd1a0..1cd236a814d8a87d2a90ddf34743b2382b83eec6 100755 (executable)
@@ -45,10 +45,12 @@ std::map<int, common::VirtualStorage> g_storages;
 std::map<const std::string, common::VirtualRoot> g_virtual_roots;
 
 void AddVirtualRoot(const std::string& name, const std::string& path) {
+  LoggerD("Enter");
   g_virtual_roots.insert(std::make_pair(name, common::VirtualRoot(name, path)));
 }
 
 void OnStorageStateChanged(int storage_id, storage_state_e state, void *user_data) {
+  LoggerD("Enter");
   const auto it = g_storages.find(storage_id);
 
   if (it != g_storages.end()) {
@@ -61,6 +63,7 @@ void OnStorageStateChanged(int storage_id, storage_state_e state, void *user_dat
 bool OnStorageDeviceSupported(int storage_id, storage_type_e type,
                               storage_state_e state, const char *path,
                               void *user_data) {
+  LoggerD("Enter");
   g_storages.insert(std::make_pair(storage_id, common::VirtualStorage(storage_id, type, state, path)));
 
   storage_set_state_changed_cb(storage_id, OnStorageStateChanged, nullptr);
@@ -84,6 +87,7 @@ bool OnStorageDeviceSupported(int storage_id, storage_type_e type,
 }
 
 common::optional<std::string> GetRootDir() {
+  LoggerD("Enter");
   std::string app_id = common::GetCurrentExtension()->GetRuntimeVariable("app_id", 64);
 
   app_info_h app_info;
@@ -183,6 +187,7 @@ VirtualStorage::VirtualStorage(int id, storage_type_e type,
       type_(type),
       state_(state),
       path_(path) {
+  LoggerD("Enter");
   switch (type_) {
     case STORAGE_TYPE_INTERNAL:
       name_ = "internal";
@@ -214,6 +219,7 @@ picojson::value VirtualStorage::ToJson() const {
 }
 
 VirtualFs::VirtualFs() : app_root_(GetRootDir()) {
+  LoggerD("Enter");
   if (app_root_) {
     AddVirtualRoot(kVirtualRootWgtPackage, *app_root_ + "/res/wgt");
     AddVirtualRoot(kVirtualRootWgtPrivate, *app_root_ + "/data");
@@ -237,6 +243,7 @@ VirtualFs::VirtualFs() : app_root_(GetRootDir()) {
 }
 
 VirtualFs::~VirtualFs() {
+  LoggerD("Enter");
   for (const auto kv : g_storages) {
     storage_unset_state_changed_cb(kv.second.id_, OnStorageStateChanged);
   }
@@ -248,6 +255,7 @@ VirtualFs& VirtualFs::GetInstance() {
 }
 
 optional<std::string> VirtualFs::GetVirtualRootDirectory(const std::string& name) const {
+  LoggerD("Enter");
   const auto it = g_virtual_roots.find(name);
   if (it != g_virtual_roots.end()) {
     return it->second.path_;
@@ -259,6 +267,7 @@ optional<std::string> VirtualFs::GetApplicationDirectory() const {
 }
 
 std::string VirtualFs::GetRealPath(const std::string& path_or_uri) const {
+  LoggerD("Enter");
   std::string realpath;
   std::size_t pos = path_or_uri.find(kFileUriPrefix);
   if (pos != std::string::npos) {
@@ -280,6 +289,7 @@ std::string VirtualFs::GetRealPath(const std::string& path_or_uri) const {
 }
 
 std::string VirtualFs::GetVirtualPath(const std::string& real_path) const {
+  LoggerD("Enter");
   for (const auto& kv : g_virtual_roots) {
     if (0 == real_path.compare(0, kv.second.path_.size(), kv.second.path_)) {
       return std::string(real_path).replace(0, kv.second.path_.size(), kv.first);
@@ -289,6 +299,7 @@ std::string VirtualFs::GetVirtualPath(const std::string& real_path) const {
 }
 
 std::vector<VirtualRoot> VirtualFs::GetVirtualRoots() const {
+  LoggerD("Enter");
   std::vector<VirtualRoot> r;
 
   for (const auto kv : g_virtual_roots) {
@@ -299,6 +310,7 @@ std::vector<VirtualRoot> VirtualFs::GetVirtualRoots() const {
 }
 
 std::vector<VirtualStorage> VirtualFs::GetStorages() const {
+  LoggerD("Enter");
   std::vector<VirtualStorage> r;
 
   for (const auto kv : g_storages) {
index 805ae47044bbda549ebfe7ef4e642685187be4d4..fc3d89c6800bcec6a8b9c27174b74dbac79df1ed 100755 (executable)
@@ -76,6 +76,7 @@ bool validateCharacter(char c) {
  */
 
 bool FilesystemBuffer::DecodeData(const std::string& data) {
+  LoggerD("Enter");
   if (data.length() % 4) {
     LoggerE("Buffer has invalid length");
     return false;
@@ -132,6 +133,7 @@ bool FilesystemBuffer::DecodeData(const std::string& data) {
 }
 
 std::string FilesystemBuffer::EncodeData() const {
+  LoggerD("Enter");
   std::string out;
 
   for (size_t i = 0; i < size(); i += 3) {
@@ -164,6 +166,7 @@ FilesystemFile::FilesystemFile(const std::string& path_)
 bool FilesystemFile::Read(FilesystemBuffer* data,
                                size_t offset,
                                size_t length) {
+  LoggerD("Enter");
   if (!data) {
     LoggerE("Missing output buffer");
     return false;
@@ -216,6 +219,7 @@ bool FilesystemFile::Read(FilesystemBuffer* data,
 }
 
 bool FilesystemFile::Write(const FilesystemBuffer& data, size_t offset) {
+  LoggerD("Enter");
   FILE* file = fopen(path.c_str(), "r+");
   if (!file) {
     LoggerE("Cannot open file %s to write!", path.c_str());
index e4fe19fa185df6879b2c7c391a6459d503ca7521..a41763109d32eef526d862b3d4f67270af98ebf1 100755 (executable)
@@ -37,6 +37,7 @@ using namespace common;
 using namespace extension::filesystem;
 
 FilesystemInstance::FilesystemInstance() {
+  LoggerD("Enter");
   using std::placeholders::_1;
   using std::placeholders::_2;
 
@@ -72,7 +73,9 @@ FilesystemInstance::FilesystemInstance() {
   FilesystemManager::GetInstance().AddListener(this);
 }
 
-FilesystemInstance::~FilesystemInstance() {}
+FilesystemInstance::~FilesystemInstance() {
+  LoggerD("enter");
+}
 
 #define CHECK_EXIST(args, name, out)                                       \
   if (!args.contains(name)) {                                              \
@@ -365,6 +368,7 @@ void FilesystemInstance::FileSystemManagerFetchStorages(
 void FilesystemInstance::StartListening(
     const picojson::value& args,
     picojson::object& out) {
+  LoggerD("enter");
   FilesystemManager::GetInstance().StartListening();
   ReportSuccess(out);
 }
@@ -372,6 +376,7 @@ void FilesystemInstance::StartListening(
 void FilesystemInstance::StopListening(
     const picojson::value& args,
     picojson::object& out) {
+  LoggerD("enter");
   FilesystemManager::GetInstance().StopListening();
   ReportSuccess(out);
 }
@@ -389,6 +394,7 @@ void FilesystemInstance::onFilesystemStateChangeSuccessCallback(const common::Vi
 }
 
 void FilesystemInstance::onFilesystemStateChangeErrorCallback() {
+  LoggerD("enter");
   picojson::value event = picojson::value(picojson::object());
   picojson::object& obj = event.get<picojson::object>();
   ReportError(UnknownException(std::string("Failed to registerd listener")), obj);
index 0699a3478f58b2725bf00860b513cb0f2d2e0d30..3c5d997ac7770e61e241149cb537c463daeb03a6 100755 (executable)
@@ -221,6 +221,7 @@ void FilesystemManager::FetchStorages(
 FilesystemManager::FilesystemManager()
     : listener_(nullptr), is_listener_registered_(false) {}
 FilesystemManager::~FilesystemManager() {
+  LoggerD("enter");
   if (is_listener_registered_) {
     for (auto id : ids_) {
       storage_unset_state_changed_cb(id, storage_cb);
@@ -229,6 +230,7 @@ FilesystemManager::~FilesystemManager() {
 }
 
 FilesystemManager& FilesystemManager::GetInstance() {
+  LoggerD("enter");
   static FilesystemManager instance;
   return instance;
 }
@@ -238,6 +240,7 @@ void FilesystemManager::StatPath(
     const std::function<void(const FilesystemStat&)>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
 
+  LoggerD("enter");
   FilesystemStat statData = FilesystemStat::getStat(path);
   if (!statData.valid) {
     error_cb(FilesystemError::NotFound);
@@ -250,6 +253,7 @@ void FilesystemManager::StatPath(
 void FilesystemManager::GetVirtualRoots(
     const std::function<void(const std::vector<common::VirtualRoot>&)>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
+  LoggerD("enter");
   success_cb(common::VirtualFs::GetInstance().GetVirtualRoots());
 }
 
@@ -257,6 +261,7 @@ void FilesystemManager::CreateFile(
     const std::string& path,
     const std::function<void(const FilesystemStat&)>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
+  LoggerD("enter");
   const mode_t create_mode = S_IRWXU | S_IRWXG | S_IRWXO;
   int status;
   status =
@@ -292,6 +297,7 @@ void FilesystemManager::Rename(
     const std::function<void(const FilesystemStat&)>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
 
+  LoggerD("enter");
   int status = rename(oldPath.c_str(), newPath.c_str());
   if (0 == status) {
     FilesystemStat fileStat = FilesystemStat::getStat(newPath);
@@ -344,6 +350,7 @@ void FilesystemManager::UnlinkFile(
     const std::string& path,
     const std::function<void()>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
+  LoggerD("enter");
   if (unlink(path.c_str()) != 0) {
     LoggerE("Error occured while deleting file");
     error_cb(FilesystemError::Other);
@@ -356,6 +363,7 @@ void FilesystemManager::RemoveDirectory(
     const std::string& path,
     const std::function<void()>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
+  LoggerD("enter");
   const int maxDirOpened = 64;
   if (nftw(path.c_str(), unlink_cb, maxDirOpened, FTW_DEPTH | FTW_PHYS) != 0) {
     LoggerE("Error occured");
@@ -372,6 +380,7 @@ void FilesystemManager::FileRead(
     const std::function<void(const std::string&)>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
 
+  LoggerD("enter");
   FilesystemFile file(path);
   FilesystemBuffer buffer;
   if (!file.Read(&buffer, offset, length)) {
@@ -391,6 +400,7 @@ void FilesystemManager::FileWrite(
     const std::function<void()>& success_cb,
     const std::function<void(FilesystemError)>& error_cb) {
 
+  LoggerD("enter");
   FilesystemFile file(path);
   FilesystemBuffer buffer;
   // Decode buffer data
@@ -455,6 +465,7 @@ void FilesystemManager::CopyTo(
   if (FilesystemError::None == retval) {
     success_cb();
   } else {
+    LoggerE("Failed: perform_deep_copy()");
     error_cb(retval);
   }
 }
index 6cc48bc832a3204fc0fdcff5ddea13d4a279c4a9..a407fcc1731ad6d92a67bc38aad83995de271c83 100755 (executable)
@@ -29,6 +29,7 @@ namespace filesystem {
 FilesystemStat::FilesystemStat() : valid(false) {}
 
 picojson::value FilesystemStat::toJSON() const {
+  LoggerD("Enter");
   picojson::value retval = picojson::value(picojson::object());
   picojson::object& obj = retval.get<picojson::object>();
 
@@ -45,6 +46,7 @@ picojson::value FilesystemStat::toJSON() const {
 }
 
 FilesystemStat FilesystemStat::getStat(const std::string& path) {
+  LoggerD("Enter");
   struct stat aStatObj;
   LoggerD("enter");
   if (0 != stat(path.c_str(), &aStatObj)) {
index f0375be53e5860e9810b7d9311b63c65099e8003..1974ae76d6d3cfd4c0c27576b5e9181b65ff5482 100755 (executable)
@@ -20,6 +20,7 @@
 
 namespace FilesystemUtils {
 std::string get_storage_dir_path(int id, storage_directory_e typeToCheck) {
+  LoggerD("Enter");
   int result = STORAGE_ERROR_NONE;
   char* platformPath = NULL;
   result = storage_get_directory(id, typeToCheck, &platformPath);
index 15506676a782b5b70c41b2985b765b75419a9c38..cd89c1e4bf3ba457c6bdde95c8b13c5620d7358d 100755 (executable)
@@ -34,6 +34,7 @@ using common::NotFoundException;
 using common::QuotaExceededException;
 
 MessageportInstance::MessageportInstance() {
+  LoggerD("Enter");
   using std::placeholders::_1;
   using std::placeholders::_2;
   #define REGISTER_SYNC(c, x) \
@@ -51,6 +52,7 @@ MessageportInstance::MessageportInstance() {
 }
 
 MessageportInstance::~MessageportInstance() {
+  LoggerD("Enter");
 }
 
 
@@ -65,6 +67,7 @@ enum MessageportCallbacks {
 };
 
 static void BundleJsonIterator(const char *k, const char *v, void *d) {
+  LoggerD("Enter");
   picojson::value::array *array = static_cast<picojson::value::array *>(d);
   picojson::value::object o;
   o["key"] = picojson::value(k);
@@ -81,6 +84,8 @@ static void BundleJsonIterator(const char *k, const char *v, void *d) {
 static void OnReceiveLocalMessage(int local_port_id,
   const char* remote_app_id, const char* remote_port,
   bool trusted_remote_port, bundle* message, void* user_data) {
+
+  LoggerD("Enter");
   MessageportInstance* object = static_cast<MessageportInstance*>(user_data);
   picojson::value::object o;
   picojson::value::array data;
@@ -106,6 +111,7 @@ static void OnReceiveLocalMessage(int local_port_id,
 
 void MessageportInstance::MessagePortManagerRequestlocalmessageport
   (const picojson::value& args, picojson::object& out) {
+  LoggerD("Enter");
   CHECK_EXIST(args, "localMessagePortName", out)
 
   int portId;
@@ -122,16 +128,20 @@ void MessageportInstance::MessagePortManagerRequestlocalmessageport
   if (portId < 0) {
     switch (portId) {
       case MESSAGE_PORT_ERROR_INVALID_PARAMETER:
+        LoggerE("The input parameter contains an invalid value");
         ReportError(InvalidValuesException
           ("The input parameter contains an invalid value."), out);
         break;
       case MESSAGE_PORT_ERROR_OUT_OF_MEMORY:
+        LoggerE("Out of memory");
         ReportError(UnknownException("Out of memory."), out);
         break;
       case MESSAGE_PORT_ERROR_IO_ERROR:
+        LoggerE("Internal I/O error ocurred");
         ReportError(UnknownException("Internal I/O error ocurred."), out);
         break;
       default:
+        LoggerE("Unknown Exception");
         ReportError(UnknownException("Unknown Exception"), out);
         break;
       }
@@ -143,6 +153,8 @@ void MessageportInstance::MessagePortManagerRequestlocalmessageport
 void MessageportInstance::
   MessagePortManagerRequesttrustedlocalmessageport
     (const picojson::value& args, picojson::object& out) {
+
+  LoggerD("Enter");
   CHECK_EXIST(args, "localMessagePortName", out)
 
   int portId;
@@ -158,16 +170,20 @@ void MessageportInstance::
   if (portId < 0) {
     switch (portId) {
       case MESSAGE_PORT_ERROR_INVALID_PARAMETER:
+        LoggerE("The input parameter contains an invalid value");
         ReportError(InvalidValuesException
           ("The input parameter contains an invalid value."), out);
         break;
       case MESSAGE_PORT_ERROR_OUT_OF_MEMORY:
+        LoggerE("Out of memory");
         ReportError(UnknownException("Out of memory."), out);
         break;
       case MESSAGE_PORT_ERROR_IO_ERROR:
+        LoggerE("Internal I/O error ocurred");
         ReportError(UnknownException("Internal I/O error ocurred."), out);
         break;
       default:
+        LoggerE("Unknown Exception");
         ReportError(UnknownException("Unknown Exception"), out);
         break;
       }
@@ -179,6 +195,7 @@ void MessageportInstance::
 void MessageportInstance::
   MessagePortManagerRequestremotemessageport
     (const picojson::value& args, picojson::object& out) {
+  LoggerD("Enter");
   CHECK_EXIST(args, "remoteMessagePortName", out)
 
   const std::string& remoteMessagePortName =
@@ -193,27 +210,45 @@ void MessageportInstance::
 
   LoggerD("Checking remote port of %s: %s", remoteMessagePortName.c_str(),
     portCheck ? "true" : "false");
+  LoggerD("Error code: -0x%X", -ret);
 
   if (ret == MESSAGE_PORT_ERROR_NONE) {
-    if (portCheck) ReportSuccess(out);
-    else
-      ReportError(NotFoundException
-        ("The port of the target application is not found"), out);
+    if (portCheck)  {
+      ReportSuccess(out);
+    } else {
+      LoggerE("The port of the target application is not found");
+      ReportError(
+          NotFoundException("The port of the target application is not found"),
+          out);
+    }
   } else if (ret == MESSAGE_PORT_ERROR_INVALID_PARAMETER) {
-      ReportError(InvalidValuesException
-        ("An input parameter contains an invalid value."), out);
+    LoggerE("An input parameter contains an invalid value");
+    ReportError(
+        InvalidValuesException("An input parameter contains an invalid value."),
+        out);
   } else if (ret == MESSAGE_PORT_ERROR_OUT_OF_MEMORY) {
-      ReportError(UnknownException("Out of memory."), out);
+    LoggerE("Out of memory");
+    ReportError(UnknownException("Out of memory."), out);
   } else if (ret == MESSAGE_PORT_ERROR_IO_ERROR) {
-      ReportError(UnknownException("Internal I/O error ocurred."), out);
+    // IO error means that remote port does not exist
+    LoggerE("The port of the target application is not found");
+    ReportError(
+        NotFoundException("The port of the target application is not found"),
+        out);
+  } else if (ret == MESSAGE_PORT_ERROR_PORT_NOT_FOUND) {
+    ReportError(
+        NotFoundException("The port of the target application is not found"),
+        out);
   } else {
-      ReportError(UnknownException("Unknown Error"), out);
+    LoggerE("Unknown Error");
+    ReportError(UnknownException("Unknown Error"), out);
   }
 }
 
 void MessageportInstance::
   MessagePortManagerRequesttrustedremotemessageport
     (const picojson::value& args, picojson::object& out) {
+  LoggerD("Enter");
   CHECK_EXIST(args, "remoteMessagePortName", out)
 
   const std::string& remoteMessagePortName =
@@ -226,31 +261,53 @@ void MessageportInstance::
   ret = message_port_check_trusted_remote_port
         (appId.c_str(), remoteMessagePortName.c_str(), &portCheck);
 
-  LoggerD("Checking trusted remoteport of %s:%s",
+  LoggerD("Checking trusted remote port of %s: %s",
     remoteMessagePortName.c_str(), portCheck ? "true":"false");
+  LoggerD("Error code: -0x%X", -ret);
 
-    if (ret == MESSAGE_PORT_ERROR_NONE) {
-      if (portCheck) ReportSuccess(out);
-      else
-        ReportError(NotFoundException
-          ("The port of the target application is not found"), out);
-    } else if (ret == MESSAGE_PORT_ERROR_INVALID_PARAMETER) {
-        ReportError(InvalidValuesException
-          ("An input parameter contains an invalid value."), out);
-    } else if (ret == MESSAGE_PORT_ERROR_OUT_OF_MEMORY) {
-        ReportError(UnknownException("Out of memory."), out);
-    } else if (ret == MESSAGE_PORT_ERROR_IO_ERROR) {
-        ReportError(UnknownException("Internal I/O error ocurred."), out);
-    } else if (ret == MESSAGE_PORT_ERROR_CERTIFICATE_NOT_MATCH) {
-        ReportError(UnknownException(
-        "The remote application is not signed with the same certificate"), out);
+  if (ret == MESSAGE_PORT_ERROR_NONE) {
+    if (portCheck) {
+      ReportSuccess(out);
     } else {
-        ReportError(UnknownException("Unknown Error"), out);
+
+      LoggerE("The port of the target application is not found");
+      ReportError(
+          NotFoundException("The port of the target application is not found"),
+          out);
     }
+  } else if (ret == MESSAGE_PORT_ERROR_INVALID_PARAMETER) {
+    LoggerE("An input parameter contains an invalid value");
+    ReportError(
+        InvalidValuesException("An input parameter contains an invalid value."),
+        out);
+  } else if (ret == MESSAGE_PORT_ERROR_OUT_OF_MEMORY) {
+    LoggerE("Out of memory");
+    ReportError(UnknownException("Out of memory."), out);
+  } else if (ret == MESSAGE_PORT_ERROR_IO_ERROR) {
+    // IO error means that remote port does not exist
+    LoggerE("The port of the target application is not found");
+    ReportError(
+        NotFoundException("The port of the target application is not found"),
+        out);
+  } else if (ret == MESSAGE_PORT_ERROR_PORT_NOT_FOUND) {
+    ReportError(
+        NotFoundException("The port of the target application is not found"),
+        out);
+  } else if (ret == MESSAGE_PORT_ERROR_CERTIFICATE_NOT_MATCH) {
+    LoggerE("The remote application is not signed with the same certificate");
+    ReportError(
+        UnknownException(
+            "The remote application is not signed with the same certificate"),
+        out);
+  } else {
+    LoggerE("Unknown Error");
+    ReportError(UnknownException("Unknown Error"), out);
+  }
 }
 
 void MessageportInstance::RemoteMessagePortSendmessage
   (const picojson::value& args, picojson::object& out) {
+  LoggerD("Enter");
   const std::string& appId = args.get("appId").get<std::string>();
   const std::string& message_port_name =
     args.get("messagePortName").get<std::string>();