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

C++ dbus_message_new_method_call函数代码示例

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

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



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

示例1: send_echo_method_call

/* Note, this is all crack-a-rific; it isn't using DBusGProxy and thus is
 * a major pain
 */
static void
send_echo_method_call (DBusConnection *connection)
{
  DBusMessage *message;
  const char *hello = "Hello World!";
  dbus_int32_t i32 = 123456;

  message = dbus_message_new_method_call (ECHO_SERVICE,
                                          ECHO_PATH,
                                          ECHO_INTERFACE,
                                          ECHO_PING_METHOD);
  dbus_message_append_args (message,
                            DBUS_TYPE_STRING, &hello,
                            DBUS_TYPE_INT32, &i32,
#if PAYLOAD_SIZE > 0
                            DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
                            &payload, PAYLOAD_SIZE,
#endif
                            DBUS_TYPE_INVALID);
  
  dbus_connection_send (connection, message, NULL);
  dbus_message_unref (message);
  dbus_connection_flush (connection);
}
开发者ID:freedesktop-unofficial-mirror,项目名称:dbus__dbus-qt3,代码行数:27,代码来源:test-profile.c


示例2: passkey_request_new

static int passkey_request_new(struct agent_request *req,
				const char *device_path)
{
	struct agent *agent = req->agent;

	req->msg = dbus_message_new_method_call(agent->owner, agent->path,
					AGENT_INTERFACE, "RequestPasskey");
	if (req->msg == NULL) {
		error("Couldn't allocate D-Bus message");
		return -ENOMEM;
	}

	dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
					DBUS_TYPE_INVALID);

	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
					&req->call, REQUEST_TIMEOUT) == FALSE) {
		error("D-Bus send failed");
		return -EIO;
	}

	dbus_pending_call_set_notify(req->call, passkey_reply, req, NULL);
	return 0;
}
开发者ID:DaisyPi,项目名称:sensortag,代码行数:24,代码来源:agent.c


示例3: dc_render_node_opacity_set

void dc_render_node_opacity_set(struct razer_daemon_controller *controller,int render_node_uid,float opacity)
{
	DBusMessage *msg;
	DBusMessageIter args;
	char *path = str_CreateEmpty();
	path = str_CatFree(path,"/");
	char *suid = str_FromLong(render_node_uid);
	path = str_CatFree(path,suid);
	free(suid);
	double opc = (double)opacity;
	msg = dbus_message_new_method_call("org.voyagerproject.razer.daemon",path,"org.voyagerproject.razer.daemon.render_node.opacity","set");
	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_DOUBLE,&opc))
		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);
	free(path);//TODO gets not freed on error
}
开发者ID:SublimeApple,项目名称:razer_blackwidow_chroma_driver,代码行数:24,代码来源:razer_daemon_controller.c


示例4: dc_render_node_parent_get

int dc_render_node_parent_get(struct razer_daemon_controller *controller,int render_node_uid)
{
	DBusMessage *msg;
	DBusMessageIter args;
	char *path = str_CreateEmpty();
	path = str_CatFree(path,"/");
	char *suid = str_FromLong(render_node_uid);
	path = str_CatFree(path,suid);
	free(suid);
	msg = dbus_message_new_method_call("org.voyagerproject.razer.daemon",path,"org.voyagerproject.razer.daemon.render_node.parent","get");
	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);

	int parent_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,&parent_uid);
	dbus_message_unref(msg);   
	free(path);//TODO gets not freed on error
	return(parent_uid);
}
开发者ID:SublimeApple,项目名称:razer_blackwidow_chroma_driver,代码行数:36,代码来源:razer_daemon_controller.c


示例5: xconnman_check_service

