当前位置: 首页>>代码示例>>C++>>正文


C++ LSMessageGetPayload函数代码示例

本文整理汇总了C++中LSMessageGetPayload函数的典型用法代码示例。如果您正苦于以下问题:C++ LSMessageGetPayload函数的具体用法?C++ LSMessageGetPayload怎么用?C++ LSMessageGetPayload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LSMessageGetPayload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clientCancel

static bool
clientCancel(LSHandle *sh, LSMessage *message, void *ctx)
{
    LSCall(GetLunaServiceHandle(), SLEEPD_SUSPEND_SERVICE"clientCancelByName",
	       		LSMessageGetPayload(message), NULL,(void *)message, NULL, NULL);
    return true;
}
开发者ID:jukkahonkela-owo,项目名称:powerd,代码行数:7,代码来源:suspend_ipc.c

示例2: g_debug

bool AmbientLightSensor::cancelSubscription(LSHandle *sh, LSMessage *message, void *ctx)
{
    bool result = false;

    g_debug ("%s: category %s, method %s", __FUNCTION__, LSMessageGetCategory(message), LSMessageGetMethod(message));
    AmbientLightSensor *als = (AmbientLightSensor *)ctx;

    if (0 == strcmp (LSMessageGetMethod(message), "status") &&
        0 == strcmp (LSMessageGetCategory(message), "/control"))
    {
        als->m_alsSubscriptions--;
        if (als->m_alsSubscriptions == 0)
        {
			bool disable = false;
			const char* str = LSMessageGetPayload(message);
			if (str) {
				json_object* root = json_tokener_parse(str);
				if (root && !is_error(root)) {
					result = true;
					disable = json_object_get_boolean(json_object_object_get(root, "disableALS"));
					json_object_put(root);
				}
			}
            if (result && disable)
                als->m_alsDisabled--;
            als->off ();
        }
    }
    return true;
}
开发者ID:Bradleygamble,项目名称:luna-sysmgr,代码行数:30,代码来源:AmbientLightSensor.cpp

示例3: shutdownServicesAck

static bool
shutdownServicesAck(LSHandle *sh, LSMessage *message,
                             void *user_data)
{
    struct json_object *object = json_tokener_parse(
                                    LSMessageGetPayload(message));
    if (is_error(object))
    {
        LSMessageReplyErrorBadJSON(sh, message);
        goto cleanup;
    }
    const char *clientId = json_object_get_string(
            json_object_object_get(object, "clientId"));
    if (!clientId)
    {
        LSMessageReplyErrorInvalidParams(sh, message);
        goto cleanup;
    }

    ShutdownEvent event;
    event.id = kShutdownEventAck;
    event.client = client_lookup_service(clientId);

    shutdown_state_dispatch(&event);

cleanup:
    if (!is_error(object)) json_object_put(object);
    return true;
}
开发者ID:jukkahonkela-owo,项目名称:sleepd,代码行数:29,代码来源:shutdown.c

示例4: machineOff

/**
 * @brief Shutdown the machine forcefully by calling "tellbootie"
 *
 * @param sh
 * @param message with "reason" field for shutdown reason.
 * @param user_data
 */
static bool
machineOff(LSHandle *sh, LSMessage *message,
                             void *user_data)
{
    struct json_object *object = json_tokener_parse(
                                    LSMessageGetPayload(message));
    if (is_error(object))
    {
        LSMessageReplyErrorBadJSON(sh, message);
        goto cleanup;
    }
    const char *reason = json_object_get_string(
            json_object_object_get(object, "reason"));
    if (!reason)
    {
        LSMessageReplyErrorInvalidParams(sh, message);
        goto cleanup;
    }

    MachineForceShutdown(reason);
    LSMessageReplySuccess(sh, message);

cleanup:
    if (!is_error(object)) json_object_put(object);
    return true;
}
开发者ID:jukkahonkela-owo,项目名称:sleepd,代码行数:33,代码来源:shutdown.c

示例5: LSMessageGetPayload

bool InputManager::activityStartCallback(LSHandle* handle, LSMessage* msg, void* userData)
{
	struct json_object* retValObj = NULL;
	bool retVal = false;
	const char* msgStr = LSMessageGetPayload(msg);
	
	struct json_object* respObj = json_tokener_parse(msgStr);
	if (is_error(respObj)) {
		g_message("%s: Unable to parse JSON response: %s\n", __PRETTY_FUNCTION__, msgStr);
		goto Exit;
	}
	
	retValObj = json_object_object_get(respObj, "returnValue");

	if (NULL == retValObj) {
		g_message("%s: Unable to get returnValue from: %s", __PRETTY_FUNCTION__, msgStr);
		goto Exit;
	}

	retVal = json_object_get_boolean(retValObj);
	if (!retVal) {
		g_message("%s: error response: %s", __PRETTY_FUNCTION__, msgStr);
	}

Exit:
	if (!is_error(respObj)) json_object_put(respObj);
	return true;
}
开发者ID:KyleMaas,项目名称:luna-sysmgr,代码行数:28,代码来源:InputManager.cpp

