Adium

Changeset 24058

Show
Ignore:
Timestamp:
06/24/2008 06:57:06 PM (5 months ago)
Author:
evands
Message:

Only attempt to do the Send Message action if the chat can actually receive the message. Fixes #10181

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plugins/Send Message Contact Alert/ESSendMessageContactAlertPlugin.m

    r23380 r24058  
    157157                chat = [[adium chatController] openChatWithContact:contact 
    158158                                                                                onPreferredAccount:NO]; 
    159                 [[adium interfaceController] setActiveChat:chat]; 
    160                  
    161                 message = [NSAttributedString stringWithData:[details objectForKey:KEY_MESSAGE_SEND_MESSAGE]]; 
    162                  
    163                 //Prepare the content object we're sending 
    164                 AIContentMessage        *content = [AIContentMessage messageInChat:chat 
    165                                                                                                                         withSource:account 
    166                                                                                                                    destination:contact 
    167                                                                                                                                   date:nil 
    168                                                                                                                            message:message 
    169                                                                                                                          autoreply:NO]; 
    170  
    171                 //Send the content 
    172                 success = [[adium contentController] sendContentObject:content]; 
    173                 AILogWithSignature(@"%@ %@ to %@ from %@ in %@", (success ? @"Sent" : @"Failed to send"), content, contact, account, chat); 
    174  
    175                 //Display an error message if the message was not delivered 
    176                 if (!success) { 
    177                         [[adium interfaceController] handleMessage:AILocalizedString(@"Contact Alert Error",nil) 
    178                                                                            withDescription:[NSString stringWithFormat:AILocalizedString(@"Unable to send message to %@.",nil), [contact displayName]] 
    179                                                                            withWindowTitle:@""]; 
     159                if (([chat messageSendingAbility] == AIChatCanSendMessageNow) || 
     160                        ([chat messageSendingAbility] == AIChatCanSendViaServersideOfflineMessage)) { 
     161                        [[adium interfaceController] setActiveChat:chat]; 
     162                         
     163                        message = [NSAttributedString stringWithData:[details objectForKey:KEY_MESSAGE_SEND_MESSAGE]]; 
     164                         
     165                        //Prepare the content object we're sending 
     166                        AIContentMessage        *content = [AIContentMessage messageInChat:chat 
     167                                                                                                                         withSource:account 
     168                                                                                                                        destination:contact 
     169                                                                                                                                   date:nil 
     170                                                                                                                                message:message 
     171                                                                                                                          autoreply:NO]; 
     172                         
     173                        //Send the content 
     174                        success = [[adium contentController] sendContentObject:content]; 
     175                        AILogWithSignature(@"%@ %@ to %@ from %@ in %@", (success ? @"Sent" : @"Failed to send"), content, contact, account, chat); 
     176                         
     177                        //Display an error message if the message was not delivered 
     178                        if (!success) { 
     179                                [[adium interfaceController] handleMessage:AILocalizedString(@"Contact Alert Error",nil) 
     180                                                                                   withDescription:[NSString stringWithFormat:AILocalizedString(@"Unable to send message to %@.",nil), [contact displayName]] 
     181                                                                                   withWindowTitle:@""]; 
     182                        } 
    180183                } 
    181184        }