[ABRT PATCH] abrt-handle-upload: switch from shell to python; send socket notification. #657
by Denys Vlasenko
This closes another unfixed detail
of issue #657 "divide abrtd into two parts to get rid of inotify"
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/daemon/abrt-handle-upload.in | 267 ++++++++++++++++++++++++++-------------
1 file changed, 180 insertions(+), 87 deletions(-)
diff --git a/src/daemon/abrt-handle-upload.in b/src/daemon/abrt-handle-upload.in
index e727db6..e258c3b 100755
--- a/src/daemon/abrt-handle-upload.in
+++ b/src/daemon/abrt-handle-upload.in
@@ -1,90 +1,183 @@
-#!/bin/sh
+#!/usr/bin/python -u
# Called by abrtd when a new file is noticed in upload directory.
# The task of this script is to unpack the file and move
# problem data found in it to abrtd spool directory.
-#
-# Usage: abrt-handle-upload [-d] ABRT_SPOOL_DIR UPLOAD_DIR FILENAME
-#
-# -d - deletes an uploaded archive
-# ABRT_SPOOL_DIR - a directory where valid uploaded archives are unpacked to
-# UPLOAD_DIR - a directory where uploaded archives are stored in
-# FILENAME - an uploaded archive file name
-
-#echo "Started: $0 $*"
-
-print_clean_and_die()
-{
- printf "%s\n" "$*"
- #echo delete_on_exit="$delete_on_exit"
- test "$delete_on_exit" && rm -rf -- $delete_on_exit
- exit $die_exitcode
-}
-
-die_exitcode=1
-delete_on_exit=""
-
-delete_archive=false
-if test x"$1" == x"-d"; then delete_archive=true; shift; fi
-
-abrt_dir="$1"
-upload_dir="$2"
-archive="$3"
-
-test -d "$abrt_dir" || print_clean_and_die "Not a directory: '$abrt_dir'"
-test -d "$upload_dir" || print_clean_and_die "Not a directory: '$upload_dir'"
-test x"${archive#/}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (starts with slash)"
-test x"${archive#.}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (starts with dot)"
-test x"${archive#*..}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains ..)"
-test x"${archive#* }" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains space)"
-# Note: next line has a tab!
-test x"${archive#* }" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains tab)"
-
-cd -- "$upload_dir" || print_clean_and_die "Can't chdir to '$upload_dir'"
-
-unpacker=""
-test x"${archive%.tar.gz}" != x"$archive" && unpacker="gunzip"
-test x"${archive%.tar.bz2}" != x"$archive" && unpacker="bunzip2"
-test x"${archive%.tar.xz}" != x"$archive" && unpacker="unxz"
-
-test "$unpacker" || print_clean_and_die "Unknown file type: '$archive'"
-
-workingdir=`mktemp -d "abrt_handle_upload.XXXXXXXXXX" --tmpdir=@LARGE_DATA_TMP_DIR@` || print_clean_and_die "Can't create working directory"
-delete_on_exit="$workingdir"
-
-tempdir="$workingdir/remote.`date +%Y-%m-%d-%H:%M:%S.%N`.$$"
-working_archive="$workingdir/$archive"
-
-if $delete_archive; then
- mv -- "$archive" "$working_archive" || print_clean_and_die "Can't move '$archive' to '$working_archive'"
-else
- cp -- "$archive" "$working_archive" || print_clean_and_die "Can't copy '$archive' to '$working_archive'"
-fi
-
-$unpacker -t -- "$working_archive" || print_clean_and_die "Verification error on '$archive'"
-
-echo "Unpacking '$archive'"
-mkdir "$tempdir" || print_clean_and_die "Can't create '$tempdir' directory"
-$unpacker <"$working_archive" | tar xf - -C "$tempdir" || print_clean_and_die "Can't unpack '$archive'"
-
-# The archive can contain either plain dump files
-# or one or more complete problem data directories.
-# Checking second possibility first.
-if test -f "$tempdir/analyzer" && test -f "$tempdir/time" && test -f "$tempdir/uid"; then
- printf "1" >"$tempdir/remote"
- mv -- "$tempdir" "$abrt_dir"
-else
- (
- cd -- "$tempdir" || exit
- for d in *; do
- test -d "$d" || continue
- printf "1" >"$d/remote"
- dst="$abrt_dir/$d"
- test -e "$dst" && dst="$abrt_dir/$d.$$"
- test -e "$dst" && continue
- mv -- "$d" "$dst"
- done
- )
-fi
-
-die_exitcode=0
-print_clean_and_die "'$archive' processed successfully"
+
+import sys
+import os
+import getopt
+import tempfile
+import shutil
+import datetime
+
+from reportclient import _, set_verbosity, error_msg_and_die, error_msg, log1, log
+import problem
+
+def spawn_and_wait(prog):
+ return os.spawnlp(os.P_WAIT, prog, prog)
+
+def write_str_to(filename, s):
+ fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0666)
+ if fd >= 0:
+ os.write(fd, s)
+ os.close(fd)
+
+if __name__ == "__main__":
+
+ # Helper: exit with cleanup
+ die_exitcode = 1
+ delete_on_exit = None
+ def print_clean_and_die(fmt, *args):
+ sys.stderr.write("%s\n" % (fmt % args))
+ if delete_on_exit:
+ shutil.rmtree(delete_on_exit, True) # True: ignore_errors
+ sys.exit(die_exitcode)
+
+ # localization
+ #init_gettext() - done by reportclient module init
+
+ verbose = 0
+ ABRT_VERBOSE = os.getenv("ABRT_VERBOSE")
+ if ABRT_VERBOSE:
+ try:
+ verbose = int(ABRT_VERBOSE)
+ except:
+ pass
+
+ progname = os.path.basename(sys.argv[0])
+ help_text = _(
+ "Usage: %s [-vd] ABRT_SPOOL_DIR UPLOAD_DIR FILENAME"
+ "\n"
+ "\n -v - Verbose"
+ "\n -d - Delete uploaded archive"
+ "\n ABRT_SPOOL_DIR - Directory where valid uploaded archives are unpacked to"
+ "\n UPLOAD_DIR - Directory where uploaded archives are stored"
+ "\n FILENAME - Uploaded archive file name"
+ "\n"
+ ) % progname
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "vdh", ["help"])
+ except getopt.GetoptError as err:
+ error_msg(err) # prints something like "option -a not recognized"
+ error_msg_and_die(help_text)
+
+ delete_archive = False
+ for opt, arg in opts:
+ if opt in ("-h", "--help"):
+ print help_text
+ sys.exit(0)
+ if opt == "-v":
+ verbose += 1
+ if opt == "-d":
+ delete_archive = True
+
+ set_verbosity(verbose)
+
+ if len(args) < 3:
+ error_msg_and_die(help_text)
+
+ abrt_dir = args[0]
+ upload_dir = args[1]
+ archive = args[2]
+
+ if not os.path.isdir(abrt_dir):
+ error_msg_and_die("Not a directory: '%s'", abrt_dir)
+
+ if not os.path.isdir(upload_dir):
+ error_msg_and_die("Not a directory: '%s'", upload_dir)
+
+ if archive[0] == "/":
+ error_msg_and_die("Skipping: '%s' (starts with slash)", archive)
+
+ if archive[0] == ".":
+ error_msg_and_die("Skipping: '%s' (starts with dot)", archive)
+
+ if ".." in archive:
+ error_msg_and_die("Skipping: '%s' (contains ..)", archive)
+
+ if " " in archive:
+ error_msg_and_die("Skipping: '%s' (contains space)", archive)
+
+ if "\t" in archive:
+ error_msg_and_die("Skipping: '%s' (contains tab)", archive)
+
+ try:
+ os.chdir(upload_dir)
+ except OSError:
+ error_msg_and_die("Can't change directory to '%s'", upload_dir)
+
+ if archive.endswith(".tar.gz"):
+ unpacker = "gunzip"
+ elif archive.endswith(".tgz"):
+ unpacker = "gunzip"
+ elif archive.endswith(".tar.bz2"):
+ unpacker = "bunzip2"
+ elif archive.endswith(".tar.xz"):
+ unpacker = "unxz"
+ else:
+ error_msg_and_die("Unknown file type: '%s'", archive)
+
+ try:
+ working_dir = tempfile.mkdtemp(prefix="abrt_handle_upload.", dir="@LARGE_DATA_TMP_DIR@")
+ except OSError:
+ error_msg_and_die("Can't create working directory in '%s'", "@LARGE_DATA_TMP_DIR@")
+ delete_on_exit = working_dir
+
+ try:
+ tempdir = working_dir + "/remote." + datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S.%f.") + str(os.getpid())
+ working_archive = working_dir + "/" + archive
+
+ if delete_archive:
+ try:
+ shutil.move(archive, working_archive)
+ except IOError:
+ print_clean_and_die("Can't move '%s' to '%s'", archive, working_archive)
+ else:
+ try:
+ shutil.copy(archive, working_archive)
+ except IOError:
+ print_clean_and_die("Can't copy '%s' to '%s'", archive, working_archive)
+
+ ex = os.spawnlp(os.P_WAIT, unpacker, unpacker, "-t", "--", working_archive)
+ if ex != 0:
+ print_clean_and_die("Verification error on '%s'", archive)
+
+ log("Unpacking '%s'", archive)
+ try:
+ os.mkdir(tempdir)
+ except OSError:
+ print_clean_and_die("Can't create '%s' directory", tempdir)
+
+ ex = os.system(unpacker+" <"+working_archive+" | tar xf - -C "+tempdir)
+ if ex != 0:
+ print_clean_and_die("Can't unpack '%s'", archive)
+
+ # The archive can contain either plain dump files
+ # or one or more complete problem data directories.
+ # Checking second possibility first.
+ if os.path.exists(tempdir+"/analyzer") and os.path.exists(tempdir+"/time"):
+ write_str_to(tempdir+"/remote", "1")
+ shutil.move(tempdir, abrt_dir)
+ problem.notify_new_path(abrt_dir+"/"+os.path.basename(tempdir))
+ else:
+ for d in os.listdir(tempdir):
+ if not os.path.isdir(tempdir+"/"+d):
+ continue
+ write_str_to(tempdir+"/"+d+"/remote", "1")
+ dst = abrt_dir+"/"+d
+ if os.path.exists(dst):
+ dst += "."+str(os.getpid())
+ if os.path.exists(dst):
+ continue
+ shutil.move(tempdir+"/"+d, dst)
+ problem.notify_new_path(dst)
+
+ die_exitcode = 0
+ # This deletes working_dir (== delete_on_exit)
+ print_clean_and_die("'%s' processed successfully", archive)
+
+ except:
+ if delete_on_exit:
+ shutil.rmtree(delete_on_exit, True) # True: ignore_errors
+ raise
--
1.8.1.4
10 years, 8 months
[LIBREPORT PATCH] do not leak file rhbz#997871
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
src/plugins/reporter-rhtsupport.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
index bbf0a1e..4598790 100644
--- a/src/plugins/reporter-rhtsupport.c
+++ b/src/plugins/reporter-rhtsupport.c
@@ -132,6 +132,9 @@ int create_tarball(const char *tempfile, problem_data_t *problem_data)
free(block);
}
+ /* now it's safe to free file */
+ free_reportfile(file);
+
/* We must be sure gzip finished, and finished successfully */
int status;
safe_waitpid(child, &status, 0);
@@ -159,7 +162,6 @@ int create_tarball(const char *tempfile, problem_data_t *problem_data)
safe_waitpid(child, NULL, 0);
}
- free_reportfile(file);
return 1; /* failure */
}
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] abrt-harvest-vmcore: notify new path - #657
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/hooks/abrt_harvest_vmcore.py.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
index abdf895..22dad07 100644
--- a/src/hooks/abrt_harvest_vmcore.py.in
+++ b/src/hooks/abrt_harvest_vmcore.py.in
@@ -13,6 +13,7 @@ import StringIO
import shutil
import time
import hashlib
+import problem
# Path to the vmcore directories
CORE_DIR = '/var/crash'
@@ -176,6 +177,8 @@ def harvest_vmcore():
# Get rid of the .new suffix
shutil.move(destdirnew, destdir)
+ problem.notify_new_path(destdir)
+
if __name__ == '__main__':
harvest_vmcore()
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] testsuite: enabled python-binding test - related #677
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
tests/runtests/aux/test_order | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/runtests/aux/test_order b/tests/runtests/aux/test_order
index 365cfc0..87564a1 100644
--- a/tests/runtests/aux/test_order
+++ b/tests/runtests/aux/test_order
@@ -33,6 +33,7 @@ dbus-elements-handling
bodhi
oops-processing
abrt-python
+python-bindings
kernel-vmcore-harvest
# - reporting tests
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] spec: add build requires for XSMP depencies
by Jakub Filak
Related to rhbz#886094
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
abrt.spec.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/abrt.spec.in b/abrt.spec.in
index a11d60f..2ce9083 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -122,6 +122,8 @@ Requires: %{name} = %{version}-%{release}
Requires: %{name}-dbus = %{version}-%{release}
Requires: gnome-abrt
BuildRequires: libreport-gtk-devel >= %{libreport_ver}
+BuildRequires: libICE-devel
+BuildRequires: libSM-devel
# we used to have abrt-applet, now abrt-gui includes it:
Provides: abrt-applet = %{version}-%{release}
Obsoletes: abrt-applet < 0.0.5
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] improved the error messages in abrt-server - closes #679
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
src/daemon/abrt-server.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
index 2e9ac20..d3e0afa 100644
--- a/src/daemon/abrt-server.c
+++ b/src/daemon/abrt-server.c
@@ -97,7 +97,7 @@ static int delete_path(const char *dump_dir_name)
if (!dir_is_in_dump_location(dump_dir_name))
{
/* Then refuse to operate on it (someone is attacking us??) */
- error_msg("Bad problem directory name '%s', not deleting", dump_dir_name);
+ error_msg("Bad problem directory name '%s', should start with: '%s'", dirname, g_settings_dump_location);
return 400; /* Bad Request */
}
if (!dump_dir_accessible_by_uid(dump_dir_name, client_uid))
@@ -144,7 +144,7 @@ static int run_post_create(const char *dirname)
if (!dir_is_in_dump_location(dirname))
{
/* Then refuse to operate on it (someone is attacking us??) */
- error_msg("Bad problem directory name '%s'", dirname);
+ error_msg("Bad problem directory name '%s', should start with: '%s'", dirname, g_settings_dump_location);
return 400; /* Bad Request */
}
if (!dump_dir_accessible_by_uid(dirname, client_uid))
--
1.8.3.1
10 years, 8 months
[ABRT PATCH] testsuite: added test for python wrapper for notify_new_path() - related #677
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
tests/runtests/python-bindings/PURPOSE | 3 ++
tests/runtests/python-bindings/notify_new_path.py | 6 +++
tests/runtests/python-bindings/runtest.sh | 56 +++++++++++++++++++++++
3 files changed, 65 insertions(+)
create mode 100644 tests/runtests/python-bindings/PURPOSE
create mode 100755 tests/runtests/python-bindings/notify_new_path.py
create mode 100755 tests/runtests/python-bindings/runtest.sh
diff --git a/tests/runtests/python-bindings/PURPOSE b/tests/runtests/python-bindings/PURPOSE
new file mode 100644
index 0000000..9427238
--- /dev/null
+++ b/tests/runtests/python-bindings/PURPOSE
@@ -0,0 +1,3 @@
+PURPOSE of python-bindings
+Description: Tests the python-bindings for ABRT API
+Author: Jiri Moskovcak <jmoskovc(a)redhat.com>
diff --git a/tests/runtests/python-bindings/notify_new_path.py b/tests/runtests/python-bindings/notify_new_path.py
new file mode 100755
index 0000000..25008d3
--- /dev/null
+++ b/tests/runtests/python-bindings/notify_new_path.py
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+import problem
+import sys
+
+problem.notify_new_path(sys.argv[1])
diff --git a/tests/runtests/python-bindings/runtest.sh b/tests/runtests/python-bindings/runtest.sh
new file mode 100755
index 0000000..73c06d6
--- /dev/null
+++ b/tests/runtests/python-bindings/runtest.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of abrt-make-check
+# Description: Clone latest abrt, build and run make check
+# Author: Michal Nowak <mnowak(a)redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
+#
+# 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 3 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, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include rhts environment
+. /usr/share/beakerlib/beakerlib.sh
+. ../aux/lib.sh
+
+TEST="python-bindings"
+PACKAGE="abrt"
+
+rlJournalStart
+ rlPhaseStartSetup
+ TmpDir=$(mktemp -d)
+ cp notify_new_path.py $TmpDir
+ pushd $TmpDir
+
+ rlPhaseEnd
+
+ rlPhaseStartTest
+ newpath="/this/is/the/testing/problem/path"
+ rlRun "./notify_new_path.py $newpath" 0 "Testing notification over socket"
+ sleep 1 # give abrt-server a while to print the message to syslog
+ rlAssertGrep "Bad problem directory name '$newpath', should start with: '/var/tmp/abrt'" /var/log/messages
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ popd # abrt/
+ popd # TmpDir
+ rm -rf $TmpDir
+ rlPhaseEnd
+ rlJournalPrintText
+rlJournalEnd
--
1.8.3.1
10 years, 8 months
[LIBREPORT RHEL6 PATCH 1/3] rhbz: replace obsolete methods by their substitutes
by Jakub Filak
- due to changes described here http://post-office.corp.redhat.com/archives/bugzilla-development-list/201...
- replaced RPC method names:
- bugzilla.getBug -> Bug.get
- bugzilla.addAttachment -> Bug.add_attachment
- works with:
- https://bugzilla.redhat.com/ [version 4.2.4-7]
- https://partner-bugzilla.redhat.com/ [version 4.2.4-7]
- https://bzweb01-devel.app.eng.rdu.redhat.com/ [version 4.4.rc1.b02]
- closes trac#921
Related to rhbz#991088
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
Conflicts:
src/plugins/rhbz.c
src/plugins/rhbz.h
---
src/plugins/rhbz.c | 127 ++++++++++++++++++++++++++++++++++++++++++-----------
src/plugins/rhbz.h | 4 ++
2 files changed, 105 insertions(+), 26 deletions(-)
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 300c5c8..fb00f60 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -145,32 +145,68 @@ void free_bug_info(struct bug_info *bi)
free(bi);
}
-static GList *parse_comments(xmlrpc_value *result_xml)
+static GList *rhbz_comments(struct abrt_xmlrpc *ax, int bug_id)
{
func_entry();
- GList *comments = NULL;
- xmlrpc_value *comments_memb = rhbz_get_member("longdescs", result_xml);
- if (!comments_memb)
- return NULL;
+ /* http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html... */
+ /*
+ * <methodResponse>
+ * <params><param>
+ * <value><struct>
+ * <member><name>bugs</name>
+ * <value><struct>
+ * <member><name>BUG_ID</name>
+ * <value><struct>
+ * <member><name>comments</name>
+ * <value><array>
+ * ...
+ */
+ xmlrpc_value *xml_response = abrt_xmlrpc_call(ax, "Bug.comments", "({s:(i)})",
+ "ids", bug_id);
+ /* bugs
+ * This is used for bugs specified in ids. This is a hash, where the
+ * keys are the numeric ids of the bugs, and the value is a hash with a
+ * single key, comments, which is an array of comments.
+ */
+ xmlrpc_value *bugs_memb = rhbz_get_member("bugs", xml_response);
- unsigned comments_memb_size = rhbz_array_size(comments_memb);
+ /* Get hash value assigned to bug_id key */
+ char *item = xasprintf("%d", bug_id);
+ xmlrpc_value *item_memb = rhbz_get_member(item, bugs_memb);
+ free(item);
+
+ /* Get array of comments */
+ xmlrpc_value *comments_memb = rhbz_get_member("comments", item_memb);
xmlrpc_env env;
xmlrpc_env_init(&env);
- for (unsigned i = 0; i < comments_memb_size; ++i)
+
+ int comments_memb_size = rhbz_array_size(comments_memb);
+
+ GList *comments = NULL;
+ for (int i = 0; i < comments_memb_size; ++i)
{
xmlrpc_value* item = NULL;
xmlrpc_array_read_item(&env, comments_memb, i, &item);
if (env.fault_occurred)
abrt_xmlrpc_die(&env);
- char *comment_body = rhbz_bug_read_item("body", item, RHBZ_READ_STR);
+ char *comment_body = rhbz_bug_read_item("text", item, RHBZ_READ_STR);
/* attachments are sometimes without comments -- skip them */
if (comment_body)
comments = g_list_prepend(comments, comment_body);
+
+ xmlrpc_DECREF(item);
}
+ xmlrpc_env_clean(&env);
+
+ xmlrpc_DECREF(comments_memb);
+ xmlrpc_DECREF(item_memb);
+ xmlrpc_DECREF(bugs_memb);
+ xmlrpc_DECREF(xml_response);
+
return g_list_reverse(comments);
}
@@ -326,6 +362,23 @@ unsigned rhbz_array_size(xmlrpc_value *xml)
return size;
}
+xmlrpc_value *rhbz_array_item_at(xmlrpc_value *xml, int pos)
+{
+ func_entry();
+
+ xmlrpc_env env;
+ xmlrpc_env_init(&env);
+
+ xmlrpc_value* item = NULL;
+ xmlrpc_array_read_item(&env, xml, pos, &item);
+ if (env.fault_occurred)
+ abrt_xmlrpc_die(&env);
+
+ xmlrpc_env_clean(&env);
+
+ return item;
+}
+
/* die or return bug id; each bug must have bug id otherwise xml is corrupted */
int rhbz_bug_id(xmlrpc_value* xml)
{
@@ -457,28 +510,42 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
func_entry();
struct bug_info *bz = new_bug_info();
- xmlrpc_value *xml_bug_response = abrt_xmlrpc_call(ax, "bugzilla.getBug",
- "(i)", bug_id);
- int *ret = (int*)rhbz_bug_read_item("bug_id", xml_bug_response,
+ /* http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html...
+ *
+ * <methodResponse>
+ * <params>
+ * <param><value><struct>
+ * <member><name>faults</name><value><array><data/></array></value></member>
+ * <member><name>bugs</name>
+ * <value><array><data>
+ * ...
+ */
+ xmlrpc_value *xml_bug_response = abrt_xmlrpc_call(ax, "Bug.get", "({s:(i)})",
+ "ids", bug_id);
+
+ xmlrpc_value *bugs_memb = rhbz_get_member("bugs", xml_bug_response);
+ xmlrpc_value *bug_item = rhbz_array_item_at(bugs_memb, 0);
+
+ int *ret = (int*)rhbz_bug_read_item("id", bug_item,
RHBZ_MANDATORY_MEMB | RHBZ_READ_INT);
bz->bi_id = *ret;
free(ret);
- bz->bi_product = rhbz_bug_read_item("product", xml_bug_response,
+ bz->bi_product = rhbz_bug_read_item("product", bug_item,
RHBZ_MANDATORY_MEMB | RHBZ_READ_STR);
- bz->bi_reporter = rhbz_bug_read_item("reporter", xml_bug_response,
+ bz->bi_reporter = rhbz_bug_read_item("creator", bug_item,
RHBZ_MANDATORY_MEMB | RHBZ_READ_STR);
- bz->bi_status = rhbz_bug_read_item("bug_status", xml_bug_response,
+ bz->bi_status = rhbz_bug_read_item("status", bug_item,
RHBZ_MANDATORY_MEMB | RHBZ_READ_STR);
- bz->bi_resolution = rhbz_bug_read_item("resolution", xml_bug_response,
+ bz->bi_resolution = rhbz_bug_read_item("resolution", bug_item,
RHBZ_READ_STR);
- bz->bi_platform = rhbz_bug_read_item("rep_platform", xml_bug_response,
+ bz->bi_platform = rhbz_bug_read_item("platform", bug_item,
RHBZ_READ_STR);
if (strcmp(bz->bi_status, "CLOSED") == 0 && !bz->bi_resolution)
error_msg_and_die(_("Bug %i is CLOSED, but it has no RESOLUTION"), bz->bi_id);
- ret = (int*)rhbz_bug_read_item("dup_id", xml_bug_response,
+ ret = (int*)rhbz_bug_read_item("dup_id", bug_item,
RHBZ_READ_INT);
if (strcmp(bz->bi_status, "CLOSED") == 0
&& strcmp(bz->bi_resolution, "DUPLICATE") == 0
@@ -491,11 +558,13 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
bz->bi_dup_id = (ret) ? *ret: -1;
free(ret);
- bz->bi_cc_list = rhbz_bug_cc(xml_bug_response);
+ bz->bi_cc_list = rhbz_bug_cc(bug_item);
- bz->bi_comments = parse_comments(xml_bug_response);
+ bz->bi_comments = rhbz_comments(ax, bug_id);
bz->bi_best_bt_rating = find_best_bt_rating_in_comments(bz->bi_comments);
+ xmlrpc_DECREF(bugs_memb);
+ xmlrpc_DECREF(bug_item);
xmlrpc_DECREF(xml_bug_response);
return bz;
@@ -703,13 +772,19 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename,
xmlrpc_value* result;
int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
- result = abrt_xmlrpc_call(ax, "bugzilla.addAttachment", "(s{s:s,s:s,s:s,s:s,s:i})",
- bug_id,
- "description", fn,
- "filename", filename,
- "contenttype", (flags & RHBZ_BINARY_ATTACHMENT) ? "application/octet-stream" : "text/plain",
- "data", encoded64,
- "nomail", nomail_notify);
+ /* http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html... */
+ result = abrt_xmlrpc_call(ax, "Bug.add_attachment", "({s:(s),s:s,s:s,s:s,s:s,s:i})",
+ "ids", bug_id,
+ "summary", fn,
+ "file_name", filename,
+ "content_type", (flags & RHBZ_BINARY_ATTACHMENT) ? "application/octet-stream" : "text/plain",
+ "data", encoded64,
+
+ /* Undocumented argument but it works with Red Hat Bugzilla version 4.2.4-7
+ * and version 4.4.rc1.b02
+ */
+ "nomail", nomail_notify
+ );
free(encoded64);
free(fn);
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
index 585b23e..14b1855 100644
--- a/src/plugins/rhbz.h
+++ b/src/plugins/rhbz.h
@@ -101,6 +101,10 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
const char *release,
int depend_on_bug);
+xmlrpc_value *rhbz_array_item_at(xmlrpc_value *xml, int pos);
+
+int rhbz_get_bug_id_from_array0(xmlrpc_value *xml, unsigned ver);
+
int rhbz_attach_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags);
--
1.8.3.1
10 years, 8 months
[GNOME-ABRT PATCH] Recover from fork errors
by Jakub Filak
Closes rhbz#995868
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
po/POTFILES.in | 1 +
src/gnome_abrt/controller.py.in | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0a3555e..0f30622 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,3 +7,4 @@ src/gnome_abrt/oops.glade
src/gnome_abrt/problems.py
src/gnome_abrt/tools.py
src/gnome_abrt/views.py
+src/gnome_abrt/controller.py
diff --git a/src/gnome_abrt/controller.py.in b/src/gnome_abrt/controller.py.in
index 0dad426..969d6a8 100644
--- a/src/gnome_abrt/controller.py.in
+++ b/src/gnome_abrt/controller.py.in
@@ -22,6 +22,7 @@ import traceback
# gnome-abrt
from gnome_abrt import errors
+from gnome_abrt.l10n import _
class Controller(object):
@@ -68,7 +69,17 @@ class Controller(object):
def _run_event_on_problem(self, event, problem):
if problem.assure_ownership():
- if os.fork() == 0:
+ pid = -1
+ try:
+ pid = os.fork()
+ except OSError as ex:
+ logging.debug(traceback.format_exc())
+ logging.error(
+ _("Failed to execute the requested action because of"
+ " an error in new process creation"))
+ return
+
+ if pid == 0:
exctbl = "@libexecdir@/abrt-handle-event"
args = [exctbl, "-e", event, "--", problem.problem_id]
try:
--
1.8.3.1
10 years, 8 months
[ABRT PATCH 1/3] expose abrt configuration GUI in public API
by Jakub Filak
Related to rhbz#993591
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
configure.ac | 1 +
po/POTFILES.in | 1 +
src/configuration-gui/Makefile.am | 31 ++++--
src/configuration-gui/abrt_gui.pc.in | 11 ++
src/configuration-gui/main.c | 163 +++++++++++++++++++++++++++++
src/configuration-gui/system-config-abrt.c | 153 +++++----------------------
src/configuration-gui/system-config-abrt.h | 35 +++++++
7 files changed, 262 insertions(+), 133 deletions(-)
create mode 100644 src/configuration-gui/abrt_gui.pc.in
create mode 100644 src/configuration-gui/main.c
create mode 100644 src/configuration-gui/system-config-abrt.h
diff --git a/configure.ac b/configure.ac
index 70fafe1..0719295 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,6 +237,7 @@ AC_CONFIG_FILES([
src/applet/Makefile
src/cli/Makefile
src/configuration-gui/Makefile
+ src/configuration-gui/abrt_gui.pc
src/dbus/Makefile
src/plugins/abrt-action-install-debuginfo
src/plugins/abrt-action-analyze-vmcore
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 752e982..f88c6ca 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,6 +6,7 @@ src/applet/applet.c
src/configuration-gui/abrt-config-widget.ui
src/configuration-gui/system-config-abrt.c
src/configuration-gui/system-config-abrt.desktop.in
+src/configuration-gui/main.c
src/daemon/abrt-action-save-package-data.c
src/daemon/abrt-server.c
src/dbus/abrt-dbus.c
diff --git a/src/configuration-gui/Makefile.am b/src/configuration-gui/Makefile.am
index 9d5ec53..1fe4e8f 100644
--- a/src/configuration-gui/Makefile.am
+++ b/src/configuration-gui/Makefile.am
@@ -1,8 +1,17 @@
-lib_LTLIBRARIES = libabrtconfigui.la
+libabrt_gui_includedir = \
+ $(includedir)/abrt
-libabrtconfigui_la_SOURCES = \
+libabrt_gui_include_HEADERS = \
+ abrt-config-widget.h \
+ system-config-abrt.h
+
+lib_LTLIBRARIES = libabrt_gui.la
+
+libabrt_gui_la_SOURCES = \
abrt-config-widget.c \
- abrt-config-widget.h
+ abrt-config-widget.h \
+ system-config-abrt.c \
+ system-config-abrt.h
# G_DEFINE_TYPE(...) macros result in
# typedef '_GStaticAssertCompileTimeAssertion_0' locally defined but not used
@@ -11,7 +20,7 @@ libabrtconfigui_la_SOURCES = \
# -Wno-error=unused-local-typedefs in CPPFLAGS suppresses this warning.
# Newer glib may have it fixed.
-libabrtconfigui_la_CPPFLAGS = \
+libabrt_gui_la_CPPFLAGS = \
-I$(srcdir)/../include \
-I$(srcdir)/../lib \
-Wno-error=unused-local-typedefs \
@@ -20,10 +29,10 @@ libabrtconfigui_la_CPPFLAGS = \
-DABRT_UI_DIR="\"$(uidir)\"" \
-DLOCALEDIR="\"$(localedir)\""
-libabrtconfigui_la_LDFLAGS = \
+libabrt_gui_la_LDFLAGS = \
-version-info 0:1:0
-libabrtconfigui_la_LIBADD = \
+libabrt_gui_la_LIBADD = \
$(GLIB_LIBS) \
$(GTK_LIBS) \
$(LIBREPORT_LIBS)
@@ -38,11 +47,11 @@ system_config_abrt_CPPFLAGS = \
$(LIBREPORT_CFLAGS)
system_config_abrt_SOURCES = \
- system-config-abrt.c
+ main.c
system_config_abrt_LDADD = \
../lib/libabrt.la \
- libabrtconfigui.la
+ libabrt_gui.la
$(GLIB_LIBS) \
$(GTK_LIBS) \
$(LIBREPORT_LIBS)
@@ -56,4 +65,8 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
CLEANFILES = $(desktop_DATA)
-EXTRA_DIST = $(desktop_in_files)
+EXTRA_DIST = $(desktop_in_files) \
+ abrt_gui.pc.in
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = abrt_gui.pc
diff --git a/src/configuration-gui/abrt_gui.pc.in b/src/configuration-gui/abrt_gui.pc.in
new file mode 100644
index 0000000..7f22ec7
--- /dev/null
+++ b/src/configuration-gui/abrt_gui.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: abrt_gui
+Description: abrt UI library
+Version: @VERSION@
+Requires: abrt
+Libs: -L${libdir} -labrt_gui
+Cflags: -fPIC -I${includedir}/abrt
diff --git a/src/configuration-gui/main.c b/src/configuration-gui/main.c
new file mode 100644
index 0000000..15e0796
--- /dev/null
+++ b/src/configuration-gui/main.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2013 Red Hat
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "system-config-abrt.h"
+
+#include <stdlib.h>
+#include <libabrt.h>
+
+#define APP_NAME "System Config ABRT"
+
+static GtkWidget *
+system_config_abrt_window_new(GApplication *app)
+{
+ GtkWidget *wnd = gtk_application_window_new(GTK_APPLICATION(app));
+ gtk_window_set_default_size(GTK_WINDOW(wnd), 640, 480);
+ gtk_window_set_title(GTK_WINDOW(wnd), _("Problem Reporting Configuration"));
+
+ GtkWidget *sca = system_config_abrt_widget_new();
+ gtk_container_add(GTK_CONTAINER(wnd), sca);
+
+ return wnd;
+}
+
+/* SystemConfigAbrt : GtkApplication */
+
+typedef struct
+{
+ GtkApplication parent_instance;
+} SystemConfigAbrt;
+
+typedef GtkApplicationClass SystemConfigAbrtClass;
+
+G_DEFINE_TYPE (SystemConfigAbrt, system_config_abrt, GTK_TYPE_APPLICATION)
+
+static void
+system_config_abrt_finalize (GObject *object)
+{
+ G_OBJECT_CLASS(system_config_abrt_parent_class)->finalize(object);
+}
+
+static void
+about_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ const gchar *authors[] = {
+ "ABRT Team <crash-catcher(a)lists.fedorahosted.org>",
+ NULL
+ };
+
+ gtk_show_about_dialog (NULL,
+ "program-name", APP_NAME,
+ "title", _("About System Config ABRT"),
+ "version", VERSION,
+ "website", "https://github.com/abrt/abrt/wiki/overview",
+ "authors", authors,
+ NULL);
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GApplication *app = user_data;
+
+ g_application_quit(app);
+}
+
+static GActionEntry app_entries[] = {
+ { "about", about_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL },
+};
+
+static void
+system_config_abrt_startup(GApplication *application)
+{
+ G_APPLICATION_CLASS(system_config_abrt_parent_class)->startup(application);
+
+ g_action_map_add_action_entries(G_ACTION_MAP(application), app_entries, G_N_ELEMENTS(app_entries), application);
+
+ GMenu *app_menu = g_menu_new();
+ g_menu_append(app_menu, _("About"), "app.about");
+ g_menu_append(app_menu, _("Quit"), "app.quit");
+
+ gtk_application_set_app_menu(GTK_APPLICATION(application), G_MENU_MODEL(app_menu));
+}
+
+static void
+system_config_abrt_shutdown(GApplication *application)
+{
+ G_APPLICATION_CLASS(system_config_abrt_parent_class)->shutdown (application);
+}
+
+static void
+system_config_abrt_activate(GApplication *application)
+{
+ GtkWidget *wnd = system_config_abrt_window_new(application);
+ gtk_widget_show_all(wnd);
+ gtk_application_add_window(GTK_APPLICATION(application), GTK_WINDOW(wnd));
+}
+
+static void
+system_config_abrt_init (SystemConfigAbrt *app)
+{
+}
+
+static void
+system_config_abrt_class_init (SystemConfigAbrtClass *class)
+{
+ GApplicationClass *application_class = G_APPLICATION_CLASS(class);
+ GObjectClass *object_class = G_OBJECT_CLASS(class);
+
+ application_class->startup = system_config_abrt_startup;
+ application_class->shutdown = system_config_abrt_shutdown;
+ application_class->activate = system_config_abrt_activate;
+
+ object_class->finalize = system_config_abrt_finalize;
+}
+
+SystemConfigAbrt *
+system_config_abrt_new (void)
+{
+ SystemConfigAbrt *system_config_abrt;
+
+ g_set_application_name(APP_NAME);
+
+ system_config_abrt = g_object_new(system_config_abrt_get_type(),
+ "application-id", "org.freedesktop.SystemConfigAbrt",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+
+ return system_config_abrt;
+}
+
+/* End class */
+
+int main(int argc, char *argv[])
+{
+ glib_init();
+
+ SystemConfigAbrt *system_config_abrt = system_config_abrt_new();
+
+ const int status = g_application_run(G_APPLICATION(system_config_abrt), argc, argv);
+
+ g_object_unref(system_config_abrt);
+
+ return status;
+}
diff --git a/src/configuration-gui/system-config-abrt.c b/src/configuration-gui/system-config-abrt.c
index 22773de..f15ce01 100644
--- a/src/configuration-gui/system-config-abrt.c
+++ b/src/configuration-gui/system-config-abrt.c
@@ -15,14 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
+#include "system-config-abrt.h"
#include "abrt-config-widget.h"
-#include "libabrt.h"
-#include <stdlib.h>
-#include <gtk/gtk.h>
+#include <libabrt.h>
-#define APP_NAME "System Config ABRT"
static void
system_config_abrt_apply_cb(GtkButton *button, gpointer user_data)
@@ -39,15 +36,9 @@ system_config_abrt_changed_cb(AbrtConfigWidget *config, gpointer user_data)
gtk_widget_set_sensitive(button, TRUE);
}
-static GtkWidget *
-system_config_abrt_window_new(GApplication *app)
+GtkWidget *system_config_abrt_widget_new(void)
{
- GtkWidget *wnd = gtk_application_window_new(GTK_APPLICATION(app));
- gtk_window_set_default_size(GTK_WINDOW(wnd), 640, 480);
- gtk_window_set_title(GTK_WINDOW(wnd), _("Problem Reporting Configuration"));
-
GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, /*spacing*/0));
- gtk_container_add(GTK_CONTAINER(wnd), GTK_WIDGET(box));
AbrtConfigWidget *config = abrt_config_widget_new();
gtk_widget_set_visible(GTK_WIDGET(config), TRUE);
@@ -79,132 +70,46 @@ system_config_abrt_window_new(GApplication *app)
gtk_widget_show_all(buttons);
- return wnd;
-}
-
-/* SystemConfigAbrt : GtkApplication */
-
-typedef struct
-{
- GtkApplication parent_instance;
-} SystemConfigAbrt;
-
-typedef GtkApplicationClass SystemConfigAbrtClass;
-
-G_DEFINE_TYPE (SystemConfigAbrt, system_config_abrt, GTK_TYPE_APPLICATION)
-
-static void
-system_config_abrt_finalize (GObject *object)
-{
- G_OBJECT_CLASS(system_config_abrt_parent_class)->finalize(object);
-}
-
-static void
-about_activated (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- const gchar *authors[] = {
- "ABRT Team <crash-catcher(a)lists.fedorahosted.org>",
- NULL
- };
-
- gtk_show_about_dialog (NULL,
- "program-name", APP_NAME,
- "title", _("About System Config ABRT"),
- "version", VERSION,
- "website", "https://github.com/abrt/abrt/wiki/overview",
- "authors", authors,
- NULL);
-}
-
-static void
-quit_activated (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- GApplication *app = user_data;
-
- g_application_quit(app);
-}
-
-static GActionEntry app_entries[] = {
- { "about", about_activated, NULL, NULL, NULL },
- { "quit", quit_activated, NULL, NULL, NULL },
-};
-
-static void
-system_config_abrt_startup(GApplication *application)
-{
- G_APPLICATION_CLASS(system_config_abrt_parent_class)->startup(application);
-
- g_action_map_add_action_entries(G_ACTION_MAP(application), app_entries, G_N_ELEMENTS(app_entries), application);
-
- GMenu *app_menu = g_menu_new();
- g_menu_append(app_menu, _("About"), "app.about");
- g_menu_append(app_menu, _("Quit"), "app.quit");
-
- gtk_application_set_app_menu(GTK_APPLICATION(application), G_MENU_MODEL(app_menu));
-}
-
-static void
-system_config_abrt_shutdown(GApplication *application)
-{
- G_APPLICATION_CLASS(system_config_abrt_parent_class)->shutdown (application);
-}
-
-static void
-system_config_abrt_activate(GApplication *application)
-{
- GtkWidget *wnd = system_config_abrt_window_new(application);
- gtk_widget_show_all(wnd);
- gtk_application_add_window(GTK_APPLICATION(application), GTK_WINDOW(wnd));
+ return GTK_WIDGET(box);
}
static void
-system_config_abrt_init (SystemConfigAbrt *app)
+system_config_abrt_dialog_close(GtkDialog *dialog, gpointer user_data)
{
+ gtk_widget_destroy(GTK_WIDGET(dialog));
}
-static void
-system_config_abrt_class_init (SystemConfigAbrtClass *class)
+static gboolean
+system_config_abrt_dialog_delete_event(GtkWidget *dialog, GdkEvent *event, gpointer user_data)
{
- GApplicationClass *application_class = G_APPLICATION_CLASS(class);
- GObjectClass *object_class = G_OBJECT_CLASS(class);
-
- application_class->startup = system_config_abrt_startup;
- application_class->shutdown = system_config_abrt_shutdown;
- application_class->activate = system_config_abrt_activate;
-
- object_class->finalize = system_config_abrt_finalize;
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ return TRUE; /*do not propagate the event*/
}
-SystemConfigAbrt *
-system_config_abrt_new (void)
+void show_system_config_abrt_dialog(GtkWindow *parent)
{
- SystemConfigAbrt *system_config_abrt;
+ GtkWidget *dialog = gtk_dialog_new();
- g_set_application_name(APP_NAME);
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Problem Reporting Configuration"));
+ gtk_window_set_default_size(GTK_WINDOW(dialog), 640, 480);
+ gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
- system_config_abrt = g_object_new(system_config_abrt_get_type(),
- "application-id", "org.freedesktop.SystemConfigAbrt",
- "flags", G_APPLICATION_HANDLES_OPEN,
- NULL);
-
- return system_config_abrt;
-}
-
-/* End class */
-
-int main(int argc, char *argv[])
-{
- glib_init();
+ if (parent != NULL)
+ {
+ gtk_window_set_icon_name(GTK_WINDOW(dialog), gtk_window_get_icon_name(parent));
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
+ gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+ }
- SystemConfigAbrt *system_config_abrt = system_config_abrt_new();
+ /* Have to handle these signals on our own otherwise users must press close button twice */
+ g_signal_connect(dialog, "close", G_CALLBACK(system_config_abrt_dialog_close), /*user_data*/NULL);
+ g_signal_connect(dialog, "delete_event", G_CALLBACK(system_config_abrt_dialog_delete_event), /*user_data*/NULL);
- const int status = g_application_run(G_APPLICATION(system_config_abrt), argc, argv);
+ GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ GtkWidget *sca = system_config_abrt_widget_new();
+ gtk_box_pack_start(GTK_BOX(content), sca, /*expand*/TRUE, /*fill*/TRUE, /*padding*/0);
- g_object_unref(system_config_abrt);
+ gtk_widget_show_all(content);
- return status;
+ gtk_dialog_run(GTK_DIALOG(dialog));
}
diff --git a/src/configuration-gui/system-config-abrt.h b/src/configuration-gui/system-config-abrt.h
new file mode 100644
index 0000000..453090c
--- /dev/null
+++ b/src/configuration-gui/system-config-abrt.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2013 Red Hat
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef _SYSTEM_CONFIG_ABRT_H
+#define _SYSTEM_CONFIG_ABRT_H
+
+#include <gtk/gtk.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+GtkWidget *system_config_abrt_widget_new(void);
+
+void show_system_config_abrt_dialog(GtkWindow *parent);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _SYSTEM_CONFIG_ABRT_H */
--
1.8.3.1
10 years, 8 months