Merge lp://qastaging/~stephen-elson/do-plugins/Dropbox into lp://qastaging/do-plugins
- Dropbox
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp://qastaging/~stephen-elson/do-plugins/Dropbox |
Merge into: | lp://qastaging/do-plugins |
Diff against target: | None lines |
To merge this branch: | bzr merge lp://qastaging/~stephen-elson/do-plugins/Dropbox |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Peng Deng (community) | Needs Fixing | ||
Review via email: mp+6440@code.qastaging.launchpad.net |
Commit message
Description of the change
Stephen Elson (stephen-elson) wrote : | # |
Alex Launi (alexlauni) wrote : | # |
You forgot to add the DropboxAbstract
- 613. By Stephen Elson
-
Added missing file.
Stephen Elson (stephen-elson) wrote : | # |
Hi Alex, sorry for the delay, I have been on holiday.
I've added the missing file, sorry about that.
- 614. By Stephen Elson
-
Updated.
- 615. By Stephen Elson
-
Merged from trunk
Peng Deng (d6g) wrote : | # |
I suggest to get a better quality dropbox icon, since the system default one seems only 16x16.
Here is one I found under cc license and looks great: http://
Peng Deng (d6g) wrote : | # |
I got an error while using the Get Public URL action:
Dropbox.
Plus, it seems when using "Add to Dropbox" action, the modifier item cannot be expanded to show sub-items.
Stephen Elson (stephen-elson) wrote : | # |
Can you confirm what version of nautilus-dropbox and the dropboxd you have? You can see the dropboxd version number in the Dropbox preferences dialog, and the nautilus plugin via apt. I am running nautilus-dropbox 0.6.1 and dropboxd 0.6.510.
My version seems to have a 64x64 icon, which looks quite nice and I don't think needs replacing. The icons you linked to are quite nice, but are slightly different from the actual Dropbox brand, which might confuse users?
The Get Public URl error suggests you don't have the dropbox CLI script, I will add a check for this script and only offer actions that depend on it if it's present. This is also indicates you have an old version of dropbox, as the CLI was only made available in their last release.
I will investigate the issue with modifier items not being expandable.
- 616. By Stephen Elson
-
Added check for dropbox CLI.
Start, Stop and Get Public URL actions will now only be offered if the CLI is avavailable (useful for older versions of dropbox).
Stephen Elson (stephen-elson) wrote : | # |
OK, I have push an update which should fix the Get Public URL action, the plugin now only offers that action (and Start/Stop) if the dropbox CLI is present.
Still looking at the unexpandable modifier items, a bit stumped at the moment. Any suggestions here would be appreciated.
Thanks,
Steve
Peng Deng (d6g) wrote : | # |
Now that I updated to the latest version of Dropbox, the issues I mentioned above are all gone.
Peng Deng (d6g) wrote : | # |
I encountered another issue: after I share a file with non-ascii file name (Chinese) using the "Share with Dropbox" action, all actions will return an error message like:
[Action's Name] encountered an error in SupportsItem: Argument is out of range..
It seems the exception happened just around the line
if (link.HasContents && link.ContentsPath == target) {
inside DropboxAbstract
It might be an Mono issue.
- 617. By Stephen Elson
-
Fixed bug in handling symlinks with non-ascii characters in filename.
Stephen Elson (stephen-elson) wrote : | # |
Fixed that issue, seems like Mono.Unix.
I am simply calling readlink instead now, which has reduced the dependencies for the plugin as well.
Still not sure why the modifier items are not expandable in Add to Dropbox, I think it could be an issue with the Files and Folders plugin? Maybe?
Chris S. (cszikszoy) wrote : | # |
Hey Stephen,
I've just downloaded Dropbox and setup an account. Before I test the actual plugin, here are a few preliminary comments:
* Don't 'return null;' from an IEnumerable<T> Function (Like Perform ()). Use 'yield break;' instead.
* Use Path.Combine (from System.IO) to build directory paths. Don't do things like: 'home + "/Dropbox";'
* For IEnumerable<Type> SupportedItemTypes you don't need to create and return an array, simply use: 'yield return typeof (T);' for any types you need to return.
* For share & unshare actions, it would be nice to handle multiple items, instead of just using 'items.First ()'
This shouldn't be too hard, basically enclose everything in your perform action in a foreach (Item item in Items) { }
* This line from your Exec method on Dropbox.cs: "Log.Error ("Error running dropbox {0}: {2}", args, e.Message)", The 2 should be changed to a 1, I think.
* Also, for logging operations, use Log<Dropbox>.*, instead of Log.*
I'll branch the plugin and test out the actual actions too.
Stephen Elson (stephen-elson) wrote : | # |
Thanks Chris,
I am just starting with C# (you could probably tell), so thanks very much for the tips :)
I will make those changes when I have time in the next few days.
Steve
- 618. By Stephen Elson
-
Some general changes suggested by Chris S.
- 619. By Stephen Elson
-
Make Dropbox class non-static.
Stephen Elson (stephen-elson) wrote : | # |
Hi again,
actually, that didn't take long, I've just pushed a new version that should include all the changes you recommended. I look forward to hearing how your testing goes.
Steve
Chris S. (cszikszoy) wrote : | # |
A couple more things I just thought of:
* Why did you make the dropbox class non static?
* You have hard-coded the paths to various folders, such as the dropbox folder, the do-shared folder. While installing Dropbox I noticed that you could change those paths, maybe it would be good to allow some sort of small configuration page to allow the user to select their dropbox folder, in case they have a setup that differs from the default.
Stephen Elson (stephen-elson) wrote : | # |
Ah yes, the Dropbox class. That was slightly random I admit, I tried Log<Dropbox>.* but it complained about using a static class, so I just flipped it to non-static. I realised as I was doing it that is was a bit weird, but if you have a better suggestion for getting round the Log problem i'll happily revert it.
Folder locations - yep, I flagged this as a limitation over in the Google Group, and agree that a configuration page would be good. That might take a bit longer for me to do, I've never touched GTK before, but I'll make a start as soon as I can.
Chris S. (cszikszoy) wrote : | # |
I'm pretty proficient with GTK# and could probably make a simple
config widget that would allow the user to set their dropbox folders
if you don't mind? If you'd like to learn GTK then by all means, feel
free, but I'm willing to help as well. It should be pretty simple,
I'm thinking just 1 or two text boxes that hold the folder path, maybe
a button to open the "choose folder" dialog box to make selecting a
path easy as well.
I think it's better to leave the Dropbox class static, there's no need
to create a new instance of it in each of your actions. I'll look
into the logging stuff w/ static classes. I know it's done with
Pidgin. Pidgin has a static class, but the Log<T> class is used
extensively in that plugin as well.
On Mon, Jun 1, 2009 at 1:24 AM, Stephen Elson<email address hidden> wrote:
> Ah yes, the Dropbox class. That was slightly random I admit, I tried Log<Dropbox>.* but it complained about using a static class, so I just flipped it to non-static. I realised as I was doing it that is was a bit weird, but if you have a better suggestion for getting round the Log problem i'll happily revert it.
>
> Folder locations - yep, I flagged this as a limitation over in the Google Group, and agree that a configuration page would be good. That might take a bit longer for me to do, I've never touched GTK before, but I'll make a start as soon as I can.
> --
> https:/
> You are subscribed to branch lp:do-plugins.
>
Stephen Elson (stephen-elson) wrote : | # |
I'd like to have a go, but would appreciate any advice you have. For
example, is there a similar config in the plugins repo that you'd suggest
I'd look at, and do you recommend a visual layout tool for building the
dialog? Basically, any tips on how to go about building it would be great.
If I get stuck or it's just taking too long, i'll take up your offer, I
appreciate you taking the interest :)
I'll revert the dropbox class and look at the Pidgin class for an idea of
how to do it better. In my defence i'd say that I did it quite late at night
after a very long and exhausting day!
Steve
Chris S. (cszikszoy) wrote : | # |
The best way to add the configuration widget is to go into
monodevelop, and create a new file, select GTK as the type, then new
Widget. Look at some other plugins, (translate, pastebin) to see how
they added that widget. You'll need to have one of your actions or
itemsources implement the IConfigurable interface (part of
Do.Platform.Linux). From there, just design away with monodevelop's
gui builder. This will create a gtk-gui directory in your source dir,
make sure to include all of these files in Makefile.am. (The
gui.stetic file should be listed under the "RESOURCES" section, not
under the "FILES" section.)
I'm usually available in #gnome-do on freenode (nick: cszikszoy) if
you need help with anything.
On Mon, Jun 1, 2009 at 3:06 AM, Stephen Elson<email address hidden> wrote:
> I'd like to have a go, but would appreciate any advice you have. For
> example, is there a similar config in the plugins repo that you'd suggest
> I'd look at, and do you recommend a visual layout tool for building the
> dialog? Basically, any tips on how to go about building it would be great.
>
> If I get stuck or it's just taking too long, i'll take up your offer, I
> appreciate you taking the interest :)
>
> I'll revert the dropbox class and look at the Pidgin class for an idea of
> how to do it better. In my defence i'd say that I did it quite late at night
> after a very long and exhausting day!
>
> Steve
>
> --
> https:/
> You are subscribed to branch lp:do-plugins.
>
Stephen Elson (stephen-elson) wrote : | # |
Hi,
I have added a configuration page that allows you to set the location of your Dropbox folder, with a default of ~/Dropbox. The "Do Shared Items" folder is another preference we could offer, but it *has* to be within the Dropbox/Public folder and I can't see a big advantage to offering it as configurable.
I have also tweaked the Dropbox class so it can be used in Log<Dropbox>. I used the Emesene plugin as a guide on how to do this.
Feedback welcome, especially on any noob mistakes in the GTK# code :)
- 620. By Stephen Elson
-
Revert making Dropbox class static
- 621. By Stephen Elson
-
Basic configuration code.
- 622. By Stephen Elson
-
Started configuration dialog layout
- 623. By Stephen Elson
-
Working config for Dropbox folder location.
- 624. By Stephen Elson
-
Added licence text
- 625. By Stephen Elson
-
Make Dropbox class non-static but with only static methods/properties - enabling use as Log<Dropbox>.*
Chris S. (cszikszoy) wrote : | # |
This looks great. I installed the plugin today and tested it out and
everything seems to work very well. The GTK code is great. I don't
think we need anything more complicated than that.
One other thing I seemed to have missed is that all public strings
should use Catalog.GetString ("some string"). This creates the
translation contexts so we can translate the public strings into other
languages. Other than that, the plugin is great. Fix this and I'll
merge.
On Tue, Jun 2, 2009 at 1:54 PM, Stephen Elson<email address hidden> wrote:
> Hi,
>
> I have added a configuration page that allows you to set the location of your Dropbox folder, with a default of ~/Dropbox. The "Do Shared Items" folder is another preference we could offer, but it *has* to be within the Dropbox/Public folder and I can't see a big advantage to offering it as configurable.
>
> I have also tweaked the Dropbox class so it can be used in Log<Dropbox>. I used the Emesene plugin as a guide on how to do this.
>
> Feedback welcome, especially on any noob mistakes in the GTK# code :)
> --
> https:/
> You are subscribed to branch lp:do-plugins.
>
- 626. By Stephen Elson
-
Made public strings translatable
Stephen Elson (stephen-elson) wrote : | # |
OK, I've committed those changes.
Thanks to you and Peng for all your help getting this plugin ready for merging :)
Steve
- 627. By Stephen Elson
-
Merge from main branch
- 628. By Stephen Elson
-
Add to Dropbox & Public URL actions accept multiple items
- 629. By Stephen Elson
-
Allow expansion of modifier items.
Chris S. (cszikszoy) wrote : | # |
Hey Stephen,
DBO has fixed core to allow different filters for Items and Modifier Items. Can you change the code for the Link Action back to what it was before?
Here's a slightly modified copy I had to test with: http://
- 630. By Stephen Elson
-
Revert expanding modifier items hack, now that Do has been updated.
Stephen Elson (stephen-elson) wrote : | # |
Done :-)
Preview Diff
1 | === added directory 'Dropbox' |
2 | === added file 'Dropbox/Dropbox.mdp' |
3 | --- Dropbox/Dropbox.mdp 1970-01-01 00:00:00 +0000 |
4 | +++ Dropbox/Dropbox.mdp 2009-05-10 17:11:46 +0000 |
5 | @@ -0,0 +1,31 @@ |
6 | +<Project name="Dropbox" fileversion="2.0" language="C#" targetFramework="2.0" ctype="DotNetProject"> |
7 | + <Configurations active="Debug"> |
8 | + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> |
9 | + <Output directory="bin/Debug" assembly="Dropbox" /> |
10 | + <Build debugmode="True" target="Exe" /> |
11 | + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" /> |
12 | + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> |
13 | + </Configuration> |
14 | + <Configuration name="Release" ctype="DotNetProjectConfiguration"> |
15 | + <Output directory="bin/Release" assembly="Dropbox" /> |
16 | + <Build debugmode="False" target="Exe" /> |
17 | + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" /> |
18 | + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> |
19 | + </Configuration> |
20 | + </Configurations> |
21 | + <Contents> |
22 | + <File name="src" subtype="Directory" buildaction="Compile" /> |
23 | + <File name="Resources" subtype="Directory" buildaction="Compile" /> |
24 | + <File name="src/DropboxStartAction.cs" subtype="Code" buildaction="Compile" /> |
25 | + <File name="src/DropboxStopAction.cs" subtype="Code" buildaction="Compile" /> |
26 | + <File name="Resources/Dropbox.addin.xml" subtype="Code" buildaction="Nothing" /> |
27 | + <File name="src/DropboxPuburlAction.cs" subtype="Code" buildaction="Compile" /> |
28 | + <File name="src/Dropbox.cs" subtype="Code" buildaction="Compile" /> |
29 | + <File name="src/DropboxWebInterfaceAction.cs" subtype="Code" buildaction="Compile" /> |
30 | + <File name="src/DropboxRevisionsAction.cs" subtype="Code" buildaction="Compile" /> |
31 | + <File name="src/DropboxShareAction.cs" subtype="Code" buildaction="Compile" /> |
32 | + <File name="src/DropboxUnshareAction.cs" subtype="Code" buildaction="Compile" /> |
33 | + <File name="src/DropboxLinkAction.cs" subtype="Code" buildaction="Compile" /> |
34 | + <File name="src/DropboxAbstractAction.cs" subtype="Code" buildaction="Compile" /> |
35 | + </Contents> |
36 | +</Project> |
37 | \ No newline at end of file |
38 | |
39 | === added file 'Dropbox/Makefile.am' |
40 | --- Dropbox/Makefile.am 1970-01-01 00:00:00 +0000 |
41 | +++ Dropbox/Makefile.am 2009-05-10 17:11:46 +0000 |
42 | @@ -0,0 +1,25 @@ |
43 | +include $(top_srcdir)/build.rules.mk |
44 | + |
45 | +ASSEMBLY=Dropbox |
46 | + |
47 | +FILES = \ |
48 | + src/DropboxWebInterfaceAction.cs \ |
49 | + src/DropboxAbstractAction.cs \ |
50 | + src/DropboxRevisionsAction.cs \ |
51 | + src/DropboxPuburlAction.cs \ |
52 | + src/DropboxUnshareAction.cs \ |
53 | + src/DropboxShareAction.cs \ |
54 | + src/DropboxStartAction.cs \ |
55 | + src/DropboxStopAction.cs \ |
56 | + src/DropboxLinkAction.cs \ |
57 | + src/Dropbox.cs |
58 | + |
59 | +RESOURCES = \ |
60 | + Resources/Dropbox.addin.xml |
61 | + |
62 | +REFERENCES = \ |
63 | + System \ |
64 | + System.Core \ |
65 | + Mono.Posix \ |
66 | + $(DO_PLATFORM_LIBS) \ |
67 | + $(DO_UNIVERSE_LIBS) |
68 | |
69 | === added directory 'Dropbox/Resources' |
70 | === added file 'Dropbox/Resources/Dropbox.addin.xml' |
71 | --- Dropbox/Resources/Dropbox.addin.xml 1970-01-01 00:00:00 +0000 |
72 | +++ Dropbox/Resources/Dropbox.addin.xml 2009-05-10 17:04:26 +0000 |
73 | @@ -0,0 +1,31 @@ |
74 | +<Addin |
75 | + id="Dropbox" |
76 | + namespace="Do" |
77 | + version="1.0" |
78 | + name="Dropbox" |
79 | + description="Share and manage files in Dropbox." |
80 | + author="Stephen Elson" |
81 | + category="Community" |
82 | + defaultEnabled="false" |
83 | + > |
84 | + |
85 | + <Runtime> |
86 | + <Import assembly="Dropbox.dll"/> |
87 | + </Runtime> |
88 | + |
89 | + <Dependencies> |
90 | + <Addin id="Universe" version="1.0" /> |
91 | + </Dependencies> |
92 | + |
93 | + <Extension path="/Do/Action"> |
94 | + <Action type="Dropbox.DropboxLinkAction" /> |
95 | + <Action type="Dropbox.DropboxStopAction" /> |
96 | + <Action type="Dropbox.DropboxStartAction" /> |
97 | + <Action type="Dropbox.DropboxShareAction" /> |
98 | + <Action type="Dropbox.DropboxUnshareAction" /> |
99 | + <Action type="Dropbox.DropboxPuburlAction" /> |
100 | + <Action type="Dropbox.DropboxRevisionsAction" /> |
101 | + <Action type="Dropbox.DropboxWebInterfaceAction" /> |
102 | + </Extension> |
103 | + |
104 | +</Addin> |
105 | |
106 | === added directory 'Dropbox/src' |
107 | === added file 'Dropbox/src/Dropbox.cs' |
108 | --- Dropbox/src/Dropbox.cs 1970-01-01 00:00:00 +0000 |
109 | +++ Dropbox/src/Dropbox.cs 2009-05-10 21:38:30 +0000 |
110 | @@ -0,0 +1,116 @@ |
111 | +// |
112 | +// Dropbox.cs |
113 | +// |
114 | +// GNOME Do is the legal property of its developers. Please refer to the |
115 | +// COPYRIGHT file distributed with this |
116 | +// source distribution. |
117 | +// |
118 | +// This program is free software: you can redistribute it and/or modify |
119 | +// it under the terms of the GNU General Public License as published by |
120 | +// the Free Software Foundation, either version 3 of the License, or |
121 | +// (at your option) any later version. |
122 | +// |
123 | +// This program is distributed in the hope that it will be useful, |
124 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
125 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
126 | +// GNU General Public License for more details. |
127 | +// |
128 | +// You should have received a copy of the GNU General Public License |
129 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
130 | +// |
131 | + |
132 | +using System; |
133 | +using System.IO; |
134 | +using System.Diagnostics; |
135 | + |
136 | +using Mono.Unix; |
137 | + |
138 | +using Do.Platform; |
139 | + |
140 | +namespace Dropbox |
141 | +{ |
142 | + |
143 | + |
144 | + public static class Dropbox |
145 | + { |
146 | + public static string BasePath; |
147 | + public static string PublicPath; |
148 | + public static string DoSharedPath; |
149 | + |
150 | + private static string db_url = "https://www.getdropbox.com/"; |
151 | + |
152 | + static Dropbox () |
153 | + { |
154 | + string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal); |
155 | + |
156 | + BasePath = home + "/Dropbox"; |
157 | + PublicPath = BasePath + "/Public"; |
158 | + DoSharedPath = PublicPath + "/Do Shared Files"; |
159 | + } |
160 | + |
161 | + public static bool IsRunning { |
162 | + get { |
163 | + return !Exec ("status").StartsWith ("Dropbox isn't running!"); |
164 | + } |
165 | + } |
166 | + |
167 | + public static void Start () |
168 | + { |
169 | + Exec ("start -i"); |
170 | + } |
171 | + |
172 | + public static void Stop () |
173 | + { |
174 | + Exec ("stop"); |
175 | + } |
176 | + |
177 | + public static string GetPubUrl (string path) |
178 | + { |
179 | + string url = Exec (String.Format ("puburl \"{0}\"", path)); |
180 | + if (!url.StartsWith ("http")) { url = null; } |
181 | + |
182 | + return url; |
183 | + } |
184 | + |
185 | + public static string GetWebUrl () |
186 | + { |
187 | + return db_url + "home#"; |
188 | + } |
189 | + |
190 | + public static string GetWebUrl (string path) |
191 | + { |
192 | + return GetWebUrl () + path.Substring (BasePath.Length); |
193 | + } |
194 | + |
195 | + public static string GetRevisionsUrl (string path) |
196 | + { |
197 | + return db_url + "revisions" + path.Substring (BasePath.Length); |
198 | + } |
199 | + |
200 | + private static string Exec (string args) |
201 | + { |
202 | + string stdout = ""; |
203 | + |
204 | + try { |
205 | + ProcessStartInfo cmd = new ProcessStartInfo (); |
206 | + cmd.FileName = "dropbox"; |
207 | + cmd.Arguments = args; |
208 | + cmd.UseShellExecute = false; |
209 | + cmd.RedirectStandardOutput = true; |
210 | + |
211 | + Process run = Process.Start (cmd); |
212 | + run.WaitForExit (); |
213 | + |
214 | + stdout = run.StandardOutput.ReadLine (); |
215 | + Log.Debug (stdout); |
216 | + |
217 | + } catch (Exception e) { |
218 | + Log.Error ("Error running dropbox {0}: {2}", args, e.Message); |
219 | + Log.Debug (e.StackTrace); |
220 | + } |
221 | + |
222 | + return stdout; |
223 | + } |
224 | + |
225 | + } |
226 | +} |
227 | |
228 | === added file 'Dropbox/src/DropboxLinkAction.cs' |
229 | --- Dropbox/src/DropboxLinkAction.cs 1970-01-01 00:00:00 +0000 |
230 | +++ Dropbox/src/DropboxLinkAction.cs 2009-05-11 20:33:20 +0000 |
231 | @@ -0,0 +1,80 @@ |
232 | +// |
233 | +// DropboxLinkAction.cs |
234 | +// |
235 | +// GNOME Do is the legal property of its developers. Please refer to the |
236 | +// COPYRIGHT file distributed with this |
237 | +// source distribution. |
238 | +// |
239 | +// This program is free software: you can redistribute it and/or modify |
240 | +// it under the terms of the GNU General Public License as published by |
241 | +// the Free Software Foundation, either version 3 of the License, or |
242 | +// (at your option) any later version. |
243 | +// |
244 | +// This program is distributed in the hope that it will be useful, |
245 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
246 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
247 | +// GNU General Public License for more details. |
248 | +// |
249 | +// You should have received a copy of the GNU General Public License |
250 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
251 | +// |
252 | + |
253 | +using System; |
254 | +using System.IO; |
255 | +using System.Linq; |
256 | +using System.Collections.Generic; |
257 | + |
258 | +using Do.Universe; |
259 | +using Do.Universe.Common; |
260 | +using Do.Platform; |
261 | + |
262 | +namespace Dropbox |
263 | +{ |
264 | + |
265 | + public class DropboxLinkAction : DropboxAbstractAction |
266 | + { |
267 | + |
268 | + public override string Name { |
269 | + get { return "Add to Dropbox..."; } |
270 | + } |
271 | + |
272 | + public override string Description { |
273 | + get { return "Links a file or folder to your Dropbox."; } |
274 | + } |
275 | + |
276 | + public override string Icon { |
277 | + get { return "dropbox"; } |
278 | + } |
279 | + |
280 | + public override IEnumerable<Type> SupportedModifierItemTypes { |
281 | + get { yield return typeof (IFileItem); } |
282 | + } |
283 | + |
284 | + public override bool SupportsItem (Item item) |
285 | + { |
286 | + string path = GetPath (item); |
287 | + |
288 | + return !path.StartsWith (Dropbox.BasePath); |
289 | + } |
290 | + |
291 | + public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem) |
292 | + { |
293 | + string path = GetPath (modItem); |
294 | + |
295 | + return Directory.Exists (path) && path.StartsWith (Dropbox.BasePath); |
296 | + } |
297 | + |
298 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
299 | + { |
300 | + string target = GetPath (items.First ()); |
301 | + string folder = GetPath (modItems.First ()); |
302 | + string link_name = Path.Combine (folder, Path.GetFileName (target)); |
303 | + |
304 | + if (MakeLink (target, link_name)) |
305 | + yield return Services.UniverseFactory.NewFileItem (link_name) as Item; |
306 | + |
307 | + yield break; |
308 | + } |
309 | + |
310 | + } |
311 | +} |
312 | |
313 | === added file 'Dropbox/src/DropboxPuburlAction.cs' |
314 | --- Dropbox/src/DropboxPuburlAction.cs 1970-01-01 00:00:00 +0000 |
315 | +++ Dropbox/src/DropboxPuburlAction.cs 2009-05-10 21:55:26 +0000 |
316 | @@ -0,0 +1,72 @@ |
317 | +/* DropboxPuburlAction.cs |
318 | + * |
319 | + * GNOME Do is the legal property of its developers. Please refer to the |
320 | + * COPYRIGHT file distributed with this |
321 | + * source distribution. |
322 | + * |
323 | + * This program is free software: you can redistribute it and/or modify |
324 | + * it under the terms of the GNU General Public License as published by |
325 | + * the Free Software Foundation, either version 3 of the License, or |
326 | + * (at your option) any later version. |
327 | + * |
328 | + * This program is distributed in the hope that it will be useful, |
329 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
330 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
331 | + * GNU General Public License for more details. |
332 | + * |
333 | + * You should have received a copy of the GNU General Public License |
334 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
335 | + */ |
336 | + |
337 | +using System; |
338 | +using System.IO; |
339 | +using System.Linq; |
340 | +using System.Collections.Generic; |
341 | + |
342 | +using Do.Universe; |
343 | +using Do.Universe.Common; |
344 | +using Do.Platform; |
345 | + |
346 | + |
347 | +namespace Dropbox |
348 | +{ |
349 | + |
350 | + |
351 | + public class DropboxPuburlAction : DropboxAbstractAction |
352 | + { |
353 | + |
354 | + public override string Name { |
355 | + get { return "Get public URL"; } |
356 | + } |
357 | + |
358 | + public override string Description { |
359 | + get { return "Gets public URL of a shared Dropbox file."; } |
360 | + } |
361 | + |
362 | + public override string Icon { |
363 | + get { return "dropbox"; } |
364 | + } |
365 | + |
366 | + public override bool SupportsItem (Item item) |
367 | + { |
368 | + string path = GetPath(item); |
369 | + |
370 | + return File.Exists (path) && |
371 | + (path.StartsWith (Dropbox.PublicPath) || |
372 | + HasLink (path)); |
373 | + } |
374 | + |
375 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
376 | + { |
377 | + string path = GetPath(items.First ()); |
378 | + |
379 | + if (!path.StartsWith (Dropbox.PublicPath)) |
380 | + path = GetLink (path); |
381 | + |
382 | + string url = Dropbox.GetPubUrl (path); |
383 | + |
384 | + yield return new BookmarkItem (url, url); |
385 | + } |
386 | + |
387 | + } |
388 | +} |
389 | |
390 | === added file 'Dropbox/src/DropboxRevisionsAction.cs' |
391 | --- Dropbox/src/DropboxRevisionsAction.cs 1970-01-01 00:00:00 +0000 |
392 | +++ Dropbox/src/DropboxRevisionsAction.cs 2009-05-10 21:55:26 +0000 |
393 | @@ -0,0 +1,74 @@ |
394 | +/* DropboxPuburlAction.cs |
395 | + * |
396 | + * GNOME Do is the legal property of its developers. Please refer to the |
397 | + * COPYRIGHT file distributed with this |
398 | + * source distribution. |
399 | + * |
400 | + * This program is free software: you can redistribute it and/or modify |
401 | + * it under the terms of the GNU General Public License as published by |
402 | + * the Free Software Foundation, either version 3 of the License, or |
403 | + * (at your option) any later version. |
404 | + * |
405 | + * This program is distributed in the hope that it will be useful, |
406 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
407 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
408 | + * GNU General Public License for more details. |
409 | + * |
410 | + * You should have received a copy of the GNU General Public License |
411 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
412 | + */ |
413 | + |
414 | +using System; |
415 | +using System.IO; |
416 | +using System.Linq; |
417 | +using System.Collections.Generic; |
418 | + |
419 | +using Do.Universe; |
420 | +using Do.Universe.Common; |
421 | +using Do.Platform; |
422 | + |
423 | + |
424 | +namespace Dropbox |
425 | +{ |
426 | + |
427 | + |
428 | + public class DropboxRevisionsAction : DropboxAbstractAction |
429 | + { |
430 | + |
431 | + public override string Name { |
432 | + get { return "View revisions"; } |
433 | + } |
434 | + |
435 | + public override string Description { |
436 | + get { return "Views file history in Dropbox web interface."; } |
437 | + } |
438 | + |
439 | + public override string Icon { |
440 | + get { return "dropbox"; } |
441 | + } |
442 | + |
443 | + public override bool SupportsItem (Item item) |
444 | + { |
445 | + string path = GetPath(item); |
446 | + |
447 | + return File.Exists (path) && |
448 | + (path.StartsWith (Dropbox.BasePath) || |
449 | + HasLink (path)); |
450 | + } |
451 | + |
452 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
453 | + { |
454 | + string path = GetPath(items.First ()); |
455 | + |
456 | + if (!path.StartsWith (Dropbox.BasePath)) |
457 | + path = GetLink (path); |
458 | + |
459 | + string url = Dropbox.GetRevisionsUrl (path); |
460 | + |
461 | + Services.Environment.OpenUrl (url); |
462 | + |
463 | + return null; |
464 | + } |
465 | + |
466 | + } |
467 | +} |
468 | |
469 | === added file 'Dropbox/src/DropboxShareAction.cs' |
470 | --- Dropbox/src/DropboxShareAction.cs 1970-01-01 00:00:00 +0000 |
471 | +++ Dropbox/src/DropboxShareAction.cs 2009-05-10 21:55:26 +0000 |
472 | @@ -0,0 +1,80 @@ |
473 | +// |
474 | +// DropboxShareAction.cs |
475 | +// |
476 | +// GNOME Do is the legal property of its developers. Please refer to the |
477 | +// COPYRIGHT file distributed with this |
478 | +// source distribution. |
479 | +// |
480 | +// This program is free software: you can redistribute it and/or modify |
481 | +// it under the terms of the GNU General Public License as published by |
482 | +// the Free Software Foundation, either version 3 of the License, or |
483 | +// (at your option) any later version. |
484 | +// |
485 | +// This program is distributed in the hope that it will be useful, |
486 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
487 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
488 | +// GNU General Public License for more details. |
489 | +// |
490 | +// You should have received a copy of the GNU General Public License |
491 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
492 | +// |
493 | + |
494 | +using System; |
495 | +using System.IO; |
496 | +using System.Linq; |
497 | +using System.Collections.Generic; |
498 | + |
499 | +using Do.Universe; |
500 | +using Do.Universe.Common; |
501 | +using Do.Platform; |
502 | + |
503 | + |
504 | +namespace Dropbox |
505 | +{ |
506 | + |
507 | + |
508 | + public class DropboxShareAction : DropboxAbstractAction |
509 | + { |
510 | + |
511 | + public override string Name { |
512 | + get { return "Share with Dropbox"; } |
513 | + } |
514 | + |
515 | + public override string Description { |
516 | + get { return "Links a file to your Dropbox public folder."; } |
517 | + } |
518 | + |
519 | + public override string Icon { |
520 | + get { return "dropbox"; } |
521 | + } |
522 | + |
523 | + public override bool SupportsItem (Item item) |
524 | + { |
525 | + string path = GetPath (item); |
526 | + |
527 | + return File.Exists (path) && |
528 | + !path.StartsWith (Dropbox.PublicPath) && |
529 | + !HasLink (path); |
530 | + } |
531 | + |
532 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
533 | + { |
534 | + string target = GetPath (items.First ()); |
535 | + string extension = Path.GetExtension (target); |
536 | + string filename = Path.GetFileNameWithoutExtension (target); |
537 | + string link_name = Path.Combine (Dropbox.DoSharedPath, |
538 | + String.Format ("{0}-{1}{2}", filename, rand.Next (), extension)); |
539 | + |
540 | + Directory.CreateDirectory (Dropbox.DoSharedPath); |
541 | + |
542 | + if (MakeLink (target, link_name)) { |
543 | + |
544 | + string url = Dropbox.GetPubUrl (link_name); |
545 | + yield return new BookmarkItem (url, url); |
546 | + |
547 | + } |
548 | + } |
549 | + |
550 | + } |
551 | +} |
552 | + |
553 | |
554 | === added file 'Dropbox/src/DropboxStartAction.cs' |
555 | --- Dropbox/src/DropboxStartAction.cs 1970-01-01 00:00:00 +0000 |
556 | +++ Dropbox/src/DropboxStartAction.cs 2009-05-09 18:51:06 +0000 |
557 | @@ -0,0 +1,65 @@ |
558 | +/* DropboxStartActions.cs |
559 | + * |
560 | + * GNOME Do is the legal property of its developers. Please refer to the |
561 | + * COPYRIGHT file distributed with this |
562 | + * source distribution. |
563 | + * |
564 | + * This program is free software: you can redistribute it and/or modify |
565 | + * it under the terms of the GNU General Public License as published by |
566 | + * the Free Software Foundation, either version 3 of the License, or |
567 | + * (at your option) any later version. |
568 | + * |
569 | + * This program is distributed in the hope that it will be useful, |
570 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
571 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
572 | + * GNU General Public License for more details. |
573 | + * |
574 | + * You should have received a copy of the GNU General Public License |
575 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
576 | + */ |
577 | + |
578 | +using System; |
579 | +using System.Linq; |
580 | +using System.Collections.Generic; |
581 | + |
582 | +using Do.Universe; |
583 | +using Do.Platform; |
584 | + |
585 | + |
586 | +namespace Dropbox |
587 | +{ |
588 | + |
589 | + |
590 | + public class DropboxStartAction : Act |
591 | + { |
592 | + |
593 | + public override string Name { |
594 | + get { return "Start Dropbox"; } |
595 | + } |
596 | + |
597 | + public override string Description { |
598 | + get { return "Starts the Dropbox daemon."; } |
599 | + } |
600 | + |
601 | + public override string Icon { |
602 | + get { return "dropbox"; } |
603 | + } |
604 | + |
605 | + public override IEnumerable<Type> SupportedItemTypes { |
606 | + get { yield return typeof (IApplicationItem); } |
607 | + } |
608 | + |
609 | + public override bool SupportsItem (Item item) |
610 | + { |
611 | + return item.Name == "Dropbox" && !Dropbox.IsRunning; |
612 | + } |
613 | + |
614 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
615 | + { |
616 | + Dropbox.Start (); |
617 | + |
618 | + return null; |
619 | + } |
620 | + |
621 | + } |
622 | +} |
623 | |
624 | === added file 'Dropbox/src/DropboxStopAction.cs' |
625 | --- Dropbox/src/DropboxStopAction.cs 1970-01-01 00:00:00 +0000 |
626 | +++ Dropbox/src/DropboxStopAction.cs 2009-05-09 18:51:06 +0000 |
627 | @@ -0,0 +1,65 @@ |
628 | +/* DropboxStopAction.cs |
629 | + * |
630 | + * GNOME Do is the legal property of its developers. Please refer to the |
631 | + * COPYRIGHT file distributed with this |
632 | + * source distribution. |
633 | + * |
634 | + * This program is free software: you can redistribute it and/or modify |
635 | + * it under the terms of the GNU General Public License as published by |
636 | + * the Free Software Foundation, either version 3 of the License, or |
637 | + * (at your option) any later version. |
638 | + * |
639 | + * This program is distributed in the hope that it will be useful, |
640 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
641 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
642 | + * GNU General Public License for more details. |
643 | + * |
644 | + * You should have received a copy of the GNU General Public License |
645 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
646 | + */ |
647 | + |
648 | +using System; |
649 | +using System.Linq; |
650 | +using System.Collections.Generic; |
651 | + |
652 | +using Do.Universe; |
653 | +using Do.Platform; |
654 | + |
655 | + |
656 | +namespace Dropbox |
657 | +{ |
658 | + |
659 | + |
660 | + public class DropboxStopAction : Act |
661 | + { |
662 | + |
663 | + public override string Name { |
664 | + get { return "Stop Dropbox"; } |
665 | + } |
666 | + |
667 | + public override string Description { |
668 | + get { return "Stops the Dropbox daemon."; } |
669 | + } |
670 | + |
671 | + public override string Icon { |
672 | + get { return "dropbox"; } |
673 | + } |
674 | + |
675 | + public override IEnumerable<Type> SupportedItemTypes { |
676 | + get { yield return typeof (IApplicationItem); } |
677 | + } |
678 | + |
679 | + public override bool SupportsItem (Item item) |
680 | + { |
681 | + return item.Name == "Dropbox" && Dropbox.IsRunning; |
682 | + } |
683 | + |
684 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
685 | + { |
686 | + Dropbox.Stop (); |
687 | + |
688 | + return null; |
689 | + } |
690 | + |
691 | + } |
692 | +} |
693 | |
694 | === added file 'Dropbox/src/DropboxUnshareAction.cs' |
695 | --- Dropbox/src/DropboxUnshareAction.cs 1970-01-01 00:00:00 +0000 |
696 | +++ Dropbox/src/DropboxUnshareAction.cs 2009-05-11 20:33:20 +0000 |
697 | @@ -0,0 +1,72 @@ |
698 | +// |
699 | +// DropboxUnshareAction.cs |
700 | +// |
701 | +// GNOME Do is the legal property of its developers. Please refer to the |
702 | +// COPYRIGHT file distributed with this |
703 | +// source distribution. |
704 | +// |
705 | +// This program is free software: you can redistribute it and/or modify |
706 | +// it under the terms of the GNU General Public License as published by |
707 | +// the Free Software Foundation, either version 3 of the License, or |
708 | +// (at your option) any later version. |
709 | +// |
710 | +// This program is distributed in the hope that it will be useful, |
711 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
712 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
713 | +// GNU General Public License for more details. |
714 | +// |
715 | +// You should have received a copy of the GNU General Public License |
716 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
717 | +// |
718 | + |
719 | +using System; |
720 | +using System.IO; |
721 | +using System.Linq; |
722 | +using System.Collections.Generic; |
723 | + |
724 | +using Do.Universe; |
725 | +using Do.Universe.Common; |
726 | +using Do.Platform; |
727 | + |
728 | + |
729 | +namespace Dropbox |
730 | +{ |
731 | + |
732 | + |
733 | + public class DropboxUnshareAction : DropboxAbstractAction |
734 | + { |
735 | + |
736 | + public override string Name { |
737 | + get { return "Stop sharing with Dropbox"; } |
738 | + } |
739 | + |
740 | + public override string Description { |
741 | + get { return "Unlinks a file from your Dropbox public folder."; } |
742 | + } |
743 | + |
744 | + public override string Icon { |
745 | + get { return "dropbox"; } |
746 | + } |
747 | + |
748 | + public override bool SupportsItem (Item item) |
749 | + { |
750 | + string path = GetPath(item); |
751 | + |
752 | + return File.Exists (path) && HasLink (path); |
753 | + } |
754 | + |
755 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
756 | + { |
757 | + string path = GetPath(items.First ()); |
758 | + string link_path = GetLink (path); |
759 | + |
760 | + Unlink (link_path); |
761 | + |
762 | + Notify (String.Format ("Stopped sharing \"{0}\"", path)); |
763 | + |
764 | + return null; |
765 | + } |
766 | + |
767 | + } |
768 | +} |
769 | + |
770 | |
771 | === added file 'Dropbox/src/DropboxWebInterfaceAction.cs' |
772 | --- Dropbox/src/DropboxWebInterfaceAction.cs 1970-01-01 00:00:00 +0000 |
773 | +++ Dropbox/src/DropboxWebInterfaceAction.cs 2009-05-09 19:40:26 +0000 |
774 | @@ -0,0 +1,87 @@ |
775 | +// |
776 | +// DropboxWebInterfaceAction.cs |
777 | +// |
778 | +// GNOME Do is the legal property of its developers. Please refer to the |
779 | +// COPYRIGHT file distributed with this |
780 | +// source distribution. |
781 | +// |
782 | +// This program is free software: you can redistribute it and/or modify |
783 | +// it under the terms of the GNU General Public License as published by |
784 | +// the Free Software Foundation, either version 3 of the License, or |
785 | +// (at your option) any later version. |
786 | +// |
787 | +// This program is distributed in the hope that it will be useful, |
788 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
789 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
790 | +// GNU General Public License for more details. |
791 | +// |
792 | +// You should have received a copy of the GNU General Public License |
793 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
794 | +// |
795 | + |
796 | +using System; |
797 | +using System.IO; |
798 | +using System.Linq; |
799 | +using System.Collections.Generic; |
800 | + |
801 | +using Do.Universe; |
802 | +using Do.Platform; |
803 | + |
804 | +namespace Dropbox |
805 | +{ |
806 | + |
807 | + |
808 | + public class DropboxWebInterfaceAction : Act |
809 | + { |
810 | + |
811 | + public override string Name { |
812 | + get { return "Dropbox web interface"; } |
813 | + } |
814 | + |
815 | + public override string Description { |
816 | + get { return "Views folder in Dropbox web interface."; } |
817 | + } |
818 | + |
819 | + public override string Icon { |
820 | + get { return "dropbox"; } |
821 | + } |
822 | + |
823 | + public override IEnumerable<Type> SupportedItemTypes { |
824 | + get { |
825 | + return new Type[] { |
826 | + typeof (IApplicationItem), |
827 | + typeof (IFileItem) |
828 | + }; |
829 | + } |
830 | + |
831 | + } |
832 | + |
833 | + public override bool SupportsItem (Item item) |
834 | + { |
835 | + if (item is IApplicationItem) { |
836 | + return item.Name == "Dropbox"; |
837 | + } else { |
838 | + string path = (item as IFileItem).Path; |
839 | + return path.StartsWith (Dropbox.BasePath) && |
840 | + Directory.Exists (path); |
841 | + } |
842 | + } |
843 | + |
844 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
845 | + { |
846 | + string url, path; |
847 | + Item item = items.First (); |
848 | + |
849 | + if (item is IApplicationItem) { |
850 | + url = Dropbox.GetWebUrl (); |
851 | + } else { |
852 | + path = (item as IFileItem).Path; |
853 | + url = Dropbox.GetWebUrl (path); |
854 | + } |
855 | + |
856 | + Services.Environment.OpenUrl (url); |
857 | + |
858 | + return null; |
859 | + } |
860 | + } |
861 | +} |
862 | |
863 | === modified file 'Makefile.am' |
864 | --- Makefile.am 2009-03-31 22:19:30 +0000 |
865 | +++ Makefile.am 2009-05-07 21:32:56 +0000 |
866 | @@ -14,6 +14,7 @@ |
867 | Confluence \ |
868 | Del.icio.us \ |
869 | DiskMounter \ |
870 | + Dropbox \ |
871 | Emesene \ |
872 | EOG-Slideshow \ |
873 | Epiphany \ |
874 | |
875 | === modified file 'configure.ac' |
876 | --- configure.ac 2009-03-20 23:05:29 +0000 |
877 | +++ configure.ac 2009-05-07 21:32:56 +0000 |
878 | @@ -131,6 +131,7 @@ |
879 | Confluence/Makefile |
880 | Del.icio.us/Makefile |
881 | DiskMounter/Makefile |
882 | +Dropbox/Makefile |
883 | Emesene/Makefile |
884 | EOG-Slideshow/Makefile |
885 | Epiphany/Makefile |
Added Dropbox plugin, features:
* Start & Stop actions - dependent on Dropbox daemon status. Public/ Do Shared Items", randomising file name to prevent duplicates
* Web interface action - view folder in web interface (also works for Dropbox application item).
* Revisions action - view revisions of a Dropbox file in web interface.
* Link action - symlinks any file or folder to a user specified directory within Dropbox home. Returns the new file/folder item
* Share action - symlinks any file to "~/Dropbox/
* Unshare action - removes symlinks created with Share action
Possible performance issue - the Share/Unshare actions check all files in "Do Shared Files" for symlinks to file items during SupportsItem() testing. I could not think of a better way of doing this, but so far have not seen any actual performance problems.
I think I have followed the Mono coding guidelines, but I am sure some things have slipped through.
Thanks,
Steve