• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dbus_message_unref函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dbus_message_unref函数的典型用法代码示例。如果您正苦于以下问题:C++ dbus_message_unref函数的具体用法?C++ dbus_message_unref怎么用?C++ dbus_message_unref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dbus_message_unref函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: endpoint_reply

static void endpoint_reply(DBusPendingCall *call, void *user_data)
{
	struct endpoint_request *request = user_data;
	struct media_endpoint *endpoint = request->endpoint;
	DBusMessage *reply;
	DBusError err;
	gboolean value;
	void *ret = NULL;
	int size = -1;

	/* steal_reply will always return non-NULL since the callback
	 * is only called after a reply has been received */
	reply = dbus_pending_call_steal_reply(call);

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

		/* Clear endpoint configuration in case of NO_REPLY error */
		if (dbus_error_has_name(&err, DBUS_ERROR_NO_REPLY)) {
			if (request->cb)
				request->cb(endpoint, NULL, size,
							request->user_data);
			clear_endpoint(endpoint);
			dbus_message_unref(reply);
			dbus_error_free(&err);
			return;
		}

		dbus_error_free(&err);
		goto done;
	}

	if (dbus_message_is_method_call(request->msg, MEDIA_ENDPOINT_INTERFACE,
				"SelectConfiguration")) {
		DBusMessageIter args, array;
		uint8_t *configuration;

		dbus_message_iter_init(reply, &args);

		dbus_message_iter_recurse(&args, &array);

		dbus_message_iter_get_fixed_array(&array, &configuration, &size);

		ret = configuration;
		goto done;
	} else  if (!dbus_message_get_args(reply, &err, DBUS_TYPE_INVALID)) {
		error("Wrong reply signature: %s", err.message);
		dbus_error_free(&err);
		goto done;
	}

	size = 1;
	value = TRUE;
	ret = &value;

done:
	dbus_message_unref(reply);

	if (request->cb)
		request->cb(endpoint, ret, size, request->user_data);

	endpoint->requests = g_slist_remove(endpoint->requests, request);
	endpoint_request_free(request);
}
开发者ID:adityakamath,项目名称:ArduHack,代码行数:66,代码来源:media.c


示例2: GetDefaultAdapterPathInternal

nsresult
GetDefaultAdapterPathInternal(nsCString& aAdapterPath)
{
  DBusMessage *msg = NULL, *reply = NULL;
  DBusError err;
  const char *device_path = NULL;
  int attempt = 0;

  for (attempt = 0; attempt < 1000 && reply == NULL; attempt ++) {
    msg = dbus_message_new_method_call("org.bluez", "/",
                                       "org.bluez.Manager", "DefaultAdapter");
    if (!msg) {
      LOG("%s: Can't allocate new method call for get_adapter_path!",
             __FUNCTION__);
      return NS_ERROR_FAILURE;
    }
    dbus_message_append_args(msg, DBUS_TYPE_INVALID);
    dbus_error_init(&err);
    reply = dbus_connection_send_with_reply_and_block(
      sDBusConnection->mConnection, msg, -1, &err);

    if (!reply) {
      if (dbus_error_is_set(&err)) {
        if (dbus_error_has_name(&err,
                                "org.freedesktop.DBus.Error.ServiceUnknown")) {
          // bluetoothd is still down, retry
          LOG("Service unknown\n");
          dbus_error_free(&err);
          //usleep(10000); // 10 ms
          continue;
        } else if (dbus_error_has_name(&err,
                                       "org.bluez.Error.NoSuchAdapter")) {
          LOG("No adapter found\n");
          dbus_error_free(&err);
          goto failed;
        } else {
          // Some other error we weren't expecting
          LOG("other error\n");
          dbus_error_free(&err);
        }
      }
    }
  }
  if (attempt == 1000) {
    LOG("timeout\n");
    //printfE("Time out while trying to get Adapter path, is bluetoothd up ?");
    goto failed;
  }

  if (!dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH,
                             &device_path, DBUS_TYPE_INVALID)
      || !device_path) {
    if (dbus_error_is_set(&err)) {
      dbus_error_free(&err);
    }
    goto failed;
  }
  dbus_message_unref(msg);
  aAdapterPath = nsDependentCString(device_path);
  return NS_OK;
failed:
  dbus_message_unref(msg);
  return NS_ERROR_FAILURE;
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:64,代码来源:BluetoothDBusUtils.cpp


示例3: HFPMsgCallBack

