summaryrefslogtreecommitdiff
path: root/svx/source/dialog/crashreportdlg.cxx
blob: aeb5c14fb192eaca1e317dc2905acebacb77bbf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* -*- 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>
#include <osl/file.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 {

OUString getLibDir()
{
    OUString aOriginal = "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER;
    rtl::Bootstrap::expandMacros(aOriginal);

    return aOriginal;
}

}

IMPL_LINK_TYPED(CrashReportDialog, BtnHdl, Button*, pBtn, void)
{
    if (pBtn == mpBtnSend.get())
    {
        std::string ini_path = CrashReporter::getIniFileName();
        OUString aCommand;
        osl::FileBase::getSystemPathFromFileURL(getLibDir() + "/minidump_upload" + SAL_EXEEXTENSION, aCommand);

        aCommand = aCommand;
        OString aOStringCommand = rtl::OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8) + " " + ini_path.c_str();
        int retVal = std::system(aOStringCommand.getStr());
        SAL_WARN_IF(retVal != 0, "svx.dialog", "Failed to upload minidump. Error Code: " << retVal);
        // TODO: moggi: return the id for the user to look it up
        Close();
    }
    else if (pBtn == mpBtnCancel.get())
    {
        Close();
    }
    else
    {
        assert(false);
    }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */