diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-09-21 12:53:10 +0200 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-09-21 12:53:10 +0200 |
| commit | bf51f658d5aff2a39f37d99893d79a667108de10 (patch) | |
| tree | 463cc783892e1ba667220d63d8ed5220648203ba /lib/Utils | |
| parent | 902a90a214dc7c41e11375a051cadca826c71f7b (diff) | |
| parent | 317ebe45bdb9ecfdf1d44e98d84ea961bb48d111 (diff) | |
| download | abrt-bf51f658d5aff2a39f37d99893d79a667108de10.tar.gz abrt-bf51f658d5aff2a39f37d99893d79a667108de10.tar.xz abrt-bf51f658d5aff2a39f37d99893d79a667108de10.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib/Utils')
| -rw-r--r-- | lib/Utils/CrashTypesSocket.cpp | 1 | ||||
| -rw-r--r-- | lib/Utils/DebugDump.cpp | 8 | ||||
| -rw-r--r-- | lib/Utils/Observer.h | 1 | ||||
| -rw-r--r-- | lib/Utils/abrt_dbus.cpp | 4 | ||||
| -rw-r--r-- | lib/Utils/abrt_dbus.h | 37 |
5 files changed, 41 insertions, 10 deletions
diff --git a/lib/Utils/CrashTypesSocket.cpp b/lib/Utils/CrashTypesSocket.cpp index dbbc163..7c206de 100644 --- a/lib/Utils/CrashTypesSocket.cpp +++ b/lib/Utils/CrashTypesSocket.cpp @@ -21,7 +21,6 @@ #include "abrtlib.h" #include "CrashTypesSocket.h" -#include <sstream> /** * A request GET_CRASH_INFOS has the following form: diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 03fb7c6..a36594b 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -22,7 +22,6 @@ #include <fstream> #include <iostream> #include <sstream> -#include <cerrno> #include <sys/utsname.h> #include <magic.h> #include "abrtlib.h" @@ -106,7 +105,6 @@ static int GetAndSetLock(const char* pLockFile, const char* pPID) if (errno != EEXIST) perror_msg_and_die("Can't create lock file '%s'", pLockFile); fd = open(pLockFile, O_RDONLY); -log("opened O_RDONLY: '%s'", pLockFile); if (fd < 0) { if (errno == ENOENT) @@ -125,7 +123,6 @@ log("opened O_RDONLY: '%s'", pLockFile); continue; } pid_buf[r] = '\0'; -log("read: '%s'", pid_buf); if (strcmp(pid_buf, pPID) == 0) { log("Lock file '%s' is already locked by us", pLockFile); @@ -143,7 +140,6 @@ log("read: '%s'", pid_buf); /* The file may be deleted by now by other process. Ignore errors */ unlink(pLockFile); } -log("created O_EXCL: '%s'", pLockFile); int len = strlen(pPID); if (write(fd, pPID, len) != len) @@ -331,10 +327,8 @@ void CDebugDump::SaveKernelArchitectureRelease() void CDebugDump::SaveTime() { - std::stringstream ss; time_t t = time(NULL); - ss << t; - SaveText(FILENAME_TIME, ss.str()); + SaveText(FILENAME_TIME, to_string(t)); } static void LoadTextFile(const std::string& pPath, std::string& pData) diff --git a/lib/Utils/Observer.h b/lib/Utils/Observer.h index 421dc0c..d6ec6f3 100644 --- a/lib/Utils/Observer.h +++ b/lib/Utils/Observer.h @@ -2,7 +2,6 @@ #define OBSERVER_H_ #include <string> -#include <iostream> #include <stdint.h> #include "DBusCommon.h" diff --git a/lib/Utils/abrt_dbus.cpp b/lib/Utils/abrt_dbus.cpp index 37d6d3e..ad23d56 100644 --- a/lib/Utils/abrt_dbus.cpp +++ b/lib/Utils/abrt_dbus.cpp @@ -264,6 +264,10 @@ void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn, const char* object_path, DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data) ) { + if (g_dbus_conn) + error_msg_and_die("Internal bug: can't connect to more than one dbus"); + g_dbus_conn = conn; + //do we need this? why? //log("dbus_connection_set_dispatch_status_function"); // dbus_connection_set_dispatch_status_function(conn, diff --git a/lib/Utils/abrt_dbus.h b/lib/Utils/abrt_dbus.h index 731f1c1..09063c5 100644 --- a/lib/Utils/abrt_dbus.h +++ b/lib/Utils/abrt_dbus.h @@ -8,8 +8,43 @@ extern DBusConnection* g_dbus_conn; /* * Glib integration machinery */ + +/* Hook up to DBus and to glib main loop. + * Usage cases: + * + * - server: + * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err); + * attach_dbus_conn_to_glib_main_loop(conn, "/some/path", handler_of_calls_to_some_path); + * rc = dbus_bus_request_name(conn, "server.name", DBUS_NAME_FLAG_REPLACE_EXISTING, &err); + * + * - client which does not receive signals (only makes calls and emits signals): + * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err); + * // needed only if you need to use async dbus calls (not shown below): + * attach_dbus_conn_to_glib_main_loop(conn); + * // syncronous method call: + * msg = dbus_message_new_method_call("some.serv", "/path/on/serv", "optional.iface.on.serv", "method_name"); + * reply = dbus_connection_send_with_reply_and_block(conn, msg, timeout, &err); + * // emitting signal: + * msg = dbus_message_new_signal("/path/sig/emitted/from", "iface.sig.emitted.from", "sig_name"); + * // (note: "iface.sig.emitted.from" is not optional for signals!) + * dbus_message_set_destination(msg, "peer"); // optional + * dbus_connection_send(conn, msg, &serial); // &serial can be NULL + * + * - client which receives and processes signals: + * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err); + * attach_dbus_conn_to_glib_main_loop(conn); + * dbus_connection_add_filter(conn, handle_message, NULL, NULL) + * dbus_bus_add_match(system_conn, "type='signal',...", &err); + * // signal is a dbus message which looks like this: + * // sender=XXX dest=YYY(or null) path=/path/sig/emitted/from interface=iface.sig.emitted.from member=sig_name + * // and handler_for_signals(conn,msg,opaque) will be called by glib + * // main loop to process received signals (and other messages + * // if you ask for them in dbus_bus_add_match[es], but this + * // would turn you into a server if you handle them too) ;] + */ void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn, - const char* object_path_to_register = NULL, /* NULL if you are just a client */ + /* NULL if you are just a client */ + const char* object_path_to_register = NULL, /* makes sense only if you use object_path_to_register: */ DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data) = NULL ); |