unsigned long HFPMsgCallBack(HFPEVENT event, void* lpParam, unsigned long param)
{
    printf("HFPMsgCallBack:%d\n",event);

    switch (event)
    {
    case RING_EVENT:
    {
        return 1;
    }
    break;
	case SMS_SUCCESS:
	{
		printf("send sms success\n");
		system("dbus-send / com.asianux.sms.succesd ");
		system("dbus-send / com.asianux.fom.succesd ");
	}
	break;
	case SMS_FAILED:
	{
		system("dbus-send / com.asianux.sms.failed ");
		system("dbus-send / com.asianux.fom.failed ");
		printf("sms sms filed\n");
	}
	break;
    case PHONESTATUS_EVENT:
    {
        PHONESTATUS status = (PHONESTATUS)param;
        switch (status)
        {
        case CALLINCOMING:
        {
			printf("-----call  in  -----\n");

            return 0;
        }
        break;
        case CALLOUTGOING:
		{
			printf("-----call  out -----\n");
			
            usleep(1200);
			
			send_panel_message();
			
//			app_agent_set_play(appAgent);

			is_calling = TRUE;

        }
        break;
        case CALLACTIVE:
        {
			printf("-----call active-----\n");
            DBusMessage *message;
            dbus_uint32_t serial = 0;

            message = dbus_message_new_signal("/","com.asianux.notification","begin");
            if (!dbus_connection_send(dbus_conn,message,&serial))
            {
                exit(1);
            }

            dbus_connection_flush(dbus_conn);
            dbus_message_unref(message);

//			app_agent_set_play(appAgent);

            send_panel_message();

            is_calling = TRUE;

        }
        break;
        case CALLINACTIVE:
        {
			printf("-----call end-----\n");

			if(is_calling == TRUE)
			{
				printf("-----end---\n\n");
	            DBusMessage *msg;
		        dbus_uint32_t serial_1 = 0;
			    msg = dbus_message_new_signal("/","com.asianux.notification","end");

				if (!dbus_connection_send(dbus_conn,msg,&serial_1))
				{
					printf("-----send end notification failed-----\n");
					exit(1);
				}

	            dbus_connection_flush(dbus_conn);
		        dbus_message_unref(msg);
			}
		    else
			{
				printf("----hook----\n\n");
				DBusMessage *msg2;
				dbus_uint32_t serial_2 =0;
				msg2 = dbus_message_new_signal("/","com.asianux.notification","hook");
//.........这里部分代码省略.........
开发者ID:B1gSmoke,项目名称:autotools,代码行数:101,代码来源:main.cpp


示例4: kwallet_create_folder

static int
kwallet_create_folder( vlc_keystore* p_keystore, const char* psz_folder_name )
{
    vlc_keystore_sys* p_sys = p_keystore->p_sys;
    DBusMessage* msg = NULL;
    DBusMessage* repmsg = NULL;
    DBusError error;
    DBusMessageIter args;
    dbus_bool_t b_reply;
    int i_ret = VLC_EGENERIC;

    /* init */
    msg = vlc_dbus_new_method( p_keystore, "createFolder" );
    if ( !msg )
    {
        msg_Err( p_keystore, "kwallet_create_folder : vlc_dbus_new_method failed" );
        return VLC_EGENERIC;
    }

    /* argument init */
    dbus_message_iter_init_append( msg, &args );
    if ( !dbus_message_iter_append_basic( &args, DBUS_TYPE_INT32, &p_sys->i_handle ) ||
         !dbus_message_iter_append_basic( &args, DBUS_TYPE_STRING, &psz_folder_name ) ||
         !dbus_message_iter_append_basic( &args, DBUS_TYPE_STRING, &p_sys->psz_app_id ) )
        goto end;

    /* sending message */
    repmsg = vlc_dbus_send_message( p_keystore, msg );
    if ( !repmsg )
    {
        msg_Err( p_keystore, "kwallet_create_folder : vlc_dbus_send_message failed" );
        goto end;
    }

    /* handling reply */
    dbus_error_init( &error );
    if ( !dbus_message_get_args( repmsg, &error, DBUS_TYPE_BOOLEAN,
                                 &b_reply, DBUS_TYPE_INVALID ) )
    {
        msg_Err( p_keystore, "kwallet_create_folder :"
                 " dbus_message_get_args failed\n%s", error.message );
        dbus_error_free( &error );
        goto end;
    }

    if ( !b_reply )
    {
        msg_Err( p_keystore, "kwallet_create_folder : Could not create folder" );
        goto end;
    }


    i_ret = VLC_SUCCESS;

end:

    if ( msg )
        dbus_message_unref( msg );
    if ( repmsg )
        dbus_message_unref( repmsg );

    return i_ret;
}
开发者ID:chouquette,项目名称:vlc,代码行数:63,代码来源:kwallet.c


示例5: kwallet_remove_entry

static int
kwallet_remove_entry( vlc_keystore* p_keystore, char* psz_entry_name )
{
    vlc_keystore_sys* p_sys = p_keystore->p_sys;
    DBusMessage* msg = NULL;
    DBusMessage* repmsg = NULL;
    DBusError error;
    DBusMessageIter args;
    int i_reply;
    bool b_has_entry = false;
    int i_ret = VLC_EGENERIC;

    if ( kwallet_has_entry( p_keystore, psz_entry_name, &b_has_entry ) )
    {
        msg_Err( p_keystore, "kwallet_remove_entry : kwallet_has_entry failed" );
        return VLC_EGENERIC;
    }
    if ( !b_has_entry )
    {
        msg_Err( p_keystore, "kwallet_remove_entry : there is no such entry :"
                "%s", psz_entry_name );
        return VLC_EGENERIC;
    }

    /* init */
    if ( !( msg = vlc_dbus_new_method( p_keystore, "removeEntry" ) ) )
    {
        msg_Err( p_keystore, "kwallet_remove_entry : vlc_dbus_new_method failed" );
        return VLC_EGENERIC;
    }

    /* argument init */
    dbus_message_iter_init_append( msg, &args );
    if ( !dbus_message_iter_append_basic( &args, DBUS_TYPE_INT32, &p_sys->i_handle ) ||
         !dbus_message_iter_append_basic( &args, DBUS_TYPE_STRING, &psz_folder ) ||
         !dbus_message_iter_append_basic( &args, DBUS_TYPE_STRING, &psz_entry_name ) ||
         !dbus_message_iter_append_basic( &args, DBUS_TYPE_STRING, &p_sys->psz_app_id ) )
        goto end;

    /* sending message */
    if ( !( repmsg = vlc_dbus_send_message( p_keystore, msg ) ) )
    {
        msg_Err( p_keystore, "kwallet_remove_entry : vlc_dbus_send_message failed" );
        goto end;
    }

    /* handling reply */
    dbus_error_init( &error );
    if ( !dbus_message_get_args( repmsg, &error, DBUS_TYPE_INT32,
                                 &i_reply, DBUS_TYPE_INVALID ) )
    {
        msg_Err( p_keystore, "kwallet_remove entry :"
                 " dbus_message_get_args failed\n%s", error.message );
        dbus_error_free( &error );
        goto end;
    }

    i_ret = VLC_SUCCESS;

end:

    if ( msg )
        dbus_message_unref( msg );
    if ( repmsg )
        dbus_message_unref( repmsg );

    return i_ret;
}
开发者ID:chouquette,项目名称:vlc,代码行数:68,代码来源:kwallet.c


示例6: unmount_childs

static void 
unmount_childs (LibHalContext *ctx, const char *udi)
{
	int num_volumes;
	char **volumes;
	DBusError error;

	/* need to force unmount all partitions */
	dbus_error_init (&error);
	if ((volumes = libhal_manager_find_device_string_match (ctx, "block.storage_device", udi, &num_volumes, &error)) != NULL) {
		int i;

		for (i = 0; i < num_volumes; i++) {
			char *vol_udi;

			vol_udi = volumes[i];
			LIBHAL_FREE_DBUS_ERROR (&error);

			if (libhal_device_get_property_bool (ctx, vol_udi, "block.is_volume", &error)) {
				dbus_bool_t is_crypto;

				/* unmount all cleartext devices associated with us */
				is_crypto = unmount_cleartext_devices (ctx, vol_udi);

				LIBHAL_FREE_DBUS_ERROR (&error);
				if (libhal_device_get_property_bool (ctx, vol_udi, "volume.is_mounted", &error)) {
					HAL_DEBUG (("Forcing unmount of child '%s'", vol_udi));
					force_unmount (ctx, vol_udi);
				}

				/* teardown crypto */
				if (is_crypto) {
					DBusMessage *msg = NULL;
					DBusMessage *reply = NULL;

					/* tear down mapping */
					HAL_DEBUG (("Teardown crypto for '%s'", vol_udi));

					msg = dbus_message_new_method_call ("org.freedesktop.Hal", vol_udi,
									    "org.freedesktop.Hal.Device.Volume.Crypto",
									    "Teardown");
					if (msg == NULL) {
						HAL_ERROR (("Could not create dbus message for %s", vol_udi));
						goto teardown_failed;
					}

					LIBHAL_FREE_DBUS_ERROR (&error);

					if (!(reply = dbus_connection_send_with_reply_and_block (
						      libhal_ctx_get_dbus_connection (ctx), msg, -1, &error)) || 
					    dbus_error_is_set (&error)) {
						HAL_DEBUG (("Teardown failed for %s: %s : %s\n", udi, error.name, error.message));
						dbus_error_free (&error);
					}

				teardown_failed:
					if (msg != NULL)
						dbus_message_unref (msg);
					if (reply != NULL)
						dbus_message_unref (reply);
				}

			}

		}
		libhal_free_string_array (volumes);
	}
	LIBHAL_FREE_DBUS_ERROR (&error);
}
开发者ID:bbidulock,项目名称:hal,代码行数:69,代码来源:addon-storage.c


示例7: test_session_connect_free_ride_notify

static void test_session_connect_free_ride_notify(struct test_session *session)
{
	struct test_session *session0 = get_session(session, 0);
	struct test_session *session1 = get_session(session, 1);
	enum test_session_state state = get_session_state(session);
	enum test_session_state next_state = state;
	DBusMessage *msg;

	LOG("state %d session %p %s online %d", state, session,
		session->notify_path, session->info->online);

	switch (state) {
	case TEST_SESSION_STATE_0:
		if (session0->info->online == FALSE &&
				session1->info->online == FALSE) {
			next_state = TEST_SESSION_STATE_1;
		}

		break;
	case TEST_SESSION_STATE_1:
		if (session0->info->online == TRUE &&
				session1->info->online == TRUE) {
			next_state = TEST_SESSION_STATE_2;
		}

		break;
	case TEST_SESSION_STATE_2:
		if (session0->info->online == FALSE &&
				session1->info->online == FALSE) {
			next_state = TEST_SESSION_STATE_3;
		}

		break;
	case TEST_SESSION_STATE_3:

		return;
	}

	if (state == next_state)
		return;

	set_session_state(session, next_state);

	LOG("next_state %d", next_state);

	switch (next_state) {
	case TEST_SESSION_STATE_0:

		return;
	case TEST_SESSION_STATE_1:
		msg = session_connect(session0->connection, session0);
		g_assert(msg != NULL);
		dbus_message_unref(msg);

		return;

	case TEST_SESSION_STATE_2:
		msg = session_disconnect(session0->connection, session0);
		g_assert(msg != NULL);
		dbus_message_unref(msg);

		return;
	case TEST_SESSION_STATE_3:
		util_session_cleanup(session0);
		util_session_cleanup(session1);

		util_idle_call(session0->fix, util_quit_loop,
				util_session_destroy);

		return;
	}
}
开发者ID:aldebaran,项目名称:connman-stable,代码行数:72,代码来源:test-session.c


示例8: dp_id_callback

void dp_id_callback(DBusPendingCall *pending, void *ptr)
{
    DBusMessage *reply;
    DBusError dbus_error;
    dbus_bool_t ret;
    dbus_uint16_t dp_ver;
    int type;

    dbus_error_init(&dbus_error);

    reply = dbus_pending_call_steal_reply(pending);
    if (!reply) {
        /* reply should never be null. This function shouldn't be called
         * until reply is valid or timeout has occurred. If reply is NULL
         * here, something is seriously wrong and we should bail out.
         */
        DEBUG(SSSDBG_FATAL_FAILURE,
              "Severe error. A reply callback was called but no"
                  " reply was received and no timeout occurred\n");

        /* FIXME: Destroy this connection ? */
        goto done;
    }

    type = dbus_message_get_type(reply);
    switch (type) {
    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
        ret = dbus_message_get_args(reply, &dbus_error,
                                    DBUS_TYPE_UINT16, &dp_ver,
                                    DBUS_TYPE_INVALID);
        if (!ret) {
            DEBUG(SSSDBG_CRIT_FAILURE, "Failed to parse message\n");
            if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
            /* FIXME: Destroy this connection ? */
            goto done;
        }

        DEBUG(SSSDBG_CONF_SETTINGS,
              "Got id ack and version (%d) from DP\n", dp_ver);

        break;

    case DBUS_MESSAGE_TYPE_ERROR:
        DEBUG(SSSDBG_FATAL_FAILURE,"The Monitor returned an error [%s]\n",
                 dbus_message_get_error_name(reply));
        /* Falling through to default intentionally*/
    default:
        /*
         * Timeout or other error occurred or something
         * unexpected happened.
         * It doesn't matter which, because either way we
         * know that this connection isn't trustworthy.
         * We'll destroy it now.
         */

        /* FIXME: Destroy this connection ? */
        break;
    }

done:
    dbus_pending_call_unref(pending);
    dbus_message_unref(reply);
}
开发者ID:3van,项目名称:sssd,代码行数:63,代码来源:dp_auth_util.c


示例9: notify


//.........这里部分代码省略.........
        char *hint_name;

        int i;
        int id;
        const char *appname = NULL;
        const char *summary = NULL;
        const char *body = NULL;
        const char *icon = NULL;
        const char *fgcolor = NULL;
        const char *bgcolor = NULL;
        int urgency = 1;
        int progress = -1;
        notification *n = malloc(sizeof(notification));
        dbus_uint32_t replaces_id = 0;
        dbus_int32_t expires = -1;

        dbus_serial++;
        dbus_message_iter_init(dmsg, &args);

        _extract_basic(DBUS_TYPE_STRING, &args, &appname);

        dbus_message_iter_next(&args);
        _extract_basic(DBUS_TYPE_UINT32, &args, &replaces_id);

        dbus_message_iter_next(&args);
        _extract_basic(DBUS_TYPE_STRING, &args, &icon);

        dbus_message_iter_next(&args);
        _extract_basic(DBUS_TYPE_STRING, &args, &summary);

        dbus_message_iter_next(&args);
        _extract_basic(DBUS_TYPE_STRING, &args, &body);

        dbus_message_iter_next(&args);
        dbus_message_iter_next(&args);

        dbus_message_iter_recurse(&args, &hints);
        dbus_message_iter_next(&args);

        _extract_basic(DBUS_TYPE_INT32, &args, &expires);

        while (dbus_message_iter_get_arg_type(&hints) != DBUS_TYPE_INVALID) {
                dbus_message_iter_recurse(&hints, &hint);
                while (dbus_message_iter_get_arg_type(&hint) !=
                       DBUS_TYPE_INVALID) {
                        if (dbus_message_iter_get_arg_type(&hint) !=
                            DBUS_TYPE_STRING) {
                                dbus_message_iter_next(&hint);
                                continue;
                        }
                        dbus_message_iter_get_basic(&hint, &hint_name);
                        _extract_hint(DBUS_TYPE_BYTE, "urgency", hint_name,
                                      &hint, &urgency);
                        _extract_hint(DBUS_TYPE_STRING, "fgcolor", hint_name,
                                      &hint, &fgcolor);
                        _extract_hint(DBUS_TYPE_STRING, "bgcolor", hint_name,
                                      &hint, &bgcolor);
                        _extract_hint(DBUS_TYPE_INT32, "value", hint_name,
                                      &hint, &progress);
                        if (!progress)
                                _extract_hint(DBUS_TYPE_UINT32, "value",
                                              hint_name, &hint, &progress);
                        dbus_message_iter_next(&hint);
                }
                dbus_message_iter_next(&hints);
        }

        if (expires > 0) {
                /* do some rounding */
                expires = (expires + 500) / 1000;
                if (expires < 1) {
                        expires = 1;
                }
        }
        n->appname = appname != NULL ? strdup(appname) : "";
        n->summary = summary != NULL ? strdup(summary) : "";
        n->body = body != NULL ? strdup(body) : "";
        n->icon = icon != NULL ? strdup(icon) : "";
        n->timeout = expires;
        n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1;
        n->urgency = urgency;
        n->dbus_client = strdup(dbus_message_get_sender(dmsg));
        for (i = 0; i < ColLast; i++) {
                n->color_strings[i] = NULL;
        }
        n->color_strings[ColFG] = fgcolor == NULL ? NULL : strdup(fgcolor);
        n->color_strings[ColBG] = bgcolor == NULL ? NULL : strdup(bgcolor);

        id = init_notification(n, replaces_id);
        if (id > 0)
                map_win();

        reply = dbus_message_new_method_return(dmsg);

        dbus_message_iter_init_append(reply, &args);
        dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32, &id);
        dbus_connection_send(dbus_conn, reply, &dbus_serial);

        dbus_message_unref(reply);
}
开发者ID:losciamano,项目名称:dunst,代码行数:101,代码来源:dunst_dbus.c


示例10: wpa_supplicant_dbus_notify_state_change

/**
 * wpa_supplicant_dbus_notify_state_change - Send a state change signal
 * @wpa_s: %wpa_supplicant network interface data
 * @new_state: new state wpa_supplicant is entering
 * @old_state: old state wpa_supplicant is leaving
 * Returns: 0 on success, -1 on failure
 *
 * Notify listeners that wpa_supplicant has changed state
 */
void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
					     wpa_states new_state,
					     wpa_states old_state)
{
	struct ctrl_iface_dbus_priv *iface;
	DBusMessage *signal = NULL;
	const char *path;
	const char *new_state_str, *old_state_str;

	/* Do nothing if the control interface is not turned on */
	if (wpa_s->global == NULL)
		return;
	iface = wpa_s->global->dbus_ctrl_iface;
	if (iface == NULL)
		return;

	/* Only send signal if state really changed */
	if (new_state == old_state)
		return;

	path = wpa_supplicant_get_dbus_path(wpa_s);
	if (path == NULL) {
		perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
		       "interface didn't have a dbus path");
		wpa_printf(MSG_ERROR,
		           "wpa_supplicant_dbus_notify_state_change[dbus]: "
		           "interface didn't have a dbus path; can't send "
		           "signal.");
		return;
	}
	signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE,
					 "StateChange");
	if (signal == NULL) {
		perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
		       "couldn't create dbus signal; likely out of memory");
		wpa_printf(MSG_ERROR,
		           "wpa_supplicant_dbus_notify_state_change[dbus]: "
		           "couldn't create dbus signal; likely out of "
		           "memory.");
		return;
	}

	new_state_str = wpa_supplicant_state_txt(new_state);
	old_state_str = wpa_supplicant_state_txt(old_state);
	if (new_state_str == NULL || old_state_str == NULL) {
		perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
		       "couldn't convert state strings");
		wpa_printf(MSG_ERROR,
		           "wpa_supplicant_dbus_notify_state_change[dbus]: "
		           "couldn't convert state strings.");
		goto out;
	}

	if (!dbus_message_append_args(signal,
	                              DBUS_TYPE_STRING, &new_state_str,
	                              DBUS_TYPE_STRING, &old_state_str,
	                              DBUS_TYPE_INVALID)) {
		perror("wpa_supplicant_dbus_notify_state_change[dbus]: "
		       "not enough memory to construct state change signal.");
		wpa_printf(MSG_ERROR,
		           "wpa_supplicant_dbus_notify_state_change[dbus]: "
		           "not enough memory to construct state change "
		           "signal.");
		goto out;
	}
	dbus_connection_send(iface->con, signal, NULL);

