Exemple #1
0
static void create_config_reply(DBusPendingCall *call, void *user_data)
{
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	const char *path;

	DBG("");

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		connman_error("Failed to create proxy configuration");
		goto done;
	}

	if (dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
						DBUS_TYPE_INVALID) == FALSE)
		goto done;

	g_free(current_config);
	current_config = g_strdup(path);

done:
	dbus_message_unref(reply);
}
void dbus_func_args_async_callback(DBusPendingCall *call, void *data) {

  dbus_async_call_t *req = (dbus_async_call_t *)data;
  DBusMessage *msg;

  /* This is guaranteed to be non-NULL, because this function is called only
     when once the remote method invokation returns. */
  msg = dbus_pending_call_steal_reply(call);

  if (msg) {
    if (req->user_cb) {
      // The user may not deref the message object.
      req->user_cb(msg, req->user);
    }
    dbus_message_unref(msg);
  }

  //dbus_message_unref(req->method);
  dbus_pending_call_cancel(call);
  dbus_pending_call_unref(call);
  free(req);
}
static void
get_active_cb(DBusPendingCall *pending, void *data)
{
	struct launcher_logind *wl = data;
	DBusMessageIter iter;
	DBusMessage *m;
	int type;

	dbus_pending_call_unref(wl->pending_active);
	wl->pending_active = NULL;

	m = dbus_pending_call_steal_reply(pending);
	if (!m)
		return;

	type = dbus_message_get_type(m);
	if (type == DBUS_MESSAGE_TYPE_METHOD_RETURN &&
	    dbus_message_iter_init(m, &iter))
		parse_active(wl, m, &iter);

	dbus_message_unref(m);
}
Exemple #4
0
static void
systemui_ack_cb(DBusPendingCall *pending, void *user_data)
{
  DBusMessage *rsp = dbus_pending_call_steal_reply(pending);

  if( rsp != 0 )
  {
    DBusError     err = DBUS_ERROR_INIT;
    dbus_int32_t *vec = 0;
    int           cnt = 0;

    switch( dbus_message_get_type(rsp) )
    {
    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
      if( dbus_message_get_args(rsp, &err,
                                DBUS_TYPE_ARRAY,
                                DBUS_TYPE_INT32, &vec, &cnt,
                                DBUS_TYPE_INVALID) )
      {
        if( systemui_ack_callback != 0 )
        {
          systemui_ack_callback(vec, cnt);
        }
      }
      if( dbus_error_is_set(&err) )
      {
        log_error_F("%s: %s\n", err.name, err.message);
      }
      break;

    case DBUS_MESSAGE_TYPE_ERROR:
      // TODO: handle system ui not up
      break;
    }

    dbus_error_free(&err);
    dbus_message_unref(rsp);
  }
}
Exemple #5
0
static void new_conn_reply(DBusPendingCall *call, void *user_data)
{
	struct ext_io *conn = user_data;
	struct ext_profile *ext = conn->ext;
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	DBusError err;

	dbus_error_init(&err);
	dbus_set_error_from_message(&err, reply);

	dbus_message_unref(reply);

	dbus_pending_call_unref(conn->new_conn);
	conn->new_conn = NULL;

	if (!dbus_error_is_set(&err)) {
		if (conn->cb) {
			conn->cb(&ext->p, conn->device, 0);
			conn->cb = NULL;
		}
		return;
	}

	error("%s replied with an error: %s, %s", ext->name,
						err.name, err.message);

	if (conn->cb) {
		conn->cb(&ext->p, conn->device, -ECONNREFUSED);
		conn->cb = NULL;
	}

	if (dbus_error_has_name(&err, DBUS_ERROR_NO_REPLY))
		ext_cancel(ext);

	dbus_error_free(&err);

	ext->conns = g_slist_remove(ext->conns, conn);
	ext_io_destroy(conn);
}
Exemple #6
0
static void mode_request_reply(DBusPendingCall *call, void *user_data)
{
	struct obex_server *server = user_data;
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	DBusError derr;

	dbus_error_init(&derr);
	if (dbus_set_error_from_message(&derr, reply)) {
		error("usb: Replied with an error: %s, %s",
				derr.name, derr.message);
		dbus_error_free(&derr);
	} else {
		const char *mode;
		dbus_message_get_args(reply, NULL,
				DBUS_TYPE_STRING, &mode,
				DBUS_TYPE_INVALID);

		usb_set_mode(server, mode);
	}

	dbus_message_unref(reply);
}
Exemple #7
0
static void session_request_reply(DBusPendingCall *call, gpointer user_data)
{
	struct pending_data *pending = user_data;
	struct obc_session *session = pending->session;
	DBusMessage *reply = dbus_pending_call_steal_reply(call);
	const char *name;
	DBusError derr;

	dbus_error_init(&derr);
	if (dbus_set_error_from_message(&derr, reply)) {
		GError *gerr = NULL;

		error("Replied with an error: %s, %s",
				derr.name, derr.message);
		dbus_error_free(&derr);
		dbus_message_unref(reply);

		g_set_error(&gerr, OBEX_IO_ERROR, -ECANCELED, "%s",
								derr.message);
		session_terminate_transfer(session, pending->transfer, gerr);
		g_clear_error(&gerr);

		return;
	}

	dbus_message_get_args(reply, NULL,
			DBUS_TYPE_STRING, &name,
			DBUS_TYPE_INVALID);

	DBG("Agent.Request() reply: %s", name);

	if (strlen(name))
		obc_transfer_set_name(pending->transfer, name);

	pending->cb(session, NULL, pending->transfer);
	dbus_message_unref(reply);

	return;
}
Exemple #8
0
static void connect_cb(DBusPendingCall *call, void *user_data)
{
	struct synce_context *context = user_data;
	DBusConnection *conn;
	DBusMessage *reply;
	DBusError err;
	char *path;

	conn = context->dbus_conn;

	reply = dbus_pending_call_steal_reply(call);

	dbus_error_init(&err);
	if (dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH, &path,
						DBUS_TYPE_INVALID) == FALSE) {
		error("%s", err.message);
		dbus_error_free(&err);
		goto failed;
	}

	DBG("Got conn object %s from syncevolution", path);
	context->conn_obj = g_strdup(path);

	context->reply_watch = g_dbus_add_signal_watch(conn, NULL, path,
						SYNCE_CONN_INTERFACE, "Reply",
						reply_signal, context, NULL);

	context->abort_watch = g_dbus_add_signal_watch(conn, NULL, path,
						SYNCE_CONN_INTERFACE, "Abort",
						abort_signal, context, NULL);

	dbus_message_unref(reply);

	return;

