1/*
2 * Copyright (c) 2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24// *****************************************************************************
25//  cclparser.h
26//
27//  Created by kevine on 3/1/06.
28//  Recreated by sspies 15 January 2007.
29// *****************************************************************************
30
31#import <Foundation/Foundation.h>
32#import "cclkeys.h"
33
34#define kCCLOtherVendorName @"Other"
35
36@interface CCLParser : NSObject
37{
38    NSMutableDictionary *mBundleData;       // vendors->models->personalities
39    NSMutableDictionary *mBundlesProcessed; // bundle IDs -> paths
40    NSMutableDictionary *mFlatOverrides;    // flat names -> personalities
41                                            // (contains "Supersedes" data)
42
43    NSSet   *mTypeFilter;
44}
45
46// allocate a parser
47+ (CCLParser*)createCCLParser;
48
49// sets a filter for CCL bundle-based personalities.  Specifically,
50// desiredConnectTypes causes the -process* routines to silently ignore
51// personalities with Connect Type values other than those listed.
52// (e.g. "GPRS" or "Dialup"; someday WWAN?)
53// Flat CCL bundles (which have no type information) are still included.
54// Be sure to call -clearParser and then the process* routines again
55// if changing the filter list for an existing object.
56- (void)setTypeFilter:(NSSet*)desiredConnectTypes;
57
58// recursively searches directory (i.e. /Library/Modem Scripts) for CCLs.
59// Additional invocations add to the store.
60//
61// A CCL bundle is a directory with the .ccl extension.
62// processFolder: returns NO if it finds any directory that looks like a
63// CCL bundle but isn't a properly formed (doesn't have the right files, bad
64// version, etc).  It does not give up just because it found one malformed
65// CCL bundle.  Conforming bundles still have their personality data added.
66// Any files are assumed to be flat CCL scripts and are gathered together
67// under the 'Other' vendor.  "Flat" CCL personalities have their DeviceVendor
68// property set to the English string "Other" (kCCLOtherVendorName).
69// Their model is the CCL filename.
70- (BOOL)processFolder:(NSString*)folderPath;
71
72// add a single bundle or flat CCL script to the store
73- (BOOL)processCCLBundle:(NSString*)path;
74- (BOOL)processFlatCCL:(NSString*)path named:(NSString*)name;
75
76// expands names to remove ambiguity; will leave expanded dups.
77// Call after adding all CCLs.
78- (void)cleanupDuplicates;
79
80// returns a new array of vendor keys sorted alphabetically except for
81// 'Other' which will be appended to the list (if there were flat CCLs)
82// 'Other' should appear in a separate segment of the Vendor popup and
83// be localized by the callers of copyVendorList.  Additionally, OS X
84// contains a number of bundles with DeviceVendor = "Generic".  Generic
85// should also be localized.
86- (NSArray*)copyVendorList;
87
88// returns a reference to a sorted (by model name) list of personalities for
89// one of the 'copyVendorList' vendors.  dictionary keys from cclkeys.h.
90- (NSArray*)getModelListForVendor:(NSString*)vendor;
91
92// attempts to upgrade a pre-Leopard deviceConfiguration dictionary to have a
93// vendor, model, connection script, and personality if needed.
94// Only needed if vendor/model missing from stored device configuration.
95// If vendor/model are present, they are validated and the ConnectionScript
96// updated or nil returned if there was no match.  Beware -setTypeFilter:.
97- (NSMutableDictionary*)upgradeDeviceConfiguration:(NSDictionary*)deviceConf;
98
99// merges personality data (e.g. preferred APN/CID) with provided
100// SystemConfiguration device (e.g. modem) configuration dictionary.
101// returns autoreleased NSMutableDictionary on success; NULL on failure.
102// (The extra copy makes sure we only store what the user chooses or types.
103// i.e. One personality's defaults don't end up in the wrong personality.)
104- (NSMutableDictionary*)mergeCCLPersonality:(NSDictionary*)personality withDeviceConfiguration:(NSDictionary*)deviceConfiguration;
105
106
107// empties the store, retaining any type filters
108- (void)clearParser;
109
110@end
111