/** 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;

	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;
}
开发者ID:zchydem,项目名称:mce,代码行数:40,代码来源:radiostates.c


示例6: pincode_request_new

static int pincode_request_new(struct agent_request *req, const char *device_path,
				dbus_bool_t numeric)
{
	struct agent *agent = req->agent;

	req->msg = dbus_message_new_method_call(agent->name, agent->path,
					"org.bluez.Agent", "RequestPinCode");
	if (req->msg == NULL) {
		error("Couldn't allocate D-Bus message");
		return -ENOMEM;
	}

	dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
					DBUS_TYPE_INVALID);

	if (dbus_connection_send_with_reply(connection, req->msg,
					&req->call, REQUEST_TIMEOUT) == FALSE) {
		error("D-Bus send failed");
		return -EIO;
	}

	dbus_pending_call_set_notify(req->call, pincode_reply, req, NULL);
	return 0;
}
开发者ID:Mcjesus15,项目名称:Zio_Other,代码行数:24,代码来源:agent.c


示例7: send_spawned

static void
send_spawned (DBusConnection *connection, gboolean succeeded, char *error_message)
{
  DBusMessage *message;
  dbus_bool_t dbus_succeeded;

  if (error_message == NULL)
    error_message = "";

  if (spawner_id == NULL || spawner_path == NULL)
    {
      if (!succeeded)
	{
	  g_printerr (_("Error: %s"), error_message);
	  g_printerr ("\n");
	}
      return;
    }
  
  message = dbus_message_new_method_call (spawner_id,
					  spawner_path,
					  G_VFS_DBUS_SPAWNER_INTERFACE,
					  G_VFS_DBUS_OP_SPAWNED);
  dbus_message_set_no_reply (message, TRUE);

  dbus_succeeded = succeeded;
  if (!dbus_message_append_args (message,
				 DBUS_TYPE_BOOLEAN, &dbus_succeeded,
				 DBUS_TYPE_STRING, &error_message,
				 DBUS_TYPE_INVALID))
    _g_dbus_oom ();
    
  dbus_connection_send (connection, message, NULL);
  /* Make sure the message is sent */
  dbus_connection_flush (connection);
}
开发者ID:Andais,项目名称:gvfs,代码行数:36,代码来源:daemon-main.c


示例8: send_new_connection

static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn,
							struct btd_device *dev)
{
	DBusMessage *msg;
	const char *path;
	int fd;

	msg = dbus_message_new_method_call(ext->owner, ext->path,
							"org.bluez.Profile",
							"NewConnection");
	if (!msg) {
		error("Unable to create NewConnection call for %s", ext->name);
		return false;
	}

	path = device_get_path(dev);
	fd = g_io_channel_unix_get_fd(conn->io);

	dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &path,
					DBUS_TYPE_UNIX_FD, &fd,
					DBUS_TYPE_INVALID);

	if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
						msg, &conn->new_conn, -1)) {
		error("%s: sending NewConnection failed", ext->name);
		dbus_message_unref(msg);
		return false;
	}

	dbus_message_unref(msg);

	dbus_pending_call_set_notify(conn->new_conn, new_conn_reply, conn,
									NULL);

	return true;
}
开发者ID:intgr,项目名称:bluez,代码行数:36,代码来源:profile.c


示例9: release_session

static void release_session(gpointer key, gpointer value, gpointer user_data)
{
	struct connman_session *session = value;
	DBusMessage *message;

	DBG("owner %s path %s", session->owner, session->notify_path);

	if (session->notify_watch > 0)
		g_dbus_remove_watch(connection, session->notify_watch);

	g_dbus_unregister_interface(connection, session->session_path,
						CONNMAN_SESSION_INTERFACE);

	message = dbus_message_new_method_call(session->owner,
						session->notify_path,
						CONNMAN_NOTIFICATION_INTERFACE,
						"Release");
	if (!message)
		return;

	dbus_message_set_no_reply(message, TRUE);

	g_dbus_send_message(connection, message);
}
开发者ID:igaw,项目名称:connman,代码行数:24,代码来源:session.c


示例10: asdbus_GetConsoleSessionType

char* asdbus_GetConsoleSessionType (const char *session_id)
{
  char     *session_type = NULL;
#ifdef HAVE_DBUS_CONTEXT
	if (ASDBus.system_conn && session_id) {
		DBusMessage *message = dbus_message_new_method_call (CK_NAME,
																													session_id,
																													CK_SESSION_INTERFACE,
																													"GetSessionType");
    if (message) {
			DBusMessage *reply;
			DBusError error;

			dbus_error_init (&error);
			reply = dbus_connection_send_with_reply_and_block (ASDBus.system_conn, message, -1, &error);
			dbus_message_unref (message);

      if (reply == NULL) {
				if (dbus_error_is_set (&error))
					show_error ("Unable to determine Console Kit Session Type: %s", error.message);
			} else {
				DBusMessageIter iter;
  	    const char     *val = NULL;
        dbus_message_iter_init (reply, &iter);
        dbus_message_iter_get_basic (&iter, &val);
				session_type = mystrdup (val);
/*				show_progress ("sess_type returned = \"%s\", arg_type = \"%c\"", val, dbus_message_iter_get_arg_type (&iter)); */
        dbus_message_unref (reply);
			}
			if (dbus_error_is_set (&error))
				dbus_error_free (&error);
		}
	}
#endif
	return session_type;
}
开发者ID:afterstep,项目名称:afterstep,代码行数:36,代码来源:dbus.c


