Functions to communicate with the daemon via dbus
[Libpower]


Modules

 Client capabilities: Capabilities

Defines

#define PS_DBUS_SERVICE   "com.novell.powersave"
#define PS_DBUS_ACTION_INTERFACE   "com.novell.powersave.action"
#define PS_DBUS_ADMIN_INTERFACE   "com.novell.powersave.admin"
#define PS_DBUS_REQUEST_INTERFACE   "com.novell.powersave.request"
#define PS_DBUS_MANAGER_INTERFACE   "com.novell.powersave.manager"
#define PS_DBUS_SCRIPTS_INTERFACE   "com.novell.powersave.scripts"
#define PS_DBUS_CLIENT_INTERFACE   "com.novell.kpowersave"
#define PS_DBUS_PATH   "/com/novell/powersave"

Enumerations

enum  DBUS_ERROR {
  REPLY_SUCCESS, REPLY_NO_CONNECTION, REPLY_NO_RIGHTS, REPLY_INVALID_PARAM,
  REPLY_INVALID_METHOD, REPLY_INVALID_INTERFACE, REPLY_HW_NOT_SUPPORTED, REPLY_DISABLED,
  REPLY_ALREADY_SET, REPLY_DBUS_ERROR, REPLY_GENERAL_ERROR, REPLY_INVALID_MESSAGE_TYPE,
  REPLY_ERROR_MAX
}
 dbus error message ids. They can be mapped to the DBus_Error_Array string array below More...
enum  POWERSAVE_MESSAGE_TYPE {
  MANAGER_MESSAGE, REQUEST_MESSAGE, ACTION_MESSAGE, SCRIPTS_MESSAGE,
  ADMIN_MESSAGE, CLIENT_MESSAGE
}
 Enum for the interface to use. More...

Functions

void dbusFree (void)
 frees and closes the connection to DBus
int dbusGetMessageString (DBusMessage *msg, char **s, int no)
 get a string argument from a dbus messsage
int dbusGetMessageInteger (DBusMessage *msg, int *i, int no)
 get an integer argument from a dbus messsage
int dbusGetMessageErrorID (DBusMessage *msg, unsigned *error_id)
 get the DBUS_ERROR id from a reply
unsigned dbusSendSimpleMessage (int msg_type, const char *method)
 Send a message to the powersave daemon and receive the reply.
unsigned dbusSendSimpleMessageWithReply (int msg_type, DBusMessage **reply, const char *method)
 send a message to the daemon and receive the reply
unsigned dbusSendMessage (int msg_type, const char *method, int first_arg_type,...)
 send message to the daemon with arguments
unsigned dbusSendMessageWithReply (int msg_type, DBusMessage **reply, const char *method, int first_arg_type,...)
 send a message to the daemon with arguments and receive the reply
dbus_int32_t establishConnection (int capabilities, DBusConnection *connection)
 establishes a connection to the daemon

Variables

char * DBus_Error_Array [REPLY_ERROR_MAX]

Define Documentation

#define PS_DBUS_ACTION_INTERFACE   "com.novell.powersave.action"
 

#define PS_DBUS_ADMIN_INTERFACE   "com.novell.powersave.admin"
 

#define PS_DBUS_CLIENT_INTERFACE   "com.novell.kpowersave"
 

#define PS_DBUS_MANAGER_INTERFACE   "com.novell.powersave.manager"
 

#define PS_DBUS_PATH   "/com/novell/powersave"
 

#define PS_DBUS_REQUEST_INTERFACE   "com.novell.powersave.request"
 

#define PS_DBUS_SCRIPTS_INTERFACE   "com.novell.powersave.scripts"
 

#define PS_DBUS_SERVICE   "com.novell.powersave"
 


Enumeration Type Documentation

enum DBUS_ERROR
 

dbus error message ids. They can be mapped to the DBus_Error_Array string array below

Enumerator:
REPLY_SUCCESS 
REPLY_NO_CONNECTION 
REPLY_NO_RIGHTS 
REPLY_INVALID_PARAM 
REPLY_INVALID_METHOD 
REPLY_INVALID_INTERFACE 
REPLY_HW_NOT_SUPPORTED 
REPLY_DISABLED 
REPLY_ALREADY_SET 
REPLY_DBUS_ERROR 
REPLY_GENERAL_ERROR 
REPLY_INVALID_MESSAGE_TYPE 
REPLY_ERROR_MAX 

enum POWERSAVE_MESSAGE_TYPE
 

Enum for the interface to use.

