Adium

Changeset 25543

Show
Ignore:
Timestamp:
11/07/2008 11:00:20 AM (2 months ago)
Author:
evands
Message:

Allow the account to prevent sending an autoreply to a message. This moves some OSCAR-specific code to CBPurpleOscarAccount from AIAutoReplyPlugin and fixes IRC sending autoreplies to the connection bots.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/Source/AIAccount.h

    r25374 r25543  
    225225- (NSString *)encodedAttributedStringForSendingContentMessage:(AIContentMessage *)inContentMessage; 
    226226- (BOOL)rejoinChat:(AIChat*)chat; 
     227/*! 
     228 * @brief Should an autoreply be sent to this message? 
     229 * 
     230 * This will only be called if the generic algorithm determines that an autoreply is appropriate. The account 
     231 * gets an opportunity to suppress sending the autoreply, e.g. on the basis of the message's content or source. 
     232 */ 
     233- (BOOL)shouldSendAutoreplyToMessage:(AIContentMessage *)message; 
    227234 
    228235//Presence Tracking 
  • trunk/Frameworks/Adium Framework/Source/AIAccount.m

    r25444 r25543  
    647647{ 
    648648    return [self encodedAttributedString:[inContentMessage message] forListObject:[inContentMessage destination]]; 
     649} 
     650 
     651/*! 
     652 * @brief Should an autoreply be sent to this message? 
     653 * 
     654 * This will only be called if the generic algorithm determines that an autoreply is appropriate. The account 
     655 * gets an opportunity to suppress sending the autoreply, e.g. on the basis of the message's content or source. 
     656 */ 
     657- (BOOL)shouldSendAutoreplyToMessage:(AIContentMessage *)message 
     658{ 
     659        return YES; 
    649660} 
    650661 
  • trunk/Plugins/Purple Service/CBPurpleOscarAccount.m

    r24889 r25543  
    513513        return success; 
    514514} 
     515 
     516- (BOOL)shouldSendAutoreplyToMessage:(AIContentMessage *)message 
     517{ 
     518        return ![[message.message string] hasPrefix:@"[Offline IM sent"]; 
     519} 
     520 
    515521 
    516522#pragma mark DirectIM (IM Image) 
  • trunk/Plugins/Purple Service/ESIRCAccount.m

    r25444 r25543  
    122122} 
    123123 
     124BOOL contactUIDIsServerContact(NSString *contactUID) 
     125{ 
     126        return (([contactUID caseInsensitiveCompare:@"nickserv"] == NSOrderedSame) || 
     127                        ([contactUID caseInsensitiveCompare:@"chanserv"] == NSOrderedSame) || 
     128                        ([contactUID rangeOfString:@"-connect" options:(NSBackwardsSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound)); 
     129} 
     130 
     131/*! 
     132 * @brief Can we send an offline message to this contact? 
     133 * 
     134 * We can only send offline messages to the server contacts, since such a message might cause us to connect 
     135 */ 
    124136- (BOOL)canSendOfflineMessageToContact:(AIListContact *)inContact 
    125137{ 
    126         return ([[inContact.UID lowercaseString] isEqualToString:@"nickserv"] || 
    127                         [[inContact.UID lowercaseString] isEqualToString:@"chanserv"]); 
     138        return contactUIDIsServerContact(inContact.UID); 
     139
     140 
     141- (BOOL)shouldSendAutoreplyToMessage:(AIContentMessage *)message 
     142
     143        return !contactUIDIsServerContact(message.source.UID); 
    128144} 
    129145 
  • trunk/Source/AIAutoReplyPlugin.m

    r25443 r25543  
    112112         * was an offline message we're getting as we connect and it's older than 5 minutes 
    113113         * (or the person sending it is no longer online) -RAF 
    114          * For AIM accounts, we know it is an offline message if it starts with "[Offline IM sent". Of course, a user could send a message like that... 
    115          *      but said user deserves not to receive an auto-reply. 
     114         * We also give the account a chance to suppress the autoreply 
    116115         */ 
    117116        if ([[contentObject type] isEqualToString:CONTENT_MESSAGE_TYPE] && 
     
    120119           !chat.isGroupChat && 
    121120                (abs([contentObject.date timeIntervalSinceNow]) < 300) && 
    122                 !([contentObject.source.serviceClass isEqualToString:@"AIM-compatible"] && [[contentObject.message string] hasPrefix:@"[Offline IM sent"])) { 
     121                [[chat account] shouldSendAutoreplyToMessage:(AIContentMessage *)contentObject]) { 
    123122                //300 is 5 minutes in seconds 
    124123