示例11: destroy_proxy_configuration

static void destroy_proxy_configuration(void)
{
	DBusMessage *msg;
	DBusPendingCall *call;
	dbus_bool_t result;

	if (!current_config)
		return;

	DBG("");

	msg = dbus_message_new_method_call(PACRUNNER_SERVICE, PACRUNNER_PATH,
			PACRUNNER_INTERFACE, "DestroyProxyConfiguration");
	if (!msg)
		return;

	dbus_message_set_auto_start(msg, FALSE);

	dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &current_config,
							DBUS_TYPE_INVALID);

	result = dbus_connection_send_with_reply(connection, msg,
							&call, DBUS_TIMEOUT);

	dbus_message_unref(msg);

	if (!result || !call)
		return;

	dbus_pending_call_set_notify(call, destroy_config_reply, NULL, NULL);

	dbus_pending_call_unref(call);

	g_free(current_config);
	current_config = NULL;
}
开发者ID:rzr,项目名称:connman,代码行数:36,代码来源:pacrunner.c


示例12: rs_external_editor_gimp

gboolean
rs_external_editor_gimp(RS_PHOTO *photo, RSFilter *prior_to_resample, guint snapshot)
{
#ifdef WIN32
	return FALSE;
#else
	RSOutput *output = NULL;
	g_assert(RS_IS_PHOTO(photo));

	// We need at least GIMP 2.4.0 to export photo
	if (!rs_has_gimp(2,4,0)) {
		return FALSE;
	}

	DBusConnection *bus;
	DBusMessage *message, *reply;
	GString *filename;

	bus = dbus_bus_get (DBUS_BUS_SESSION, NULL);

	gchar* org_name = g_path_get_basename(photo->filename);
	gchar* org_name_noext = g_utf8_strchr(org_name, -1, '.');

	/* Terminate string there */
	if (NULL != org_name_noext)
		org_name_noext[0] = 0;

	filename = g_string_new("");
        g_string_printf(filename, "%s/%s-rawstudio_%.0f.png",g_get_tmp_dir(), org_name, g_random_double()*10000);

	g_free(org_name);

	/* Setup our filter chain for saving */
				RSFilter *ftransform_input = rs_filter_new("RSColorspaceTransform", prior_to_resample);
        RSFilter *fdcp = rs_filter_new("RSDcp", ftransform_input);
        RSFilter *fdenoise= rs_filter_new("RSDenoise", fdcp);
        RSFilter *ftransform_display = rs_filter_new("RSColorspaceTransform", fdenoise);
        RSFilter *fend = ftransform_display;

			GList *filters = g_list_append(NULL, fend);
			rs_photo_apply_to_filters(photo, filters, snapshot);
			g_list_free(filters);


	output = rs_output_new("RSPngfile");
	g_object_set(output, "filename", filename->str, NULL);
	g_object_set(output, "save16bit", FALSE, NULL);
	g_object_set(output, "copy-metadata", TRUE, NULL);
	rs_output_execute(output, fend);
	g_object_unref(output);
	g_object_unref(ftransform_input);
	g_object_unref(ftransform_display);
	g_object_unref(fdenoise);
	g_object_unref(fdcp);

	message = dbus_message_new_method_call("org.gimp.GIMP.UI",
                                                "/org/gimp/GIMP/UI",
                                                "org.gimp.GIMP.UI",
                                                "OpenAsNew");
	dbus_message_append_args (message,
                                        DBUS_TYPE_STRING, &filename->str,
					DBUS_TYPE_INVALID);

	/* Send DBus message to GIMP */
	reply = dbus_connection_send_with_reply_and_block (bus, message, -1, NULL);

	/* If we didn't get a reply from GIMP - we try to start it and resend the message */
	if (!reply) {
		gint retval = system("gimp &");
		if (retval != 0) {
			g_warning("system(\"gimp &\") returned: %d\n", retval);
			g_unlink(filename->str);
			g_string_free(filename, TRUE);
			dbus_message_unref (message);
			return FALSE;
		}
	}

	/* Allow GIMP to start - we send the message every one second */
	while (!reply) {
		gint i = 0;
		if (i > EXPORT_TO_GIMP_TIMEOUT_SECONDS) {
			g_warning("Never got a reply from GIMP - deleting temporary file");
			g_unlink(filename->str);
			g_string_free(filename, TRUE);
			dbus_message_unref (message);
			return FALSE;
		}
		sleep(1);
		i++;
		reply = dbus_connection_send_with_reply_and_block (bus, message, -1, NULL);
	}

	dbus_message_unref (message);

	/* Depends on GIMP DBus signal: 'Opened' */
	if (rs_has_gimp(2,6,2)) {
		/* Connect to GIMP and listen for "Opened" signal */
		dbus_bus_add_match (bus, "type='signal',interface='org.gimp.GIMP.UI'", NULL);
		dbus_connection_add_filter(bus, dbus_gimp_opened, filename->str , NULL);
//.........这里部分代码省略.........
开发者ID:dmuktro,项目名称:rawstudio,代码行数:101,代码来源:rs-external-editor.c


示例13: libvlc_InternalInit


//.........这里部分代码省略.........
            else
            {
                int i_input;
                DBusMessage* p_dbus_msg = NULL;
                DBusMessageIter dbus_args;
                DBusPendingCall* p_dbus_pending = NULL;
                dbus_bool_t b_play;

                msg_Warn( p_libvlc, "Another Media Player is running. Exiting");

                for( i_input = vlc_optind; i_input < i_argc;i_input++ )
                {
                    /* Skip input options, we can't pass them through D-Bus */
                    if( ppsz_argv[i_input][0] == ':' )
                    {
                        msg_Warn( p_libvlc, "Ignoring option %s",
                                  ppsz_argv[i_input] );
                        continue;
                    }

                    /* We need to resolve relative paths in this instance */
                    char *psz_mrl;
                    if( strstr( psz_mrl, "://" ) )
                        psz_mrl = strdup( ppsz_argv[i_input] );
                    else
                        psz_mrl = vlc_path2uri( ppsz_argv[i_input], NULL );
                    const char *psz_after_track = MPRIS_APPEND;

                    if( psz_mrl == NULL )
                        continue;
                    msg_Dbg( p_libvlc, "Adds %s to the running Media Player",
                             psz_mrl );

                    p_dbus_msg = dbus_message_new_method_call(
                        MPRIS_BUS_NAME, MPRIS_OBJECT_PATH,
                        MPRIS_TRACKLIST_INTERFACE, "AddTrack" );

                    if ( NULL == p_dbus_msg )
                    {
                        msg_Err( p_libvlc, "D-Bus problem" );
                        free( psz_mrl );
                        system_End( );
                        exit( 1 );
                    }

                    /* append MRLs */
                    dbus_message_iter_init_append( p_dbus_msg, &dbus_args );
                    if ( !dbus_message_iter_append_basic( &dbus_args,
                                DBUS_TYPE_STRING, &psz_mrl ) )
                    {
                        dbus_message_unref( p_dbus_msg );
                        free( psz_mrl );
                        system_End( );
                        exit( 1 );
                    }
                    free( psz_mrl );

                    if( !dbus_message_iter_append_basic( &dbus_args,
                                DBUS_TYPE_OBJECT_PATH, &psz_after_track ) )
                    {
                        dbus_message_unref( p_dbus_msg );
                        system_End( );
                        exit( 1 );
                    }

                    b_play = TRUE;
开发者ID:RodrigoNieves,项目名称:vlc,代码行数:67,代码来源:libvlc.c


示例14: start_target

static void start_target(const char *target, bool isolate) {
        DBusMessage *m = NULL, *reply = NULL;
        DBusError error;
        const char *mode, *basic_target = "basic.target";
        DBusConnection *bus = NULL;

        assert(target);

        dbus_error_init(&error);

        if (bus_connect(DBUS_BUS_SYSTEM, &bus, NULL, &error) < 0) {
                log_error("Failed to get D-Bus connection: %s", bus_error_message(&error));
                goto finish;
        }

        if (isolate)
                mode = "isolate";
        else
                mode = "replace";

        log_info("Running request %s/start/%s", target, mode);

        if (!(m = dbus_message_new_method_call("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartUnitReplace"))) {
                log_error("Could not allocate message.");
                goto finish;
        }

        /* Start these units only if we can replace base.target with it */

        if (!dbus_message_append_args(m,
                                      DBUS_TYPE_STRING, &basic_target,
                                      DBUS_TYPE_STRING, &target,
                                      DBUS_TYPE_STRING, &mode,
                                      DBUS_TYPE_INVALID)) {
                log_error("Could not attach target and flag information to message.");
                goto finish;
        }

        if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) {

                /* Don't print a warning if we aren't called during
                 * startup */
                if (!dbus_error_has_name(&error, BUS_ERROR_NO_SUCH_JOB))
                        log_error("Failed to start unit: %s", bus_error_message(&error));

                goto finish;
        }

finish:
        if (m)
                dbus_message_unref(m);

        if (reply)
                dbus_message_unref(reply);

        if (bus) {
                dbus_connection_flush(bus);
                dbus_connection_close(bus);
                dbus_connection_unref(bus);
        }

        dbus_error_free(&error);
}
开发者ID:RoadRunnr,项目名称:systemd,代码行数:63,代码来源:fsck.c


示例15: register_machine

void register_machine(pid_t pid, const char *dest) {
	int rc;

	DBusError err;
	DBusConnection *conn;

	DBusMessageIter args;
	DBusMessage *req, *rep;

	DBusMessageIter uuid_iter, scope_iter;

	_free_ char *name = NULL;

	char *app = "pflask";
	unsigned char uuid[16];
	char *type = "container";

	dbus_error_init(&err);

	rc = asprintf(&name, "pflask-%d", pid);
	if (rc < 0) fail_printf("OOM");

	conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
	if (dbus_error_is_set(&err))
		return;

	req = dbus_message_new_method_call(
		"org.freedesktop.machine1",
		"/org/freedesktop/machine1",
		"org.freedesktop.machine1.Manager",
		"CreateMachine"
	);

	dbus_message_iter_init_append(req, &args);

	/* name */
	if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &name))
		fail_printf("OOM");

	/* id */
	if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "y",
	                                      &uuid_iter))
		fail_printf("OOM");

	if (!dbus_message_iter_append_fixed_array(&uuid_iter, DBUS_TYPE_BYTE,
	                                          uuid, 0))
		fail_printf("OOM");

	if (!dbus_message_iter_close_container(&args, &uuid_iter))
		fail_printf("OOM");

	/* service */
	if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &app))
		fail_printf("OOM");

	/* type */
	if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &type))
		fail_printf("OOM");

	/* leader */
	if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32, &pid))
		fail_printf("OOM");

	/* root */
	if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &dest))
		fail_printf("OOM");

	/* scope properties */
	if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "(sv)",
	                                      &scope_iter))
		fail_printf("OOM");

	if (!dbus_message_iter_close_container(&args, &scope_iter))
		fail_printf("OOM");

	rep = dbus_connection_send_with_reply_and_block(conn, req, -1, &err);
	if (dbus_error_is_set(&err))
		goto done;

	dbus_message_unref(rep);

