William Bowling is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this againadium / Plugins / Purple Service / ESPurpleAIMAccount.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | //
// ESPurpleAIMAccount.m
// Adium
//
// Created by Evan Schoenberg on 2/23/05.
// Copyright 2006 The Adium Team. All rights reserved.
//
#import "ESPurpleAIMAccount.h"
#import <AdiumLibpurple/SLPurpleCocoaAdapter.h>
#import <Adium/AIContactControllerProtocol.h>
#import <Adium/AIChat.h>
#import <Adium/AIHTMLDecoder.h>
#import <Adium/AIListContact.h>
#import <Adium/AIService.h>
#import <Adium/AIContentMessage.h>
#import <AIUtilities/AIAttributedStringAdditions.h>
#import <AIUtilities/AIStringAdditions.h>
#import <AIUtilities/AIObjectAdditions.h>
#define MAX_AVAILABLE_MESSAGE_LENGTH 249
@interface ESPurpleAIMAccount ()
- (void)setFormattedUID;
@end
@implementation ESPurpleAIMAccount
#pragma mark Initialization and setup
- (const char *)protocolPlugin
{
return "prpl-aim";
}
- (void)initAccount
{
[super initAccount];
arrayOfContactsForDelayedUpdates = nil;
delayedSignonUpdateTimer = nil;
[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_NOTES];
}
- (void)dealloc
{
[adium.preferenceController unregisterPreferenceObserver:self];
[super dealloc];
}
#pragma mark Connectivity
/*!
* @brief We are connected.
*/
- (oneway void)accountConnectionConnected
{
[super accountConnectionConnected];
[self setFormattedUID];
}
/*!
* @brief Set the spacing and capitilization of our formatted UID serverside
*/
- (void)setFormattedUID
{
NSString *formattedUID;
//Set our capitilization properly if necessary
formattedUID = self.formattedUID;
if (![formattedUID isCaseInsensitivelyEqualToString:formattedUID]) {
//Remove trailing and leading whitespace
formattedUID = [formattedUID stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[[self purpleAdapter] performSelector:@selector(OSCARSetFormatTo:onAccount:)
withObject:formattedUID
withObject:self
afterDelay:5.0];
}
}
#pragma mark Account Action Menu Items
- (NSString *)titleForAccountActionMenuLabel:(const char *)label
{
/* Remove various actions which are either duplicates of superior Adium actions (*grin*)
* or are just silly ("Confirm Account" for example). */
if (strcmp(label, _("Set Available Message...")) == 0) {
return nil;
} else if (strcmp(label, _("Format Screen Name...")) == 0) {
return nil;
} else if (strcmp(label, _("Confirm Account")) == 0) {
return nil;
}
return [super titleForAccountActionMenuLabel:label];
}
#pragma mark Contact updates
- (oneway void)updateContact:(AIListContact *)theContact forEvent:(NSNumber *)event
{
SEL updateSelector = nil;
switch ([event integerValue]) {
case PURPLE_BUDDY_INFO_UPDATED: {
updateSelector = @selector(updateInfo:);
break;
}
case PURPLE_BUDDY_DIRECTIM_CONNECTED: {
updateSelector = @selector(directIMConnected:);
break;
}
case PURPLE_BUDDY_DIRECTIM_DISCONNECTED:{
updateSelector = @selector(directIMDisconnected:);
break;
}
}
if (updateSelector) {
[self performSelector:updateSelector
withObject:theContact];
}
[super updateContact:theContact forEvent:event];
}
#pragma mark Suported keys
- (NSSet *)supportedPropertyKeys
{
static NSMutableSet *supportedPropertyKeys = nil;
if (!supportedPropertyKeys) {
supportedPropertyKeys = [[NSMutableSet alloc] initWithObjects:
@"AvailableMessage",
@"Invisible",
nil];
[supportedPropertyKeys unionSet:[super supportedPropertyKeys]];
}
return supportedPropertyKeys;
}
#pragma mark Typing notifications
/*!
* @brief Suppress typing notifications after send?
*
* AIM assumes that "typing stopped" is not explicitly stopped when the user sends. This is particularly visible
* in iChat. Returning YES here prevents messages sent to iChat from jumping up and down in ichat as the typing
* notification is removed and then the incoming text is added.
*/
- (BOOL)suppressTypingNotificationChangesAfterSend
{
return YES;
}
#pragma mark Group chat
- (void)addUser:(NSString *)contactName toChat:(AIChat *)chat newArrival:(NSNumber *)newArrival
{
AIListContact *listContact;
if ((chat) &&
(listContact = [self contactWithUID:contactName])) {
if (!namesAreCaseSensitive) {
[listContact setValue:contactName forProperty:@"FormattedUID" notify:NotifyNow];
}
/* Purple incorrectly flags group chat participants as being on a mobile device... we're just going
* to assume that a contact in a group chat is by definition not on their cell phone. This assumption
* could become wrong in the future... we can deal with it more properly at that time. :P -eds
*/
if (listContact.isMobile) {
[listContact setIsMobile:NO notify:NotifyLater];
[listContact setValue:nil
forProperty:@"Client"
notify:NotifyLater];
[listContact notifyOfChangedPropertiesSilently:NO];
}
[chat addParticipatingListObject:listContact notify:(newArrival && [newArrival boolValue])];
}
}
@end
|