failed:
	obex_object_set_io_flags(context, G_IO_ERR, -EPERM);
	context->lasterr = -EPERM;
}
Exemple #9
0
int dbus_call_method(DBusConnection* dbus_connection, const char* bus_name,
	const char* path, const char* iface, const char* method,
	char** params, char** ret)
{
	DBusMessage *message;
	DBusMessageIter args;
	DBusPendingCall* pending;
	int param_index, param_count = sizeof(params) / sizeof(char*);

	message = dbus_message_new_method_call(
		bus_name,
		path,
		iface,
		method);

	dbus_message_iter_init_append(message, &args);
	for (param_index = 0; param_index < param_count; param_index++) {
		dbus_message_iter_append_basic(
			&args, DBUS_TYPE_STRING,
			&params[param_index]);
	}

	dbus_connection_send_with_reply(dbus_connection, message, &pending, -1);
	dbus_connection_flush(dbus_connection);
	dbus_message_unref(message);

	dbus_pending_call_block(pending);
	if (ret) message = dbus_pending_call_steal_reply(pending);
	dbus_pending_call_unref(pending);

	if (ret) {
		dbus_message_iter_init(message, &args);
		dbus_message_iter_get_basic(&args, ret);
		dbus_message_unref(message);
	}

	return RET_OK;
}
Exemple #10
0
static void
cb_pending(DBusPendingCall *dbus_pending, void *user_data)
{
   Eldbus_Message *msg;
   Eldbus_Pending *pending = user_data;

   if (!dbus_pending_call_get_completed(dbus_pending))
     {
        INF("timeout to pending %p", pending);
        dbus_pending_call_cancel(dbus_pending);
        msg = eldbus_message_error_new(pending->msg_sent,
                                       ELDBUS_ERROR_PENDING_TIMEOUT,
                                       "This call was not completed in time.");
        eldbus_pending_dispatch(pending, msg);
        return;
     }

   msg = eldbus_message_new(EINA_FALSE);
   EINA_SAFETY_ON_NULL_RETURN(msg);
   msg->dbus_msg = dbus_pending_call_steal_reply(dbus_pending);
   if (!msg->dbus_msg)
     {
        EINA_SAFETY_ON_NULL_GOTO(pending->cb, cleanup);

        msg->dbus_msg = dbus_message_new_error(NULL,
                            "org.enlightenment.DBus.NoReply",
                            "There was no reply to this method call.");
        EINA_SAFETY_ON_NULL_GOTO(msg->dbus_msg, cleanup);
     }

   dbus_message_iter_init(msg->dbus_msg, &msg->iterator->dbus_iterator);
   eldbus_pending_dispatch(pending, msg);

   return;

cleanup:
   eldbus_message_unref(msg);
}
Exemple #11
0
static void
systemui_ack_close(DBusPendingCall *pending, void *user_data)
{
  cookie_t cookie = (cookie_t)user_data;
  int      result = 0;

  DBusMessage *rsp = dbus_pending_call_steal_reply(pending);
  if( rsp != 0 )
  {
    DBusError     err = DBUS_ERROR_INIT;
    dbus_int32_t  ack = 0;

    switch( dbus_message_get_type(rsp) )
    {
    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
      if( dbus_message_get_args(rsp, &err,
                                DBUS_TYPE_INT32, &ack,
                                DBUS_TYPE_INVALID) )
      {
        result = ack;
      }
      if( dbus_error_is_set(&err) )
      {
        log_error_F("%s: %s\n", err.name, err.message);
      }
      break;

    case DBUS_MESSAGE_TYPE_ERROR:
      // TODO: handle system ui not up
      break;
    }

    dbus_error_free(&err);
    dbus_message_unref(rsp);
  }

  log_debug_F("%ld -> %s\n", (long)cookie, (result>0) ? "ACK" : "NAK");
}
Exemple #12
0
static void loader_needed_cb(DBusPendingCall *pending, void *user_data)
{
    (void)user_data;

    DBusMessage *rsp = 0;
    DBusError    err = DBUS_ERROR_INIT;

    if (!(rsp = dbus_pending_call_steal_reply(pending)))
        goto cleanup;

    if (dbus_set_error_from_message(&err, rsp)) {
        dsme_log(LOG_DEBUG, "wlanloader: disabled, GetUnit: %s: %s",
                                                    err.name, err.message);
    } else {
        /* We got the reply without error, so the service exists */
        dsme_dbus_bind_signals(&bound, signals);
        dsme_log(LOG_DEBUG, "wlanloader: activated");
    }

cleanup:
    if (rsp) dbus_message_unref(rsp);
    dbus_error_free(&err);
}
/* Don't be bothered by the fact that this function is almost exactly
 * the same as object_created().  The little difference is that it
 * gives the callback the objectid on error too. */
