EdbusConnection.h
/*
* $Id: EdbusConnection.h 3401 2012-08-29 07:57:30Z karijes $
*
* D-BUS stuff
* Copyright (c) 2008 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_EDBUSCONNECTION_H__
#define __EDELIB_EDBUSCONNECTION_H__
#include "EdbusMessage.h"
#include "EdbusError.h"
EDELIB_NS_BEGIN
#define EDBUS_INTROSPECTION_DTD \
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \n" \
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n\n"
enum EdbusConnectionType {
EDBUS_SYSTEM,
EDBUS_SESSION
};
enum EdbusNameMode {
EDBUS_NAME_NO_REPLACE = 0,
EDBUS_NAME_ALLOW_REPLACE = 1,
EDBUS_NAME_REPLACE_EXISTING = 2
};
typedef int (*EdbusCallback)(const EdbusMessage*, void*);
#ifndef SKIP_DOCS
struct EdbusConnImpl;
#endif
class EDELIB_API EdbusConnection {
private:
EdbusConnImpl* dc;
void setup_filter(void);
E_DISABLE_CLASS_COPY(EdbusConnection)
public:
EdbusConnection();
~EdbusConnection();
bool connect(EdbusConnectionType ctype);
void disconnect(void);
bool connected(void);
bool send(const EdbusMessage& content);
bool send_with_reply_and_block(const EdbusMessage& content, int timeout_ms, EdbusMessage& ret);
bool request_name(const char* name, int mode = EDBUS_NAME_NO_REPLACE);
const char* unique_name(void);
void signal_callback(EdbusCallback cb, void* data);
void method_callback(EdbusCallback cb, void* data);
void add_signal_match(const char* path, const char* interface, const char* name);
void add_method_match(const char* path, const char* interface, const char* name);
void register_object(const char* path);
void unregister_object(const char* path);
void setup_listener(void);
void setup_listener_with_fltk(void);
int wait(int timeout_ms);
EdbusError* error(void);
};
EDELIB_NS_END
#endif
edelib::EdbusConnection
D-Bus connection and data sender.
Definition: EdbusConnection.h:154
edelib::EDBUS_NAME_REPLACE_EXISTING
Force replacement.
Definition: EdbusConnection.h:61
edelib::EdbusCallback
int(* EdbusCallback)(const EdbusMessage *, void *)
Definition: EdbusConnection.h:68
edelib::EdbusNameMode
EdbusNameMode
What to do when known name is acquired.
Definition: EdbusConnection.h:58
edelib::EDBUS_SYSTEM
System bus.
Definition: EdbusConnection.h:49
edelib::EDBUS_NAME_ALLOW_REPLACE
Existing name can be replaced.
Definition: EdbusConnection.h:60
edelib::EDBUS_SESSION
Session bus.
Definition: EdbusConnection.h:50
edelib::EdbusMessage
Data transporter for D-Bus.
Definition: EdbusMessage.h:104
E_DISABLE_CLASS_COPY
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
edelib::EDBUS_NAME_NO_REPLACE
Do not replace existing name.
Definition: EdbusConnection.h:59
edelib::EdbusConnectionType
EdbusConnectionType
Represents connection either to system or session bus.
Definition: EdbusConnection.h:48
edelib::EdbusError
A class representing D-Bus error.
Definition: EdbusError.h:70