• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LSMessageGetPayload函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: prepareSuspendRegister

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


示例17: listContactsHandler

static bool listContactsHandler(LSHandle *sh, LSMessage *reply, void *ctx)
{
    printf("Got reply: %s\n", LSMessageGetPayload(reply));
    if (!LSMessageIsHubErrorMessage(reply))
        hit_reply = TRUE;
    g_main_loop_quit((GMainLoop *) ctx);
    return TRUE;
}
开发者ID:ctbrowser,项目名称:luna-service2,代码行数:8,代码来源:test_example.c


示例18: _service_network_set_cb

/**
 * @brief Set the network the modem should connect to.
 *
 * JSON format:
 *  request:
 *    {
 *        "automatic": <boolean>,
 *        "id": <string>,
 *    }
 *  response:
 *    {
 *       "returnValue": <boolean>,
 *       "errorCode": <integer>,
 *       "errorString": <string>,
 *    }
 **/
bool _service_network_set_cb(LSHandle *handle, LSMessage *message, void *user_data)
{
	struct telephony_service *service = user_data;
	struct luna_service_req_data *req_data = NULL;
	jvalue_ref parsed_obj = NULL;
	jvalue_ref automatic_obj = NULL;
	jvalue_ref id_obj = NULL;
	const char *payload;
	raw_buffer id_buf;
	const char *id = NULL;
	bool automatic = false;

	if (!service->initialized) {
		luna_service_message_reply_custom_error(handle, message, "Backend not initialized");
		return true;
	}

	if (!service->driver || !service->driver->network_set) {
		g_warning("No implementation available for service networkSet API method");
		luna_service_message_reply_error_not_implemented(handle, message);
		goto cleanup;
	}

	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;
	}

	if (!jobject_get_exists(parsed_obj, J_CSTR_TO_BUF("automatic"), &automatic_obj)) {
		luna_service_message_reply_error_bad_json(handle, message);
		goto cleanup;
	}

	jboolean_get(automatic_obj, &automatic);

	if (!automatic) {
		if (!jobject_get_exists(parsed_obj, J_CSTR_TO_BUF("id"), &id_obj)) {
			luna_service_message_reply_error_bad_json(handle, message);
			goto cleanup;
		}

		id_buf = jstring_get(id_obj);
		id = id_buf.m_str;
	}

	req_data = luna_service_req_data_new(handle, message);

	service->driver->network_set(service, automatic, id, telephonyservice_common_finish, req_data);

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

	return true;
}
开发者ID:corpuscle,项目名称:webos-telephonyd,代码行数:73,代码来源:telephonyservice_net.c


示例19: shutdownApplicationsAck

/**
 * @brief Ack the "shutdownApplications" signal.
 */
static bool
shutdownApplicationsAck(LSHandle *sh, LSMessage *message,
                             void *user_data)
{
    LSMessageRef(message);
    LSCallOneReply(GetLunaServiceHandle(), SLEEPD_SHUTDOWN_SERVICE"shutdownApplicationsAck",
                   LSMessageGetPayload(message), shutdown_method_cb,(void *)message, NULL, NULL);
    return true;
}
开发者ID:Andolamin,项目名称:powerd,代码行数:12,代码来源:shutdown.c


示例20: alarmRemove

static bool
alarmRemove(LSHandle *sh, LSMessage *message, void *ctx)
{
	LSMessageRef(message);
	LSCallOneReply(GetLunaServiceHandle(), "palm://com.palm.sleep/time/alarmRemove",
			LSMessageGetPayload(message), alarms_timeout_cb, (void *)message, NULL, NULL);

	return true;
}
开发者ID:Andolamin,项目名称:powerd,代码行数:9,代码来源:timeout_alarm.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LSSharedFileListInsertItemURL函数代码示例发布时间:2022-05-30
下一篇:
C++ LSErrorPrint函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap