1.1 --- a/app-manager/app-manager.c Mon Nov 02 19:01:50 2015 +0000
1.2 +++ b/app-manager/app-manager.c Mon Nov 02 19:04:58 2015 +0000
1.3 @@ -27,6 +27,7 @@
1.4 #include <gio/gio.h>
1.5 #include <gtk/gtk.h>
1.6 #include <whelk/whelk.h>
1.7 +#include <plover/plover.h>
1.8 #include <plover/packageset.h>
1.9 #include <plover-gtk/stockicons.h>
1.10 #include "app-manager.h"
1.11 @@ -244,6 +245,7 @@
1.12 ShowWindow(GetConsoleWindow(),SW_HIDE);
1.13 }
1.14 #endif
1.15 + plover_exception_handler_init();
1.16 razor_set_lua_loader("posix",luaopen_posix);
1.17 razor_set_lua_loader("whelk",luaopen_whelk);
1.18 if (!gtk_init_with_args(&argc,&argv,NULL,options,NULL,&err))
2.1 --- a/configure.ac Mon Nov 02 19:01:50 2015 +0000
2.2 +++ b/configure.ac Mon Nov 02 19:04:58 2015 +0000
2.3 @@ -1,7 +1,7 @@
2.4 # -*- Autoconf -*-
2.5 # Process this file with autoconf to produce a configure script.
2.6
2.7 -AC_INIT([plover],[0.5],[ali@juiblex.co.uk])
2.8 +AC_INIT([plover],[0.5.1],[ali@juiblex.co.uk])
2.9 AC_PREREQ(2.59)
2.10 AC_CONFIG_AUX_DIR([config])
2.11 AC_CONFIG_SRCDIR([plover/plover.h])
2.12 @@ -70,9 +70,9 @@
2.13 # increment CURRENT and set AGE and REVISION to 0.
2.14 # - If the interface is the same as the previous version, increment REVISION.
2.15 #
2.16 -lt_current=3
2.17 +lt_current=4
2.18 lt_revision=0
2.19 -lt_age=0
2.20 +lt_age=1
2.21 LIBPLOVER_LT_VERSION_INFO="$lt_current:$lt_revision:$lt_age"
2.22 AC_SUBST(LIBPLOVER_LT_VERSION_INFO)
2.23
2.24 @@ -88,6 +88,7 @@
2.25 # Checks for programs.
2.26 ##################################################
2.27 AC_PROG_CC
2.28 +AC_PROG_CXX
2.29 AC_LIBTOOL_WIN32_DLL
2.30 AC_PROG_LIBTOOL
2.31 PKG_PROG_PKG_CONFIG
2.32 @@ -163,6 +164,22 @@
2.33 fi
2.34 AC_SUBST([FETCH_LIBS])
2.35 LIBS="$save_LIBS"
2.36 +AC_ARG_WITH([breakpad],
2.37 + [AS_HELP_STRING([--with-breakpad],
2.38 + [produce minidumps on crash @<:@default=check@:>@])],
2.39 + [],[with_breakpad=check])
2.40 +if test "$with_breakpad" != no; then
2.41 + PKG_CHECK_MODULES([BREAKPAD],[breakpad-client],
2.42 + [have_breakpad="yes";REQUIREMENTS="$REQUIREMENTS x11"],[have_breakpad="no"])
2.43 + if test "$have_breakpad" = yes; then
2.44 + AC_DEFINE([HAVE_BREAKPAD],[1],[Define if breakpad is available.])
2.45 + elif test "$with_breakpad" = yes; then
2.46 + AC_MSG_ERROR([$BREAKPAD_PKG_ERRORS])
2.47 + fi
2.48 +else
2.49 + have_breakpad="no"
2.50 +fi
2.51 +AM_CONDITIONAL([HAVE_BREAKPAD],[test $have_breakpad = yes])
2.52
2.53 ##################################################
2.54 # Checks for library functions.
3.1 --- a/plover-open/plover-open.c Mon Nov 02 19:01:50 2015 +0000
3.2 +++ b/plover-open/plover-open.c Mon Nov 02 19:04:58 2015 +0000
3.3 @@ -164,6 +164,7 @@
3.4 ShowWindow(GetConsoleWindow(),SW_HIDE);
3.5 }
3.6 #endif
3.7 + plover_exception_handler_init();
3.8 razor_set_lua_loader("posix",luaopen_posix);
3.9 razor_set_lua_loader("whelk",luaopen_whelk);
3.10 if (!gtk_init_with_args(&argc,&argv,NULL,options,NULL,&err))
4.1 --- a/plover/Makefile.am Mon Nov 02 19:01:50 2015 +0000
4.2 +++ b/plover/Makefile.am Mon Nov 02 19:04:58 2015 +0000
4.3 @@ -1,4 +1,5 @@
4.4 AM_CFLAGS=-g $(LIBPLOVER_CFLAGS)
4.5 +AM_CXXFLAGS=-g $(LIBPLOVER_CFLAGS)
4.6 LIBS=$(LIBPLOVER_LIBS)
4.7 INCLUDES=-I$(top_srcdir)
4.8 AM_LDFLAGS=-no-undefined -version-info $(LIBPLOVER_LT_VERSION_INFO)
4.9 @@ -7,7 +8,8 @@
4.10
4.11 lib_LTLIBRARIES=libplover.la
4.12 libplover_la_SOURCES=$(pkginclude_HEADERS) util.c import-yum.c razor.c comps.c \
4.13 - log.c vector.c transaction.c package.c packageset.c repository.c
4.14 + log.c vector.c transaction.c package.c packageset.c repository.c \
4.15 + exception-handler.cpp
4.16
4.17 pkgconfigdir=$(libdir)/pkgconfig
4.18 pkgconfig_DATA=plover.pc
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/plover/exception-handler.cpp Mon Nov 02 19:04:58 2015 +0000
5.3 @@ -0,0 +1,51 @@
5.4 +/*
5.5 + * Copyright (C) 2015 J. Ali Harlow <ali@juiblex.co.uk>
5.6 + *
5.7 + * This program is free software; you can redistribute it and/or modify
5.8 + * it under the terms of the GNU General Public License as published by
5.9 + * the Free Software Foundation; either version 2 of the License, or
5.10 + * (at your option) any later version.
5.11 + *
5.12 + * This program is distributed in the hope that it will be useful,
5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 + * GNU General Public License for more details.
5.16 + *
5.17 + * You should have received a copy of the GNU General Public License along
5.18 + * with this program; if not, write to the Free Software Foundation, Inc.,
5.19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5.20 + */
5.21 +
5.22 +#include <cstdlib>
5.23 +#include "plover/plover.h"
5.24 +#if defined(HAVE_BREAKPAD) && defined(WIN32)
5.25 +#include <breakpad/client/windows/crash_generation/crash_generation_client.h>
5.26 +#include <breakpad/client/windows/handler/exception_handler.h>
5.27 +#endif
5.28 +
5.29 +extern "C" {
5.30 +
5.31 +#if defined(HAVE_BREAKPAD) && defined(WIN32)
5.32 +static google_breakpad::ExceptionHandler *plover_exception_handler=NULL;
5.33 +#endif
5.34 +
5.35 +void plover_exception_handler_init(void)
5.36 +{
5.37 +#if defined(HAVE_BREAKPAD) && defined(WIN32)
5.38 + gchar *path;
5.39 + WCHAR *dump_path;
5.40 + if (!plover_exception_handler)
5.41 + {
5.42 + path=plover_get_reports_directory();
5.43 + dump_path=(WCHAR *)g_utf8_to_utf16(path,-1,NULL,NULL,NULL);
5.44 + g_free(path);
5.45 + plover_exception_handler=new
5.46 + google_breakpad::ExceptionHandler(dump_path,NULL,NULL,NULL,
5.47 + google_breakpad::ExceptionHandler::HANDLER_ALL,MiniDumpWithDataSegs,
5.48 + NULL,NULL);
5.49 + g_free(dump_path);
5.50 + }
5.51 +#endif /* HAVE_BREAKPAD && WIN32 */
5.52 +}
5.53 +
5.54 +} // extern "C"
6.1 --- a/plover/plover.h Mon Nov 02 19:01:50 2015 +0000
6.2 +++ b/plover/plover.h Mon Nov 02 19:04:58 2015 +0000
6.3 @@ -7,6 +7,8 @@
6.4 #include <plover/packageset.h>
6.5 #include <plover/repository.h>
6.6
6.7 +G_BEGIN_DECLS
6.8 +
6.9 #define PLOVER_GENERAL_ERROR RAZOR_ERROR_DOMAIN('P','l','v',0)
6.10 #define PLOVER_SCRIPTLET_ERROR RAZOR_ERROR_DOMAIN('P','l','v',1)
6.11 #define PLOVER_RAZOR_ERROR plover_razor_error_quark()
6.12 @@ -61,6 +63,8 @@
6.13
6.14 gchar *plover_default_prefix_for_vendor(const char *vendor);
6.15 gchar *plover_pre_install_prefix(void);
6.16 +void plover_purge_reports(const char *path);
6.17 +gchar *plover_get_reports_directory(void);
6.18 char *plover_get_program_directory(const char *argv0);
6.19 GQuark plover_razor_error_quark(void);
6.20 GQuark plover_posix_error_quark(void);
6.21 @@ -92,6 +96,7 @@
6.22 const char *id);
6.23
6.24 int plover_log_open(const char *path);
6.25 +void plover_exception_handler_init(void);
6.26
6.27 struct plover_vector *plover_vector_new(void);
6.28 struct plover_vector *plover_vector_dup(struct plover_vector *old);
6.29 @@ -102,4 +107,6 @@
6.30 char *plover_vector_format_for_display(struct plover_vector *vector);
6.31 void plover_vector_free(struct plover_vector *vector);
6.32
6.33 +G_END_DECLS
6.34 +
6.35 #endif /* __PLOVER_H__ */
7.1 --- a/plover/util.c Mon Nov 02 19:01:50 2015 +0000
7.2 +++ b/plover/util.c Mon Nov 02 19:04:58 2015 +0000
7.3 @@ -1,5 +1,5 @@
7.4 /*
7.5 - * Copyright (C) 2009, 2011, 2014 J. Ali Harlow <ali@juiblex.co.uk>
7.6 + * Copyright (C) 2009, 2011, 2014, 2015 J. Ali Harlow <ali@juiblex.co.uk>
7.7 *
7.8 * This program is free software; you can redistribute it and/or modify
7.9 * it under the terms of the GNU General Public License as published by
7.10 @@ -24,6 +24,8 @@
7.11 #include <windows.h>
7.12 #include <shlobj.h>
7.13 #endif
7.14 +#include <glib.h>
7.15 +#include <glib/gstdio.h>
7.16 #include "config.h"
7.17 #include "plover.h"
7.18
7.19 @@ -106,6 +108,124 @@
7.20 #endif
7.21 }
7.22
7.23 +#define MAX_REPORTS 12
7.24 +
7.25 +struct plover_util_file {
7.26 + gchar *name;
7.27 + time_t mtime;
7.28 +};
7.29 +
7.30 +static int plover_util_compare_files(gconstpointer a,gconstpointer b)
7.31 +{
7.32 + struct plover_util_file *fa=(struct plover_util_file *)a;
7.33 + struct plover_util_file *fb=(struct plover_util_file *)b;
7.34 + return fa->mtime-fb->mtime;
7.35 +}
7.36 +
7.37 +/*
7.38 + * Limit the number of reports to MAX_REPORTS
7.39 + */
7.40 +
7.41 +void plover_purge_reports(const char *path)
7.42 +{
7.43 + const char *name;
7.44 + GStatBuf sbuf;
7.45 + int count=0;
7.46 + GDir *d;
7.47 + GError *err=NULL;
7.48 + GList *files=NULL;
7.49 + struct plover_util_file *file;
7.50 + d=g_dir_open(path,0,&err);
7.51 + if (!d)
7.52 + {
7.53 + if (g_error_matches(err,G_FILE_ERROR,G_FILE_ERROR_NOENT))
7.54 + g_mkdir_with_parents(path,0777);
7.55 + return;
7.56 + }
7.57 + while(count<=MAX_REPORTS && g_dir_read_name(d))
7.58 + count++;
7.59 + if (count>MAX_REPORTS)
7.60 + {
7.61 + g_dir_rewind(d);
7.62 + while((name=g_dir_read_name(d)))
7.63 + {
7.64 + file=g_new(struct plover_util_file,1);
7.65 + file->name=g_build_filename(path,name,NULL);
7.66 + if (!g_stat(file->name,&sbuf))
7.67 + file->mtime=sbuf.st_mtime;
7.68 + else
7.69 + file->mtime=0;
7.70 + files=g_list_prepend(files,file);
7.71 + }
7.72 + files=g_list_sort(files,plover_util_compare_files);
7.73 + while(files)
7.74 + {
7.75 + file=(struct plover_util_file *)files->data;
7.76 + if (count>MAX_REPORTS)
7.77 + {
7.78 + count--;
7.79 + g_remove(file->name);
7.80 + }
7.81 + g_free(file->name);
7.82 + g_free(file);
7.83 + files=g_list_delete_link(files,files);
7.84 + }
7.85 + }
7.86 + g_dir_close(d);
7.87 +}
7.88 +
7.89 +gchar *plover_get_reports_directory(void)
7.90 +{
7.91 + gchar *path=NULL;
7.92 +#ifdef WIN32
7.93 + HKEY key;
7.94 + DWORD rtype,nb;
7.95 + int len;
7.96 + long retval;
7.97 + gunichar2 *str2;
7.98 + char *dir;
7.99 + retval=RegOpenKeyW(HKEY_LOCAL_MACHINE,L"Software\\Plover",&key);
7.100 + if (SUCCEEDED(retval))
7.101 + {
7.102 + nb=200;
7.103 + str2=malloc(nb);
7.104 + retval=RegQueryValueExW(key,L"Reports",0,&rtype,(void *)str2,&nb);
7.105 + if (retval==ERROR_MORE_DATA)
7.106 + {
7.107 + g_free(str2);
7.108 + str2=malloc(nb);
7.109 + retval=RegQueryValueExW(key,L"Reports",0,NULL,(void *)str2,&nb);
7.110 + }
7.111 + if (SUCCEEDED(retval) && rtype==REG_SZ)
7.112 + {
7.113 + len=nb/2;
7.114 + if (!str2[len-1]) /* Cope with unterminated strings */
7.115 + len--;
7.116 + path=g_utf16_to_utf8(str2,len,NULL,NULL,NULL);
7.117 + }
7.118 + RegCloseKey(key);
7.119 + g_free(str2);
7.120 + }
7.121 + if (!path)
7.122 + {
7.123 + WCHAR wpath[MAX_PATH];
7.124 + retval=SHGetFolderPathW(NULL,CSIDL_COMMON_APPDATA,NULL,
7.125 + SHGFP_TYPE_CURRENT,wpath);
7.126 + if (SUCCEEDED(retval))
7.127 + dir=g_utf16_to_utf8((const gunichar2 *)wpath,-1,NULL,NULL,NULL);
7.128 + else
7.129 + dir=g_strdup(
7.130 + "C:\\Documents and Settings\\All Users\\Application Data");
7.131 + path=g_build_filename(dir,"plover","reports",NULL);
7.132 + g_free(dir);
7.133 + }
7.134 +#else
7.135 + path=g_strdup("/var/lib/plover/reports");
7.136 +#endif
7.137 + plover_purge_reports(path);
7.138 + return path;
7.139 +}
7.140 +
7.141 /*
7.142 * Get the directory containing the program executable.
7.143 */
8.1 --- a/pre-inst/pre-inst.c Mon Nov 02 19:01:50 2015 +0000
8.2 +++ b/pre-inst/pre-inst.c Mon Nov 02 19:04:58 2015 +0000
8.3 @@ -473,6 +473,7 @@
8.4 ShowWindow(GetConsoleWindow(),SW_HIDE);
8.5 }
8.6 #endif
8.7 + plover_exception_handler_init();
8.8 if (argc>1 && !strcmp(argv[1],"-u"))
8.9 {
8.10 success=pre_uninstall();
9.1 --- a/setup/setup.c Mon Nov 02 19:01:50 2015 +0000
9.2 +++ b/setup/setup.c Mon Nov 02 19:04:58 2015 +0000
9.3 @@ -112,6 +112,7 @@
9.4 int main(int argc,char **argv)
9.5 {
9.6 GError *error=NULL;
9.7 + plover_exception_handler_init();
9.8 razor_set_lua_loader("posix",luaopen_posix);
9.9 razor_set_lua_loader("whelk",luaopen_whelk);
9.10 if (argc>1 && !strcmp(argv[1],"-u"))
10.1 --- a/update/update.c Mon Nov 02 19:01:50 2015 +0000
10.2 +++ b/update/update.c Mon Nov 02 19:04:58 2015 +0000
10.3 @@ -72,6 +72,7 @@
10.4
10.5 int main(int argc,char **argv)
10.6 {
10.7 + plover_exception_handler_init();
10.8 razor_set_lua_loader("posix",luaopen_posix);
10.9 razor_set_lua_loader("whelk",luaopen_whelk);
10.10 update(argv[0]);