Dragging Folders and opening Finder Folders

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
simon.ustwo
Harmless
Posts: 5
Joined: Tue Jul 22, 2008 10:43 am

Dragging Folders and opening Finder Folders

Post by simon.ustwo »

Hi all,

I've want to extend Adium (why else would I be here :P) through the use of a plugin that will essentially allow the user to pass a folder (either alias or real folder) to the chat window and then convert that folder to the path as a string (or some other path indication). When the user receives the link they can click on it and it will open a finder window with the correct location set.

I've started coding this up using the latest source of adium, currently I've got it to flag when it see "file://", but I want to automate this more :P

So my questions:
  • How do I tell if a item put in to the chat window is a Folder (I can currently tell if it's a message by using "AIContentMessage") which seems to work well
  • How do I then cancel the folder load and then just send the path to the folder (I can work out the folder path :P), but it's bailing out of the folder being sent and replacing that with a message
  • How do I trigger the launching of a applescript action when the user clicks on the link, or can I do it another way - is there a Notification sent when a user clicks on a link and can I think bail the default action so that I can then call an applescript action (This seems very possible to me, but I'm unsure how to implement)
Thank-you for your attention,
si
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Re: Dragging Folders and opening Finder Folders

Post by evands »

You could probably use the content filter system (see AIContentControllerProtocol) to handle dropped folders before the content controller gets a chance to do a file transfer out of them. you could use some delimiter string ("$$OpenFolder$$" surrounding the path) and then look for the same delimiter on the other side to decode it back to a link...

...though the link still wouldn't work, because Adium actually disables clicking on file:// links, in AIWebKitMessageViewController, to prevent potential abuse. I'm not sure what you could do about that.

What's the ultimate purpose of your plugin?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
simon.ustwo
Harmless
Posts: 5
Joined: Tue Jul 22, 2008 10:43 am

Re: Dragging Folders and opening Finder Folders

Post by simon.ustwo »

We spend a lot of our time in and out of projects and finding the correct assets (images, documents and etc) in folders is a long and laborious job (This is what being organized brings you!). We currently end up sending a path to a person in the company on adium (normally Bonjour or .mac) where the correct asset is and then they have to go find it. It would be a lot more efficient to actually just click on a link and just open the finder window.

I've currently got it to filter the content so when you do send file:// it will flag it, the problem like you say is how to trigger it on the other side. I have gone the approach of working out how to trigger a mouse click, but this might not be possible. I also looked in to applescript automatically creating a new window and finding that path. Except that I'm having a hard time trying to find the resource folder of the plugin bundle. I'm assuming that I will have to use a different reference than NSBundle.

any ideas?

Thanks for your help :P
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Re: Dragging Folders and opening Finder Folders

Post by evands »

Oh, if it's purely for internal use, the solution is pretty straightforward if you're willing to assume a level of trust between people conversing using the plugin and you're okay opening the folder as soon as the message is received instead of when it is clicked.

For outgoing content: Use a delimiter to change the folder-reference into plain text, like
$$OpenFolder$$/Volumes/SharedStuff/docs/foobar.txt$$OpenFolder$$

For incoming content: Check for the delimiter you're using. Extract the path. Use NSWorkspace's selectFile:inFileViewerRootedAtPath: method to reveal the path in the Finder. For bonus points, remove the delimiter so that the receiving side doesn't have to see its ugliness.

Make sense?
The duck still burns.
--
My company: Saltatory Software. Check it out :)
simon.ustwo
Harmless
Posts: 5
Joined: Tue Jul 22, 2008 10:43 am

Re: Dragging Folders and opening Finder Folders

Post by simon.ustwo »

Yeap, I'll just have a quick try now and I'll let you know how it goes :P
simon.ustwo
Harmless
Posts: 5
Joined: Tue Jul 22, 2008 10:43 am

Re: Dragging Folders and opening Finder Folders

Post by simon.ustwo »

Excellent,

** I've fixed this :P **

I've got the NSWorkspace work a treat :) - I'm wondering about the link though, how do I format as a link (i.e. afp:// and http:// seem to format them selves ) so the user can click on it after they close the window down?
I'm currently using NSAttributedString to format the string (is that needed?) so am I on the right path?

** I've fixed this :P **

This is great by the way, keep it coming!
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Re: Dragging Folders and opening Finder Folders

Post by evands »

So after the "i've fixed this" edit, does a question remain? :)
The duck still burns.
--
My company: Saltatory Software. Check it out :)
simon.ustwo
Harmless
Posts: 5
Joined: Tue Jul 22, 2008 10:43 am

Re: Dragging Folders and opening Finder Folders

Post by simon.ustwo »

I don't think so, we're currently employing a shortcut command to paste the front most finder window into adium. I think I'm sorted.

Thank-you again :P
Post Reply