Ejemplo n.º 1
0
void PowerdProxy::EnableChargerSignals()
{
	MojLogTrace(s_log);
	MojLogInfo(s_log, _T("Enabling charger signals"));

	MojErr err;
	MojErr errs = MojErrNone;
	MojObject params(MojObject::TypeObject);

	err = params.putString(_T("category"), "/com/palm/power");
	MojErrAccumulate(errs, err);

	err = params.putString(_T("method"), "chargerStatus");
	MojErrAccumulate(errs, err);

	if (errs != MojErrNone) {
		throw std::runtime_error("Error populating arguments for subscription "
			"to charger status");
	}

	m_chargerStatus = boost::make_shared<MojoWeakPtrCall<PowerdProxy> >(
		boost::dynamic_pointer_cast<PowerdProxy, RequirementManager>(
			shared_from_this()), &PowerdProxy::ChargerStatusSignal,
		m_service, "palm://com.palm.lunabus/signal/addmatch", params,
		MojoCall::Unlimited);
	m_chargerStatus->Call();
}
Ejemplo n.º 2
0
MojErr MojDbSandwichEngine::close()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
    MojErr err = MojErrNone;
    MojErr errClose = MojErrNone;

    // close seqs before closing their databases
    m_seqs.clear();

    // close dbs
    if (m_seqDb.get()) {
        errClose = m_seqDb->close();
        MojErrAccumulate(err, errClose);
        m_seqDb.reset();
    }
    if (m_indexDb.get()) {
        errClose = m_indexDb->close();
        MojErrAccumulate(err, errClose);
        m_indexDb.reset();
    }
    m_env.reset();
    m_isOpen = false;

    return err;
}
Ejemplo n.º 3
0
MojErr MojDbKindEngine::close()
{
	MojLogTrace(s_log);
	MojErr err = MojErrNone;

	if (isOpen()) {
		// close all kinds
		for (KindMap::ConstIterator i = m_kinds.begin(); i != m_kinds.end(); ++i) {
			MojErr errClose = (*i)->close();
			MojErrAccumulate(err, errClose);
		}
		m_kinds.clear();
		// close index seq/db
		MojErr errClose = m_indexIdSeq->close();
		MojErrAccumulate(err, errClose);
		m_indexIdSeq.reset();
		errClose = m_indexIdDb->close();
		MojErrAccumulate(err, errClose);
		m_indexIdDb.reset();
		// close kind db
		errClose = m_kindDb->close();
		MojErrAccumulate(err, errClose);
		m_kindDb.reset();
		m_locale.clear();
		m_db = NULL;
	}
	return err;
}
Ejemplo n.º 4
0
void PowerdProxy::EnableBatterySignals()
{
	LOG_TRACE("Entering function %s", __FUNCTION__);
	LOG_DEBUG("Enabling battery signals");

	MojErr err;
	MojErr errs = MojErrNone;
	MojObject params(MojObject::TypeObject);

	err = params.putString(_T("category"), "/com/palm/power");
	MojErrAccumulate(errs, err);

	err = params.putString(_T("method"), "batteryStatus");
	MojErrAccumulate(errs, err);

	if (errs != MojErrNone) {
		throw std::runtime_error("Error populating arguments for subscription "
			"to battery status");
	}

	m_batteryStatus = boost::make_shared<MojoWeakPtrCall<PowerdProxy> >(
		boost::dynamic_pointer_cast<PowerdProxy, RequirementManager>(
			shared_from_this()), &PowerdProxy::BatteryStatusSignal,
		m_service, "palm://com.palm.lunabus/signal/addmatch", params,
		MojoCall::Unlimited);
	m_batteryStatus->Call();
}
Ejemplo n.º 5
0
MojErr MojDbLunaServiceApp::close()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
    LOG_DEBUG("[mojodb] stopping...");

	// stop dispatcher
	MojErr err = MojErrNone;
	MojErr errClose = m_dispatcher.stop();
	MojErrAccumulate(err, errClose);
	errClose = m_dispatcher.wait();
	MojErrAccumulate(err, errClose);
	// close services
	errClose = m_mainService.close();
	MojErrAccumulate(err, errClose);

	m_internalHandler->close();
	m_internalHandler.reset();

	errClose = Base::close();
	MojErrAccumulate(err, errClose);

    LOG_DEBUG("[mojodb] stopped");

	return err;
}
Ejemplo n.º 6
0
MojErr MojGmainReactor::SockInfo::dispatch()
{
	MojErr err = MojErrNone;
	MojErr errDispatch = MojErrNone;

	bool readable = m_pollFd.revents & ReadableEvents;
	bool writeable = m_pollFd.revents & WriteableEvents;
	// remove fired events from registered events
	{
		MojThreadGuard guard(m_mutex);
		guint newEvents = 0;
		if ((m_pollFd.events & ReadableEvents) && !readable)
			newEvents |= ReadableEvents;
		if ((m_pollFd.events & WriteableEvents) && !writeable)
			newEvents |= WriteableEvents;
		m_pollFd.events = (gushort) newEvents;
	}
	// dispatch
	if (readable) {
		errDispatch = m_readSig.fire(m_pollFd.fd);
		MojErrAccumulate(err, errDispatch);
	}
	if (writeable) {
		errDispatch = m_writeSig.fire(m_pollFd.fd);
		MojErrAccumulate(err, errDispatch);
	}
	m_pollFd.revents = 0;

	return err;
}
Ejemplo n.º 7
0
MojErr MojSocketService::SocHandler::close()
{
	MojErr err = MojErrNone;
	MojErr errClose = MojSignalHandler::close();
	MojErrAccumulate(err, errClose);
	errClose = m_sock.close();
	MojErrAccumulate(err, errClose);

	return err;
}
Ejemplo n.º 8
0
MojErr MojDbLunaServiceDb::close()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
    MojErr err = MojErrNone;

    m_handler.reset();
    MojErr errClose = m_service.close();
    MojErrAccumulate(err, errClose);
    errClose = m_db.close();
    MojErrAccumulate(err, errClose);

    return err;
}
Ejemplo n.º 9
0
MojErr MojDbLevelQuery::close()
{
	MojErr err = MojErrNone;

	if (m_isOpen) {
		MojErr errClose = MojDbIsamQuery::close();
		MojErrAccumulate(err, errClose);
		errClose = m_cursor.close();
		MojErrAccumulate(err, errClose);
		m_db = NULL;
	}
	return err;
}
Ejemplo n.º 10
0
MojErr MojAppMain::close()
{
	// stop dispatcher
	MojErr err = MojErrNone;
	MojErr errClose = m_dispatcher.stop();
	MojErrAccumulate(err, errClose);
	errClose = m_dispatcher.wait();
	MojErrAccumulate(err, errClose);

	errClose = Base::close();
	MojErrAccumulate(err, errClose);

	return MojErrNone;
}
MojErr IMAccountValidatorApp::close()
{
	MojLogNotice(s_log, _T("%s stopping..."), name().data());

	MojErr err = MojErrNone;
	MojErr errClose = m_service.close();
	MojErrAccumulate(err, errClose);
	errClose = Base::close();
	MojErrAccumulate(err, errClose);

	MojLogNotice(s_log, _T("%s stopped."), name().data());

	return err;
}
void ResourceContainer::PushJson(MojObject& array) const
{
	MojErr errs = MojErrNone;

	MojObject rep(MojObject::TypeObject);

	MojErr err = ToJson(rep);
	MojErrAccumulate(errs, err);

	err = array.push(rep);
	MojErrAccumulate(errs, err);

	if (errs) {
		throw std::runtime_error("Unable to convert resource container to "
			"JSON object");
	}
}
Ejemplo n.º 13
0
MojErr MojDbQuotaEngine::close()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

	MojErr err = MojErrNone;
	MojErr errClose = MojDbPutHandler::close();
	MojErrAccumulate(err, errClose);
	if (m_usageDb.get()) {
		errClose = m_usageDb->close();
		MojErrAccumulate(err, errClose);
		m_usageDb.reset();
	}
	m_quotas.clear();
	m_isOpen = false;

	return err;
}
Ejemplo n.º 14
0
MojErr MojDbQuotaEngine::close()
{
	MojLogTrace(s_log);

	MojErr err = MojErrNone;
	MojErr errClose = MojDbPutHandler::close();
	MojErrAccumulate(err, errClose);
	if (m_usageDb.get()) {
		errClose = m_usageDb->close();
		MojErrAccumulate(err, errClose);
		m_usageDb.reset();
	}
	m_quotas.clear();
	m_isOpen = false;

	return err;
}
Ejemplo n.º 15
0
void PowerdScheduler::UpdateTimeout(time_t nextWakeup, time_t curTime)
{
	LOG_AM_TRACE("Entering function %s", __FUNCTION__);
	LOG_AM_DEBUG("Updating powerd scheduling callback - nextWakeup %llu, current time %llu",
		(unsigned long long)nextWakeup, (unsigned long long)curTime);

	MojErr err;
	MojErr errs = MojErrNone;

	MojObject params;

	params.putBool("wakeup", true);

	char formattedTime[32];
	FormatWakeupTime(nextWakeup, formattedTime, sizeof(formattedTime));

	err = params.putString(_T("at"), formattedTime);
	MojErrAccumulate(errs, err);

	err = params.putString(_T("key"), PowerdWakeupKey);
	MojErrAccumulate(errs, err);

	err = params.putString(_T("uri"),
		"palm://com.palm.activitymanager/callback/scheduledwakeup");
	MojErrAccumulate(errs, err);

	MojObject cbParams(MojObject::TypeObject);
	err = params.put(_T("params"), cbParams);
	MojErrAccumulate(errs, err);

	if (errs) {
		LOG_AM_ERROR(MSGID_SET_TIMEOUT_PARAM_ERR,0,
			"Error constructing parameters for powerd set timeout call");
		throw std::runtime_error("Error constructing parameters for "
			"powerd set timeout call");
	}

	m_call = boost::make_shared<MojoWeakPtrCall<PowerdScheduler> >(
		boost::dynamic_pointer_cast<PowerdScheduler, Scheduler>(
			shared_from_this()), &PowerdScheduler::HandleTimeoutSetResponse,
		m_service, "palm://com.palm.power/timeout/set", params);
	m_call->Call();
}
Ejemplo n.º 16
0
MojErr MojSock::close()
{
    MojErr err = MojErrNone;
    if (m_sock != MojInvalidSock) {
        MojErr errClose = MojSockClose(m_sock);
        MojErrAccumulate(err, errClose);
        m_sock = MojInvalidSock;
    }
    return err;
}
Ejemplo n.º 17
0
MojErr MojDbLevelEnvTxn::commitImpl()
{
    MojErr accErr = MojErrNone;
    for(TableTxns::iterator it = m_tableTxns.begin();
                            it != m_tableTxns.end();
                            ++it)
    {
        MojErr err = (*it)->commitImpl();
        MojErrAccumulate(accErr, err);
    }
    return accErr;
}
Ejemplo n.º 18
0
MojErr MojDbBerkeleyEngine::close()
{
	MojLogTrace(MojDbBerkeleyEngine::s_log);
	MojErr err = MojErrNone;
	MojErr errClose = MojErrNone;

	// close dbs
	if (m_seqDb.get()) {
		errClose = m_seqDb->close();
		MojErrAccumulate(err, errClose);
		m_seqDb.reset();
	}
	if (m_indexDb.get()) {
		errClose = m_indexDb->close();
		MojErrAccumulate(err, errClose);
		m_indexDb.reset();
	}
	m_env.reset();
	m_isOpen = false;

	return err;
}
Ejemplo n.º 19
0
MojErr MojDbKind::close()
{
	MojLogTrace(s_log);

	MojErr err = MojErrNone;
	MojErr errClose = clearSupers();
	MojErrAccumulate(err, errClose);

	for (IndexVec::ConstIterator i = m_indexes.begin();
		 i != m_indexes.end(); ++i) {
		errClose = (*i)->close();
		MojErrAccumulate(err, errClose);
	}

	m_indexes.clear();
	m_indexObjects.clear();
	m_schema.clear();
	m_revSets.clear();
	m_superIds.clear();

	return err;
}
Ejemplo n.º 20
0
MojErr MojDbSearchCursor::close()
{
    MojErr err = MojErrNone;
    MojErr errClose = MojDbCursor::close();
    MojErrAccumulate(err, errClose);

    m_limit = 0;
    m_pos = NULL;
    m_limitPos = NULL;
    m_items.clear();

    return err;
}
Ejemplo n.º 21
0
MojErr MojDbKind::drop(MojDbReq& req)
{
	MojLogTrace(s_log);

	MojErr err = checkPermission(OpKindUpdate, req);
	MojErrCheck(err);
	err = req.curKind(this);
	MojErrCheck(err);

	// drop indexes
	MojErr errAcc = MojErrNone;
	for (IndexVec::ConstIterator i = m_indexes.begin();
		 i != m_indexes.end(); ++i) {
		errAcc = dropIndex(i->get(), req);
		MojErrAccumulate(err, errAcc);
	}
	m_indexes.clear();

	// remove self from super/sub kinds
	errAcc = close();
	MojErrAccumulate(err, errAcc);

	return err;
}
Ejemplo n.º 22
0
MojErr MojDbSearchCursor::close()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

    MojErr err = MojErrNone;
    MojErr errClose = MojDbCursor::close();
    MojErrAccumulate(err, errClose);

    m_limit = 0;
    m_pos = NULL;
    m_limitPos = NULL;
    m_items.clear();

    return err;
}
Ejemplo n.º 23
0
MojErr MojService::close()
{
	MojLogTrace(s_log);

	// cancel all pending subscriptions
	MojErr err = MojErrNone;
	for (SubscriptionMap::ConstIterator i = m_subscriptions.begin(); i != m_subscriptions.end();) {
		SubscriptionKey key = (i++).key();
		MojErr errClose = dispatchCancel(key);
		MojErrAccumulate(err, errClose);
	}
	// if you're hitting this assertion, you probably aren't releasing your message in your cancel handler
	MojAssert(m_subscriptions.empty());

	return err;
}
Ejemplo n.º 24
0
MojErr MojLunaService::close()
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

	MojErr err = MojErrNone;
	MojErr errClose = MojService::close();
	MojErrAccumulate(err, errClose);

	// destroy service handle
	MojLunaErr lserr;
	bool retVal;
	if (m_service) {
		retVal = LSUnregisterPalmService(m_service, lserr);
		m_service = NULL;
		m_handle = NULL;
		MojLsErrAccumulate(err, retVal, lserr);
	} else if (m_handle) {
		retVal = LSUnregister(m_handle, lserr);
		m_handle = NULL;
		MojLsErrAccumulate(err, retVal, lserr);
	}
	return err;
}
Ejemplo n.º 25
0
MojErr MojDb::putKind(MojObject& obj, MojUInt32 flags, MojDbReqRef req)
{
	MojErr err = beginReq(req, true);
	MojErrCheck(err);

    // get id
    MojString id;
    err = obj.getRequired(MojDbServiceDefs::IdKey, id);
    MojErrCheck(err);

	MojLogInfo(s_log, _T("putKind: %s \n"), id.data());
	MojLogWarning(s_log, _T("putKind: %s \n"), id.data());

	// set _kind and _id
	err = obj.putString(KindKey, MojDbKindEngine::KindKindId);
	MojErrCheck(err);
	MojString dbId;
	err = formatKindId(id, dbId);
	MojErrCheck(err);
	err = obj.putString(IdKey, dbId);
	MojErrCheck(err);

	// put the object
	MojDbAdminGuard guard(req);
	err = putImpl(obj, flags | FlagForce, req);
	MojErrCheck(err);
	guard.unset();

	// attempt the putKind
	MojErr errAcc = m_kindEngine.putKind(obj, req);
	MojErrAccumulate(err, errAcc);

	err = commitKind(id, req, err);
	MojErrCheck(err);

	return MojErrNone;
}
Ejemplo n.º 26
0
MojErr MojDb::close()
{
	MojLogTrace(s_log);
	MojThreadWriteGuard guard(m_schemaLock);

	MojErr err = MojErrNone;
	MojErr errClose = MojErrNone;

	if (m_isOpen) {
		MojLogInfo(s_log, _T("closing..."));

		errClose = m_quotaEngine.close();
		MojErrAccumulate(err, errClose);
		errClose = m_permissionEngine.close();
		MojErrAccumulate(err, errClose);
		errClose = m_kindEngine.close();
		MojErrAccumulate(err, errClose);
		if (m_idSeq.get()) {
			errClose = m_idSeq->close();
			MojErrAccumulate(err, errClose);
			m_idSeq.reset();
		}
		if (m_objDb.get()) {
			errClose = m_objDb->close();
			MojErrAccumulate(err, errClose);
			m_objDb.reset();
		}
		if (m_storageEngine.get()) {
			errClose = m_storageEngine->close();
			MojErrAccumulate(err, errClose);
			m_storageEngine.reset();
		}
		m_isOpen = false;
		MojLogInfo(s_log, _T("close completed"));
	}
	return err;
}
Ejemplo n.º 27
0
MojErr MojDb::delKind(const MojObject& id, bool& foundOut, MojUInt32 flags, MojDbReqRef req)
{
	MojLogTrace(s_log);
	foundOut = false;

	MojErr err = beginReq(req, true);
	MojErrCheck(err);

	// del kind obj
	MojString idStr;
	err = id.stringValue(idStr);
	MojErrCheck(err);

	MojDbKind *pk = NULL;

	// If Kinds has sub-kinds, we give an error
	err = m_kindEngine.getKind(idStr.data(), pk);
	MojErrCheck(err);

	if (pk->nsubkinds() > 0) {
		MojLogWarning(s_log, _T("delKind_error: %s has %d subkinds \n"), idStr.data(), pk->nsubkinds());
		MojErrThrow(MojErrDbKindHasSubKinds);
	}

	//MojLogInfo(s_log, _T("delKind: %s \n"), idStr.data());
	MojLogWarning(s_log, _T("delKind: %s \n"), idStr.data());

	err = m_kindEngine.checkOwnerPermission(idStr, req);
	MojErrCheck(err);

	MojString dbId;
	err = formatKindId(idStr, dbId);
	MojErrCheck(err);
	MojObject deleted;
	bool found = false;
	MojDbAdminGuard adminGuard(req);
	err = delImpl(dbId, found, deleted, req, flags);
	MojErrCheck(err);

	if (found) {
		// del objects
		MojDbQuery query;
		err = query.from(idStr);
		MojErrCheck(err);
		err = query.includeDeleted(true);
		MojErrCheck(err);
		MojUInt32 count;
		req->fixmode(true); 
		err = delImpl(query, count, req, flags | FlagPurge);
		MojErrCheck(err);

		// del associated permissions
		query.clear();
		err = query.from(MojDbKindEngine::PermissionId);
		MojErrCheck(err);
		err = query.where(MojDbServiceDefs::ObjectKey, MojDbQuery::OpEq, idStr);
		MojErrCheck(err);
		req->fixmode(true);
		err = delImpl(query, count, req, flags);
		MojErrCheck(err);

		// del kind
		MojErr errAcc = m_kindEngine.delKind(idStr, req);
		MojErrAccumulate(err, errAcc);
	}
	err = commitKind(idStr, req, err);
	MojErrCheck(err);
	foundOut = found;

	return MojErrNone;
}