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());
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
_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_);
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_; }
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;
// 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_;
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);
}
}
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;
+}