Plugins/Purple Service/PurpleMySpaceService.m
author Zachary West <zacw@adium.im>
Sat Oct 17 17:35:57 2009 -0400 (2009-10-17)
changeset 2743 df2c24e3844c
parent 716 cf5b60a07058
child 3679 f4294bb53b0f
permissions -rw-r--r--
Add -[AIService pathForDefaultServiceIconOfType:], and use it for replacing %serviceIconImg% in headers. Fixes #12697.
David@0
     1
//
David@0
     2
//  PurpleMySpaceService.m
David@0
     3
//  Adium
David@0
     4
//
David@0
     5
//  Created by Evan Schoenberg on 9/11/07.
David@0
     6
//
David@0
     7
David@0
     8
#import "PurpleMySpaceService.h"
David@0
     9
#import "PurpleMySpaceAccount.h"
David@0
    10
#import "PurpleMySpaceAccountViewController.h"
David@0
    11
#import <Adium/AIStatusControllerProtocol.h>
David@0
    12
#import <AIUtilities/AIImageAdditions.h>
David@0
    13
David@0
    14
@implementation PurpleMySpaceService
David@0
    15
David@0
    16
//Account Creation
David@0
    17
- (Class)accountClass{
David@0
    18
	return [PurpleMySpaceAccount class];
David@0
    19
}
David@0
    20
David@0
    21
- (AIAccountViewController *)accountViewController{
David@0
    22
    return [PurpleMySpaceAccountViewController accountViewController];
David@0
    23
}
David@0
    24
David@0
    25
- (DCJoinChatViewController *)joinChatView{
David@0
    26
	return nil;
David@0
    27
}
David@0
    28
David@0
    29
//Service Description
David@0
    30
- (NSString *)serviceCodeUniqueID{
David@0
    31
	return @"libpurple-MySpace";
David@0
    32
}
David@0
    33
- (NSString *)serviceID{
David@0
    34
	return @"MySpace";
David@0
    35
}
David@0
    36
- (NSString *)serviceClass{
David@0
    37
	return @"MySpace";
David@0
    38
}
David@0
    39
- (NSString *)shortDescription{
David@0
    40
	return @"MySpace";
David@0
    41
}
David@0
    42
- (NSString *)longDescription{
David@0
    43
	return @"MySpaceIM";
David@0
    44
}
David@0
    45
- (NSCharacterSet *)allowedCharacters{
David@0
    46
	return [NSCharacterSet characterSetWithCharactersInString:@"+abcdefghijklmnopqrstuvwxyz0123456789@._-"];
David@0
    47
}
David@60
    48
- (NSUInteger)allowedLength{
David@0
    49
	return 999;
David@0
    50
}
David@0
    51
- (BOOL)caseSensitive{
David@0
    52
	return NO;
David@0
    53
}
David@0
    54
- (AIServiceImportance)serviceImportance{
David@0
    55
	return AIServiceSecondary;
David@0
    56
}
David@0
    57
- (NSString *)userNameLabel{
David@0
    58
    return AILocalizedString(@"Email", "Used as a label for a username specified by email address");
David@0
    59
}
David@0
    60
- (NSString *)contactUserNameLabel{
David@0
    61
	return AILocalizedString(@"MySpace ID", "Label for the username for a MySpace contact");
David@0
    62
}
David@0
    63
- (void)registerStatuses{
David@100
    64
	[adium.statusController registerStatus:STATUS_NAME_AVAILABLE
David@100
    65
							 withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AVAILABLE]
David@0
    66
									  ofType:AIAvailableStatusType
David@0
    67
								  forService:self];
David@0
    68
	
David@100
    69
	[adium.statusController registerStatus:STATUS_NAME_AWAY
David@100
    70
							 withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AWAY]
David@0
    71
									  ofType:AIAwayStatusType
David@0
    72
								  forService:self];
David@0
    73
David@100
    74
	[adium.statusController registerStatus:STATUS_NAME_INVISIBLE
David@100
    75
							 withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_INVISIBLE]
David@0
    76
									  ofType:AIInvisibleStatusType
David@0
    77
								  forService:self];
David@0
    78
}
David@0
    79
David@0
    80
/*!
David@0
    81
 * @brief Default icon
David@0
    82
 *
David@0
    83
 * Service Icon packs should always include images for all the built-in Adium services.  This method allows external
David@0
    84
 * service plugins to specify an image which will be used when the service icon pack does not specify one.  It will
David@0
    85
 * also be useful if new services are added to Adium itself after a significant number of Service Icon packs exist
David@0
    86
 * which do not yet have an image for this service.  If the active Service Icon pack provides an image for this service,
David@0
    87
 * this method will not be called.
David@0
    88
 *
David@0
    89
 * The service should _not_ cache this icon internally; multiple calls should return unique NSImage objects.
David@0
    90
 *
David@0
    91
 * @param iconType The AIServiceIconType of the icon to return. This specifies the desired size of the icon.
David@0
    92
 * @return NSImage to use for this service by default
David@0
    93
 */
David@0
    94
- (NSImage *)defaultServiceIconOfType:(AIServiceIconType)iconType
David@0
    95
{
David@0
    96
	//If we're going to do it this way, we've got to return the small icon for both AIServiceIconSmall and the AIServiceIconList icons. 
David@0
    97
	return [NSImage imageNamed:((iconType == AIServiceIconSmall || iconType == AIServiceIconList) ? @"MySpace-small" : @"MySpace-large")
David@0
    98
					  forClass:[self class] loadLazily:YES];
David@0
    99
}
David@0
   100
zacw@2743
   101
/*!
zacw@2743
   102
 * @brief Path for default icon
zacw@2743
   103
 *
zacw@2743
   104
 * For use in message views, this is the path to a default icon as described above.
zacw@2743
   105
 *
zacw@2743
   106
 * @param iconType The AIServiceIconType of the icon to return.
zacw@2743
   107
 * @return The path to the image, otherwise nil.
zacw@2743
   108
 */
zacw@2743
   109
- (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType
zacw@2743
   110
{
zacw@2743
   111
	if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) {
zacw@2743
   112
		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"MySpace-small"];
zacw@2743
   113
	} else {
zacw@2743
   114
		return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"MySpace-large"];		
zacw@2743
   115
	}
zacw@2743
   116
}
zacw@2743
   117
David@0
   118
@end