bump product version to 4.1.6.2
[LibreOffice.git] / desktop / source / deployment / inc / lockfile.hxx
blob1e041244a28116a32009b4eccbc3b2b1e89116d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 /* Information:
21 * This class implements a mechanism to lock a users installation directory,
22 * which is necessesary because instances of staroffice could be running on
23 * different hosts while using the same directory thus causing data
24 * inconsistency.
25 * When an existing lock is detected, the user will be asked whether he wants
26 * to continue anyway, thus removing the lock and replacing it with a new one
28 * ideas:
29 * - store information about user and host and time in the lockfile and display
30 * these when asking whether to remove the lockfile.
31 * - periodically check the lockfile and warn the user when it gets replaced
35 #include "sal/types.h"
36 #include "rtl/string.hxx"
37 #include "rtl/ustring.hxx"
39 #include "dp_misc_api.hxx"
41 #define LOCKFILE_SUFFIX OUString( "/.lock" )
42 #define LOCKFILE_GROUP OString( "Lockdata" )
43 #define LOCKFILE_USERKEY OString( "User" )
44 #define LOCKFILE_HOSTKEY OString( "Host" )
45 #define LOCKFILE_STAMPKEY OString( "Stamp" )
46 #define LOCKFILE_TIMEKEY OString( "Time" )
47 #define LOCKFILE_IPCKEY OString( "IPCServer" )
49 namespace desktop {
51 class Lockfile;
52 bool Lockfile_execWarning( Lockfile * that );
54 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Lockfile
56 public:
58 // contructs a new lockfile onject
59 Lockfile( bool bIPCserver = true );
61 // separating GUI code:
62 typedef bool (* fpExecWarning)( Lockfile * that );
64 // checks the lockfile, asks user when lockfile is
65 // found (iff gui) and returns false when we may not continue
66 sal_Bool check( fpExecWarning execWarning );
68 // removes the lockfile
69 ~Lockfile(void);
71 private:
72 bool m_bIPCserver;
73 // full qualified name (file://-url) of the lockfile
74 OUString m_aLockname;
75 // flag whether the d'tor should delete the lock
76 sal_Bool m_bRemove;
77 sal_Bool m_bIsLocked;
78 // ID
79 OUString m_aId;
80 OUString m_aDate;
81 // access to data in file
82 void syncToFile(void) const;
83 sal_Bool isStale(void) const;
84 friend bool Lockfile_execWarning( Lockfile * that );
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */