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-08-25 20:15:32 +00:00
|
|
|
#include <GNUstepBase/GSCategories.h>
|
2003-02-01 19:07:25 +00:00
|
|
|
|
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
|
|
|
//====================================================================
|
2004-03-26 10:27:20 +00:00
|
|
|
@interface GSWSession (Private)
|
|
|
|
-(void)_setContextArrayStack:(NSArray*)contextArrayStack;
|
|
|
|
-(void)_setContextRecords:(NSDictionary*)contextRecords;
|
|
|
|
-(void)_setComponentState:(NSDictionary*)componentState;
|
|
|
|
-(void)_setStatistics:(NSArray*)statistics;
|
|
|
|
-(void)_setFormattedStatistics:(NSString*)formattedStatistics;
|
|
|
|
-(void)_setContextCounter:(int)contextCounter;
|
|
|
|
-(void)_setRequestCounter:(int)requestCounter;
|
|
|
|
@end
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2004-03-26 10:27:20 +00:00
|
|
|
//====================================================================
|
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];
|
2004-03-26 10:27:20 +00:00
|
|
|
[clone setSessionID:_sessionID];
|
|
|
|
[clone setTimeOut:_timeOut];
|
|
|
|
[clone _setContextArrayStack:_contextArrayStack];
|
|
|
|
[clone _setContextRecords:_contextRecords];
|
|
|
|
//_editingContext: no
|
|
|
|
[clone setLanguages:_languages];
|
|
|
|
[clone _setComponentState:_componentState];
|
|
|
|
[clone _setBirthDate:_birthDate];
|
|
|
|
//_wasTimedOut: no
|
|
|
|
[clone _setStatistics:_statistics];
|
|
|
|
[clone _setFormattedStatistics:_formattedStatistics];
|
|
|
|
[clone _setContext:_currentContext];
|
|
|
|
//_permanentPageCache:
|
|
|
|
//_permanentContextIDArray: no
|
|
|
|
[clone _setContextCounter:_contextCounter];
|
|
|
|
[clone _setRequestCounter:_requestCounter];
|
|
|
|
[clone _setAllowedToViewStatistics:_isAllowedToViewStatistics];
|
|
|
|
[clone _setAllowedToViewEvents:_isAllowedToViewEvents];
|
|
|
|
//_isTerminating: no
|
|
|
|
[clone setDistributionEnabled:_isDistributionEnabled];
|
|
|
|
[clone setStoresIDsInURLs:_storesIDsInURLs];
|
|
|
|
[clone setStoresIDsInCookies:_storesIDsInCookies];
|
|
|
|
//_hasSessionLockedEditingContext: no
|
2000-01-22 12:49:49 +00:00
|
|
|
return clone;
|
|
|
|
};
|
|
|
|
|
2004-03-26 10:27:20 +00:00
|
|
|
//--------------------------------------------------------------------
|
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
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
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);
|
* GSWeb.framework/GSWApplication.m
(GSWApplicationMainReal): Reformat. Use GSCurrentThread
instead of objc_thread_id. Remove \n in NSLog type logs.
(GSWApplicationMain): Ditto.
([GSWApplication init], [GSWApplication lockRequestHandling],
[GSWApplication unlockRequestHandling], [GSWApplication lock],
[GSWApplication unlock], [GSWApplication _sessionClass],
[GSWApplication run],
[GSWApplication addDynCreateClassName:superClassName:],
[GSWApplication pageWithName:],
[GSWApplication dynamicElementWithName:associations:template:]):
Ditto.
* GSWeb.framework/GSWComponent.m
([GSWComponent appendToResponse:inContext:], [GSWComponent
templateWithHTMLString:declarationString:languages:]): Ditto.
* GSWeb.framework/GSWContext.m
([GSWContext dealloc], [GSWContext setValidate:]): Ditto.
* GSWeb.framework/GSWDebug.m
(GSWLogC_, GSWLogDumpObjectFn): Ditto.
* GSWeb.framework/GSWDefaultAdaptor.m
([GSWDefaultAdaptor registerForEvents],
[GSWDefaultAdaptor announceNewConnection:],
[GSWDefaultAdaptor adaptorThreadExited:],
[GSWDefaultAdaptor tryLock]): Ditto.
* GSWeb.framework/GSWDefaultAdaptorThread.m
([GSWDefaultAdaptorThread setPool:destroyLast:],
[GSWDefaultAdaptorThread run:],
[GSWDefaultAdaptorThread threadExited],
[GSWDefaultAdaptorThread isExpired],
[GSWDefaultAdaptorThread sendRetryLasterResponseToStream:],
[GSWDefaultAdaptorThread
sendConnectionRefusedResponseToStream:withMessage:]): Ditto.
* GSWeb.framework/GSWDeployedBundle.m
([GSWDeployedBundle initWithPath:], [GSWDeployedBundle dealloc],
[GSWDeployedBundle lock], [GSWDeployedBundle unlock]): Ditto.
* GSWeb.framework/GSWLifebeatThread.m
([GSWLifebeatThread setPool:destroyLast:],
[GSWLifebeatThread threadExited]): Ditto.
* GSWeb.framework/GSWSession.m
([GSWSession initWithCoder:],
[GSWSession _releaseAutoreleasePool]): Ditto.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18611 72102866-910b-0410-8b05-ffd578937521
2004-02-17 16:53:36 +00:00
|
|
|
NSDebugFLog(@"Dealloc GSWSession %p. %@",
|
|
|
|
(void*)self, GSCurrentThread());
|
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 ");
|
* GSWeb.framework/GSWApplication.m
(GSWApplicationMainReal): Reformat. Use GSCurrentThread
instead of objc_thread_id. Remove \n in NSLog type logs.
(GSWApplicationMain): Ditto.
([GSWApplication init], [GSWApplication lockRequestHandling],
[GSWApplication unlockRequestHandling], [GSWApplication lock],
[GSWApplication unlock], [GSWApplication _sessionClass],
[GSWApplication run],
[GSWApplication addDynCreateClassName:superClassName:],
[GSWApplication pageWithName:],
[GSWApplication dynamicElementWithName:associations:template:]):
Ditto.
* GSWeb.framework/GSWComponent.m
([GSWComponent appendToResponse:inContext:], [GSWComponent
templateWithHTMLString:declarationString:languages:]): Ditto.
* GSWeb.framework/GSWContext.m
([GSWContext dealloc], [GSWContext setValidate:]): Ditto.
* GSWeb.framework/GSWDebug.m
(GSWLogC_, GSWLogDumpObjectFn): Ditto.
* GSWeb.framework/GSWDefaultAdaptor.m
([GSWDefaultAdaptor registerForEvents],
[GSWDefaultAdaptor announceNewConnection:],
[GSWDefaultAdaptor adaptorThreadExited:],
[GSWDefaultAdaptor tryLock]): Ditto.
* GSWeb.framework/GSWDefaultAdaptorThread.m
([GSWDefaultAdaptorThread setPool:destroyLast:],
[GSWDefaultAdaptorThread run:],
[GSWDefaultAdaptorThread threadExited],
[GSWDefaultAdaptorThread isExpired],
[GSWDefaultAdaptorThread sendRetryLasterResponseToStream:],
[GSWDefaultAdaptorThread
sendConnectionRefusedResponseToStream:withMessage:]): Ditto.
* GSWeb.framework/GSWDeployedBundle.m
([GSWDeployedBundle initWithPath:], [GSWDeployedBundle dealloc],
[GSWDeployedBundle lock], [GSWDeployedBundle unlock]): Ditto.
* GSWeb.framework/GSWLifebeatThread.m
([GSWLifebeatThread setPool:destroyLast:],
[GSWLifebeatThread threadExited]): Ditto.
* GSWeb.framework/GSWSession.m
([GSWSession initWithCoder:],
[GSWSession _releaseAutoreleasePool]): Ditto.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18611 72102866-910b-0410-8b05-ffd578937521
2004-02-17 16:53:36 +00:00
|
|
|
GSWLogMemCF("Destroy NSAutoreleasePool: %p. %@",
|
|
|
|
_autoreleasePool, GSCurrentThread());
|
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
|
|
|
};
|
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// sessionID
|
|
|
|
|
|
|
|
-(void)setSessionID:(NSString*)sessionID
|
|
|
|
{
|
|
|
|
ASSIGN(_sessionID,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
|
|
|
|
{
|
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
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
if (flag!=_storesIDsInURLs)
|
|
|
|
_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
|
|
|
|
{
|
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
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"newflag=%d",(int)flag);
|
2003-11-24 09:43:11 +00:00
|
|
|
if (flag!=_storesIDsInCookies)
|
|
|
|
{
|
|
|
|
_storesIDsInCookies=flag;
|
|
|
|
[_currentContext _synchronizeForDistribution];
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-11-24 09:43:11 +00:00
|
|
|
/** Returns NO if URLs contains application number so requests are
|
|
|
|
directed to the specific application instance.
|
|
|
|
Resturns YES if URLs doesn't contain application number so requests
|
|
|
|
can be directed to any instance (load balancing)
|
|
|
|
Default value is NO
|
|
|
|
**/
|
2000-01-22 12:49:49 +00:00
|
|
|
-(BOOL)isDistributionEnabled
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _isDistributionEnabled;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-11-24 09:43:11 +00:00
|
|
|
/** Enables or disables application instance number in URLs.
|
|
|
|
If flag is NO, URLs contains application number so requests are directed
|
|
|
|
to the specific application instance.
|
|
|
|
If flag is YES, URLs doesn't contain application number so requests can
|
|
|
|
be directed to any instance (load balancing)
|
|
|
|
**/
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)setDistributionEnabled:(BOOL)flag
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2003-11-24 09:43:11 +00:00
|
|
|
if (flag!=_isDistributionEnabled)
|
|
|
|
{
|
|
|
|
_isDistributionEnabled=flag;
|
|
|
|
[_currentContext _synchronizeForDistribution];
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
2004-03-26 10:27:20 +00:00
|
|
|
@implementation GSWSession (Private)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setContextArrayStack:(NSArray*)contextArrayStack
|
|
|
|
{
|
|
|
|
DESTROY(_contextArrayStack);
|
|
|
|
_contextArrayStack=[contextArrayStack mutableCopy];
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2004-03-26 10:27:20 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setContextRecords:(NSDictionary*)contextRecords
|
|
|
|
{
|
|
|
|
DESTROY(_contextRecords);
|
|
|
|
_contextRecords=[contextRecords mutableCopy];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setComponentState:(NSDictionary*)componentState
|
|
|
|
{
|
|
|
|
DESTROY(_componentState);
|
|
|
|
_componentState=[componentState mutableCopy];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setStatistics:(NSArray*)statistics
|
|
|
|
{
|
|
|
|
DESTROY(_statistics);
|
|
|
|
_statistics=[statistics mutableCopy];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setFormattedStatistics:(NSString*)formattedStatistics
|
|
|
|
{
|
|
|
|
DESTROY(_formattedStatistics);
|
|
|
|
_formattedStatistics=[formattedStatistics mutableCopy];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setContextCounter:(int)contextCounter
|
|
|
|
{
|
|
|
|
_contextCounter = contextCounter;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setRequestCounter:(int)requestCounter
|
|
|
|
{
|
|
|
|
_requestCounter = requestCounter;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
2000-01-22 12:49:49 +00:00
|
|
|
@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
|
2003-11-24 09:43:11 +00:00
|
|
|
[self _setBirthDate:[NSDate date]];
|
2002-07-27 23:48:47 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
|
|
|
|
2003-11-24 09:43:11 +00:00
|
|
|
if (!_isTerminating) // don't do it multiple times !
|
|
|
|
{
|
|
|
|
GSWApplication* application=[GSWApplication application];
|
|
|
|
NSString* sessionID=[self sessionID];
|
|
|
|
|
|
|
|
_isTerminating=YES;
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:GSWNotification__SessionDidTimeOutNotification[GSWebNamingConv]
|
|
|
|
object:sessionID];
|
|
|
|
|
|
|
|
[application _discountTerminatedSession];
|
|
|
|
[[application statisticsStore] _sessionTerminating:self];
|
|
|
|
|
|
|
|
if (_editingContext)
|
|
|
|
{
|
|
|
|
if (_hasSessionLockedEditingContext)
|
|
|
|
{
|
|
|
|
[_editingContext unlock];
|
|
|
|
_hasSessionLockedEditingContext = NO;
|
|
|
|
};
|
|
|
|
DESTROY(_editingContext);
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
[self setTimeOut:(NSTimeInterval) 1]; // forces to call removeSessionWithID in GSWServerSessionStore to dealloc it
|
|
|
|
//TODO: VERIFY
|
|
|
|
[self setTimeOut:(NSTimeInterval) 1]; // forces to call removeSessionWithID in GSWServerSessionStore to dealloc it
|
|
|
|
*/
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
2003-06-25 15:36:28 +00:00
|
|
|
|
2004-04-06 11:10:11 +00:00
|
|
|
//--------------------------------------------------------------------
|
2003-06-25 15:36:28 +00:00
|
|
|
-(void)_terminateByTimeout
|
|
|
|
{
|
|
|
|
_wasTimedOut = YES;
|
|
|
|
[self terminate];
|
|
|
|
}
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
// 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);
|
2003-11-24 09:43:11 +00:00
|
|
|
if (timeOut==0)
|
|
|
|
_timeOut=[[NSDate distantFuture]timeIntervalSinceDate:_birthDate];
|
|
|
|
else
|
|
|
|
_timeOut=timeOut;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionDebugging)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2004-04-06 11:10:11 +00:00
|
|
|
-(void)debugWithFormat:(NSString*)aFormat,...
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2004-04-06 11:10:11 +00:00
|
|
|
va_list ap=NULL;
|
|
|
|
va_start(ap,aFormat);
|
|
|
|
[GSWApp debugWithFormat:aFormat
|
|
|
|
arguments:ap];
|
|
|
|
va_end(ap);
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWSessionD)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)_debugWithString:(NSString*)string
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2004-04-06 11:10:11 +00:00
|
|
|
[GSWApp debugWithString:string];
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@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();
|
2003-06-25 15:36:28 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
NSAssert(page,@"No Page");
|
2003-06-25 15:36:28 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
context=[self context];
|
|
|
|
pageReplaced=[context _pageReplaced];
|
2003-06-25 15:36:28 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!pageReplaced)
|
2003-06-25 15:36:28 +00:00
|
|
|
pageChanged=[context _pageChanged];
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
[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;
|
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);
|
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
transactionRecord=[_contextRecords objectForKey:aContextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord=%@",transactionRecord);
|
|
|
|
|
|
|
|
if (transactionRecord)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord2=%@",transactionRecord);
|
|
|
|
page=[transactionRecord responsePage];
|
|
|
|
GSWLogAssertGood(page);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (page) // will put it at the end of the stack
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
unsigned int stackIndex=0;
|
|
|
|
unsigned int contextArrayIndex=0;
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord3=%@",transactionRecord);
|
|
|
|
NSDebugMLLog(@"sessions",@"page 1=%@",page);
|
2003-06-25 15:36:28 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
contextArray=[self _contextArrayForContextID:aContextID
|
|
|
|
stackIndex:&stackIndex
|
|
|
|
contextArrayIndex:&contextArrayIndex];
|
2003-06-25 15:36:28 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"page 2=%@",page);
|
|
|
|
if (contextArray)
|
|
|
|
{
|
|
|
|
if (stackIndex!=([_contextArrayStack count]-1))
|
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
//NSLog(@"AA stackIndex=%d",stackIndex);
|
|
|
|
//NSLog(@"AA _contextArrayStack class=%@",[_contextArrayStack class]);
|
|
|
|
//NSLog(@"AA [_contextArrayStack count]=%d",[_contextArrayStack count]);
|
|
|
|
[_contextArrayStack addObject:contextArray]; //add before removing to avoid release
|
2002-07-27 23:48:47 +00:00
|
|
|
[_contextArrayStack removeObjectAtIndex:stackIndex];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2003-06-25 15:36:28 +00:00
|
|
|
|
|
|
|
if ([_permanentPageCache objectForKey:aContextID])
|
|
|
|
page=[self _permanentPageWithContextID:aContextID];
|
|
|
|
|
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
|
2004-05-06 13:55:49 +00:00
|
|
|
-(unsigned int)permanentPageCacheSize
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
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];
|
2003-11-24 09:43:11 +00:00
|
|
|
|
|
|
|
// first we'll remove excessive cached pages.
|
2002-07-27 23:48:47 +00:00
|
|
|
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);
|
2003-03-24 07:45:52 +00:00
|
|
|
RETAIN(deleteContextID); // We'll remove it from array
|
2002-07-27 23:48:47 +00:00
|
|
|
[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-03-24 07:45:52 +00:00
|
|
|
RELEASE(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];
|
2003-11-24 09:43:11 +00:00
|
|
|
/*
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
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
|
|
|
};
|
2003-11-24 09:43:11 +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;
|
2003-04-09 12:03:17 +00:00
|
|
|
NSDate* anExpireDate=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-07-27 23:48:47 +00:00
|
|
|
domainForIDCookies=[self domainForIDCookies];
|
|
|
|
sessionID=[self sessionID];
|
2003-04-09 12:03:17 +00:00
|
|
|
anExpireDate=[NSDate date]; // Expire now
|
2002-07-27 23:48:47 +00:00
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_SessionID[GSWebNamingConv]
|
|
|
|
value:sessionID
|
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
2003-04-09 12:03:17 +00:00
|
|
|
expires:anExpireDate
|
2002-07-27 23:48:47 +00:00
|
|
|
isSecure:NO]];
|
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_InstanceID[GSWebNamingConv]
|
2003-04-09 12:03:17 +00:00
|
|
|
value:@"-1"
|
2002-07-27 23:48:47 +00:00
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
2003-04-09 12:03:17 +00:00
|
|
|
expires:anExpireDate
|
2002-07-27 23:48:47 +00:00
|
|
|
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
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
|
|
|
if ([self storesIDsInCookies])
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-04-09 12:03:17 +00:00
|
|
|
NSString* domainForIDCookies=[self domainForIDCookies];
|
2004-04-06 11:10:11 +00:00
|
|
|
NSString* sessionID=nil;
|
2003-04-09 12:03:17 +00:00
|
|
|
int instance=-1;
|
2004-04-06 11:10:11 +00:00
|
|
|
NSDate* anExpireDate=nil;
|
|
|
|
if ([self isTerminating])
|
|
|
|
{
|
|
|
|
sessionID=@"";
|
|
|
|
anExpireDate=[NSDate date]; //expire now !
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sessionID=[self sessionID];
|
|
|
|
anExpireDate=[self expirationDateForIDCookies];
|
|
|
|
};
|
2003-04-09 12:03:17 +00:00
|
|
|
|
|
|
|
// SessionID cookie
|
2002-07-27 23:48:47 +00:00
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_SessionID[GSWebNamingConv]
|
|
|
|
value:sessionID
|
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
2003-04-09 12:03:17 +00:00
|
|
|
expires:anExpireDate
|
2002-07-27 23:48:47 +00:00
|
|
|
isSecure:NO]];
|
2003-04-09 12:03:17 +00:00
|
|
|
|
|
|
|
// Instance Cookie
|
|
|
|
// No Instance if distribution enabled or this session is terminating
|
|
|
|
if ([self isDistributionEnabled] || [self isTerminating])
|
|
|
|
{
|
|
|
|
instance=-1;
|
|
|
|
anExpireDate=[NSDate date]; //expire now !
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GSWRequest* request = [_currentContext request];
|
|
|
|
if (request)
|
|
|
|
instance=[request applicationNumber]; // use the request instance number
|
|
|
|
else
|
|
|
|
instance=-1;
|
|
|
|
};
|
2002-07-27 23:48:47 +00:00
|
|
|
[aResponse addCookie:[GSWCookie cookieWithName:GSWKey_InstanceID[GSWebNamingConv]
|
2003-04-09 12:03:17 +00:00
|
|
|
value:[NSString stringWithFormat:@"%d",instance]
|
2002-07-27 23:48:47 +00:00
|
|
|
path:domainForIDCookies
|
|
|
|
domain:nil
|
2003-04-09 12:03:17 +00:00
|
|
|
expires:anExpireDate
|
2002-07-27 23:48:47 +00:00
|
|
|
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);
|
* GSWeb.framework/GSWApplication.m
(GSWApplicationMainReal): Reformat. Use GSCurrentThread
instead of objc_thread_id. Remove \n in NSLog type logs.
(GSWApplicationMain): Ditto.
([GSWApplication init], [GSWApplication lockRequestHandling],
[GSWApplication unlockRequestHandling], [GSWApplication lock],
[GSWApplication unlock], [GSWApplication _sessionClass],
[GSWApplication run],
[GSWApplication addDynCreateClassName:superClassName:],
[GSWApplication pageWithName:],
[GSWApplication dynamicElementWithName:associations:template:]):
Ditto.
* GSWeb.framework/GSWComponent.m
([GSWComponent appendToResponse:inContext:], [GSWComponent
templateWithHTMLString:declarationString:languages:]): Ditto.
* GSWeb.framework/GSWContext.m
([GSWContext dealloc], [GSWContext setValidate:]): Ditto.
* GSWeb.framework/GSWDebug.m
(GSWLogC_, GSWLogDumpObjectFn): Ditto.
* GSWeb.framework/GSWDefaultAdaptor.m
([GSWDefaultAdaptor registerForEvents],
[GSWDefaultAdaptor announceNewConnection:],
[GSWDefaultAdaptor adaptorThreadExited:],
[GSWDefaultAdaptor tryLock]): Ditto.
* GSWeb.framework/GSWDefaultAdaptorThread.m
([GSWDefaultAdaptorThread setPool:destroyLast:],
[GSWDefaultAdaptorThread run:],
[GSWDefaultAdaptorThread threadExited],
[GSWDefaultAdaptorThread isExpired],
[GSWDefaultAdaptorThread sendRetryLasterResponseToStream:],
[GSWDefaultAdaptorThread
sendConnectionRefusedResponseToStream:withMessage:]): Ditto.
* GSWeb.framework/GSWDeployedBundle.m
([GSWDeployedBundle initWithPath:], [GSWDeployedBundle dealloc],
[GSWDeployedBundle lock], [GSWDeployedBundle unlock]): Ditto.
* GSWeb.framework/GSWLifebeatThread.m
([GSWLifebeatThread setPool:destroyLast:],
[GSWLifebeatThread threadExited]): Ditto.
* GSWeb.framework/GSWSession.m
([GSWSession initWithCoder:],
[GSWSession _releaseAutoreleasePool]): Ditto.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18611 72102866-910b-0410-8b05-ffd578937521
2004-02-17 16:53:36 +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);
|
* GSWeb.framework/GSWApplication.m
(GSWApplicationMainReal): Reformat. Use GSCurrentThread
instead of objc_thread_id. Remove \n in NSLog type logs.
(GSWApplicationMain): Ditto.
([GSWApplication init], [GSWApplication lockRequestHandling],
[GSWApplication unlockRequestHandling], [GSWApplication lock],
[GSWApplication unlock], [GSWApplication _sessionClass],
[GSWApplication run],
[GSWApplication addDynCreateClassName:superClassName:],
[GSWApplication pageWithName:],
[GSWApplication dynamicElementWithName:associations:template:]):
Ditto.
* GSWeb.framework/GSWComponent.m
([GSWComponent appendToResponse:inContext:], [GSWComponent
templateWithHTMLString:declarationString:languages:]): Ditto.
* GSWeb.framework/GSWContext.m
([GSWContext dealloc], [GSWContext setValidate:]): Ditto.
* GSWeb.framework/GSWDebug.m
(GSWLogC_, GSWLogDumpObjectFn): Ditto.
* GSWeb.framework/GSWDefaultAdaptor.m
([GSWDefaultAdaptor registerForEvents],
[GSWDefaultAdaptor announceNewConnection:],
[GSWDefaultAdaptor adaptorThreadExited:],
[GSWDefaultAdaptor tryLock]): Ditto.
* GSWeb.framework/GSWDefaultAdaptorThread.m
([GSWDefaultAdaptorThread setPool:destroyLast:],
[GSWDefaultAdaptorThread run:],
[GSWDefaultAdaptorThread threadExited],
[GSWDefaultAdaptorThread isExpired],
[GSWDefaultAdaptorThread sendRetryLasterResponseToStream:],
[GSWDefaultAdaptorThread
sendConnectionRefusedResponseToStream:withMessage:]): Ditto.
* GSWeb.framework/GSWDeployedBundle.m
([GSWDeployedBundle initWithPath:], [GSWDeployedBundle dealloc],
[GSWDeployedBundle lock], [GSWDeployedBundle unlock]): Ditto.
* GSWeb.framework/GSWLifebeatThread.m
([GSWLifebeatThread setPool:destroyLast:],
[GSWLifebeatThread threadExited]): Ditto.
* GSWeb.framework/GSWSession.m
([GSWSession initWithCoder:],
[GSWSession _releaseAutoreleasePool]): Ditto.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18611 72102866-910b-0410-8b05-ffd578937521
2004-02-17 16:53:36 +00:00
|
|
|
fprintf(stderr,"session %p _releaseAutoreleasePool STOP\n",self);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_createAutoreleasePool
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
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
|
|
|
|
{
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-06-25 15:36:28 +00:00
|
|
|
-(NSString*)_contextIDMatchingContextID:(NSString*)aContextID
|
|
|
|
requestSenderID:(NSString*)aSenderID
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSAssert(NO,@"Deprecated. use _contextIDMatchingIDsInContext:");
|
|
|
|
return nil;
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)_contextIDMatchingIDsInContext:(GSWContext*)aContext
|
|
|
|
{
|
|
|
|
NSString* contextID=nil;
|
|
|
|
NSString* requestContextID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
NSDebugMLog(@"aContext=%@",aContext);
|
|
|
|
requestContextID=[aContext _requestContextID];
|
|
|
|
NSDebugMLog(@"requestContextID=%@",requestContextID);
|
|
|
|
if (_contextRecords && requestContextID)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSArray* contextIDs = [_contextRecords allKeys];
|
|
|
|
int count = [contextIDs count];
|
|
|
|
int i=0;
|
|
|
|
for(i=0;!contextID && i<count;i++)
|
|
|
|
{
|
|
|
|
NSString* aContextID=[contextIDs objectAtIndex:i];
|
|
|
|
GSWTransactionRecord* aTransactionRecord=[_contextRecords objectForKey:aContextID];
|
|
|
|
if ([aTransactionRecord isMatchingIDsInContext:aContext])
|
|
|
|
contextID=aContextID;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGObjectFnStop();
|
|
|
|
|
|
|
|
return contextID;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-06-25 15:36:28 +00:00
|
|
|
-(void)_rearrangeContextArrayStackForContextID:(NSString*)contextID
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
2003-06-25 15:36:28 +00:00
|
|
|
|
|
|
|
if (_contextRecords)
|
|
|
|
{
|
|
|
|
unsigned int stackIndex=0;
|
|
|
|
unsigned int contextArrayIndex=0;
|
|
|
|
NSMutableArray* contextArray = [self _contextArrayForContextID:contextID
|
|
|
|
stackIndex:&stackIndex
|
|
|
|
contextArrayIndex:&contextArrayIndex];
|
|
|
|
int stackCount=[_contextArrayStack count];
|
|
|
|
if (contextArray // Found
|
|
|
|
&& (stackIndex!=stackCount-1 // not already the last one
|
|
|
|
|| contextArrayIndex!=[contextArray count]-1)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Put it at the stack end
|
|
|
|
[_contextArrayStack addObject:contextArray]; //add before removing to avoid release
|
|
|
|
//NSLog(@"AA _contextArrayStack class=%@",[_contextArrayStack class]);
|
|
|
|
//NSLog(@"BB stackIndex=%d",stackIndex);
|
|
|
|
//NSLog(@"BB [_contextArrayStack count]=%d",[_contextArrayStack count]);
|
|
|
|
[_contextArrayStack removeObjectAtIndex:stackIndex];
|
|
|
|
};
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-06-25 15:36:28 +00:00
|
|
|
-(NSMutableArray*)_contextArrayForContextID:(NSString*)aContextID
|
|
|
|
stackIndex:(unsigned int*)pStackIndex
|
|
|
|
contextArrayIndex:(unsigned int*)pContextArrayIndex
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSMutableArray* contextArray=nil;
|
|
|
|
int stackCount=[_contextArrayStack count];
|
|
|
|
unsigned int i=0;
|
|
|
|
for(i=0;!contextArray && i<stackCount;i++)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSMutableArray* aContextArray=[_contextArrayStack objectAtIndex:i];
|
|
|
|
unsigned int contextArrayIndex=[aContextArray indexOfObject:aContextID];
|
|
|
|
if (contextArrayIndex!=NSNotFound)
|
|
|
|
{
|
|
|
|
contextArray=aContextArray;
|
|
|
|
if (pStackIndex)
|
|
|
|
*pStackIndex=i;
|
|
|
|
if (pContextArrayIndex)
|
|
|
|
*pContextArrayIndex=contextArrayIndex;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (!contextArray)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
if (pStackIndex)
|
2003-06-25 15:36:28 +00:00
|
|
|
*pStackIndex=NSNotFound;
|
|
|
|
if (pContextArrayIndex)
|
|
|
|
*pContextArrayIndex=NSNotFound;
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
|
|
|
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
|
2004-05-06 13:55:49 +00:00
|
|
|
-(unsigned int)pageCacheSize
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
return [GSWApp pageCacheSize];
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)_savePage:(GSWComponent*)page
|
2003-03-24 07:45:52 +00:00
|
|
|
forChange:(BOOL)forChange
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWResponse* response=nil;
|
|
|
|
GSWTransactionRecord* transactionRecord=nil;
|
2003-06-25 15:36:28 +00:00
|
|
|
int pageCacheSize=0;
|
2002-07-27 23:48:47 +00:00
|
|
|
NSString* contextID=nil;
|
2003-06-25 15:36:28 +00:00
|
|
|
int pagesCount=0;
|
|
|
|
int contextsCount=0;
|
|
|
|
NSMutableArray* contextArray=nil;
|
|
|
|
BOOL createNewContextArrayFlag=NO;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
NSAssert(page,@"No Page");
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// Retrieve Page contextID
|
|
|
|
contextID=[[page context]contextID];
|
|
|
|
NSDebugMLLog(@"sessions",@"_contextID=%@",contextID);
|
|
|
|
NSAssert(contextID,@"No contextID");
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
if ([_contextArrayStack count]>0) // && _forChange!=NO ??
|
|
|
|
{
|
|
|
|
[self _rearrangeContextArrayStackForContextID:contextID];
|
|
|
|
contextArray=[_contextArrayStack lastObject]; //??
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
if(forChange || !contextArray)
|
|
|
|
createNewContextArrayFlag=YES;
|
|
|
|
else if ([contextArray count]>0)
|
|
|
|
{
|
|
|
|
NSString* lastContextID=[contextArray lastObject];
|
|
|
|
GSWTransactionRecord* transRecord = (GSWTransactionRecord*)[_contextRecords objectForKey:lastContextID];
|
|
|
|
GSWComponent* transRecordResponsePage = [transRecord responsePage];
|
|
|
|
createNewContextArrayFlag = (page!=transRecordResponsePage);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (createNewContextArrayFlag)
|
|
|
|
{
|
|
|
|
contextArray = [NSMutableArray array];
|
|
|
|
[_contextArrayStack addObject:contextArray];
|
|
|
|
}
|
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];
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
if (!_contextRecords)
|
|
|
|
_contextRecords=[NSMutableDictionary new];
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"contextArrayStack=%@",_contextArrayStack);
|
|
|
|
NSDebugMLLog(@"sessions",@"contextRecords=%@",_contextRecords);
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// Get the response
|
|
|
|
response=[_currentContext response];
|
|
|
|
NSDebugMLLog(@"sessions",@"response=%@",response);
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// Create a new transaction record
|
|
|
|
if (response && [response _isClientCachingDisabled])
|
|
|
|
transactionRecord = [GSWTransactionRecord transactionRecordWithResponsePage:page
|
|
|
|
context:_currentContext];
|
|
|
|
else
|
|
|
|
transactionRecord = [GSWTransactionRecord transactionRecordWithResponsePage:page
|
|
|
|
context:NULL];
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"transactionRecord=%@",transactionRecord);
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// Add it to contextRecords...
|
|
|
|
[_contextRecords setObject:transactionRecord
|
|
|
|
forKey:contextID];
|
|
|
|
[contextArray addObject:contextID];
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// Retrieve the pageCacheSize
|
|
|
|
pageCacheSize=[self pageCacheSize];
|
|
|
|
NSDebugMLLog(@"sessions",@"pageCacheSize=%d",pageCacheSize);
|
|
|
|
NSAssert1(pageCacheSize>=0,@"bad pageCacheSize %d",pageCacheSize);
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// Remove contextArray pages if page number greater than page cache size
|
|
|
|
pagesCount=[contextArray count];
|
|
|
|
while(pagesCount>=pageCacheSize)
|
|
|
|
{
|
|
|
|
NSString* deleteContextID=[contextArray objectAtIndex:0];
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
RETAIN(deleteContextID);
|
|
|
|
GSWLogAssertGood(deleteContextID);
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
[GSWApplication statusLogWithFormat:@"Deleting cached Page"];
|
2003-03-24 07:45:52 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
//NSLog(@"DD contextArray class=%@",[contextArray class]);
|
|
|
|
//NSLog(@"CC contextArray count=%d",[contextArray count]);
|
|
|
|
[contextArray removeObjectAtIndex:0];
|
|
|
|
[_contextRecords removeObjectForKey:deleteContextID];
|
2003-03-24 07:45:52 +00:00
|
|
|
RELEASE(deleteContextID);
|
2003-06-25 15:36:28 +00:00
|
|
|
pagesCount--;
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
// If empty, remove it
|
|
|
|
//NSLog(@"DD _contextArrayStack class=%@",[_contextArrayStack class]);
|
|
|
|
//NSLog(@"DD _contextArrayStack count=%d",[_contextArrayStack count]);
|
|
|
|
if(pagesCount==0)
|
|
|
|
[_contextArrayStack removeLastObject];
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-06-25 15:36:28 +00:00
|
|
|
contextsCount=[_contextArrayStack count];
|
|
|
|
//NSLog(@"zz1 contextsCount=%d",contextsCount);
|
|
|
|
//NSLog(@"zz1 pageCacheSize=%d",pageCacheSize);
|
|
|
|
while(contextsCount>=pageCacheSize)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSMutableArray* aContextArray=[_contextArrayStack objectAtIndex:0];
|
|
|
|
//NSLog(@"zz2 contextsCount=%d",contextsCount);
|
|
|
|
pagesCount=[aContextArray count];
|
|
|
|
while(pagesCount)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
2003-06-25 15:36:28 +00:00
|
|
|
NSString* deleteContextID=[aContextArray objectAtIndex:0];
|
|
|
|
RETAIN(deleteContextID);
|
|
|
|
GSWLogAssertGood(deleteContextID);
|
|
|
|
|
|
|
|
[GSWApplication statusLogWithFormat:@"Deleting cached Page"];
|
|
|
|
|
|
|
|
//NSLog(@"EE aContextArray class=%@",[aContextArray class]);
|
|
|
|
//NSLog(@"EE aContextArray count=%d",[aContextArray count]);
|
|
|
|
[aContextArray removeObjectAtIndex:0];
|
|
|
|
[_contextRecords removeObjectForKey:deleteContextID];
|
|
|
|
RELEASE(deleteContextID);
|
|
|
|
pagesCount--;
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
2003-06-25 15:36:28 +00:00
|
|
|
contextsCount--;
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
2003-06-25 15:36:28 +00:00
|
|
|
//NSLog(@"FF _contextArrayStack class=%@",[_contextArrayStack class]);
|
|
|
|
//NSLog(@"FF _contextArrayStack count=%d",[_contextArrayStack count]);
|
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);
|
2003-11-24 09:43:11 +00:00
|
|
|
if (aContext!=_currentContext)
|
|
|
|
_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];
|
2003-11-24 09:43:11 +00:00
|
|
|
if (_hasSessionLockedEditingContext)
|
|
|
|
{
|
|
|
|
[_editingContext unlock];
|
|
|
|
_hasSessionLockedEditingContext = NO;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
[self _setContext:nil];
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-07-27 23:48:47 +00:00
|
|
|
-(void)awakeInContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
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);
|
2003-11-24 09:43:11 +00:00
|
|
|
if (_editingContext
|
|
|
|
&& !_hasSessionLockedEditingContext
|
|
|
|
&& [GSWApplication _lockDefaultEditingContext])
|
|
|
|
{
|
|
|
|
[_editingContext lock];
|
|
|
|
_hasSessionLockedEditingContext=YES;
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
[self awake];
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWLocalization)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)setLanguages:(NSArray*)someLanguages
|
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
|
|
|
|
NSDebugMLLog(@"sessions",@"someLanguages=%@",someLanguages);
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
if (!someLanguages)
|
2002-07-27 23:48:47 +00:00
|
|
|
{
|
|
|
|
LOGError0(@"No languages");
|
|
|
|
};
|
|
|
|
ASSIGN(_languages,someLanguages);
|
2003-11-24 09:43:11 +00:00
|
|
|
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
/** GSWeb specific
|
|
|
|
Insert language language at the begining of session languages array
|
|
|
|
**/
|
|
|
|
-(void)insertLanguage:(NSString*)language
|
|
|
|
{
|
|
|
|
NSArray* languages=nil;
|
|
|
|
LOGObjectFnStart();
|
|
|
|
if ([language length]>0)
|
|
|
|
{
|
|
|
|
languages=[self languages];
|
|
|
|
if ([languages count]>0)
|
|
|
|
{
|
|
|
|
if (![language isEqualToString:[languages objectAtIndex:0]])
|
|
|
|
{
|
|
|
|
NSMutableArray* mutableLanguages=[[languages mutableCopy]autorelease];
|
|
|
|
[mutableLanguages removeObject:language];//Remove language if it exists in languages
|
|
|
|
[mutableLanguages insertObject:language
|
|
|
|
atIndex:0];
|
|
|
|
[self setLanguages:mutableLanguages];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self setLanguages:[NSArray arrayWithObject:language]];
|
|
|
|
};
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
/** GSWeb specific
|
|
|
|
Add language language at the end of session languages array if language
|
|
|
|
is not present
|
|
|
|
**/
|
|
|
|
-(void)addLanguage:(NSString*)language
|
|
|
|
{
|
|
|
|
NSArray* languages=nil;
|
|
|
|
LOGObjectFnStart();
|
|
|
|
if ([language length]>0)
|
|
|
|
{
|
|
|
|
languages=[self languages];
|
|
|
|
if ([languages count]>0)
|
|
|
|
{
|
|
|
|
if (![languages containsObject:language])
|
|
|
|
[self setLanguages:[languages arrayByAddingObject:language]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self setLanguages:[NSArray arrayWithObject:language]];
|
|
|
|
};
|
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
/** GSWeb specific
|
|
|
|
Returns first element of languages or nil if languages is empty
|
|
|
|
**/
|
|
|
|
-(NSString*)firstLanguage
|
|
|
|
{
|
|
|
|
NSArray* languages=nil;
|
|
|
|
NSString* firstLanguage=nil;
|
|
|
|
LOGObjectFnStart();
|
|
|
|
|
|
|
|
languages=[self languages];
|
|
|
|
if ([languages count]>0)
|
|
|
|
firstLanguage=[languages objectAtIndex:0];
|
|
|
|
|
|
|
|
LOGObjectFnStop();
|
|
|
|
|
|
|
|
return firstLanguage;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSArray*)languages
|
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
|
|
|
|
NSDebugMLLog(@"sessions",@"_languages=%@",_languages);
|
|
|
|
|
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];
|
2003-11-24 09:43:11 +00:00
|
|
|
NSDebugMLLog(@"sessions",@"_languages=%@",_languages);
|
2002-07-27 23:48:47 +00:00
|
|
|
};
|
2003-11-24 09:43:11 +00:00
|
|
|
|
|
|
|
LOGObjectFnStop();
|
|
|
|
|
|
|
|
return _languages;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSArray*)_languages
|
|
|
|
{
|
|
|
|
LOGObjectFnStart();
|
|
|
|
LOGObjectFnStop();
|
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
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
|
|
|
};
|
2004-03-26 10:27:20 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWEnterpriseObjects)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(EOEditingContext*)defaultEditingContext
|
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
#if HAVE_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]);
|
2003-11-24 09:43:11 +00:00
|
|
|
[_editingContext setLevelsOfUndo:[GSWApplication defaultUndoStackLimit]];
|
|
|
|
if ([GSWApplication _lockDefaultEditingContext])
|
|
|
|
{
|
|
|
|
[_editingContext lock];
|
|
|
|
_hasSessionLockedEditingContext=YES;
|
|
|
|
};
|
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
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
if (_editingContext)
|
|
|
|
{
|
|
|
|
// We can't set the editing context if one has already been created
|
|
|
|
[NSException raise:NSInvalidArgumentException
|
|
|
|
format:@"%s Can't set a defautEditingContext when one already exists",
|
|
|
|
object_get_class_name(self)];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ASSIGN(_editingContext,editingContext);
|
|
|
|
if ([GSWApplication _lockDefaultEditingContext])
|
|
|
|
{
|
|
|
|
[_editingContext lock];
|
|
|
|
_hasSessionLockedEditingContext=YES;
|
|
|
|
};
|
|
|
|
};
|
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
|
|
|
{
|
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
|
2003-11-24 09:43:11 +00:00
|
|
|
[aContext _setCurrentComponent:pageComponent];
|
|
|
|
[pageElement takeValuesFromRequest:aRequest
|
|
|
|
inContext:aContext];
|
2002-07-27 23:48:47 +00:00
|
|
|
[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
|
2003-11-24 09:43:11 +00:00
|
|
|
[aContext _setCurrentComponent:pageComponent];
|
|
|
|
element=[pageElement invokeActionForRequest:aRequest
|
|
|
|
inContext:aContext];
|
2002-07-27 23:48:47 +00:00
|
|
|
[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
|
2003-11-24 09:43:11 +00:00
|
|
|
inContext:(GSWContext*)aContext
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
GSWStatisticsStore* statisticsStore=nil;
|
|
|
|
NSString* logFile=nil;
|
|
|
|
GSWElement* pageElement=nil;
|
|
|
|
GSWComponent* pageComponent=nil;
|
2003-11-24 09:43:11 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2003-11-24 09:43:11 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
statisticsStore=[[GSWApplication application] statisticsStore];
|
2003-11-24 09:43:11 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
pageElement=[aContext _pageElement];
|
|
|
|
pageComponent=[aContext _pageComponent];
|
2003-11-24 09:43:11 +00:00
|
|
|
|
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
|
2003-11-24 09:43:11 +00:00
|
|
|
|
|
|
|
[aContext _setCurrentComponent:pageComponent];
|
2003-01-19 15:33:07 +00:00
|
|
|
NS_DURING
|
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
[pageElement appendToResponse:aResponse
|
|
|
|
inContext:aContext];
|
2003-01-19 15:33:07 +00:00
|
|
|
}
|
|
|
|
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;
|
2003-11-24 09:43:11 +00:00
|
|
|
|
2002-07-27 23:48:47 +00:00
|
|
|
[aContext _setCurrentComponent:nil];
|
2003-11-24 09:43:11 +00:00
|
|
|
|
|
|
|
[self appendCookieToResponse:aResponse];
|
|
|
|
|
|
|
|
{
|
|
|
|
NSString* descr=nil;
|
|
|
|
[statisticsStore recordStatisticsForResponse:aResponse
|
|
|
|
inContext:aContext];
|
|
|
|
descr=[statisticsStore descriptionForResponse:aResponse
|
|
|
|
inContext:aContext];
|
|
|
|
if (descr)
|
|
|
|
{
|
|
|
|
[_statistics addObject:descr];
|
|
|
|
logFile=[statisticsStore logFile];
|
|
|
|
if (logFile)
|
|
|
|
{
|
|
|
|
NSString* formattedDescr=[GSWStatisticsStore formatDescription:descr
|
|
|
|
forResponse:aResponse
|
|
|
|
inContext:aContext];
|
|
|
|
if (formattedDescr)
|
|
|
|
{
|
|
|
|
if (!_formattedStatistics)
|
|
|
|
_formattedStatistics = [NSMutableString new];
|
|
|
|
[_formattedStatistics appendString:formattedDescr];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWStatistics)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSArray*)statistics
|
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
return _statistics;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(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
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2003-11-24 09:43:11 +00:00
|
|
|
-(void)_setAllowedToViewStatistics:(BOOL)flag
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2003-11-24 09:43:11 +00:00
|
|
|
_isAllowedToViewStatistics=flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)validateStatisticsLogin:(NSString*)login
|
|
|
|
withPassword:(NSString*)password
|
|
|
|
{
|
|
|
|
GSWStatisticsStore* statsStore = [[GSWApplication application]statisticsStore];
|
|
|
|
if (statsStore)
|
|
|
|
{
|
|
|
|
NSString* statsStorePassword=[statsStore _password];
|
|
|
|
if ([statsStorePassword isEqual:password])
|
|
|
|
[self _allowToViewStatistics];
|
|
|
|
}
|
|
|
|
return [self _allowedToViewStatistics];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSString*)_formattedStatistics
|
|
|
|
{
|
|
|
|
return [NSString stringWithString:_formattedStatistics];
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(NSDate*)_birthDate
|
|
|
|
{
|
2002-07-27 23:48:47 +00:00
|
|
|
return _birthDate;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
2003-11-24 09:43:11 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setBirthDate:(NSDate*)birthDate
|
|
|
|
{
|
|
|
|
ASSIGN(_birthDate,birthDate);
|
|
|
|
};
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWSession (GSWEvents)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)_allowedToViewEvents
|
|
|
|
{
|
|
|
|
return _isAllowedToViewEvents;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_allowToViewEvents
|
|
|
|
{
|
|
|
|
_isAllowedToViewEvents=YES;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(void)_setAllowedToViewEvents:(BOOL)flag
|
|
|
|
{
|
|
|
|
_isAllowedToViewEvents=flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
-(BOOL)validateEventsLogin:(NSString*)login
|
|
|
|
withPassword:(NSString*)password
|
|
|
|
{
|
|
|
|
//TODO wait for gdl2 implementation
|
|
|
|
/*
|
|
|
|
NSString* eventCenterPassword=[EOEventCenter password];
|
|
|
|
if ([eventCenterPassword isEqual:password])
|
|
|
|
[self _allowToViewEvents];
|
|
|
|
*/
|
|
|
|
return [self _allowedToViewEvents];
|
|
|
|
}
|
|
|
|
|
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
|