/* Copyright (C) 2000-2003 Max Berger This file is part of vCardReceiver, 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$ #import "AddressBookSyncSessionHandler.h" @implementation AddressBookSessionHandler - (id) initWithUser:(NSString *)u pass:(NSString *)p syncType:(int)syncType errorLine:(id)line { self = [super init]; if (self) { user = [u retain]; pass = [p retain]; db = [[AddressBookDatabaseHandler alloc]init]; [db setRemoteTarget:[NSString stringWithFormat:@"./Contacts/%@",user]]; [db setSessionHandler:self]; [db setSyncType:syncType]; errorLine = line; } return self; } - (void) dealloc { [db release]; [user release]; [pass release]; [super dealloc]; } - (NSString *)requireAuthentication { return nil; } - (BOOL)authenticateAs:(NSString *)user withPass:(NSString *)pass { return YES; } - (NSString *)provideUsername { return user; } - (NSString *)providePlainPassword { return pass; } - (int)databaseCount { return 1; } - (id)databaseForIndex:(int)index { return db; } - (BOOL) server { return NO; } - (void) setSyncml:(SyncML*)syncml { // Do nothing (don't need that - yet) } - (void) invalidCredentials { [errorLine setStringValue:@"Invalid Credentials (username/password)"]; } - (int)addCount { return [db addCount]; } - (NSString*) deviceIdentification { return @"AddressBookSync"; } - (NSDictionary*) loadDeviceInformationFor:(NSString*)device { return [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"deviceInformation"] valueForKey:device]; } - (void) saveDeviceInformation:(NSDictionary*)information for:(NSString*)device { NSDictionary* oldValues = [[NSUserDefaults standardUserDefaults]dictionaryForKey:@"deviceInformation"]; NSMutableDictionary* newValues = [[NSMutableDictionary alloc]init]; [newValues addEntriesFromDictionary:oldValues]; [newValues setValue:information forKey:device]; [[NSUserDefaults standardUserDefaults]setValue:newValues forKey:@"deviceInformation"]; [[NSUserDefaults standardUserDefaults] synchronize]; } @end