out:
	dbus_message_unref(signal);
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:79,代码来源:ctrl_iface_dbus.c


示例11: main


//.........这里部分代码省略.........
      attr = ippFindAttribute(msg, "notify-job-id", IPP_TAG_INTEGER);
      if (attr)
      {
        dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0);
        dbus_message_iter_append_uint32(&iter, &val);
      }
      else
	goto bail;

      /* UINT32 job-state */
      attr = ippFindAttribute(msg, "job-state", IPP_TAG_ENUM);
      if (attr)
      {
        dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0);
        dbus_message_iter_append_uint32(&iter, &val);
      }
      else
	goto bail;

      /* STRING job-state-reasons */
      attr = ippFindAttribute(msg, "job-state-reasons", IPP_TAG_KEYWORD);
      if (attr)
      {
	int num_values = ippGetCount(attr);
	for (reasons_length = 0, i = 0; i < num_values; i++)
	  /* All need commas except the last, which needs a nul byte. */
	  reasons_length += 1 + strlen(ippGetString(attr, i, NULL));
	job_reasons = malloc(reasons_length);
	if (!job_reasons)
	  goto bail;
	p = job_reasons;
	for (i = 0; i < num_values; i++)
	{
	  if (i)
	    *p++ = ',';

	  strlcpy(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - job_reasons));
	  p += strlen(p);
	}
	if (!dbus_message_iter_append_string(&iter, &job_reasons))
	  goto bail;
      }
      else
	goto bail;

      /* STRING job-name or "" */
      attr = ippFindAttribute(msg, "job-name", IPP_TAG_NAME);
      if (attr)
      {
        const char *val = ippGetString(attr, 0, NULL);
        if (!dbus_message_iter_append_string(&iter, &val))
          goto bail;
      }
      else
	dbus_message_iter_append_string(&iter, &nul);

      /* UINT32 job-impressions-completed */
      attr = ippFindAttribute(msg, "job-impressions-completed",
			      IPP_TAG_INTEGER);
      if (attr)
      {
        dbus_uint32_t val = (dbus_uint32_t)ippGetInteger(attr, 0);
        dbus_message_iter_append_uint32(&iter, &val);
      }
      else
	goto bail;
    }

    dbus_connection_send(con, message, NULL);
    dbus_connection_flush(con);

   /*
    * Cleanup...
    */

    bail:

    dbus_message_unref(message);

    if (printer_reasons)
      free(printer_reasons);

    if (job_reasons)
      free(job_reasons);

    ippDelete(msg);
  }

 /*
  * Remove lock file...
  */

  if (lock_fd >= 0)
  {
    close(lock_fd);
    release_lock();
  }

  return (0);
}
开发者ID:jschwender,项目名称:cups,代码行数:101,代码来源:dbus.c


