LibreOffice Module desktop (master) 1
lockfile2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <vcl/svapp.hxx>
21#include <vcl/weld.hxx>
22#include <dp_shared.hxx>
23#include <strings.hrc>
24#include <tools/config.hxx>
25#include <lockfile.hxx>
26
27namespace desktop {
28
29bool Lockfile_execWarning( Lockfile const * that )
30{
31 // read information from lock
32 OUString aLockname = that->m_aLockname;
33 Config aConfig(aLockname);
34 aConfig.SetGroup( LOCKFILE_GROUP );
35 OString aHost = aConfig.ReadKey( LOCKFILE_HOSTKEY );
36 OString aUser = aConfig.ReadKey( LOCKFILE_USERKEY );
37 OString aTime = aConfig.ReadKey( LOCKFILE_TIMEKEY );
38
39 // display warning and return response
40 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
41 VclMessageType::Question, VclButtonsType::YesNo, DpResId(STR_QUERY_USERDATALOCKED)));
42 // set box title
43 OUString aTitle = DpResId(STR_TITLE_USERDATALOCKED);
44 xBox->set_title( aTitle );
45 // insert values...
46 OUString aMsgText = xBox->get_primary_text();
47 aMsgText = aMsgText.replaceFirst(
48 "$u", OStringToOUString( aUser, RTL_TEXTENCODING_ASCII_US) );
49 aMsgText = aMsgText.replaceFirst(
50 "$h", OStringToOUString( aHost, RTL_TEXTENCODING_ASCII_US) );
51 aMsgText = aMsgText.replaceFirst(
52 "$t", OStringToOUString( aTime, RTL_TEXTENCODING_ASCII_US) );
53 xBox->set_primary_text(aMsgText);
54 // do it
55 return xBox->run() == RET_YES;
56}
57
58}
59
60/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
void SetGroup(const OString &rGroup)
OString ReadKey(const OString &rKey) const
OUString m_aLockname
Definition: lockfile.hxx:73
OUString DpResId(TranslateId aId)
Definition: dp_misc.cxx:555
#define LOCKFILE_GROUP
Definition: lockfile.hxx:41
#define LOCKFILE_HOSTKEY
Definition: lockfile.hxx:43
#define LOCKFILE_TIMEKEY
Definition: lockfile.hxx:45
#define LOCKFILE_USERKEY
Definition: lockfile.hxx:42
Definition: app.cxx:167
bool Lockfile_execWarning(Lockfile const *that)
Definition: lockfile2.cxx:29
RET_YES