Adium

Changeset 14670

Show
Ignore:
Timestamp:
12/30/2005 04:38:33 PM (3 years ago)
Author:
kbotc
Message:

Drag and drop sending of text via the contact list.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plugins/Contact List/AIListController.m

    r14554 r14670  
    1515 */ 
    1616 
     17#import "AIChat.h" 
     18#import "AIChatController.h" 
    1719#import "AIContactController.h" 
     20#import "AIContentController.h" 
     21#import "AIContentMessage.h" 
    1822#import "AIInterfaceController.h" 
    1923#import "AIListController.h" 
    2024#import "AIPreferenceController.h" 
    2125#import "ESFileTransfer.h" 
     26#import <AIUtilities/AIAttributedStringAdditions.h> 
    2227#import <AIUtilities/AIAutoScrollView.h> 
    2328#import <AIUtilities/AIWindowAdditions.h> 
     
    493498- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index 
    494499{ 
    495     NSString    *availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]]; 
     500        BOOL            success = YES; 
     501        NSString        *availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]]; 
    496502         
    497503    if ([availableType isEqualToString:@"AIListObject"]) { 
     
    529535                                                                                   AILocalizedString(@"Once combined, Adium will treat these contacts as a single individual both on your contact list and when sending messages.\n\nYou may un-combine these contacts by getting info on the combined contact.","Explanation of metacontact creation")); 
    530536                } 
    531                 //Drag and Drop for the contact list. 
    532537        } else if([[[info draggingPasteboard] types] containsObject:NSFilenamesPboardType]) { 
     538                //Drag and Drop file transfer for the contact list. 
    533539                NSString                *file; 
    534540                NSArray                 *files = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType]; 
     
    536542                 
    537543                while ((file = [enumerator nextObject])) { 
    538                         AIListContact   *targetFileTransferContact = [[adium contactController] preferredContactForContentType:FILE_TRANSFER_TYPE forListContact:item]; 
     544                        AIListContact   *targetFileTransferContact = [[adium contactController] preferredContactForContentType:FILE_TRANSFER_TYPE 
     545                                                                                                                                                                                                        forListContact:item]; 
    539546                        [[adium fileTransferController] sendFile:file toListContact:targetFileTransferContact]; 
    540547                } 
     548        } else if([[[info draggingPasteboard] types] containsObject:NSRTFPboardType]) { 
     549                //Drag and drop text sending via the contact list. 
     550                AIListContact   *contact = [[adium contactController] preferredContactForContentType:CONTENT_MESSAGE_TYPE 
     551                                                                                                                                                          forListContact:item]; 
     552                 
     553                if (contact) { 
     554                        //XXX 
     555                        //This is not the best method for doing this, but I can't figure out why the Message View 
     556                        //won't let me add the text directly into it's text entry even if I expand AIWebKitMessageView. 
     557                         
     558                        //Open the chat and send the dragged text. 
     559                        AIChat                                                  *chat; 
     560                        AIContentMessage                                *messageContent; 
     561                         
     562                        chat = [[adium chatController] openChatWithContact:contact]; 
     563                        messageContent = [AIContentMessage messageInChat:chat 
     564                                                                                                  withSource:[chat account] 
     565                                                                                                 destination:[chat listObject] 
     566                                                                                                                date:nil 
     567                                                                                                         message:[NSAttributedString stringWithData:[[info draggingPasteboard] dataForType:NSRTFPboardType]] 
     568                                                                                                   autoreply:NO]; 
     569                         
     570                        [[adium contentController] sendContentObject:messageContent]; 
     571                } else { 
     572                        success = NO; 
     573                } 
    541574        } 
    542575         
    543576        [super outlineView:outlineView acceptDrop:info item:item childIndex:index]; 
    544577         
    545     return YES
     578    return success
    546579} 
    547580- (void)mergeContactSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo