summaryrefslogtreecommitdiff
path: root/desktop/source/app/lockfile.cxx
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2003-12-01 10:44:42 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2003-12-01 10:44:42 +0000
commitbcf862eacf83e12ab8cc12cdeccfc4cfbac0e5e1 (patch)
treebf3f0d3cf44220e5ecf0cdfdccb556d91153f9db /desktop/source/app/lockfile.cxx
parent7a83a7c4f47a9754d6f6bab7b1a54d1986b8f5be (diff)
INTEGRATION: CWS geordi2q09 (1.5.156); FILE MERGED
2003/11/21 10:54:42 obo 1.5.156.1: #111934#: join CWS pmselectedfixes2
Diffstat (limited to 'desktop/source/app/lockfile.cxx')
-rw-r--r--desktop/source/app/lockfile.cxx63
1 files changed, 57 insertions, 6 deletions
diff --git a/desktop/source/app/lockfile.cxx b/desktop/source/app/lockfile.cxx
index 8e25b50c93..a89eae9ea9 100644
--- a/desktop/source/app/lockfile.cxx
+++ b/desktop/source/app/lockfile.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: lockfile.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: hr $ $Date: 2003-04-04 17:22:51 $
+ * last change: $Author: rt $ $Date: 2003-12-01 11:44:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,6 +60,11 @@
************************************************************************/
#include <stdlib.h>
#include <time.h>
+#ifdef WNT
+#include <tools/prewin.h>
+#include <windows.h>
+#include <tools/postwin.h>
+#endif
#include <sal/types.h>
#include <osl/file.hxx>
#include <osl/socket.hxx>
@@ -69,10 +74,12 @@
#include <tools/string.hxx>
#include <tools/config.hxx>
+
#include "desktopresid.hxx"
#include "lockfile.hxx"
#include "desktop.hrc"
+
using namespace ::osl;
using namespace ::rtl;
using namespace ::utl;
@@ -114,8 +121,13 @@ namespace desktop {
// generate date string
char *tmpTime = ctime( &t );
- tmpTime[24] = 0x00; // buffer is always 26 chars, remove '\n'
- m_aDate = OUString::createFromAscii( tmpTime );
+ if (tmpTime != NULL) {
+ m_aDate = OUString::createFromAscii( tmpTime );
+ sal_Int32 i = m_aDate.indexOf('\n');
+ if (i > 0)
+ m_aDate = m_aDate.copy(0, i);
+ }
+
// try to create file
File aFile(m_aLockname);
@@ -166,8 +178,23 @@ namespace desktop {
ByteString aUser = aConfig.ReadKey( m_aUserkey );
// lockfile from same host?
oslSocketResult sRes;
- ByteString myHost = OUStringToOString(
+ ByteString myHost;
+#ifdef WNT
+ /*
+ prevent windows from connecting to the net to get it's own
+ hostname by using the netbios name
+ */
+ sal_Int32 sz = MAX_COMPUTERNAME_LENGTH + 1;
+ char* szHost = new char[sz];
+ if (GetComputerName(szHost, (LPDWORD)&sz))
+ myHost = OString(szHost);
+ else
+ myHost = OString("UNKNOWN");
+ delete[] szHost;
+#else
+ myHost = OUStringToOString(
SocketAddr::getLocalHostname( &sRes ), RTL_TEXTENCODING_ASCII_US );
+#endif
if (aHost == myHost) {
// lockfile by same UID
OUString myUserName;
@@ -188,8 +215,23 @@ namespace desktop {
// get information
oslSocketResult sRes;
- ByteString aHost = OUStringToOString(
+ ByteString aHost;
+#ifdef WNT
+ /*
+ prevent windows from connecting to the net to get it's own
+ hostname by using the netbios name
+ */
+ sal_Int32 sz = MAX_COMPUTERNAME_LENGTH + 1;
+ char* szHost = new char[sz];
+ if (GetComputerName(szHost, (LPDWORD)&sz))
+ aHost = OString(szHost);
+ else
+ aHost = OString("UNKNOWN");
+ delete[] szHost;
+#else
+ aHost = OUStringToOString(
SocketAddr::getLocalHostname( &sRes ), RTL_TEXTENCODING_ASCII_US );
+#endif
OUString aUserName;
Security aSecurity;
aSecurity.getUserName( aUserName );
@@ -247,3 +289,12 @@ namespace desktop {
File::remove( m_aLockname );
}
}
+
+
+
+
+
+
+
+
+