Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dbus] Move dbus_any_t union declaration to mce-dbus.h
Essentially the same declaration is made in several source files and
is used to simplify D-Bus message construction and parsing.

Move the declaration to mce-dbus.h header file and remove redundant
declarations from source files.

Rename the union declared in the radiostates plugin as it is used in
slightly different manner and needs to have non-const pointers.
  • Loading branch information
spiiroin committed Nov 3, 2015
1 parent 467b229 commit 0b7a9f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 41 deletions.
18 changes: 0 additions & 18 deletions mce-dbus.c
Expand Up @@ -115,24 +115,6 @@ void mce_dbus_pending_call_blocks_suspend(DBusPendingCall *pc)

static bool introspectable_signal(const char *interface, const char *member);

/** Placeholder for any basic dbus data type */
typedef union
{
dbus_int16_t i16;
dbus_int32_t i32;
dbus_int64_t i64;

dbus_uint16_t u16;
dbus_uint32_t u32;
dbus_uint64_t u64;

dbus_bool_t b;
unsigned char o;
const char *s;
double d;

} dbus_any_t;

/** Emit one iterm from dbus message iterator to file
*
* @param file output file
Expand Down
18 changes: 18 additions & 0 deletions mce-dbus.h
Expand Up @@ -128,6 +128,24 @@ void mce_dbus_exit(void);

void mce_dbus_send_config_notification(GConfEntry *entry);

/** Placeholder for any basic dbus data type */
typedef union
{
dbus_int16_t i16;
dbus_int32_t i32;
dbus_int64_t i64;

dbus_uint16_t u16;
dbus_uint32_t u32;
dbus_uint64_t u64;

dbus_bool_t b;
unsigned char o;
const char *s;
double d;

} dbus_any_t;

/** D-Bus message handler data
*
* For use with mce_dbus_handler_register() etc
Expand Down
10 changes: 5 additions & 5 deletions modules/battery-upower.c
Expand Up @@ -57,7 +57,7 @@
#define UPOWER_INTERFACE_DEVICE "org.freedesktop.UPower.Device"

/* ========================================================================= *
* union dbus_any_t
* union uval_t
* ========================================================================= */

/** Placeholder for any basic dbus data type */
Expand All @@ -76,7 +76,7 @@ typedef union
char *s;
double d;

} dbus_any_t;
} uval_t;

/* ========================================================================= *
* struct MceBattery holds battery data available via UPower
Expand Down Expand Up @@ -159,9 +159,9 @@ static void mcebat_update_schedule(void);
/** UPower property object */
typedef struct
{
char *p_key;
int p_type;
dbus_any_t p_val;
char *p_key;
int p_type;
uval_t p_val;
} uprop_t;

/** Invalidate property
Expand Down
18 changes: 0 additions & 18 deletions modules/radiostates.c
Expand Up @@ -477,24 +477,6 @@ static void master_radio_trigger(gconstpointer data)
/** net.connman.Manager.PropertyChanged D-Bus signal */
#define CONNMAN_PROPERTY_CHANGED_SIG "PropertyChanged"

/** Placeholder for any basic dbus data type */
typedef union
{
dbus_int16_t i16;
dbus_int32_t i32;
dbus_int64_t i64;

dbus_uint16_t u16;
dbus_uint32_t u32;
dbus_uint64_t u64;

dbus_bool_t b;
unsigned char o;
const char *s;
double d;

} dbus_any_t;

/** Initializer for dbus_any_t; largest union member set to zero */
#define DBUS_ANY_INIT { .i64 = 0 }

Expand Down

0 comments on commit 0b7a9f9

Please sign in to comment.