LibreOffice Module desktop (master)  1
lockfile.hxx
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 /* Information:
21  * This class implements a mechanism to lock a users installation directory,
22  * which is necessary 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
27  *
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
32  *
33  */
34 
35 #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX
36 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX
37 
38 #include <sal/types.h>
39 #include <rtl/string.hxx>
40 #include <rtl/ustring.hxx>
41 
42 #include "dp_misc_api.hxx"
43 
44 #define LOCKFILE_GROUP "Lockdata"
45 #define LOCKFILE_USERKEY "User"
46 #define LOCKFILE_HOSTKEY "Host"
47 #define LOCKFILE_STAMPKEY "Stamp"
48 #define LOCKFILE_TIMEKEY "Time"
49 #define LOCKFILE_IPCKEY "IPCServer"
50 
51 namespace desktop {
52 
53  class Lockfile;
54  bool Lockfile_execWarning( Lockfile const * that );
55 
57  {
58  public:
59 
60  // constructs a new lockfile onject
61  Lockfile( bool bIPCserver = true );
62 
63  // separating GUI code:
64  typedef bool (* fpExecWarning)( Lockfile const * that );
65 
66  // checks the lockfile, asks user when lockfile is
67  // found (iff gui) and returns false when we may not continue
68  bool check( fpExecWarning execWarning );
69 
70  // removes the lockfile
71  ~Lockfile();
72 
73  private:
75  // full qualified name (file://-url) of the lockfile
76  OUString m_aLockname;
77  // flag whether the d'tor should delete the lock
78  bool m_bRemove;
80  // ID
81  OUString m_aId;
82  OUString m_aDate;
83  // access to data in file
84  void syncToFile() const;
85  bool isStale() const;
86  friend bool Lockfile_execWarning( Lockfile const * that );
87 
88  };
89 
90 }
91 
92 #endif // INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX
93 
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: app.cxx:167
OUString m_aLockname
Definition: lockfile.hxx:76
def check(model)
#define DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
Definition: dp_misc_api.hxx:29
OUString m_aDate
Definition: lockfile.hxx:82
OUString m_aId
Definition: lockfile.hxx:81
bool Lockfile_execWarning(Lockfile const *that)
Definition: lockfile2.cxx:29