Merge lp:~mcuelenaere/syncany/trunk into lp:~syncany-team/syncany/trunk
- trunk
- Merge into trunk
Proposed by
Maurus Cuelenaere
Status: | Needs review |
---|---|
Proposed branch: | lp:~mcuelenaere/syncany/trunk |
Merge into: | lp:~syncany-team/syncany/trunk |
Diff against target: |
632 lines (+522/-1) 9 files modified
syncany/README (+4/-0) syncany/build.xml (+5/-1) syncany/nbproject/project.properties (+8/-0) syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.form (+42/-0) syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.java (+126/-0) syncany/src/org/syncany/connection/plugins/dropbox/DropboxConnection.java (+121/-0) syncany/src/org/syncany/connection/plugins/dropbox/DropboxPluginInfo.java (+57/-0) syncany/src/org/syncany/connection/plugins/dropbox/DropboxTransferManager.java (+145/-0) syncany/src/org/syncany/i18n/I18n_en_US.properties (+14/-0) |
To merge this branch: | bzr merge lp:~mcuelenaere/syncany/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Syncany Team | Pending | ||
Review via email: mp+92642@code.launchpad.net |
Commit message
Description of the change
Adds some minor fixes + Dropbox plugin
To post a comment you must log in.
Unmerged revisions
- 63. By Maurus Cuelenaere
-
Add Dropbox plugin
- 62. By Maurus Cuelenaere
-
Fix project.properties
- 61. By Maurus Cuelenaere
-
Fix Linux run target
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'syncany/README' | |||
2 | --- syncany/README 2011-06-10 18:44:48 +0000 | |||
3 | +++ syncany/README 2012-02-11 23:28:18 +0000 | |||
4 | @@ -62,3 +62,7 @@ | |||
5 | 62 | - The Syncany Rackspace plugin uses the java-cloudfiles library provided by | 62 | - The Syncany Rackspace plugin uses the java-cloudfiles library provided by |
6 | 63 | Rackspace (https://github.com/rackspace/java-cloudfiles). It is distributed | 63 | Rackspace (https://github.com/rackspace/java-cloudfiles). It is distributed |
7 | 64 | under the GPL-compatible MIT License. | 64 | under the GPL-compatible MIT License. |
8 | 65 | |||
9 | 66 | - The Dropbox plugin uses the SDK provided by Dropbox | ||
10 | 67 | (https://www.dropbox.com/developers/reference/sdk). It is distributed under | ||
11 | 68 | the GPL-compatible MIT License. | ||
12 | 65 | 69 | ||
13 | === modified file 'syncany/build.xml' | |||
14 | --- syncany/build.xml 2011-06-05 20:06:20 +0000 | |||
15 | +++ syncany/build.xml 2012-02-11 23:28:18 +0000 | |||
16 | @@ -163,7 +163,11 @@ | |||
17 | 163 | </fileset> | 163 | </fileset> |
18 | 164 | </copy> | 164 | </copy> |
19 | 165 | </target> | 165 | </target> |
21 | 166 | 166 | ||
22 | 167 | <target name="run" depends="compile" if="isLinux"> | ||
23 | 168 | <exec dir="bin" executable="./syncany.sh" /> | ||
24 | 169 | </target> | ||
25 | 170 | |||
26 | 167 | <!-- | 171 | <!-- |
27 | 168 | 172 | ||
28 | 169 | There exist several targets which are by default empty and which can be | 173 | There exist several targets which are by default empty and which can be |
29 | 170 | 174 | ||
30 | === added directory 'syncany/lib/plugins/dropbox' | |||
31 | === added file 'syncany/lib/plugins/dropbox/dropbox-java-sdk-1.2.3.jar' | |||
32 | 171 | Binary files syncany/lib/plugins/dropbox/dropbox-java-sdk-1.2.3.jar 1970-01-01 00:00:00 +0000 and syncany/lib/plugins/dropbox/dropbox-java-sdk-1.2.3.jar 2012-02-11 23:28:18 +0000 differ | 175 | Binary files syncany/lib/plugins/dropbox/dropbox-java-sdk-1.2.3.jar 1970-01-01 00:00:00 +0000 and syncany/lib/plugins/dropbox/dropbox-java-sdk-1.2.3.jar 2012-02-11 23:28:18 +0000 differ |
33 | === added file 'syncany/lib/plugins/dropbox/httpmime-4.0.3.jar' | |||
34 | 172 | Binary files syncany/lib/plugins/dropbox/httpmime-4.0.3.jar 1970-01-01 00:00:00 +0000 and syncany/lib/plugins/dropbox/httpmime-4.0.3.jar 2012-02-11 23:28:18 +0000 differ | 176 | Binary files syncany/lib/plugins/dropbox/httpmime-4.0.3.jar 1970-01-01 00:00:00 +0000 and syncany/lib/plugins/dropbox/httpmime-4.0.3.jar 2012-02-11 23:28:18 +0000 differ |
35 | === added file 'syncany/lib/plugins/dropbox/json_simple-1.1.jar' | |||
36 | 173 | Binary files syncany/lib/plugins/dropbox/json_simple-1.1.jar 1970-01-01 00:00:00 +0000 and syncany/lib/plugins/dropbox/json_simple-1.1.jar 2012-02-11 23:28:18 +0000 differ | 177 | Binary files syncany/lib/plugins/dropbox/json_simple-1.1.jar 1970-01-01 00:00:00 +0000 and syncany/lib/plugins/dropbox/json_simple-1.1.jar 2012-02-11 23:28:18 +0000 differ |
37 | === modified file 'syncany/nbproject/project.properties' | |||
38 | --- syncany/nbproject/project.properties 2011-06-05 21:47:40 +0000 | |||
39 | +++ syncany/nbproject/project.properties 2012-02-11 23:28:18 +0000 | |||
40 | @@ -34,6 +34,7 @@ | |||
41 | 34 | excludes= | 34 | excludes= |
42 | 35 | file.reference.AbsoluteLayout.jar=lib/AbsoluteLayout.jar | 35 | file.reference.AbsoluteLayout.jar=lib/AbsoluteLayout.jar |
43 | 36 | file.reference.AppFramework-1.03.jar=lib/AppFramework-1.03.jar | 36 | file.reference.AppFramework-1.03.jar=lib/AppFramework-1.03.jar |
44 | 37 | file.reference.bcprov-jdk16-146.jar=lib/bcprov-jdk16-146.jar | ||
45 | 37 | file.reference.box4j-1.4.0.jar=lib/plugins/box/box4j-1.4.0.jar | 38 | file.reference.box4j-1.4.0.jar=lib/plugins/box/box4j-1.4.0.jar |
46 | 38 | file.reference.commons-cli-1.2.jar=lib/commons-cli-1.2.jar | 39 | file.reference.commons-cli-1.2.jar=lib/commons-cli-1.2.jar |
47 | 39 | file.reference.commons-codec-1.4.jar=lib/commons-codec-1.4.jar | 40 | file.reference.commons-codec-1.4.jar=lib/commons-codec-1.4.jar |
48 | @@ -45,6 +46,7 @@ | |||
49 | 45 | file.reference.commons-vfs-1.0.jar=lib/commons-vfs-1.0.jar | 46 | file.reference.commons-vfs-1.0.jar=lib/commons-vfs-1.0.jar |
50 | 46 | file.reference.derby-10.8.1.2.jar=lib/derby-10.8.1.2.jar | 47 | file.reference.derby-10.8.1.2.jar=lib/derby-10.8.1.2.jar |
51 | 47 | file.reference.dom4j-1.6.1.jar=lib/dom4j-1.6.1.jar | 48 | file.reference.dom4j-1.6.1.jar=lib/dom4j-1.6.1.jar |
52 | 49 | file.reference.dropbox-java-sdk-1.2.3.jar=lib/plugins/dropbox/dropbox-java-sdk-1.2.3.jar | ||
53 | 48 | file.reference.eclipselink-2.2.0.jar=lib/eclipselink-2.2.0.jar | 50 | file.reference.eclipselink-2.2.0.jar=lib/eclipselink-2.2.0.jar |
54 | 49 | file.reference.eclipselink-javax.persistence-2.0.jar=lib/eclipselink-javax.persistence-2.0.jar | 51 | file.reference.eclipselink-javax.persistence-2.0.jar=lib/eclipselink-javax.persistence-2.0.jar |
55 | 50 | file.reference.gdata-client-1.0.jar=lib/plugins/picasa/gdata-client-1.0.jar | 52 | file.reference.gdata-client-1.0.jar=lib/plugins/picasa/gdata-client-1.0.jar |
56 | @@ -55,6 +57,7 @@ | |||
57 | 55 | file.reference.guava-r09.jar=lib/plugins/picasa/guava-r09.jar | 57 | file.reference.guava-r09.jar=lib/plugins/picasa/guava-r09.jar |
58 | 56 | file.reference.httpclient-4.0.3.jar=lib/httpclient-4.0.3.jar | 58 | file.reference.httpclient-4.0.3.jar=lib/httpclient-4.0.3.jar |
59 | 57 | file.reference.httpcore-4.1.jar=lib/httpcore-4.1.jar | 59 | file.reference.httpcore-4.1.jar=lib/httpcore-4.1.jar |
60 | 60 | file.reference.httpmime-4.0.3.jar=lib/plugins/dropbox/httpmime-4.0.3.jar | ||
61 | 58 | file.reference.inotify-java-recursive-source=../inotify-java-recursive/source | 61 | file.reference.inotify-java-recursive-source=../inotify-java-recursive/source |
62 | 59 | file.reference.j2ssh-core-0.2.9.jar=lib/plugins/sftp/j2ssh-core-0.2.9.jar | 62 | file.reference.j2ssh-core-0.2.9.jar=lib/plugins/sftp/j2ssh-core-0.2.9.jar |
63 | 60 | file.reference.java-cloudfiles.jar=lib/plugins/rackspace/java-cloudfiles.jar | 63 | file.reference.java-cloudfiles.jar=lib/plugins/rackspace/java-cloudfiles.jar |
64 | @@ -66,6 +69,7 @@ | |||
65 | 66 | file.reference.jets3t-0.8.1.jar-1=lib/plugins/shared/jets3t-0.8.1.jar | 69 | file.reference.jets3t-0.8.1.jar-1=lib/plugins/shared/jets3t-0.8.1.jar |
66 | 67 | file.reference.jpathwatch-0-94-libs-only.jar=lib/jpathwatch-0-94-libs-only.jar | 70 | file.reference.jpathwatch-0-94-libs-only.jar=lib/jpathwatch-0-94-libs-only.jar |
67 | 68 | file.reference.jsch-0.1.44.jar=lib/jsch-0.1.44.jar | 71 | file.reference.jsch-0.1.44.jar=lib/jsch-0.1.44.jar |
68 | 72 | file.reference.json_simple-1.1.jar=lib/plugins/dropbox/json_simple-1.1.jar | ||
69 | 69 | file.reference.log4j-1.2.jar=lib/log4j-1.2.jar | 73 | file.reference.log4j-1.2.jar=lib/log4j-1.2.jar |
70 | 70 | file.reference.mx4j-3.0.2.jar=lib/mx4j-3.0.2.jar | 74 | file.reference.mx4j-3.0.2.jar=lib/mx4j-3.0.2.jar |
71 | 71 | file.reference.mysql-connector-java-5.1.13-bin.jar=lib/mysql-connector-java-5.1.13-bin.jar | 75 | file.reference.mysql-connector-java-5.1.13-bin.jar=lib/mysql-connector-java-5.1.13-bin.jar |
72 | @@ -73,6 +77,7 @@ | |||
73 | 73 | file.reference.rabin-hash-function-2.0.jar=lib/rabin-hash-function-2.0.jar | 77 | file.reference.rabin-hash-function-2.0.jar=lib/rabin-hash-function-2.0.jar |
74 | 74 | file.reference.sardine.jar=lib/plugins/webdav/sardine.jar | 78 | file.reference.sardine.jar=lib/plugins/webdav/sardine.jar |
75 | 75 | file.reference.source-java=../inotify-java-recursive/source/java | 79 | file.reference.source-java=../inotify-java-recursive/source/java |
76 | 80 | file.reference.SSHTools-j2ssh-ext-0.1.0.jar=lib/plugins/sftp/SSHTools-j2ssh-ext-0.1.0.jar | ||
77 | 76 | file.reference.swing-layout-1.0.4.jar=lib/swing-layout-1.0.4.jar | 81 | file.reference.swing-layout-1.0.4.jar=lib/swing-layout-1.0.4.jar |
78 | 77 | file.reference.swing-worker-1.1.jar=lib/swing-worker-1.1.jar | 82 | file.reference.swing-worker-1.1.jar=lib/swing-worker-1.1.jar |
79 | 78 | includes=** | 83 | includes=** |
80 | @@ -120,8 +125,11 @@ | |||
81 | 120 | ${file.reference.rabin-hash-function-2.0.jar}:\ | 125 | ${file.reference.rabin-hash-function-2.0.jar}:\ |
82 | 121 | ${file.reference.swing-layout-1.0.4.jar}:\ | 126 | ${file.reference.swing-layout-1.0.4.jar}:\ |
83 | 122 | ${file.reference.swing-worker-1.1.jar}:\ | 127 | ${file.reference.swing-worker-1.1.jar}:\ |
84 | 128 | ${file.reference.dropbox-java-sdk-1.2.3.jar}:\ | ||
85 | 123 | ${file.reference.bcprov-jdk16-146.jar}:\ | 129 | ${file.reference.bcprov-jdk16-146.jar}:\ |
86 | 124 | ${file.reference.SSHTools-j2ssh-ext-0.1.0.jar}:\ | 130 | ${file.reference.SSHTools-j2ssh-ext-0.1.0.jar}:\ |
87 | 131 | ${file.reference.httpmime-4.0.3.jar}:\ | ||
88 | 132 | ${file.reference.json_simple-1.1.jar}:\ | ||
89 | 125 | ${file.reference.jsch-0.1.44.jar} | 133 | ${file.reference.jsch-0.1.44.jar} |
90 | 126 | # Space-separated list of extra javac options | 134 | # Space-separated list of extra javac options |
91 | 127 | javac.compilerargs= | 135 | javac.compilerargs= |
92 | 128 | 136 | ||
93 | === added directory 'syncany/src/org/syncany/connection/plugins/dropbox' | |||
94 | === added file 'syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.form' | |||
95 | --- syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.form 1970-01-01 00:00:00 +0000 | |||
96 | +++ syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.form 2012-02-11 23:28:18 +0000 | |||
97 | @@ -0,0 +1,42 @@ | |||
98 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
99 | 2 | |||
100 | 3 | <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> | ||
101 | 4 | <AuxValues> | ||
102 | 5 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | ||
103 | 6 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/> | ||
104 | 7 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> | ||
105 | 8 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> | ||
106 | 9 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> | ||
107 | 10 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> | ||
108 | 11 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||
109 | 12 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||
110 | 13 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | ||
111 | 14 | <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,56,0,0,0,-34"/> | ||
112 | 15 | </AuxValues> | ||
113 | 16 | |||
114 | 17 | <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> | ||
115 | 18 | <Property name="axis" type="int" value="1"/> | ||
116 | 19 | </Layout> | ||
117 | 20 | <SubComponents> | ||
118 | 21 | <Component class="javax.swing.JLabel" name="lblStatus"> | ||
119 | 22 | <Properties> | ||
120 | 23 | <Property name="horizontalAlignment" type="int" value="2"/> | ||
121 | 24 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> | ||
122 | 25 | <Connection code="resourceBundle.getString("dropbox_begin_auth")" type="code"/> | ||
123 | 26 | </Property> | ||
124 | 27 | <Property name="name" type="java.lang.String" value="lblStatus" noResource="true"/> | ||
125 | 28 | </Properties> | ||
126 | 29 | </Component> | ||
127 | 30 | <Component class="javax.swing.JButton" name="btnAuthenticate"> | ||
128 | 31 | <Properties> | ||
129 | 32 | <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> | ||
130 | 33 | <Connection code="resourceBundle.getString("dropbox_btn_authenticate")" type="code"/> | ||
131 | 34 | </Property> | ||
132 | 35 | <Property name="name" type="java.lang.String" value="btnAuthenticate"/> | ||
133 | 36 | </Properties> | ||
134 | 37 | <Events> | ||
135 | 38 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAuthenticateActionPerformed"/> | ||
136 | 39 | </Events> | ||
137 | 40 | </Component> | ||
138 | 41 | </SubComponents> | ||
139 | 42 | </Form> | ||
140 | 0 | 43 | ||
141 | === added file 'syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.java' | |||
142 | --- syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.java 1970-01-01 00:00:00 +0000 | |||
143 | +++ syncany/src/org/syncany/connection/plugins/dropbox/DropboxConfigPanel.java 2012-02-11 23:28:18 +0000 | |||
144 | @@ -0,0 +1,126 @@ | |||
145 | 1 | /* | ||
146 | 2 | * Syncany, www.syncany.org | ||
147 | 3 | * Copyright (C) 2012 Maurus Cuelenaere<mcuelenaere@gmail.com> | ||
148 | 4 | * | ||
149 | 5 | * This program is free software: you can redistribute it and/or modify | ||
150 | 6 | * it under the terms of the GNU General Public License as published by | ||
151 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
152 | 8 | * (at your option) any later version. | ||
153 | 9 | * | ||
154 | 10 | * This program is distributed in the hope that it will be useful, | ||
155 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
156 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
157 | 13 | * GNU General Public License for more details. | ||
158 | 14 | * | ||
159 | 15 | * You should have received a copy of the GNU General Public License | ||
160 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
161 | 17 | */ | ||
162 | 18 | package org.syncany.connection.plugins.dropbox; | ||
163 | 19 | |||
164 | 20 | import java.awt.Desktop; | ||
165 | 21 | import java.net.URI; | ||
166 | 22 | import java.util.ResourceBundle; | ||
167 | 23 | import javax.swing.JOptionPane; | ||
168 | 24 | import org.syncany.config.Config; | ||
169 | 25 | import org.syncany.connection.plugins.ConfigPanel; | ||
170 | 26 | import org.syncany.connection.plugins.dropbox.DropboxConnection.DropboxAuthentication; | ||
171 | 27 | |||
172 | 28 | /** | ||
173 | 29 | * @author Maurus Cuelenaere <mcuelenaere@gmail.com> | ||
174 | 30 | */ | ||
175 | 31 | public class DropboxConfigPanel extends ConfigPanel { | ||
176 | 32 | private ResourceBundle resourceBundle; | ||
177 | 33 | private DropboxAuthentication pendingAuthentication; | ||
178 | 34 | |||
179 | 35 | public DropboxConfigPanel(DropboxConnection connection) { | ||
180 | 36 | super(connection); | ||
181 | 37 | resourceBundle = Config.getInstance().getResourceBundle(); | ||
182 | 38 | initComponents(); | ||
183 | 39 | } | ||
184 | 40 | |||
185 | 41 | @Override | ||
186 | 42 | public void load() { | ||
187 | 43 | if (getConnection().isAuthenticated()) { | ||
188 | 44 | lblStatus.setText(resourceBundle.getString("dropbox_auth_success")); | ||
189 | 45 | btnAuthenticate.setText(resourceBundle.getString("dropbox_btn_reauthenticate")); | ||
190 | 46 | } else { | ||
191 | 47 | lblStatus.setText(resourceBundle.getString("dropbox_begin_auth")); | ||
192 | 48 | btnAuthenticate.setText(resourceBundle.getString("dropbox_btn_authenticate")); | ||
193 | 49 | } | ||
194 | 50 | } | ||
195 | 51 | |||
196 | 52 | @Override | ||
197 | 53 | public void save() { | ||
198 | 54 | // do nothing | ||
199 | 55 | } | ||
200 | 56 | |||
201 | 57 | @Override | ||
202 | 58 | public DropboxConnection getConnection() { | ||
203 | 59 | return (DropboxConnection) super.getConnection(); | ||
204 | 60 | } | ||
205 | 61 | |||
206 | 62 | private void browseUrl(String url) { | ||
207 | 63 | try { | ||
208 | 64 | Desktop.getDesktop().browse(new URI(url)); | ||
209 | 65 | } catch (Exception ex) { | ||
210 | 66 | // fallback | ||
211 | 67 | JOptionPane.showInputDialog(this, resourceBundle.getString("dropbox_browse_url"), url); | ||
212 | 68 | } | ||
213 | 69 | } | ||
214 | 70 | |||
215 | 71 | /** This method is called from within the constructor to | ||
216 | 72 | * initialize the form. | ||
217 | 73 | * WARNING: Do NOT modify this code. The content of this method is | ||
218 | 74 | * always regenerated by the Form Editor. | ||
219 | 75 | */ | ||
220 | 76 | @SuppressWarnings("unchecked") | ||
221 | 77 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | ||
222 | 78 | private void initComponents() { | ||
223 | 79 | |||
224 | 80 | lblStatus = new javax.swing.JLabel(); | ||
225 | 81 | btnAuthenticate = new javax.swing.JButton(); | ||
226 | 82 | |||
227 | 83 | setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS)); | ||
228 | 84 | |||
229 | 85 | lblStatus.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); | ||
230 | 86 | lblStatus.setText(resourceBundle.getString("dropbox_begin_auth")); | ||
231 | 87 | lblStatus.setName("lblStatus"); // NOI18N | ||
232 | 88 | add(lblStatus); | ||
233 | 89 | |||
234 | 90 | btnAuthenticate.setText(resourceBundle.getString("dropbox_btn_authenticate")); | ||
235 | 91 | btnAuthenticate.setName("btnAuthenticate"); | ||
236 | 92 | btnAuthenticate.addActionListener(new java.awt.event.ActionListener() { | ||
237 | 93 | public void actionPerformed(java.awt.event.ActionEvent evt) { | ||
238 | 94 | btnAuthenticateActionPerformed(evt); | ||
239 | 95 | } | ||
240 | 96 | }); | ||
241 | 97 | add(btnAuthenticate); | ||
242 | 98 | }// </editor-fold>//GEN-END:initComponents | ||
243 | 99 | |||
244 | 100 | private void btnAuthenticateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAuthenticateActionPerformed | ||
245 | 101 | if (pendingAuthentication != null) { | ||
246 | 102 | boolean result = pendingAuthentication.complete(); | ||
247 | 103 | pendingAuthentication = null; | ||
248 | 104 | |||
249 | 105 | if (result) { | ||
250 | 106 | btnAuthenticate.setText(resourceBundle.getString("dropbox_btn_reauthenticate")); | ||
251 | 107 | lblStatus.setText(resourceBundle.getString("dropbox_auth_success")); | ||
252 | 108 | } else { | ||
253 | 109 | btnAuthenticate.setText(resourceBundle.getString("dropbox_btn_authenticate")); | ||
254 | 110 | lblStatus.setText(resourceBundle.getString("dropbox_auth_fail")); | ||
255 | 111 | } | ||
256 | 112 | } else { | ||
257 | 113 | pendingAuthentication = getConnection().authenticate(); | ||
258 | 114 | |||
259 | 115 | browseUrl(pendingAuthentication.getUrl()); | ||
260 | 116 | |||
261 | 117 | lblStatus.setText(resourceBundle.getString("dropbox_awaiting_auth")); | ||
262 | 118 | btnAuthenticate.setText(resourceBundle.getString("dropbox_btn_complete_authentication")); | ||
263 | 119 | } | ||
264 | 120 | }//GEN-LAST:event_btnAuthenticateActionPerformed | ||
265 | 121 | |||
266 | 122 | // Variables declaration - do not modify//GEN-BEGIN:variables | ||
267 | 123 | private javax.swing.JButton btnAuthenticate; | ||
268 | 124 | private javax.swing.JLabel lblStatus; | ||
269 | 125 | // End of variables declaration//GEN-END:variables | ||
270 | 126 | } | ||
271 | 0 | 127 | ||
272 | === added file 'syncany/src/org/syncany/connection/plugins/dropbox/DropboxConnection.java' | |||
273 | --- syncany/src/org/syncany/connection/plugins/dropbox/DropboxConnection.java 1970-01-01 00:00:00 +0000 | |||
274 | +++ syncany/src/org/syncany/connection/plugins/dropbox/DropboxConnection.java 2012-02-11 23:28:18 +0000 | |||
275 | @@ -0,0 +1,121 @@ | |||
276 | 1 | /* | ||
277 | 2 | * Syncany, www.syncany.org | ||
278 | 3 | * Copyright (C) 2012 Maurus Cuelenaere<mcuelenaere@gmail.com> | ||
279 | 4 | * | ||
280 | 5 | * This program is free software: you can redistribute it and/or modify | ||
281 | 6 | * it under the terms of the GNU General Public License as published by | ||
282 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
283 | 8 | * (at your option) any later version. | ||
284 | 9 | * | ||
285 | 10 | * This program is distributed in the hope that it will be useful, | ||
286 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
287 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
288 | 13 | * GNU General Public License for more details. | ||
289 | 14 | * | ||
290 | 15 | * You should have received a copy of the GNU General Public License | ||
291 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
292 | 17 | */ | ||
293 | 18 | package org.syncany.connection.plugins.dropbox; | ||
294 | 19 | |||
295 | 20 | import com.dropbox.client2.exception.DropboxException; | ||
296 | 21 | import com.dropbox.client2.session.AccessTokenPair; | ||
297 | 22 | import com.dropbox.client2.session.AppKeyPair; | ||
298 | 23 | import com.dropbox.client2.session.Session; | ||
299 | 24 | import com.dropbox.client2.session.WebAuthSession; | ||
300 | 25 | import com.dropbox.client2.session.WebAuthSession.WebAuthInfo; | ||
301 | 26 | import java.util.logging.Level; | ||
302 | 27 | import java.util.logging.Logger; | ||
303 | 28 | import org.syncany.config.ConfigNode; | ||
304 | 29 | import org.syncany.connection.plugins.ConfigPanel; | ||
305 | 30 | import org.syncany.connection.plugins.Connection; | ||
306 | 31 | import org.syncany.connection.plugins.PluginInfo; | ||
307 | 32 | import org.syncany.connection.plugins.TransferManager; | ||
308 | 33 | import org.syncany.exceptions.ConfigException; | ||
309 | 34 | |||
310 | 35 | /** | ||
311 | 36 | * @author Maurus Cuelenaere <mcuelenaere@gmail.com> | ||
312 | 37 | */ | ||
313 | 38 | public class DropboxConnection implements Connection { | ||
314 | 39 | private static final AppKeyPair APP_KEY = new AppKeyPair("<FILLME>", "<FILLME>"); | ||
315 | 40 | private static final Logger logger = Logger.getLogger(DropboxConnection.class.getSimpleName()); | ||
316 | 41 | |||
317 | 42 | private WebAuthSession authSession; | ||
318 | 43 | |||
319 | 44 | public DropboxConnection() { | ||
320 | 45 | authSession = new WebAuthSession(APP_KEY, Session.AccessType.APP_FOLDER); | ||
321 | 46 | } | ||
322 | 47 | |||
323 | 48 | public WebAuthSession getAuthSession() { | ||
324 | 49 | return authSession; | ||
325 | 50 | } | ||
326 | 51 | |||
327 | 52 | public boolean isAuthenticated() { | ||
328 | 53 | return authSession.getAccessTokenPair() != null; | ||
329 | 54 | } | ||
330 | 55 | |||
331 | 56 | public class DropboxAuthentication { | ||
332 | 57 | private final WebAuthInfo authInfo; | ||
333 | 58 | |||
334 | 59 | public DropboxAuthentication() throws DropboxException { | ||
335 | 60 | authInfo = authSession.getAuthInfo(); | ||
336 | 61 | } | ||
337 | 62 | |||
338 | 63 | public String getUrl() { | ||
339 | 64 | return authInfo.url; | ||
340 | 65 | } | ||
341 | 66 | |||
342 | 67 | public boolean complete() { | ||
343 | 68 | try { | ||
344 | 69 | authSession.retrieveWebAccessToken(authInfo.requestTokenPair); | ||
345 | 70 | return true; | ||
346 | 71 | } catch (DropboxException ex) { | ||
347 | 72 | logger.log(Level.WARNING, "Couldn't complete Dropbox authentication", ex); | ||
348 | 73 | return false; | ||
349 | 74 | } | ||
350 | 75 | } | ||
351 | 76 | } | ||
352 | 77 | |||
353 | 78 | public DropboxAuthentication authenticate() { | ||
354 | 79 | try { | ||
355 | 80 | return new DropboxAuthentication(); | ||
356 | 81 | } catch (DropboxException ex) { | ||
357 | 82 | logger.log(Level.WARNING, "Couldn't start Dropbox authentication", ex); | ||
358 | 83 | return null; | ||
359 | 84 | } | ||
360 | 85 | } | ||
361 | 86 | |||
362 | 87 | @Override | ||
363 | 88 | public TransferManager createTransferManager() { | ||
364 | 89 | return new DropboxTransferManager(this); | ||
365 | 90 | } | ||
366 | 91 | |||
367 | 92 | @Override | ||
368 | 93 | public ConfigPanel createConfigPanel() { | ||
369 | 94 | return new DropboxConfigPanel(this); | ||
370 | 95 | } | ||
371 | 96 | |||
372 | 97 | @Override | ||
373 | 98 | public PluginInfo getPluginInfo() { | ||
374 | 99 | return new DropboxPluginInfo(); | ||
375 | 100 | } | ||
376 | 101 | |||
377 | 102 | @Override | ||
378 | 103 | public void load(ConfigNode node) throws ConfigException { | ||
379 | 104 | String key = node.getProperty("accessKey"); | ||
380 | 105 | String secret = node.getProperty("accessSecret"); | ||
381 | 106 | |||
382 | 107 | if (key == null || secret == null) | ||
383 | 108 | throw new ConfigException("Dropbox connection properties must at least contain the parameters 'accessKey' and 'accessSecret'."); | ||
384 | 109 | |||
385 | 110 | authSession.setAccessTokenPair(new AccessTokenPair(key, secret)); | ||
386 | 111 | } | ||
387 | 112 | |||
388 | 113 | @Override | ||
389 | 114 | public void save(ConfigNode node) { | ||
390 | 115 | AccessTokenPair tokenPair = authSession.getAccessTokenPair(); | ||
391 | 116 | |||
392 | 117 | node.setAttribute("type", getPluginInfo().getId()); | ||
393 | 118 | node.setProperty("accessKey", tokenPair.key); | ||
394 | 119 | node.setProperty("accessSecret", tokenPair.secret); | ||
395 | 120 | } | ||
396 | 121 | } | ||
397 | 0 | \ No newline at end of file | 122 | \ No newline at end of file |
398 | 1 | 123 | ||
399 | === added file 'syncany/src/org/syncany/connection/plugins/dropbox/DropboxPluginInfo.java' | |||
400 | --- syncany/src/org/syncany/connection/plugins/dropbox/DropboxPluginInfo.java 1970-01-01 00:00:00 +0000 | |||
401 | +++ syncany/src/org/syncany/connection/plugins/dropbox/DropboxPluginInfo.java 2012-02-11 23:28:18 +0000 | |||
402 | @@ -0,0 +1,57 @@ | |||
403 | 1 | /* | ||
404 | 2 | * Syncany, www.syncany.org | ||
405 | 3 | * Copyright (C) 2012 Maurus Cuelenaere<mcuelenaere@gmail.com> | ||
406 | 4 | * | ||
407 | 5 | * This program is free software: you can redistribute it and/or modify | ||
408 | 6 | * it under the terms of the GNU General Public License as published by | ||
409 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
410 | 8 | * (at your option) any later version. | ||
411 | 9 | * | ||
412 | 10 | * This program is distributed in the hope that it will be useful, | ||
413 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
414 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
415 | 13 | * GNU General Public License for more details. | ||
416 | 14 | * | ||
417 | 15 | * You should have received a copy of the GNU General Public License | ||
418 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
419 | 17 | */ | ||
420 | 18 | package org.syncany.connection.plugins.dropbox; | ||
421 | 19 | |||
422 | 20 | import java.util.ResourceBundle; | ||
423 | 21 | import org.syncany.config.Config; | ||
424 | 22 | import org.syncany.connection.plugins.Connection; | ||
425 | 23 | import org.syncany.connection.plugins.PluginInfo; | ||
426 | 24 | |||
427 | 25 | /** | ||
428 | 26 | * @author Maurus Cuelenaere <mcuelenaere@gmail.com> | ||
429 | 27 | */ | ||
430 | 28 | public class DropboxPluginInfo extends PluginInfo { | ||
431 | 29 | public static final String ID = "dropbox"; | ||
432 | 30 | |||
433 | 31 | private ResourceBundle resourceBundle = Config.getInstance().getResourceBundle(); | ||
434 | 32 | |||
435 | 33 | @Override | ||
436 | 34 | public String getId() { | ||
437 | 35 | return ID; | ||
438 | 36 | } | ||
439 | 37 | |||
440 | 38 | @Override | ||
441 | 39 | public String getName() { | ||
442 | 40 | return resourceBundle.getString("dropbox_plugin_name"); | ||
443 | 41 | } | ||
444 | 42 | |||
445 | 43 | @Override | ||
446 | 44 | public Integer[] getVersion() { | ||
447 | 45 | return new Integer[] {0, 1}; | ||
448 | 46 | } | ||
449 | 47 | |||
450 | 48 | @Override | ||
451 | 49 | public String getDescripton() { | ||
452 | 50 | return resourceBundle.getString("dropbox_plugin_description"); | ||
453 | 51 | } | ||
454 | 52 | |||
455 | 53 | @Override | ||
456 | 54 | public Connection createConnection() { | ||
457 | 55 | return new DropboxConnection(); | ||
458 | 56 | } | ||
459 | 57 | } | ||
460 | 0 | 58 | ||
461 | === added file 'syncany/src/org/syncany/connection/plugins/dropbox/DropboxTransferManager.java' | |||
462 | --- syncany/src/org/syncany/connection/plugins/dropbox/DropboxTransferManager.java 1970-01-01 00:00:00 +0000 | |||
463 | +++ syncany/src/org/syncany/connection/plugins/dropbox/DropboxTransferManager.java 2012-02-11 23:28:18 +0000 | |||
464 | @@ -0,0 +1,145 @@ | |||
465 | 1 | /* | ||
466 | 2 | * Syncany, www.syncany.org | ||
467 | 3 | * Copyright (C) 2012 Maurus Cuelenaere<mcuelenaere@gmail.com> | ||
468 | 4 | * | ||
469 | 5 | * This program is free software: you can redistribute it and/or modify | ||
470 | 6 | * it under the terms of the GNU General Public License as published by | ||
471 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
472 | 8 | * (at your option) any later version. | ||
473 | 9 | * | ||
474 | 10 | * This program is distributed in the hope that it will be useful, | ||
475 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
476 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
477 | 13 | * GNU General Public License for more details. | ||
478 | 14 | * | ||
479 | 15 | * You should have received a copy of the GNU General Public License | ||
480 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
481 | 17 | */ | ||
482 | 18 | package org.syncany.connection.plugins.dropbox; | ||
483 | 19 | |||
484 | 20 | import com.dropbox.client2.DropboxAPI; | ||
485 | 21 | import com.dropbox.client2.exception.DropboxException; | ||
486 | 22 | import com.dropbox.client2.exception.DropboxServerException; | ||
487 | 23 | import com.dropbox.client2.session.WebAuthSession; | ||
488 | 24 | import java.io.*; | ||
489 | 25 | import java.util.HashMap; | ||
490 | 26 | import java.util.Map; | ||
491 | 27 | import org.syncany.connection.plugins.AbstractTransferManager; | ||
492 | 28 | import org.syncany.exceptions.LocalFileNotFoundException; | ||
493 | 29 | import org.syncany.exceptions.RemoteFileNotFoundException; | ||
494 | 30 | import org.syncany.exceptions.StorageConnectException; | ||
495 | 31 | import org.syncany.exceptions.StorageException; | ||
496 | 32 | import org.syncany.repository.files.RemoteFile; | ||
497 | 33 | |||
498 | 34 | /** | ||
499 | 35 | * @author Maurus Cuelenaere <mcuelenaere@gmail.com> | ||
500 | 36 | */ | ||
501 | 37 | public class DropboxTransferManager extends AbstractTransferManager { | ||
502 | 38 | private final DropboxAPI<WebAuthSession> api; | ||
503 | 39 | private String cachedListHash; | ||
504 | 40 | private Map<String, RemoteFile> cachedListResult; | ||
505 | 41 | |||
506 | 42 | public DropboxTransferManager(DropboxConnection connection) { | ||
507 | 43 | super(connection); | ||
508 | 44 | |||
509 | 45 | api = new DropboxAPI<WebAuthSession>(connection.getAuthSession()); | ||
510 | 46 | } | ||
511 | 47 | |||
512 | 48 | @Override | ||
513 | 49 | public void connect() throws StorageConnectException { | ||
514 | 50 | } | ||
515 | 51 | |||
516 | 52 | @Override | ||
517 | 53 | public void disconnect() throws StorageException { | ||
518 | 54 | } | ||
519 | 55 | |||
520 | 56 | @Override | ||
521 | 57 | public void download(RemoteFile remoteFile, File localFile) throws RemoteFileNotFoundException, StorageException { | ||
522 | 58 | String name = "/" + remoteFile.getName(); | ||
523 | 59 | OutputStream out = null; | ||
524 | 60 | try { | ||
525 | 61 | out = new FileOutputStream(localFile); | ||
526 | 62 | api.getFile(name, null, out, null); | ||
527 | 63 | } catch (Exception ex) { | ||
528 | 64 | if (ex instanceof DropboxServerException) { | ||
529 | 65 | DropboxServerException sex = (DropboxServerException) ex; | ||
530 | 66 | if (sex.error == 404) | ||
531 | 67 | throw new RemoteFileNotFoundException(ex); | ||
532 | 68 | } | ||
533 | 69 | |||
534 | 70 | throw new StorageException(ex); | ||
535 | 71 | } finally { | ||
536 | 72 | if (out != null) { | ||
537 | 73 | try { | ||
538 | 74 | out.close(); | ||
539 | 75 | } catch (IOException ex) { | ||
540 | 76 | throw new StorageException(ex); | ||
541 | 77 | } | ||
542 | 78 | } | ||
543 | 79 | } | ||
544 | 80 | } | ||
545 | 81 | |||
546 | 82 | @Override | ||
547 | 83 | public void upload(File localFile, RemoteFile remoteFile) throws LocalFileNotFoundException, StorageException { | ||
548 | 84 | if (!localFile.exists()) | ||
549 | 85 | throw new LocalFileNotFoundException(); | ||
550 | 86 | |||
551 | 87 | String name = "/" + remoteFile.getName(); | ||
552 | 88 | InputStream in = null; | ||
553 | 89 | try { | ||
554 | 90 | in = new FileInputStream(localFile); | ||
555 | 91 | api.putFile(name, in, localFile.length(), null, null); | ||
556 | 92 | } catch (Exception ex) { | ||
557 | 93 | throw new StorageException(ex); | ||
558 | 94 | } finally { | ||
559 | 95 | if (in != null) { | ||
560 | 96 | try { | ||
561 | 97 | in.close(); | ||
562 | 98 | } catch (IOException ex) { | ||
563 | 99 | throw new StorageException(ex); | ||
564 | 100 | } | ||
565 | 101 | } | ||
566 | 102 | } | ||
567 | 103 | } | ||
568 | 104 | |||
569 | 105 | @Override | ||
570 | 106 | public void delete(RemoteFile remoteFile) throws RemoteFileNotFoundException, StorageException { | ||
571 | 107 | try { | ||
572 | 108 | api.delete(remoteFile.getName()); | ||
573 | 109 | } catch (DropboxException ex) { | ||
574 | 110 | throw new StorageException(ex); | ||
575 | 111 | } | ||
576 | 112 | } | ||
577 | 113 | |||
578 | 114 | @Override | ||
579 | 115 | public Map<String, RemoteFile> list() throws StorageException { | ||
580 | 116 | try { | ||
581 | 117 | Map<String, RemoteFile> result = new HashMap<String, RemoteFile>(); | ||
582 | 118 | DropboxAPI.Entry entry = api.metadata("", 0, cachedListHash, true, null); | ||
583 | 119 | assert(!entry.isDir); | ||
584 | 120 | |||
585 | 121 | for (DropboxAPI.Entry child : entry.contents) { | ||
586 | 122 | if (child.isDeleted || child.isDir) | ||
587 | 123 | continue; | ||
588 | 124 | |||
589 | 125 | String name = child.path.substring(1); // skip the first slash | ||
590 | 126 | RemoteFile file = new RemoteFile(name, child.bytes); | ||
591 | 127 | result.put(name, file); | ||
592 | 128 | } | ||
593 | 129 | |||
594 | 130 | // update cache | ||
595 | 131 | cachedListHash = entry.hash; | ||
596 | 132 | cachedListResult = result; | ||
597 | 133 | |||
598 | 134 | return result; | ||
599 | 135 | } catch (DropboxException ex) { | ||
600 | 136 | if (ex instanceof DropboxServerException) { | ||
601 | 137 | DropboxServerException sex = (DropboxServerException) ex; | ||
602 | 138 | if (sex.error == 304) | ||
603 | 139 | return cachedListResult; | ||
604 | 140 | } | ||
605 | 141 | |||
606 | 142 | throw new StorageException(ex); | ||
607 | 143 | } | ||
608 | 144 | } | ||
609 | 145 | } | ||
610 | 0 | 146 | ||
611 | === modified file 'syncany/src/org/syncany/i18n/I18n_en_US.properties' | |||
612 | --- syncany/src/org/syncany/i18n/I18n_en_US.properties 2011-06-04 00:29:53 +0000 | |||
613 | +++ syncany/src/org/syncany/i18n/I18n_en_US.properties 2012-02-11 23:28:18 +0000 | |||
614 | @@ -290,3 +290,17 @@ | |||
615 | 290 | webdav_path = Path: | 290 | webdav_path = Path: |
616 | 291 | webdav_name = WebDAV | 291 | webdav_name = WebDAV |
617 | 292 | webdav_plugin_description = Uses a WebDAV folder as data repository. | 292 | webdav_plugin_description = Uses a WebDAV folder as data repository. |
618 | 293 | |||
619 | 294 | ## DROPBOX PLUGIN | ||
620 | 295 | ## DROPBOX PLUGIN INFO | ||
621 | 296 | dropbox_plugin_name = Dropbox | ||
622 | 297 | dropbox_plugin_description = Uses Dropbox as data repository | ||
623 | 298 | ## DROPBOX PLUGIN CONFIG PANEL | ||
624 | 299 | dropbox_auth_success = Authentication successfull! | ||
625 | 300 | dropbox_auth_fail = Couldn't complete authentication! | ||
626 | 301 | dropbox_begin_auth = Please start authentication | ||
627 | 302 | dropbox_awaiting_auth = Awaiting authentication completion... | ||
628 | 303 | dropbox_btn_authenticate = Authenticate | ||
629 | 304 | dropbox_btn_reauthenticate = Re-authenticate | ||
630 | 305 | dropbox_btn_complete_authentication = Complete authentication | ||
631 | 306 | dropbox_browse_url = Browse to the following url: | ||
632 | 293 | \ No newline at end of file | 307 | \ No newline at end of file |