Ejemplo n.º 1
0
void svc_accessor::run()
{
    // Create context
    main_context_ = std::shared_ptr<GMainContext>(g_main_context_new(), g_main_context_unref);

    // Run loop
    main_loop_ = std::shared_ptr<GMainLoop>
      (g_main_loop_new(main_context_.get(), TRUE), g_main_loop_unref);

    LShlService* svc = 0;
    // Service handle
    hl::ls_error lserror;
    if (!LSRegisterhlService(svc_name_.c_str(), &svc, &lserror))
        lserror.warning("Error register service.");

    svc_ = std::shared_ptr<LShlService >(
             svc
             , [](LShlService* svc)
               {
                  hl::ls_error lserror;
                  if (!LSUnregisterhlService(svc, &lserror))
                    lserror.warning("LSUnregisterhlService ");
               }
            );

    LSGmainAttachhlService(svc_.get(), main_loop_.get(), &lserror);

    // The bus handle
    if (!(private_bus_ = LShlServiceGetPrivateConnection(svc_.get()))
        || !LSGmainSetPriority(private_bus_, priority_, &lserror))
    {
        lserror.warning("Set priority error.");
    }

    if (!(bus_ = LShlServiceGetPublicConnection(svc_.get()))
            || !LSGmainSetPriority(bus_, priority_, &lserror))
    {
        lserror.warning("Set priority error.");
    }

    std::shared_ptr<GMainLoop > locloop = main_loop_;
    loop_thread_ = std::unique_ptr<std::thread > (
        new std::thread([locloop]()
        {
            g_main_loop_run(locloop.get());
        })
    );
}
Ejemplo n.º 2
0
void Handle::setPriority(int priority) const
{
    Error error;

    if (!LSGmainSetPriority(_handle, priority, error.get()))
    {
        throw error;
    }
}
Ejemplo n.º 3
0
bool
LSGmainSetPriorityPalmService(LSPalmService *psh, int priority, LSError *lserror)
{
    bool retVal;
    _LSErrorIfFail(psh != NULL, lserror);

    if (psh->public_sh)
    {
        retVal = LSGmainSetPriority(psh->public_sh, priority, lserror);
        if (!retVal) return false;
    }
    if (psh->private_sh)
    {
        retVal = LSGmainSetPriority(psh->private_sh, priority, lserror);
        if (!retVal) return false;
    }
    return true;
}