done:
	dbus_message_unref(req);

	dbus_connection_close(conn);
	dbus_error_free(&err);
}
开发者ID:jrandall,项目名称:pflask,代码行数:87,代码来源:machine.c


示例16: send_msg1

static void* send_msg1(void* data)
{
	DBusConnection* connection;
	DBusError error;
	static int cnt = 1;
	dbus_int32_t no = 5;
	DBusPendingCall* pending;
	DBusMessage* msg1;
	DBusMessage* msg;
	int data_slot = *(int*)data;
	FILE* fp;
	threadData1* thrData;

	dbus_error_init(&error);
	connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
	
	thrData = (threadData1*)dbus_connection_get_data(connection, data_slot);
	if(!thrData)
		return NULL;
	
	pthread_mutex_lock(&thrData->mutex);
	
	msg = dbus_message_new_method_call("Test.Method.Call", "/Test/Method/Object", "test.Method.Call", "simple");
	
	dbus_message_append_args(msg, DBUS_TYPE_INT32, &no, DBUS_TYPE_INVALID);
	 
	pthread_cond_wait(&thrData->cond,  &thrData->mutex);
	 
	// send message and get a handle for a reply
	   if (!dbus_connection_send_with_reply (connection, msg, &pending, -1)) { // -1 is default timeout
	   thrData->ret = 2;
//	   		exit(1);
	   }   
	   if (NULL == pending) {
	   thrData->ret = 2;
//	      exit(1);
	   } 
	   dbus_connection_flush(connection);
	   
		// free message
	   dbus_message_unref(msg);   
	  
	   // block until we recieve a reply
	   dbus_pending_call_block(pending);
	
	   // get the reply message
	   msg1 = dbus_pending_call_steal_reply(pending);
	   if (NULL == msg1) {
	   thrData->ret = 2;
	
	   }  
	   // free the pending message handle
	   dbus_pending_call_unref(pending);
		 
	  
	   dbus_message_get_args(msg1, &error, DBUS_TYPE_INT32, &no, DBUS_TYPE_INVALID);
	   
	   fp = fopen("C:\\new.txt", "a+");
	   fprintf(fp, "%d\n", no);
	   fclose(fp);
	    
	   if(no == 9090)
		   {
		   thrData->ret++;
		   }
	   
	 	 
	   // free reply and close connection
	   dbus_message_unref(msg1); 
	   dbus_connection_unref(connection);
	   pthread_mutex_unlock(&thrData->mutex); 
	   return NULL;
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:73,代码来源:dbus_N_messages1.c


示例17: ck_tracker_init_get_seats_and_sessions

static gboolean
ck_tracker_init_get_seats_and_sessions (CKTracker *tracker)
{
	gboolean ret;
	DBusError error;
	DBusMessage *message;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter iter_array;

	ret = FALSE;

	/* first build array of existing seats and sessions */

	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
						"/org/freedesktop/ConsoleKit/Manager",
						"org.freedesktop.ConsoleKit.Manager",
						"GetSeats");
	dbus_error_init (&error);
	reply = dbus_connection_send_with_reply_and_block (tracker->dbus_connection, message, -1, &error);
	if (reply == NULL || dbus_error_is_set (&error)) {
		HAL_ERROR (("Error doing GetSeats on ConsoleKit: %s: %s", error.name, error.message));
		dbus_message_unref (message);
		if (reply != NULL)
			dbus_message_unref (reply);
		goto error;
	}

	dbus_message_iter_init (reply, &iter);
	if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY) {
		HAL_WARNING (("Expecting an array from GetSeats on ConsoleKit."));
		dbus_message_unref (message);
		dbus_message_unref (reply);
		goto error;
	}
	dbus_message_iter_recurse (&iter, &iter_array);
	while (dbus_message_iter_get_arg_type (&iter_array) == DBUS_TYPE_OBJECT_PATH) {
		const char *seat_objpath;
		CKSeat *seat;

		dbus_message_iter_get_basic (&iter_array, &seat_objpath);
		HAL_INFO (("got seat '%s'", seat_objpath));

		seat = ck_seat_new (seat_objpath);

		/* get information */
		if (!ck_seat_get_info (tracker, seat)) {
			HAL_ERROR (("Could not get information for seat '%s'", seat_objpath));
			dbus_message_unref (message);
			dbus_message_unref (reply);
			goto error;
		}

		/* for each seat, get the sessions */
		if (!ck_tracker_init_get_sessions_for_seat (tracker, seat)) {
			HAL_ERROR (("Could not get sessions for seat '%s'", seat_objpath));
			dbus_message_unref (message);
			dbus_message_unref (reply);
			goto error;
		}

		tracker->seats = g_slist_prepend (tracker->seats, seat);

		dbus_message_iter_next (&iter_array);
	}
	dbus_message_unref (message);
	dbus_message_unref (reply);

	HAL_INFO (("Got seats"));

	ret = TRUE;
