2
// DropboxShareAction.cs
4
// GNOME Do is the legal property of its developers. Please refer to the
5
// COPYRIGHT file distributed with this
6
// source distribution.
8
// This program is free software: you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 3 of the License, or
11
// (at your option) any later version.
13
// This program is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with this program. If not, see <http://www.gnu.org/licenses/>.
25
using System.Collections.Generic;
30
using Do.Universe.Common;
38
public class DropboxShareAction : DropboxAbstractAction
41
public override string Name {
42
get { return AddinManager.CurrentLocalizer.GetString ("Share with Dropbox"); }
45
public override string Description {
46
get { return AddinManager.CurrentLocalizer.GetString ("Links a file to your Dropbox public folder."); }
49
public override string Icon {
50
get { return ("dropbox-share.png@") + GetType ().Assembly.FullName; }
53
public override bool SupportsItem (Item item)
55
string path = GetPath (item);
57
return File.Exists (path) &&
58
!path.StartsWith (Dropbox.PublicPath) &&
62
public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
64
string target, extension, filename, linkName, url;
66
foreach (Item item in items) {
67
target = GetPath (item);
68
extension = Path.GetExtension (target);
69
filename = Path.GetFileNameWithoutExtension (target);
70
linkName = Path.Combine (Dropbox.DoSharedPath,
71
String.Format ("{0}-{1}{2}", filename, rand.Next (), extension));
73
Directory.CreateDirectory (Dropbox.DoSharedPath);
75
if (MakeLink (target, linkName)) {
77
url = Dropbox.GetPubUrl (linkName);
78
yield return new BookmarkItem (url, url);