本文整理汇总了C++中LSErrorFree函数的典型用法代码示例。如果您正苦于以下问题:C++ LSErrorFree函数的具体用法?C++ LSErrorFree怎么用?C++ LSErrorFree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LSErrorFree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LSErrorInit
void Preferences::registerService()
{
bool ret;
LSError error;
LSErrorInit(&error);
ret = LSRegister(NULL, &m_lsHandle, &error);
if (!ret) {
g_critical("Failed to register handler: %s", error.message);
LSErrorFree(&error);
exit(1);
}
ret = LSGmainAttach(m_lsHandle, HostBase::instance()->mainLoop(), &error);
if (!ret) {
g_critical("Failed to attach service to main loop: %s", error.message);
LSErrorFree(&error);
exit(1);
}
ret = LSCall(m_lsHandle, "palm://com.palm.lunabus/signal/registerServerStatus",
"{\"serviceName\":\"com.palm.systemservice\"}",
serverConnectCallback, this, &m_serverStatusToken, &error);
if (!ret) {
g_critical("Failed in calling palm://com.palm.lunabus/signal/registerServerStatus: %s",
error.message);
LSErrorFree(&error);
exit(1);
}
}
示例2: cbGetStatus
bool cbGetStatus(LSHandle *handle, LSMessage *message, void *user_data)
{
SUBSCRIBE_SCHEMA_RETURN(handle, message);
bool success = true;
LSError error;
json_object* json = json_object_new_object();
bool subscribed = false;
bool firstUse = false;
std::string stateStr;
LSErrorInit(&error);
if (LSMessageIsSubscription(message)) {
if (!LSSubscriptionProcess(handle, message, &subscribed, &error)) {
LSErrorFree (&error);
goto done;
}
}
stateStr = bootStateToStr(BootManager::instance()->currentState());
json_object_object_add(json, "state", json_object_new_string(stateStr.c_str()));
done:
json_object_object_add(json, "returnValue", json_object_new_boolean(success));
json_object_object_add(json, "subscribed", json_object_new_boolean(subscribed));
if (!LSMessageReply(handle, message, json_object_to_json_string(json), &error))
LSErrorFree (&error);
json_object_put(json);
return true;
}
示例3: LSErrorInit
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);
}
}
示例4: set_debug_log_method
//
// Return a polite response.
// Called directly from webOS, and returns directly to webOS.
//
bool set_debug_log_method(LSHandle* lshandle, LSMessage *message, void *ctx)
{
log("set_debug_log_method");
LSError lserror;
LSErrorInit(&lserror);
// Extract the id argument from the message
json_t *object = json_parse_document(LSMessageGetPayload(message));
json_t *enableDebugLogging = json_find_first_label(object, "enableDebugLogging");
if(enableDebugLogging)
{
if(enableDebugLogging->child->type == JSON_TRUE)
{
log("enableDebugLogging: JSON_TRUE");
g_debugLoggingEnabled = true;
}
else if(enableDebugLogging->child->type == JSON_FALSE)
{
log("enableDebugLogging: JSON_FALSE");
g_debugLoggingEnabled = false;
remove(LOG_FILE);
}
else
{
log("enableDebugLogging: %d", enableDebugLogging->child->type);
}
}
else
{
if (!LSMessageReply(lshandle, message, "{\"returnValue\": false, \"errorCode\": -1, \"errorText\": \"Invalid or missing parameters\"}", &lserror))
{
LSErrorPrint(&lserror, stderr);
LSErrorFree(&lserror);
return false;
}
}
// Local buffer to store the reply
char reply[MAXLINLEN];
sprintf(reply, "{\"returnValue\": true, \"debugLoggingEnabled\": %s}", g_debugLoggingEnabled ? "true" : "false");
log(reply);
if (!LSMessageReply(lshandle, message, reply, &lserror))
{
LSErrorPrint(&lserror, stderr);
LSErrorFree(&lserror);
return false;
}
return true;
}
示例5: timingServiceResponse
static bool
timingServiceResponse(LSHandle *sh, LSMessage *reply, void *ctx)
{
LSError lserror;
LSErrorInit(&lserror);
LSMessageToken token;
const char *payload;
clock_gettime(CLOCK_MONOTONIC, &stopTime);
token = LSMessageGetResponseToken(reply);
payload = LSMessageGetPayload(reply);
double duration = ((double)stopTime.tv_sec + (((double)stopTime.tv_nsec)/1000000000.0)) -
((double)startTime.tv_sec + (((double)startTime.tv_nsec)/1000000000.0));
roundtripTime += duration;
roundtripCount++;
rcvdBytes += strlen(payload);
sentBytes += url ? strlen(url) : 0;
sentBytes += message ? strlen(message) : 0;
g_message("%s Got response: duration %.02f ms, token %ld, payload %s", __FUNCTION__, duration * 1000.0, token, payload);
if (--count > 0)
{
// resend the message!
LSMessageToken sessionToken;
clock_gettime(CLOCK_MONOTONIC, &startTime);
/* Basic sending */
bool retVal = LSCallFromApplication(sh, url, message, appId,
timingServiceResponse, ctx, &sessionToken, &lserror);
if (!retVal)
{
LSErrorPrint (&lserror, stderr);
LSErrorFree (&lserror);
}
} else {
bool retVal = LSCallCancel (sh, token, &lserror);
if (!retVal)
{
LSErrorPrint (&lserror, stderr);
LSErrorFree (&lserror);
}
g_timeout_add (300, goodbye, ctx);
return true;
}
return true;
}
示例6: handle_get_info_command
static bool handle_get_info_command(LSHandle *sh, LSMessage *message, void* context)
{
jvalue_ref reply = jobject_create();
LSError lserror;
LSErrorInit(&lserror);
char wifi_mac_address[32]={0}, wired_mac_address[32]={0};
jobject_put(reply, J_CSTR_TO_JVAL("returnValue"), jboolean_create(true));
if(get_wifi_mac_address(CONNMAN_WIFI_INTERFACE_NAME, wifi_mac_address) == 0)
{
jvalue_ref wifi_info = jobject_create();
jobject_put(wifi_info, J_CSTR_TO_JVAL("macAddress"),jstring_create(wifi_mac_address));
jobject_put(reply, J_CSTR_TO_JVAL("wifiInfo"), wifi_info);
}
else
WCA_LOG_ERROR("Error in fetching mac address for wifi interface");
if(get_wifi_mac_address(CONNMAN_WIRED_INTERFACE_NAME, wired_mac_address) == 0)
{
jvalue_ref wired_info = jobject_create();
jobject_put(wired_info, J_CSTR_TO_JVAL("macAddress"),jstring_create(wired_mac_address));
jobject_put(reply, J_CSTR_TO_JVAL("wiredInfo"), wired_info);
}
else
WCA_LOG_ERROR("Error in fetching mac address for wired interface");
jschema_ref response_schema = jschema_parse (j_cstr_to_buffer("{}"), DOMOPT_NOOPT, NULL);
if(!response_schema)
{
LSMessageReplyErrorUnknown(sh,message);
goto cleanup;
}
if (!LSMessageReply(sh, message, jvalue_tostring(reply, response_schema), &lserror))
{
LSErrorPrint(&lserror, stderr);
LSErrorFree(&lserror);
}
jschema_release(&response_schema);
cleanup:
if (LSErrorIsSet(&lserror))
{
LSErrorPrint(&lserror, stderr);
LSErrorFree(&lserror);
}
j_release(&reply);
return true;
}
示例7: LSErrorInit
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;
}
示例8: _test0
bool _test0(LSHandle* lshandle,LSMessage *message, void *user_data)
{
const char* str = LSMessageGetPayload(message);
if( !str )
return false;
QtJsonAbstract * j = QtJsonAbstract::jsonParse(QString(str));
if (j)
{
QList<QPair<QString,QVariant> > allContents = j->extractAll();
for (QtJsonAbstract::ContentsListIterator it = allContents.begin();
it != allContents.end();++it)
{
//qDebug() << "key = " << it->first;
// if ((QMetaType::Type)(it->second.userType()) == qMetaTypeId<QtJsonAbstractVariant>())
//qDebug() << "\tval = " << it->second.value<QtJsonAbstractVariant>();
// else
//qDebug() << "\tval = " << it->second << " , usertype = " << (QMetaType::Type)(it->second.userType()) << " , mytype = " << qMetaTypeId<QtJsonAbstractVariant>();
}
QtJsonAbstract::throwAway(j);
QtJsonAbstract * reply = QtJsonAbstract::create();
reply->add("returnValue",true);
LSError lserror;
LSErrorInit(&lserror);
if (!LSMessageReply( lshandle, message,ccstr(reply->toString()), &lserror )) {
LSErrorPrint (&lserror, stderr);
LSErrorFree(&lserror);
}
QtJsonAbstract::throwAway(reply);
}
else
{
QtJsonAbstract * reply = QtJsonAbstract::create();
reply->add("returnValue",true);
LSError lserror;
LSErrorInit(&lserror);
if (!LSMessageReply( lshandle, message,ccstr(reply->toString()), &lserror )) {
LSErrorPrint (&lserror, stderr);
LSErrorFree(&lserror);
}
QtJsonAbstract::throwAway(reply);
}
return true;
}
示例9: property_service_create
struct property_service* property_service_create()
{
struct property_service *service;
LSError error;
service = g_try_new0(struct property_service, 1);
if (!service)
return NULL;
LSErrorInit(&error);
if (!LSRegisterPubPriv("com.android.properties", &service->handle, false, &error)) {
g_error("Failed to register the luna service: %s", error.message);
LSErrorFree(&error);
goto error;
}
if (!LSRegisterCategory(service->handle, "/", property_service_methods,
NULL, NULL, &error)) {
g_error("Could not register service category: %s", error.message);
LSErrorFree(&error);
goto error;
}
if (!LSCategorySetData(service->handle, "/", service, &error)) {
g_error("Could not set daa for service category: %s", error.message);
LSErrorFree(&error);
goto error;
}
if (!LSGmainAttach(service->handle, event_loop, &error)) {
g_error("Could not attach service handle to mainloop: %s", error.message);
LSErrorFree(&error);
goto error;
}
return service;
error:
if (service->handle != NULL) {
LSUnregister(service->handle, &error);
LSErrorFree(&error);
}
g_free(service);
return NULL;
}
示例10: luna_service_message_validate_and_send
bool luna_service_message_validate_and_send(LSHandle *handle, LSMessage *message, jvalue_ref reply_obj)
{
jschema_ref response_schema = NULL;
LSError lserror;
bool success = true;
LSErrorInit(&lserror);
response_schema = jschema_parse (j_cstr_to_buffer("{}"), DOMOPT_NOOPT, NULL);
if(!response_schema) {
luna_service_message_reply_error_internal(handle, message);
return false;
}
if (!LSMessageReply(handle, message,
jvalue_tostring(reply_obj, response_schema), &lserror)) {
LSErrorPrint(&lserror, stderr);
LSErrorFree(&lserror);
success = false;
}
jschema_release(&response_schema);
return success;
}
示例11: service_register
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;
}
示例12: _power_timeout_init
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;
}
示例13: test_LSErrorLog
static void
test_LSErrorLog(TestData *fixture, gconstpointer user_data)
{
LSError lserror;
LSErrorInit(&lserror);
_LSErrorSetNoPrint(&lserror, LS_ERROR_CODE_UNKNOWN_ERROR, LS_ERROR_TEXT_UNKNOWN_ERROR);
if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
{
LOG_LSERROR("LS_TEST_ERROR", &lserror);
exit(0);
}
gchar *expected_stderr = g_strdup_printf("{\"ERROR_CODE\":%d,\"ERROR\":\"%s\",\"FUNC\":\"%s\",\"FILE\":\"%s\",\"LINE\":%d"
"} LUNASERVICE ERROR\n",
lserror.error_code, lserror.message, lserror.func, lserror.file, lserror.line);
g_test_trap_assert_stderr(expected_stderr);
g_free(expected_stderr);
if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
{
LOG_LSERROR("LS_TEST_ERROR", NULL);
exit(0);
}
g_test_trap_assert_stderr("lserror is NULL. Did you pass in a LSError?\n");
LSErrorFree(&lserror);
}
示例14: LSErrorInit
void AlertWebApp::startPowerdActivity()
{
if (!m_isPowerdActivityRunning) {
LSHandle* lshandle = WebAppManager::instance()->getStatsServiceHandle();
LSError lsError;
LSErrorInit(&lsError);
gchar* activityId = g_strdup_printf("com.palm.lunastats-alert-%p", this);
g_message ("%s: starting powerd activity for %s", __PRETTY_FUNCTION__, activityId);
gchar* params = g_strdup_printf("{\"id\": \"%s\", \"duration_ms\": %d}", activityId, kAlertActivityDuration);
bool ret = LSCall(lshandle, "palm://com.palm.power/com/palm/power/activityStart",
params, NULL, NULL, NULL, &lsError);
g_free (activityId);
g_free (params);
if (!ret) {
g_warning("%s: Failed to call powerd activityStart: %s", __PRETTY_FUNCTION__, lsError.message);
LSErrorFree(&lsError);
return;
}
m_isPowerdActivityRunning = true;
}
}
示例15: chargerStatusQuery
bool
chargerStatusQuery(LSHandle *sh,
LSMessage *message, void *user_data)
{
nyx_charger_status_t status;
if(!nyxDev)
return false;
nyx_error_t err = nyx_charger_query_charger_status(nyxDev,&status);
if(err != NYX_ERROR_NONE)
{
POWERDLOG(LOG_ERR,"%s: nyx_charger_query_battery_status returned with error : %d",__func__,err);
}
LSError lserror;
LSErrorInit(&lserror);
char *payload = g_strdup_printf("{\"DockConnected\":%s,\"DockPower\":%s,\"DockSerialNo\":\"%s\","
"\"USBConnected\":%s,\"USBName\":\"%s\",\"Charging\":%s}",(status.connected & NYX_CHARGER_INDUCTIVE_CONNECTED) ? "true" : "false",
(status.powered & NYX_CHARGER_INDUCTIVE_POWERED) ? "true" :"false",(strlen(status.dock_serial_number)) ? status.dock_serial_number : "NULL",
(status.powered & NYX_CHARGER_USB_POWERED) ? "true" : "false",ChargerNameToString(status.connected),
(status.is_charging) ? "true":"false");
POWERDLOG(LOG_DEBUG,"%s: Sending payload : %s",__func__,payload);
bool retVal = LSMessageReply(sh, message, payload,NULL);
if (!retVal)
{
LSErrorPrint(&lserror, stderr);
LSErrorFree(&lserror);
}
g_free(payload);
return TRUE;
}