error:
	if (dbus_error_is_set (&error))
		dbus_error_free (&error);

	return ret;
}
开发者ID:bbidulock,项目名称:hal,代码行数:77,代码来源:ck-tracker.c


示例18: ck_session_get_info

static gboolean
ck_session_get_info (CKTracker *tracker, CKSession *session)
{
	gboolean ret;
	DBusError error;
	DBusMessage *message;
	DBusMessage *reply;
	char *hostname;

	ret = FALSE;

	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
						session->session_objpath,
						"org.freedesktop.ConsoleKit.Session",
						"IsActive");
	dbus_error_init (&error);
	reply = dbus_connection_send_with_reply_and_block (tracker->dbus_connection, message, -1, &error);
	if (reply == NULL || dbus_error_is_set (&error)) {
		HAL_ERROR (("Error doing Session.IsActive on ConsoleKit: %s: %s", error.name, error.message));
		dbus_message_unref (message);
		if (reply != NULL)
			dbus_message_unref (reply);
		goto error;
	}
	if (!dbus_message_get_args (reply, NULL,
				    DBUS_TYPE_BOOLEAN, &(session->is_active),
				    DBUS_TYPE_INVALID)) {
		HAL_ERROR (("Invalid IsActive reply from CK"));
		goto error;
	}
	dbus_message_unref (message);
	dbus_message_unref (reply);

	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
						session->session_objpath,
						"org.freedesktop.ConsoleKit.Session",
						"IsLocal");
	dbus_error_init (&error);
	reply = dbus_connection_send_with_reply_and_block (tracker->dbus_connection, message, -1, &error);
	if (reply == NULL || dbus_error_is_set (&error)) {
		HAL_ERROR (("Error doing Session.IsLocal on ConsoleKit: %s: %s", error.name, error.message));
		dbus_message_unref (message);
		if (reply != NULL)
			dbus_message_unref (reply);
		goto error;
	}
	if (!dbus_message_get_args (reply, NULL,
				    DBUS_TYPE_BOOLEAN, &(session->is_local),
				    DBUS_TYPE_INVALID)) {
		HAL_ERROR (("Invalid IsLocal reply from CK"));
		goto error;
	}
	dbus_message_unref (message);
	dbus_message_unref (reply);

	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
						session->session_objpath,
						"org.freedesktop.ConsoleKit.Session",
						"GetRemoteHostName");
	dbus_error_init (&error);
	reply = dbus_connection_send_with_reply_and_block (tracker->dbus_connection, message, -1, &error);
	if (reply == NULL || dbus_error_is_set (&error)) {
		HAL_ERROR (("Error doing Session.GetRemoteHostName on ConsoleKit: %s: %s", error.name, error.message));
		dbus_message_unref (message);
		if (reply != NULL)
			dbus_message_unref (reply);
		goto error;
	}
	if (!dbus_message_get_args (reply, NULL,
				    DBUS_TYPE_STRING, &hostname,
				    DBUS_TYPE_INVALID)) {
		HAL_ERROR (("Invalid GetRemoteHostName reply from CK"));
		goto error;
	}
	session->hostname = g_strdup (hostname);
	dbus_message_unref (message);
	dbus_message_unref (reply);

	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
						session->session_objpath,
						"org.freedesktop.ConsoleKit.Session",
						"GetUnixUser");
	dbus_error_init (&error);
	reply = dbus_connection_send_with_reply_and_block (tracker->dbus_connection, message, -1, &error);
	if (reply == NULL || dbus_error_is_set (&error)) {
		HAL_ERROR (("Error doing Session.GetUnixUser on ConsoleKit: %s: %s", error.name, error.message));
		dbus_message_unref (message);
		if (reply != NULL)
			dbus_message_unref (reply);
		goto error;
	}
	if (!dbus_message_get_args (reply, NULL,
#ifdef HAVE_CK_0_3
				    DBUS_TYPE_UINT32, &(session->user),
#else
				    DBUS_TYPE_INT32, &(session->user),
#endif
				    DBUS_TYPE_INVALID)) {
		HAL_ERROR (("Invalid GetUnixUser reply from CK"));
		goto error;
//.........这里部分代码省略.........
开发者ID:bbidulock,项目名称:hal,代码行数:101,代码来源:ck-tracker.c


示例19: _dbus_message_test

/**
 * @ingroup DBusMessageInternals
 * Unit test for DBusMessage.
 *
 * @returns #TRUE on success.
 */
dbus_bool_t
_dbus_message_test (const char *test_data_dir)
{
  DBusMessage *message, *message_without_unix_fds;
  DBusMessageLoader *loader;
  int i;
  const char *data;
  DBusMessage *copy;
  const char *name1;
  const char *name2;
  const dbus_uint32_t our_uint32_array[] =
    { 0x12345678, 0x23456781, 0x34567812, 0x45678123 };
  const dbus_int32_t our_int32_array[] =
    { 0x12345678, -0x23456781, 0x34567812, -0x45678123 };
  const dbus_uint32_t *v_ARRAY_UINT32 = our_uint32_array;
  const dbus_int32_t *v_ARRAY_INT32 = our_int32_array;
#ifdef DBUS_HAVE_INT64
  const dbus_uint64_t our_uint64_array[] =
    { 0x12345678, 0x23456781, 0x34567812, 0x45678123 };
  const dbus_int64_t our_int64_array[] =
    { 0x12345678, -0x23456781, 0x34567812, -0x45678123 };
  const dbus_uint64_t *v_ARRAY_UINT64 = our_uint64_array;
  const dbus_int64_t *v_ARRAY_INT64 = our_int64_array;
#endif
  const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" };
  const char **v_ARRAY_STRING = our_string_array;
  const double our_double_array[] = { 0.1234, 9876.54321, -300.0 };
  const double *v_ARRAY_DOUBLE = our_double_array;
  const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 };
  const unsigned char *v_ARRAY_BYTE = our_byte_array;
  const dbus_bool_t our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE };
  const dbus_bool_t *v_ARRAY_BOOLEAN = our_boolean_array;
  char sig[64];
  const char *s;
  const char *v_STRING;
  double v_DOUBLE;
  dbus_int16_t v_INT16;
  dbus_uint16_t v_UINT16;
  dbus_int32_t v_INT32;
  dbus_uint32_t v_UINT32;
