signal
[message]

Collaboration diagram for signal:

Detailed Description

Module for manage EasyDbus Signal objects

TO COMPLETE

See also:
skeleton module for functions to use for insert args on signals. In particular must be used EASYDBUS_ET_SIGNAL as event type value.

Signal Meta Information

Contact:
Daniele Rondina aka Ge@ru <geaaru@gmail.com>
Status:
EasyDbus Core Library
License:
GPL
Contributor(s):


Data Structures

struct  EasyDbus_signal
 EasyDbus_signal object. More...

Functions

EasyDbus_signaleasydbus_signal_create_skeleton (char *path, char *interface, char *signal)
 Create signal skeleton struct.
void easydbus_signal_free_skeleton (EasyDbus_signal *signal)
 Free a struct EasyDbus_signal object.
int easydbus_signal_get_args (EasyDbus_signal *signal)
 Get number of args on EasyDbus_signal object.
const char * easydbus_signal_get_destination (EasyDbus_signal *signal)
 Get destination of signal.
const EasyDbus_elemeasydbus_signal_get_element (EasyDbus_signal *signal, unsigned int n)
 Get N-element of EasyDbus_signal object.
const char * easydbus_signal_get_interface (EasyDbus_signal *signal)
 Get interface of signal.
const char * easydbus_signal_get_name (EasyDbus_signal *signal)
 Get name of signal.
const char * easydbus_signal_get_path (EasyDbus_signal *signal)
 Get path of signal.
const char * easydbus_signal_get_sender (EasyDbus_signal *signal)
 Get sender of signal.
enum easydbus_ret_values easydbus_signal_send (EasyDbus_conn *data, EasyDbus_signal *signal)
 Send signal message.
int easydbus_signal_set_destination (EasyDbus_signal *signal, const char *destination)
 Set destination of signal.
int easydbus_signal_set_sender (EasyDbus_signal *signal, const char *sender)
 Set sender of signal.


Function Documentation

EasyDbus_signal* easydbus_signal_create_skeleton ( char *  path,
char *  interface,
char *  signal 
)

Create signal skeleton struct.

Parameters:
path path of source address of signal
interface interface where signal is emitted from.
signal signal name.
Returns:
NULL

pointer to struct EasyDbus_signal.

Definition at line 59 of file signal.c.

References EasyDbus_signal::destination, EASYDBUS_MEMCOPY, EasyDbus_signal::first, EasyDbus_signal::interface, EasyDbus_signal::name, EasyDbus_signal::path, and EasyDbus_signal::sender.

Referenced by easydbus_signal_build_skeleton().

00062 {
00063    struct EasyDbus_signal *signal_skeleton = NULL;
00064    int string_length = 0;
00065 
00066    if (path == NULL || interface == NULL || signal == NULL)
00067       return NULL;
00068 
00069    signal_skeleton = (struct EasyDbus_signal *) malloc
00070       (sizeof (struct EasyDbus_signal));
00071 
00072    if (signal_skeleton == NULL)
00073       return NULL;
00074 
00075    memset (signal_skeleton, 0, sizeof (struct EasyDbus_signal));
00076 
00077    signal_skeleton->name = signal_skeleton->path =
00078       signal_skeleton->interface = 
00079       signal_skeleton->destination = 
00080       signal_skeleton->sender = NULL;
00081    signal_skeleton->first = NULL;
00082 
00083    string_length = strlen (signal) + 1;
00084    signal_skeleton->name = (char *) malloc (string_length);
00085    if (!signal_skeleton->name)
00086       goto out_of_memory_error;
00087    EASYDBUS_MEMCOPY (signal_skeleton->name, signal,
00088                      string_length);
00089 
00090    string_length = strlen (path) + 1;
00091    signal_skeleton->path = (char *) malloc (string_length);
00092    if (!signal_skeleton->path)
00093       goto out_of_memory_error;
00094    EASYDBUS_MEMCOPY (signal_skeleton->path, path,
00095                      string_length);
00096 
00097    string_length = strlen (interface) + 1;
00098    signal_skeleton->interface = (char *) malloc (string_length);
00099    if (!signal_skeleton->interface)
00100       goto out_of_memory_error;
00101    EASYDBUS_MEMCOPY (signal_skeleton->interface, interface,
00102                      string_length);
00103 
00104    return signal_skeleton;
00105 
00106  out_of_memory_error:
00107    if (signal_skeleton->name)
00108       free (signal_skeleton->name);
00109    if (signal_skeleton->path)
00110       free (signal_skeleton->path);
00111    if (signal_skeleton->interface)
00112       free (signal_skeleton->interface);
00113    free (signal_skeleton);
00114 
00115    return NULL;
00116 }

