/*
 * dbXML - Native XML Database
 * Copyright (C) 1999-2003  The dbXML Group, L.L.C.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Id: ConnectionManager.m,v 1.4 2003/12/27 21:01:28 bradford Exp $
 */

#import <CoreServices/CoreServices.h>

#import "Constants.h"
#import "ConnectionManager.h"

@implementation ConnectionManager

- (id) init {
   self = [super init];
   connected = false;
   properties = [NSMutableDictionary dictionary];
   return self;
}

- (void) setProperty: (NSString*) name toValue:(NSString*) value {
   [properties setValue:value forKey:name];
}

- (NSString*) getProperty: (NSString*) name {
   return (NSString*) [properties valueForKey:name];
}

- (NSArray*) listProperties {
   return [properties allKeys];
}

- (NSDictionary*) getProperties {
   return properties;
}

- (void) connect {
   NSString* host = [self getProperty:dbXMLClient_HOST];
   if ( host == nil )
      host = [ self getProperty:dbXMLClient_ALT_HOST];
   
   NSString* port = [self getProperty:dbXMLClient_PORT];
   if ( port == nil )
      port = [self getProperty:dbXMLClient_ALT_PORT];
   
   NSString* user = [self getProperty:dbXMLClient_USER];
   if ( user == nil )
      user = [self getProperty:dbXMLClient_ALT_USER];
   
   NSString* pass = [self getProperty:dbXMLClient_PASS];
   if ( pass == nil )
      pass = [self getProperty:dbXMLClient_ALT_PASS];
   
   /*
   CFUrlRef url;
   CFStringRef methodName;
   CFStringRef protocolName = kWSXMLRPCProtocol;
      
   WSMethodInvocationRef ws = WSMethodInvocationCreate(url, methodName, protocolName);   
   */
      
   connected = true;
}

- (void) disconnect {
   connected = false;
}

@end
