static void profile_print_with_attrs (const char *type, DBusMessage *message, struct timeval *t, ProfileAttributeFlags attrs) { printf (PROFILE_TIMED_FORMAT, type, t->tv_sec, t->tv_usec); if (attrs & PROFILE_ATTRIBUTE_FLAG_SERIAL) printf ("\t%u", dbus_message_get_serial (message)); if (attrs & PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL) printf ("\t%u", dbus_message_get_reply_serial (message)); if (attrs & PROFILE_ATTRIBUTE_FLAG_SENDER) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_sender (message))); if (attrs & PROFILE_ATTRIBUTE_FLAG_DESTINATION) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_destination (message))); if (attrs & PROFILE_ATTRIBUTE_FLAG_PATH) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_path (message))); if (attrs & PROFILE_ATTRIBUTE_FLAG_INTERFACE) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_interface (message))); if (attrs & PROFILE_ATTRIBUTE_FLAG_MEMBER) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_member (message))); if (attrs & PROFILE_ATTRIBUTE_FLAG_ERROR_NAME) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_error_name (message))); printf ("\n"); }
static bool filter_handle_message(Filter* filter, DBusMessage* msg) { switch (dbus_message_get_type(msg)) { case DBUS_MESSAGE_TYPE_METHOD_CALL: // TODO: add logging break; case DBUS_MESSAGE_TYPE_SIGNAL: break; case DBUS_MESSAGE_TYPE_ERROR: { DBusError error; dbus_error_init(&error); if (dbus_set_error_from_message(&error, msg)) { dsme_log(LOG_DEBUG, "D-Bus: %s: %s", dbus_message_get_error_name(msg), error.message); } else { dsme_log(LOG_DEBUG, "D-Bus: could not get error message"); } dbus_error_free(&error); } break; default: // IGNORE (silently ignore per D-Bus documentation) break; } return false; }
static void pan_connect_cb(DBusMessage *message, void *user_data) { const char *path = user_data; const char *iface = NULL; struct bluetooth_pan *pan; DBusMessageIter iter; pan = g_hash_table_lookup(networks, path); if (pan == NULL) { DBG("network already removed"); return; } if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); DBG("network %p %s", pan->network, dbus_error); if (strcmp(dbus_error, "org.bluez.Error.AlreadyConnected") != 0) { connman_network_set_error(pan->network, CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); return; } } else { if (dbus_message_iter_init(message, &iter) == TRUE && dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) dbus_message_iter_get_basic(&iter, &iface); } DBG("network %p interface %s", pan->network, iface); pan_connect(pan, iface); }
static int cdbus_del_snap_unpack(DBusConnection *conn, DBusMessage *rsp_msg) { int msg_type; const char *sig; msg_type = dbus_message_get_type(rsp_msg); if (msg_type == DBUS_MESSAGE_TYPE_ERROR) { fprintf(stderr, "del snap error response: %s\n", dbus_message_get_error_name(rsp_msg)); return -EINVAL; } if (msg_type != DBUS_MESSAGE_TYPE_METHOD_RETURN) { fprintf(stderr, "unexpected del snap ret type: %d\n", msg_type); return -EINVAL; } sig = dbus_message_get_signature(rsp_msg); if ((sig == NULL) || (strcmp(sig, CDBUS_SIG_DEL_SNAPS_RSP) != 0)) { fprintf(stderr, "bad del snap response sig: %s, " "expected: %s\n", (sig ? sig : "NULL"), CDBUS_SIG_DEL_SNAPS_RSP); return -EINVAL; } /* no parameters in response */ return 0; }
static void request_input_login_reply(DBusMessage *reply, void *user_data) { struct request_input_reply *username_password_reply = user_data; const char *error = NULL; bool values_received = false; char *username = NULL; char *password = NULL; char *key; DBusMessageIter iter, dict; if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { error = dbus_message_get_error_name(reply); goto done; } if (!check_reply_has_dict(reply)) goto done; values_received = true; dbus_message_iter_init(reply, &iter); dbus_message_iter_recurse(&iter, &dict); while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { DBusMessageIter entry, value; dbus_message_iter_recurse(&dict, &entry); if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) break; dbus_message_iter_get_basic(&entry, &key); if (g_str_equal(key, "Username")) { dbus_message_iter_next(&entry); if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; dbus_message_iter_recurse(&entry, &value); dbus_message_iter_get_basic(&value, &username); } else if (g_str_equal(key, "Password")) { dbus_message_iter_next(&entry); if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) break; dbus_message_iter_recurse(&entry, &value); dbus_message_iter_get_basic(&value, &password); } dbus_message_iter_next(&dict); } done: username_password_reply->callback(username_password_reply->service, values_received, NULL, 0, username, password, FALSE, NULL, error, username_password_reply->user_data); g_free(username_password_reply); }
static void pid_queried(DBusPendingCall *pend, void *data) { query_t *query = (query_t *)data; int success = FALSE; dbus_uint32_t pid = 0; const char *error = ""; DBusMessage *reply = NULL; const char *str; do { /* not a loop */ if ((reply = dbus_pending_call_steal_reply(pend)) == NULL) { error = "NoReplyMessage"; break; } if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { if ((str = dbus_message_get_error_name(reply)) == NULL) error = "UnknownError"; else { for (error = str + strlen(str); error > str; error--) { if (*error == '.') { error++; break; } } } break; } success = dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID); if (success) error = "OK"; } while(0); if (query) { if (success) OHM_DEBUG(DBG_DBUS, "pid query succeeded: %s -> %u", query->addr, pid); else OHM_DEBUG(DBG_DBUS, "pid query for %s failed: %s", query->addr, error); query->cb.func(pid, error, query->cb.data); free(query->bus); free(query->addr); free(query); } if (reply) dbus_message_unref(reply); dbus_pending_call_unref(pend); }
static void _run_iteration (DBusConnection *conn) { DBusPendingCall *echo_pending; DBusPendingCall *dbus_pending; DBusMessage *method; DBusMessage *reply; char *echo = "echo"; /* send the first message */ method = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteEchoService", "/org/freedesktop/TestSuite", "org.freedesktop.TestSuite", "Echo"); dbus_message_append_args (method, DBUS_TYPE_STRING, &echo, NULL); dbus_connection_send_with_reply (conn, method, &echo_pending, -1); dbus_message_unref (method); /* send the second message */ method = dbus_message_new_method_call (DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, "org.freedesktop.Introspectable", "Introspect"); dbus_connection_send_with_reply (conn, method, &dbus_pending, -1); dbus_message_unref (method); /* block on the second message (should return immediately) */ dbus_pending_call_block (dbus_pending); /* block on the first message */ /* if it does not return immediately chances are we hit the block in poll bug */ dbus_pending_call_block (echo_pending); /* check the reply only to make sure we are not getting errors unrelated to the block in poll bug */ reply = dbus_pending_call_steal_reply (echo_pending); if (reply == NULL) { printf ("Failed: Reply is NULL ***\n"); exit (1); } if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) { printf ("Failed: Reply is error: %s ***\n", dbus_message_get_error_name (reply)); exit (1); } dbus_message_unref (reply); dbus_pending_call_unref (dbus_pending); dbus_pending_call_unref (echo_pending); }
/** * @brief Optionally prints a trace of a D-Bus message depending on the "level". * * @param [in] level Trace mask controlling whether trace appears. * @param [in] msg The D-Bus message to trace. */ void l2dbus_traceMessage ( unsigned level, struct DBusMessage* msg ) { const cdbus_Char* msgTypeStr ="UNKNOWN"; cdbus_Int32 msgType = DBUS_MESSAGE_TYPE_INVALID; const cdbus_Char* path = NULL; const cdbus_Char* intf = NULL; const cdbus_Char* name = NULL; const cdbus_Char* dest = NULL; const cdbus_Char* errName = NULL; if ( NULL != msg ) { msgType = dbus_message_get_type(msg); msgTypeStr = dbus_message_type_to_string(msgType); if ( (DBUS_MESSAGE_TYPE_METHOD_CALL == msgType) || (DBUS_MESSAGE_TYPE_SIGNAL == msgType) ) { path = dbus_message_get_path(msg); intf = dbus_message_get_interface(msg); name = dbus_message_get_member(msg); l2dbus_trace(level, "(Ser=%u) [%s] <%s> %s%s%s", dbus_message_get_serial(msg), msgTypeStr, path ? path : "", intf ? intf : "", intf ? "." : "", name ? name : ""); } else if (DBUS_MESSAGE_TYPE_METHOD_RETURN == msgType) { dest = dbus_message_get_destination(msg); l2dbus_trace(level, "(RSer=%u) [%s] -> %s", dbus_message_get_reply_serial(msg), msgTypeStr, dest ? dest : ""); } else if (DBUS_MESSAGE_TYPE_ERROR == msgType ) { errName = dbus_message_get_error_name(msg); l2dbus_trace(level, "(RSer=%u) [%s] %s", dbus_message_get_reply_serial(msg), msgTypeStr, errName ? errName : ""); } else { l2dbus_trace(level, "(Ser=%u) [%s]", dbus_message_get_serial(msg), msgTypeStr); } } }
int cras_bt_transport_try_acquire(struct cras_bt_transport *transport) { DBusMessage *method_call, *reply; DBusError dbus_error; int fd, read_mtu, write_mtu; method_call = dbus_message_new_method_call( BLUEZ_SERVICE, transport->object_path, BLUEZ_INTERFACE_MEDIA_TRANSPORT, "TryAcquire"); if (!method_call) return -ENOMEM; dbus_error_init(&dbus_error); reply = dbus_connection_send_with_reply_and_block( transport->conn, method_call, DBUS_TIMEOUT_USE_DEFAULT, &dbus_error); if (!reply) { syslog(LOG_ERR, "Failed to try acquire transport %s: %s", transport->object_path, dbus_error.message); dbus_error_free(&dbus_error); dbus_message_unref(method_call); return -EIO; } dbus_message_unref(method_call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { syslog(LOG_ERR, "TryAcquire returned error: %s", dbus_message_get_error_name(reply)); dbus_message_unref(reply); return -EIO; } if (!dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_UINT16, &read_mtu, DBUS_TYPE_UINT16, &write_mtu, DBUS_TYPE_INVALID)) { syslog(LOG_ERR, "Bad TryAcquire reply received: %s", dbus_error.message); dbus_error_free(&dbus_error); dbus_message_unref(reply); return -EINVAL; } /* Done TryAcquired the transport so it won't be released in bluez, * no need for the new file descriptor so close it. */ if (transport->fd != fd) close(fd); dbus_message_unref(reply); return 0; }
/** * @brief Callback getting available properties (IMSI, IMEI, ...) from qmi-dbus and * finally add connman network */ static void open_modem_get_properties_callback(DBusMessage *message, void *user_data) { DBusMessageIter iter; struct qmi_data *qmi = (struct qmi_data *)user_data; DBG("QMI data %p D-Bus message %p", qmi, message); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); qmi->modem_opening = FALSE; connman_error("%s", dbus_error); return; } if(dbus_message_iter_init(message, &iter) == FALSE) { connman_error("Failure init ITER"); qmi->modem_opening = FALSE; return; } if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INVALID) { connman_error("Invalid D-Bus type"); qmi->modem_opening = FALSE; return; } /* Set new D-Bus reply properties */ if(set_reply_to_qmi_data(&iter, qmi) == FALSE) { connman_error("Failure parse D-Bus message"); return; } DBG("Modem opened %d", qmi->modem_opened); DBG("IMSI %s", qmi->imsi); /* Set a new connman network group of the newly replied IMSI */ if(qmi->group) g_free(qmi->group); qmi->group = g_strdup_printf("%s_none", qmi->imsi); /* Modem was opened successfully, add the new device to connman */ qmi->modem_opened = TRUE; qmi->modem_opening = FALSE; add_network(qmi); }
int cras_bt_transport_acquire(struct cras_bt_transport *transport) { DBusMessage *method_call, *reply; DBusError dbus_error; if (transport->fd >= 0) return 0; method_call = dbus_message_new_method_call( BLUEZ_SERVICE, transport->object_path, BLUEZ_INTERFACE_MEDIA_TRANSPORT, "Acquire"); if (!method_call) return -ENOMEM; dbus_error_init(&dbus_error); reply = dbus_connection_send_with_reply_and_block( transport->conn, method_call, DBUS_TIMEOUT_USE_DEFAULT, &dbus_error); if (!reply) { syslog(LOG_ERR, "Failed to acquire transport %s: %s", transport->object_path, dbus_error.message); dbus_error_free(&dbus_error); dbus_message_unref(method_call); return -EIO; } dbus_message_unref(method_call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { syslog(LOG_ERR, "Acquire returned error: %s", dbus_message_get_error_name(reply)); dbus_message_unref(reply); return -EIO; } if (!dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_UNIX_FD, &(transport->fd), DBUS_TYPE_UINT16, &(transport->read_mtu), DBUS_TYPE_UINT16, &(transport->write_mtu), DBUS_TYPE_INVALID)) { syslog(LOG_ERR, "Bad Acquire reply received: %s", dbus_error.message); dbus_error_free(&dbus_error); dbus_message_unref(reply); return -EINVAL; } dbus_message_unref(reply); return 0; }
static int ldbus_message_get_error_name(lua_State *L) { DBusMessage *message = check_DBusMessage(L, 1); const char * error_name = dbus_message_get_error_name(message); if (error_name == NULL) { lua_pushnil(L); } else { lua_pushstring(L, error_name); } return 1; }
static void on_transport_volume_set(DBusPendingCall *pending_call, void *data) { DBusMessage *reply; reply = dbus_pending_call_steal_reply(pending_call); dbus_pending_call_unref(pending_call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) syslog(LOG_ERR, "Set absolute volume returned error: %s", dbus_message_get_error_name(reply)); dbus_message_unref(reply); }
void print_message (DBusMessage *message, dbus_bool_t literal) { DBusMessageIter iter; const char *sender; const char *destination; int message_type; message_type = dbus_message_get_type (message); sender = dbus_message_get_sender (message); destination = dbus_message_get_destination (message); if (!literal) { printf ("%s sender=%s -> dest=%s", type_to_name (message_type), sender ? sender : "(null sender)", destination ? destination : "(null destination)"); switch (message_type) { case DBUS_MESSAGE_TYPE_METHOD_CALL: case DBUS_MESSAGE_TYPE_SIGNAL: printf (" serial=%u path=%s; interface=%s; member=%s\n", dbus_message_get_serial (message), dbus_message_get_path (message), dbus_message_get_interface (message), dbus_message_get_member (message)); break; case DBUS_MESSAGE_TYPE_METHOD_RETURN: printf (" reply_serial=%u\n", dbus_message_get_reply_serial (message)); break; case DBUS_MESSAGE_TYPE_ERROR: printf (" error_name=%s reply_serial=%u\n", dbus_message_get_error_name (message), dbus_message_get_reply_serial (message)); break; default: printf ("\n"); break; } } dbus_message_iter_init (message, &iter); print_iter (&iter, literal, 1); fflush (stdout); }
static int cdbus_list_confs_unpack(DBusConnection *conn, DBusMessage *rsp_msg, uint32_t *num_confs_out, struct config **confs_out) { int ret; DBusMessageIter iter; int msg_type; uint32_t num_confs; struct config *confs; const char *sig; msg_type = dbus_message_get_type(rsp_msg); if (msg_type == DBUS_MESSAGE_TYPE_ERROR) { fprintf(stderr, "list_confs error response: %s\n", dbus_message_get_error_name(rsp_msg)); return -EINVAL; } if (msg_type != DBUS_MESSAGE_TYPE_METHOD_RETURN) { fprintf(stderr, "unexpected list_confs ret type: %d\n", msg_type); return -EINVAL; } sig = dbus_message_get_signature(rsp_msg); if ((sig == NULL) || (strcmp(sig, CDBUS_SIG_LIST_CONFS_RSP) != 0)) { fprintf(stderr, "bad list confs response sig: %s, " "expected: %s\n", (sig ? sig : "NULL"), CDBUS_SIG_LIST_CONFS_RSP); return -EINVAL; } if (!dbus_message_iter_init(rsp_msg, &iter)) { /* FIXME return empty? */ fprintf(stderr, "Message has no arguments!\n"); return -EINVAL; } ret = conf_array_unpack(&iter, &num_confs, &confs); if (ret < 0) { fprintf(stderr, "failed to unpack conf array\n"); return -EINVAL; } *num_confs_out = num_confs; *confs_out = confs; return 0; }
/** * @brief Callback closing modem */ static void close_modem_callback(DBusMessage *message, void *unused) { DBG("DBusmessage %p", message); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); connman_error("%s", dbus_error); return; } }
int cras_bt_transport_release(struct cras_bt_transport *transport) { DBusMessage *method_call, *reply; DBusError dbus_error; if (transport->fd < 0) return 0; /* Close the transport on our end no matter whether or not the server * gives us an error. */ close(transport->fd); transport->fd = -1; method_call = dbus_message_new_method_call( BLUEZ_SERVICE, transport->object_path, BLUEZ_INTERFACE_MEDIA_TRANSPORT, "Release"); if (!method_call) return -ENOMEM; dbus_error_init(&dbus_error); reply = dbus_connection_send_with_reply_and_block( transport->conn, method_call, DBUS_TIMEOUT_USE_DEFAULT, &dbus_error); if (!reply) { syslog(LOG_ERR, "Failed to release transport %s: %s", transport->object_path, dbus_error.message); dbus_error_free(&dbus_error); dbus_message_unref(method_call); return -EIO; } dbus_message_unref(method_call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { syslog(LOG_ERR, "Release returned error: %s", dbus_message_get_error_name(reply)); dbus_message_unref(reply); return -EIO; } dbus_message_unref(reply); return 0; }
void timer_proxy::remove_timer(const long a0) { // create caller (name, arguments) dboost::dbus_ptr<DBusMessage> msg(DBOOST_CHECK(dbus_message_new_method_call(m_bus_name.c_str(), m_obj_name.c_str(), s_ifc_name, "remove_timer"))); dboost::oserializer os(msg.get()); os & a0; // call synchronously dboost::error err; dboost::dbus_ptr<DBusMessage> reply(dbus_connection_send_with_reply_and_block(m_connection.get(), msg.get(), TIMEOUT_MS, &err)); // check if there was an error DBOOST_CHECK_WITH_ERR(reply, err); if (dbus_message_get_type(reply.get()) == DBUS_MESSAGE_TYPE_ERROR) { throw dboost::exception(dbus_message_get_error_name(reply.get())); } }
/* Callback to trigger when transport release completed. */ static void cras_bt_on_transport_release(DBusPendingCall *pending_call, void *data) { DBusMessage *reply; reply = dbus_pending_call_steal_reply(pending_call); dbus_pending_call_unref(pending_call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { syslog(LOG_WARNING, "Release transport returned error: %s", dbus_message_get_error_name(reply)); dbus_message_unref(reply); return; } dbus_message_unref(reply); }
static void report_error_reply(DBusMessage *reply, void *user_data) { struct report_error_data *report_error = user_data; gboolean retry = FALSE; const char *dbus_err; if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { dbus_err = dbus_message_get_error_name(reply); if (dbus_err != NULL && strcmp(dbus_err, CONNMAN_AGENT_INTERFACE ".Error.Retry") == 0) retry = TRUE; } report_error->callback(report_error->user_context, retry, report_error->user_data); g_free(report_error); }
static void request_browser_reply(DBusMessage *reply, void *user_data) { struct request_browser_reply_data *browser_reply_data = user_data; bool result = false; const char *error = NULL; if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { error = dbus_message_get_error_name(reply); goto done; } result = true; done: browser_reply_data->callback(browser_reply_data->service, result, error, browser_reply_data->user_data); g_free(browser_reply_data); }
/** * @brief Callback disconnect modem */ static void network_disconnect_callback(DBusMessage *message, void *user_data) { struct qmi_data *qmi = (struct qmi_data *)user_data; DBG("qmi data %p DBusmessage %p", qmi, message); g_return_if_fail(qmi); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); connman_error("%s", dbus_error); } DBG("Device %s connected %d", qmi->devpath, qmi->modem_connected); }
static void _method_call (DBusConnection *conn, int timeout_milliseconds) { DBusPendingCall *pending; DBusMessage *method; DBusMessage *reply; char *echo = "echo"; /* send the message */ method = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteEchoService", "/org/freedesktop/TestSuite", "org.freedesktop.TestSuite", "DelayEcho"); dbus_message_append_args (method, DBUS_TYPE_STRING, &echo, NULL); dbus_connection_send_with_reply (conn, method, &pending, timeout_milliseconds); dbus_message_unref (method); /* block on the message */ dbus_pending_call_block (pending); /* check the reply only to make sure we are not getting errors unrelated to the block in poll bug */ reply = dbus_pending_call_steal_reply (pending); if (reply == NULL) { printf ("Bail out! Reply is NULL ***\n"); exit (1); } if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) { printf ("Bail out! Reply is error: %s ***\n", dbus_message_get_error_name (reply)); exit (1); } dbus_message_unref (reply); dbus_pending_call_unref (pending); }
static int cdbus_create_snap_unpack(DBusConnection *conn, DBusMessage *rsp_msg, uint32_t *snap_id_out) { DBusMessageIter iter; int msg_type; const char *sig; msg_type = dbus_message_get_type(rsp_msg); if (msg_type == DBUS_MESSAGE_TYPE_ERROR) { fprintf(stderr, "create snap error response: %s\n", dbus_message_get_error_name(rsp_msg)); return -EINVAL; } if (msg_type != DBUS_MESSAGE_TYPE_METHOD_RETURN) { fprintf(stderr, "unexpected create snap ret type: %d\n", msg_type); return -EINVAL; } sig = dbus_message_get_signature(rsp_msg); if ((sig == NULL) || (strcmp(sig, CDBUS_SIG_CREATE_SNAP_RSP) != 0)) { fprintf(stderr, "bad create snap response sig: %s, " "expected: %s\n", (sig ? sig : "NULL"), CDBUS_SIG_CREATE_SNAP_RSP); return -EINVAL; } /* read the parameters */ if (!dbus_message_iter_init(rsp_msg, &iter)) { fprintf(stderr, "Message has no arguments!\n"); return -EINVAL; } if (cdbus_type_check_get(&iter, DBUS_TYPE_UINT32, snap_id_out)) { return -EINVAL; } return 0; }
/** * @brief Callback connecting network */ static void network_connect_callback(DBusMessage *message, void *user_data) { struct qmi_data *qmi = (struct qmi_data *)user_data; DBG("qmi data %p DBusmessage %p", qmi, message); g_return_if_fail(qmi); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); /*Failure during connecting */ qmi->modem_connected = FALSE; if(qmi->network) connman_network_set_connected(qmi->network, FALSE); connman_error("%s", dbus_error); return; } /* Connected successfully */ qmi->modem_connected = TRUE; connman_network_set_connected(qmi->network, TRUE); DBG("Device %s connected %d", qmi->devpath, qmi->modem_connected); g_assert(qmi->qmi_proxy_device); /* Request all available properties */ g_dbus_proxy_method_call( qmi->qmi_proxy_device, GET_PROPERTIES, NULL, get_properties_callback, qmi, NULL); //FIXME Hack NAT enable by default __connman_nat_enable("qmi", NULL, 0); }
EAPI Eina_Bool eldbus_message_error_get(const Eldbus_Message *msg, const char **name, const char **text) { if (name) *name = NULL; if (text) *text = NULL; ELDBUS_MESSAGE_CHECK_RETVAL(msg, EINA_FALSE); if (dbus_message_get_type(msg->dbus_msg) != DBUS_MESSAGE_TYPE_ERROR) return EINA_FALSE; if (name) *name = dbus_message_get_error_name(msg->dbus_msg); if (text) dbus_message_get_args(msg->dbus_msg, NULL, DBUS_TYPE_STRING, text, DBUS_TYPE_INVALID); return EINA_TRUE; }
static void tethering_create_cb(DBusMessage *message, void *user_data) { struct tethering_info *tethering = user_data; if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); DBG("%s tethering failed: %s", tethering->enable ? "enable" : "disable", dbus_error); return; } DBG("bridge %s %s", tethering->bridge, tethering->enable ? "enabled": "disabled"); if (tethering->technology) connman_technology_tethering_notify(tethering->technology, tethering->enable); }
/** * @brief Callback getting properties */ static void get_properties_callback(DBusMessage *message, void *user_data) { DBusMessageIter iter; struct qmi_data *qmi = (struct qmi_data *)user_data; DBG("QMI data %p D-Bus message %p", qmi, message); if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); connman_error("%s", dbus_error); return; } if(dbus_message_iter_init(message, &iter) == FALSE) { connman_error("Failure init ITER"); return; } if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INVALID) { connman_error("Invalid D-Bus type"); return; } /* Set all received properties */ if(set_reply_to_qmi_data(&iter, qmi) == FALSE) { connman_error("Failure parse D-Bus message"); return; } }
void hippo_dbus_debug_log_error(const char *where, DBusMessage *message) { if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *error; const char *text; error = dbus_message_get_error_name(message); text = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID)) { g_debug("Got error reply at %s %s '%s'", where, error ? error : "NULL", text ? text : "NULL"); } else { g_debug("Got error reply at %s %s", where, error ? error : "NULL"); } } }
static void pan_disconnect_cb(DBusMessage *message, void *user_data) { const char *path = user_data; struct bluetooth_pan *pan; pan = g_hash_table_lookup(networks, path); if (!pan || !pan->network) { DBG("network already removed"); return; } if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); DBG("network %p %s", pan->network, dbus_error); } DBG("network %p", pan->network); connman_network_set_connected(pan->network, false); }