static void object_destroyed(DBusPendingCall *pendelum, RequestReplyInfo *info)
{
	GError *error;
	DBusMessage *reply;

	reply = dbus_pending_call_steal_reply(pendelum);
	if (!(error = mafw_dbus_is_error(reply, MAFW_SOURCE_ERROR))) {
		g_assert(dbus_message_get_type(reply) ==
                         DBUS_MESSAGE_TYPE_METHOD_RETURN);
		if (info->object_destroyed_cb)
			info->object_destroyed_cb(info->src,
					  info->objectid,
					  info->cbdata, NULL);
	} else {
		if (info->object_destroyed_cb)
			info->object_destroyed_cb(info->src,
					  info->objectid,
					  info->cbdata, error);
		g_error_free(error);
	}
	dbus_message_unref(reply);
	dbus_pending_call_unref(pendelum);
}
Exemple #14
0
static void register_agent_cb(DBusPendingCall *pending, void *user_data)
{
	DBusMessage *reply;

	if (dbus_pending_call_get_completed(pending) == FALSE)
		return;

	register_call = NULL;

	reply = dbus_pending_call_steal_reply(pending);
	if (reply == NULL)
		goto out;

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		g_dbus_unregister_interface(connection,
					AGENT_PATH, NEARD_AGENT_INTERFACE);
	} else
		agent_registered = TRUE;

	dbus_message_unref(reply);