Enumerator:
MANAGER_MESSAGE 
REQUEST_MESSAGE 
ACTION_MESSAGE 
SCRIPTS_MESSAGE 
ADMIN_MESSAGE 
CLIENT_MESSAGE 


Function Documentation

void dbusFree void   ) 
 

frees and closes the connection to DBus

Call this inside your application as soon as the dbus daemon brakes away

int dbusGetMessageErrorID DBusMessage *  msg,
unsigned *  error_id
 

get the DBUS_ERROR id from a reply

if sendMessageWithReply was unsuccessful (returned !REPLY_SUCCESS) you may want to use this function to get the contents of the reply.

Parameters:
msg The message where the contents should be read from
error_id pointer to an integer that gets filled with the error_id
Returns:
negative on failure, zero on success
Return values:
DBUS_ERROR 

int dbusGetMessageInteger DBusMessage *  msg,
int *  i,
int  no
 

get an integer argument from a dbus messsage

if sendMessageWithReply was successful (returned REPLY_SUCCESS) you may want to use this function to get the contents of the reply.

Parameters:
msg The message where the contents should be read from
i pointer to an integer value that gets filled with the desired value
no The Xth integer that was added to the message that i should be filled with (starting from 0)
Returns:
negative on failure, zero on success
Return values:
DBUS_ERROR 

int dbusGetMessageString DBusMessage *  msg,
char **  s,
int  no
 

get a string argument from a dbus messsage

if sendMessageWithReply was successful (returned REPLY_SUCCESS) you may want to use this function to get the contents of the reply.

Parameters:
msg The message where the contents should be read from
s The char double pointer that gets filled with the desired string
no The Xth string that was added to the message that s should be filled with (starting from 0)
Returns:
negative on failure, zero on success
Return values:
DBUS_ERROR 

unsigned dbusSendMessage int  msg_type,
const char *  method,
int  first_arg_type,
  ...
 

send message to the daemon with arguments

Parameters:
msg_type POWERSAVE_MESSAGE_TYPE
method the dbus method to invoke
first_arg_type the type of the first argument. End the list with DBUS_TYPE_INVALID
Returns:
DBUS_ERROR

unsigned dbusSendMessageWithReply int  msg_type,
DBusMessage **  reply,
const char *  method,
int  first_arg_type,
  ...
 

send a message to the daemon with arguments and receive the reply

Parameters:
msg_type POWERSAVE_MESSAGE_TYPE
reply double pointer in which the reply get stored
method the dbus method to invoke
first_arg_type the type of the first argument. End the list with DBUS_TYPE_INVALID
Returns:
DBUS_ERROR

unsigned dbusSendSimpleMessage int  msg_type,
const char *  method
 

Send a message to the powersave daemon and receive the reply.

You can only use the REQUEST and ACTION interface (msg_type) and you need to know what request/action you want to send and give the appropriate params for.

Use the dbus type definitions and let the varargs end with DBUS_TYPE_INVALID (also see the dbus doc/code for the function dbus_message_append_args(...)

E.g.:

 DBusMessage *reply;
 int ret;
 char *scheme = "performance";
 ret = dbus_send_message(REQUEST, &reply, "set_scheme",
                         DBUS_TYPE_STRING, &scheme, DBUS_TYPE_INVALID);
 if (ret == REPLY_SUCCESS){
        // PROCESS MESSAGE;
        dbus_message_unref(reply)
 }
 else{ // Handle error - no need to unref reply 
 } 

Tries to set the current scheme ("set_scheme" -> method name) to "performance" (special argument for "set_scheme" messages)

Parameters:
msg_type POWERSAVE_MESSAGE_TYPE
method the dbus method to invoke
Returns:
The error code (see DBUS_ERROR . Use DBus_Error_Array[RET_VAL] to get the corresponding error string).

unsigned dbusSendSimpleMessageWithReply int  msg_type,
DBusMessage **  reply,
const char *  method
 

send a message to the daemon and receive the reply

Parameters:
msg_type POWERSAVE_MESSAGE_TYPE
reply double pointer in which the reply get stored
method the dbus method to invoke
Returns:
DBUS_ERROR

dbus_int32_t establishConnection int  capabilities,
DBusConnection *  connection
 

establishes a connection to the daemon

Parameters:
capabilities sum of integers from powersave_clientsocket.h
connection the dbus connection from which the client's name is taken
Returns:
DBUS_ERROR


Variable Documentation

char* DBus_Error_Array[REPLY_ERROR_MAX]
 


Generated on Mon Mar 27 09:27:20 2006 for Powersave Daemon by  doxygen 1.4.6