[Spice-devel] [vdagent-linux v2 1/6] console-kit: use define for dbus paths

Victor Toso victortoso at redhat.com
Mon Apr 25 10:01:19 UTC 2016


Hi,

On Mon, Apr 25, 2016 at 05:08:08AM -0400, Frediano Ziglio wrote:
> > 
> > This improves readability of all paths related to dbus methods. This patch
> > only
> > applies for interfaces and object paths, later one it is included for signals
> > as
> > well.
> > ---
> >  src/console-kit.c | 30 ++++++++++++++++++++----------
> >  1 file changed, 20 insertions(+), 10 deletions(-)
> > 
> > diff --git a/src/console-kit.c b/src/console-kit.c
> > index 6e83bf2..4049622 100644
> > --- a/src/console-kit.c
> > +++ b/src/console-kit.c
> > @@ -34,6 +34,14 @@ struct session_info {
> >      char *active_session;
> >  };
> >  
> > +#define INTERFACE_CONSOLE_KIT "org.freedesktop.ConsoleKit"
> > +#define OBJ_PATH_CONSOLE_KIT  "/org/freedesktop/ConsoleKit"
> > +
> > +#define INTERFACE_CK_MANAGER    INTERFACE_CONSOLE_KIT ".Manager"
> > +#define OBJ_PATH_CK_MANAGER     OBJ_PATH_CONSOLE_KIT "/Manager"
> > +
> > +#define INTERFACE_CK_SEAT       INTERFACE_CONSOLE_KIT ".Seat"
> > +
>
> Why CONSOLE_KIT and CK ?

Hehe, I was trying to avoid too big defines. I can change that if you prefer!

- INTERFACE_CK_MANAGER
+ INTERFACE_CONSOLE_KIT_MANAGER

- INTERFACE_CK_SEAT
+ INTERFACE_CONSOLE_KIT_SEAT
>
> >  static char *console_kit_get_first_seat(struct session_info *ck);
> >  static char *console_kit_check_active_session_change(struct session_info
> >  *ck);
> >  
> > @@ -73,8 +81,9 @@ struct session_info *session_info_create(int verbose)
> >  
> >      /* Register for active session changes */
> >      snprintf(match, sizeof(match),
> > -             "type='signal',interface='org.freedesktop.ConsoleKit.Seat',"
> > -             "path='%s',member='ActiveSessionChanged'", ck->seat);
> > +             "type='signal',interface='%s',"
> > +             "path='%s',member='ActiveSessionChanged'",
> > +             INTERFACE_CK_SEAT, ck->seat);
> >      dbus_error_init(&error);
> >      dbus_bus_add_match(ck->connection, match, &error);
> >      if (dbus_error_is_set(&error)) {
> > @@ -111,9 +120,10 @@ static char *console_kit_get_first_seat(struct
> > session_info *ck)
> >      int type;
> >      char *seat = NULL;
> >  
> > -    message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
> > -
> > "/org/freedesktop/ConsoleKit/Manager",
> > -
> > "org.freedesktop.ConsoleKit.Manager",
> > +
> > +    message = dbus_message_new_method_call(INTERFACE_CONSOLE_KIT,
> > +                                           OBJ_PATH_CK_MANAGER,
> > +                                           INTERFACE_CK_MANAGER,
> >                                             "GetSeats");
> >      if (message == NULL) {
> >          syslog(LOG_ERR, "Unable to create dbus message");
> > @@ -178,9 +188,9 @@ const char *session_info_get_active_session(struct
> > session_info *ck)
> >      if (ck->active_session)
> >          return console_kit_check_active_session_change(ck);
> >  
> > -    message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
> > +    message = dbus_message_new_method_call(INTERFACE_CONSOLE_KIT,
> >                                             ck->seat,
> > -
> > "org.freedesktop.ConsoleKit.Seat",
> > +                                           INTERFACE_CK_SEAT,
> >                                             "GetActiveSession");
> >      if (message == NULL) {
> >          syslog(LOG_ERR, "Unable to create dbus message");
> > @@ -241,9 +251,9 @@ char *session_info_session_for_pid(struct session_info
> > *ck, uint32_t pid)
> >      if (!ck)
> >          return NULL;
> >  
> > -    message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
> > -
> > "/org/freedesktop/ConsoleKit/Manager",
> > -
> > "org.freedesktop.ConsoleKit.Manager",
> > +    message = dbus_message_new_method_call(INTERFACE_CONSOLE_KIT,
> > +                                           OBJ_PATH_CK_MANAGER,
> > +                                           INTERFACE_CK_MANAGER,
> >                                             "GetSessionForUnixProcess");
> >      if (message == NULL) {
> >          syslog(LOG_ERR, "Unable to create dbus message");
> 
> Frediano


More information about the Spice-devel mailing list