示例12: wpas_iface_message_handler

/**
 * wpas_iface_message_handler - Dispatch messages for interfaces or networks
 * @connection: Connection to the system message bus
 * @message: An incoming dbus message
 * @user_data: A pointer to a dbus control interface data structure
 * Returns: Whether or not the message was handled
 *
 * This function dispatches all incoming dbus messages for network interfaces,
 * or objects owned by them, such as scanned BSSIDs and configured networks.
 */
static DBusHandlerResult wpas_iface_message_handler(DBusConnection *connection,
						    DBusMessage *message,
						    void *user_data)
{
	struct wpa_supplicant *wpa_s = user_data;
	const char *method = dbus_message_get_member(message);
	const char *path = dbus_message_get_path(message);
	const char *msg_interface = dbus_message_get_interface(message);
	char *iface_obj_path = NULL;
	char *network = NULL;
	char *bssid = NULL;
	DBusMessage *reply = NULL;

	/* Caller must specify a message interface */
	if (!msg_interface)
		goto out;

	iface_obj_path = wpas_dbus_decompose_object_path(path, &network,
	                                                 &bssid);
	if (iface_obj_path == NULL) {
		reply = wpas_dbus_new_invalid_iface_error(message);
		goto out;
	}

	/* Make sure the message's object path actually refers to the
	 * wpa_supplicant structure it's supposed to (which is wpa_s)
	 */
	if (wpa_supplicant_get_iface_by_dbus_path(wpa_s->global,
	                                          iface_obj_path) != wpa_s) {
		reply = wpas_dbus_new_invalid_iface_error(message);
		goto out;
	}

	if (network && !strcmp(msg_interface, WPAS_DBUS_IFACE_NETWORK)) {
		/* A method for one of this interface's configured networks */
		int nid = strtoul(network, NULL, 10);
		if (errno != EINVAL)
			reply = wpas_dispatch_network_method(message, wpa_s,
							     nid);
		else
			reply = wpas_dbus_new_invalid_network_error(message);
	} else if (bssid && !strcmp(msg_interface, WPAS_DBUS_IFACE_BSSID)) {
		/* A method for one of this interface's scanned BSSIDs */
		reply = wpas_dispatch_bssid_method(message, wpa_s, bssid);
	} else if (!strcmp(msg_interface, WPAS_DBUS_IFACE_INTERFACE)) {
		/* A method for an interface only. */
		if (!strcmp(method, "scan"))
			reply = wpas_dbus_iface_scan(message, wpa_s);
		else if (!strcmp(method, "scanResults"))
			reply = wpas_dbus_iface_scan_results(message, wpa_s);
		else if (!strcmp(method, "addNetwork"))
			reply = wpas_dbus_iface_add_network(message, wpa_s);
		else if (!strcmp(method, "removeNetwork"))
			reply = wpas_dbus_iface_remove_network(message, wpa_s);
		else if (!strcmp(method, "selectNetwork"))
			reply = wpas_dbus_iface_select_network(message, wpa_s);
		else if (!strcmp(method, "capabilities"))
			reply = wpas_dbus_iface_capabilities(message, wpa_s);
		else if (!strcmp(method, "disconnect"))
			reply = wpas_dbus_iface_disconnect(message, wpa_s);
		else if (!strcmp(method, "setAPScan"))
			reply = wpas_dbus_iface_set_ap_scan(message, wpa_s);
		else if (!strcmp(method, "state"))
			reply = wpas_dbus_iface_get_state(message, wpa_s);
		else if (!strcmp(method, "setBlobs"))
			reply = wpas_dbus_iface_set_blobs(message, wpa_s);
		else if (!strcmp(method, "removeBlobs"))
			reply = wpas_dbus_iface_remove_blobs(message, wpa_s);
	}

	/* If the message was handled, send back the reply */
	if (reply) {
		dbus_connection_send(connection, reply, NULL);
		dbus_message_unref(reply);
	}

out:
	free(iface_obj_path);
	free(network);
	free(bssid);
	return reply ? DBUS_HANDLER_RESULT_HANDLED :
		DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:93,代码来源:ctrl_iface_dbus.c


示例13: main

int
main (int argc, char *argv[])
{
  DBusMessage *method;
  DBusConnection *conn;
  DBusError error;
  DBusMutex *mutex1, *dispatch_mutex1, *io_path_mutex1;
  DBusCondVar *dispatch_cond1, *io_path_cond1;
  DBusMutex *mutex2, *dispatch_mutex2, *io_path_mutex2;
  DBusCondVar *dispatch_cond2, *io_path_cond2;

  printf ("*** Testing late thread init\n");

  dbus_error_init (&error);

  conn = dbus_bus_get (DBUS_BUS_SESSION, &error);

  _dbus_connection_test_get_locks (conn, &mutex1, 
                                         &dispatch_mutex1, 
                                         &io_path_mutex1,
                                         &dispatch_cond1,
                                         &io_path_cond1);
  _run_iteration (conn);
  _dbus_connection_test_get_locks (conn, &mutex2,
                                         &dispatch_mutex2,
                                         &io_path_mutex2,
                                         &dispatch_cond2,
                                         &io_path_cond2);

  check_mutex_lock (mutex1, mutex2, TRUE);
  check_mutex_lock (dispatch_mutex1, dispatch_mutex2, TRUE);
  check_mutex_lock (io_path_mutex1, io_path_mutex2, TRUE);
  check_condvar_lock (dispatch_cond1, dispatch_cond2, TRUE);
  check_condvar_lock (io_path_cond1, io_path_cond2, TRUE);

  dbus_threads_init_default ();

  _dbus_connection_test_get_locks (conn, &mutex1,
                                         &dispatch_mutex1,
                                         &io_path_mutex1,
                                         &dispatch_cond1,
                                         &io_path_cond1);

  _run_iteration (conn);
  _dbus_connection_test_get_locks (conn, &mutex2,
                                         &dispatch_mutex2,
                                         &io_path_mutex2,
                                         &dispatch_cond2,
                                         &io_path_cond2);

  check_mutex_lock (mutex1, mutex2, TRUE);
  check_mutex_lock (dispatch_mutex1, dispatch_mutex2, TRUE);
  check_mutex_lock (io_path_mutex1, io_path_mutex2, TRUE);
  check_condvar_lock (dispatch_cond1, dispatch_cond2, TRUE);
  check_condvar_lock (io_path_cond1, io_path_cond2, TRUE);

  method = dbus_message_new_method_call ("org.freedesktop.TestSuiteEchoService",
                                         "/org/freedesktop/TestSuite",
                                         "org.freedesktop.TestSuite",
                                         "Exit");
  dbus_connection_send (conn, method, NULL);
  dbus_message_unref (method);

  printf ("Success ***\n");
  exit (0);
}
开发者ID:13824125580,项目名称:hello-world,代码行数:66,代码来源:test-threads-init.c


示例14: modem_unregister

static void modem_unregister(struct ofono_modem *modem)
{
	DBusConnection *conn = ofono_dbus_get_connection();

	DBG("%p", modem);

	if (modem->powered == TRUE)
		set_powered(modem, FALSE);

	__ofono_watchlist_free(modem->atom_watches);
	modem->atom_watches = NULL;

	__ofono_watchlist_free(modem->online_watches);
	modem->online_watches = NULL;

	__ofono_watchlist_free(modem->powered_watches);
	modem->powered_watches = NULL;

	modem->sim_watch = 0;
	modem->sim_ready_watch = 0;

	g_slist_foreach(modem->interface_list, (GFunc) g_free, NULL);
	g_slist_free(modem->interface_list);
	modem->interface_list = NULL;

	g_slist_foreach(modem->feature_list, (GFunc) g_free, NULL);
	g_slist_free(modem->feature_list);
	modem->feature_list = NULL;

	if (modem->timeout) {
		g_source_remove(modem->timeout);
		modem->timeout = 0;
	}

	if (modem->pending) {
		dbus_message_unref(modem->pending);
		modem->pending = NULL;
	}

	if (modem->interface_update) {
		g_source_remove(modem->interface_update);
		modem->interface_update = 0;
	}

	if (modem->lock_watch) {
		lockdown_remove(modem);

		ofono_dbus_signal_property_changed(conn, modem->path,
					OFONO_MODEM_INTERFACE,
					"Lockdown", DBUS_TYPE_BOOLEAN,
					&modem->lockdown);
	}

	g_dbus_unregister_interface(conn, modem->path, OFONO_MODEM_INTERFACE);

	if (modem->driver && modem->driver->remove)
		modem->driver->remove(modem);

	g_hash_table_destroy(modem->properties);
	modem->properties = NULL;

	modem->driver = NULL;

	emit_modem_removed(modem);
	call_modemwatches(modem, FALSE);
}
开发者ID:jkangas,项目名称:ofono-1,代码行数:66,代码来源:modem.c


示例15: g_assert


//.........这里部分代码省略.........
				  DBUS_TYPE_UINT64, &endpoint,
				  DBUS_TYPE_STRING, &chatId,
				  DBUS_TYPE_STRING, &userId,
				  DBUS_TYPE_INVALID)) {
            if (listener_)
                listener_->onUserLeave(endpoint, chatId, userId);
	} else {
	    reply = dbus_message_new_error(message,
					   DBUS_ERROR_INVALID_ARGS,
					   _("Expected userLeave(uint64 endpoint, string chatId, string userId)"));
	}

    } else if (strcmp(member, "Message") == 0) {
	dbus_uint64_t endpoint;
	const char *chatId;
	const char *userId;
	const char *text;
        dbus_int32_t sentiment;
	double timestamp;
	int serial;

	if (dbus_message_get_args(message, NULL,
				  DBUS_TYPE_UINT64, &endpoint,
				  DBUS_TYPE_STRING, &chatId,
				  DBUS_TYPE_STRING, &userId,
				  DBUS_TYPE_STRING, &text,
				  DBUS_TYPE_INT32,  &sentiment,
				  DBUS_TYPE_DOUBLE, &timestamp,
				  DBUS_TYPE_INT32, &serial,
				  DBUS_TYPE_INVALID)) {
	    if (listener_)
		listener_->onMessage(endpoint, chatId, userId, text, sentiment, timestamp, serial);
	} else {
	    reply = dbus_message_new_error(message,
					  DBUS_ERROR_INVALID_ARGS,
					  _("Expected Messsage(uint64 endpoint, string chatId, string userId, string text, int32 sentiment, double timestamp, int32 serial)"));
	}

    } else if (strcmp(member, "UserInfo") == 0) {
	dbus_uint64_t endpoint;
	const char *userId;
	const char *name;
	const char *smallPhotoUrl;
	const char *currentSong;
	const char *currentArtist;
	dbus_bool_t musicPlaying;
	
	if (dbus_message_get_args(message, NULL,
				  DBUS_TYPE_UINT64, &endpoint,
				  DBUS_TYPE_STRING, &userId,
				  DBUS_TYPE_STRING, &name,
				  DBUS_TYPE_STRING, &smallPhotoUrl,
				  DBUS_TYPE_STRING, &currentSong,
				  DBUS_TYPE_STRING, &currentArtist,
				  DBUS_TYPE_BOOLEAN, &musicPlaying,
				  DBUS_TYPE_INVALID)) {
	    if (listener_)
		listener_->userInfo(endpoint, userId, name, smallPhotoUrl,
				    currentSong, currentArtist, musicPlaying);
	} else {
	    reply = dbus_message_new_error(message,
					   DBUS_ERROR_INVALID_ARGS,
					   _("Expected UserInfo(uint64 endpoint, string userId, string name, string smallPhotoUrl, string currentSong, boolean musicPlaying)"));
	}

    } else if (strcmp(member, "ApplicationInfo") == 0) {
	dbus_uint64_t endpoint;
	const char *applicationId;
	dbus_bool_t canInstall;
	dbus_bool_t canRun;
	const char *version;
	
	if (dbus_message_get_args(message, NULL,
				  DBUS_TYPE_UINT64, &endpoint,
				  DBUS_TYPE_STRING, &applicationId,
				  DBUS_TYPE_BOOLEAN, &canInstall,
				  DBUS_TYPE_BOOLEAN, &canRun,
				  DBUS_TYPE_STRING, &version,
				  DBUS_TYPE_INVALID)) {
	    if (listener_)
		listener_->applicationInfo(endpoint, applicationId, canInstall, canRun, version);
	} else {
	    reply = dbus_message_new_error(message,
					   DBUS_ERROR_INVALID_ARGS,
					   _("Expected ApplicationInfo(uint64 endpoint, string applicationId, boolean canInstall, boolean canRun, string version)"));
	}

    } else {
	reply = dbus_message_new_error(message,
				       DBUS_ERROR_UNKNOWN_METHOD,
				       _("Unknown callback method"));
    }

    if (reply) {
        dbus_connection_send(connection_, reply, NULL);
        dbus_message_unref(reply);
    }

    return DBUS_HANDLER_RESULT_HANDLED;
}
开发者ID:nihed,项目名称:magnetism,代码行数:101,代码来源:hippo-dbus-ipc-provider.cpp


