Source/AIURLHandlerAdvancedPreferences.m
author Thijs Alkemade <me@thijsalkema.de>
Sun, 23 Apr 2017 20:53:22 +0200
branchadium-1.5.10.4
changeset 5983 a98704da1923
parent 3678 4dbda7e6999b
permissions -rw-r--r--
Fix an uncaught exception in the Default Client advanced preferences from messing up the UI by removing all traces of MSN and Yahoo from the URL handler code.
3678
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     1
/* 
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     2
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     3
 * with this source distribution.
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     4
 * 
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     6
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     7
 * or (at your option) any later version.
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     8
 * 
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
    10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
    11
 * Public License for more details.
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
    12
 * 
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
    13
 * You should have received a copy of the GNU General Public License along with this program; if not,
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
    14
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
4dbda7e6999b Bring consistency to file headings, this is not exhaustive. Zac and Adam version.
Frank Dowsett <wixardy@adium.im>
parents: 3204
diff changeset
    15
 */
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    16
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    17
#import "AIURLHandlerAdvancedPreferences.h"
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    18
#import "AIPreferenceWindowController.h"
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    19
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    20
#import <AIUtilities/AIImageTextCell.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    21
#import <AIUtilities/AIImageAdditions.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    22
#import <AIUtilities/AIArrayAdditions.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    23
#import <AIUtilities/AIMenuAdditions.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    24
#import <AIUtilities/AIImageDrawingAdditions.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    25
#import <Adium/AIAccountControllerProtocol.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    26
#import <Adium/AIService.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    27
#import <Adium/AIServiceIcons.h>
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    28
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    29
@interface AIURLHandlerAdvancedPreferences()
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    30
- (void)configureTableView;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    31
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    32
- (void)initializeServiceInformationForSchemes:(NSArray *)schemes;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    33
- (NSMenu *)applicationMenuForScheme:(NSString *)scheme;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    34
- (NSArray *)applicationDictionaryArrayForScheme:(NSString *)scheme;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    35
- (NSImage *)serviceImageForScheme:(NSString *)scheme;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    36
- (NSString *)serviceNameForScheme:(NSString *)scheme;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    37
@end
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    38
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    39
@implementation AIURLHandlerAdvancedPreferences
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    40
#pragma mark Preference pane settings
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    41
- (AIPreferenceCategory)category
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    42
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    43
    return AIPref_Advanced;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    44
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    45
- (NSString *)label{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    46
    return AILocalizedString(@"Default Client",nil);
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    47
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    48
- (NSString *)nibName{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    49
    return @"AIURLHandlerPreferences";
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    50
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    51
- (NSImage *)image{
2810
0815e91b9644 Update to the images provided by George Lambrou.
Zachary West <zacw@adium.im>
parents: 2634
diff changeset
    52
	return [NSImage imageNamed:@"pref-defaultclient" forClass:[AIPreferenceWindowController class]];
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    53
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    54
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    55
- (void)viewDidLoad
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    56
{
1635
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
    57
	[servicesList release];
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
    58
	
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    59
	servicesList = [((AIURLHandlerPlugin *)plugin).uniqueSchemes retain];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    60
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    61
	[self configureTableView];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    62
	[self initializeServiceInformationForSchemes:servicesList];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    63
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    64
	[button_setDefault setLocalizedString:AILocalizedString(@"Set Default for All", nil)];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    65
	[checkBox_enforceDefault setLocalizedString:AILocalizedString(@"Always set Adium as the default", nil)];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    66
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    67
	[checkBox_enforceDefault setState:[[adium.preferenceController preferenceForKey:PREF_KEY_ENFORCE_DEFAULT
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    68
																			  group:GROUP_URL_HANDLING] boolValue]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    69
	
3204
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
    70
	[tableView setEnabled:![[adium.preferenceController preferenceForKey:PREF_KEY_ENFORCE_DEFAULT
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
    71
																   group:GROUP_URL_HANDLING] boolValue]];
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
    72
	
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    73
	[super viewDidLoad];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    74
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    75
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    76
- (void)dealloc
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    77
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    78
	[servicesList release];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    79
	[services release];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    80
	[super dealloc];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    81
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    82
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    83
#pragma mark Actions
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    84
- (IBAction)setDefault:(id)sender
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    85
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    86
	[plugin setAdiumAsDefault];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    87
	[tableView reloadData];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    88
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    89
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    90
- (IBAction)enforceDefault:(id)sender
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    91
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    92
	[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    93
									   forKey:PREF_KEY_ENFORCE_DEFAULT
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
    94
										group:GROUP_URL_HANDLING];
1541
ddd88bf723d1 When enabling the enforce service default option for URL handling, set Adium as the default for everything.
Zachary West <zacw@adiumx.com>
parents: 1492
diff changeset
    95
	
3204
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
    96
	[tableView setEnabled:![sender state]];
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
    97
	
1541
ddd88bf723d1 When enabling the enforce service default option for URL handling, set Adium as the default for everything.
Zachary West <zacw@adiumx.com>
parents: 1492
diff changeset
    98
	if ([sender state]) {
ddd88bf723d1 When enabling the enforce service default option for URL handling, set Adium as the default for everything.
Zachary West <zacw@adiumx.com>
parents: 1492
diff changeset
    99
		[plugin setAdiumAsDefault];
ddd88bf723d1 When enabling the enforce service default option for URL handling, set Adium as the default for everything.
Zachary West <zacw@adiumx.com>
parents: 1492
diff changeset
   100
	}
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   101
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   102
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   103
#pragma mark Scheme information
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   104
- (void)initializeServiceInformationForSchemes:(NSArray *)schemes
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   105
{
1635
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
   106
	[services release]; services = [[NSMutableDictionary alloc] init];
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   107
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   108
	for (NSString *scheme in schemes) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   109
		[services setObject:[NSMutableDictionary dictionary] forKey:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   110
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   111
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   112
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   113
- (NSMenu *)applicationMenuForScheme:(NSString *)scheme
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   114
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   115
	NSMutableDictionary		*servicesInformation = [services objectForKey:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   116
	NSMenu					*menu = [servicesInformation objectForKey:@"applicationsMenu"];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   117
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   118
	if (!menu) {
1635
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
   119
		menu = [[[NSMenu alloc] init] autorelease];
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   120
		
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   121
		for (NSDictionary *application in [self applicationDictionaryArrayForScheme:scheme]) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   122
			NSMenuItem *menuItem = [menu addItemWithTitle:[application objectForKey:@"ApplicationName"]
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   123
												   target:nil
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   124
												   action:nil
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   125
											keyEquivalent:@""];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   126
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   127
			[menuItem setImage:[[application objectForKey:@"ApplicationImage"] imageByScalingForMenuItem]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   128
			[menuItem setRepresentedObject:[application objectForKey:@"BundleID"]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   129
		}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   130
		
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   131
		[servicesInformation setObject:menu forKey:@"applicationsMenu"];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   132
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   133
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   134
	return menu;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   135
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   136
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   137
- (NSArray *)applicationDictionaryArrayForScheme:(NSString *)scheme
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   138
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   139
	NSMutableDictionary		*servicesInformation = [services objectForKey:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   140
	NSArray					*applications = [servicesInformation objectForKey:@"applications"];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   141
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   142
	if (!applications) {
1635
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
   143
		NSArray					*applicationArray = [(NSArray *)LSCopyAllHandlersForURLScheme((CFStringRef)scheme) autorelease];
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
   144
		NSMutableArray			*mutableApplications = [NSMutableArray array];
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   145
		
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   146
		for (NSString *bundleID in applicationArray) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   147
			// File System Ref for this bundle ID
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   148
			FSRef		fileSystemRef;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   149
			OSStatus	err = LSFindApplicationForInfo(kLSUnknownCreator, (CFStringRef)bundleID, NULL, &fileSystemRef, NULL);
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   150
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   151
			if (err == kLSApplicationNotFoundErr) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   152
				return nil;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   153
			}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   154
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   155
			// Application Name
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   156
			HFSUniStr255	name;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   157
			OSErr informationError = FSGetCatalogInfo(&fileSystemRef, kFSCatInfoNone, NULL, &name, NULL, NULL);
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   158
			if (informationError) { 
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   159
				return nil;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   160
			}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   161
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   162
			NSString	*applicationName = [NSString stringWithCharacters:name.unicode length:name.length];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   163
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   164
			// Application Image
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   165
			IconRef iconRef;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   166
			err = GetIconRefFromFileInfo(&fileSystemRef, 0, NULL, kFSCatInfoNone, NULL, kIconServicesNoBadgeFlag, &iconRef, NULL);
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   167
			if (err) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   168
				return nil;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   169
			}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   170
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   171
			NSImage *image = [[[NSImage alloc] initWithIconRef:iconRef] autorelease];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   172
			
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   173
			[mutableApplications addObject:[NSDictionary dictionaryWithObjectsAndKeys:bundleID.lowercaseString, @"BundleID",
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   174
											applicationName, @"ApplicationName",
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   175
											image, @"ApplicationImage", nil]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   176
		}
1635
02bb97fff1a3 Plug a few leaks in the URL handler.
Zachary West <zacw@adiumx.com>
parents: 1541
diff changeset
   177
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   178
		[servicesInformation setObject:mutableApplications forKey:@"applications"];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   179
		
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   180
		applications = mutableApplications;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   181
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   182
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   183
	return applications;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   184
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   185
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   186
- (NSImage *)serviceImageForScheme:(NSString *)scheme
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   187
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   188
	NSMutableDictionary		*servicesInformation = [services objectForKey:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   189
	NSImage					*image = [servicesInformation objectForKey:@"image"];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   190
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   191
	if (!image) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   192
		AIService *service = [adium.accountController firstServiceWithServiceID:[plugin serviceIDForScheme:scheme]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   193
		image = [AIServiceIcons serviceIconForService:service type:AIServiceIconLarge direction:AIIconNormal];
5983
a98704da1923 Fix an uncaught exception in the Default Client advanced preferences from messing up the UI by removing all traces of MSN and Yahoo from the URL handler code.
Thijs Alkemade <me@thijsalkema.de>
parents: 3678
diff changeset
   194
		if (image) [servicesInformation setObject:image forKey:@"image"];
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   195
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   196
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   197
	return image;	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   198
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   199
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   200
- (NSString *)serviceNameForScheme:(NSString *)scheme
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   201
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   202
	NSMutableDictionary		*servicesInformation = [services objectForKey:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   203
	NSString				*longServiceName = [servicesInformation objectForKey:@"name"];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   204
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   205
	if (!longServiceName) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   206
		AIService *service = [adium.accountController firstServiceWithServiceID:[plugin serviceIDForScheme:scheme]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   207
		longServiceName = [service longDescription];
5983
a98704da1923 Fix an uncaught exception in the Default Client advanced preferences from messing up the UI by removing all traces of MSN and Yahoo from the URL handler code.
Thijs Alkemade <me@thijsalkema.de>
parents: 3678
diff changeset
   208
		[servicesInformation setObject:(longServiceName ?: @"(unknown)") forKey:@"name"];
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   209
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   210
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   211
	return longServiceName;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   212
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   213
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   214
#pragma mark Table view Delegate
3204
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
   215
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
   216
- (void)refreshTable
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
   217
{
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
   218
	[tableView reloadData];
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
   219
}
a635c2bb8fc9 Patch from ''sphynx'' which fixes updating the Default Client table. Thanks :) Fixes #13635
Evan Schoenberg
parents: 2810
diff changeset
   220
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   221
- (void)configureTableView
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   222
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   223
	AIImageTextCell		*imageTextCell = [[AIImageTextCell alloc] init];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   224
	[imageTextCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   225
	[[tableView tableColumnWithIdentifier:@"service"] setDataCell:imageTextCell];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   226
	[imageTextCell release];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   227
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   228
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   229
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   230
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   231
	return servicesList.count;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   232
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   233
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   234
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   235
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   236
	NSString *identifier = tableColumn.identifier;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   237
	NSString *scheme = [servicesList objectAtIndex:row];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   238
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   239
	if ([identifier isEqualToString:@"service"]) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   240
		// Configure to display the service icon and service name.
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   241
		[cell setImage:[self serviceImageForScheme:scheme]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   242
	} else if ([identifier isEqualToString:@"applications"]) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   243
		NSMenu *menu = [self applicationMenuForScheme:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   244
		NSString *defaultApplication = [plugin defaultApplicationBundleIDForScheme:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   245
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   246
		// Letting the NSPopupButtonCell handle state causes some buggy results. Do it ourself.
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   247
		for (NSMenuItem *menuItem in menu.itemArray) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   248
			[menuItem setState:[menuItem.representedObject isEqualToString:defaultApplication]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   249
		}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   250
		
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   251
		[cell setMenu:menu];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   252
		[cell setAltersStateOfSelectedItem:NO];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   253
		[cell selectItemAtIndex:[cell indexOfItemWithRepresentedObject:defaultApplication]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   254
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   255
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   256
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   257
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   258
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   259
	NSString *identifier = tableColumn.identifier;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   260
	NSString *scheme = [servicesList objectAtIndex:row];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   261
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   262
	if ([identifier isEqualToString:@"service"]) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   263
		return [self serviceNameForScheme:scheme];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   264
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   265
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   266
	return nil;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   267
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   268
2634
f8f70fff48f1 Type fixes for adium. making it ready for 64-bit compiling.
Stephen Holt <sholt@adium.im>
parents: 1946
diff changeset
   269
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
1492
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   270
{
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   271
	NSString *identifier = tableColumn.identifier;
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   272
	NSString *scheme = [servicesList objectAtIndex:row];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   273
	
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   274
	if ([identifier isEqualToString:@"applications"]) {
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   275
		[plugin setDefaultForScheme:scheme
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   276
						 toBundleID:[[[self applicationMenuForScheme:scheme] itemAtIndex:[object integerValue]] representedObject]];
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   277
	}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   278
}
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   279
076adb934a85 Change AdiumURLHandling into an AIPlugin subclass, which allows us to create an advanced preference pane to control its actions. Adds a few useful features:
Zachary West <zacw@adiumx.com>
parents:
diff changeset
   280
@end