2002-07-27 23:48:47 +00:00
|
|
|
/** GSWSession.m - <title>GSWeb: Class GSWSession</title>
|
|
|
|
|
2003-01-19 15:33:07 +00:00
|
|
|
Copyright (C) 1999-2003 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: Jan 1999
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
$Revision$
|
|
|
|
$Date$
|
2003-01-19 15:33:07 +00:00
|
|
|
$Id$
|
2002-07-27 23:48:47 +00:00
|
|
|
|
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
|
|
|
|
2003-03-21 14:32:57 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
RCS_ID("$Id$")
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-01-22 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/Makefile.postamble:
o use $(LN_S) -f in install-WO-headers
o added $(MKDIRS) $(GNUSTEP_HEADERS)/$(GSWExtensions_wo_HEADER_FILES_INSTALL_DIR);
* GSWExtensionsGSW.framework/Makefile.postamble: use $(LN_S) -f in install-WO-headers
2003-01-20 David Ayers <d.ayers@inode.at>
* Makefile.postamble
o added support for make gswnames=(gsw,wo,all) (corrected
typo)
o reinserted support for $(INSTALL_ROOT_DIR)
* config.h.in
o added HAVE_GDL2
* configure
o added support for --with-gswnames=(gsw,wo,all)
o set LIBWRAP during configure
o added config.mak.in as configurable file
* configure.ac
o (see configure)
* config.mak: removed (replaced by config.mak.in)
* config.mak.in: new file
o added support for make gswnames=(gsw,wo,all)
* gsweb.make.in
o add GSANTLR as auxiliary lib
o add gsweb libs to AUXILIARY_GSW_LIBS
o include correct extensions for GSW/WO-libs
* gsweb_wo.make: new file
* GSWeb/GSWConfig.h
o changed support for GSWEB_WONAMES
o conditionally import file GSWWOCompatiblity
here instead of in GSWeb.h
* GSWeb/GNUMakefile
o added support for make gswnames=(gsw,wo,all)
o ensure each lib gets built with its own object files
o removed deactivated framework extension determination code
o removed reference to unused files:
GSWeb.m, GSWWOCompatibility.m
o added references to new files:
GSWExtenstions.h, GSWExtWOCompatibility.h
o added support to create WO header files
* GSWeb/Makefile.postamble
o changed support to install WO header files according to
make gswnames=(gsw,wo,all)
o remove Makefile.preamble during distclean
* GSWeb/Makefile.preamble.in
o fixed typo
* GSWeb/GSWeb.h
o moved GSW/WO-Name-mapping to GSWWOCompatibility.h
o replaced inclusions of
<GSWeb/file.h> with "file.h"
* GSWeb/GSWeb.m: removed
* GSWeb/GSWWOCompatibility.h
o changed GSWEB_WONAMES handling
o removed hybrid namespace WO subclasses
o moved & reorganized GSW/WO-Name-mapping from GSWeb.h
o inlucluded missing GSW/WO-Name-mappings
* GSWeb/GSWWOCompatibility.m: removed
* GSWeb/*.m
o replaced inclusions of
<GSWeb/file.h> with "file.h"
* GSWeb/GSWApplication.m
o remove special GSW/WO handling of WOApp
* GSWeb/WebObject/WO*: removed
* GSWeb/WebObject/WebObjects
o replaced inclusions of
<GSWeb/file.h> with "file.h"
* GSWExtensions/GNUMakefile
o added support for make gswnames=(gsw,wo,all)
o ensure each lib gets built with its own object files
o removed deactivated framework extension determination code
o added references to new files:
GSWExtenstions.h, GSWExtWOCompatibility.h
o added support to create WO header files
* GSWExtensions/Makefile.preamble
o let gnustep make figure whether to link agains debug libs
o added support for make gswnames=(gsw,wo,all)
* GSWExtensions/Makefile.postamble
o changed support to install WO header files according to
make gswnames=(gsw,wo,all)
* GSWExtensions/*.m
o replaced inclusions of
<GSWeb/GSWeb.h> with "GSWExtWOCompatibility.h"
o replaces inclusions of
<GSWExtensions/file.h> with "file.h"
* GSWExtensions/GSWExtensions.h: new file
* GSWExtensions/WOExtensions.h: new file
* GSWExtensions/GSWExtWOCompatibility.h: new file
* GSWExtensionsGSW/GNUMakefile
o added support for make gswnames=(gsw,wo,all)
o ensure each lib gets built with its own object files
o removed deactivated framework extension determination code
o added references to new file GSWExtGSWWOCompatibility.h
o added support to create WO header files
* GSWExtensionsGSW/Makefile.pramble
o let gnustep make figure whether to link agains debug libs
o added support for make gswnames=(gsw,wo,all)
o removed GSWExtensions from ADDITIONAL_LIB_DIRS
* GSWExtensionsGSW/*.m
o replaced inclusions of
<GSWeb/GSWeb.h> with "GSWExtGSWWOCompatibility.h"
* GSWExtensions/GSWExtGSWWOCompatibility.h: new file
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@15675 72102866-910b-0410-8b05-ffd578937521
2003-01-22 12:24:26 +00:00
|
|
|
#include "GSWeb.h"
|
2003-02-01 19:07:25 +00:00
|
|
|
#include <gnustep/base/GSCategories.h>
|
|
|
|
|
2003-01-19 15:33:07 +00:00
|
|
|
#include <time.h>
|
|
|
|
#if __linux__
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sys.h>
|
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
#endif
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
@implementation GSWSession
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// init
|
|
|
|
-(id)init
|
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
|
|
|
if ((self = [super init]))
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
NSTimeInterval sessionTimeOut=[GSWApplication sessionTimeOutValue];
|
|
|
|
NSDebugMLLog(@"sessions",@"sessionTimeOut=%ld",(long)sessionTimeOut);
|
|
|
|
[self setTimeOut:sessionTimeOut];
|
2003-01-19 15:33:07 +00:00
|
|
|
[self _initWithSessionID:[[self class]createSessionID]];
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(id)copyWithZone: (NSZone*)zone
|
|
|
|
{
|
|
|
|
GSWSession* clone = [[isa allocWithZone: zone] init];
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
/*
|
|
|
|
[clone setSessionID:sessionID];
|
|
|
|
[clone setLanguages:languages];
|
|
|
|
[clone setTimeOut:timeOut];
|
|
|
|
[clone setVariables:[[variables copy]autorelease]];
|
|
|
|
[clone setPageCache:[[pageCache copy]autorelease]];
|
|
|
|
*/
|
|
|
|
return clone;
|
|
|
|
};
|
|
|
|
|
2003-01-19 15:33:07 +00:00
|
|
|
+(NSString*)createSessionID
|
|
|
|
{
|
|
|
|
// The idea is to have uniq sessionID generated.
|
|
|
|
// Parts are:
|
|
|
|
// o a modified TimeStamp (modified because we don't want to give
|
|
|
|
// information on server exact time which can be always a security
|
|
|
|
// problem), so we can remember this sessionID for long time without conflict
|
|
|
|
// o a md5 sum of various elements
|
|
|
|
|
|
|
|
// The generated session ID is a sizeof(time_t)+16 bytes string
|
|
|
|
|
|
|
|
NSString* sessionID=nil;
|
|
|
|
NSMutableData* data=nil;
|
|
|
|
NSMutableData* md5Data=nil;
|
|
|
|
NSData* md5Sum=nil;
|
|
|
|
void* pMd5Data=NULL;
|
|
|
|
time_t ts=time(NULL);
|
|
|
|
int sizeToFill=64;
|
|
|
|
|
|
|
|
md5Data=[NSMutableData dataWithLength:64];
|
|
|
|
pMd5Data=[md5Data mutableBytes];
|
|
|
|
|
|
|
|
// initialize random generator
|
|
|
|
// We xor time stamp with a pointer so 2 sessions created at the same
|
|
|
|
// time won't have the same random generator initializer
|
|
|
|
srand(((unsigned long int)ts) ^ ((unsigned long int)md5Data));
|
|
|
|
|
|
|
|
// We randomize on 60s
|
|
|
|
ts=ts+(int)(60*rand()/(RAND_MAX+1.0));
|
|
|
|
|
|
|
|
data=[NSMutableData dataWithBytes:&ts
|
|
|
|
length:sizeof(ts)];
|
|
|
|
|
|
|
|
// Now, use some system related chnaging info (
|
|
|
|
#if __linux__
|
|
|
|
{
|
|
|
|
struct sysinfo info;
|
|
|
|
if ((sysinfo(&info)) == 0)
|
|
|
|
{
|
|
|
|
unsigned int rnd;
|
|
|
|
|
|
|
|
// >0 test is to ignore not changing elements
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.uptime>0)
|
|
|
|
{
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLog(@"UPTIME %ld",(long)info.uptime);
|
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.uptime)) ^ rnd);
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.loads[0]>0)
|
|
|
|
{
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLog(@"loads[0] %ld",(long)info.loads[0]);
|
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.loads[0] >> 4)) ^ rnd);
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.loads[1]>0)
|
|
|
|
{
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLog(@"loads[1] %ld",(long)info.loads[1]);
|
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.loads[1] >> 4)) ^ rnd);
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.loads[2]>0)
|
|
|
|
{
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLog(@"loads[2] %ld",(long)info.loads[2]);
|
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.loads[2] >> 4)) ^ rnd);
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.freeram>0)
|
|
|
|
{
|
|
|
|
NSDebugMLog(@"freeram %ld",(unsigned long)info.freeram);
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.freeram >> 4)) ^ rnd); // Drop 4 minor bits
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.sharedram>0)
|
|
|
|
{
|
|
|
|
NSDebugMLog(@"sharedram %ld",(unsigned long)info.sharedram);
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.sharedram >> 4)) ^ rnd); // Drop 4 minor bits
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.freeswap>0)
|
|
|
|
{
|
|
|
|
NSDebugMLog(@"freeswap %ld",(unsigned long)info.freeswap);
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.freeswap >> 4)) ^ rnd); // Drop 4 minor bits
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (sizeToFill>=sizeof(unsigned int) && info.bufferram>0)
|
|
|
|
{
|
|
|
|
NSDebugMLog(@"bufferram %ld",(unsigned long)info.bufferram);
|
2003-02-01 19:07:25 +00:00
|
|
|
rnd=(unsigned)(((float)UINT_MAX)*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
*((unsigned int*)pMd5Data)=(((unsigned int)(info.bufferram >> 4)) ^ rnd); // Drop 4 minor bits
|
|
|
|
sizeToFill-=sizeof(unsigned int);
|
|
|
|
pMd5Data+=sizeof(unsigned int);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
NSDebugMLog(@"sizeToFill %d",sizeToFill);
|
|
|
|
while(sizeToFill>0)
|
|
|
|
{
|
2003-02-01 19:07:25 +00:00
|
|
|
*((unsigned char*)pMd5Data)=(unsigned char)(256.0*rand()/(RAND_MAX+1.0));
|
2003-01-19 15:33:07 +00:00
|
|
|
sizeToFill--;
|
|
|
|
pMd5Data++;
|
|
|
|
};
|
|
|
|
//Now do md5 on bytes after sizeof(ts)
|
2003-02-01 19:07:25 +00:00
|
|
|
md5Sum=[md5Data md5Digest];
|
2003-01-19 15:33:07 +00:00
|
|
|
[data appendData:md5Sum];
|
2003-02-01 19:07:25 +00:00
|
|
|
sessionID=[data hexadecimalRepresentation];
|
2003-01-19 15:33:07 +00:00
|
|
|
return sessionID;
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)encodeWithCoder:(NSCoder*)coder
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
[super encodeWithCoder:coder];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
/*
|
|
|
|
[coder_ encodeObject:sessionID];
|
|
|
|
[coder_ encodeObject:languages];
|
|
|
|
[coder_ encodeValueOfObjCType: @encode(NSTimeInterval) at: &timeOut];
|
|
|
|
[coder_ encodeObject:variables];
|
|
|
|
[coder_ encodeObject:pageCache];
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(id)initWithCoder: (NSCoder*)coder
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
self = [super initWithCoder: coder];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
/*
|
|
|
|
[coder_ decodeValueOfObjCType: @encode(id) at:&sessionID];
|
|
|
|
[coder_ decodeValueOfObjCType: @encode(id) at:&languages];
|
|
|
|
[coder_ decodeValueOfObjCType: @encode(NSTimeInterval) at: &timeOut];
|
|
|
|
[coder_ decodeValueOfObjCType: @encode(id) at:&variables];
|
|
|
|
[coder_ decodeValueOfObjCType: @encode(id) at:&pageCache];
|
|
|
|
*/
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
2000-03-20 15:50:51 +00:00
|
|
|
GSWLogAssertGood(self);
|
2003-02-01 19:07:25 +00:00
|
|
|
NSDebugFLog(@"Dealloc GSWSession %p. ThreadID=%p",(void*)self,(void*)objc_thread_id());
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: sessionID");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_sessionID);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession:autoreleasePool ");
|
2003-02-01 19:07:25 +00:00
|
|
|
GSWLogMemCF("Destroy NSAutoreleasePool: %p. ThreadID=%p",_autoreleasePool,(void*)objc_thread_id());
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_autoreleasePool);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: contextArrayStack");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_contextArrayStack);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: contextRecords");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_contextRecords);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: editingContext");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_editingContext);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: languages");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_languages);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: componentState");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_componentState);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: birthDate");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_birthDate);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: statistics");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_statistics);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: formattedStatistics");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_formattedStatistics);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: currentContext (set to nil)");
|
2002-07-27 23:48:47 +00:00
|
|
|
_currentContext=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: permanentPageCache");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_permanentPageCache);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession: permanentContextIDArray");
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_permanentContextIDArray);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugFLog0(@"Dealloc GSWSession Super");
|
|
|
|
[super dealloc];
|
|
|
|
NSDebugFLog0(@"End Dealloc GSWSession");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)description
|
|
|
|
{
|
|
|
|
NSString* dscr=nil;
|
2000-03-20 15:50:51 +00:00
|
|
|
GSWLogAssertGood(self);
|
2000-01-22 12:49:49 +00:00
|
|
|
/*
|
|
|
|
NSDebugMLLog(@"sessions",@"selfCount=%u",(unsigned int)[self retainCount]);
|
|
|
|
NSDebugMLLog(@"sessions",@"sessionIDCount=%u",(unsigned int)[sessionID retainCount]);
|
|
|
|
*/
|
|
|
|
dscr=[NSString stringWithFormat:@"<%s %p>",
|
|
|
|
object_get_class_name(self),
|
|
|
|
(void*)self];
|
|
|
|
/*
|
|
|
|
dscr=[NSString stringWithFormat:@"<%s %p - sessionID=%@ autoreleasePool=%p timeOut=%f contextArrayStack=%@",
|
|
|
|
object_get_class_name(self),
|
|
|
|
(void*)self,
|
|
|
|
sessionID,
|
|
|
|
(void*)autoreleasePool,
|
|
|
|
timeOut,
|
|
|
|
contextArrayStack];
|
|
|
|
dscr=[dscr stringByAppendingFormat:@" contextRecords=%@ editingContext=%p languages=%@ componentState=%@ birthDate=%@",
|
|
|
|
contextRecords,
|
|
|
|
(void*)editingContext,
|
|
|
|
languages,
|
|
|
|
componentState,
|
|
|
|
birthDate];
|
|
|
|
dscr=[dscr stringByAppendingFormat:@" statistics=%@ formattedStatistics=%@ currentContext=%p permanentPageCache=%@",
|
|
|
|
statistics,
|
|
|
|
formattedStatistics,
|
|
|
|
(void*)currentContext,
|
|
|
|
permanentPageCache];
|
|
|
|
dscr=[dscr stringByAppendingFormat:@" permanentContextIDArray=%@ contextCounter=%d requestCounter=%d isAllowedToViewStatistics=%s",
|
|
|
|
permanentContextIDArray,
|
|
|
|
contextCounter,
|
|
|
|
requestCounter,
|
|
|
|
isAllowedToViewStatistics ? "YES" : "NO"];
|
|
|
|
|
|
|
|
dscr=[dscr stringByAppendingFormat:@" isTerminating=%s isDistributionEnabled=%s storesIDsInCookies=%s storesIDsInURLs=%s hasSessionLockedEditingContext=%s>",
|
|
|
|
isTerminating ? "YES" : "NO",
|
|
|
|
isDistributionEnabled ? "YES" : "NO",
|
|
|
|
storesIDsInCookies ? "YES" : "NO",
|
|
|
|
storesIDsInURLs ? "YES" : "NO",
|
|
|
|
hasSessionLockedEditingContext ? "YES" : "NO"];
|
|
|
|
*/
|
|
|
|
return dscr;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// sessionID
|
|
|
|
|
|
|
|
-(NSString*)sessionID
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _sessionID;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)domainForIDCookies
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
NSString* domain=nil;
|
|
|
|
GSWContext* context=nil;
|
|
|
|
GSWRequest* request=nil;
|
|
|
|
NSString* applicationName=nil;
|
|
|
|
NSString* adaptorPrefix=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
[[GSWApplication application]lock];
|
2002-07-27 23:48:47 +00:00
|
|
|
context=[self context];
|
|
|
|
request=[context request];
|
|
|
|
applicationName=[request applicationName];
|
|
|
|
NSDebugMLLog(@"sessions",@"applicationName=%@",applicationName);
|
|
|
|
adaptorPrefix=[request adaptorPrefix];
|
|
|
|
NSDebugMLLog(@"sessions",@"adaptorPrefix=%@",adaptorPrefix);
|
2000-01-22 12:49:49 +00:00
|
|
|
[[GSWApplication application]unlock];
|
2002-07-27 23:48:47 +00:00
|
|
|
domain=[NSString stringWithFormat:@"%@/%@.%@",
|
|
|
|
adaptorPrefix,
|
|
|
|
applicationName,
|
|
|
|
GSWApplicationSuffix[GSWebNamingConv]];
|
|
|
|
NSDebugMLLog(@"sessions",@"domain=%@",domain);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return domain;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)storesIDsInURLs
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
return _storesIDsInURLs;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setStoresIDsInURLs:(BOOL)flag
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
_storesIDsInURLs=flag;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSDate*)expirationDateForIDCookies
|
|
|
|
{
|
2001-10-28 10:29:17 +00:00
|
|
|
NSDate* expirationDateForIDCookies=nil;
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"timeOut=%f",(double)_timeOut);
|
|
|
|
expirationDateForIDCookies=[NSDate dateWithTimeIntervalSinceNow:_timeOut];
|
2001-10-28 10:29:17 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"expirationDateForIDCookies=%@ (HTML: %@)",
|
|
|
|
expirationDateForIDCookies,
|
|
|
|
[expirationDateForIDCookies htmlDescription]);
|
|
|
|
return expirationDateForIDCookies;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)storesIDsInCookies
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
return _storesIDsInCookies;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setStoresIDsInCookies:(BOOL)flag
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"newflag=%d",(int)flag);
|
|
|
|
_storesIDsInCookies=flag;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)isDistributionEnabled
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _isDistributionEnabled;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setDistributionEnabled:(BOOL)flag
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
_isDistributionEnabled=flag;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
@implementation GSWSession (GSWSessionA)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(id)_initWithSessionID:(NSString*)aSessionID
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWApplication* application=nil;
|
|
|
|
GSWStatisticsStore* statisticsStore=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-10-28 19:57:10 +00:00
|
|
|
statisticsStore=[GSWApp statisticsStore];
|
2002-07-27 23:48:47 +00:00
|
|
|
[statisticsStore _applicationCreatedSession:self];
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
ASSIGNCOPY(_sessionID,aSessionID);
|
|
|
|
NSDebugMLLog(@"sessions",@"sessionID=%u",aSessionID);
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"_sessionID=%u",_sessionID);
|
2002-07-27 23:48:47 +00:00
|
|
|
if (_sessionID)
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"sessions",@"sessionIDCount=%u",[_sessionID retainCount]);
|
|
|
|
};
|
|
|
|
application=[GSWApplication application];
|
2000-01-22 12:49:49 +00:00
|
|
|
//applic statisticsStore
|
|
|
|
//applic _activeSessionsCount
|
2002-07-27 23:48:47 +00:00
|
|
|
ASSIGN(_birthDate,[NSDate date]);
|
|
|
|
ASSIGN(_statistics,[NSMutableArray array]);
|
|
|
|
_storesIDsInURLs=YES;
|
|
|
|
[application _finishInitializingSession:self];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
@implementation GSWSession (GSWTermination)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// isTerminating
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)isTerminating
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _isTerminating;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// terminate
|
|
|
|
-(void)terminate
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
NSString* sessionID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
_isTerminating=YES;
|
|
|
|
sessionID=[self sessionID];
|
2001-10-25 Manuel Guesdon <mguesdon@orange-concept.com>
Applied patch from Turbocat (www.turbocat.de): GSWPatch_04-JUL_2001.diff
except GSWeb.framework/GSWInput.m/.h one (have to verify coherence of it)
* GSWAdaptors/common/GSWApp.c/.h: Added GSWAppInfo
* GSWAdaptors/common/GSWAppConnectNSSocket.c: Changes on includes
* GSWAdaptors/common/GSWLoadBalancing.h: Added parameter to GSWLoadBalancing_Find*
* GSWAdaptors/common/GSWLoadBalancing.c: added p_pURLComponents parameter,
o management of AppInfo
* GSWAdaptors/common/GSWAppRequest.c: managing refused connections
* GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd: misspelling correction
* GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html: Various Changes
* GSWExtensions.framework/GSWStatsPage.m: changes in login/password validation
o -awake added
* GSWeb.framework/GSWApplication.m/.h: Manage refusing new sessions
* GSWeb.framework/GSWBundle.m: debug traces commented
* GSWeb.framework/GSWComponent.m: implementation of ensureAwakeInContext:
* GSWeb.framework/GSWAssociation.m: special case for returned value of type GSMutableArray (Why ?)
* GSWeb.framework/GSWComponentRequestHandler.m: comments added
* GSWeb.framework/GSWDefaultAdaptorThread.m: added debug traces
* GSWeb.framework/GSWDirectActionRequestHandler.m: replaced GSWDirectAction by DirectAction
* GSWeb.framework/GSWDisplayGroup.m: initialize _baseIndex,
o correct misspelled names,
o added -description,
o use delegate in _changedInEditingContext:, _invalidatedAllObjectsInStore:,
o changes in -deleteObjectAtIndex:,
* GSWeb.framework/GSWFileUpload.m: different handling of _fileDatasCount,
handle bug in omniweb-browser
* GSWeb.framework/GSWHyperlink.m: added ensureAwakeInContext: call
* GSWeb.framework/GSWImageButton.m: added ensureAwakeInContext: call
* GSWeb.framework/GSWPopUpButton.m:
o use [response_ appendContentString:_noSelectionStringValue] instead of
[response_ appendContentHTMLString:_noSelectionStringValue]
o handle no displayString case
o use [response_ appendContentString:_displayStringValue] instead of
[response_ appendContentHTMLString:_displayStringValue]
* GSWeb.framework/GSWConfig.h: set GSWOPTVALUE_AutoOpenInBrowser to NO
* GSWeb.framework/GSWElementIDString.m: comment some debug traces
* GSWeb.framework/GSWHTMLStaticGroup.m/.h: added support of documentType
* GSWeb.framework/GSWHTMLURLValuedElement.m: addeded debug trace
* GSWeb.framework/GSWKeyValueAssociation.m: use NSStringFromClass([retValue class])
instead of [retValue class] for log
* GSWeb.framework/GSWRequest.m/.h: added -(NSDictionary*)headers;
o added test on _contentType in _contentType
o autorelease _dict in -uriElements
* GSWeb.framework/GSWResponse.m/.h: added -setHeaders: and -headers
o Added GSWResponse (GSWResponseRefused)
o return self in -generateResponse
* GSWeb.framework/GSWServerSessionStore.m/.h: added @interface GSWServerSessionStore (GSWServerSessionStoreInfo)
o added refusing session management
* GSWeb.framework/GSWSession.m:
o in -terminate forces to call removeSessionWithID in GSWServerSessionStore to dealloc it
* GSWeb.framework/GSWSessionTimeOutManager.m/.h: replace NSMutableOrderedArray* sessionOrderedTimeOuts;
by NSMutableArray* sessionOrderedTimeOuts;
o added traces
o added GSWSessionTimeOutManager (GSWSessionRefused)
* GSWeb.framework/GSWSubmitButton.m: raise exception if no element is returned
* GSWeb.framework/GSWTemplateParser.m: added doctype management
* GSWeb.framework/GSWUtils.h: added if defined for __NetBSD__
* GSWeb.framework/GSWWOCompatibility.m/.h: added WOGenericContainer, WOImageButton, WOHyperlink
* GSWeb.framework/attach.m: added if defined for __NetBSD__
* GSWeb.framework/stacktrace.m: added if defined for __NetBSD__
* GSWeb.framework/GSWTemplateParserXML.m: traces commented
o test XML node content before adding it
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m
o changes in -getIVarNamed: and in setIVarNamed:withValue: (use of sel+imp, tests on parameters)
* GSWAdaptors/common/GSWHTTPResponse.c: change in GSWHTTPResponse_GetResponse()
o debug traces removed
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@11251 72102866-910b-0410-8b05-ffd578937521
2001-10-26 08:50:52 +00:00
|
|
|
[self setTimeOut:(NSTimeInterval) 1]; // forces to call removeSessionWithID in GSWServerSessionStore to dealloc it
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:GSWNotification__SessionDidTimeOutNotification[GSWebNamingConv]
|
2002-07-27 23:48:47 +00:00
|
|
|
object:sessionID];
|
2001-10-28 10:29:17 +00:00
|
|
|
//TODO: VERIFY
|
|
|
|
[self setTimeOut:(NSTimeInterval) 1]; // forces to call removeSessionWithID in GSWServerSessionStore to dealloc it
|
2000-01-22 12:49:49 +00:00
|
|
|
//goto => GSWApp _sessionDidTimeOutNotification:
|
|
|
|
//call GSWApp _discountTerminatedSession
|
|
|
|
//call GSWApp statisticsStore
|
|
|
|
//call statstore _sessionTerminating:self
|
2002-10-28 19:57:10 +00:00
|
|
|
[[GSWApp statisticsStore] _sessionTerminating:self];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
// componentDefinition _notifyObserversForDyingComponent:Main component
|
|
|
|
//....
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// timeOut
|
|
|
|
|
|
|
|
-(NSTimeInterval)timeOut
|
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"timeOut=%ld",(long)_timeOut);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return _timeOut;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// setTimeOut:
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setTimeOut:(NSTimeInterval)timeOut
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"timeOut=%ld",(long)timeOut);
|
|
|
|
_timeOut=timeOut;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionDebugging)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)debugWithFormat:(NSString*)format,...
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionD)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)_debugWithString:(NSString*)string
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
@implementation GSWSession (GSWPageManagement)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)savePage:(GSWComponent*)page
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWContext* context=nil;
|
|
|
|
BOOL pageReplaced=NO;
|
|
|
|
BOOL pageChanged=NO;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSAssert(page,@"No Page");
|
|
|
|
context=[self context];
|
|
|
|
pageReplaced=[context _pageReplaced];
|
|
|
|
if (!pageReplaced)
|
|
|
|
[context _pageChanged];
|
|
|
|
[self _savePage:page
|
|
|
|
forChange:pageChanged || pageReplaced]; //??
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2002-07-27 23:48:47 +00:00
|
|
|
NSData* data=[NSArchiver archivedDataWithRootObject:page];
|
2000-01-22 12:49:49 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"savePage data=%@",data);
|
|
|
|
[pageCache setObject:data
|
2002-07-27 23:48:47 +00:00
|
|
|
forKey:[[self context] contextID]//TODO
|
2000-01-22 12:49:49 +00:00
|
|
|
withDuration:60*60];//TODO
|
|
|
|
*/
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(GSWComponent*)restorePageForContextID:(NSString*)aContextID
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWComponent* page=nil;
|
|
|
|
NSArray* contextArray=nil;
|
|
|
|
GSWTransactionRecord* transactionRecord=nil;
|
|
|
|
unsigned int stackIndex=0;
|
|
|
|
unsigned int contextArrayIndex=0;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2000-03-20 15:50:51 +00:00
|
|
|
GSWLogAssertGood(self);
|
2002-07-27 23:48:47 +00:00
|
|
|
NSAssert(aContextID,@"No contextID");
|
|
|
|
NSAssert([aContextID length]>0,@"contextID empty");
|
|
|
|
NSDebugMLLog(@"sessions",@"aContextID=%@",aContextID);
|
|
|
|
|
|
|
|
if ([_permanentPageCache objectForKey:aContextID])
|
|
|
|
{
|
|
|
|
page=[self _permanentPageWithContextID:aContextID];
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
transactionRecord=[_contextRecords objectForKey:aContextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord=%@",transactionRecord);
|
|
|
|
if (transactionRecord)
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord2=%@",transactionRecord);
|
|
|
|
page=[transactionRecord responsePage];
|
|
|
|
GSWLogAssertGood(page);
|
|
|
|
};
|
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord3=%@",transactionRecord);
|
|
|
|
NSDebugMLLog(@"sessions",@"page 1=%@",page);
|
|
|
|
contextArray=[self _contextArrayForContextID:aContextID
|
|
|
|
stackIndex:&stackIndex
|
|
|
|
contextArrayIndex:&contextArrayIndex];
|
|
|
|
NSDebugMLLog(@"sessions",@"page 2=%@",page);
|
|
|
|
if (contextArray)
|
|
|
|
{
|
|
|
|
if (stackIndex!=([_contextArrayStack count]-1))
|
|
|
|
{
|
|
|
|
[_contextArrayStack addObject:contextArray];
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_contextArrayStack objectAtIndex:stackIndex]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextArrayStack removeObjectAtIndex:stackIndex];
|
|
|
|
//TODO faire pareil avec _contextArray ?
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
NSAssert(self,@"self");
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"_currentContext=%@",_currentContext);
|
|
|
|
NSDebugMLLog(@"sessions",@"page 3=%@",page);
|
|
|
|
[page awakeInContext:_currentContext];
|
|
|
|
NSDebugMLLog(@"sessions",@"page 4=%@",page);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return page;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//NDFN
|
|
|
|
-(uint)permanentPageCacheSize
|
|
|
|
{
|
|
|
|
return [GSWApp permanentPageCacheSize];
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)savePageInPermanentCache:(GSWComponent*)page
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWContext* context=nil;
|
|
|
|
NSMutableDictionary* permanentPageCache=nil;
|
|
|
|
unsigned int permanentPageCacheSize=0;
|
|
|
|
NSString* contextID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
context=[self context];
|
|
|
|
permanentPageCache=[self _permanentPageCache];
|
|
|
|
permanentPageCacheSize=[self permanentPageCacheSize];
|
|
|
|
while([_permanentContextIDArray count]>0 && [_permanentContextIDArray count]>=permanentPageCacheSize)
|
|
|
|
{
|
|
|
|
id deletePage=nil;
|
|
|
|
NSString* deleteContextID=nil;
|
|
|
|
[GSWApplication statusLogWithFormat:@"Deleting permanent cached Page"];
|
|
|
|
deleteContextID=[_permanentContextIDArray objectAtIndex:0];
|
|
|
|
GSWLogAssertGood(deleteContextID);
|
|
|
|
[GSWApplication statusLogWithFormat:@"permanentContextIDArray=%@",
|
|
|
|
_permanentContextIDArray];
|
|
|
|
[GSWApplication statusLogWithFormat:@"contextID=%@",deleteContextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"deleteContextID=%@",deleteContextID);
|
|
|
|
NSDebugMLLog(@"sessions",@"[permanentContextIDArray objectAtIndex:0]=%@",
|
|
|
|
[_permanentContextIDArray objectAtIndex:0]);
|
|
|
|
NSDebugMLLog(@"sessions",@"[permanentContextIDArray objectAtIndex:0] retainCount=%d",
|
|
|
|
(int)[[_permanentContextIDArray objectAtIndex:0] retainCount]);
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_permanentContextIDArray objectAtIndex:0]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_permanentContextIDArray removeObjectAtIndex:0];
|
|
|
|
deletePage=[_contextRecords objectForKey:deleteContextID];
|
|
|
|
GSWLogAssertGood(deletePage);
|
|
|
|
[GSWApplication statusLogWithFormat:@"delete page of class=%@",
|
|
|
|
[deletePage class]];
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[permanentPageCache objectForKey:deleteContextID]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[permanentPageCache removeObjectForKey:deleteContextID];
|
2003-01-19 15:33:07 +00:00
|
|
|
};
|
2002-07-27 23:48:47 +00:00
|
|
|
contextID=[context contextID];
|
|
|
|
NSAssert(contextID,@"No contextID");
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
if ([_permanentContextIDArray containsObject:contextID])
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"page of class %@ contextID %@ already in permanent cache stack",
|
|
|
|
[page class],
|
|
|
|
contextID);
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",contextID);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_permanentContextIDArray removeObject:contextID];
|
|
|
|
if (![permanentPageCache objectForKey:contextID])
|
|
|
|
{
|
|
|
|
LOGSeriousError0(@"but not present in cache");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else if ([permanentPageCache objectForKey:contextID])
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"page of class %@ contextID %@ in permanent cache but not in stack",
|
|
|
|
[page class],
|
|
|
|
contextID);
|
|
|
|
};
|
|
|
|
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REPLACE: %p",[permanentPageCache objectForKey:contextID]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[permanentPageCache setObject:page
|
|
|
|
forKey:contextID];
|
|
|
|
[_permanentContextIDArray addObject:contextID];
|
2000-01-22 12:49:49 +00:00
|
|
|
//TODO
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
int i=0;
|
|
|
|
id anObject=nil;
|
|
|
|
id anotherContextID=nil;
|
|
|
|
for(i=0;i<[_permanentContextIDArray count];i++)
|
|
|
|
{
|
|
|
|
anotherContextID=[_permanentContextIDArray objectAtIndex:i];
|
|
|
|
anObject=[permanentPageCache objectForKey:anotherContextID];
|
|
|
|
[GSWApplication statusLogWithFormat:@"%d contextID=%@ page class=%@",i,anotherContextID,[anObject class]];
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2002-07-27 23:48:47 +00:00
|
|
|
if ([_permanentContextIDArray count]!=[permanentPageCache count])
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"[permanentContextIDArray count] %d != [permanentPageCache count] %d",
|
|
|
|
(int)[_permanentContextIDArray count],
|
|
|
|
(int)[permanentPageCache count]);
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionF)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)clearCookieFromResponse:(GSWResponse*)aResponse
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
NSString* domainForIDCookies=nil;
|
|
|
|
NSString* sessionID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
domainForIDCookies=[self domainForIDCookies];
|
|
|
|
sessionID=[self sessionID];
|
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_SessionID[GSWebNamingConv]
|
|
|
|
value:sessionID
|
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
|
|
|
expires:[self expirationDateForIDCookies]
|
|
|
|
isSecure:NO]];
|
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_InstanceID[GSWebNamingConv]
|
|
|
|
value:@"-1" //TODO
|
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
|
|
|
expires:[self expirationDateForIDCookies]
|
|
|
|
isSecure:NO]];
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)appendCookieToResponse:(GSWResponse*)aResponse
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
|
|
|
if ([self storesIDsInCookies])
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
//TODO VERIFY
|
|
|
|
NSString* domainForIDCookies=nil;
|
|
|
|
NSString* sessionID=nil;
|
|
|
|
domainForIDCookies=[self domainForIDCookies];
|
|
|
|
sessionID=[self sessionID];
|
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_SessionID[GSWebNamingConv]
|
|
|
|
value:sessionID
|
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
|
|
|
expires:[self expirationDateForIDCookies]
|
|
|
|
isSecure:NO]];
|
|
|
|
|
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_InstanceID[GSWebNamingConv]
|
|
|
|
value:@"1" //TODO
|
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
|
|
|
expires:[self expirationDateForIDCookies]
|
|
|
|
isSecure:NO]];
|
|
|
|
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionG)
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
extern id gcObjectsToBeVisited;
|
2000-01-22 12:49:49 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_releaseAutoreleasePool
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2002-05-14 11:28:50 +00:00
|
|
|
printf("session %p _releaseAutoreleasePool START\n",self);
|
|
|
|
fprintf(stderr,"session %p _releaseAutoreleasePool START\n",self);
|
2001-10-28 10:29:17 +00:00
|
|
|
//TODO-NOW remettre [GarbageCollector collectGarbages];
|
|
|
|
printf("session %p _releaseAutoreleasePool after garbage",self);
|
2002-05-14 11:28:50 +00:00
|
|
|
fprintf(stderr,"session %p _releaseAutoreleasePool after garbage\n",self);
|
2002-07-27 23:48:47 +00:00
|
|
|
DESTROY(_autoreleasePool);
|
2002-05-14 11:28:50 +00:00
|
|
|
printf("session %p _releaseAutoreleasePool STOP\n",self);
|
|
|
|
fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_createAutoreleasePool
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!_autoreleasePool)
|
2003-02-01 19:07:25 +00:00
|
|
|
{
|
|
|
|
_autoreleasePool=[NSAutoreleasePool new];
|
|
|
|
GSWLogMemCF("New NSAutoreleasePool: %p",_autoreleasePool);
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(GSWComponent*)_permanentPageWithContextID:(NSString*)aContextID
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWComponent* page=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
page=[_permanentPageCache objectForKey:aContextID];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return page;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSMutableDictionary*)_permanentPageCache
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!_permanentPageCache)
|
|
|
|
_permanentPageCache=[NSMutableDictionary new];
|
|
|
|
if (!_permanentContextIDArray)
|
|
|
|
_permanentContextIDArray=[NSMutableArray new];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return _permanentPageCache;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(GSWContext*)_contextIDMatchingContextID:(NSString*)aContextID
|
|
|
|
requestSenderID:(NSString*)aSenderID
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//avec (0) contextID=0 senderID=1.3 ==> return index=(0) stackIndex=0 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,1) contextID=1 senderID=3 ==> return index=(1) stackIndex=1 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,1,2) contextID=2 senderID=1.3 ==> return index=(2) stackIndex=2 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,2,3,1) contextID=1 senderID=3 ==> return index=(1) stackIndex=3 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,2,3,1,4) contextID=4 senderID=1.1 ==> return index=(4) stackIndex=4 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,2,3,1,4,5) contextID=5 senderID=3 ==> return index=(5) stackIndex=5 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,2,3,1,4,5,6) contextID=6 senderID=1.3 ==> return index=(6) stackIndex=6 contextArrayIndex=0 ==> return nil
|
|
|
|
//avec (0,2,3,1,5,6,7,4) contextID=4 senderID=1.1 ==> return index=(4) stackIndex=7 contextArrayIndex=0 ==> return ni
|
|
|
|
//avec (0,2,3,1,5,6,7,8,4) contextID=4 senderID=1.1 ==> return index=(4) stackIndex=8 contextArrayIndex=0 ==> return nil
|
|
|
|
|
|
|
|
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWContext* context=nil;
|
|
|
|
if (_contextArrayStack)
|
|
|
|
{
|
|
|
|
unsigned int stackIndex=0;
|
|
|
|
unsigned int contextArrayIndex=0;
|
|
|
|
NSArray* contextArray=[self _contextArrayForContextID:aContextID
|
|
|
|
stackIndex:&stackIndex
|
|
|
|
contextArrayIndex:&contextArrayIndex];
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
//TODO!!
|
2002-07-27 23:48:47 +00:00
|
|
|
return context;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_rearrangeContextArrayStack
|
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
|
|
|
//avec (0) contextID=1 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,1) contextID=2 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,1,2) contextID=3 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,2,3,1) contextID=4 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,2,3,1,4) contextID=5 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,2,3,1,4,5) contextID=6 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,2,3,1,4,5,6) contextID=7 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,2,3,1,5,6,7,4) contextID=8 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
//avec (0,2,3,1,5,6,7,8,4) contextID=9 ==> return index=nil stackIndex=0 contextArrayIndex=0 ==> nothing
|
|
|
|
|
|
|
|
/*
|
|
|
|
NSArray* _contextArray=[self _contextArrayForContextID:contextID
|
|
|
|
stackIndex:XX
|
|
|
|
contextArrayIndex:XX];
|
|
|
|
*/
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(NSArray*)_contextArrayForContextID:(NSString*)aContextID
|
|
|
|
stackIndex:(unsigned int*)pStackIndex
|
|
|
|
contextArrayIndex:(unsigned int*)pContextArrayIndex
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
NSArray* contextArray=nil;
|
|
|
|
unsigned int index=[_contextArrayStack indexOfObject:aContextID];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
if (index==NSNotFound)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
if (pStackIndex)
|
|
|
|
*pStackIndex=0;
|
|
|
|
if (pContextArrayIndex)
|
|
|
|
*pContextArrayIndex=0;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
if (pStackIndex)
|
|
|
|
*pStackIndex=index;
|
|
|
|
/* if (pContextArrayIndex)
|
|
|
|
*pContextArrayIndex=XX;*/
|
|
|
|
contextArray=[_contextArrayStack objectAtIndex:index];
|
|
|
|
};
|
|
|
|
return contextArray;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)_replacePage:(GSWComponent*)page
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//NDFN
|
|
|
|
-(uint)pageCacheSize
|
|
|
|
{
|
|
|
|
return [GSWApp pageCacheSize];
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)_savePage:(GSWComponent*)page
|
|
|
|
forChange:(BOOL)forChange
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWResponse* response=nil;
|
|
|
|
BOOL isClientCachingDisabled=NO;
|
|
|
|
GSWTransactionRecord* transactionRecord=nil;
|
|
|
|
unsigned int pageCacheSize=0;
|
|
|
|
NSString* contextID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSAssert(page,@"No Page");
|
|
|
|
if ([_contextArrayStack count]>0) // && _forChange!=NO ??
|
|
|
|
[self _rearrangeContextArrayStack];
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Get the response
|
2002-07-27 23:48:47 +00:00
|
|
|
response=[_currentContext response];//currentContext??
|
|
|
|
NSDebugMLLog(@"sessions",@"response=%@",response);
|
|
|
|
isClientCachingDisabled=[response _isClientCachingDisabled]; //So what
|
|
|
|
NSDebugMLLog(@"sessions",@"currentContext=%@",_currentContext);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Create a new transaction record
|
2002-07-27 23:48:47 +00:00
|
|
|
transactionRecord=[[[GSWTransactionRecord alloc]
|
|
|
|
initWithResponsePage:page
|
|
|
|
context:_currentContext]//currentContext??
|
|
|
|
autorelease];
|
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord=%@",transactionRecord);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Retrieve the pageCacheSize
|
2002-07-27 23:48:47 +00:00
|
|
|
pageCacheSize=[self pageCacheSize];
|
|
|
|
NSDebugMLLog(@"sessions",@"pageCacheSize=%d",pageCacheSize);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Create contextArrayStack and contextRecords if not already created
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!_contextArrayStack)
|
|
|
|
_contextArrayStack=[NSMutableArray new];
|
|
|
|
if (!_contextRecords)
|
|
|
|
_contextRecords=[NSMutableDictionary new];
|
|
|
|
NSDebugMLLog(@"sessions",@"contextArrayStack=%@",_contextArrayStack);
|
|
|
|
NSDebugMLLog(@"sessions",@"contextRecords=%@",_contextRecords);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Remove some pages if page number greater than page cache size
|
2002-07-27 23:48:47 +00:00
|
|
|
while([_contextArrayStack count]>0 && [_contextArrayStack count]>=pageCacheSize)
|
|
|
|
{
|
|
|
|
id deleteRecord=nil;
|
|
|
|
NSString* deleteContextID=nil;
|
|
|
|
[GSWApplication statusLogWithFormat:@"Deleting cached Page"];
|
|
|
|
deleteContextID=[_contextArrayStack objectAtIndex:0];
|
|
|
|
GSWLogAssertGood(deleteContextID);
|
|
|
|
[GSWApplication statusLogWithFormat:@"contextArrayStack=%@",_contextArrayStack];
|
|
|
|
[GSWApplication statusLogWithFormat:@"contextID=%@",deleteContextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"_deleteContextID=%@",deleteContextID);
|
|
|
|
NSDebugMLLog(@"sessions",@"[contextArrayStack objectAtIndex:0]=%@",
|
|
|
|
[_contextArrayStack objectAtIndex:0]);
|
|
|
|
NSDebugMLLog(@"sessions",@"[contextArrayStack objectAtIndex:0] retainCount=%d",
|
|
|
|
(int)[[_contextArrayStack objectAtIndex:0] retainCount]);
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_contextArrayStack objectAtIndex:0]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextArrayStack removeObjectAtIndex:0];
|
|
|
|
deleteRecord=[_contextRecords objectForKey:deleteContextID];
|
|
|
|
GSWLogAssertGood(deleteRecord);
|
|
|
|
GSWLogAssertGood([deleteRecord responsePage]);
|
|
|
|
[GSWApplication statusLogWithFormat:@"delete page of class=%@",
|
|
|
|
[[deleteRecord responsePage] class]];
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",[_contextRecords objectForKey:deleteContextID]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextRecords removeObjectForKey:deleteContextID];
|
|
|
|
};
|
|
|
|
|
|
|
|
GSWLogC("display page");
|
|
|
|
NSDebugMLLog(@"sessions",@"page=%@",page);
|
|
|
|
NSDebugMLLog(@"sessions",@"page context=%@",[page context]);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Retrieve Page contextID
|
2002-07-27 23:48:47 +00:00
|
|
|
contextID=[[page context]contextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"_contextID=%@",contextID);
|
|
|
|
NSAssert(contextID,@"No contextID");
|
|
|
|
|
|
|
|
if ([_contextArrayStack containsObject:contextID])
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"page of class %@ contextID %@ already in cache stack",
|
|
|
|
[page class],
|
|
|
|
contextID);
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REMOVE: %p",contextID);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextArrayStack removeObject:contextID];
|
|
|
|
if (![_contextRecords objectForKey:contextID])
|
|
|
|
{
|
|
|
|
LOGSeriousError0(@"but not present in cache");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else if ([_contextRecords objectForKey:contextID])
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"page of class %@ contextID %@ in cache but not in stack",
|
|
|
|
[page class],
|
|
|
|
contextID);
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
// Add the page contextID in contextArrayStack
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextArrayStack addObject:contextID];
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// Add the record for this contextID in contextRecords
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"SESSION REPLACE: %p",[_contextRecords objectForKey:contextID]);
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextRecords setObject:transactionRecord
|
|
|
|
forKey:contextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"contextArrayStack=%@",_contextArrayStack);
|
2000-01-22 12:49:49 +00:00
|
|
|
//TODO
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
int i=0;
|
|
|
|
GSWTransactionRecord* aTransRecord=nil;
|
|
|
|
id anotherContextID=nil;
|
|
|
|
for(i=0;i<[_contextArrayStack count];i++)
|
|
|
|
{
|
|
|
|
anotherContextID=[_contextArrayStack objectAtIndex:i];
|
|
|
|
aTransRecord=[_contextRecords objectForKey:anotherContextID];
|
|
|
|
[GSWApplication statusLogWithFormat:@"%d contextID=%@ page class=%@",
|
|
|
|
i,anotherContextID,[[aTransRecord responsePage] class]];
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
2002-07-27 23:48:47 +00:00
|
|
|
if ([_contextArrayStack count]!=[_contextRecords count])
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"[contextArrayStack count] %d != [contextRecords count] %d",
|
|
|
|
(int)[_contextArrayStack count],
|
|
|
|
(int)[_contextRecords count]);
|
|
|
|
};
|
|
|
|
NSDebugMLLog(@"sessions",@"contextRecords=%@",_contextRecords);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_saveCurrentPage
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2003-01-19 15:33:07 +00:00
|
|
|
if (_currentContext)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-01-19 15:33:07 +00:00
|
|
|
GSWComponent* component=[_currentContext _pageComponent];
|
2002-07-27 23:48:47 +00:00
|
|
|
if ([component _isPage])
|
|
|
|
{
|
2003-01-19 15:33:07 +00:00
|
|
|
GSWComponent* testComponent=[self _permanentPageWithContextID:[_currentContext contextID]];
|
|
|
|
if (testComponent!=component)
|
|
|
|
{
|
|
|
|
testComponent=[self _permanentPageWithContextID:[_currentContext _requestContextID]];
|
|
|
|
if (testComponent && [self permanentPageCacheSize]>0)
|
|
|
|
{
|
|
|
|
[self savePageInPermanentCache:component];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([self pageCacheSize]>0)
|
|
|
|
[self savePage:component];
|
|
|
|
};
|
|
|
|
};
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(int)_requestCounter
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
return _requestCounter;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_contextDidIncrementContextID
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
_contextCounter++;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(int)_contextCounter
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
return _contextCounter;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)_setContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"aContext=%p",(void*)aContext);
|
|
|
|
_currentContext=aContext;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)sleepInContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
|
|
|
[self sleep];
|
|
|
|
[self _setContext:nil];
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)awakeInContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
[self _setContext:aContext];
|
|
|
|
NSDebugMLLog(@"sessions",@"contextCounter=%i",_contextCounter);
|
|
|
|
if (aContext)
|
|
|
|
{
|
|
|
|
if ([[self class] __counterIncrementingEnabledFlag]) //??
|
|
|
|
{
|
|
|
|
_contextCounter++;
|
|
|
|
_requestCounter++;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
NSDebugMLLog(@"sessions",@"contextCounter=%i",_contextCounter);
|
2000-01-22 12:49:49 +00:00
|
|
|
[self awake];
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWLocalization)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)setLanguages:(NSArray*)someLanguages
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
if (!someLanguages)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
LOGError0(@"No languages");
|
|
|
|
};
|
|
|
|
ASSIGN(_languages,someLanguages);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSArray*)languages
|
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!_languages)
|
|
|
|
{
|
|
|
|
GSWContext* aContext=[self context];
|
|
|
|
GSWRequest* request=[aContext request];
|
|
|
|
NSArray* languages=[request browserLanguages];
|
|
|
|
[self setLanguages:languages];
|
|
|
|
};
|
|
|
|
return _languages;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWComponentStateManagement)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// objectForKey:
|
2002-07-27 23:48:47 +00:00
|
|
|
-(id)objectForKey:(NSString*)key
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
id object=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
object=[_componentState objectForKey:key];
|
|
|
|
NSDebugMLLog(@"sessions",@"key=%@ object=%@",key,object);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return object;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// setObject:forKey:
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setObject:(id)object
|
|
|
|
forKey:(NSString*)key
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!_componentState)
|
|
|
|
_componentState=[NSMutableDictionary new];
|
|
|
|
NSDebugMLLog(@"sessions",@"key=%@ object=%@",key,object);
|
|
|
|
[_componentState setObject:object
|
|
|
|
forKey:key];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)removeObjectForKey:(NSString*)key
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"key=%@",key);
|
|
|
|
[_componentState removeObjectForKey:key];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//NDFN
|
|
|
|
-(NSMutableDictionary*)componentState
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _componentState;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWEnterpriseObjects)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(EOEditingContext*)defaultEditingContext
|
|
|
|
{
|
2000-07-27 21:53:39 +00:00
|
|
|
#if GDL2
|
2002-07-27 23:48:47 +00:00
|
|
|
if(!_editingContext)
|
2000-07-27 21:53:39 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
ASSIGN(_editingContext,[[[EOEditingContext alloc] init] autorelease]);
|
2000-07-27 21:53:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
return _editingContext;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setDefaultEditingContext:(EOEditingContext*)editingContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
ASSIGN(_editingContext,editingContext);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWRequestHandling)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(GSWContext*)context
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _currentContext;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// awake
|
|
|
|
-(void)awake
|
|
|
|
{
|
|
|
|
//ok
|
|
|
|
//Does Nothing
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// sleep
|
|
|
|
|
|
|
|
-(void)sleep
|
|
|
|
{
|
|
|
|
//Does Nothing
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// takeValuesFromRequest:inContext:
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
|
|
|
inContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWElement* pageElement=nil;
|
|
|
|
GSWComponent* pageComponent=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
pageElement=[aContext _pageElement];
|
|
|
|
pageComponent=[aContext _pageComponent];
|
2002-05-16 18:01:40 +00:00
|
|
|
#ifndef NDEBUG
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext addDocStructureStep:@"Take Values From Request"];
|
2002-05-16 18:01:40 +00:00
|
|
|
#endif
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext _setCurrentComponent:pageComponent]; //_pageElement ??
|
|
|
|
[pageComponent takeValuesFromRequest:aRequest
|
|
|
|
inContext:aContext]; //_pageComponent ??
|
|
|
|
[aContext _setCurrentComponent:nil];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// invokeActionForRequest:inContext:
|
2002-07-27 23:48:47 +00:00
|
|
|
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
|
|
|
|
inContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWElement* element=nil;
|
|
|
|
GSWElement* pageElement=nil;
|
|
|
|
GSWComponent* pageComponent=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2000-02-12 13:08:41 +00:00
|
|
|
NS_DURING
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
pageElement=[aContext _pageElement];
|
|
|
|
pageComponent=[aContext _pageComponent];
|
2002-05-16 18:01:40 +00:00
|
|
|
#ifndef NDEBUG
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext addDocStructureStep:@"Invoke Action For Request"];
|
2002-05-16 18:01:40 +00:00
|
|
|
#endif
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext _setCurrentComponent:pageComponent]; //_pageElement ??
|
|
|
|
element=[pageComponent invokeActionForRequest:aRequest
|
|
|
|
inContext:aContext]; //_pageComponent
|
|
|
|
[aContext _setCurrentComponent:nil];
|
|
|
|
if (!element)
|
|
|
|
element=[aContext page]; //??
|
|
|
|
}
|
2000-02-12 13:08:41 +00:00
|
|
|
NS_HANDLER
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
LOGException0(@"exception in GSWSession invokeActionForRequest:inContext");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
|
|
|
@"In GSWSession invokeActionForRequest:inContext");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
[localException raise];
|
|
|
|
}
|
2000-02-12 13:08:41 +00:00
|
|
|
NS_ENDHANDLER;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-07-27 23:48:47 +00:00
|
|
|
return element;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// appendToResponse:inContext:
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)appendToResponse:(GSWResponse*)aResponse
|
|
|
|
inContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWStatisticsStore* statisticsStore=nil;
|
|
|
|
NSString* logFile=nil;
|
|
|
|
GSWSession* session=nil;
|
|
|
|
GSWElement* pageElement=nil;
|
|
|
|
GSWComponent* pageComponent=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
statisticsStore=[[GSWApplication application] statisticsStore];
|
|
|
|
pageElement=[aContext _pageElement];
|
|
|
|
pageComponent=[aContext _pageComponent];
|
2002-05-16 18:01:40 +00:00
|
|
|
#ifndef NDEBUG
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext addDocStructureStep:@"Append To Response"];
|
2002-05-16 18:01:40 +00:00
|
|
|
#endif
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext _setCurrentComponent:pageComponent]; //_pageElement ??
|
2003-01-19 15:33:07 +00:00
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[pageComponent appendToResponse:aResponse
|
|
|
|
inContext:aContext]; //_pageComponent??
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"exception in %@ appendToResponse:inContext",
|
|
|
|
[self class]);
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
|
|
|
@"In %@ appendToResponse:inContext",
|
|
|
|
[self class]);
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext _setCurrentComponent:nil];
|
|
|
|
session=[aContext existingSession];
|
|
|
|
[session appendCookieToResponse:aResponse];
|
|
|
|
[statisticsStore recordStatisticsForResponse:aResponse
|
|
|
|
inContext:aContext];
|
|
|
|
[statisticsStore descriptionForResponse:aResponse
|
|
|
|
inContext:aContext];
|
|
|
|
logFile=[statisticsStore logFile];
|
|
|
|
if (logFile)
|
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWStatistics)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSArray*)statistics
|
|
|
|
{
|
|
|
|
//return (Main, DisksList, DisksList, DisksList) (page dans l'ordre des context)
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
return nil;
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionM)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)_allowedToViewStatistics
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _isAllowedToViewStatistics;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_allowToViewStatistics
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
_isAllowedToViewStatistics=YES;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(id)_formattedStatistics
|
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
return nil;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSDate*)_birthDate
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _birthDate;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionN)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(GSWApplication*)application
|
|
|
|
{
|
|
|
|
return [GSWApplication application];
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionO)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_validateAPI
|
|
|
|
{
|
|
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionClassA)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
+(void)__setContextCounterIncrementingEnabled:(BOOL)flag
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGClassFnNotImplemented(); //TODOFN
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
+(int)__counterIncrementingEnabledFlag
|
|
|
|
{
|
|
|
|
LOGClassFnNotImplemented(); //TODOFN
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|