示例16: push_data

static void push_data(DBusConnection *bus) {
        char **l_set = NULL, **l_unset = NULL, **t;
        int c_set = 0, c_unset = 0, p;
        DBusError error;
        DBusMessage *m = NULL, *reply = NULL;
        DBusMessageIter iter, sub;

        dbus_error_init(&error);

        assert(bus);

        l_set = new0(char*, _PROP_MAX);
        l_unset = new0(char*, _PROP_MAX);
        if (!l_set || !l_unset) {
                log_oom();
                goto finish;
        }

        for (p = 0; p < _PROP_MAX; p++) {
                assert(names[p]);

                if (isempty(data[p]))
                        l_unset[c_set++] = (char*) names[p];
                else {
                        char *s;

                        if (asprintf(&s, "%s=%s", names[p], data[p]) < 0) {
                                log_oom();
                                goto finish;
                        }

                        l_set[c_unset++] = s;
                }
        }

        assert(c_set + c_unset == _PROP_MAX);
        m = dbus_message_new_method_call("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "UnsetAndSetEnvironment");
        if (!m) {
                log_error("Could not allocate message.");
                goto finish;
        }

        dbus_message_iter_init_append(m, &iter);

        if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
                log_oom();
                goto finish;
        }

        STRV_FOREACH(t, l_unset)
                if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
                        log_oom();
                        goto finish;
                }

        if (!dbus_message_iter_close_container(&iter, &sub) ||
            !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
                log_oom();
                goto finish;
        }

        STRV_FOREACH(t, l_set)
                if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
                        log_oom();
                        goto finish;
                }

        if (!dbus_message_iter_close_container(&iter, &sub)) {
                log_oom();
                goto finish;
        }

        reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
        if (!reply) {
                log_error("Failed to set locale information: %s", bus_error_message(&error));
                goto finish;
        }

finish:
        if (m)
                dbus_message_unref(m);

        if (reply)
                dbus_message_unref(reply);

        dbus_error_free(&error);

        strv_free(l_set);
        free(l_unset);
}
开发者ID:RoadRunnr,项目名称:systemd,代码行数:90,代码来源:localed.c


示例17: thunar_dbus_client_bulk_rename

/**
 * thunar_dbus_client_bulk_rename:
 * @working_directory : the default working directory  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dbus_new0函数代码示例发布时间:2022-05-30
下一篇:
C++ dbus_message_ref函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap