Plugins/Purple Service/PurpleFacebookService.m
author Zachary West <zacw@adium.im>
Sat Oct 17 17:35:57 2009 -0400 (2009-10-17)
changeset 2743 df2c24e3844c
parent 716 cf5b60a07058
child 3679 f4294bb53b0f
permissions -rw-r--r--
Add -[AIService pathForDefaultServiceIconOfType:], and use it for replacing %serviceIconImg% in headers. Fixes #12697.
Evan@660
     1
//
Evan@660
     2
//  PurpleFacebookService.m
Evan@660
     3
//  Adium
Evan@660
     4
//
Evan@660
     5
//  Created by Evan Schoenberg on 1/15/09.
Evan@660
     6
//  Copyright 2009 Adium X. All rights reserved.
Evan@660
     7
//
Evan@660
     8
Evan@660
     9
#import "PurpleFacebookService.h"
Evan@660
    10
#import "PurpleFacebookAccount.h"
Evan@660
    11
#import "PurpleFacebookAccountViewController.h"
Evan@660
    12
#import <Adium/AIStatusControllerProtocol.h>
Evan@660
    13
#import <AIUtilities/AIImageAdditions.h>
Evan@660
    14
Evan@660
    15
@implementation PurpleFacebookService
Evan@660
    16
Evan@660
    17
//Account Creation
Evan@660
    18
- (Class)accountClass{
Evan@660
    19
	return [PurpleFacebookAccount class];
Evan@660
    20
}
Evan@660
    21
Evan@660
    22
- (AIAccountViewController *)accountViewController{
Evan@660
    23
    return [PurpleFacebookAccountViewController accountViewController];
Evan@660
    24
}
Evan@660
    25
Evan@660
    26
- (DCJoinChatViewController *)joinChatView{
Evan@660
    27
	return nil;
Evan@660
    28
}
Evan@660
    29
Evan@660
    30
//Service Description
Evan@660
    31
- (NSString *)serviceCodeUniqueID{
Evan@660
    32
	return @"facebook-http";
Evan@660
    33
}
Evan@660
    34
- (NSString *)serviceID{
Evan@660
    35
	return @"Facebook";
Evan@660
    36
}
Evan@660
    37
- (NSString *)serviceClass{
Evan@660
    38
	return @"Facebook";
Evan@660
    39
}
Evan@660
    40
- (NSString *)shortDescription{
Evan@660
    41
	return @"Facebook";
Evan@660
    42
}
Evan@660
    43
- (NSString *)longDescription{
Evan@660
    44
	return @"Facebook";
Evan@660
    45
}
Evan@660
    46
- (NSCharacterSet *)allowedCharacters{
Evan@660
    47
	return [[NSCharacterSet illegalCharacterSet] invertedSet];
Evan@660
    48
}
Evan@660
    49
- (NSUInteger)allowedLength{
Evan@660
    50
	return 999;
Evan@660
    51
}
Evan@660
    52
- (AIServiceImportance)serviceImportance{
Evan@660
    53
	return AIServiceSecondary;
Evan@660
    54
}
Evan@660
    55
- (NSString *)userNameLabel{
Evan@660
    56
    return AILocalizedString(@"Email", "Used as a label for a username specified by email address");
Evan@660
    57
}
Evan@660
    58
- (NSString *)contactUserNameLabel{
Evan@660
    59
	return AILocalizedString(@"Facebook Email", "Label for the username for a Facebook contact");
Evan@660
    60
}
Evan@660
    61
- (void)registerStatuses{
Evan@660
    62
	[adium.statusController registerStatus:STATUS_NAME_AVAILABLE
Evan@660
    63
	 withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AVAILABLE]
Evan@660
    64
	 ofType:AIAvailableStatusType
Evan@660
    65
	 forService:self];
Evan@660
    66
}
Evan@660
    67
Evan@660
    68
- (BOOL)isSocialNetworkingService
Evan@660
    69
{
Evan@660
    70
	return YES;
Evan@660
    71
}
Evan@660
    72
Evan@660
    73
/*!
Evan@660
    74
 * @brief Default icon
Evan@660
    75
 *
Evan@660
    76
 * Service Icon packs should always include images for all the built-in Adium services.  This method allows external
Evan@660
    77
 * service plugins to specify an image which will be used when the service icon pack does not specify one.  It will
Evan@660
    78
 * also be useful if new services are added to Adium itself after a significant number of Service Icon packs exist
Evan@660
    79
 * which do not yet have an image for this service.  If the active Service Icon pack provides an image for this service,
Evan@660
    80
 * this method will not be called.
Evan@660
    81
 *
Evan@660
    82
 * The service should _not_ cache this icon internally; multiple calls should return unique NSImage objects.
Evan@660
    83
 *
Evan@660
    84
 * @param iconType The AIServiceIconType of the icon to return. This specifies the desired size of the icon.
Evan@660
    85
 * @return NSImage to use for this service by default
Evan@660
    86
 */
Evan@660
    87
- (NSImage *)defaultServiceIconOfType:(AIServiceIconType)iconType
Evan@660
    88
{
Evan@660
    89
	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
Evan@660
    90
		return [NSImage imageNamed:@"facebook-small" forClass:[self class] loadLazily:YES];
Evan@660
    91
	} else {
Evan@660
    92
		return [NSImage imageNamed:@"facebook" forClass:[self class] loadLazily:YES];
Evan@660
    93
	}
Evan@660
    94
}
Evan@660
    95
zacw@2743
    96
/*!
zacw@2743
    97
 * @brief Path for default icon
zacw@2743
    98
 *
zacw@2743
    99
 * For use in message views, this is the path to a default icon as described above.
zacw@2743
   100
 *
zacw@2743
   101
 * @param iconType The AIServiceIconType of the icon to return.
zacw@2743
   102
 * @return The path to the image, otherwise nil.
zacw@2743
   103
 */
zacw@2743
   104
- (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType
zacw@2743
   105
{
zacw@2743
   106
	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
zacw@2743
   107
		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"facebook-small"];
zacw@2743
   108
	} else {
zacw@2743
   109
		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"facebook"];		
zacw@2743
   110
	}
zacw@2743
   111
}
zacw@2743
   112
Evan@660
   113
@end