summaryrefslogtreecommitdiffstats
path: root/src/CLI
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-10-30 22:50:39 +0100
committerKarel Klic <kklic@redhat.com>2009-10-30 22:50:39 +0100
commit0843e750bce39df0e69e4962b3c7f98294d0739b (patch)
treef0be3fd68da8908e4db6152f5f91166a4b3c3b28 /src/CLI
parentd6f85d204994b7f4a7afe943f4d5fa873599cd01 (diff)
downloadabrt-0843e750bce39df0e69e4962b3c7f98294d0739b.tar.gz
abrt-0843e750bce39df0e69e4962b3c7f98294d0739b.tar.xz
abrt-0843e750bce39df0e69e4962b3c7f98294d0739b.zip
Receive and print Warning and Update messages during remode procedure calls
Diffstat (limited to 'src/CLI')
-rw-r--r--src/CLI/dbus.cpp76
1 files changed, 66 insertions, 10 deletions
diff --git a/src/CLI/dbus.cpp b/src/CLI/dbus.cpp
index 420fe703..98fe9ac1 100644
--- a/src/CLI/dbus.cpp
+++ b/src/CLI/dbus.cpp
@@ -35,18 +35,74 @@ static DBusMessage* new_call_msg(const char* method)
static DBusMessage* send_get_reply_and_unref(DBusMessage* msg)
{
- DBusError err;
- dbus_error_init(&err);
- DBusMessage *reply;
- reply = dbus_connection_send_with_reply_and_block(s_dbus_conn,
- msg, /*timeout*/ -1, &err);
- if (reply == NULL)
+ dbus_uint32_t serial;
+ if (TRUE != dbus_connection_send(s_dbus_conn, msg, &serial))
+ error_msg_and_die("Error sending DBus message");
+ dbus_message_unref(msg);
+
+ while (true)
{
- //TODO: analyse err
- error_msg_and_die("Error sending DBus message");
+ DBusMessage *received = dbus_connection_pop_message(s_dbus_conn);
+ if (!received)
+ {
+ if (FALSE == dbus_connection_read_write(s_dbus_conn, -1))
+ error_msg_and_die("Connection to ABRT daemon closed.");
+
+ continue;
+ }
+
+ /* Debugging*/
+ /*
+ const char *sender = dbus_message_get_sender(received);
+ if (sender)
+ printf("sender: %s\n", sender);
+ const char *path = dbus_message_get_path(received);
+ if (path)
+ printf("path: %s\n", path);
+ const char *member = dbus_message_get_member(received);
+ if (member)
+ printf("member: %s\n", member);
+ const char *interface = dbus_message_get_interface(received);
+ if (interface)
+ printf("interface: %s\n", interface);
+ const char *destination = dbus_message_get_destination(received);
+ if (destination)
+ printf("destination: %s\n", destination);
+ */
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ if (dbus_message_is_signal(received, CC_DBUS_IFACE, "Update"))
+ {
+ const char *update_msg;
+ if (!dbus_message_get_args(received, &err,
+ DBUS_TYPE_STRING, &update_msg,
+ DBUS_TYPE_INVALID))
+ {
+ error_msg_and_die("dbus Update message: arguments mismatch");
+ }
+ printf(">> %s\n", update_msg);
+ }
+ else if (dbus_message_is_signal(received, CC_DBUS_IFACE, "Warning"))
+ {
+ const char *warning_msg;
+ if (!dbus_message_get_args(received, &err,
+ DBUS_TYPE_STRING, &warning_msg,
+ DBUS_TYPE_INVALID))
+ {
+ error_msg_and_die("dbus Update message: arguments mismatch");
+ }
+ printf(">! %s\n", warning_msg);
+ }
+ else if (dbus_message_get_type(received) == DBUS_MESSAGE_TYPE_METHOD_RETURN &&
+ dbus_message_get_reply_serial(received) == serial)
+ {
+ return received;
+ }
+
+ dbus_message_unref(received);
}
- dbus_message_unref(msg);
- return reply;
}
vector_crash_infos_t call_GetCrashInfos()