示例6: LSMessageGetPayload

bool EASPolicyManager::cbSecurityPolicy (LSHandle *sh, LSMessage *message, void *data)
{
    const char* str = LSMessageGetPayload(message);
    json_object *root = 0, *results = 0, *policy = 0;

    if (!str)
		goto done;

    root = json_tokener_parse(str);
    if (!root || is_error(root))
		goto done;
    
    results = json_object_object_get (root, "results");
    if (!results) {
		g_debug ("No security policies set, no processing needed");
		goto done;
    }

    EASPolicyManager::instance()->updateDevicePolicy (results);

done:
	
    if (root && !is_error(root))
		json_object_put (root);

    return true;
}
开发者ID:22350,项目名称:luna-sysmgr,代码行数:27,代码来源:EASPolicyManager.cpp

示例7: getFilecacheType_method

bool getFilecacheType_method(LSHandle* lshandle, LSMessage *message, void *ctx) {
  LSError lserror;
  LSErrorInit(&lserror);

  if (access_denied(message)) return true;

  char filename[MAXLINLEN];

  // Extract the id argument from the message
  json_t *object = json_parse_document(LSMessageGetPayload(message));
  json_t *type = json_find_first_label(object, "type");               
  if (!type || (type->child->type != JSON_STRING) || (strspn(type->child->text, ALLOWED_CHARS) != strlen(type->child->text))) {
    if (!LSMessageRespond(message,
			"{\"returnValue\": false, \"errorCode\": -1, \"errorText\": \"Invalid or missing type\"}",
			&lserror)) goto error;
    return true;
  }

  sprintf(filename, "/etc/palm/filecache_types/%s", type->child->text);

  return read_file(message, filename, true);

 error:
  LSErrorPrint(&lserror, stderr);
  LSErrorFree(&lserror);
 end:
  return false;
}
开发者ID:rwhitby,项目名称:impostah,代码行数:28,代码来源:luna_methods.c

示例8: LSMessageGetPayload

bool WindowServerLuna::cbFullEraseCallback(LSHandle* handle, LSMessage* msg, void* data)
{
	bool success = false;
	const char* str = LSMessageGetPayload(msg);
	if (str) {

		json_object* root = json_tokener_parse(str);
		if (root && !is_error(root)) {

			json_object* prop = json_object_object_get(root, "returnValue");
			if (prop && !is_error(prop)) {
				success = json_object_get_boolean(prop);
			}

			json_object_put(root);
		}
	}

	g_warning("%s: full erase successful? %d", __PRETTY_FUNCTION__, success);
	if (success) {
		exit(-2);
	}

	// in the outside case that the full erase fails, remove the full erase window
	// so the user can attempt it again
	WindowServerLuna* ws = reinterpret_cast<WindowServerLuna*>(data);
	ws->m_fullErasePending = false;

	ws->m_powerVolumeKeyComboState.reset();
	ws->cancelFullEraseCountdown();

	return true;
}
开发者ID:KyleMaas,项目名称:luna-sysmgr,代码行数:33,代码来源:WindowServerLuna.cpp

示例9: _powerd_server_up

/** 
* @brief Called to re-register with powerd if powerd crashes.
* 
* @param  sh 
* @param  msg 
* @param  ctx 
* 
* @retval
*/
static bool
_powerd_server_up(LSHandle *sh, LSMessage *msg, void *ctx)
{
    bool connected;

    struct json_object *object = json_tokener_parse(LSMessageGetPayload(msg));
    if (is_error(object)) goto error;

    connected = json_object_get_boolean(
                json_object_object_get(object, "connected"));

    if (connected)
    {
        g_debug("%s connected was true (powerd is already running)", __FUNCTION__);
        PowerdHandle *handle = PowerdGetHandle();

        /* Send our name to powerd. */
        SendMessage(_identify_callback,
                "luna://com.palm.power/com/palm/power/identify",
                "{\"subscribe\":true,\"clientName\":\"%s\"}",
                handle->clientName);
    }

end:
    if (!is_error(object)) json_object_put(object);
    return true;

error:
    g_critical("%s: Error registering with com.palm.power", __FUNCTION__);
    goto end;
}
开发者ID:jukkahonkela-owo,项目名称:powerd,代码行数:40,代码来源:commands.c

示例10: set_mic_mute_cb

static bool set_mic_mute_cb(LSHandle *handle, LSMessage *message, void *user_data)
{
	struct audio_service *service = user_data;
	const char *payload;
	jvalue_ref parsed_obj = NULL;
	struct luna_service_req_data *req;
	pa_operation *op;

	if (!service->context_initialized) {
		luna_service_message_reply_custom_error(handle, message, "Not yet initialized");
		return true;
	}

	payload = LSMessageGetPayload(message);
	parsed_obj = luna_service_message_parse_and_validate(payload);
	if (jis_null(parsed_obj)) {
		luna_service_message_reply_error_bad_json(handle, message);
		goto cleanup;
	}

	service->mic_mute = luna_service_message_get_boolean(parsed_obj, "micMute", service->mic_mute);

	req = luna_service_req_data_new(handle, message);
	req->user_data = service;

	op = pa_context_get_source_info_list(service->context, mm_sourceinfo_cb, req);
	pa_operation_unref(op);

cleanup:
	if (!jis_null(parsed_obj))
		j_release(&parsed_obj);

	return true;
}
开发者ID:nizovn,项目名称:audio-service,代码行数:34,代码来源:audio_service.c

