Skip to content
Newer
Older
100644 69 lines (60 sloc) 2.2 KB
76d2a5b @mstroeck
mstroeck authored Aug 28, 2011
1 //
2 // URLHandlerCommand.m
3 // Vienna
4 //
5 // Created by Steve on Wed Feb 04 2004.
6 // Copyright (c) 2004-2005 Steve Palmer. All rights reserved.
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 //
20
21 #import "URLHandlerCommand.h"
22 #import "AppController.h"
23
24 @implementation ViennaScriptCommand
25
26 /* performDefaultImplementation
27 * This is the entry point for all link handlers associated with Vienna. Currently we parse
28 * and manage the following format:
29 *
30 * feed://<rss link>
31 *
32 * Where <rss link> may be preceded by a scheme - either http:// or https://. If no scheme
33 * is specified then http:// is implied.
34 */
35 -(id)performDefaultImplementation
36 {
37 NSScanner * scanner = [NSScanner scannerWithString:[self directParameter]];
38 NSString * urlPrefix = nil;
39
40 [scanner scanUpToString:@":" intoString:&urlPrefix];
41 [scanner scanString:@":" intoString:nil];
42 if (urlPrefix && [urlPrefix isEqualToString:@"feed"])
43 {
44 NSString * feedScheme = nil;
45
46 // Throw away the next few bits if they exist
47 [scanner scanString:@"//" intoString:nil];
48 [scanner scanString:@"http:" intoString:&feedScheme];
49 [scanner scanString:@"https:" intoString:&feedScheme];
50 [scanner scanString:@"//" intoString:nil];
51
52 // The rest is the interesting part
53 NSString * linkPath = nil;
54
55 [scanner scanUpToString:@"" intoString:&linkPath];
56 if (linkPath == nil)
57 return nil;
58 if (feedScheme == nil)
59 feedScheme = @"http:";
60 linkPath = [NSString stringWithFormat:@"%@//%@", feedScheme, linkPath];
61
62 // Allow the run loop to run first, because this may be called at launch,
63 // In which case the db is not fully initialized yet.
64 [[NSApp delegate] performSelector:@selector(handleRSSLink:) withObject:linkPath afterDelay:0.0];
65 }
66 return nil;
67 }
68 @end
Something went wrong with that request. Please try again.