Changeset 23663
- Timestamp:
- 05/26/2008 09:17:26 AM (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Frameworks/Adium Framework/Source/AIAbstractListController.m
r23647 r23663 40 40 #import <AIUtilities/AIApplicationAdditions.h> 41 41 #import <AIUtilities/AIOutlineViewAdditions.h> 42 #import <AIUtilities/AIPasteboardAdditions.h> 42 43 #import <Adium/KFTypeSelectTableView.h> 43 44 #import "AIMessageWindowController.h" … … 202 203 203 204 //Dragging 204 [contactListView registerForDraggedTypes:[NSArray arrayWithObjects:@"AIListObject", @"AIListObjectUniqueIDs", NSFilenamesPboardType, NSURLPboardType, NSStringPboardType, nil]]; 205 [contactListView registerForDraggedTypes: 206 [NSArray arrayWithObjects:@"AIListObject", @"AIListObjectUniqueIDs", 207 NSFilenamesPboardType, NSURLPboardType, 208 AIiTunesTrackPboardType, NSStringPboardType, nil]]; 205 209 206 210 [contactListView reloadData]; trunk/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m
r23556 r23663 34 34 #import <AIUtilities/AIImageAdditions.h> 35 35 #import <AIUtilities/AIFileManagerAdditions.h> 36 #import <AIUtilities/AIPasteboardAdditions.h> 36 37 37 38 #import <AIUtilities/AITigerCompatibility.h> … … 56 57 57 58 #define FILES_AND_IMAGES_TYPES [NSArray arrayWithObjects: \ 58 NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType, NSPICTPboardType, nil]59 NSFilenamesPboardType, AIiTunesTrackPboardType, NSTIFFPboardType, NSPDFPboardType, NSPICTPboardType, nil] 59 60 60 61 #define PASS_TO_SUPERCLASS_DRAG_TYPE_ARRAY [NSArray arrayWithObjects: \ … … 1164 1165 #pragma mark Drag and drop 1165 1166 1166 /*An NSTextView which has setImportsGraphics:YES as of 10.3 gets the following drag types by default: 1167 "NSColor pasteboard type" 1168 "NSFilenamesPboardType" 1169 "Apple PDF pasteboard type" 1170 "Apple PICT pasteboard type" 1171 "NeXT Encapsulated PostScript v1.2 pasteboard type" 1172 "NeXT TIFF v4.0 pasteboard type" 1173 "CorePasteboardFlavorType 0x6D6F6F76" 1174 "Apple HTML pasteboard type" 1175 "NeXT RTFD pasteboard type" 1176 "NeXT Rich Text Format v1.0 pasteboard type" 1177 "NSStringPboardType" 1178 "NSFilenamesPboardType" 1167 /*An NSTextView which has setImportsGraphics:YES as of 10.5 gets the following drag types by default: 1168 "NeXT RTFD pasteboard type", 1169 "NeXT Rich Text Format v1.0 pasteboard type", 1170 "Apple HTML pasteboard type", 1171 NSFilenamesPboardType, 1172 "CorePasteboardFlavorType 0x6D6F6F76", 1173 "Apple PDF pasteboard type", 1174 "NeXT TIFF v4.0 pasteboard type", 1175 "Apple PICT pasteboard type", 1176 "NeXT Encapsulated PostScript v1.2 pasteboard type", 1177 "Apple PNG pasteboard type", 1178 WebURLsWithTitlesPboardType, 1179 "CorePasteboardFlavorType 0x75726C20", 1180 "Apple URL pasteboard type", 1181 NSStringPboardType, 1182 "NSColor pasteboard type", 1183 "NeXT font pasteboard type", 1184 "NeXT ruler pasteboard type", 1179 1185 */ 1180 /* 1186 1181 1187 - (NSArray *)acceptableDragTypes; 1182 1188 { … … 1184 1190 1185 1191 dragTypes = [NSMutableArray arrayWithArray:[super acceptableDragTypes]]; 1192 [dragTypes addObject:AIiTunesTrackPboardType]; 1193 1186 1194 return dragTypes; 1187 1195 } 1188 */ 1196 1197 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender 1198 { 1199 NSPasteboard *pasteboard = [sender draggingPasteboard]; 1200 1201 if ([pasteboard availableTypeFromArray:FILES_AND_IMAGES_TYPES]) 1202 return NSDragOperationCopy; 1203 else 1204 return [super draggingEntered:sender]; 1205 } 1206 1207 - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender 1208 { 1209 NSPasteboard *pasteboard = [sender draggingPasteboard]; 1210 1211 if ([pasteboard availableTypeFromArray:FILES_AND_IMAGES_TYPES]) 1212 return NSDragOperationCopy; 1213 else 1214 return [super draggingUpdated:sender]; 1215 } 1189 1216 1190 1217 //We don't need to prepare for the types we are handling in performDragOperation: below … … 1222 1249 - (void)addAttachmentsFromPasteboard:(NSPasteboard *)pasteboard 1223 1250 { 1224 if ([pasteboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]) { 1251 NSString *availableType; 1252 if ((availableType = [pasteboard availableTypeFromArray:[NSArray arrayWithObjects:NSFilenamesPboardType, AIiTunesTrackPboardType, nil]])) { 1225 1253 //The pasteboard points to one or more files on disc. Use them directly. 1226 NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType]; 1254 NSArray *files = nil; 1255 if ([availableType isEqualToString:NSFilenamesPboardType]) { 1256 files = [pasteboard propertyListForType:NSFilenamesPboardType]; 1257 1258 } else if ([availableType isEqualToString:AIiTunesTrackPboardType]) { 1259 files = [pasteboard filesFromITunesDragPasteboard]; 1260 } 1261 1227 1262 NSEnumerator *enumerator = [files objectEnumerator]; 1228 1263 NSString *path; trunk/Source/AIListController.m
r23645 r23663 34 34 #import <AIUtilities/AIAttributedStringAdditions.h> 35 35 #import <AIUtilities/AIAutoScrollView.h> 36 #import <AIUtilities/AIPasteboardAdditions.h> 36 37 #import <AIUtilities/AIWindowAdditions.h> 37 38 #import <AIUtilities/AIOutlineViewAdditions.h> … … 617 618 [types containsObject:NSRTFPboardType] || 618 619 [types containsObject:NSURLPboardType] || 619 [types containsObject:NSStringPboardType]) { 620 [types containsObject:NSStringPboardType] || 621 [types containsObject:AIiTunesTrackPboardType]) { 620 622 retVal = ((item && [item isKindOfClass:[AIListContact class]]) ? NSDragOperationLink : NSDragOperationNone); 621 623 … … 631 633 BOOL success = YES; 632 634 NSPasteboard *draggingPasteboard = [info draggingPasteboard]; 633 NSString *availableType = [draggingPasteboard availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]];634 635 if ( [availableType isEqualToString:@"AIListObject"]) {635 NSString *availableType; 636 637 if ((availableType = [draggingPasteboard availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]])) { 636 638 //Kill the selection now, (in a more finder-esque way) 637 639 [outlineView deselectAll:nil]; … … 654 656 655 657 } else if ([item isMemberOfClass:[AIMetaContact class]]) { 656 //Ordering gets implemented here. 657 NSString *availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]]; 658 659 //No longer in a drag, so allow tooltips again 660 if ([availableType isEqualToString:@"AIListObject"]) { 661 662 //If we don't have drag items, we are dragging from another instance; build our own dragItems array 663 //using the supplied internalObjectIDs 664 if (!dragItems) { 665 if ([[[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObjectUniqueIDs"]] isEqualToString:@"AIListObjectUniqueIDs"]) { 666 NSArray *dragItemsUniqueIDs; 667 NSMutableArray *arrayOfDragItems; 668 NSString *uniqueID; 669 NSEnumerator *enumerator; 670 671 dragItemsUniqueIDs = [draggingPasteboard propertyListForType:@"AIListObjectUniqueIDs"]; 672 arrayOfDragItems = [NSMutableArray array]; 673 674 enumerator = [dragItemsUniqueIDs objectEnumerator]; 675 while ((uniqueID = [enumerator nextObject])) { 676 [arrayOfDragItems addObject:[[adium contactController] existingListObjectWithUniqueID:uniqueID]]; 677 } 678 679 //We will release this when the drag is completed 680 dragItems = [arrayOfDragItems retain]; 658 //Ordering gets implemented here. 659 660 //If we don't have drag items, we are dragging from another instance; build our own dragItems array 661 //using the supplied internalObjectIDs 662 if (!dragItems) { 663 NSArray *dragItemsUniqueIDs; 664 NSMutableArray *arrayOfDragItems; 665 NSString *uniqueID; 666 NSEnumerator *enumerator; 667 668 dragItemsUniqueIDs = [draggingPasteboard propertyListForType:@"AIListObjectUniqueIDs"]; 669 arrayOfDragItems = [NSMutableArray array]; 670 671 enumerator = [dragItemsUniqueIDs objectEnumerator]; 672 while ((uniqueID = [enumerator nextObject])) { 673 [arrayOfDragItems addObject:[[adium contactController] existingListObjectWithUniqueID:uniqueID]]; 674 } 675 676 //We will release this when the drag is completed 677 dragItems = [arrayOfDragItems retain]; 678 } 679 680 //The tree root is not associated with our root contact list group, so we need to make that association here 681 if (item == nil) item = contactList; 682 683 //Move the list object to its new location 684 if ([item isKindOfClass:[AIMetaContact class]]) { 685 686 NSMutableArray *realDragItems = [NSMutableArray array]; 687 NSEnumerator *enumerator; 688 AIListObject *aDragItem; 689 690 enumerator = [dragItems objectEnumerator]; 691 while ((aDragItem = [enumerator nextObject])) { 692 if ([aDragItem isMemberOfClass:[AIListContact class]]) { 693 //For listContacts, add all contacts with the same service and UID (on all accounts) 694 [realDragItems addObjectsFromArray:[[[adium contactController] allContactsWithService:[aDragItem service] 695 UID:[aDragItem UID] 696 existingOnly:YES] allObjects]]; 697 } else { 698 [realDragItems addObject:aDragItem]; 681 699 } 682 700 } 683 701 684 //The tree root is not associated with our root contact list group, so we need to make that association here 685 if (item == nil) item = contactList; 686 687 //Move the list object to its new location 688 if ([item isKindOfClass:[AIMetaContact class]]) { 689 690 NSMutableArray *realDragItems = [NSMutableArray array]; 691 NSEnumerator *enumerator; 692 AIListObject *aDragItem; 693 694 enumerator = [dragItems objectEnumerator]; 695 while ((aDragItem = [enumerator nextObject])) { 696 if ([aDragItem isMemberOfClass:[AIListContact class]]) { 697 //For listContacts, add all contacts with the same service and UID (on all accounts) 698 [realDragItems addObjectsFromArray:[[[adium contactController] allContactsWithService:[aDragItem service] 699 UID:[aDragItem UID] 700 existingOnly:YES] allObjects]]; 701 } else { 702 [realDragItems addObject:aDragItem]; 703 } 704 } 705 706 [[adium contactController] moveListObjects:realDragItems intoObject:item index:index]; 707 [outlineView reloadData]; 708 } 709 } 710 702 [[adium contactController] moveListObjects:realDragItems intoObject:item index:index]; 703 [outlineView reloadData]; 704 } 705 711 706 //Call super and return its value 712 return [super outlineView:outlineView acceptDrop:info item:item childIndex:index]; 713 707 return [super outlineView:outlineView acceptDrop:info item:item childIndex:index]; 714 708 715 709 } else if ([item isKindOfClass:[AIListContact class]]) { … … 739 733 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")); 740 734 } 741 } else if ([[[info draggingPasteboard] types] containsObject:NSFilenamesPboardType]) { 735 736 737 } else if ((availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObjects: 738 NSFilenamesPboardType, AIiTunesTrackPboardType, nil]])) { 742 739 //Drag and Drop file transfer for the contact list. 743 NSString *file;744 NSArray *files = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];745 NSEnumerator *enumerator = [files objectEnumerator];746 747 740 AIListContact *targetFileTransferContact = [[adium contactController] preferredContactForContentType:CONTENT_FILE_TRANSFER_TYPE 748 741 forListContact:item]; 749 742 if (targetFileTransferContact) { 743 NSArray *files = nil; 744 NSString *file; 745 NSEnumerator *enumerator; 746 747 if ([availableType isEqualToString:NSFilenamesPboardType]) { 748 files = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType]; 749 750 } else if ([availableType isEqualToString:AIiTunesTrackPboardType]) { 751 files = [[info draggingPasteboard] filesFromITunesDragPasteboard]; 752 } 753 754 enumerator = [files objectEnumerator]; 750 755 while ((file = [enumerator nextObject])) { 751 756 [[adium fileTransferController] sendFile:file toListContact:targetFileTransferContact]; 752 757 } 758 753 759 } else { 754 760 AILogWithSignature(@"No contact available to receive files"); … … 756 762 } 757 763 758 } else if ([[[info draggingPasteboard] types] containsObject:NSRTFPboardType] || 759 [[[info draggingPasteboard] types] containsObject:NSURLPboardType] || 760 [[[info draggingPasteboard] types] containsObject:NSStringPboardType]) { 764 } else if ((availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObjects:NSRTFPboardType, 765 NSURLPboardType, NSStringPboardType, nil]])) { 761 766 //Drag and drop text sending via the contact list. 762 767 if ([item isKindOfClass:[AIListContact class]]) { … … 766 771 NSAttributedString *messageAttributedString = nil; 767 772 768 if ([[[info draggingPasteboard] types] containsObject:NSRTFPboardType]) {773 if ([availableType isEqualToString:NSRTFPboardType]) { 769 774 //for RTF data, we want to preserve the formatting, so use dataForType: 770 775 messageAttributedString = [NSAttributedString stringWithData:[[info draggingPasteboard] dataForType:NSRTFPboardType]]; 771 776 } 772 else if ([[[info draggingPasteboard] types] containsObject:NSURLPboardType]) {777 else if ([availableType isEqualToString:NSURLPboardType]) { 773 778 //NSURLPboardType contains an NSURL object 774 messageAttributedString = [NSAttributedString stringWithString:[[NSURL URLFromPasteboard:[info draggingPasteboard]] absoluteString]];775 } 776 else if ([[[info draggingPasteboard] types] containsObject:NSStringPboardType]) {779 messageAttributedString = [NSAttributedString stringWithString:[[NSURL URLFromPasteboard:[info draggingPasteboard]] absoluteString]]; 780 } 781 else if ([availableType isEqualToString:NSStringPboardType]) { 777 782 //this is just plain text, so stringForType: works fine 778 messageAttributedString = [NSAttributedString stringWithString:[[info draggingPasteboard] stringForType:NSStringPboardType]];783 messageAttributedString = [NSAttributedString stringWithString:[[info draggingPasteboard] stringForType:NSStringPboardType]]; 779 784 } 780 785