#ifdef DBUS_HAVE_INT64
  dbus_int64_t v_INT64;
  dbus_uint64_t v_UINT64;
#endif
  unsigned char v_BYTE;
  unsigned char v2_BYTE;
  dbus_bool_t v_BOOLEAN;
  DBusMessageIter iter, array_iter, struct_iter;
#ifdef HAVE_UNIX_FD_PASSING
  int v_UNIX_FD;
#endif
  char **decomposed;

  message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
                                          "/org/freedesktop/TestPath",
                                          "Foo.TestInterface",
                                          "TestMethod");
  _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
  _dbus_assert (dbus_message_is_method_call (message, "Foo.TestInterface",
                                             "TestMethod"));
  _dbus_assert (strcmp (dbus_message_get_path (message),
                        "/org/freedesktop/TestPath") == 0);
  dbus_message_set_serial (message, 1234);

  /* string length including nul byte not a multiple of 4 */
  if (!dbus_message_set_sender (message, "org.foo.bar1"))
    _dbus_assert_not_reached ("out of memory");

  _dbus_assert (dbus_message_has_sender (message, "org.foo.bar1"));
  dbus_message_set_reply_serial (message, 5678);

  _dbus_verbose_bytes_of_string (&message->header.data, 0,
                                 _dbus_string_get_length (&message->header.data));
  _dbus_verbose_bytes_of_string (&message->body, 0,
                                 _dbus_string_get_length (&message->body));

  if (!dbus_message_set_sender (message, NULL))
    _dbus_assert_not_reached ("out of memory");


  _dbus_verbose_bytes_of_string (&message->header.data, 0,
                                 _dbus_string_get_length (&message->header.data));
  _dbus_verbose_bytes_of_string (&message->body, 0,
                                 _dbus_string_get_length (&message->body));


  _dbus_assert (!dbus_message_has_sender (message, "org.foo.bar1"));
  _dbus_assert (dbus_message_get_serial (message) == 1234);
  _dbus_assert (dbus_message_get_reply_serial (message) == 5678);
  _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));

  _dbus_assert (dbus_message_get_no_reply (message) == FALSE);
  dbus_message_set_no_reply (message, TRUE);
  _dbus_assert (dbus_message_get_no_reply (message) == TRUE);
