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