void easydbus_signal_free_skeleton ( EasyDbus_signal signal  )  [inline]

Free a struct EasyDbus_signal object.

Parameters:
signal pointer to EasyDbus_signal object.
Precondition:
signal != NULL

Definition at line 125 of file signal.c.

References EasyDbus_signal::args, EasyDbus_signal::destination, easydbus_elem_free(), EasyDbus_signal::first, EasyDbus_signal::interface, EasyDbus_signal::name, EasyDbus_elem::next, EasyDbus_signal::path, and EasyDbus_signal::sender.

Referenced by easydbus_signal_build_skeleton(), and easydbus_signal_handler().

00126 {
00127    struct EasyDbus_elem *el = NULL;
00128 
00129    if (signal) {
00130       if (signal->name)
00131          free (signal->name);
00132       if (signal->path)
00133          free (signal->path);
00134       if (signal->interface)
00135          free (signal->interface);
00136       if (signal->sender)
00137          free (signal->sender);
00138       if (signal->destination)
00139          free (signal->destination);
00140       signal->name = signal->path =
00141          signal->destination =
00142          signal->interface = signal->sender = NULL;
00143 
00144       while (signal->args) {
00145          if (signal->first) {
00146             el = signal->first;
00147             signal->first = signal->first->next;
00148             easydbus_elem_free (el);
00149          }
00150          signal->args--;
00151       }
00152       free (signal);
00153    }
00154 }

Here is the call graph for this function:

int easydbus_signal_get_args ( EasyDbus_signal signal  ) 

Get number of args on EasyDbus_signal object.

Precondition:
signal != NULL
Parameters:
signal EasyDbus_signal object pointer
Returns:
-1 on error

number of args on EasyDbus_signal object.

Definition at line 366 of file signal.c.

References EasyDbus_signal::args.

00367 {
00368    return (signal ? (int) signal->args : -1);
00369 }

const char* easydbus_signal_get_destination ( EasyDbus_signal signal  ) 

Get destination of signal.

Precondition:
signal != NULL
Parameters:
signal EasyDbus_signal object pointer
Returns:
signal interface string.

NULL on error or no destination set.

Definition at line 281 of file signal.c.

References EasyDbus_signal::destination.

00282 {
00283    return (signal ? (const char *) signal->destination : NULL);
00284 }

const EasyDbus_elem* easydbus_signal_get_element ( EasyDbus_signal signal,
unsigned int  n 
)

Get N-element of EasyDbus_signal object.

Precondition:
signal != NULL n >= 1 && n <= signal arguments number
Parameters:
signal EasyDbus_signal object pointer
n element to recover.
Returns:
NULL on error

pointer to n-EasyDbus_elem of signal.

Definition at line 382 of file signal.c.

References EasyDbus_signal::args, easydbus_elem_get_element(), and EasyDbus_signal::first.

00384 {
00385    return ((signal && n <= signal->args) ? 
00386             easydbus_elem_get_element (signal->first, n) : NULL);
00387 }

Here is the call graph for this function:

const char* easydbus_signal_get_interface ( EasyDbus_signal signal  ) 

Get interface of signal.

Precondition:
signal != NULL
Parameters:
signal EasyDbus_signal object pointer
Returns:
signal interface string.

NULL on error or no interface set.

Definition at line 267 of file signal.c.

References EasyDbus_signal::interface.

00268 {
00269    return (signal ? (const char *) signal->interface : NULL);
00270 }

const char* easydbus_signal_get_name ( EasyDbus_signal signal  ) 

Get name of signal.

Precondition:
signal != NULL
Parameters:
signal EasyDbus_signal object pointer
Returns:
signal name string.

NULL on error.

Definition at line 239 of file signal.c.

References EasyDbus_signal::name.

00240 {
00241    return (signal ? (const char *) signal->name : NULL);
00242 }

