2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "AIVideoConfController.h"
19 #import <AIUtilities/AIToolbarUtilities.h>
20 #import <AIUtilities/AIImageAdditions.h>
21 #import <Adium/AIObject.h>
22 #import <Adium/AIListObject.h>
23 #import <Adium/AIPreferencePane.h>
25 @implementation AIVideoConfController
27 ////////////////////////////////////////////////////////////////////////////////
28 #pragma mark Initializers
29 ////////////////////////////////////////////////////////////////////////////////
36 if ((self = [super init])) {
37 providers = [[NSMutableDictionary alloc] init];
44 * @brief Finish initialization
46 - (void)controllerDidLoad
54 - (void)controllerWillClose
64 [providers release]; providers = nil;
68 ////////////////////////////////////////////////////////////////////////////////
69 #pragma mark Protocol Providers Management
70 ////////////////////////////////////////////////////////////////////////////////
73 * @brief Register a protocol provider
75 - (void) registerProvider:(id)provider forProtocol:(VCProtocol)protocol
77 NSAssert([provider conformsToProtocol:@protocol(VCProtocolProvider)],
78 @"Protocol does not conform to the VCProtocolProvider protocol.");
80 // Add our new provider
81 [providers setObject:provider forKey:[NSNumber numberWithInt:protocol]];
85 * @brief Unregister a protocol provider
87 - (void) unregisterProviderForProtocol:(VCProtocol)protocol
89 [providers removeObjectForKey:[NSNumber numberWithInt:protocol]];
93 * @brief Return the list of providers for a protocol
95 - (NSDictionary*) providersForProtocol:(VCProtocol)protocol
97 NSMutableDictionary *providersSet = [NSMutableDictionary dictionary];
98 NSDictionary *availableProviders;
100 if ((availableProviders = [providers objectForKey:[NSNumber numberWithInt:protocol]])) {
101 [providersSet addEntriesFromDictionary:availableProviders];
108 ////////////////////////////////////////////////////////////////////////////////
109 #pragma mark Payloads
110 ////////////////////////////////////////////////////////////////////////////////
111 - (NSArray*) getAudioPayloadsForProtocol:(VCProtocol)protocol
113 NSArray *listOfPayloads = nil;
114 id<VCProtocolProvider> provider;
116 provider = [providers objectForKey:[NSNumber numberWithInt:protocol]];
117 if (provider != nil) {
118 listOfPayloads = [provider getAudioPayloadsForProtocol:protocol];
121 return listOfPayloads;
124 - (NSArray*) getVideoPayloadsForProtocol:(VCProtocol)protocol
126 NSArray *listOfPayloads = nil;
127 id<VCProtocolProvider> provider;
129 provider = [providers objectForKey:[NSNumber numberWithInt:protocol]];
130 if (provider != nil) {
131 listOfPayloads = [provider getVideoPayloadsForProtocol:protocol];
134 return listOfPayloads;
138 ////////////////////////////////////////////////////////////////////////////////
139 #pragma mark Connections Creation
140 ////////////////////////////////////////////////////////////////////////////////
141 - (id) createConnectionWithProtocol:(VCProtocol)protocol
142 payload:(VCPayload*)pt
143 from:(VCTransport*)local
144 to:(VCTransport*)remote
146 id<VCConnection> connection = nil;
147 id<VCProtocolProvider> provider;
149 provider = [providers objectForKey:[NSNumber numberWithInt:protocol]];
150 if (provider != nil) {
151 connection = [provider createConnectionWithProtocol:protocol payload:pt from:local to:remote];