#include <service_types.h>
#include <tizen_error.h>
+#include <service.h>
+
#ifdef __cplusplus
extern "C" {
#endif
int service_loader_unload_service(const char *name);
+int service_loader_get_service(const char* name, service_h *service);
+
#ifdef __cplusplus
}
#endif
bool Service::Init() {
tizen_core_init();
- int ret = tizen_core_task_create(GetName().c_str(), true, &task_);
+ int ret = false;
+ if (info_->UseMainThread())
+ ret = tizen_core_task_create("main", false, &task_);
+ else
+ ret = tizen_core_task_create(GetName().c_str(), true, &task_);
+
if (ret != TIZEN_CORE_ERROR_NONE) {
_E("tizen_core_task_create() is failed. name=%s", GetName().c_str());
return false;
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;
assembly_ = std::make_shared<ServiceAssembly>(path_);
return path_;
}
+bool ServiceInfo::UseMainThread() const {
+ return use_main_thread_;
+}
+
const unsigned int ServiceInfo::GetPriority() const { return priority_; }
std::shared_ptr<ServiceAssembly> ServiceInfo::GetAssembly() const {
const std::string& GetType() const;
const std::string& GetPath() const;
const unsigned int GetPriority() const;
+ bool UseMainThread() const;
std::shared_ptr<ServiceAssembly> GetAssembly() const;
std::shared_ptr<DBusInfo> GetDbusInfo() const;
// std::shared_ptr<VconfInfo> GetVconfInfo() const;
private:
+ bool use_main_thread_ = true;
std::string conf_name_;
std::string name_;
std::string description_;
THROW(SERVICE_ERROR_INVALID_CONTEXT);
}
+ if (service->GetServiceInfo()->UseMainThread()) {
+ _E("Cannot quit main thread service. name=%s", service->GetName().c_str());
+ THROW(SERVICE_ERROR_INVALID_CONTEXT);
+ }
service->Quit();
}
void ListenService(const std::string& name);
void LoadService(const std::string& name);
void UnloadService(const std::string& name);
+ std::shared_ptr<Service> GetService(const std::string& name);
virtual void OnCreate();
virtual void OnDestroy();
void OnActivationEvent(const std::string& name) override;
private:
- std::shared_ptr<Service> GetService(const std::string& name);
std::shared_ptr<ServiceInfo> GetServiceInfo(const std::string& name);
void ServiceStateChangedCb(const Service* service, Service::State state);