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