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