2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2002-09-30 14:24:07 +00:00
|
|
|
|
|
|
|
/* Information:
|
|
|
|
* This class implements a mechanism to lock a users installation directory,
|
|
|
|
* which is necessesary because instances of staroffice could be running on
|
|
|
|
* different hosts while using the same directory thus causing data
|
|
|
|
* inconsistency.
|
|
|
|
* When an existing lock is detected, the user will be asked whether he wants
|
|
|
|
* to continue anyway, thus removing the lock and replacing it with a new one
|
|
|
|
*
|
|
|
|
* ideas:
|
|
|
|
* - store information about user and host and time in the lockfile and display
|
|
|
|
* these when asking whether to remove the lockfile.
|
|
|
|
* - periodically check the lockfile and warn the user when it gets replaced
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-05-29 21:12:22 +00:00
|
|
|
#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX
|
|
|
|
#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX
|
|
|
|
|
2014-06-04 10:55:43 +02:00
|
|
|
#include <sal/types.h>
|
|
|
|
#include <rtl/string.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
2005-04-13 07:46:13 +00:00
|
|
|
|
2012-03-12 16:24:34 +01:00
|
|
|
#include "dp_misc_api.hxx"
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
#define LOCKFILE_GROUP OString( "Lockdata" )
|
|
|
|
#define LOCKFILE_USERKEY OString( "User" )
|
|
|
|
#define LOCKFILE_HOSTKEY OString( "Host" )
|
|
|
|
#define LOCKFILE_STAMPKEY OString( "Stamp" )
|
|
|
|
#define LOCKFILE_TIMEKEY OString( "Time" )
|
|
|
|
#define LOCKFILE_IPCKEY OString( "IPCServer" )
|
2010-10-15 11:38:35 +02:00
|
|
|
|
2002-09-30 14:24:07 +00:00
|
|
|
namespace desktop {
|
2004-06-11 11:01:31 +00:00
|
|
|
|
2006-01-19 17:02:49 +00:00
|
|
|
class Lockfile;
|
|
|
|
bool Lockfile_execWarning( Lockfile * that );
|
|
|
|
|
2012-03-12 16:24:34 +01:00
|
|
|
class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Lockfile
|
2002-09-30 14:24:07 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// contructs a new lockfile onject
|
2004-06-11 11:01:31 +00:00
|
|
|
Lockfile( bool bIPCserver = true );
|
|
|
|
|
|
|
|
// separating GUI code:
|
|
|
|
typedef bool (* fpExecWarning)( Lockfile * that );
|
2002-09-30 14:24:07 +00:00
|
|
|
|
2002-11-06 13:44:49 +00:00
|
|
|
// checks the lockfile, asks user when lockfile is
|
2015-06-23 20:42:27 +02:00
|
|
|
// found (iff gui) and returns false when we may not continue
|
2014-04-17 11:33:18 +02:00
|
|
|
bool check( fpExecWarning execWarning );
|
2002-09-30 14:24:07 +00:00
|
|
|
|
|
|
|
// removes the lockfile
|
2015-04-14 12:44:47 +02:00
|
|
|
~Lockfile();
|
2002-09-30 14:24:07 +00:00
|
|
|
|
|
|
|
private:
|
2004-06-11 11:01:31 +00:00
|
|
|
bool m_bIPCserver;
|
2002-09-30 14:24:07 +00:00
|
|
|
// full qualified name (file://-url) of the lockfile
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_aLockname;
|
2002-09-30 14:24:07 +00:00
|
|
|
// flag whether the d'tor should delete the lock
|
2014-04-17 11:33:18 +02:00
|
|
|
bool m_bRemove;
|
|
|
|
bool m_bIsLocked;
|
2002-09-30 14:24:07 +00:00
|
|
|
// ID
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_aId;
|
|
|
|
OUString m_aDate;
|
2002-09-30 14:24:07 +00:00
|
|
|
// access to data in file
|
2015-04-14 12:44:47 +02:00
|
|
|
void syncToFile() const;
|
|
|
|
bool isStale() const;
|
2004-06-11 11:01:31 +00:00
|
|
|
friend bool Lockfile_execWarning( Lockfile * that );
|
2002-09-30 14:24:07 +00:00
|
|
|
|
|
|
|
};
|
2004-06-11 11:01:31 +00:00
|
|
|
|
2002-10-04 09:32:20 +00:00
|
|
|
}
|
2010-10-27 13:11:31 +01:00
|
|
|
|
2014-05-29 21:12:22 +00:00
|
|
|
#endif // INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX
|
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|