Plugins/Purple Service/ESIRCService.m
author Zachary West <zacw@adium.im>
Sat Oct 17 17:35:57 2009 -0400 (2009-10-17)
changeset 2743 df2c24e3844c
parent 1408 0cbddb6a4b8d
child 2839 ecb36859abb9
permissions -rw-r--r--
Add -[AIService pathForDefaultServiceIconOfType:], and use it for replacing %serviceIconImg% in headers. Fixes #12697.
     1 //
     2 //  ESIRCService.m
     3 //  Adium
     4 //
     5 //  Created by Evan Schoenberg on 3/4/06.
     6 //
     7 
     8 #import "ESIRCService.h"
     9 #import "ESIRCAccount.h"
    10 #import "ESIRCAccountViewController.h"
    11 #import "ESIRCJoinChatViewController.h"
    12 #import <AIUtilities/AIImageAdditions.h>
    13 #import <AIUtilities/AIImageDrawingAdditions.h>
    14 #import <AIUtilities/AICharacterSetAdditions.h>
    15 
    16 @implementation ESIRCService
    17 //Account Creation
    18 - (Class)accountClass{
    19 	return [ESIRCAccount class];
    20 }
    21 
    22 - (AIAccountViewController *)accountViewController{
    23     return [ESIRCAccountViewController accountViewController];
    24 }
    25 
    26 - (DCJoinChatViewController *)joinChatView{
    27 	return [ESIRCJoinChatViewController joinChatView];
    28 }
    29 
    30 //Service Description
    31 - (NSString *)serviceCodeUniqueID{
    32 	return @"libpurple-IRC";
    33 }
    34 - (NSString *)serviceID{
    35 	return @"IRC";
    36 }
    37 - (NSString *)serviceClass{
    38 	return @"IRC";
    39 }
    40 - (NSString *)shortDescription{
    41 	return @"IRC";
    42 }
    43 - (NSString *)longDescription{
    44 	return AILocalizedString(@"IRC (Internet Relay Chat)", nil);
    45 }
    46 - (NSCharacterSet *)allowedCharacters{
    47 	//Per RFC-2812: http://www.ietf.org/rfc/rfc2812.txt
    48 	NSMutableCharacterSet	*allowedCharacters = [[NSCharacterSet alphanumericCharacterSet] mutableCopy];
    49 	NSCharacterSet			*returnSet;
    50 	
    51 	[allowedCharacters addCharactersInString:@"[]\\`_^{|}-"];
    52 	returnSet = [allowedCharacters immutableCopy];
    53 	[allowedCharacters release];
    54 
    55 	return [returnSet autorelease];
    56 }
    57 - (BOOL)caseSensitive{
    58 	return NO;
    59 }
    60 - (BOOL)canCreateGroupChats{
    61 	return YES;
    62 }
    63 - (BOOL)supportsPassword{
    64 	return YES;
    65 }
    66 //Passwords are supported but optional
    67 - (BOOL)requiresPassword
    68 {
    69 	return NO;
    70 }
    71 - (AIServiceImportance)serviceImportance{
    72 	return AIServiceSecondary;
    73 }
    74 /*!
    75  * @brief Placeholder string for the UID field
    76  */
    77 - (NSString *)UIDPlaceholder
    78 {
    79 	return AILocalizedString(@"nickname","Sample name and server for new IRC accounts");
    80 }
    81 /*!
    82  * @brief Username label
    83  */
    84 - (NSString *)userNameLabel
    85 {
    86 	return AILocalizedString(@"Nickname", "Name for IRC user names");
    87 }
    88 
    89 /*!
    90 * @brief Default icon
    91  *
    92  * Service Icon packs should always include images for all the built-in Adium services.  This method allows external
    93  * service plugins to specify an image which will be used when the service icon pack does not specify one.  It will
    94  * also be useful if new services are added to Adium itself after a significant number of Service Icon packs exist
    95  * which do not yet have an image for this service.  If the active Service Icon pack provides an image for this service,
    96  * this method will not be called.
    97  *
    98  * The service should _not_ cache this icon internally; multiple calls should return unique NSImage objects.
    99  *
   100  * @param iconType The AIServiceIconType of the icon to return. This specifies the desired size of the icon.
   101  * @return NSImage to use for this service by default
   102  */
   103 - (NSImage *)defaultServiceIconOfType:(AIServiceIconType)iconType
   104 {
   105 	NSImage *baseImage = [NSImage imageNamed:@"irc" forClass:[self class] loadLazily:YES];
   106 
   107 	if (iconType == AIServiceIconSmall || iconType == AIServiceIconList) {
   108 		baseImage = [baseImage imageByScalingToSize:NSMakeSize(16, 16)];
   109     }
   110 
   111 	return baseImage;
   112 }
   113 
   114 /*!
   115  * @brief Path for default icon
   116  *
   117  * For use in message views, this is the path to a default icon as described above.
   118  *
   119  * @param iconType The AIServiceIconType of the icon to return.
   120  * @return The path to the image, otherwise nil.
   121  */
   122 - (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType
   123 {
   124 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
   125 		return nil; //xxx add small IRC icon
   126 	} else {
   127 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"irc"];		
   128 	}
   129 }
   130 
   131 @end