summaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-02-10 18:04:43 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-02-10 18:04:43 +0100
commit2abf0fc078221715abbd20c8451d300eaf787848 (patch)
tree1dc278a78fda61ad68bcb889fd3f8c94b532900b /src/cli
parent394508ab25eb2a78a40cde19714e9afa2537c393 (diff)
downloadabrt-2abf0fc078221715abbd20c8451d300eaf787848.tar.gz
abrt-2abf0fc078221715abbd20c8451d300eaf787848.tar.xz
abrt-2abf0fc078221715abbd20c8451d300eaf787848.zip
abrt-gtk: make Delete key actually delete the dump dir
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/CLI.cpp15
-rw-r--r--src/cli/Makefile.am3
-rw-r--r--src/cli/dbus.cpp160
-rw-r--r--src/cli/dbus.h30
-rw-r--r--src/cli/report.cpp1
5 files changed, 4 insertions, 205 deletions
diff --git a/src/cli/CLI.cpp b/src/cli/CLI.cpp
index e322e7cd..0e902b9e 100644
--- a/src/cli/CLI.cpp
+++ b/src/cli/CLI.cpp
@@ -21,9 +21,7 @@
#include <getopt.h>
#include "abrtlib.h"
#include "abrt_dbus.h"
-#include "dbus_common.h"
#include "report.h"
-#include "dbus.h"
/** Creates a localized string from crash time. */
static char *localize_crash_time(const char *timestr)
@@ -410,11 +408,6 @@ int main(int argc, char** argv)
print_usage_and_die(argv[0]);
}
- DBusError err;
- dbus_error_init(&err);
- s_dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
- handle_dbus_err(s_dbus_conn == NULL, &err);
-
/* Do the selected operation. */
int exitcode = 0;
switch (op)
@@ -469,12 +462,10 @@ int main(int argc, char** argv)
}
dd_close(dd);
}
+
/* Ask abrtd to do it for us */
- exitcode = call_DeleteDebugDump(dump_dir_name);
- if (exitcode == ENOENT)
- error_msg_and_die("Crash '%s' not found", dump_dir_name);
- if (exitcode != 0)
- error_msg_and_die("Can't delete debug dump '%s'", dump_dir_name);
+ exitcode = connect_to_abrtd_and_call_DeleteDebugDump(dump_dir_name);
+
break;
}
case OPT_INFO:
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 41a600c6..0a5c6e1a 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -3,8 +3,7 @@ bin_PROGRAMS = abrt-cli
abrt_cli_SOURCES = \
CLI.cpp \
run-command.h run-command.c \
- report.h report.cpp \
- dbus.h dbus.cpp
+ report.h report.cpp
abrt_cli_CPPFLAGS = \
-I$(srcdir)/../include/report -I$(srcdir)/../include \
-I$(srcdir)/../lib \
diff --git a/src/cli/dbus.cpp b/src/cli/dbus.cpp
deleted file mode 100644
index 9c2bfbd6..00000000
--- a/src/cli/dbus.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "dbus.h"
-#include "dbus_common.h"
-
-DBusConnection* s_dbus_conn;
-
-/*
- * DBus member calls
- */
-
-/* helpers */
-static DBusMessage* new_call_msg(const char* method)
-{
- DBusMessage* msg = dbus_message_new_method_call(ABRTD_DBUS_NAME, ABRTD_DBUS_PATH, ABRTD_DBUS_IFACE, method);
- if (!msg)
- die_out_of_memory();
- return msg;
-}
-
-static DBusMessage* send_get_reply_and_unref(DBusMessage* msg)
-{
- 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)
- {
- 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("dbus connection closed");
- continue;
- }
-
- int tp = dbus_message_get_type(received);
- const char *error_str = dbus_message_get_error_name(received);
-#if 0
- /* Debugging */
- printf("type:%u (CALL:%u, RETURN:%u, ERROR:%u, SIGNAL:%u)\n", tp,
- DBUS_MESSAGE_TYPE_METHOD_CALL,
- DBUS_MESSAGE_TYPE_METHOD_RETURN,
- DBUS_MESSAGE_TYPE_ERROR,
- DBUS_MESSAGE_TYPE_SIGNAL
- );
- 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);
- if (error_str)
- printf("error: '%s'\n", error_str);
-#endif
-
- DBusError err;
- dbus_error_init(&err);
-
- if (dbus_message_is_signal(received, ABRTD_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, ABRTD_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 Warning message: arguments mismatch");
- }
- log(">! %s\n", warning_msg);
- }
- else
- if (tp == DBUS_MESSAGE_TYPE_METHOD_RETURN
- && dbus_message_get_reply_serial(received) == serial
- ) {
- return received;
- }
- else
- if (tp == DBUS_MESSAGE_TYPE_ERROR
- && dbus_message_get_reply_serial(received) == serial
- ) {
- error_msg_and_die("dbus call returned error: '%s'", error_str);
- }
-
- dbus_message_unref(received);
- }
-}
-
-void handle_dbus_err(bool error_flag, DBusError *err)
-{
- if (dbus_error_is_set(err))
- {
- error_msg("dbus error: %s", err->message);
- /* dbus_error_free(&err); */
- error_flag = true;
- }
- if (!error_flag)
- return;
- error_msg_and_die(
- "error requesting DBus name %s, possible reasons: "
- "abrt run by non-root; dbus config is incorrect; "
- "or dbus daemon needs to be restarted to reload dbus config",
- ABRTD_DBUS_NAME);
-}
-
-int32_t call_DeleteDebugDump(const char* crash_id)
-{
- DBusMessage* msg = new_call_msg(__func__ + 5);
- dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &crash_id,
- DBUS_TYPE_INVALID);
-
- DBusMessage *reply = send_get_reply_and_unref(msg);
-
- DBusMessageIter in_iter;
- dbus_message_iter_init(reply, &in_iter);
-
- int32_t result;
- int r = load_val(&in_iter, result);
- if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */
- error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5);
-
- dbus_message_unref(reply);
- return result;
-}
diff --git a/src/cli/dbus.h b/src/cli/dbus.h
deleted file mode 100644
index efaceca8..00000000
--- a/src/cli/dbus.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef ABRT_CLI_DBUS_H
-#define ABRT_CLI_DBUS_H
-
-#include "abrt_dbus.h"
-#include "abrt_crash_data.h"
-
-extern DBusConnection* s_dbus_conn;
-
-int32_t call_DeleteDebugDump(const char* crash_id);
-
-void handle_dbus_err(bool error_flag, DBusError *err);
-
-#endif
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 5c85fa28..7f317f05 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -17,7 +17,6 @@
*/
#include "report.h"
#include "run-command.h"
-#include "dbus.h"
#include "abrtlib.h"
/* Field separator for the crash report file that is edited by user. */