reply_internal
[message_internal]

Collaboration diagram for reply_internal:

Detailed Description

Module for manage EasyDbus Reply_msg objects internal

TO COMPLETE

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

Reply_msg Meta Information

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


Functions

int easydbus_reply_build_error (struct EasyDbus_method *method, const char *error_msg)
 Create Error reply.
int easydbus_reply_build_struct (struct EasyDbus_method *method, DBusMessage *reply)
 Create EasyDbus_reply for an EasyDbus_method object from a DBusMessage reply.
DBusMessage * easydbus_reply_create_msg (struct EasyDbus_core *core, struct EasyDbus_reply *reply, DBusMessage *method_msg)
 Create DBusMessage for reply.
int easydbus_reply_send (struct EasyDbus_core *core, DBusMessage *method_msg, struct EasyDbus_reply *reply)
 Send reply on DBus bus.
int easydbus_reply_send_error (struct EasyDbus_core *core, DBusMessage *msg, char *error_name, char *error_string)
 Send error reply.


Function Documentation

int easydbus_reply_build_error ( struct EasyDbus_method method,
const char *  error_msg 
)

Create Error reply.

Parameters:
method EasyDbus_method object pointer where is created error reply for user.
error_msg string with error message.
Returns:
-1 error

0 ok

For internal use only.

Definition at line 286 of file reply.c.

References easydbus_add_string_param_to_skeleton(), EASYDBUS_ET_FAILURE, EASYDBUS_ET_REPLY, easydbus_reply_create_skeleton(), easydbus_reply_free_skeleton(), EasyDbus_method::reply, and EasyDbus_reply::type.

Referenced by easydbus_send_method_withReply_Blocking().

00288 {
00289    struct EasyDbus_reply *reply_foruser = NULL;
00290 
00291    reply_foruser = easydbus_reply_create_skeleton ();
00292    if (!reply_foruser)
00293       return -1;
00294 
00295    if (easydbus_add_string_param_to_skeleton
00296        (EASYDBUS_ET_REPLY, reply_foruser, (char *) error_msg))
00297       goto out_of_memory;
00298 
00299    reply_foruser->type = EASYDBUS_ET_FAILURE;
00300    method->reply = reply_foruser;
00301 
00302    return 0;
00303  out_of_memory:
00304    if (reply_foruser)
00305       easydbus_reply_free_skeleton (reply_foruser);
00306    return -1;
00307 }

Here is the call graph for this function:

int easydbus_reply_build_struct ( struct EasyDbus_method method,
DBusMessage *  reply 
)

Create EasyDbus_reply for an EasyDbus_method object from a DBusMessage reply.

Parameters:
method EasyDbus_method object pointer
reply DBusMessage with reply data
Returns:
0 ok

-1 error

For internal use only.

Definition at line 319 of file reply.c.

References easydbus_build_skeleton_data(), EASYDBUS_ET_INVALID, EASYDBUS_ET_REPLY, easydbus_reply_create_skeleton(), easydbus_reply_free_skeleton(), easydbus_reply_set_interface(), easydbus_reply_set_path(), EasyDbusDebug, EasyDbus_method::reply, and EasyDbus_reply::type.

Referenced by easydbus_send_method_withReply_Blocking().

00321 {
00322    struct EasyDbus_reply *reply_foruser = NULL;
00323    const char *temp = NULL;
00324    int type_msg = 0;
00325 
00326    reply_foruser = easydbus_reply_create_skeleton ();
00327 
00328    if (!reply_foruser)
00329       return -1;
00330 
00331    temp = dbus_message_get_path (reply);
00332    /* see of manage case where path == NULL */
00333    //if (temp == NULL) goto out_of_memory_error;
00334 
00335    if (temp)
00336       if (easydbus_reply_set_path (reply_foruser, temp))
00337          goto out_of_memory_error;
00338 
00339    temp = dbus_message_get_interface (reply);
00340    /* see of manage case where path == NULL */
00341    //if (temp == NULL) goto out_of_memory_error;
00342 
00343    if (temp)
00344       if (easydbus_reply_set_interface (reply_foruser,
00345                                         temp))
00346          goto out_of_memory_error;
00347 
00348    type_msg = dbus_message_get_type (reply);
00349    if (type_msg == DBUS_MESSAGE_TYPE_METHOD_RETURN)
00350       reply_foruser->type = EASYDBUS_ET_REPLY;
00351    else
00352       reply_foruser->type = EASYDBUS_ET_INVALID;
00353 
00354    easydbus_build_skeleton_data (reply, EASYDBUS_ET_REPLY,
00355                                  reply_foruser);
00356 
00357    method->reply = reply_foruser;
00358    EasyDbusDebug ("Created reply object");
00359    return 0;
00360 
00361 out_of_memory_error:
00362 
00363    if (reply_foruser)
00364       easydbus_reply_free_skeleton (reply_foruser);
00365 
00366    return -1;
00367 }

