/* 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 "SyncMLSessionState.h" @implementation SyncMLSessionState - (id)initWithSessionID:(NSString *)_sessionID { if ((self = [super init])) { ASSIGNCOPY(self->sessionID,_sessionID); self->messageID = 1; self->openRequests = [[NSMutableDictionary alloc]init]; self->openRequestsExtraInfo = [[NSMutableDictionary alloc]init]; self->sendInitialAlerts = YES; self->syncForDB = [[NSMutableDictionary alloc]init]; self->mappingDBs = [[NSMutableSet alloc]init]; self->activeMappingDBs = [[NSMutableSet alloc]init]; self->backendData = [[NSMutableDictionary alloc]init]; self->syncLater = [[NSMutableSet alloc]init]; } return self; } - (void)dealloc { [self->sessionID release]; [self->remoteLocation release]; [self->openRequests release]; [self->openRequestsExtraInfo release]; [self->authenticationType release]; [self->authenticationData release]; [self->authenticationFormat release]; [self->syncForDB release]; [self->mappingDBs release]; [self->activeMappingDBs release]; [self->backendData release]; [self->syncLater release]; [self->deviceInformation release]; [super dealloc]; } - (NSString *)sessionID { return self->sessionID; } - (NSString *)messageID { return [NSString stringWithFormat:@"%u",self->messageID]; } - (NSString *)remoteLocation { return remoteLocation; } - (void)setRemoteLocation:(NSString *)_remoteLocation { ASSIGNCOPY(self->remoteLocation,_remoteLocation); } - (void)addOpenReq:(id)_command cmdID:(NSString*)_cmdid msgID:(NSString*)_msgid { [openRequests setObject:_command forKey:[NSString stringWithFormat:@"%@/%@",_cmdid,_msgid]]; } - (id)openReqCmdID:(NSString*)_cmdid msgID:(NSString*)_msgid { return [self->openRequests objectForKey: [NSString stringWithFormat:@"%@/%@",_cmdid,_msgid]]; } - (void)closeReqCmdID:(NSString*)_cmdid msgID:(NSString*)_msgid; { [self->openRequests removeObjectForKey: [NSString stringWithFormat:@"%@/%@",_cmdid,_msgid]]; [self->openRequestsExtraInfo removeObjectForKey: [NSString stringWithFormat:@"%@/%@",_cmdid,_msgid]]; } - (void)setExtraInfo:(id)_extraInfo forCmdID:(NSString*)_cmdid msgID:(NSString*)_msgid { [openRequestsExtraInfo setObject:_extraInfo forKey:[NSString stringWithFormat:@"%@/%@", _cmdid,_msgid]]; } - (id)extraInfoForCmdID:(NSString *)_cmdid msgID:(NSString *)_msgid { return [self->openRequestsExtraInfo objectForKey: [NSString stringWithFormat:@"%@/%@",_cmdid,_msgid]]; } - (BOOL)sendInitialAlerts { return self->sendInitialAlerts; } - (void)setSendInitialAlerts:(BOOL)_initialAlerts { self->sendInitialAlerts=_initialAlerts; } - (NSString *)authenticationType { return self->authenticationType; } - (void)setAuthenticationType:(NSString *)_authenticationType { ASSIGNCOPY(self->authenticationType,_authenticationType); } - (NSString *)authenticationFormat { return authenticationFormat; } - (void)setAuthenticationFormat:(NSString *)_authenticationFormat { ASSIGNCOPY(self->authenticationFormat,_authenticationFormat); } - (NSString *)authenticationData { return authenticationData; } - (void)setAuthenticationData:(NSString *)_authenticationData { ASSIGNCOPY(self->authenticationData,_authenticationData); } - (BOOL)iAmAuthenticated { return self->iAmAuthenticated; } - (void)setIAmAuthenticated:(BOOL)_authenticated { self->iAmAuthenticated = _authenticated; } - (BOOL)otherIsAuthenticated { return self->otherIsAuthenticated; } - (void)setOtherIsAuthenticated:(BOOL)_authenticated { self->otherIsAuthenticated = _authenticated; } - (void)setSync:(int)_syncAlert forDB:(id)_db { [self->syncForDB setObject:[NSNumber numberWithInt:_syncAlert] forKey:_db]; } - (int)syncForDB:(id)_db { return [[self->syncForDB objectForKey:_db] intValue]; } - (void)setBackendData:(id)_data forKey:(id)_key { [self->backendData setObject:_data forKey:_key]; } - (id)backendDataForKey:(id)_key { return [self->backendData objectForKey:_key]; } - (void)increaseMessageID { self->messageID++; } - (NSArray*)nextSyncLater { NSArray *next = [[self->syncLater anyObject] retain]; if (next) [self->syncLater removeObject:next]; return [next autorelease]; } - (void)addSyncLaterTarget:(NSString *)_targetdb source:(NSString *)_sourcedb { [self->syncLater addObject: [NSArray arrayWithObjects:_targetdb, _sourcedb, nil]]; } - (NSMutableDictionary *)deviceInformation { return self->deviceInformation; } - (void)setDeviceInformation:(NSDictionary*)_deviceInformation { [self->deviceInformation release]; self->deviceInformation = [[NSMutableDictionary alloc]init]; [self->deviceInformation addEntriesFromDictionary:_deviceInformation]; } - (NSMutableSet *)mappingDBs { return self->mappingDBs; } - (NSMutableSet *)activeMappingDBs { return self->activeMappingDBs; } - (void)makeMappingsActive { [activeMappingDBs unionSet:mappingDBs]; [mappingDBs removeAllObjects]; } @end /* SyncMLSessionState */