void BootManager::startService() { bool result; LSError error; LSErrorInit(&error); GMainLoop *mainLoop = HostBase::instance()->mainLoop(); g_message("BootManager starting..."); if (!LSRegister("org.webosports.bootmgr", &m_service, &error)) { g_warning("Failed in BootManager: %s", error.message); LSErrorFree(&error); return; } if (!LSRegisterCategory(m_service, "/", s_methods, NULL, NULL, &error)) { g_warning("Failed in BootManager: %s", error.message); LSErrorFree(&error); return; } if (!LSGmainAttach(m_service, mainLoop, &error)) { g_warning("Failed in BootManager: %s", error.message); LSErrorFree(&error); return; } if (!LSRegisterServerStatus(m_service, "org.webosports.luna", cbCompositorAvailable, NULL, &error)) { g_warning("Failed to register for compositor status"); LSErrorFree(&error); } }
AmbientLightSensor::AmbientLightSensor () : m_service(NULL) , m_alsEnabled(false) , m_alsIsOn(false) , m_alsPointer(0) , m_alsRegion(ALS_REGION_UNDEFINED) , m_alsSum(0) , m_alsLastOff(0) , m_alsDisplayOn(false) , m_alsSubscriptions(0) , m_alsDisabled(0) , m_alsHiddOnline(false) , m_alsFastRate(false) , m_alsSampleCount(0) , m_alsCountInRegion(0) , m_alsSamplesNeeded (ALS_INIT_SAMPLE_SIZE) , m_alsLastSampleTs (0) { LSError lserror; LSErrorInit(&lserror); bool result; GMainLoop* mainLoop = HostBase::instance()->mainLoop(); result = LSRegister(AMBIENT_LIGHT_SENSOR_ID, &m_service, &lserror); if (!result) { LSErrorPrint (&lserror, stderr); LSErrorFree(&lserror); } result = LSRegisterCategory (m_service, "/control", alsMethods, NULL, NULL, &lserror); if (!result) { LSErrorPrint (&lserror, stderr); LSErrorFree(&lserror); } result = LSCategorySetData (m_service, "/control", this, &lserror); if (!result) { LSErrorPrint (&lserror, stderr); LSErrorFree(&lserror); } result = LSSubscriptionSetCancelFunction(m_service, AmbientLightSensor::cancelSubscription, this, &lserror); if (!result) { LSErrorPrint (&lserror, stderr); LSErrorFree (&lserror); } result = LSGmainAttach(m_service, mainLoop, &lserror); if (!result) { LSErrorPrint (&lserror, stderr); LSErrorFree(&lserror); } result = LSRegisterServerStatus(m_service, "com.palm.hidd", AmbientLightSensor::hiddServiceNotification, this, &lserror); if (!result) { LSErrorPrint (&lserror, stderr); LSErrorFree (&lserror); } #if defined (MACHINE_CASTLE) m_alsEnabled = true; m_alsBorder[0] = 10 * ALS_SAMPLE_SIZE; m_alsBorder[1] = 200 * ALS_SAMPLE_SIZE; m_alsMargin[0] = 2 * ALS_SAMPLE_SIZE; m_alsMargin[1] = (m_alsBorder[1] / 10) > (ALS_SAMPLE_SIZE * 2) ? m_alsBorder[1] / 10 : ALS_SAMPLE_SIZE * 2; #else if (Settings::LunaSettings()->enableAls) { m_alsEnabled = true; g_warning ("ALSCal token found, expecting lux values in light events"); m_alsBorder[ALS_REGION_UNDEFINED] = -1; m_alsBorder[ALS_REGION_DARK] = 6; m_alsBorder[ALS_REGION_DIM] = 100; m_alsBorder[ALS_REGION_INDOOR] = 1000; m_alsBorder[ALS_REGION_OUTDOOR] = INT_MAX; // margins are higher at lower lux values m_alsMargin[ALS_REGION_UNDEFINED] = 0; m_alsMargin[ALS_REGION_DARK] = 4; m_alsMargin[ALS_REGION_DIM] = 10; m_alsMargin[ALS_REGION_INDOOR] = 100; m_alsMargin[ALS_REGION_OUTDOOR] = 0; } else { g_warning ("%s: ALS is not enabled", __PRETTY_FUNCTION__); } #endif m_instance = this; g_debug ("%s started", __PRETTY_FUNCTION__); }