コード例 #1
0
ファイル: radiostates.c プロジェクト: spiiroin/mce
/** Initiate asynchronous connman properties query
 *
 * @return TRUE if the method call was initiated, or FALSE in case of errors
 */
static gboolean xconnman_get_properties(void)
{
	gboolean         res  = FALSE;
	DBusMessage     *req  = 0;
	DBusPendingCall *pc   = 0;

	if( !(req = dbus_message_new_method_call(CONNMAN_SERVICE,
						 CONNMAN_OBJECT_PATH,
						 CONNMAN_INTERFACE,
						 CONNMAN_GET_PROPERTIES_REQ)) )
		goto EXIT;

	if( !dbus_connection_send_with_reply(connman_bus, req, &pc, -1) )
		goto EXIT;

	if( !pc )
		goto EXIT;

	mce_dbus_pending_call_blocks_suspend(pc);

	if( !dbus_pending_call_set_notify(pc, xconnman_get_properties_cb, 0, 0) )
		goto EXIT;

	// success
	res = TRUE;

EXIT:
	if( pc )  dbus_pending_call_unref(pc);
	if( req ) dbus_message_unref(req);

	return res;
}
コード例 #2
0
ファイル: radiostates.c プロジェクト: spiiroin/mce
/** Initiate asynchronous connman property change D-Bus method call
 *
 * @param key property name
 * @param val value to set
 *
 * @return TRUE if the method call was initiated, or FALSE in case of errors
 */
static gboolean xconnman_set_property_bool(const char *key, gboolean val)
{
	gboolean         res  = FALSE;
	DBusMessage     *req  = 0;
	DBusPendingCall *pc   = 0;
	dbus_bool_t      dta  = val;

	DBusMessageIter miter, viter;

	mce_log(LL_DEBUG, "%s = %s", key, val ? "true" : "false");

	if( !(req = dbus_message_new_method_call(CONNMAN_SERVICE,
						 CONNMAN_OBJECT_PATH,
						 CONNMAN_INTERFACE,
						 CONNMAN_SET_PROPERTY_REQ)) )
		goto EXIT;

	dbus_message_iter_init_append(req, &miter);
	dbus_message_iter_append_basic(&miter, DBUS_TYPE_STRING, &key);

	if( !dbus_message_iter_open_container(&miter, DBUS_TYPE_VARIANT,
					      DBUS_TYPE_BOOLEAN_AS_STRING,
					      &viter) ) {
		mce_log(LL_WARN, "container open failed");
		goto EXIT;
	}

	dbus_message_iter_append_basic(&viter, DBUS_TYPE_BOOLEAN, &dta);

	if( !dbus_message_iter_close_container(&miter, &viter) ) {
		mce_log(LL_WARN, "container close failed");
		goto EXIT;
	}

	if( !dbus_connection_send_with_reply(connman_bus, req, &pc, -1) )
		goto EXIT;

	if( !pc )
		goto EXIT;

	mce_dbus_pending_call_blocks_suspend(pc);

	if( !dbus_pending_call_set_notify(pc, xconnman_set_property_cb, 0, 0) )
		goto EXIT;

	// success
	res = TRUE;

EXIT:
	if( pc )  dbus_pending_call_unref(pc);
	if( req ) dbus_message_unref(req);

	return res;
}
コード例 #3
0
ファイル: cpu-keepalive.c プロジェクト: spiiroin/mce
/** Verify that a client exists via an asynchronous GetNameOwner method call
 *
 * @param name  the dbus name who's owner we wish to know
 *
 * @return TRUE if the method call was initiated, or FALSE in case of errors
 */
static
gboolean
cka_clients_verify_name(const char *name)
{
  gboolean         res = FALSE;
  DBusMessage     *req = 0;
  DBusPendingCall *pc  = 0;
  gchar           *key = 0;

  if( !(req = cka_dbusutil_create_GetNameOwner_req(name)) )
  {
    goto EXIT;
  }

  if( !dbus_connection_send_with_reply(cka_dbus_systembus, req, &pc, -1) )
  {
    goto EXIT;
  }

  if( !pc )
  {
    goto EXIT;
  }

  mce_dbus_pending_call_blocks_suspend(pc);

  key = g_strdup(name);

  if( !dbus_pending_call_set_notify(pc, cka_clients_verify_name_cb,
                                    key, g_free) )
  {
    goto EXIT;
  }

  // key string is owned by pending call
  key = 0;

  // success
  res = TRUE;

EXIT:

  g_free(key);

  if( pc  ) dbus_pending_call_unref(pc);
  if( req ) dbus_message_unref(req);

  return res;
}
コード例 #4
0
/** Start async UPower device properties query
 */
static void xup_properties_get_all(const char *path)
{
    DBusConnection  *bus = 0;
    DBusMessage     *req = 0;
    DBusPendingCall *pc  = 0;
    const char      *arg = UPOWER_INTERFACE_DEVICE;

    if( !(bus = dbus_connection_get()) )
        goto EXIT;

    req = dbus_message_new_method_call(UPOWER_SERVICE,
                                       path,
                                       DBUS_INTERFACE_PROPERTIES,
                                       "GetAll");
    if( !req )
        goto EXIT;

    if( !dbus_message_append_args(req,
                                  DBUS_TYPE_STRING, &arg,
                                  DBUS_TYPE_INVALID) )
        goto EXIT;

    if( !dbus_connection_send_with_reply(bus, req, &pc, -1) )
        goto EXIT;

    if( !pc )
        goto EXIT;

    mce_dbus_pending_call_blocks_suspend(pc);

    if( !dbus_pending_call_set_notify(pc, xup_properties_get_all_cb,
                                      strdup(path), free) )
        goto EXIT;

EXIT:
    if( pc )  dbus_pending_call_unref(pc);
    if( req ) dbus_message_unref(req);
    if( bus ) dbus_connection_unref(bus);
}
コード例 #5
0
ファイル: radiostates.c プロジェクト: spiiroin/mce
/** Initiate asynchronous connman service name ownership query
 *
 * @return TRUE if the method call was initiated, or FALSE in case of errors
 */
static gboolean xconnman_check_service(void)
{
	gboolean         res  = FALSE;
	DBusMessage     *req  = 0;
	DBusPendingCall *pc   = 0;
	const char      *name = CONNMAN_SERVICE;

	if( !(req = dbus_message_new_method_call(DBUS_SERVICE_DBUS,
						 DBUS_PATH_DBUS,
						 DBUS_INTERFACE_DBUS,
						 "GetNameOwner")) )
		goto EXIT;

	if( !dbus_message_append_args(req,
				      DBUS_TYPE_STRING, &name,
				      DBUS_TYPE_INVALID) )
		goto EXIT;

	if( !dbus_connection_send_with_reply(connman_bus, req, &pc, -1) )
		goto EXIT;

	if( !pc )
		goto EXIT;

	mce_dbus_pending_call_blocks_suspend(pc);

	if( !dbus_pending_call_set_notify(pc, xconnman_check_service_cb, 0, 0) )
		goto EXIT;

	// success
	res = TRUE;

EXIT:
	if( pc )  dbus_pending_call_unref(pc);
	if( req ) dbus_message_unref(req);

	return res;
}