merge the formfield patch from ooo-build
[ooovba.git] / desktop / source / app / lockfile2.cxx
blobce9cc1eaae483d56263494db62dbe32988666ffa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: lockfile2.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_desktop.hxx"
34 #include "vcl/msgbox.hxx"
35 #include "desktopresid.hxx"
36 #include "desktop.hrc"
37 #include "tools/config.hxx"
38 #include "lockfile.hxx"
41 namespace desktop {
43 bool Lockfile_execWarning( Lockfile * that )
45 // read information from lock
46 String aLockname = that->m_aLockname;
47 Config aConfig(aLockname);
48 aConfig.SetGroup( LOCKFILE_GROUP );
49 ByteString aHost = aConfig.ReadKey( LOCKFILE_HOSTKEY );
50 ByteString aUser = aConfig.ReadKey( LOCKFILE_USERKEY );
51 ByteString aStamp = aConfig.ReadKey( LOCKFILE_STAMPKEY );
52 ByteString aTime = aConfig.ReadKey( LOCKFILE_TIMEKEY );
54 // display warning and return response
55 QueryBox aBox( NULL, DesktopResId( QBX_USERDATALOCKED ) );
56 // set box title
57 String aTitle = String( DesktopResId( STR_TITLE_USERDATALOCKED ));
58 aBox.SetText( aTitle );
59 // insert values...
60 String aMsgText = aBox.GetMessText( );
61 aMsgText.SearchAndReplaceAscii(
62 "$u", String( aUser, RTL_TEXTENCODING_ASCII_US) );
63 aMsgText.SearchAndReplaceAscii(
64 "$h", String( aHost, RTL_TEXTENCODING_ASCII_US) );
65 aMsgText.SearchAndReplaceAscii(
66 "$t", String( aTime, RTL_TEXTENCODING_ASCII_US) );
67 aBox.SetMessText(aMsgText);
68 // do it
69 return aBox.Execute( ) == RET_YES;