Plugins/Twitter Plugin/AILaconicaService.m
author Zachary West <zacw@adium.im>
Sat Oct 17 17:35:57 2009 -0400 (2009-10-17)
changeset 2743 df2c24e3844c
parent 2723 82dcdf0db1b0
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 "AILaconicaService.h"
    18 #import <Adium/AIStatusControllerProtocol.h>
    19 #import <AIUtilities/AIImageAdditions.h>
    20 #import "AILaconicaAccount.h"
    21 #import "AILaconicaAccountViewController.h"
    22 
    23 @implementation AILaconicaService
    24 - (Class)accountClass
    25 {
    26 	return [AILaconicaAccount class];
    27 }
    28 
    29 - (AIAccountViewController *)accountViewController
    30 {
    31 	return [AILaconicaAccountViewController accountViewController];
    32 }
    33 
    34 - (DCJoinChatViewController *)joinChatView
    35 {
    36 	return nil;
    37 }
    38 
    39 // Service description
    40 - (NSString *)serviceCodeUniqueID{
    41 	return @"laconica";
    42 }
    43 - (NSString *)serviceID{
    44 	return @"Laconica";
    45 }
    46 - (NSString *)serviceClass{
    47 	return @"Laconica";
    48 }
    49 - (NSString *)shortDescription{
    50 	return @"StatusNet";
    51 }
    52 - (NSString *)longDescription{
    53 	return @"StatusNet";
    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)isSocialNetworkingService
    78 {
    79 	return YES;
    80 }
    81 
    82 /*!
    83  * @brief Default icon
    84  *
    85  * Service Icon packs should always include images for all the built-in Adium services.  This method allows external
    86  * service plugins to specify an image which will be used when the service icon pack does not specify one.  It will
    87  * also be useful if new services are added to Adium itself after a significant number of Service Icon packs exist
    88  * which do not yet have an image for this service.  If the active Service Icon pack provides an image for this service,
    89  * this method will not be called.
    90  *
    91  * The service should _not_ cache this icon internally; multiple calls should return unique NSImage objects.
    92  *
    93  * @param iconType The AIServiceIconType of the icon to return. This specifies the desired size of the icon.
    94  * @return NSImage to use for this service by default
    95  */
    96 - (NSImage *)defaultServiceIconOfType:(AIServiceIconType)iconType
    97 {
    98 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
    99 		return [NSImage imageNamed:@"laconica-small" forClass:[self class] loadLazily:YES];
   100 	} else {
   101 		return [NSImage imageNamed:@"laconica" forClass:[self class] loadLazily:YES];
   102 	}
   103 }
   104 
   105 /*!
   106  * @brief Path for default icon
   107  *
   108  * For use in message views, this is the path to a default icon as described above.
   109  *
   110  * @param iconType The AIServiceIconType of the icon to return.
   111  * @return The path to the image, otherwise nil.
   112  */
   113 - (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType
   114 {
   115 	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
   116 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"laconica-small"];
   117 	} else {
   118 		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"laconica"];		
   119 	}
   120 }
   121 
   122 @end