out:
	dbus_pending_call_unref(pending);
}
Exemple #15
0
static void method_call_reply(DBusPendingCall *call, void *user_data)
{
	struct method_call_data *data = user_data;
	DBusMessage *reply;
	DBusMessageIter iter;
	const char *error;

	reply = dbus_pending_call_steal_reply(call);

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
		error = dbus_message_get_error_name(reply);
	else
		error = NULL;

	dbus_message_iter_init(reply, &iter);

	if (data->function != NULL)
		data->function(error, &iter, data->user_data);

	dbus_message_unref(reply);

	dbus_pending_call_unref(call);
}
Exemple #16
0
static void
FcitxNotifyCallback(DBusPendingCall *call, void *data)
{
    FcitxNotifyItem *item = (FcitxNotifyItem*)data;
    if (item->global_id)
        return;
    FcitxNotify *notify = item->owner;
    DBusMessage *msg = dbus_pending_call_steal_reply(call);
    if (msg) {
        uint32_t id;
        DBusError error;
        dbus_error_init(&error);
        dbus_message_get_args(msg, &error, DBUS_TYPE_UINT32,
                              &id , DBUS_TYPE_INVALID);
        dbus_message_unref(msg);
        dbus_error_free(&error);
        item->global_id = id;
        FcitxNotifyItemAddGlobal(notify, item);
        if (item->state == NOTIFY_TO_BE_REMOVE) {
            _FcitxNotifyCloseNotification(notify, item);
        }
    }
}
Exemple #17
0
void DBus_CallResult(DBusPendingCall *pending, void *data)
{
   DBusMessage *msg;
   Tcl_CallData *dataPtr = data;
   Tcl_DBusEvent *evPtr;
   
   msg = dbus_pending_call_steal_reply(pending);
   /* free the pending message handle */
   dbus_pending_call_unref(pending);
   /* Allocate a DBus event structure and copy in some basic data */
   evPtr = (Tcl_DBusEvent *) ckalloc(sizeof(Tcl_DBusEvent));
   evPtr->interp = dataPtr->interp;
   evPtr->script = dataPtr->script;
   evPtr->conn = dataPtr->conn;
   /* Fill in the rest of the DBus event structure */
   evPtr->event.proc = DBus_EventHandler;
   evPtr->msg = msg;
   /* Don't send a reply on the reply */
   evPtr->flags = dataPtr->flags | DBUSFLAG_NOREPLY;
   Tcl_QueueEvent((Tcl_Event *) evPtr, TCL_QUEUE_TAIL);
   /* Free the DBus handler data structure */
   ckfree(data);
}
void method_callback(DBusPendingCall* pending){
   dbus_bool_t stat;
   dbus_uint32_t level;
   DBusMessage* msg;
   DBusMessageIter args;
   DBusMessageIter list;
   DBusError error;
   char** service_list;
   char* stuff;
   int service_list_len, i;
        
   dbus_error_init (&error);

   // block until we receive a reply
   dbus_pending_call_block(pending);
   
   // get the reply message
   msg = dbus_pending_call_steal_reply(pending);
   if (NULL == msg) {
      fprintf(stderr, "Reply Null\n"); 
      exit(1); 
   }
   // free the pending message handle
   dbus_pending_call_unref(pending);

    /* Extract the data from the reply */
    if (!dbus_message_get_args (msg, &error,
                               DBUS_TYPE_STRING, &service_list,
                               DBUS_TYPE_INVALID )) {
        fprintf (stderr, "Failed to complete 71 get_args call: %s\n", error.message);
        exit (1);
    }

    printf("Got Reply: \n%s\n", service_list);
    // free reply and close connection
    dbus_message_unref(msg);   
}
int dc_render_node_create(struct razer_daemon_controller *controller,int effect_uid,char *name,char *description)
{
	DBusMessage *msg;
	DBusMessageIter args;
	msg = dbus_message_new_method_call("org.voyagerproject.razer.daemon","/","org.voyagerproject.razer.daemon.render_node","create");
	if(!msg)
		dc_error_close(controller,"Error creating Message\n");
	dbus_message_iter_init_append(msg,&args);
	if(!dbus_message_iter_append_basic(&args,DBUS_TYPE_INT32,&effect_uid))
		dc_error_close(controller,"Out of memory!\n"); 
	if(!dbus_message_iter_append_basic(&args,DBUS_TYPE_STRING,&name))
		dc_error_close(controller,"Out of memory!\n"); 
	if(!dbus_message_iter_append_basic(&args,DBUS_TYPE_STRING,&description))
		dc_error_close(controller,"Out of memory!\n"); 
	if(!dbus_connection_send_with_reply(controller->dbus,msg,&controller->pending,-1))
		dc_error_close(controller,"Out of memory!\n"); 
	if(!controller->pending)
		dc_error_close(controller,"No pending call\n"); 
	dbus_connection_flush(controller->dbus);
	dbus_message_unref(msg);

	int render_node_uid = -1;

	dbus_pending_call_block(controller->pending);
	msg = dbus_pending_call_steal_reply(controller->pending);
	if(!msg)
		dc_error_close(controller,"Empty reply\n"); 
	dbus_pending_call_unref(controller->pending);
	if(!dbus_message_iter_init(msg,&args))
		dc_error_close(controller,"Message has no arguments!\n"); 
	else if(dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_INT32) 
		dc_error_close(controller,"Argument is not an int!\n"); 
	else
		dbus_message_iter_get_basic(&args,&render_node_uid);
	dbus_message_unref(msg);   
	return(render_node_uid);
}
char *dc_fx_list(struct razer_daemon_controller *controller)
{
	DBusMessage *msg;
	DBusMessageIter args;
	msg = dbus_message_new_method_call("org.voyagerproject.razer.daemon","/","org.voyagerproject.razer.daemon.fx","list");
	if(!msg)
		dc_error_close(controller,"Error creating Message\n");
	if(!dbus_connection_send_with_reply(controller->dbus,msg,&controller->pending,-1))
		dc_error_close(controller,"Out of memory!\n"); 
	if(!controller->pending)
		dc_error_close(controller,"No pending call\n"); 
	dbus_connection_flush(controller->dbus);
	dbus_message_unref(msg);

	char *list = NULL;

	dbus_pending_call_block(controller->pending);
	msg = dbus_pending_call_steal_reply(controller->pending);
	if(!msg)
		dc_error_close(controller,"Empty reply\n"); 
	dbus_pending_call_unref(controller->pending);
	if(!dbus_message_iter_init(msg,&args))
		dc_error_close(controller,"Message has no arguments!\n"); 
	else if(dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) 
		dc_error_close(controller,"Argument is not a string!\n"); 
	else
		dbus_message_iter_get_basic(&args,&list);
	//if(!dbus_message_iter_next(&args))
	//	dc_error_close(controller,"Message has too few arguments!\n"); 
	//else if(dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_UINT32) 
	//	dc_error_close(controller,"Argument is not int!\n"); 
	//else
	//	dbus_message_iter_get_basic(&args,&level);
	//printf("fx List: %s\n",list);
	dbus_message_unref(msg);   
	return(list);
}
Exemple #21
0
int get_device_list(DBusConnection * conn, char *dev_list[30])
{
	DBusMessage *msg;
	DBusMessageIter args;
	DBusPendingCall *pending;
	int num_of_dev = 0;

	msg = dbus_message_new_method_call("org.freedesktop.NetworkManager",	/* Destination */
					   "/org/freedesktop/NetworkManager",	/* Object Path */
					   "org.freedesktop.NetworkManager",	/* Interface */
					   "GetDevices");	/* Method */
	if (NULL == msg) {
		syslog(LOG_ERR, "Message Null in \n");
		syslog(LOG_ERR, "Message Null in get_device_list \n");
		exit(1);
	}

	if (!dbus_connection_send_with_reply(conn, msg, &pending, -1)) {
		syslog(LOG_ERR, "Out Of Memory!\n");
		exit(1);
	}
	dbus_connection_flush(conn);
	dbus_message_unref(msg);
	dbus_pending_call_block(pending);
	msg = dbus_pending_call_steal_reply(pending);
	if (NULL == msg) {
		syslog(LOG_ERR, "Reply Null\n");
		exit(1);
	}
	dbus_pending_call_unref(pending);
	if (!dbus_message_iter_init(msg, &args))
		syslog(LOG_ERR, "Message has no arguments!\n");
	else
		num_of_dev = read_array(&args, dev_list);
	dbus_message_unref(msg);
	return (num_of_dev);
}
Exemple #22
0
static void check_sim_status_reply(DBusPendingCall *call, void *user_data)
{
	DBusMessage *reply;
	DBusError error;
	struct tapi_modem *modem = user_data;
	int status;
	bool changed;

	DBG("");

	reply = dbus_pending_call_steal_reply(call);

	dbus_error_init(&error);

	if (dbus_set_error_from_message(&error, reply) == TRUE) {
		DBG("%s", error.message);
		dbus_error_free(&error);
		goto done;
	}

	if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32, &status,
					DBUS_TYPE_BOOLEAN, &changed,
					DBUS_TYPE_INVALID))
		goto done;

	DBG("sim status %d changed %d", status, changed);
	if (status == SIM_INIT_COMPLETED)
		modem->sim_available = true;

	if (default_modem == NULL && modem->sim_available == true)
		default_modem = modem;