Here is the call graph for this function:

DBusMessage* easydbus_reply_create_msg ( struct EasyDbus_core core,
struct EasyDbus_reply reply,
DBusMessage *  method_msg 
) [inline]

Create DBusMessage for reply.

For internal use only.

Parameters:
core EasyDbus_core object pointer
method_msg DBusMessage of message that must be replied
reply EasyDbus_reply object pointer.
Returns:
NULL on error

DBusMessage object pointer for reply.

Todo:
optimize this function and manage of errors.

Definition at line 188 of file reply.c.

References add_elems_to_msg(), EasyDbus_reply::args, EASYDBUS_ELTYPE_STRING, EASYDBUS_ET_FAILURE, EASYDBUS_ET_REPLY, EasyDbus_reply::first, EasyDbus_elem::string, EasyDbus_elem::type, and EasyDbus_reply::type.

Referenced by easydbus_reply_send().

00191 {
00192    DBusMessage *msg = NULL;
00193 
00194    if (reply->type == EASYDBUS_ET_REPLY) {
00195       /* create msg */
00196       msg = dbus_message_new_method_return (method_msg);
00197    }
00198    else if (reply->type == EASYDBUS_ET_FAILURE) {
00199       if (reply->args == 1 &&
00200           reply->first->type == EASYDBUS_ELTYPE_STRING) {
00201          msg = dbus_message_new_error (method_msg,
00202                                        DBUS_ERROR_FAILED,
00203                                        (const char *) reply->first->
00204                                        payload.string);
00205       }
00206    }
00207 
00208    if (msg && 
00209        /* add method data if there are */
00210        (reply->args && reply->type == EASYDBUS_ET_REPLY))
00211       add_elems_to_msg (msg, reply->first);
00212 
00213    return msg;
00214 }

Here is the call graph for this function:

int easydbus_reply_send ( struct EasyDbus_core core,
DBusMessage *  method_msg,
struct EasyDbus_reply reply 
)

Send reply on DBus bus.

For internal use only.

Parameters:
core EasyDbus_core object pointer
method_msg DBusMessage of message that must be replied
reply EasyDbus_reply object pointer.
Returns:
-1 error

0 ok

Definition at line 151 of file reply.c.

References easydbus_message_send(), easydbus_reply_create_msg(), and EasyDbusDebug.

Referenced by easydbus_introspect_filter_func(), and easydbus_obj_path_msg_function().

00154 {
00155    DBusMessage *msg = NULL;
00156    int ret = -1;
00157 
00158    if (!reply || !method_msg || !core) {
00159       EasyDbusDebug ("Error from input params");
00160       return -1;
00161    }
00162 
00163    msg = easydbus_reply_create_msg (core, reply, method_msg);
00164 
00165    if (msg &&
00166        !easydbus_message_send (core, msg, 1, NULL))
00167       ret = 0;
00168 
00169    if (msg)
00170       dbus_message_unref (msg);
00171 
00172    return ret;
00173 }

Here is the call graph for this function:

int easydbus_reply_send_error ( struct EasyDbus_core core,
DBusMessage *  msg,
char *  error_name,
char *  error_string 
)

Send error reply.

For internal use only.

Parameters:
core pointer to EasyDbus_core object
msg DBusMessage that needed error reply.
error_name Error name
error_string Error string
Todo:
see on dbus-specification syntax for error name string.
Returns:
-1 error

0 ok

Definition at line 64 of file reply.c.

References easydbus_message_send(), and EasyDbusDebug.

Referenced by easydbus_introspect_filter_func(), and easydbus_obj_path_msg_function().

00067 {
00068    DBusMessage *error = NULL;
00069 
00070    if (!core || !msg || !error_name || !error_string) {
00071       EasyDbusDebug ("Error from input params");
00072       return -1;
00073    }
00074 
00075    error = dbus_message_new_error (msg,
00076                                    DBUS_ERROR_FAILED,
00077                                    (const char *) error_string);
00078 
00079    if (!error)
00080       return -1;
00081 
00082    if (easydbus_message_send (core, error, 1, NULL)) {
00083       dbus_message_unref (error);
00084       return -1;
00085    }
00086    dbus_message_unref (error);
00087    return 0;
00088 }

Here is the call graph for this function:


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