示例11: shutdownServicesRegister

static bool
shutdownServicesRegister(LSHandle *sh, LSMessage *message,
                             void *user_data)
{
    struct json_object *object =
        json_tokener_parse(LSMessageGetPayload(message));
    if (is_error(object)) goto end;

    const char *clientId = LSMessageGetUniqueToken(message);
    const char *clientName = json_object_get_string(json_object_object_get(
        object, "clientName"));

    client_new_service(clientId, clientName);

    bool retVal;
    LSError lserror;
    LSErrorInit(&lserror);

    retVal = LSSubscriptionAdd(sh, "shutdownClient",
                             message, &lserror);
    if (!retVal)
    {
        g_critical("LSSubscriptionAdd failed.");
        LSErrorPrint(&lserror, stderr);
        LSErrorFree(&lserror);
    }

    send_reply(sh, message, "{\"clientId\":\"%s\"}", clientId);

    json_object_put(object);
end:
    return true;
}
开发者ID:jukkahonkela-owo,项目名称:sleepd,代码行数:33,代码来源:shutdown.c

示例12: VALIDATE_SCHEMA_AND_RETURN

bool InputManager::processKeyState(LSHandle* handle, LSMessage* msg, void* userData)
{
    // {"get": string}
    VALIDATE_SCHEMA_AND_RETURN(handle,
                               msg,
                               SCHEMA_1(REQUIRED(get, string)));

	bool success = false;
	const char* keyString = NULL;
	QEvent::Type state = QEvent::None;
	LSError err;
	json_object* root = 0;

	LSErrorInit(&err);

	// get the text name of the key
	const char* str = LSMessageGetPayload(msg);
	if (!str) {
		g_debug("%s: Unable to get JSON payload from message", __PRETTY_FUNCTION__);
		return false;
	}

	root = json_tokener_parse(str);
	if (root && !is_error(root)) {

		// Get the key name from the msg -- the format will be {"get":"NAME"},
		// where NAME is something like ringer, slider, etc
		keyString = json_object_get_string(json_object_object_get(root, "get"));
		if (keyString) {

			// lookup the state of the key
			Qt::Key key = stringToKey(keyString);
			state = getKeyState(key);

			success = true;
		}
	}
	
	json_object* response = 0;
	if (success) {
		response = createKeyJson(keyString, state);
	}
	else {
		response = json_object_new_object();
	}
	json_object_object_add(response, "returnValue", json_object_new_boolean(success));

	if (!LSMessageReply(handle, msg, json_object_to_json_string(response), &err)) {
		LSErrorPrint(&err, stderr);
		LSErrorFree(&err);
	}

	if (root && !is_error(root))
		json_object_put(root);

	json_object_put(response);

	return true;
}
开发者ID:KyleMaas,项目名称:luna-sysmgr,代码行数:59,代码来源:InputManager.cpp

示例13: visualLedSuspendCallback

/** 
* @brief Turn on/off visual leds suspend via luna-service.
* 
* @retval
*/
bool
visualLedSuspendCallback(LSHandle *sh, LSMessage *message, void *data)
{
	LSMessageRef(message);
	LSCall(GetLunaServiceHandle(), SLEEPD_SUSPEND_SERVICE"visualLedSuspend",
				       		LSMessageGetPayload(message), suspend_ipc_method_cb,(void *)message, NULL, NULL);
	return true;
}
开发者ID:jukkahonkela-owo,项目名称:powerd,代码行数:13,代码来源:suspend_ipc.c

示例14: activityStartCallback

/**
 * @brief Start an activity.
 */
bool
activityStartCallback(LSHandle *sh, LSMessage *message, void *user_data)
{
	LSMessageRef(message);
	LSCall(GetLunaServiceHandle(), SLEEPD_SUSPEND_SERVICE"activityStart",
					       		LSMessageGetPayload(message), suspend_ipc_method_cb,(void *)message, NULL, NULL);
	return true;
}
开发者ID:jukkahonkela-owo,项目名称:powerd,代码行数:11,代码来源:suspend_ipc.c

示例15: TESTresetShutdownState

/** 
* @brief Called by test code to reset state machine to square 1.
* 
* @retval
*/
static bool
TESTresetShutdownState(LSHandle *sh, LSMessage *message, void *user_data)
{
    LSMessageRef(message);
    LSCallOneReply(GetLunaServiceHandle(), SLEEPD_SHUTDOWN_SERVICE"TESTresetShutdownState",
                   LSMessageGetPayload(message), shutdown_method_cb,(void *)message, NULL, NULL);
    return true;
}
开发者ID:Andolamin,项目名称:powerd,代码行数:13,代码来源:shutdown.c


注:本文中的LSMessageGetPayload函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。