done:
	dbus_message_unref(reply);
	dbus_pending_call_unref(call);
}
Exemple #23
0
static void adapter_reply(DBusPendingCall *call, void *user_data)
{
	struct bluetooth_session *session = user_data;
	DBusError err;
	DBusMessage *reply;
	GError *gerr = NULL;

	reply = dbus_pending_call_steal_reply(call);

	session->pending_calls = g_slist_remove(session->pending_calls, call);
	finalize_call(call);

	dbus_error_init(&err);
	if (dbus_set_error_from_message(&err, reply)) {
		error("manager replied with an error: %s, %s",
				err.name, err.message);
		dbus_error_free(&err);

		goto failed;
	}

	if (session_connect(session) == 0)
		goto proceed;

failed:
	g_set_error(&gerr, OBC_BT_ERROR, -EINVAL,
					"Unable to request session");
	if (session->func)
		session->func(session->io, gerr, session->user_data);
	g_clear_error(&gerr);

	session_destroy(session);

proceed:
	dbus_message_unref(reply);
}
Exemple #24
0
static void start_discovery_reply(DBusPendingCall *pcall,
                                  void *user_data)
{
    DBusMessage *reply;
    int type;

    printf("%s %d\n", __func__, __LINE__);

    reply = dbus_pending_call_steal_reply (pcall);
    type = dbus_message_get_type (reply);

    while(1)
    {
        if (type == DBUS_MESSAGE_TYPE_SIGNAL)
        {
            printf("%s %d get a signal\n", __func__, __LINE__);
            break;
        }
        printf("%s %d\n", __func__, __LINE__);
        sleep(1);
    }

    dbus_message_unref (reply);
}
Exemple #25
0
static void scan_reply(DBusPendingCall *call, void *user_data)
{
	struct supplicant_task *task = user_data;
	DBusMessage *reply;

	_DBG_SUPPLICANT("task %p", task);

	task->scan_call = NULL;

	reply = dbus_pending_call_steal_reply(call);
	if (reply == NULL)
		return;

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
		connman_device_set_scanning(task->device, FALSE);
		goto done;
	}

	if (task->scanning == TRUE)
		connman_device_set_scanning(task->device, TRUE);

