1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 bool Lockfile_execWarning( Lockfile
const * that
)
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
);
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
)));
43 OUString aTitle
= DpResId(STR_TITLE_USERDATALOCKED
);
44 xBox
->set_title( aTitle
);
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
);
55 return xBox
->run() == RET_YES
;
60 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */