/* Copyright (C) 2000-2003 Max Berger This file is part of libsyncml, written for the OpenGroupware project (OGo) OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OGo 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with OGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id$ #include "SyncML.h" #include "SyncMLSessionState.h" #include "SyncMLSessionStatesStore.h" @implementation SyncMLSessionStatesStore static SyncMLSessionStatesStore *theStore = nil; // THREAD + (SyncMLSessionStatesStore *)getSyncMLSessionStatesStore { if (theStore == nil) theStore = [[SyncMLSessionStatesStore alloc]init]; return theStore; } + (void)deleteSyncMLSessionStatesStore { [theStore release]; theStore = nil; } - (id)init { if ((self = [super init])) { self->sessions = [[NSMutableDictionary alloc]init]; } return self; } - (void)dealloc { [self->sessions release]; [super dealloc]; } - (SyncMLSessionState*)_newStateWithID:(NSString *)_sessionID { SyncMLSessionState *state = [[SyncMLSessionState alloc]initWithSessionID:_sessionID]; [self->sessions setObject:state forKey:_sessionID]; [state release]; return [self->sessions objectForKey:_sessionID]; } - (SyncMLSessionState*)getStateForID:(NSString *)_sessionID { SyncMLSessionState *state = [self->sessions objectForKey:_sessionID]; if (state == nil) { NSLog(@"State %@ not found, creating new one!",_sessionID); state = [self _newStateWithID:_sessionID]; } return state; } - (SyncMLSessionState*)newState { NSString *sessionID = [NSString stringWithFormat:@"LIBSYNCML %@", [SyncML extendedTimeStamp]]; // FIXME: Check sessionID in existing states. This is low priority since // sessionID is generated by clients which have only one state // anyways... return [self _newStateWithID:sessionID]; } - (NSData *)serialize { // FIXME! return nil; } - (void)deserialize { // FIXME! } @end /* SyncMLSessionStatesStore */