diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-02-07 00:19:09 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-02-27 11:51:35 +0000 |
commit | b78209ae74af5bf4fc5dacde8c9b7e709cbb1a70 (patch) | |
tree | 8ae3017f83a32786b114f93b3ce6f5996e2ffad0 /svx | |
parent | 65694793e9588106e570d82b359c9c9e25a5cf0d (diff) |
work on adding crash report UI
Change-Id: I66f4dca3cd32381ecd52cc36490e7ee1dddf3699
Reviewed-on: https://gerrit.libreoffice.org/22566
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/Library_svx.mk | 5 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/source/dialog/crashreportdlg.cxx | 73 | ||||
-rw-r--r-- | svx/source/dialog/crashreportdlg.hxx | 36 | ||||
-rw-r--r-- | svx/source/dialog/crashreportui.cxx | 100 | ||||
-rw-r--r-- | svx/uiconfig/ui/crashreportdlg.ui | 67 | ||||
-rw-r--r-- | svx/util/svx.component | 4 |
7 files changed, 286 insertions, 0 deletions
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 296312d2aa27..8869014381a7 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -46,6 +46,8 @@ $(eval $(call gb_Library_use_libraries,svx,\ comphelper \ cppuhelper \ cppu \ + $(call gb_Helper_optional,BREAKPAD, \ + crashreport) \ $(call gb_Helper_optional,DBCONNECTIVITY, \ dbtools) \ drawinglayer \ @@ -108,6 +110,9 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/dialog/_contdlg \ svx/source/dialog/contwnd \ svx/source/dialog/compressgraphicdialog \ + $(call gb_Helper_optional,BREAKPAD, \ + svx/source/dialog/crashreportdlg \ + svx/source/dialog/crashreportui) \ svx/source/dialog/ctredlin \ svx/source/dialog/databaseregistrationui \ svx/source/dialog/dialcontrol \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 650ecf917408..39df1db7c2b8 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -22,6 +22,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/chinesedictionary \ svx/uiconfig/ui/colorwindow \ svx/uiconfig/ui/compressgraphicdialog \ + svx/uiconfig/ui/crashreportdlg \ svx/uiconfig/ui/datanavigator \ svx/uiconfig/ui/deleteheaderdialog \ svx/uiconfig/ui/deletefooterdialog \ diff --git a/svx/source/dialog/crashreportdlg.cxx b/svx/source/dialog/crashreportdlg.cxx new file mode 100644 index 000000000000..74066a8dea7e --- /dev/null +++ b/svx/source/dialog/crashreportdlg.cxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "crashreportdlg.hxx" + +#include <config_folders.h> + +#include <rtl/bootstrap.hxx> +#include <desktop/crashreport.hxx> + +CrashReportDialog::CrashReportDialog(vcl::Window* pParent): + Dialog(pParent, "CrashReportDialog", + "svx/ui/crashreportdlg.ui") +{ + get(mpBtnSend, "btn_send"); + get(mpBtnCancel, "btn_cancel"); + + mpBtnSend->SetClickHdl(LINK(this, CrashReportDialog, BtnHdl)); + mpBtnCancel->SetClickHdl(LINK(this, CrashReportDialog, BtnHdl)); +} + +CrashReportDialog::~CrashReportDialog() +{ + disposeOnce(); +} + +void CrashReportDialog::dispose() +{ + mpBtnSend.clear(); + mpBtnCancel.clear(); + + Dialog::dispose(); +} + +namespace { + +OString getLibDir() +{ + OUString aOriginal = "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER; + rtl::Bootstrap::expandMacros(aOriginal); + + return rtl::OUStringToOString(aOriginal, RTL_TEXTENCODING_UTF8); +} + +} + +IMPL_LINK_TYPED(CrashReportDialog, BtnHdl, Button*, pBtn, void) +{ + if (pBtn == mpBtnSend.get()) + { + std::string ini_path = CrashReporter::getIniFileName(); + OString aCommand = getLibDir().copy(7) + "/minidump_upload " + ini_path.c_str(); + int retVal = std::system(aCommand.getStr()); + SAL_WARN_IF(retVal != 0, "crashreport", "Failed to upload minidump. Error Code: " << retVal); + Close(); + } + else if (pBtn == mpBtnCancel.get()) + { + Close(); + } + else + { + assert(false); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/crashreportdlg.hxx b/svx/source/dialog/crashreportdlg.hxx new file mode 100644 index 000000000000..e6041f88f325 --- /dev/null +++ b/svx/source/dialog/crashreportdlg.hxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SVX_SOURCE_DIALOG_CRASHREPORTDLG_HXX +#define INCLUDED_SVX_SOURCE_DIALOG_CRASHREPORTDLG_HXX + +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> + +class CrashReportDialog : public Dialog +{ +public: + + CrashReportDialog(vcl::Window* pParent); + + ~CrashReportDialog(); + + virtual void dispose() override; + +private: + + VclPtr<Button> mpBtnSend; + VclPtr<Button> mpBtnCancel; + + DECL_LINK_TYPED(BtnHdl, Button*, void); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/crashreportui.cxx b/svx/source/dialog/crashreportui.cxx new file mode 100644 index 000000000000..28cac67a3ab5 --- /dev/null +++ b/svx/source/dialog/crashreportui.cxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/frame/XSynchronousDispatch.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <comphelper/processfactory.hxx> +#include <cppuhelper/supportsservice.hxx> + +#include <vcl/svapp.hxx> + +#include "crashreportdlg.hxx" + +namespace { + +class CrashReportUI : public ::cppu::WeakImplHelper< css::lang::XServiceInfo , + css::frame::XSynchronousDispatch > // => XDispatch! +{ +public: + CrashReportUI(const css::uno::Reference< css::uno::XComponentContext >& xContext); + virtual ~CrashReportUI(); + + // css.lang.XServiceInfo + + virtual OUString SAL_CALL getImplementationName() + throw(css::uno::RuntimeException, std::exception) override; + + virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) + throw(css::uno::RuntimeException, std::exception) override; + + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() + throw(css::uno::RuntimeException, std::exception) override; + + + virtual css::uno::Any SAL_CALL dispatchWithReturnValue(const css::util::URL& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) + throw(css::uno::RuntimeException, std::exception) override; + +private: + css::uno::Reference< css::uno::XComponentContext > mxContext; +}; + +CrashReportUI::CrashReportUI(const css::uno::Reference<css::uno::XComponentContext>& xContext): + mxContext(xContext) +{ + +} + +CrashReportUI::~CrashReportUI() +{ +} + +OUString SAL_CALL CrashReportUI::getImplementationName() + throw(css::uno::RuntimeException, std::exception) +{ + return OUString("com.sun.star.comp.svx.CrashReportUI"); +} + +sal_Bool SAL_CALL CrashReportUI::supportsService(const OUString& sServiceName) + throw(css::uno::RuntimeException, std::exception) +{ + return cppu::supportsService(this, sServiceName); +} + +css::uno::Sequence< OUString > SAL_CALL CrashReportUI::getSupportedServiceNames() + throw(css::uno::RuntimeException, std::exception) +{ + css::uno::Sequence< OUString > lServiceNames { "com.sun.star.dialog.CrashReportUI" }; + return lServiceNames; +} + +css::uno::Any SAL_CALL CrashReportUI::dispatchWithReturnValue(const css::util::URL&, + const css::uno::Sequence< css::beans::PropertyValue >& ) + throw(css::uno::RuntimeException, std::exception) +{ + SolarMutexGuard aGuard; + css::uno::Any aRet; + ScopedVclPtrInstance<CrashReportDialog> xDialog(new CrashReportDialog(nullptr)); + xDialog->Execute(); + return aRet; +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_svx_CrashReportUI_get_implementation( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new CrashReportUI(context)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/crashreportdlg.ui b/svx/uiconfig/ui/crashreportdlg.ui new file mode 100644 index 000000000000..e8d1355e7202 --- /dev/null +++ b/svx/uiconfig/ui/crashreportdlg.ui @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> +<interface> + <requires lib="gtk+" version="3.12"/> + <object class="GtkDialog" id="CrashReportDialog"> + <property name="can_focus">False</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="btn_send"> + <property name="label" translatable="yes">Send report</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btn_cancel"> + <property name="label" translatable="yes">Don't send report</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">We are sorry but it seems that LibreOffice crashed the last time. +You can help us fix this issue by sending the crash report to the +LibreOffice crash reporting server.</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/svx/util/svx.component b/svx/util/svx.component index 3f0e38e1eba3..31c8005fd692 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -32,6 +32,10 @@ constructor="com_sun_star_comp_svx_RecoveryUI_get_implementation"> <service name="com.sun.star.dialog.RecoveryUI"/> </implementation> + <implementation name="com.sun.star.comp.svx.CrashReportUI" + constructor="com_sun_star_comp_svx_CrashReportUI_get_implementation"> + <service name="com.sun.star.dialog.CrashReportUI"/> + </implementation> <implementation name="com.sun.star.drawing.EnhancedCustomShapeEngine" constructor="com_sun_star_drawing_EnhancedCustomShapeEngine_get_implementation"> <service name="com.sun.star.drawing.CustomShapeEngine"/> |