Plugins/Twitter Plugin/AITwitterService.m
author Zachary West <zacw@adium.im>
Sat Oct 17 17:35:57 2009 -0400 (2009-10-17)
changeset 2743 df2c24e3844c
parent 1134 ca29b36c1d4c
permissions -rw-r--r--
Add -[AIService pathForDefaultServiceIconOfType:], and use it for replacing %serviceIconImg% in headers. Fixes #12697.
     1 /* 
     2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
     3  * with this source distribution.
     4  * 
     5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
     6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
     7  * or (at your option) any later version.
     8  * 
     9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
    10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
    11  * Public License for more details.
    12  * 
    13  * You should have received a copy of the GNU General Public License along with this program; if not,
    14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    15  */
    16 
    17 #import "AITwitterService.h"
    18 #import <Adium/AIStatusControllerProtocol.h>
    19 #import <AIUtilities/AIImageAdditions.h>
    20 #import "AITwitterAccount.h"
    21 #import "AITwitterAccountViewController.h"
    22 
    23 @implementation AITwitterService
    24 - (Class)accountClass
    25 {
    26 	return [AITwitterAccount class];
    27 }
    28 
    29 - (AIAccountViewController *)accountViewController
    30 {
    31 	return [AITwitterAccountViewController accountViewController];
    32 }
    33 
    34 - (DCJoinChatViewController *)joinChatView
    35 {
    36 	return nil;
    37 }
    38 
    39 // Service description
    40 - (NSString *)serviceCodeUniqueID{
    41 	return @"twitter";
    42 }
    43 - (NSString *)serviceID{
    44 	return @"Twitter";
    45 }
    46 - (NSString *)serviceClass{
    47 	return @"Twitter";
    48 }
    49 - (NSString *)shortDescription{
    50 	return @"Twitter";
    51 }
    52 - (NSString *)longDescription{
    53 	return @"Twitter";
    54 }
    55 - (NSCharacterSet *)allowedCharacters{
    56 	return [NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"];
    57 }
    58 - (NSUInteger)allowedLength{
    59 	return 999;
    60 }
    61 - (BOOL)caseSensitive{
    62 	return NO;
    63 }
    64 - (AIServiceImportance)serviceImportance{
    65 	return AIServiceSecondary;
    66 }
    67 - (BOOL)supportsProxySettings{
    68 	return NO;
    69 }
    70 - (void)registerStatuses{
    71 	[adium.statusController registerStatus:STATUS_NAME_AVAILABLE
    72 	 withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AVAILABLE]
    73 	 ofType:AIAvailableStatusType
    74 	 forService:self];
    75 }
    76 
    77 - (BOOL)requiresPassword
    78 {
    79 	return NO;
    80 }
    81 
    82 - (BOOL)isSocialNetworkingService
    83 {
    84 	return YES;
    85 }
    86 
    87 /*!
    88  * @brief Default icon
    89  *
    90  * Service Icon packs should always include images for all the built-in Adium services.  This method allows external
    91  * service plugins to specify an image which will be used when the service icon pack does not specify one.  It will
    92  * also be useful if new services are added to Adium itself after a significant number of Service Icon packs exist
    93  * which do not yet have an image for this service.  If the active Service Icon pack provides an image for this service,
    94  * this method will not be called.
    95  *
    96  * The service should _not_ cache this icon internally; multiple calls should return unique NSImage objects.
    97  *
    98  * @param iconType The AIServiceIconType of the icon to return. This specifies the desired size of the icon.
    99  * @return NSImage to use for this service by default
   100  */
   101 - (NSImage *)defaultServiceIconOfType:(AIServiceIconType)iconType
   102 {
   103 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
   104 		return [NSImage imageNamed:@"twitter-small" forClass:[self class] loadLazily:YES];
   105 	} else {
   106 		return [NSImage imageNamed:@"twitter" forClass:[self class] loadLazily:YES];
   107 	}
   108 }
   109 
   110 /*!
   111  * @brief Path for default icon
   112  *
   113  * For use in message views, this is the path to a default icon as described above.
   114  *
   115  * @param iconType The AIServiceIconType of the icon to return.
   116  * @return The path to the image, otherwise nil.
   117  */
   118 - (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType
   119 {
   120 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
   121 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"twitter-small"];
   122 	} else {
   123 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"twitter"];		
   124 	}
   125 }
   126 
   127 @end