int connman_agent_reply_identity(const char *identity, const char *passphrase) { DBusMessageIter arg, dict; DBusMessage *reply; if (agent_if == NULL || agent_if->pending_reply == NULL) return 0; if (identity == NULL || passphrase == NULL) return -EINVAL; reply = dbus_message_new_method_return(agent_if->pending_reply); if (reply == NULL) return -ENOMEM; dbus_message_iter_init_append(reply, &arg); if (cui_dbus_open_dict(&arg, &dict) == FALSE) goto error; cui_dbus_append_dict_entry_basic(&dict, "Identity", DBUS_TYPE_STRING, &identity); cui_dbus_append_dict_entry_basic(&dict, "Passphrase", DBUS_TYPE_STRING, &passphrase); dbus_message_iter_close_container(&dict, &arg); send_agent_reply(reply); return 0; error: dbus_message_unref(reply); dbus_message_unref(agent_if->pending_reply); agent_if->pending_reply = NULL; return -ENOMEM; }
int connman_agent_reply_login(const char *username, const char *password) { DBusMessageIter arg, dict; DBusMessage *reply; if (agent_if == NULL || agent_if->pending_reply == NULL) return 0; if (username == NULL && password == NULL) return -EINVAL; reply = dbus_message_new_method_return(agent_if->pending_reply); if (reply == NULL) return -ENOMEM; dbus_message_iter_init_append(reply, &arg); if (cui_dbus_open_dict(&arg, &dict) == FALSE) goto error; cui_dbus_append_dict_entry_basic(&dict, "Username", DBUS_TYPE_STRING, &username); cui_dbus_append_dict_entry_basic(&dict, "Password", DBUS_TYPE_STRING, &password); dbus_message_iter_close_container(&dict, &arg); send_agent_reply(reply); return 0; error: dbus_message_unref(reply); dbus_message_unref(agent_if->pending_reply); agent_if->pending_reply = NULL; return -ENOMEM; }
static DBusMessage *hrcp_reset(DBusConnection *conn, DBusMessage *msg, void *data) { struct heartrate *hr = data; uint8_t value; char *vmsg; if (!hr->hrcp_val_handle) return btd_error_not_supported(msg); if (!hr->attrib) return btd_error_not_available(msg); value = 0x01; vmsg = g_strdup("Reset Control Point"); gatt_write_char(hr->attrib, hr->hrcp_val_handle, &value, sizeof(value), char_write_cb, vmsg); DBG("Energy Expended Value has been reset"); return dbus_message_new_method_return(msg); }
static DBusMessage * server_make_reply(DBusMessage *msg, int type, ...) { DBusMessage *rsp = 0; va_list va; va_start(va, type); if( (rsp = dbus_message_new_method_return(msg)) != 0 ) { if( !dbus_message_append_args_valist(rsp, type, va) ) { dbus_message_unref(rsp), rsp = 0; } } va_end(va); return rsp; }
static DBusHandlerResult profile_handler(DBusConnection *c, DBusMessage *m, void *userdata) { pa_bluetooth_backend *b = userdata; DBusMessage *r = NULL; const char *path, *interface, *member; pa_assert(b); path = dbus_message_get_path(m); interface = dbus_message_get_interface(m); member = dbus_message_get_member(m); pa_log_debug("dbus: path=%s, interface=%s, member=%s", path, interface, member); if (!pa_streq(path, HSP_AG_PROFILE) && !pa_streq(path, HSP_HS_PROFILE)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { const char *xml = PROFILE_INTROSPECT_XML; pa_assert_se(r = dbus_message_new_method_return(m)); pa_assert_se(dbus_message_append_args(r, DBUS_TYPE_STRING, &xml, DBUS_TYPE_INVALID)); } else if (dbus_message_is_method_call(m, BLUEZ_PROFILE_INTERFACE, "Release")) { pa_log_debug("Release not handled"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } else if (dbus_message_is_method_call(m, BLUEZ_PROFILE_INTERFACE, "RequestDisconnection")) { r = profile_request_disconnection(c, m, userdata); } else if (dbus_message_is_method_call(m, BLUEZ_PROFILE_INTERFACE, "NewConnection")) r = profile_new_connection(c, m, userdata); else return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (r) { pa_assert_se(dbus_connection_send(pa_dbus_connection_get(b->connection), r, NULL)); dbus_message_unref(r); } return DBUS_HANDLER_RESULT_HANDLED; }
static void pull_phonebook_callback(struct obc_session *session, GError *err, void *user_data) { struct obc_transfer *transfer = obc_session_get_transfer(session); struct pbap_data *pbap = user_data; DBusMessage *reply; const char *buf; int size; if (pbap->msg == NULL) goto done; if (err) { reply = g_dbus_create_error(pbap->msg, "org.openobex.Error.Failed", "%s", err->message); goto send; } reply = dbus_message_new_method_return(pbap->msg); buf = obc_transfer_get_buffer(transfer, &size); if (size == 0) buf = ""; dbus_message_append_args(reply, DBUS_TYPE_STRING, &buf, DBUS_TYPE_INVALID); obc_transfer_clear_buffer(transfer); send: g_dbus_send_message(conn, reply); dbus_message_unref(pbap->msg); pbap->msg = NULL; done: obc_transfer_unregister(transfer); }
static DBusMessage *assign_agent(DBusConnection *connection, DBusMessage *message, void *user_data) { struct session_data *session = user_data; const gchar *sender, *path; if (dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", "Invalid arguments in method call"); sender = dbus_message_get_sender(message); if (session_set_agent(session, sender, path) < 0) return g_dbus_create_error(message, "org.openobex.Error.AlreadyExists", "Already exists"); return dbus_message_new_method_return(message); }
static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessageIter iter; DBusMessageIter dict; DBusMessage *reply = NULL; const char *linkloss_level, *immalert_level; struct btd_device *device = data; reply = dbus_message_new_method_return(msg); if (!reply) return NULL; linkloss_level = link_loss_get_alert_level(device); immalert_level = imm_alert_get_level(device); dbus_message_iter_init_append(reply, &iter); if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict)) goto err; dict_append_entry(&dict, "LinkLossAlertLevel", DBUS_TYPE_STRING, &linkloss_level); dict_append_entry(&dict, "ImmediateAlertLevel", DBUS_TYPE_STRING, &immalert_level); if (!dbus_message_iter_close_container(&iter, &dict)) goto err; return reply; err: if (reply) dbus_message_unref(reply); return btd_error_failed(msg, "not enough memory"); }
static DBusMessage * impl_GetSize (DBusConnection * bus, DBusMessage * message, void *user_data) { AtkComponent *component = (AtkComponent *) user_data; gint iwidth = 0, iheight = 0; dbus_int32_t width, height; DBusMessage *reply; g_return_val_if_fail (ATK_IS_COMPONENT (user_data), droute_not_yet_handled_error (message)); atk_component_get_size (component, &iwidth, &iheight); width = iwidth; height = iheight; reply = dbus_message_new_method_return (message); if (reply) { dbus_message_append_args (reply, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID); } return reply; }
static DBusMessage *ongoing_call(DBusConnection *conn, DBusMessage *msg, void *data) { dbus_bool_t ongoing; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BOOLEAN, &ongoing, DBUS_TYPE_INVALID)) return invalid_args(msg); if (ongoing_call_status && !ongoing) { /* An ongoing call has finished. Continue connection.*/ sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_RESET); ongoing_call_status = FALSE; } else if (!ongoing_call_status && ongoing) { /* An ongoing call has started.*/ ongoing_call_status = TRUE; } DBG("OngoingCall status set to %d", ongoing_call_status); return dbus_message_new_method_return(msg); }
int my_test_peek_reply (NihDBusMessage *message, const char * value) { DBusMessage * reply; DBusMessageIter iter; nih_assert (message != NULL); nih_assert (value != NULL); /* If the sender doesn't care about a reply, don't bother wasting * effort constructing and sending one. */ if (dbus_message_get_no_reply (message->message)) return 0; /* Construct the reply message. */ reply = dbus_message_new_method_return (message->message); if (! reply) return -1; dbus_message_iter_init_append (reply, &iter); /* Marshal a char * onto the message */ if (! dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &value)) { dbus_message_unref (reply); return -1; } /* Send the reply, appending it to the outgoing queue. */ if (! dbus_connection_send (message->connection, reply, NULL)) { dbus_message_unref (reply); return -1; } dbus_message_unref (reply); return 0; }
static DBusMessage *stk_unregister_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_stk *stk = data; const char *agent_path; const char *agent_bus = dbus_message_get_sender(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!stk->default_agent) return __ofono_error_failed(msg); if (!stk_agent_matches(stk->default_agent, agent_path, agent_bus)) return __ofono_error_failed(msg); stk_agent_free(stk->default_agent); return dbus_message_new_method_return(msg); }
static void mv_set_callback(const struct ofono_error *error, void *data) { struct ofono_call_volume *cv = data; DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(cv->atom); if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { __ofono_dbus_pending_reply(&cv->pending, __ofono_error_failed(cv->pending)); return; } cv->microphone_volume = cv->pending_volume; __ofono_dbus_pending_reply(&cv->pending, dbus_message_new_method_return(cv->pending)); ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_VOLUME_INTERFACE, "MicrophoneVolume", DBUS_TYPE_BYTE, &cv->microphone_volume); }
DBusHandlerResult FcitxDBusMenuEventHandler(DBusConnection* connection, DBusMessage* message, void* user_data) { FcitxNotificationItem* notificationitem = user_data; DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; DBusMessage *reply = NULL; boolean flush = false; if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) { reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_STRING, &dbus_menu_interface, DBUS_TYPE_INVALID); } else if (dbus_message_is_method_call(message, DBUS_MENU_IFACE, "Event")) { /* this is no reply */ FcitxDBusMenuEvent(notificationitem, message); return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call(message, DBUS_MENU_IFACE, "GetProperty")) { reply = FcitxDBusMenuGetProperty(notificationitem, message); } else if (dbus_message_is_method_call(message, DBUS_MENU_IFACE, "GetLayout")) { reply = FcitxDBusMenuGetLayout(notificationitem, message); } else if (dbus_message_is_method_call(message, DBUS_MENU_IFACE, "GetGroupProperties")) { reply = FcitxDBusMenuGetGroupProperties(notificationitem, message); } else if (dbus_message_is_method_call(message, DBUS_MENU_IFACE, "AboutToShow")) { reply = FcitxDBusMenuAboutToShow(notificationitem, message); } else if (dbus_message_is_method_call(message, DBUS_INTERFACE_PROPERTIES, "Get")) { reply = FcitxDBusPropertyGet(notificationitem, dbusMenuPropertyTable, message); } else if (dbus_message_is_method_call(message, DBUS_INTERFACE_PROPERTIES, "Set")) { reply = FcitxDBusPropertySet(notificationitem, dbusMenuPropertyTable, message); } else if (dbus_message_is_method_call(message, DBUS_INTERFACE_PROPERTIES, "GetAll")) { reply = FcitxDBusPropertyGetAll(notificationitem, dbusMenuPropertyTable, message); } if (reply) { dbus_connection_send(connection, reply, NULL); dbus_message_unref(reply); if (flush) { dbus_connection_flush(connection); } result = DBUS_HANDLER_RESULT_HANDLED; } return result; }
static DBusMessage *default_adapter(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessage *reply; struct btd_adapter *adapter; const gchar *path; adapter = manager_find_adapter_by_id(default_adapter_id); if (!adapter) return btd_error_no_such_adapter(msg); reply = dbus_message_new_method_return(msg); if (!reply) return NULL; path = adapter_get_path(adapter); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); return reply; }
static DBusMessage *push_notification_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct push_notification *pn = data; const char *agent_path; if (pn->agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); pn->agent = sms_agent_new(AGENT_INTERFACE, dbus_message_get_sender(msg), agent_path); if (pn->agent == NULL) return __ofono_error_failed(msg); sms_agent_set_removed_notify(pn->agent, agent_exited, pn); pn->push_watch[0] = __ofono_sms_datagram_watch_add(pn->sms, push_received, WAP_PUSH_DST_PORT, WAP_PUSH_SRC_PORT, pn, NULL); pn->push_watch[1] = __ofono_sms_datagram_watch_add(pn->sms, push_received, WAP_PUSH_DST_PORT, 0, pn, NULL); return dbus_message_new_method_return(msg); }
static void write_req_cb(guint8 status, const guint8 *pdu, guint16 len, gpointer user_data) { DBusMessage *reply; struct write_val_op *write_op = user_data; struct characteristic *chr = write_op->chr; struct write_resp_op *resp_op; const char *error_str = att_ecode2str(status); INFO("write_req_cb chr:%s status:%s(%d)", chr->path, error_str,status); reply = dbus_message_new_method_return(write_op->msg); g_dbus_send_message(write_op->conn, reply); g_free(write_op); resp_op = g_new0(struct write_resp_op,1); resp_op->chr = chr; resp_op->status = status; g_slist_foreach(chr->gatt->watchers, update_watchers_write_complete, resp_op); g_free(resp_op); }
static DBusMessage *sink_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct audio_device *device = data; struct sink *sink = device->sink; DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; const char *state; gboolean value; reply = dbus_message_new_method_return(msg); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); /* Playing */ value = (sink->stream_state == AVDTP_STATE_STREAMING); dict_append_entry(&dict, "Playing", DBUS_TYPE_BOOLEAN, &value); /* Connected */ value = (sink->stream_state >= AVDTP_STATE_CONFIGURED); dict_append_entry(&dict, "Connected", DBUS_TYPE_BOOLEAN, &value); /* State */ state = state2str(sink->state); if (state) dict_append_entry(&dict, "State", DBUS_TYPE_STRING, &state); dbus_message_iter_close_container(&iter, &dict); return reply; }
static void radio_fast_dormancy_set_callback(const struct ofono_error *error, void *data) { struct ofono_radio_settings *rs = data; DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Error setting fast dormancy"); rs->fast_dormancy_pending = rs->fast_dormancy; reply = __ofono_error_failed(rs->pending); __ofono_dbus_pending_reply(&rs->pending, reply); return; } reply = dbus_message_new_method_return(rs->pending); __ofono_dbus_pending_reply(&rs->pending, reply); radio_set_fast_dormancy(rs, rs->fast_dormancy_pending); }
/* Callback: "a message is received to a registered object path" */ static DBusHandlerResult message_received(DBusConnection* conn, DBusMessage* msg, void* data) { const char* member = dbus_message_get_member(msg); VERB1 log("%s(method:'%s')", __func__, member); set_client_name(dbus_message_get_sender(msg)); DBusMessage* reply = dbus_message_new_method_return(msg); int r = -1; if (strcmp(member, "DeleteDebugDump") == 0) r = handle_DeleteDebugDump(msg, reply); // NB: C++ binding also handles "Introspect" method, which returns a string. // It was sending "dummy" introspection answer whick looks like this: // "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" // "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" // "<node>\n" // "</node>\n" // Apart from a warning from abrt-gui, just sending error back works as well. // NB2: we may want to handle "Disconnected" here too. if (r < 0) { /* handle_XXX experienced an error (and did not send any reply) */ dbus_message_unref(reply); if (dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_METHOD_CALL) { /* Create and send error reply */ reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "not supported"); if (!reply) die_out_of_memory(); send_flush_and_unref(reply); } } set_client_name(NULL); return DBUS_HANDLER_RESULT_HANDLED; }
static DBusMessage *message_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct message *m = data; DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; reply = dbus_message_new_method_return(msg); if (reply == NULL) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, OFONO_PROPERTIES_ARRAY_SIGNATURE, &dict); message_append_properties(m, &dict); dbus_message_iter_close_container(&iter, &dict); return reply; }
static DBusHandlerResult request_passkey_message(DBusConnection *conn, DBusMessage *msg) { DBusMessage *reply; DBusError derr; const char *device; char passkey[17]; const char *psk = passkey; reply = dbus_message_new_method_return(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; dbus_error_init(&derr); if (!dbus_message_get_args(msg, &derr, DBUS_TYPE_OBJECT_PATH, &device, DBUS_TYPE_INVALID)) { fprintf(stderr, "%s", derr.message); dbus_error_free(&derr); return error_message(conn, msg, "org.bluez.Error.Rejected", "Wrong signature"); } if (device) printf("Device: %s\n", device); memset(passkey, 0, sizeof(passkey)); printf("Insert passkey >> "); scanf("%16s", passkey); dbus_message_append_args(reply, DBUS_TYPE_STRING, &psk, DBUS_TYPE_INVALID); dbus_connection_send(conn, reply, NULL); dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; }
static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct heartrate *hr = data; DBusMessageIter iter; DBusMessageIter dict; DBusMessage *reply; gboolean has_reset; reply = dbus_message_new_method_return(msg); if (reply == NULL) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); if (hr->has_location) { char *loc = g_strdup(location2str(hr->location)); if (loc) { dict_append_entry(&dict, "Location", DBUS_TYPE_STRING, &loc); g_free(loc); } } has_reset = !!hr->hrcp_val_handle; dict_append_entry(&dict, "ResetSupported", DBUS_TYPE_BOOLEAN, &has_reset); dbus_message_iter_close_container(&iter, &dict); return reply; }
static DBusMessage *list_adapters(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessageIter iter; DBusMessageIter array_iter; DBusMessage *reply; GSList *l; reply = dbus_message_new_method_return(msg); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH_AS_STRING, &array_iter); for (l = adapters; l; l = l->next) { struct adapter *adapter = l->data; char *path; struct hci_dev_info di; if (hci_devinfo(adapter->dev_id, &di) < 0) continue; if (hci_test_bit(HCI_RAW, &di.flags)) continue; path = adapter->path + ADAPTER_PATH_INDEX; dbus_message_iter_append_basic(&array_iter, DBUS_TYPE_OBJECT_PATH, &path); } dbus_message_iter_close_container(&iter, &array_iter); return reply; }
static DBusMessage *generate_get_properties_reply(struct ofono_sms *sms, DBusMessage *msg) { DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; const char *sca; const char *bearer; const char *alphabet; reply = dbus_message_new_method_return(msg); if (reply == NULL) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, OFONO_PROPERTIES_ARRAY_SIGNATURE, &dict); sca = phone_number_to_string(&sms->sca); ofono_dbus_dict_append(&dict, "ServiceCenterAddress", DBUS_TYPE_STRING, &sca); ofono_dbus_dict_append(&dict, "UseDeliveryReports", DBUS_TYPE_BOOLEAN, &sms->use_delivery_reports); bearer = sms_bearer_to_string(sms->bearer); ofono_dbus_dict_append(&dict, "Bearer", DBUS_TYPE_STRING, &bearer); alphabet = sms_alphabet_to_string(sms->alphabet); ofono_dbus_dict_append(&dict, "Alphabet", DBUS_TYPE_STRING, &alphabet); dbus_message_iter_close_container(&iter, &dict); return reply; }
static DBusHandlerResult nfs_rpc_cbsim_get_client_ids(DBusConnection *conn, DBusMessage *msg, void *user_data) { DBusMessage* reply; static uint32_t i, serial = 1; hash_table_t *ht = ht_confirmed_client_id; struct rbt_head *head_rbt; hash_data_t *pdata = NULL; struct rbt_node *pn; nfs_client_id_t *pclientid; uint64_t clientid; DBusMessageIter iter, sub_iter; /* create a reply from the message */ reply = dbus_message_new_method_return(msg); dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64_AS_STRING, &sub_iter); /* For each bucket of the hashtable */ for(i = 0; i < ht->parameter.index_size; i++) { head_rbt = &(ht->partitions[i].rbt); /* acquire mutex */ pthread_rwlock_wrlock(&(ht->partitions[i].lock)); /* go through all entries in the red-black-tree*/ RBT_LOOP(head_rbt, pn) { pdata = RBT_OPAQ(pn); pclientid = (nfs_client_id_t *)pdata->buffval.pdata; clientid = pclientid->cid_clientid; dbus_message_iter_append_basic(&sub_iter, DBUS_TYPE_UINT64, &clientid); RBT_INCREMENT(pn); } pthread_rwlock_unlock(&(ht->partitions[i].lock)); }
void getServerInformation(DBusMessage *dmsg) { DBusMessage *reply; DBusMessageIter args; char *param = ""; const char *info[4] = {"dunst", "dunst", "2011", "2011"}; if (!dbus_message_iter_init(dmsg, &args)) { } else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) { } else { dbus_message_iter_get_basic(&args, ¶m); } reply = dbus_message_new_method_return(dmsg); dbus_message_iter_init_append(reply, &args); if(!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &info[0]) || !dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &info[1]) || !dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &info[2]) || !dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &info[3])) { fprintf(stderr, "Unable to fill arguments"); return; } dbus_serial++; if (!dbus_connection_send(dbus_conn, reply, &dbus_serial)) { fprintf(stderr, "Out Of Memory!\n"); exit(EXIT_FAILURE); } dbus_connection_flush(dbus_conn); dbus_message_unref(reply); }
/***************************************************** ** DISCRIPTION: ** synchronize files to other boards ** INPUT: ** ** OUTPUT: ** ** RETURN: ** ** CREATOR: ** <*****@*****.**> ** DATE: ** 2011-08-18 *****************************************************/ DBusMessage * bsd_synchronize_files(DBusConnection *conn, DBusMessage *msg, void *user_data){ DBusMessage* reply; DBusMessageIter iter; DBusError err; int ret = BSD_DBUS_SUCCESS; int syn_type = 0; dbus_error_init(&err); if (!(dbus_message_get_args ( msg, &err, DBUS_TYPE_UINT32,&syn_type, DBUS_TYPE_INVALID))) { bsd_syslog_err("copy files between boards:Unable to get input args "); if (dbus_error_is_set(&err)) { bsd_syslog_err("copy files failed %s raised: %s",err.name,err.message); dbus_error_free(&err); } return NULL; } system("sudo mount /blk"); //printf("syn_type = %d\n",syn_type); ret = BSDSynchronizeFiles(syn_type); //printf("@@@@@@@@@ time = %ld @@@@@@@@@\n",finish - start); system("sudo umount /blk"); reply = dbus_message_new_method_return(msg); if(NULL == reply){ bsd_syslog_err("vrrp set hansi profile dbus reply null!\n"); return reply; } dbus_message_iter_init_append (reply, &iter); dbus_message_iter_append_basic (&iter,DBUS_TYPE_UINT32,&ret); return reply; }
static DBusHandlerResult filter_session_message (DBusConnection *connection, DBusMessage *message, void *user_data) { TestServiceData *testdata = user_data; if (dbus_message_is_method_call (message, "org.freedesktop.DBus.TestSuite.PrivServer", "GetPrivateAddress")) { DBusMessage *reply; reply = dbus_message_new_method_return (message); if (reply == NULL) die ("OOM"); if (!dbus_message_append_args (reply, DBUS_TYPE_STRING, &(testdata->private_addr), DBUS_TYPE_INVALID)) die ("OOM"); if (!dbus_connection_send (connection, reply, NULL)) die ("Error sending message"); dbus_message_unref (reply); return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.TestSuite.PrivServer", "Quit")) { fprintf (stderr, "server exiting loop\n"); _dbus_loop_quit (testdata->loop); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
/** D-Bus callback for the color profile change method call * * @param msg The D-Bus message * @return TRUE */ static gboolean color_profile_change_req_dbus_cb(DBusMessage *const msg) { mce_log(LL_DEVEL, "Received set color profile request from %s", mce_dbus_get_message_sender_ident(msg)); const char *val = 0; DBusError err = DBUS_ERROR_INIT; dbus_bool_t ack = FALSE; DBusMessage *rsp = 0; if( !dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &val, DBUS_TYPE_INVALID)) { // XXX: should we return an error instead? mce_log(LL_ERR, "Failed to get argument from %s.%s: %s: %s", MCE_REQUEST_IF, MCE_COLOR_PROFILE_CHANGE_REQ, err.name, err.message); } else { if( set_color_profile(val) ) ack = TRUE; } if( dbus_message_get_no_reply(msg) ) goto EXIT; if( !(rsp = dbus_message_new_method_return(msg)) ) goto EXIT; dbus_message_append_args(rsp, DBUS_TYPE_BOOLEAN, &ack, DBUS_TYPE_INVALID); EXIT: if( rsp ) dbus_send_message(rsp), rsp = 0; dbus_error_free(&err); return TRUE; }