const char* easydbus_signal_get_path ( EasyDbus_signal signal  ) 

Get path of signal.

Precondition:
signal != NULL
Parameters:
signal EasyDbus_signal object pointer
Returns:
signal path string.

NULL on error or no path set.

Definition at line 253 of file signal.c.

References EasyDbus_signal::path.

00254 {
00255    return (signal ? (const char *) signal->path : NULL);
00256 }

const char* easydbus_signal_get_sender ( EasyDbus_signal signal  ) 

Get sender of signal.

Precondition:
signal != NULL
Parameters:
signal EasyDbus_signal object pointer
Returns:
signal sender string.

NULL on error or no sender set.

Definition at line 295 of file signal.c.

References EasyDbus_signal::sender.

00296 {
00297   return (signal ? (const char *) signal->sender : NULL);
00298 }

enum easydbus_ret_values easydbus_signal_send ( EasyDbus_conn data,
EasyDbus_signal signal 
)

Send signal message.

Precondition:
signal != NULL && data != NULL
Parameters:
data EasyDbus_conn object pointer
signal EasyDbus_signal object pointer
Returns:
EASYDBUS_ERROR on error

EASYDBUS_SIGNAL_NOT_SENT signal not sent.

EASYDBUS_SIGNAL_SENT signal sent

Definition at line 400 of file signal.c.

References create_signal_msg(), EASYDBUS_ERROR, easydbus_message_send(), EASYDBUS_SIGNAL_NOT_SENT, and EASYDBUS_SIGNAL_SENT.

00402 {
00403    struct EasyDbus_core *core = (struct EasyDbus_core *) data;
00404    int ret_val = EASYDBUS_SIGNAL_NOT_SENT;
00405 
00406    if (!data || !signal)
00407       return EASYDBUS_ERROR;
00408 
00409    DBusMessage *msg = create_signal_msg (core, signal);
00410 
00411    if (!msg)
00412       return EASYDBUS_ERROR;
00413 
00414    if (!easydbus_message_send (core, msg, 1, NULL))
00415       ret_val = EASYDBUS_SIGNAL_SENT;
00416 
00417    dbus_message_unref (msg);
00418 
00419    return ret_val;
00420 }

Here is the call graph for this function:

int easydbus_signal_set_destination ( EasyDbus_signal signal,
const char *  destination 
)

Set destination of signal.

Precondition:
signal != NULL && sender != NULL
Parameters:
signal EasyDbus_signal object pointer
destination destination to insert on signal object.
Returns:
-1 on error

0 ok

Definition at line 338 of file signal.c.

References EasyDbus_signal::destination, and EASYDBUS_MEMCOPY.

Referenced by easydbus_signal_build_skeleton().

00340 {
00341    unsigned int string_length = 0;
00342 
00343    if (!destination || !signal || signal->destination) 
00344       return -1;
00345 
00346    string_length = strlen (destination) + 1;
00347    signal->destination = (char *) malloc (string_length);
00348    if (!signal->destination)
00349       return -1;
00350 
00351    EASYDBUS_MEMCOPY (signal->destination, destination,
00352                      string_length);
00353 
00354    return 0;
00355 }

int easydbus_signal_set_sender ( EasyDbus_signal signal,
const char *  sender 
)

Set sender of signal.

Precondition:
signal != NULL && sender != NULL
Parameters:
signal EasyDbus_signal object pointer
sender sender to insert on signal object.
Returns:
-1 on error

0 ok

Definition at line 310 of file signal.c.

References EASYDBUS_MEMCOPY, and EasyDbus_signal::sender.

Referenced by easydbus_signal_build_skeleton(), and easydbus_signal_handler().

00312 {
00313    unsigned int string_length = 0;
00314 
00315    if (!sender || !signal || signal->sender) 
00316       return -1;
00317 
00318    string_length = strlen (sender) + 1;
00319    signal->sender = (char *) malloc (string_length);
00320    if (!signal->sender)
00321       return -1;
00322 
00323    EASYDBUS_MEMCOPY (signal->sender, sender, string_length);
00324 
00325    return 0;
00326 }


Generated on Thu Apr 10 10:02:19 2008 for EasyDbus-0.2 by  doxygen 1.5.4