45 |
TEST_RELEASE (fullpath); |
TEST_RELEASE (fullpath); |
46 |
TEST_RELEASE (name); |
TEST_RELEASE (name); |
47 |
TEST_RELEASE (hostname); |
TEST_RELEASE (hostname); |
|
TEST_RELEASE (remoteHostName); |
|
48 |
TEST_RELEASE (type); |
TEST_RELEASE (type); |
49 |
TEST_RELEASE (icon); |
TEST_RELEASE (icon); |
50 |
RELEASE (namelabel); |
RELEASE (namelabel); |
53 |
[super dealloc]; |
[super dealloc]; |
54 |
} |
} |
55 |
|
|
56 |
- (id)initForRemoteHost:(NSString *)rhost |
- (id)init |
57 |
{ |
{ |
58 |
self = [super init]; |
self = [super init]; |
59 |
|
|
66 |
|
|
67 |
gworkspace = (id<GWProtocol>)[gwclass gworkspace]; |
gworkspace = (id<GWProtocol>)[gwclass gworkspace]; |
68 |
|
|
|
if (rhost) { |
|
|
isRemote = YES; |
|
|
ASSIGN (remoteHostName, rhost); |
|
|
} else { |
|
|
isRemote = NO; |
|
|
remoteHostName = nil; |
|
|
} |
|
|
|
|
69 |
fm = [NSFileManager defaultManager]; |
fm = [NSFileManager defaultManager]; |
70 |
|
|
71 |
ASSIGN (highlight, [NSImage imageNamed: @"CellHighlight.tiff"]); |
ASSIGN (highlight, [NSImage imageNamed: @"CellHighlight.tiff"]); |
96 |
onSelf = NO; |
onSelf = NO; |
97 |
isRootIcon = NO; |
isRootIcon = NO; |
98 |
|
|
99 |
if (isRemote == NO) { |
[self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]]; |
|
[self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]]; |
|
|
} else { |
|
|
[self registerForDraggedTypes: [NSArray arrayWithObject: GWRemoteFilenamesPboardType]]; |
|
|
} |
|
100 |
} |
} |
101 |
|
|
102 |
return self; |
return self; |
143 |
isRootIcon = NO; |
isRootIcon = NO; |
144 |
} |
} |
145 |
|
|
146 |
ASSIGN (type, [gworkspace server: remoteHostName typeOfFileAt: fullpath]); |
ASSIGN (type, [gworkspace typeOfFileAt: fullpath]); |
147 |
isPakage = [gworkspace server: remoteHostName isPakageAtPath: fullpath]; |
isPakage = [gworkspace isPakageAtPath: fullpath]; |
148 |
|
|
149 |
} else { |
} else { |
150 |
fullpath = nil; |
fullpath = nil; |
171 |
if (isRootIcon == NO) { |
if (isRootIcon == NO) { |
172 |
[namelabel setStringValue: cutFileLabelText(name, namelabel, labwidth)]; |
[namelabel setStringValue: cutFileLabelText(name, namelabel, labwidth)]; |
173 |
} else { |
} else { |
174 |
if (isRemote == NO) { |
NSHost *host = [NSHost currentHost]; |
175 |
NSHost *host = [NSHost currentHost]; |
NSString *hname = [host name]; |
176 |
NSString *hname = [host name]; |
NSRange range = [hname rangeOfString: @"."]; |
177 |
NSRange range = [hname rangeOfString: @"."]; |
|
178 |
|
if (range.length != 0) { |
179 |
if (range.length != 0) { |
hname = [hname substringToIndex: range.location]; |
180 |
hname = [hname substringToIndex: range.location]; |
} |
181 |
} |
ASSIGN (hostname, hname); |
182 |
ASSIGN (hostname, hname); |
[namelabel setStringValue: hostname]; |
|
[namelabel setStringValue: hostname]; |
|
|
} else { |
|
|
ASSIGN (hostname, remoteHostName); |
|
|
[namelabel setStringValue: remoteHostName]; |
|
|
} |
|
183 |
} |
} |
184 |
|
|
185 |
[self setLocked: NO]; |
[self setLocked: NO]; |
187 |
for (i = 0; i < [paths count]; i++) { |
for (i = 0; i < [paths count]; i++) { |
188 |
NSString *path = [paths objectAtIndex: i]; |
NSString *path = [paths objectAtIndex: i]; |
189 |
|
|
190 |
if ([gworkspace server: remoteHostName isLockedPath: path]) { |
if ([gworkspace isLockedPath: path]) { |
191 |
[self setLocked: YES]; |
[self setLocked: YES]; |
192 |
break; |
break; |
193 |
} |
} |
260 |
|
|
261 |
- (void)openWithApp:(id)sender |
- (void)openWithApp:(id)sender |
262 |
{ |
{ |
263 |
if (isRemote == NO) { |
NSString *appName = [[sender representedObject] objectForKey: @"appName"]; |
264 |
NSString *appName = [[sender representedObject] objectForKey: @"appName"]; |
NSString *fullPath = [[sender representedObject] objectForKey: @"fullPath"]; |
265 |
NSString *fullPath = [[sender representedObject] objectForKey: @"fullPath"]; |
|
266 |
|
[[NSWorkspace sharedWorkspace] openFile: fullPath withApplication: appName]; |
|
[[NSWorkspace sharedWorkspace] openFile: fullPath withApplication: appName]; |
|
|
} |
|
267 |
} |
} |
268 |
|
|
269 |
- (void)openWith:(id)sender |
- (void)openWith:(id)sender |
270 |
{ |
{ |
271 |
if (isRemote == NO) { |
[gworkspace openSelectedPathsWith]; |
|
[gworkspace openSelectedPathsWith]; |
|
|
} |
|
272 |
} |
} |
273 |
|
|
274 |
- (BOOL)isSelect |
- (BOOL)isSelect |
435 |
} else if ([theEvent modifierFlags] == NSControlKeyMask) { |
} else if ([theEvent modifierFlags] == NSControlKeyMask) { |
436 |
return [super menuForEvent: theEvent]; |
return [super menuForEvent: theEvent]; |
437 |
} |
} |
438 |
if ((name == nil) || ([[name pathExtension] length] == 0) || isRemote) { |
if ((name == nil) || ([[name pathExtension] length] == 0)) { |
439 |
return [super menuForEvent: theEvent]; |
return [super menuForEvent: theEvent]; |
440 |
} |
} |
441 |
if (contestualMenu == NO) { |
if (contestualMenu == NO) { |
586 |
|
|
587 |
- (void)declareAndSetShapeOnPasteboard:(NSPasteboard *)pb |
- (void)declareAndSetShapeOnPasteboard:(NSPasteboard *)pb |
588 |
{ |
{ |
589 |
NSArray *dndtypes; |
NSArray *dndtypes = [NSArray arrayWithObject: NSFilenamesPboardType]; |
590 |
NSData *pbData; |
|
591 |
|
[pb declareTypes: dndtypes owner: nil]; |
|
if (isRemote == NO) { |
|
|
dndtypes = [NSArray arrayWithObject: NSFilenamesPboardType]; |
|
|
[pb declareTypes: dndtypes owner: nil]; |
|
592 |
|
|
593 |
if ([pb setPropertyList: paths forType: NSFilenamesPboardType] == NO) { |
if ([pb setPropertyList: paths forType: NSFilenamesPboardType] == NO) { |
594 |
return; |
return; |
|
} |
|
|
} else { |
|
|
NSMutableDictionary *pbDict = [NSMutableDictionary dictionary]; |
|
|
dndtypes = [NSArray arrayWithObject: GWRemoteFilenamesPboardType]; |
|
|
[pb declareTypes: dndtypes owner: nil]; |
|
|
[pbDict setObject: remoteHostName forKey: @"host"]; |
|
|
[pbDict setObject: paths forKey: @"paths"]; |
|
|
pbData = [NSArchiver archivedDataWithRootObject: pbDict]; |
|
|
[pb setData: pbData forType: GWRemoteFilenamesPboardType]; |
|
595 |
} |
} |
596 |
} |
} |
597 |
|
|
619 |
{ |
{ |
620 |
NSPasteboard *pb; |
NSPasteboard *pb; |
621 |
NSDragOperation sourceDragMask; |
NSDragOperation sourceDragMask; |
|
NSData *pbData; |
|
622 |
NSArray *sourcePaths; |
NSArray *sourcePaths; |
623 |
NSString *fromPath; |
NSString *fromPath; |
624 |
NSString *buff; |
NSString *buff; |
635 |
} |
} |
636 |
|
|
637 |
pb = [sender draggingPasteboard]; |
pb = [sender draggingPasteboard]; |
|
|
|
|
if (isRemote == NO) { |
|
|
if ([[pb types] indexOfObject: NSFilenamesPboardType] == NSNotFound) { |
|
|
return NSDragOperationNone; |
|
|
} |
|
|
} else { |
|
|
if ([[pb types] indexOfObject: GWRemoteFilenamesPboardType] == NSNotFound) { |
|
|
return NSDragOperationNone; |
|
|
} |
|
|
} |
|
638 |
|
|
639 |
if (isRemote == NO) { |
if ([[pb types] indexOfObject: NSFilenamesPboardType] == NSNotFound) { |
640 |
sourcePaths = [pb propertyListForType: NSFilenamesPboardType]; |
return NSDragOperationNone; |
|
} else { |
|
|
NSDictionary *dndDict; |
|
|
|
|
|
pbData = [pb dataForType: GWRemoteFilenamesPboardType]; |
|
|
dndDict = [NSUnarchiver unarchiveObjectWithData: pbData]; |
|
|
|
|
|
sourcePaths = [dndDict objectForKey: @"paths"]; |
|
641 |
} |
} |
642 |
|
|
643 |
|
sourcePaths = [pb propertyListForType: NSFilenamesPboardType]; |
644 |
|
|
645 |
count = [sourcePaths count]; |
count = [sourcePaths count]; |
646 |
fromPath = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent]; |
fromPath = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent]; |
649 |
return NSDragOperationNone; |
return NSDragOperationNone; |
650 |
} |
} |
651 |
|
|
652 |
if ([gworkspace server: remoteHostName isWritableFileAtPath: fullpath] == NO) { |
if ([fm isWritableFileAtPath: fullpath] == NO) { |
653 |
return NSDragOperationNone; |
return NSDragOperationNone; |
654 |
} |
} |
655 |
|
|
684 |
|
|
685 |
iconPath = [fullpath stringByAppendingPathComponent: @".opendir.tiff"]; |
iconPath = [fullpath stringByAppendingPathComponent: @".opendir.tiff"]; |
686 |
|
|
687 |
if ((isRemote == NO) && ([fm isReadableFileAtPath: iconPath])) { |
if ([fm isReadableFileAtPath: iconPath]) { |
688 |
NSImage *img = [[NSImage alloc] initWithContentsOfFile: iconPath]; |
NSImage *img = [[NSImage alloc] initWithContentsOfFile: iconPath]; |
689 |
|
|
690 |
if (img) { |
if (img) { |
764 |
{ |
{ |
765 |
NSPasteboard *pb; |
NSPasteboard *pb; |
766 |
NSDragOperation sourceDragMask; |
NSDragOperation sourceDragMask; |
|
NSData *pbData; |
|
767 |
NSArray *sourcePaths; |
NSArray *sourcePaths; |
768 |
NSString *operation, *source; |
NSString *operation, *source; |
769 |
NSMutableArray *files; |
NSMutableArray *files; |
770 |
NSMutableDictionary *opDict; |
NSMutableDictionary *opDict; |
771 |
NSString *trashPath; |
NSString *trashPath; |
|
NSString *sourceHost; |
|
772 |
int i; |
int i; |
773 |
|
|
774 |
CHECK_LOCK; |
CHECK_LOCK; |
785 |
|
|
786 |
sourceDragMask = [sender draggingSourceOperationMask]; |
sourceDragMask = [sender draggingSourceOperationMask]; |
787 |
pb = [sender draggingPasteboard]; |
pb = [sender draggingPasteboard]; |
|
|
|
|
sourceHost = nil; |
|
|
|
|
|
if (isRemote == NO) { |
|
|
sourcePaths = [pb propertyListForType: NSFilenamesPboardType]; |
|
|
} else { |
|
|
NSDictionary *dndDict; |
|
788 |
|
|
789 |
pbData = [pb dataForType: GWRemoteFilenamesPboardType]; |
sourcePaths = [pb propertyListForType: NSFilenamesPboardType]; |
|
dndDict = [NSUnarchiver unarchiveObjectWithData: pbData]; |
|
|
|
|
|
sourcePaths = [dndDict objectForKey: @"paths"]; |
|
|
sourceHost = [dndDict objectForKey: @"host"]; |
|
|
} |
|
790 |
|
|
791 |
source = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent]; |
source = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent]; |
792 |
|
|
793 |
if (isRemote == NO) { |
trashPath = [gworkspace trashPath]; |
|
trashPath = [gworkspace trashPath]; |
|
794 |
|
|
795 |
if ([source isEqual: trashPath]) { |
if ([source isEqual: trashPath]) { |
796 |
operation = GWorkspaceRecycleOutOperation; |
operation = GWorkspaceRecycleOutOperation; |
797 |
} else { |
} else { |
|
if (sourceDragMask == NSDragOperationCopy) { |
|
|
operation = NSWorkspaceCopyOperation; |
|
|
} else if (sourceDragMask == NSDragOperationLink) { |
|
|
operation = NSWorkspaceLinkOperation; |
|
|
} else { |
|
|
operation = NSWorkspaceMoveOperation; |
|
|
} |
|
|
} |
|
|
} else { |
|
798 |
if (sourceDragMask == NSDragOperationCopy) { |
if (sourceDragMask == NSDragOperationCopy) { |
799 |
operation = NSWorkspaceCopyOperation; |
operation = NSWorkspaceCopyOperation; |
800 |
} else if (sourceDragMask == NSDragOperationLink) { |
} else if (sourceDragMask == NSDragOperationLink) { |
815 |
[opDict setObject: fullpath forKey: @"destination"]; |
[opDict setObject: fullpath forKey: @"destination"]; |
816 |
[opDict setObject: files forKey: @"files"]; |
[opDict setObject: files forKey: @"files"]; |
817 |
|
|
818 |
[gworkspace performFileOperationWithDictionary: opDict |
[gworkspace performFileOperationWithDictionary: opDict]; |
|
fromSourceHost: sourceHost |
|
|
toDestinationHost: remoteHostName]; |
|
819 |
} |
} |
820 |
|
|
821 |
@end |
@end |