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