예제 #1
0
void InputManager::startService()
{
	LSError lserror;
	LSErrorInit(&lserror);
	bool result;
	
	GMainLoop* mainLoop = HostBase::instance()->mainLoop();

	g_debug ("%s starting", __PRETTY_FUNCTION__);

	result = LSRegisterPalmService(LUNA_KEYS, &m_palmService, &lserror);
	if (!result) goto Error;

	// Save off public and private bus handles
	m_publicService = LSPalmServiceGetPublicConnection(m_palmService);
	if (NULL == m_publicService) {
		g_message("unable to get public handle");
	}

	
	m_service = LSPalmServiceGetPrivateConnection(m_palmService);
	if (NULL == m_service) {
		g_message("unable to get private handle");
	}

	// We're providing the notion of "key categories" that you can
	// subscribe to in order to get notifications when a key is pressed
	result = LSPalmServiceRegisterCategory(m_palmService, CATEGORY_AUDIO, s_audioMethods, NULL, NULL, this, &lserror);
	if (!result) goto Error;

	// For now the media keys are the only ones that have been requested
	// to be put on the public bus -- the calling syntax is a little
	// strange, but when using this call everything on the public bus
	// is also put on the private bus
	result = LSPalmServiceRegisterCategory(m_palmService, CATEGORY_MEDIA, s_mediaMethods, NULL, NULL, this, &lserror);
	if (!result) goto Error;
	
	result = LSPalmServiceRegisterCategory(m_palmService, CATEGORY_SWITCHES, s_switchesMethods, NULL, NULL, this, &lserror);
	if (!result) goto Error;

	result = LSPalmServiceRegisterCategory(m_palmService, CATEGORY_HEADSET, s_headsetMethods, NULL, NULL, this, &lserror);
	if (!result) goto Error;

	result = LSGmainAttachPalmService(m_palmService, mainLoop, &lserror);
	if (!result) goto Error;
	
	g_debug ("%s service started", LUNA_KEYS);

	return;

Error:
	if (LSErrorIsSet(&lserror)) {
		LSErrorPrint(&lserror, stderr);
		LSErrorFree(&lserror);
	}

	g_debug(":%s: Unable to start service", __PRETTY_FUNCTION__);
}
bool service_register(const char *name)
{
	bool rc;
	LSError err;
	LSErrorInit(&err);

	loop = g_main_loop_new(NULL, FALSE);

	if(loop == NULL)
		goto end;

	rc = LSRegisterPalmService(name, &handle, &err);
	if(rc)
	{
		pub = LSPalmServiceGetPublicConnection(handle);
		prv = LSPalmServiceGetPrivateConnection(handle);
	}
	else
		goto end;

	rc = LSPalmServiceRegisterCategory(handle, "/", methods, NULL, NULL,
					   NULL, &err);
	LSGmainAttachPalmService(handle, loop, &err);
	if(!rc)
		goto end;
end:
	if(LSErrorIsSet(&err))
	{
		LSErrorPrint(&err, stderr);
		LSErrorFree(&err);
		puts("servece startup error...");
	}
	return rc;
}
예제 #3
0
static int
_power_timeout_init(void)
{
    /* Set up luna service */


    psh = GetPalmService();

    LSError lserror;
    LSErrorInit(&lserror);
    if (!LSPalmServiceRegisterCategory(psh,
                "/timeout", timeout_methods /*public*/, NULL /*private*/, NULL, NULL, &lserror)) {
        POWERDLOG(LOG_ERR, "%s could not register category: %s",
                __FUNCTION__, lserror.message);
        LSErrorFree(&lserror);
        goto error;
    }

    if (!LSRegisterCategory(GetLunaServiceHandle(),
          "/time", time_methods, NULL, NULL, &lserror))
      {
          goto error;
      }

    UEventListen("/com/palm/powerd/timechange/uevent", _timechange_callback);

    return 0;

error:
    return -1;
}
예제 #4
0
MojErr MojLunaService::addCategory(const MojChar* name, CategoryHandler* handler)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(name && handler);
	MojAssertMutexUnlocked(m_mutex);
	MojThreadGuard guard(m_mutex);

	// create array of LSMethods
	MethodVec pubMethods;
	MethodVec privMethods;
	const CategoryHandler::CallbackMap& callbacks = handler->callbacks();
	for (CategoryHandler::CallbackMap::ConstIterator i = callbacks.begin();
		 i != callbacks.end();
		 i++) {
			LSMethod m = {i.key(), &handleRequest};

			MethodVec& methods = i->m_pub ? pubMethods : privMethods;
			MojErr err = methods.push(m);
			MojErrCheck(err);
	}
    LSMethod nullMethod = {NULL, NULL};
    MojErr err = pubMethods.push(nullMethod);
    MojErrCheck(err);
    err = privMethods.push(nullMethod);
    MojErrCheck(err);

    // create category object to hang on to method array
	MojRefCountedPtr<LunaCategory> cat(new LunaCategory(this, handler, pubMethods, privMethods));
	MojAllocCheck(cat.get());
	LSMethod* pubLsMethods = const_cast<LSMethod*>(cat->m_pubMethods.begin());
	LSMethod* privLsMethods = const_cast<LSMethod*>(cat->m_privMethods.begin());

	MojLunaErr lserr;
    bool retVal;
    if (m_service) {
    	retVal = LSPalmServiceRegisterCategory(m_service, name, pubLsMethods, privLsMethods, NULL, cat.get(), lserr);
    	MojLsErrCheck(retVal, lserr);
    } else {
    	MojAssert(m_handle);
    	retVal = LSRegisterCategory(m_handle, name, privLsMethods, NULL, NULL, lserr);
    	MojLsErrCheck(retVal, lserr);
        retVal = LSCategorySetData(m_handle, name, cat.get(), lserr);
        MojLsErrCheck(retVal, lserr);
    }

	MojString categoryStr;
	err = categoryStr.assign(name);
	MojErrCheck(err);
	err = m_categories.put(categoryStr, cat);
	MojErrCheck(err);

	return MojErrNone;
}
예제 #5
0
bool ImageServices::init(MainLoopProvider * p)
{
	if (p == NULL)
		return false;
	
	//grab the main loop ptr from the provider
	m_p_mainloop = p->getMainLoopPtr();
	if (m_p_mainloop == NULL)
		return false;
	
	//register the service
	LSError lsError;
	bool result;

	LSErrorInit(&lsError);

	// Register the service
	result = LSRegisterPalmService("com.palm.image", &m_service, &lsError);
	if (!result) {
		g_warning("Failed to register service: com.palm.image");
		return false;
	}

	m_serviceHandlePublic = LSPalmServiceGetPublicConnection(m_service);
	m_serviceHandlePrivate = LSPalmServiceGetPrivateConnection(m_service);
	result = LSGmainAttachPalmService(m_service, m_p_mainloop, &lsError);
	if (!result) {
		g_warning("Failed to attach service handle to main loop");
		LSErrorFree(&lsError);
		LSErrorInit(&lsError);
		result = LSUnregisterPalmService(m_service,&lsError);
		if (!result)
			LSErrorFree(&lsError);
		return false;
	}
	
	//register methods
	result = LSPalmServiceRegisterCategory( m_service, "/", s_methods_public, s_methods_private,
			NULL, this, &lsError);
	if (!result) {
		g_warning("Failed in registering handler methods on /: %s", lsError.message);
		LSErrorFree(&lsError);
		result = LSUnregisterPalmService(m_service,&lsError);
		if (!result)
			LSErrorFree(&lsError);
		return false;
	}

	return true;

}
void DeviceInfoService::setServiceHandle(LSPalmService* service)
{
	m_service = service;

	LSError lsError;
	LSErrorInit(&lsError);

	bool result = LSPalmServiceRegisterCategory(m_service, "/deviceInfo",
												NULL, s_device_methods,
												NULL, this, &lsError);
	if (!result) {
		qCritical() << "Failed in registering deviceinfo handler method:" << lsError.message;
		LSErrorFree(&lsError);
		return;
	}
}
static int initialize_luna_service(void)
{
	LSError error;

	g_message("Initializing luna service ...");

	LSErrorInit(&error);

	if (!LSPalmServiceRegisterCategory(palm_service_handle, "/", NULL, service_methods,
			NULL, NULL, &error)) {
		g_warning("Could not register service category");
		LSErrorFree(&error);
		return -EIO;
	}

	return 0;
}
예제 #8
0
bool SysmgrDebuggerService::startup()
{
	LSError lserror;
	LSErrorInit(&lserror);
	bool result;

	if (m_p_service)
	{
		qWarning() << __FUNCTION__ << " will exit since it seems the service handle is already active; shutdown first" ;
		return true;
	}

	GMainLoop *mainLoop = HostBase::instance()->mainLoop();

	result = LSRegisterPalmService("com.palm.sysmgrdebugger", &m_p_service, &lserror);
	if (!result)
	{
		qWarning() << __FUNCTION__ << " failed" ;
		LSErrorFree(&lserror);
		m_p_service = 0;
		return false;
	}

	result = LSPalmServiceRegisterCategory( m_p_service, "/", s_public_methods, s_private_methods,
			NULL, NULL, &lserror);
	if (!result)
	{
		qWarning() << __FUNCTION__ << " failed" ;
		LSErrorFree(&lserror);
		(void)shutdown();
		return false;
	}

	result = LSGmainAttachPalmService(m_p_service, mainLoop, &lserror);
	if (!result)
	{
		qWarning() << __FUNCTION__ << " failed" ;
		LSErrorFree(&lserror);
		(void)shutdown();
		return false;
	}

	//qDebug() << __FUNCTION__ << " Ok" ;
	return true;
}
예제 #9
0
static int
com_palm_power_lunabus_init(void)
{
    LSError lserror;
    LSErrorInit(&lserror);

    if (!LSPalmServiceRegisterCategory(GetPalmService(), "/com/palm/power",
        com_palm_power_public_methods, com_palm_power_methods, com_palm_power_signals,
        NULL, &lserror))
    {
        goto error;
    }
    return 0;

error:
    LSErrorPrint(&lserror, stderr);
    LSErrorFree(&lserror);
    return -1;
}
예제 #10
0
void TimeZoneService::setServiceHandle(LSPalmService* service)
{
	m_service = service;
	
    LSError lsError;
    LSErrorInit(&lsError);

    bool result = LSPalmServiceRegisterCategory(m_service, "/timezone",
												s_methods, NULL,
												NULL, this, &lsError);
    if (!result) {
		g_critical("Failed in registering timezone handler method: %s", lsError.message);
    	LSErrorFree(&lsError);
    	return;
    }

    m_serviceHandlePublic = LSPalmServiceGetPublicConnection(m_service);
    m_serviceHandlePrivate = LSPalmServiceGetPrivateConnection(m_service);	
}
예제 #11
0
bool register_methods(LSPalmService *serviceHandle, LSError lserror)
{
	log("register_methods");
	return LSPalmServiceRegisterCategory(serviceHandle, "/", luna_methods, NULL, NULL, NULL, &lserror);
}