//.........这里部分代码省略.........
开发者ID:0omega,项目名称:platform_external_dbus,代码行数:101,代码来源:dbus-message-util.c


示例20: dbus_message_new_method_call

static char *device_get_ieee1284_id(const char *adapter, const char *device)
{
	DBusMessage *message, *reply;
	DBusMessageIter iter, reply_iter;
	DBusMessageIter reply_iter_entry;
	const char *hcr_print = "00001126-0000-1000-8000-00805f9b34fb";
	const char *xml;
	char *id = NULL;

	/* Look for the service handle of the HCRP service */
	message = dbus_message_new_method_call("org.bluez", device,
						"org.bluez.Device",
						"DiscoverServices");
	dbus_message_iter_init_append(message, &iter);
	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &hcr_print);

	reply = dbus_connection_send_with_reply_and_block(conn,
							message, -1, NULL);

	dbus_message_unref(message);

	if (!reply)
		return NULL;

	dbus_message_iter_init(reply, &reply_iter);

	if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
		dbus_message_unref(reply);
		return NULL;
	}

	dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);

	/* Hopefully we only get one handle, or take a punt */
	while (dbus_message_iter_get_arg_type(&reply_iter_entry) == DBUS_TYPE_DICT_ENTRY) {
		guint32 key;
		DBusMessageIter dict_entry;

		dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);

		/* Key ? */
		dbus_message_iter_get_basic(&dict_entry, &key);
		if (!key) {
			dbus_message_iter_next(&reply_iter_entry);
			continue;
		}

		/* Try to get the value */
		if (!dbus_message_iter_next(&dict_entry)) {
			dbus_message_iter_next(&reply_iter_entry);
			continue;
		}

		dbus_message_iter_get_basic(&dict_entry, &xml);

		id = sdp_xml_parse_record(xml);
		if (id != NULL)
			break;
		dbus_message_iter_next(&reply_iter_entry);
	}

	dbus_message_unref(reply);

	return id;
}
开发者ID:Mcjesus15,项目名称:Zio_Other,代码行数:65,代码来源:main.c



注:本文中的dbus_message_new_method_call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ dbus_message_new_method_return函数代码示例发布时间:2022-05-30
下一篇:
C++ dbus_message_new_error函数代码示例发布时间: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