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