Change usethread conf naming
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 28 Apr 2025 04:29:13 +0000 (13:29 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 14 May 2025 11:37:17 +0000 (20:37 +0900)
Changes:
 - use-main-thread -> usethread

Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/service.cc
src/service_info.cc
src/service_info.hh
src/service_loader.cc
src/stub_service_loader.cc

index 39d3c6c3b636d2128426359d0702855aabd4a103..78bf275ac2bf9bc2bd8f439110bcca371fc45b91 100644 (file)
@@ -65,10 +65,10 @@ Service::~Service() {
 bool Service::Init() {
   tizen_core_init();
   int ret = false;
-  if (info_->UseMainThread())
-    ret = tizen_core_task_create("main", false, &task_);
-  else
+  if (info_->UseThread())
     ret = tizen_core_task_create(GetName().c_str(), true, &task_);
+  else
+    ret = tizen_core_task_create("main", false, &task_);
 
   if (ret != TIZEN_CORE_ERROR_NONE) {
     _E("tizen_core_task_create() is failed. name=%s", GetName().c_str());
index 0c3d4bfb4c474520c402dac082df904670ad10fb..78c08e3e516f89e7ee33d69f29744955bb9f69db 100644 (file)
@@ -36,11 +36,11 @@ static const std::string kPathActivation = kActivationMethod + ":path";
 static const std::string kPathActivationMode = kActivationMethod + ":mode";
 static const std::string kDBusActivation = kActivationMethod + ":busname";
 static const std::string kVconfActivation = kActivationMethod + ":vconf";
+static const std::string kUseThread =
+    kTagUnitedService + ":usethread";
 
 static const int kMinPriority = 1;
 static const int kMaxPriority = 99;
-static const std::string kUseMainThread =
-    kTagUnitedService + ":use-main-thread";
 
 }  // namespace
 
@@ -59,9 +59,9 @@ ServiceInfo::ServiceInfo(std::string conf_name,
   _D("Type=%s", type_.c_str());
   path_ = dictionary->Get(kPath);
   _D("Path=%s", path_.c_str());
-  std::string use_main_thread = dictionary->Get(kUseMainThread);
-  if (use_main_thread == "true")
-    use_main_thread_ = true;
+  std::string use_thread = dictionary->Get(kUseThread);
+  if (use_thread == "false")
+    use_thread_ = false;
 
   assembly_ = std::make_shared<ServiceAssembly>(path_);
 
@@ -146,8 +146,8 @@ const std::string& ServiceInfo::GetPath() const {
   return path_;
 }
 
-bool ServiceInfo::UseMainThread() const {
-  return use_main_thread_;
+bool ServiceInfo::UseThread() const {
+  return use_thread_;
 }
 
 const unsigned int ServiceInfo::GetPriority() const { return priority_; }
index cdb424cf9060f4409e75fb2b845f74ce6b0f9604..1595825b5e03566c2842f3edee22cb2875749a95 100644 (file)
@@ -42,7 +42,7 @@ class ServiceInfo {
   const std::string& GetType() const;
   const std::string& GetPath() const;
   const unsigned int GetPriority() const;
-  bool UseMainThread() const;
+  bool UseThread() const;
   std::shared_ptr<ServiceAssembly> GetAssembly() const;
 
   std::shared_ptr<DBusInfo> GetDbusInfo() const;
@@ -51,7 +51,7 @@ class ServiceInfo {
   // std::shared_ptr<VconfInfo> GetVconfInfo() const;
 
  private:
-  bool use_main_thread_ = false;
+  bool use_thread_ = true;
   std::string conf_name_;
   std::string name_;
   std::string description_;
index aa181e4928edc821d52fd4032e75dca09599225b..b2e2ae5ef34aa5b6832e0ca02a0e5ae9385ee2c8 100755 (executable)
@@ -299,7 +299,7 @@ void ServiceLoader::QuitService(const std::string& name) {
     THROW(SERVICE_ERROR_INVALID_CONTEXT);
   }
 
-  if (service->GetServiceInfo()->UseMainThread()) {
+  if (!service->GetServiceInfo()->UseThread()) {
     _E("Cannot quit main thread service. name=%s", service->GetName().c_str());
     THROW(SERVICE_ERROR_INVALID_CONTEXT);
   }
index bd4405d643e1269eb0a227a36e296be9b94566df..54bde185e9fc9b0bf6b638bb2e9964db06796d8c 100644 (file)
@@ -234,3 +234,24 @@ API int service_loader_unload_service(const char* name) {
   }
   return SERVICE_ERROR_NONE;
 }
+
+API int service_loader_get_service(const char* name, service_h* service) {
+  if (!name || !service) {
+    _E("Invalid parameter");
+    return SERVICE_ERROR_INVALID_PARAMETER;
+  }
+
+  if (!::context) {
+    _E("Invalid context");
+    return SERVICE_ERROR_INVALID_CONTEXT;
+  }
+
+  try {
+    *service = static_cast<service_h>(::context->GetService(name).get());
+  } catch (const tizen_base::Exception& e) {
+    _E("Exception occurs. error: %s", e.what());
+    return e.GetErrorCode();
+  }
+
+  return SERVICE_ERROR_NONE;
+}