Plugins/Purple Service/ESIRCService.m
author Zachary West <zacw@adium.im>
Sat Oct 31 15:52:20 2009 -0400 (2009-10-31)
changeset 2714 253da42ff00e
parent 2632 4e544bf1b994
permissions -rw-r--r--
Add a small IRC icon and an improved larger one. Refs #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 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
   106 		return [NSImage imageNamed:@"irc-small" forClass:[self class] loadLazily:YES];
   107 	} else {
   108 		return [NSImage imageNamed:@"irc" forClass:[self class] loadLazily:YES];
   109 	}
   110 }
   111 
   112 /*!
   113  * @brief Path for default icon
   114  *
   115  * For use in message views, this is the path to a default icon as described above.
   116  *
   117  * @param iconType The AIServiceIconType of the icon to return.
   118  * @return The path to the image, otherwise nil.
   119  */
   120 - (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType
   121 {
   122 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
   123 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"irc-small"];
   124 	} else {
   125 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"irc"];
   126 	}
   127 }
   128 
   129 @end