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 
27 namespace desktop {
28 
29 bool 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: */
Definition: app.cxx:166
void SetGroup(const OString &rGroup)
#define LOCKFILE_HOSTKEY
Definition: lockfile.hxx:46
OUString m_aLockname
Definition: lockfile.hxx:76
RET_YES
OString ReadKey(const OString &rKey) const
#define LOCKFILE_USERKEY
Definition: lockfile.hxx:45
#define LOCKFILE_GROUP
Definition: lockfile.hxx:44
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
OUString DpResId(const char *pId)
Definition: dp_shared.hxx:38
bool Lockfile_execWarning(Lockfile const *that)
Definition: lockfile2.cxx:29
#define LOCKFILE_TIMEKEY
Definition: lockfile.hxx:48