2002-07-27 23:48:47 +00:00
|
|
|
/** GSWSessionTimeOut.m - <title>GSWeb: Class GSWSessionTimeOut</title>
|
|
|
|
|
|
|
|
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
|
|
Date: Mar 1999
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
$Revision$
|
|
|
|
$Date$
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
This file is part of the GNUstep Web Library.
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
<license>
|
2000-01-22 12:49:49 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2002-07-27 23:48:47 +00:00
|
|
|
</license>
|
|
|
|
**/
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
static char rcsId[] = "$Id$";
|
|
|
|
|
2000-10-30 15:36:50 +00:00
|
|
|
#include <GSWeb/GSWeb.h>
|
2000-01-22 12:49:49 +00:00
|
|
|
#include "GSWSessionTimeOut.h"
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSessionTimeOut
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(id)initWithSessionID:(NSString*)aSessionID
|
|
|
|
lastAccessTime:(NSTimeInterval)aTime
|
|
|
|
sessionTimeOut:(NSTimeInterval)aTimeOutInterval
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
if ((self=[super init]))
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
ASSIGN(_sessionID,aSessionID);
|
|
|
|
_lastAccessTime=aTime;
|
|
|
|
_timeOut=aTimeOutInterval;
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
+(id)timeOutWithSessionID:(NSString*)aSessionID
|
|
|
|
lastAccessTime:(NSTimeInterval)aTime
|
|
|
|
sessionTimeOut:(NSTimeInterval)aTimeOutInterval
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return [[[self alloc]initWithSessionID:aSessionID
|
|
|
|
lastAccessTime:aTime
|
|
|
|
sessionTimeOut:aTimeOutInterval]autorelease];
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
NSDebugFLog0(@"Dealloc GSWSessionTimeOut");
|
2002-07-27 23:48:47 +00:00
|
|
|
if (_sessionID)
|
|
|
|
{
|
|
|
|
NSDebugFLog(@"sessionIDCount=%u",[_sessionID retainCount]);
|
|
|
|
};
|
|
|
|
DESTROY(_sessionID);
|
2000-01-22 12:49:49 +00:00
|
|
|
[super dealloc];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)description
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat:@"<%s %p - sessionID=%@ timeOutTime=%f lastAccessTime=%f timeOut=%ld",
|
2002-07-27 23:48:47 +00:00
|
|
|
object_get_class_name(self),
|
|
|
|
(void*)self,
|
|
|
|
_sessionID,
|
|
|
|
[self timeOutTime],
|
|
|
|
_lastAccessTime,
|
|
|
|
(long)_timeOut];
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(NSComparisonResult)compareTimeOutDate:(GSWSessionTimeOut*)timeOutObject
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
if (timeOutObject)
|
|
|
|
{
|
|
|
|
if ([self timeOutTime]<[timeOutObject timeOutTime])
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else if ([self timeOutTime]==[timeOutObject timeOutTime])
|
|
|
|
return NSOrderedSame;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-07-27 23:48:47 +00:00
|
|
|
return NSOrderedDescending;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSTimeInterval)sessionTimeOut
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _timeOut;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setSessionTimeOut:(NSTimeInterval)aTimeOutInterval
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
_timeOut=aTimeOutInterval;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)sessionID
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _sessionID;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setLastAccessTime:(NSTimeInterval)aTime
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
_lastAccessTime=aTime;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSTimeInterval)lastAccessTime
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _lastAccessTime;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSTimeInterval)timeOutTime
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _lastAccessTime+_timeOut;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|