done:
	dbus_message_unref(reply);
}
Exemple #26
0
static void hfp_connect_reply(DBusPendingCall *call, gpointer user_data)
{
	struct ofono_modem *modem = user_data;
	struct hfp_data *data = ofono_modem_get_data(modem);
	DBusError derr;
	DBusMessage *reply, *msg;

	reply = dbus_pending_call_steal_reply(call);

	if (ofono_modem_get_powered(modem))
		goto done;

	dbus_error_init(&derr);
	if (!dbus_set_error_from_message(&derr, reply))
		goto done;

	DBG("Connect reply: %s", derr.message);

	if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
		msg = dbus_message_new_method_call(BLUEZ_SERVICE,
				data->handsfree_path,
				BLUEZ_GATEWAY_INTERFACE, "Disconnect");
		if (msg == NULL)
			ofono_error("Disconnect failed");
		else
			g_dbus_send_message(connection, msg);
	}

	ofono_modem_set_powered(modem, FALSE);

	dbus_error_free(&derr);

done:
	dbus_message_unref(reply);
	data->call = NULL;
}
Exemple #27
0
static void process_cb(DBusPendingCall *call, void *user_data)
{
	struct synce_context *context = user_data;
	DBusMessage *reply;
	DBusError derr;

	reply = dbus_pending_call_steal_reply(call);
	dbus_error_init(&derr);
	if (dbus_set_error_from_message(&derr, reply)) {
		error("process_cb(): syncevolution replied with an error:"
					" %s, %s", derr.name, derr.message);
		dbus_error_free(&derr);

		obex_object_set_io_flags(context, G_IO_ERR, -EPERM);
		context->lasterr = -EPERM;
		goto done;
	}

	obex_object_set_io_flags(context, G_IO_OUT, 0);
	context->lasterr = 0;

done:
	dbus_message_unref(reply);
}
Exemple #28
0
static void powered_reply(DBusPendingCall *call, void *user_data)
{
	DBusError error;
	DBusMessage *reply;

	DBG("");

	reply = dbus_pending_call_steal_reply(call);

	dbus_error_init(&error);

	if (dbus_set_error_from_message(&error, reply) == TRUE) {
		connman_error("%s", error.message);
		dbus_error_free(&error);
		dbus_message_unref(reply);
		dbus_pending_call_unref(call);
		return;
	}

	dbus_message_unref(reply);
	dbus_pending_call_unref(call);

	add_adapter(connection, user_data);
}
Exemple #29
0
static void
systemd_loadunit_cb(DBusPendingCall *pending, void *user_data)
{
    DBusMessage *reply = NULL;
    svc_action_t * op = user_data;

    if(pending) {
        reply = dbus_pending_call_steal_reply(pending);
    }

    if(op) {
        crm_trace("Got result: %p for %p for %s, %s", reply, pending, op->rsc, op->action);
    } else {
        crm_trace("Got result: %p for %p", reply, pending);
    }
    systemd_loadunit_result(reply, user_data);

    if(pending) {
        dbus_pending_call_unref(pending);
    }
    if(reply) {
        dbus_message_unref(reply);
    }
}
static void get_property_reply(DBusPendingCall *call, void *user_data)
{
	DBusMessage *reply;
	struct get_property_data *gpd = user_data;
	char **values = gpd->accounts->property_values;
	int id = gpd->prop_id;

	reply = dbus_pending_call_steal_reply(call);
	if (reply == NULL) {
		ofono_error("%s: failed to get reply", __func__);
		goto done;
	}

	g_free(values[id]);
	values[id] = get_property_value(reply);
	dbus_message_unref(reply);

	DBG("property %s has value %s",
		setting_names[id].property_name, PRINTABLE_STR(values[id]));

done:
	dbus_pending_call_unref(call);
	g_free(gpd);
}