Merge lp:~meese/pantheon-photos/code-reformat into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by meese
Status: Merged
Approved by: David Gomes
Approved revision: 2568
Merged at revision: 2568
Proposed branch: lp:~meese/pantheon-photos/code-reformat
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 147724 lines (+55554/-55196)
210 files modified
plugins/common/RESTSupport.vala (+659/-659)
plugins/common/Resources.vala (+22/-22)
plugins/common/SqliteSupport.vala (+49/-49)
plugins/common/VersionNumber.vala (+13/-13)
plugins/shotwell-data-imports/FSpotDatabase.vala (+24/-24)
plugins/shotwell-data-imports/FSpotDatabaseBehavior.vala (+115/-115)
plugins/shotwell-data-imports/FSpotDatabaseTable.vala (+23/-23)
plugins/shotwell-data-imports/FSpotImporter.vala (+250/-250)
plugins/shotwell-data-imports/FSpotMetaTable.vala (+50/-50)
plugins/shotwell-data-imports/FSpotPhotoTagsTable.vala (+17/-17)
plugins/shotwell-data-imports/FSpotPhotoVersionsTable.vala (+143/-139)
plugins/shotwell-data-imports/FSpotPhotosTable.vala (+186/-179)
plugins/shotwell-data-imports/FSpotRollsTable.vala (+47/-47)
plugins/shotwell-data-imports/FSpotTableBehavior.vala (+5/-5)
plugins/shotwell-data-imports/FSpotTagsTable.vala (+60/-60)
plugins/shotwell-data-imports/shotwell-data-imports.vala (+20/-20)
plugins/shotwell-publishing-extras/TumblrPublishing.vala (+938/-939)
plugins/shotwell-publishing-extras/YandexPublishing.vala (+357/-357)
plugins/shotwell-publishing-extras/shotwell-publishing-extras.vala (+19/-19)
plugins/shotwell-publishing/FacebookPublishing.vala (+1046/-1047)
plugins/shotwell-publishing/FlickrPublishing.vala (+854/-854)
plugins/shotwell-publishing/PicasaPublishing.vala (+537/-538)
plugins/shotwell-publishing/PiwigoPublishing.vala (+839/-839)
plugins/shotwell-publishing/YouTubePublishing.vala (+344/-344)
plugins/shotwell-publishing/shotwell-publishing.vala (+24/-24)
plugins/shotwell-transitions/BlindsEffect.vala (+41/-41)
plugins/shotwell-transitions/ChessEffect.vala (+31/-31)
plugins/shotwell-transitions/CircleEffect.vala (+25/-25)
plugins/shotwell-transitions/CirclesEffect.vala (+32/-32)
plugins/shotwell-transitions/ClockEffect.vala (+27/-27)
plugins/shotwell-transitions/CrumbleEffect.vala (+43/-43)
plugins/shotwell-transitions/FadeEffect.vala (+30/-30)
plugins/shotwell-transitions/SlideEffect.vala (+34/-34)
plugins/shotwell-transitions/SquaresEffect.vala (+35/-35)
plugins/shotwell-transitions/StripesEffect.vala (+28/-28)
plugins/shotwell-transitions/shotwell-transitions.vala (+49/-49)
samples/simple-plugin/simple-plugin.vala (+14/-14)
src/AppDirs.vala (+207/-207)
src/AppWindow.vala (+558/-549)
src/Application.vala (+100/-100)
src/BatchImport.vala (+1105/-1105)
src/Box.vala (+193/-193)
src/CheckerboardLayout.vala (+988/-988)
src/CollectionPage.vala (+509/-493)
src/ColorTransformation.vala (+587/-587)
src/CommandManager.vala (+119/-119)
src/Commands.vala (+1543/-1543)
src/CustomComponents.vala (+227/-226)
src/Debug.vala (+135/-135)
src/DesktopIntegration.vala (+155/-155)
src/Dialogs.vala (+1615/-1613)
src/Dimensions.vala (+415/-415)
src/DirectoryMonitor.vala (+935/-935)
src/Event.vala (+572/-572)
src/Exporter.vala (+171/-171)
src/International.vala (+10/-10)
src/LibraryFiles.vala (+46/-46)
src/LibraryMonitor.vala (+598/-598)
src/MediaDataRepresentation.vala (+550/-548)
src/MediaInterfaces.vala (+95/-95)
src/MediaMetadata.vala (+70/-70)
src/MediaMonitor.vala (+253/-253)
src/MediaPage.vala (+987/-953)
src/MediaViewTracker.vala (+49/-49)
src/MetadataWriter.vala (+393/-393)
src/Orientation.vala (+438/-438)
src/Page.vala (+1653/-1653)
src/Photo.vala (+2935/-2933)
src/PhotoMonitor.vala (+760/-760)
src/PhotoPage.vala (+2197/-2149)
src/PixbufCache.vala (+205/-205)
src/Printing.vala (+671/-671)
src/Properties.vala (+331/-331)
src/Resources.vala (+1094/-1094)
src/Screensaver.vala (+10/-10)
src/SearchFilter.vala (+362/-346)
src/SlideshowPage.vala (+292/-292)
src/SortedList.vala (+222/-216)
src/Tag.vala (+701/-701)
src/Thumbnail.vala (+273/-273)
src/ThumbnailCache.vala (+340/-340)
src/TimedQueue.vala (+153/-153)
src/Tombstone.vala (+184/-184)
src/UnityProgressBar.vala (+16/-16)
src/Upgrades.vala (+45/-45)
src/VideoMetadata.vala (+305/-305)
src/VideoMonitor.vala (+178/-178)
src/VideoSupport.vala (+637/-633)
src/camera/Branch.vala (+73/-73)
src/camera/Camera.vala (+4/-4)
src/camera/CameraTable.vala (+227/-227)
src/camera/GPhoto.vala (+283/-283)
src/camera/ImportPage.vala (+1050/-1031)
src/config/Config.vala (+70/-70)
src/config/ConfigurationInterfaces.vala (+701/-702)
src/config/GSettingsEngine.vala (+270/-270)
src/core/Alteration.vala (+167/-167)
src/core/ContainerSourceCollection.vala (+159/-159)
src/core/Core.vala (+9/-9)
src/core/DataCollection.vala (+399/-399)
src/core/DataObject.vala (+57/-57)
src/core/DataSet.vala (+104/-104)
src/core/DataSource.vala (+334/-334)
src/core/DataSourceTypes.vala (+52/-52)
src/core/DataView.vala (+85/-85)
src/core/DataViewTypes.vala (+24/-24)
src/core/DatabaseSourceCollection.vala (+42/-42)
src/core/SourceCollection.vala (+149/-149)
src/core/SourceHoldingTank.vala (+125/-125)
src/core/SourceInterfaces.vala (+14/-14)
src/core/Tracker.vala (+145/-145)
src/core/ViewCollection.vala (+792/-792)
src/core/util.vala (+83/-77)
src/data_imports/DataImportJob.vala (+98/-98)
src/data_imports/DataImportSource.vala (+73/-73)
src/data_imports/DataImports.vala (+7/-7)
src/data_imports/DataImportsPluginHost.vala (+267/-266)
src/data_imports/DataImportsUI.vala (+247/-247)
src/db/DatabaseTable.vala (+276/-276)
src/db/Db.vala (+162/-162)
src/db/EventTable.vala (+140/-140)
src/db/PhotoTable.vala (+853/-853)
src/db/SavedSearchDBTable.vala (+486/-486)
src/db/TagTable.vala (+152/-152)
src/db/TombstoneTable.vala (+85/-85)
src/db/VersionTable.vala (+62/-62)
src/db/VideoTable.vala (+314/-314)
src/direct/Direct.vala (+9/-9)
src/direct/DirectPhoto.vala (+165/-166)
src/direct/DirectPhotoPage.vala (+384/-361)
src/direct/DirectView.vala (+21/-21)
src/direct/DirectWindow.vala (+62/-62)
src/editing_tools/EditingTools.vala (+1654/-1653)
src/editing_tools/StraightenTool.vala (+281/-281)
src/events/Branch.vala (+337/-337)
src/events/EventDirectoryItem.vala (+129/-129)
src/events/EventPage.vala (+104/-102)
src/events/Events.vala (+4/-4)
src/events/EventsDirectoryPage.vala (+192/-189)
src/folders/Branch.vala (+112/-106)
src/folders/Folders.vala (+7/-7)
src/folders/Page.vala (+23/-23)
src/library/Branch.vala (+114/-95)
src/library/FlaggedPage.vala (+32/-32)
src/library/FlaggedSidebarEntry.vala (+34/-34)
src/library/ImportQueuePage.vala (+136/-135)
src/library/ImportQueueSidebarEntry.vala (+36/-36)
src/library/LastImportPage.vala (+43/-43)
src/library/LastImportSidebarEntry.vala (+24/-24)
src/library/Library.vala (+4/-4)
src/library/LibraryWindow.vala (+1031/-1019)
src/library/OfflinePage.vala (+82/-81)
src/library/OfflineSidebarEntry.vala (+30/-30)
src/library/TrashPage.vala (+80/-78)
src/library/TrashSidebarEntry.vala (+37/-37)
src/main.vala (+265/-261)
src/photos/BmpSupport.vala (+78/-78)
src/photos/GRaw.vala (+141/-141)
src/photos/GdkSupport.vala (+63/-63)
src/photos/JfifSupport.vala (+161/-161)
src/photos/PhotoFileAdapter.vala (+42/-42)
src/photos/PhotoFileFormat.vala (+306/-300)
src/photos/PhotoFileSniffer.vala (+20/-20)
src/photos/PhotoMetadata.vala (+690/-680)
src/photos/Photos.vala (+11/-11)
src/photos/PngSupport.vala (+82/-82)
src/photos/RawSupport.vala (+162/-162)
src/photos/TiffSupport.vala (+93/-93)
src/plugins/DataImportsInterfaces.vala (+96/-96)
src/plugins/ManifestWidget.vala (+153/-153)
src/plugins/Plugins.vala (+243/-217)
src/plugins/PublishingInterfaces.vala (+97/-97)
src/plugins/SpitInterfaces.vala (+83/-83)
src/plugins/StandardHostInterface.vala (+58/-58)
src/plugins/TransitionsInterfaces.vala (+112/-88)
src/publishing/APIGlue.vala (+54/-54)
src/publishing/Publishing.vala (+5/-5)
src/publishing/PublishingPluginHost.vala (+140/-140)
src/publishing/PublishingUI.vala (+290/-289)
src/searches/Branch.vala (+105/-105)
src/searches/SavedSearchDialog.vala (+551/-551)
src/searches/SavedSearchPage.vala (+60/-60)
src/searches/SearchBoolean.vala (+561/-520)
src/searches/Searches.vala (+11/-11)
src/sidebar/Branch.vala (+290/-290)
src/sidebar/Entry.vala (+36/-36)
src/sidebar/Sidebar.vala (+2/-2)
src/sidebar/Tree.vala (+790/-790)
src/sidebar/common.vala (+57/-57)
src/slideshow/Slideshow.vala (+7/-7)
src/slideshow/TransitionEffects.vala (+209/-209)
src/tags/Branch.vala (+186/-186)
src/tags/HierarchicalTagIndex.vala (+47/-47)
src/tags/HierarchicalTagUtilities.vala (+83/-83)
src/tags/TagPage.vala (+96/-92)
src/tags/Tags.vala (+4/-4)
src/threads/BackgroundJob.vala (+87/-87)
src/threads/Semaphore.vala (+82/-82)
src/threads/Threads.vala (+5/-5)
src/threads/Workers.vala (+51/-51)
src/unit/Unit.vala (+5/-5)
src/util/KeyValueMap.vala (+81/-81)
src/util/Util.vala (+8/-8)
src/util/file.vala (+109/-109)
src/util/image.vala (+158/-158)
src/util/misc.vala (+174/-174)
src/util/string.vala (+125/-125)
src/util/system.vala (+22/-22)
src/util/ui.vala (+39/-39)
thumbnailer/shotwell-video-thumbnailer.vala (+44/-44)
To merge this branch: bzr merge lp:~meese/pantheon-photos/code-reformat
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+230185@code.launchpad.net

Commit message

Description of the change

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) wrote :

Great job, thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/common/RESTSupport.vala'
2--- plugins/common/RESTSupport.vala 2013-09-24 22:08:27 +0000
3+++ plugins/common/RESTSupport.vala 2014-08-08 21:16:43 +0000
4@@ -4,7 +4,7 @@
5 * (version 2.1 or later). See the COPYING file in this distribution.
6 */
7
8-extern Soup.Message soup_form_request_new_from_multipart(string uri, Soup.Multipart multipart);
9+extern Soup.Message soup_form_request_new_from_multipart (string uri, Soup.Multipart multipart);
10
11 namespace Publishing.RESTSupport {
12
13@@ -12,51 +12,51 @@
14 private string? endpoint_url = null;
15 private Soup.Session soup_session = null;
16 private bool transactions_stopped = false;
17-
18- public signal void wire_message_unqueued(Soup.Message message);
19- public signal void authenticated();
20- public signal void authentication_failed(Spit.Publishing.PublishingError err);
21-
22- public Session(string? endpoint_url = null) {
23+
24+ public signal void wire_message_unqueued (Soup.Message message);
25+ public signal void authenticated ();
26+ public signal void authentication_failed (Spit.Publishing.PublishingError err);
27+
28+ public Session (string? endpoint_url = null) {
29 this.endpoint_url = endpoint_url;
30- soup_session = new Soup.SessionAsync();
31- }
32-
33- protected void notify_wire_message_unqueued(Soup.Message message) {
34- wire_message_unqueued(message);
35- }
36-
37- protected void notify_authenticated() {
38- authenticated();
39- }
40-
41- protected void notify_authentication_failed(Spit.Publishing.PublishingError err) {
42- authentication_failed(err);
43- }
44-
45- public abstract bool is_authenticated();
46-
47- public string? get_endpoint_url() {
48+ soup_session = new Soup.SessionAsync ();
49+ }
50+
51+ protected void notify_wire_message_unqueued (Soup.Message message) {
52+ wire_message_unqueued (message);
53+ }
54+
55+ protected void notify_authenticated () {
56+ authenticated ();
57+ }
58+
59+ protected void notify_authentication_failed (Spit.Publishing.PublishingError err) {
60+ authentication_failed (err);
61+ }
62+
63+ public abstract bool is_authenticated ();
64+
65+ public string? get_endpoint_url () {
66 return endpoint_url;
67 }
68-
69- public void stop_transactions() {
70+
71+ public void stop_transactions () {
72 transactions_stopped = true;
73- soup_session.abort();
74+ soup_session.abort ();
75 }
76-
77- public bool are_transactions_stopped() {
78+
79+ public bool are_transactions_stopped () {
80 return transactions_stopped;
81 }
82-
83- public void send_wire_message(Soup.Message message) {
84- if (are_transactions_stopped())
85+
86+ public void send_wire_message (Soup.Message message) {
87+ if (are_transactions_stopped ())
88 return;
89
90- soup_session.request_unqueued.connect(notify_wire_message_unqueued);
91- soup_session.send_message(message);
92-
93- soup_session.request_unqueued.disconnect(notify_wire_message_unqueued);
94+ soup_session.request_unqueued.connect (notify_wire_message_unqueued);
95+ soup_session.send_message (message);
96+
97+ soup_session.request_unqueued.disconnect (notify_wire_message_unqueued);
98 }
99 }
100
101@@ -65,23 +65,23 @@
102 POST,
103 PUT;
104
105- public string to_string() {
106+ public string to_string () {
107 switch (this) {
108- case HttpMethod.GET:
109- return "GET";
110-
111- case HttpMethod.PUT:
112- return "PUT";
113-
114- case HttpMethod.POST:
115- return "POST";
116-
117- default:
118- error("unrecognized HTTP method enumeration value");
119+ case HttpMethod.GET:
120+ return "GET";
121+
122+ case HttpMethod.PUT:
123+ return "PUT";
124+
125+ case HttpMethod.POST:
126+ return "POST";
127+
128+ default:
129+ error ("unrecognized HTTP method enumeration value");
130 }
131 }
132
133- public static HttpMethod from_string(string str) {
134+ public static HttpMethod from_string (string str) {
135 if (str == "GET") {
136 return HttpMethod.GET;
137 } else if (str == "PUT") {
138@@ -89,7 +89,7 @@
139 } else if (str == "POST") {
140 return HttpMethod.POST;
141 } else {
142- error("unrecognized HTTP method name: %s", str);
143+ error ("unrecognized HTTP method name: %s", str);
144 }
145 }
146 }
147@@ -98,22 +98,22 @@
148 public string key;
149 public string value;
150
151- public Argument(string key, string value) {
152+ public Argument (string key, string value) {
153 this.key = key;
154 this.value = value;
155 }
156
157- public static int compare(Argument arg1, Argument arg2) {
158- return strcmp(arg1.key, arg2.key);
159+ public static int compare (Argument arg1, Argument arg2) {
160+ return strcmp (arg1.key, arg2.key);
161 }
162-
163- public static Argument[] sort(Argument[] inputArray) {
164- FixedTreeSet<Argument> sorted_args = new FixedTreeSet<Argument>(Argument.compare);
165+
166+ public static Argument[] sort (Argument[] inputArray) {
167+ FixedTreeSet<Argument> sorted_args = new FixedTreeSet<Argument> (Argument.compare);
168
169 foreach (Argument arg in inputArray)
170- sorted_args.add(arg);
171+ sorted_args.add (arg);
172
173- return sorted_args.to_array();
174+ return sorted_args.to_array ();
175 }
176 }
177
178@@ -126,227 +126,227 @@
179 private Spit.Publishing.PublishingError? err = null;
180 private string? endpoint_url = null;
181 private bool use_custom_payload;
182-
183- public signal void chunk_transmitted(int bytes_written_so_far, int total_bytes);
184- public signal void network_error(Spit.Publishing.PublishingError err);
185- public signal void completed();
186-
187- public Transaction(Session parent_session, HttpMethod method = HttpMethod.POST) {
188+
189+ public signal void chunk_transmitted (int bytes_written_so_far, int total_bytes);
190+ public signal void network_error (Spit.Publishing.PublishingError err);
191+ public signal void completed ();
192+
193+ public Transaction (Session parent_session, HttpMethod method = HttpMethod.POST) {
194 // if our creator doesn't specify an endpoint url by using the Transaction.with_endpoint_url
195 // constructor, then our parent session must have a non-null endpoint url
196- assert(parent_session.get_endpoint_url() != null);
197-
198+ assert (parent_session.get_endpoint_url () != null);
199+
200 this.parent_session = parent_session;
201
202- message = new Soup.Message(method.to_string(), parent_session.get_endpoint_url());
203- message.wrote_body_data.connect(on_wrote_body_data);
204+ message = new Soup.Message (method.to_string (), parent_session.get_endpoint_url ());
205+ message.wrote_body_data.connect (on_wrote_body_data);
206 }
207
208- public Transaction.with_endpoint_url(Session parent_session, string endpoint_url,
209- HttpMethod method = HttpMethod.POST) {
210+ public Transaction.with_endpoint_url (Session parent_session, string endpoint_url,
211+ HttpMethod method = HttpMethod.POST) {
212 this.parent_session = parent_session;
213 this.endpoint_url = endpoint_url;
214- message = new Soup.Message(method.to_string(), endpoint_url);
215+ message = new Soup.Message (method.to_string (), endpoint_url);
216 }
217
218- private void on_wrote_body_data(Soup.Buffer written_data) {
219+ private void on_wrote_body_data (Soup.Buffer written_data) {
220 bytes_written += (int) written_data.length;
221- chunk_transmitted(bytes_written, (int) message.request_body.length);
222+ chunk_transmitted (bytes_written, (int) message.request_body.length);
223 }
224
225- private void on_message_unqueued(Soup.Message message) {
226+ private void on_message_unqueued (Soup.Message message) {
227 if (this.message != message)
228 return;
229
230 try {
231- check_response(message);
232+ check_response (message);
233 } catch (Spit.Publishing.PublishingError err) {
234- warning("Publishing error: %s", err.message);
235- warning("response validation failed. bad response = '%s'.", get_response());
236+ warning ("Publishing error: %s", err.message);
237+ warning ("response validation failed. bad response = '%s'.", get_response ());
238 this.err = err;
239 }
240 }
241
242- protected void check_response(Soup.Message message) throws Spit.Publishing.PublishingError {
243+ protected void check_response (Soup.Message message) throws Spit.Publishing.PublishingError {
244 switch (message.status_code) {
245- case Soup.KnownStatusCode.OK:
246- case Soup.KnownStatusCode.CREATED: // HTTP code 201 (CREATED) signals that a new
247- // resource was created in response to a PUT or POST
248+ case Soup.KnownStatusCode.OK:
249+ case Soup.KnownStatusCode.CREATED: // HTTP code 201 (CREATED) signals that a new
250+ // resource was created in response to a PUT or POST
251 break;
252-
253- case Soup.KnownStatusCode.CANT_RESOLVE:
254- case Soup.KnownStatusCode.CANT_RESOLVE_PROXY:
255- throw new Spit.Publishing.PublishingError.NO_ANSWER("Unable to resolve %s (error code %u)",
256- get_endpoint_url(), message.status_code);
257-
258- case Soup.KnownStatusCode.CANT_CONNECT:
259- case Soup.KnownStatusCode.CANT_CONNECT_PROXY:
260- throw new Spit.Publishing.PublishingError.NO_ANSWER("Unable to connect to %s (error code %u)",
261- get_endpoint_url(), message.status_code);
262-
263- default:
264- // status codes below 100 are used by Soup, 100 and above are defined HTTP codes
265- if (message.status_code >= 100) {
266- throw new Spit.Publishing.PublishingError.NO_ANSWER("Service %s returned HTTP status code %u %s",
267- get_endpoint_url(), message.status_code, message.reason_phrase);
268- } else {
269- throw new Spit.Publishing.PublishingError.NO_ANSWER("Failure communicating with %s (error code %u)",
270- get_endpoint_url(), message.status_code);
271- }
272+
273+ case Soup.KnownStatusCode.CANT_RESOLVE:
274+ case Soup.KnownStatusCode.CANT_RESOLVE_PROXY:
275+ throw new Spit.Publishing.PublishingError.NO_ANSWER ("Unable to resolve %s (error code %u)",
276+ get_endpoint_url (), message.status_code);
277+
278+ case Soup.KnownStatusCode.CANT_CONNECT:
279+ case Soup.KnownStatusCode.CANT_CONNECT_PROXY:
280+ throw new Spit.Publishing.PublishingError.NO_ANSWER ("Unable to connect to %s (error code %u)",
281+ get_endpoint_url (), message.status_code);
282+
283+ default:
284+ // status codes below 100 are used by Soup, 100 and above are defined HTTP codes
285+ if (message.status_code >= 100) {
286+ throw new Spit.Publishing.PublishingError.NO_ANSWER ("Service %s returned HTTP status code %u %s",
287+ get_endpoint_url (), message.status_code, message.reason_phrase);
288+ } else {
289+ throw new Spit.Publishing.PublishingError.NO_ANSWER ("Failure communicating with %s (error code %u)",
290+ get_endpoint_url (), message.status_code);
291+ }
292 }
293-
294+
295 // All valid communication involves body data in the response
296 if (message.response_body.data == null || message.response_body.data.length == 0)
297- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("No response data from %s",
298- get_endpoint_url());
299+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("No response data from %s",
300+ get_endpoint_url ());
301 }
302
303- public Argument[] get_arguments() {
304+ public Argument[] get_arguments () {
305 return arguments;
306 }
307-
308- public Argument[] get_sorted_arguments() {
309- return Argument.sort(get_arguments());
310+
311+ public Argument[] get_sorted_arguments () {
312+ return Argument.sort (get_arguments ());
313 }
314-
315- protected void set_is_executed(bool is_executed) {
316+
317+ protected void set_is_executed (bool is_executed) {
318 this.is_executed = is_executed;
319 }
320
321- protected void send() throws Spit.Publishing.PublishingError {
322- parent_session.wire_message_unqueued.connect(on_message_unqueued);
323- message.wrote_body_data.connect(on_wrote_body_data);
324- parent_session.send_wire_message(message);
325-
326- parent_session.wire_message_unqueued.disconnect(on_message_unqueued);
327- message.wrote_body_data.disconnect(on_wrote_body_data);
328-
329+ protected void send () throws Spit.Publishing.PublishingError {
330+ parent_session.wire_message_unqueued.connect (on_message_unqueued);
331+ message.wrote_body_data.connect (on_wrote_body_data);
332+ parent_session.send_wire_message (message);
333+
334+ parent_session.wire_message_unqueued.disconnect (on_message_unqueued);
335+ message.wrote_body_data.disconnect (on_wrote_body_data);
336+
337 if (err != null)
338- network_error(err);
339+ network_error (err);
340 else
341- completed();
342-
343+ completed ();
344+
345 if (err != null)
346 throw err;
347- }
348-
349- public HttpMethod get_method() {
350- return HttpMethod.from_string(message.method);
351- }
352-
353- protected virtual void add_header(string key, string value) {
354- message.request_headers.append(key, value);
355- }
356-
357+ }
358+
359+ public HttpMethod get_method () {
360+ return HttpMethod.from_string (message.method);
361+ }
362+
363+ protected virtual void add_header (string key, string value) {
364+ message.request_headers.append (key, value);
365+ }
366+
367 // set custom_payload to null to have this transaction send the default payload of
368 // key-value pairs appended through add_argument(...) (this is how most REST requests work).
369 // To send a payload other than traditional key-value pairs (such as an XML document or a JPEG
370 // image) to the endpoint, set the custom_payload parameter to a non-null value. If the
371- // custom_payload you specify is text data, then it's null terminated, and its length is just
372+ // custom_payload you specify is text data, then it's null terminated, and its length is just
373 // custom_payload.length, so you don't have to pass in a payload_length parameter in this case.
374 // If, however, custom_payload is binary data (such as a JEPG), then the caller must set
375 // payload_length to the byte length of the custom_payload buffer
376- protected void set_custom_payload(string? custom_payload, string payload_content_type,
377- ulong payload_length = 0) {
378- assert (get_method() != HttpMethod.GET); // GET messages don't have payloads
379+ protected void set_custom_payload (string? custom_payload, string payload_content_type,
380+ ulong payload_length = 0) {
381+ assert (get_method () != HttpMethod.GET); // GET messages don't have payloads
382
383 if (custom_payload == null) {
384 use_custom_payload = false;
385 return;
386 }
387-
388+
389 ulong length = (payload_length > 0) ? payload_length : custom_payload.length;
390- message.set_request(payload_content_type, Soup.MemoryUse.COPY, custom_payload.data[0:length]);
391+ message.set_request (payload_content_type, Soup.MemoryUse.COPY, custom_payload.data[0:length]);
392
393 use_custom_payload = true;
394 }
395-
396+
397 // When writing a specialized transaction subclass you should rarely need to
398 // call this method. In general, it's better to leave the underlying Soup message
399 // alone and let the Transaction class manage it for you. You should only need
400 // to install a new message if your subclass has radically different behavior from
401 // normal Transactions -- like multipart encoding.
402- protected void set_message(Soup.Message message) {
403+ protected void set_message (Soup.Message message) {
404 this.message = message;
405 }
406-
407- public bool get_is_executed() {
408+
409+ public bool get_is_executed () {
410 return is_executed;
411 }
412
413- public uint get_status_code() {
414- assert(get_is_executed());
415+ public uint get_status_code () {
416+ assert (get_is_executed ());
417 return message.status_code;
418 }
419
420- public virtual void execute() throws Spit.Publishing.PublishingError {
421+ public virtual void execute () throws Spit.Publishing.PublishingError {
422 // if a custom payload is being used, we don't need to peform the tasks that are necessary
423 // to prepare a traditional key-value pair REST request; Instead (since we don't
424 // know anything about the custom payload), we just put it on the wire and return
425 if (use_custom_payload) {
426 is_executed = true;
427- send();
428+ send ();
429
430 return;
431- }
432-
433+ }
434+
435 // REST POST requests must transmit at least one argument
436- if (get_method() == HttpMethod.POST)
437- assert(arguments.length > 0);
438+ if (get_method () == HttpMethod.POST)
439+ assert (arguments.length > 0);
440
441 // concatenate the REST arguments array into an HTTP formdata string
442 string formdata_string = "";
443 for (int i = 0; i < arguments.length; i++) {
444- formdata_string += ("%s=%s".printf(arguments[i].key, arguments[i].value));
445+ formdata_string += ("%s=%s".printf (arguments[i].key, arguments[i].value));
446 if (i < arguments.length - 1)
447 formdata_string += "&";
448 }
449-
450+
451 // for GET requests with arguments, append the formdata string to the endpoint url after a
452 // query divider ('?') -- but make sure to save the old (caller-specified) endpoint URL
453 // and restore it after the GET so that the underlying Soup message remains consistent
454 string old_url = null;
455 string url_with_query = null;
456- if (get_method() == HttpMethod.GET && arguments.length > 0) {
457- old_url = message.get_uri().to_string(false);
458- url_with_query = get_endpoint_url() + "?" + formdata_string;
459- message.set_uri(new Soup.URI(url_with_query));
460+ if (get_method () == HttpMethod.GET && arguments.length > 0) {
461+ old_url = message.get_uri ().to_string (false);
462+ url_with_query = get_endpoint_url () + "?" + formdata_string;
463+ message.set_uri (new Soup.URI (url_with_query));
464 } else {
465- message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY,
466- formdata_string.data);
467+ message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.COPY,
468+ formdata_string.data);
469 }
470
471 is_executed = true;
472
473 try {
474- debug("sending message to URI = '%s'", message.get_uri().to_string(false));
475- send();
476+ debug ("sending message to URI = '%s'", message.get_uri ().to_string (false));
477+ send ();
478 } finally {
479 // if old_url is non-null, then restore it
480 if (old_url != null)
481- message.set_uri(new Soup.URI(old_url));
482+ message.set_uri (new Soup.URI (old_url));
483 }
484 }
485
486- public string get_response() {
487- assert(get_is_executed());
488+ public string get_response () {
489+ assert (get_is_executed ());
490 return (string) message.response_body.data;
491 }
492-
493- public unowned Soup.MessageHeaders get_response_headers() {
494- assert(get_is_executed());
495+
496+ public unowned Soup.MessageHeaders get_response_headers () {
497+ assert (get_is_executed ());
498 return message.response_headers;
499 }
500-
501- public void add_argument(string name, string value) {
502- arguments += new Argument(name, value);
503- }
504-
505- public string? get_endpoint_url() {
506- return (endpoint_url != null) ? endpoint_url : parent_session.get_endpoint_url();
507- }
508-
509- public Session get_parent_session() {
510+
511+ public void add_argument (string name, string value) {
512+ arguments += new Argument (name, value);
513+ }
514+
515+ public string? get_endpoint_url () {
516+ return (endpoint_url != null) ? endpoint_url : parent_session.get_endpoint_url ();
517+ }
518+
519+ public Session get_parent_session () {
520 return parent_session;
521 }
522 }
523@@ -357,177 +357,177 @@
524 protected string mime_type;
525 protected Gee.HashMap<string, string> message_headers = null;
526
527- public UploadTransaction(Session session, Spit.Publishing.Publishable publishable) {
528+ public UploadTransaction (Session session, Spit.Publishing.Publishable publishable) {
529 base (session);
530 this.publishable = publishable;
531- this.mime_type = media_type_to_mime_type(publishable.get_media_type());
532-
533- binary_disposition_table = create_default_binary_disposition_table();
534-
535- message_headers = new Gee.HashMap<string, string>();
536+ this.mime_type = media_type_to_mime_type (publishable.get_media_type ());
537+
538+ binary_disposition_table = create_default_binary_disposition_table ();
539+
540+ message_headers = new Gee.HashMap<string, string> ();
541 }
542-
543- public UploadTransaction.with_endpoint_url(Session session,
544- Spit.Publishing.Publishable publishable, string endpoint_url) {
545- base.with_endpoint_url(session, endpoint_url);
546+
547+ public UploadTransaction.with_endpoint_url (Session session,
548+ Spit.Publishing.Publishable publishable, string endpoint_url) {
549+ base.with_endpoint_url (session, endpoint_url);
550 this.publishable = publishable;
551- this.mime_type = media_type_to_mime_type(publishable.get_media_type());
552-
553- binary_disposition_table = create_default_binary_disposition_table();
554-
555- message_headers = new Gee.HashMap<string, string>();
556- }
557-
558- protected override void add_header(string key, string value) {
559- message_headers.set(key, value);
560- }
561-
562- private static string media_type_to_mime_type(Spit.Publishing.Publisher.MediaType media_type) {
563+ this.mime_type = media_type_to_mime_type (publishable.get_media_type ());
564+
565+ binary_disposition_table = create_default_binary_disposition_table ();
566+
567+ message_headers = new Gee.HashMap<string, string> ();
568+ }
569+
570+ protected override void add_header (string key, string value) {
571+ message_headers.set (key, value);
572+ }
573+
574+ private static string media_type_to_mime_type (Spit.Publishing.Publisher.MediaType media_type) {
575 if (media_type == Spit.Publishing.Publisher.MediaType.PHOTO)
576 return "image/jpeg";
577 else if (media_type == Spit.Publishing.Publisher.MediaType.VIDEO)
578 return "video/mpeg";
579 else
580- error("UploadTransaction: unknown media type %s.", media_type.to_string());
581+ error ("UploadTransaction: unknown media type %s.", media_type.to_string ());
582 }
583
584- private GLib.HashTable<string, string> create_default_binary_disposition_table() {
585+ private GLib.HashTable<string, string> create_default_binary_disposition_table () {
586 GLib.HashTable<string, string> result =
587- new GLib.HashTable<string, string>(GLib.str_hash, GLib.str_equal);
588+ new GLib.HashTable<string, string> (GLib.str_hash, GLib.str_equal);
589
590- result.insert("filename", Soup.URI.encode(publishable.get_serialized_file().get_basename(),
591- null));
592+ result.insert ("filename", Soup.URI.encode (publishable.get_serialized_file ().get_basename (),
593+ null));
594
595 return result;
596 }
597
598- protected void set_binary_disposition_table(GLib.HashTable<string, string> new_disp_table) {
599+ protected void set_binary_disposition_table (GLib.HashTable<string, string> new_disp_table) {
600 binary_disposition_table = new_disp_table;
601 }
602
603- public override void execute() throws Spit.Publishing.PublishingError {
604- Argument[] request_arguments = get_arguments();
605- assert(request_arguments.length > 0);
606+ public override void execute () throws Spit.Publishing.PublishingError {
607+ Argument[] request_arguments = get_arguments ();
608+ assert (request_arguments.length > 0);
609
610- Soup.Multipart message_parts = new Soup.Multipart("multipart/form-data");
611+ Soup.Multipart message_parts = new Soup.Multipart ("multipart/form-data");
612
613 foreach (Argument arg in request_arguments)
614- message_parts.append_form_string(arg.key, arg.value);
615+ message_parts.append_form_string (arg.key, arg.value);
616
617 string payload;
618 size_t payload_length;
619 try {
620- FileUtils.get_contents(publishable.get_serialized_file().get_path(), out payload,
621- out payload_length);
622+ FileUtils.get_contents (publishable.get_serialized_file ().get_path (), out payload,
623+ out payload_length);
624 } catch (FileError e) {
625- throw new Spit.Publishing.PublishingError.LOCAL_FILE_ERROR(
626- _("A temporary file needed for publishing is unavailable"));
627+ throw new Spit.Publishing.PublishingError.LOCAL_FILE_ERROR (
628+ _ ("A temporary file needed for publishing is unavailable"));
629 }
630
631- int payload_part_num = message_parts.get_length();
632+ int payload_part_num = message_parts.get_length ();
633
634- Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.COPY, payload.data[0:payload_length]);
635- message_parts.append_form_file("", publishable.get_serialized_file().get_path(), mime_type,
636- bindable_data);
637+ Soup.Buffer bindable_data = new Soup.Buffer (Soup.MemoryUse.COPY, payload.data[0:payload_length]);
638+ message_parts.append_form_file ("", publishable.get_serialized_file ().get_path (), mime_type,
639+ bindable_data);
640
641 unowned Soup.MessageHeaders image_part_header;
642 unowned Soup.Buffer image_part_body;
643- message_parts.get_part(payload_part_num, out image_part_header, out image_part_body);
644- image_part_header.set_content_disposition("form-data", binary_disposition_table);
645+ message_parts.get_part (payload_part_num, out image_part_header, out image_part_body);
646+ image_part_header.set_content_disposition ("form-data", binary_disposition_table);
647
648 Soup.Message outbound_message =
649- soup_form_request_new_from_multipart(get_endpoint_url(), message_parts);
650+ soup_form_request_new_from_multipart (get_endpoint_url (), message_parts);
651 // TODO: there must be a better way to iterate over a map
652- Gee.MapIterator<string, string> i = message_headers.map_iterator();
653- bool cont = i.next();
654- while(cont) {
655- outbound_message.request_headers.append(i.get_key(), i.get_value());
656- cont = i.next();
657+ Gee.MapIterator<string, string> i = message_headers.map_iterator ();
658+ bool cont = i.next ();
659+ while (cont) {
660+ outbound_message.request_headers.append (i.get_key (), i.get_value ());
661+ cont = i.next ();
662 }
663- set_message(outbound_message);
664-
665- set_is_executed(true);
666- send();
667+ set_message (outbound_message);
668+
669+ set_is_executed (true);
670+ send ();
671 }
672 }
673
674 public class XmlDocument {
675- // Returns non-null string if an error condition is discovered in the XML (such as a well-known
676+ // Returns non-null string if an error condition is discovered in the XML (such as a well-known
677 // node). The string is used when generating a PublishingError exception. This delegate does
678 // not need to check for general-case malformed XML.
679- public delegate string? CheckForErrorResponse(XmlDocument doc);
680-
681- private Xml.Doc* document;
682-
683- private XmlDocument(Xml.Doc* doc) {
684+ public delegate string? CheckForErrorResponse (XmlDocument doc);
685+
686+ private Xml.Doc *document;
687+
688+ private XmlDocument (Xml.Doc *doc) {
689 document = doc;
690 }
691
692- ~RESTXmlDocument() {
693+ ~RESTXmlDocument () {
694 delete document;
695 }
696
697- public Xml.Node* get_root_node() {
698- return document->get_root_element();
699+ public Xml.Node *get_root_node () {
700+ return document->get_root_element ();
701 }
702
703- public Xml.Node* get_named_child(Xml.Node* parent, string child_name)
704- throws Spit.Publishing.PublishingError {
705- Xml.Node* doc_node_iter = parent->children;
706-
707+ public Xml.Node *get_named_child (Xml.Node *parent, string child_name)
708+ throws Spit.Publishing.PublishingError {
709+ Xml.Node *doc_node_iter = parent->children;
710+
711 for ( ; doc_node_iter != null; doc_node_iter = doc_node_iter->next) {
712 if (doc_node_iter->name == child_name)
713 return doc_node_iter;
714 }
715
716- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Can't find XML node %s",
717- child_name);
718+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("Can't find XML node %s",
719+ child_name);
720 }
721
722- public string get_property_value(Xml.Node* node, string property_key)
723- throws Spit.Publishing.PublishingError {
724- string value_string = node->get_prop(property_key);
725+ public string get_property_value (Xml.Node *node, string property_key)
726+ throws Spit.Publishing.PublishingError {
727+ string value_string = node->get_prop (property_key);
728 if (value_string == null)
729- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Can't find XML " +
730- "property %s on node %s", property_key, node->name);
731+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("Can't find XML " +
732+ "property %s on node %s", property_key, node->name);
733
734 return value_string;
735 }
736
737- public static XmlDocument parse_string(string? input_string,
738- CheckForErrorResponse check_for_error_response) throws Spit.Publishing.PublishingError {
739+ public static XmlDocument parse_string (string? input_string,
740+ CheckForErrorResponse check_for_error_response) throws Spit.Publishing.PublishingError {
741 if (input_string == null || input_string.length == 0)
742- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Empty XML string");
743+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("Empty XML string");
744
745 // Does this even start and end with the right characters?
746- if (!input_string.chug().chomp().has_prefix("<") ||
747- !input_string.chug().chomp().has_suffix(">")) {
748+ if (!input_string.chug ().chomp ().has_prefix ("<") ||
749+ !input_string.chug ().chomp ().has_suffix (">")) {
750 // Didn't start or end with a < or > and can't be parsed as XML - treat as malformed.
751- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Unable to parse XML " +
752- "document");
753+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("Unable to parse XML " +
754+ "document");
755 }
756
757 // Don't want blanks to be included as text nodes, and want the XML parser to tolerate
758 // tolerable XML
759- Xml.Doc* doc = Xml.Parser.read_memory(input_string, (int) input_string.length, null, null,
760- Xml.ParserOption.NOBLANKS | Xml.ParserOption.RECOVER);
761+ Xml.Doc *doc = Xml.Parser.read_memory (input_string, (int) input_string.length, null, null,
762+ Xml.ParserOption.NOBLANKS | Xml.ParserOption.RECOVER);
763 if (doc == null)
764- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Unable to parse XML " +
765- "document");
766+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("Unable to parse XML " +
767+ "document");
768
769 // Since 'doc' is the top level, if it has no children, something is wrong
770 // with the XML; we cannot continue normally here.
771 if (doc->children == null) {
772- throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Unable to parse XML " +
773- "document");
774+ throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE ("Unable to parse XML " +
775+ "document");
776 }
777-
778- XmlDocument rest_doc = new XmlDocument(doc);
779-
780- string? result = check_for_error_response(rest_doc);
781+
782+ XmlDocument rest_doc = new XmlDocument (doc);
783+
784+ string? result = check_for_error_response (rest_doc);
785 if (result != null)
786- throw new Spit.Publishing.PublishingError.SERVICE_ERROR("%s", result);
787-
788+ throw new Spit.Publishing.PublishingError.SERVICE_ERROR ("%s", result);
789+
790 return rest_doc;
791 }
792 }
793@@ -537,27 +537,27 @@
794 entities are encoded in short, symbolic names (e.g. "ñ" -> &ntilde;). Picasa Web Albums,
795 however, doesn't like symbolic encoding, and instead wants non-ASCII entities encoded directly
796 as their Unicode code point numbers (e.g. "ñ" -> &241;). */
797-public string decimal_entity_encode(string source) {
798- StringBuilder encoded_str_builder = new StringBuilder();
799+public string decimal_entity_encode (string source) {
800+ StringBuilder encoded_str_builder = new StringBuilder ();
801 string current_char = source;
802 while (true) {
803- int current_char_value = (int) (current_char.get_char_validated());
804-
805+ int current_char_value = (int) (current_char.get_char_validated ());
806+
807 // null character signals end of string
808 if (current_char_value < 1)
809 break;
810-
811+
812 // no need to escape ASCII characters except the ampersand, greater-than sign and less-than
813 // signs, which are special in the world of XML
814 if ((current_char_value < 128) && (current_char_value != '&') && (current_char_value != '<') &&
815- (current_char_value != '>'))
816- encoded_str_builder.append_unichar(current_char.get_char_validated());
817+ (current_char_value != '>'))
818+ encoded_str_builder.append_unichar (current_char.get_char_validated ());
819 else
820- encoded_str_builder.append("&#%d;".printf(current_char_value));
821+ encoded_str_builder.append ("&#%d;".printf (current_char_value));
822
823- current_char = current_char.next_char();
824+ current_char = current_char.next_char ();
825 }
826-
827+
828 return encoded_str_builder.str;
829 }
830
831@@ -565,22 +565,22 @@
832 private int current_file = 0;
833 private Spit.Publishing.Publishable[] publishables = null;
834 private Session session = null;
835- private unowned Spit.Publishing.ProgressCallback? status_updated = null;
836-
837- public signal void upload_complete(int num_photos_published);
838- public signal void upload_error(Spit.Publishing.PublishingError err);
839-
840- public BatchUploader(Session session, Spit.Publishing.Publishable[] publishables) {
841+ private unowned Spit.Publishing.ProgressCallback? status_updated = null;
842+
843+ public signal void upload_complete (int num_photos_published);
844+ public signal void upload_error (Spit.Publishing.PublishingError err);
845+
846+ public BatchUploader (Session session, Spit.Publishing.Publishable[] publishables) {
847 this.publishables = publishables;
848 this.session = session;
849 }
850
851- private void send_files() {
852+ private void send_files () {
853 current_file = 0;
854 bool stop = false;
855 foreach (Spit.Publishing.Publishable publishable in publishables) {
856- GLib.File? file = publishable.get_serialized_file();
857-
858+ GLib.File? file = publishable.get_serialized_file ();
859+
860 // if the current publishable hasn't been serialized, then skip it
861 if (file == null) {
862 current_file++;
863@@ -588,572 +588,572 @@
864 }
865
866 double fraction_complete = ((double) current_file) / publishables.length;
867- if (status_updated != null)
868- status_updated(current_file + 1, fraction_complete);
869-
870- Transaction txn = create_transaction(publishables[current_file]);
871-
872- txn.chunk_transmitted.connect(on_chunk_transmitted);
873-
874+ if (status_updated != null)
875+ status_updated (current_file + 1, fraction_complete);
876+
877+ Transaction txn = create_transaction (publishables[current_file]);
878+
879+ txn.chunk_transmitted.connect (on_chunk_transmitted);
880+
881 try {
882- txn.execute();
883+ txn.execute ();
884 } catch (Spit.Publishing.PublishingError err) {
885- upload_error(err);
886+ upload_error (err);
887 stop = true;
888 }
889-
890- txn.chunk_transmitted.disconnect(on_chunk_transmitted);
891-
892+
893+ txn.chunk_transmitted.disconnect (on_chunk_transmitted);
894+
895 if (stop)
896 break;
897-
898+
899 current_file++;
900 }
901-
902+
903 if (!stop)
904- upload_complete(current_file);
905+ upload_complete (current_file);
906 }
907-
908- private void on_chunk_transmitted(int bytes_written_so_far, int total_bytes) {
909+
910+ private void on_chunk_transmitted (int bytes_written_so_far, int total_bytes) {
911 double file_span = 1.0 / publishables.length;
912 double this_file_fraction_complete = ((double) bytes_written_so_far) / total_bytes;
913 double fraction_complete = (current_file * file_span) + (this_file_fraction_complete *
914- file_span);
915+ file_span);
916
917- if (status_updated != null)
918- status_updated(current_file + 1, fraction_complete);
919+ if (status_updated != null)
920+ status_updated (current_file + 1, fraction_complete);
921 }
922-
923- protected Session get_session() {
924+
925+ protected Session get_session () {
926 return session;
927 }
928-
929- protected Spit.Publishing.Publishable get_current_publishable() {
930+
931+ protected Spit.Publishing.Publishable get_current_publishable () {
932 return publishables[current_file];
933 }
934-
935- protected abstract Transaction create_transaction(Spit.Publishing.Publishable publishable);
936-
937- public void upload(Spit.Publishing.ProgressCallback? status_updated = null) {
938+
939+ protected abstract Transaction create_transaction (Spit.Publishing.Publishable publishable);
940+
941+ public void upload (Spit.Publishing.ProgressCallback? status_updated = null) {
942 this.status_updated = status_updated;
943
944 if (publishables.length > 0)
945- send_files();
946+ send_files ();
947 }
948 }
949
950 // Remove diacritics in a string, yielding ASCII. If the given string is in
951 // a character set not based on Latin letters (e.g. Cyrillic), the result
952 // may be empty.
953-public string asciify_string(string s) {
954- string t = s.normalize(); // default normalization yields a maximally decomposed form
955-
956- StringBuilder b = new StringBuilder();
957- for (unowned string u = t; u.get_char() != 0 ; u = u.next_char()) {
958- unichar c = u.get_char();
959+public string asciify_string (string s) {
960+ string t = s.normalize (); // default normalization yields a maximally decomposed form
961+
962+ StringBuilder b = new StringBuilder ();
963+ for (unowned string u = t; u.get_char () != 0 ; u = u.next_char ()) {
964+ unichar c = u.get_char ();
965 if ((int) c < 128)
966- b.append_unichar(c);
967+ b.append_unichar (c);
968 }
969-
970+
971 return b.str;
972 }
973
974 /** @brief Work-around for a problem in libgee where a TreeSet can leak references when it
975 * goes out of scope; please see https://bugzilla.gnome.org/show_bug.cgi?id=695045 for more
976- * details. This class merely wraps it and adds a call to clear() to the destructor.
977+ * details. This class merely wraps it and adds a call to clear () to the destructor.
978 */
979 public class FixedTreeSet<G> : Gee.TreeSet<G> {
980- public FixedTreeSet(owned CompareDataFunc<G>? comp_func = null) {
981- base((owned) comp_func);
982+ public FixedTreeSet (owned CompareDataFunc<G>? comp_func = null) {
983+ base ((owned) comp_func);
984 }
985-
986- ~FixedTreeSet() {
987- clear();
988+
989+ ~FixedTreeSet () {
990+ clear ();
991 }
992 }
993
994 public abstract class GoogleSession : Session {
995- public abstract string get_user_name();
996- public abstract string get_access_token();
997- public abstract string get_refresh_token();
998- public abstract void deauthenticate();
999+ public abstract string get_user_name ();
1000+ public abstract string get_access_token ();
1001+ public abstract string get_refresh_token ();
1002+ public abstract void deauthenticate ();
1003 }
1004
1005 public abstract class GooglePublisher : Object, Spit.Publishing.Publisher {
1006 private const string OAUTH_CLIENT_ID = "1073902228337-gm4uf5etk25s0hnnm0g7uv2tm2bm1j0b.apps.googleusercontent.com";
1007 private const string OAUTH_CLIENT_SECRET = "_kA4RZz72xqed4DqfO7xMmMN";
1008-
1009+
1010 private class GoogleSessionImpl : GoogleSession {
1011 public string? access_token;
1012 public string? user_name;
1013 public string? refresh_token;
1014-
1015- public GoogleSessionImpl() {
1016+
1017+ public GoogleSessionImpl () {
1018 this.access_token = null;
1019 this.user_name = null;
1020 this.refresh_token = null;
1021 }
1022-
1023- public override bool is_authenticated() {
1024+
1025+ public override bool is_authenticated () {
1026 return (access_token != null);
1027 }
1028-
1029- public override string get_user_name() {
1030+
1031+ public override string get_user_name () {
1032 assert (user_name != null);
1033 return user_name;
1034 }
1035-
1036- public override string get_access_token() {
1037- assert(is_authenticated());
1038+
1039+ public override string get_access_token () {
1040+ assert (is_authenticated ());
1041 return access_token;
1042 }
1043-
1044- public override string get_refresh_token() {
1045- assert(refresh_token != null);
1046+
1047+ public override string get_refresh_token () {
1048+ assert (refresh_token != null);
1049 return refresh_token;
1050 }
1051-
1052- public override void deauthenticate() {
1053+
1054+ public override void deauthenticate () {
1055 access_token = null;
1056 user_name = null;
1057 refresh_token = null;
1058 }
1059 }
1060-
1061+
1062 private class WebAuthenticationPane : Spit.Publishing.DialogPane, Object {
1063 public static bool cache_dirty = false;
1064-
1065+
1066 private WebKit.WebView webview;
1067 private Gtk.Box pane_widget;
1068 private Gtk.ScrolledWindow webview_frame;
1069 private string auth_sequence_start_url;
1070
1071- public signal void authorized(string auth_code);
1072+ public signal void authorized (string auth_code);
1073
1074- public WebAuthenticationPane(string auth_sequence_start_url) {
1075+ public WebAuthenticationPane (string auth_sequence_start_url) {
1076 this.auth_sequence_start_url = auth_sequence_start_url;
1077
1078- pane_widget = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
1079-
1080- webview_frame = new Gtk.ScrolledWindow(null, null);
1081- webview_frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN);
1082- webview_frame.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1083-
1084- webview = new WebKit.WebView();
1085- webview.get_settings().enable_plugins = false;
1086- webview.get_settings().enable_default_context_menu = false;
1087-
1088- webview.load_finished.connect(on_page_load);
1089- webview.load_started.connect(on_load_started);
1090-
1091- webview_frame.add(webview);
1092- pane_widget.pack_start(webview_frame, true, true, 0);
1093+ pane_widget = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
1094+
1095+ webview_frame = new Gtk.ScrolledWindow (null, null);
1096+ webview_frame.set_shadow_type (Gtk.ShadowType.ETCHED_IN);
1097+ webview_frame.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1098+
1099+ webview = new WebKit.WebView ();
1100+ webview.get_settings ().enable_plugins = false;
1101+ webview.get_settings ().enable_default_context_menu = false;
1102+
1103+ webview.load_finished.connect (on_page_load);
1104+ webview.load_started.connect (on_load_started);
1105+
1106+ webview_frame.add (webview);
1107+ pane_widget.pack_start (webview_frame, true, true, 0);
1108 }
1109-
1110- public static bool is_cache_dirty() {
1111+
1112+ public static bool is_cache_dirty () {
1113 return cache_dirty;
1114 }
1115-
1116- private void on_page_load(WebKit.WebFrame origin_frame) {
1117- pane_widget.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR));
1118-
1119- string page_title = webview.get_title();
1120- if (page_title.index_of("state=connect") > 0) {
1121- int auth_code_field_start = page_title.index_of("code=");
1122+
1123+ private void on_page_load (WebKit.WebFrame origin_frame) {
1124+ pane_widget.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.LEFT_PTR));
1125+
1126+ string page_title = webview.get_title ();
1127+ if (page_title.index_of ("state=connect") > 0) {
1128+ int auth_code_field_start = page_title.index_of ("code=");
1129 if (auth_code_field_start < 0)
1130 return;
1131
1132 string auth_code =
1133- page_title.substring(auth_code_field_start + 5); // 5 = "code=".length
1134+ page_title.substring (auth_code_field_start + 5); // 5 = "code=".length
1135
1136 cache_dirty = true;
1137
1138- authorized(auth_code);
1139+ authorized (auth_code);
1140 }
1141 }
1142
1143- private void on_load_started(WebKit.WebFrame frame) {
1144- pane_widget.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.WATCH));
1145+ private void on_load_started (WebKit.WebFrame frame) {
1146+ pane_widget.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
1147 }
1148-
1149- public Spit.Publishing.DialogPane.GeometryOptions get_preferred_geometry() {
1150+
1151+ public Spit.Publishing.DialogPane.GeometryOptions get_preferred_geometry () {
1152 return Spit.Publishing.DialogPane.GeometryOptions.NONE;
1153 }
1154-
1155- public Gtk.Widget get_widget() {
1156+
1157+ public Gtk.Widget get_widget () {
1158 return pane_widget;
1159 }
1160
1161- public void on_pane_installed() {
1162- webview.open(auth_sequence_start_url);
1163+ public void on_pane_installed () {
1164+ webview.open (auth_sequence_start_url);
1165 }
1166
1167- public void on_pane_uninstalled() {
1168+ public void on_pane_uninstalled () {
1169 }
1170 }
1171-
1172+
1173 private class GetAccessTokensTransaction : Publishing.RESTSupport.Transaction {
1174 private const string ENDPOINT_URL = "https://accounts.google.com/o/oauth2/token";
1175-
1176- public GetAccessTokensTransaction(Session session, string auth_code) {
1177- base.with_endpoint_url(session, ENDPOINT_URL);
1178-
1179- add_argument("code", auth_code);
1180- add_argument("client_id", OAUTH_CLIENT_ID);
1181- add_argument("client_secret", OAUTH_CLIENT_SECRET);
1182- add_argument("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
1183- add_argument("grant_type", "authorization_code");
1184+
1185+ public GetAccessTokensTransaction (Session session, string auth_code) {
1186+ base.with_endpoint_url (session, ENDPOINT_URL);
1187+
1188+ add_argument ("code", auth_code);
1189+ add_argument ("client_id", OAUTH_CLIENT_ID);
1190+ add_argument ("client_secret", OAUTH_CLIENT_SECRET);
1191+ add_argument ("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
1192+ add_argument ("grant_type", "authorization_code");
1193 }
1194 }
1195
1196 private class RefreshAccessTokenTransaction : Publishing.RESTSupport.Transaction {
1197 private const string ENDPOINT_URL = "https://accounts.google.com/o/oauth2/token";
1198-
1199- public RefreshAccessTokenTransaction(Session session) {
1200- base.with_endpoint_url(session, ENDPOINT_URL);
1201-
1202- add_argument("client_id", OAUTH_CLIENT_ID);
1203- add_argument("client_secret", OAUTH_CLIENT_SECRET);
1204- add_argument("refresh_token", ((GoogleSession) session).get_refresh_token());
1205- add_argument("grant_type", "refresh_token");
1206+
1207+ public RefreshAccessTokenTransaction (Session session) {
1208+ base.with_endpoint_url (session, ENDPOINT_URL);
1209+
1210+ add_argument ("client_id", OAUTH_CLIENT_ID);
1211+ add_argument ("client_secret", OAUTH_CLIENT_SECRET);
1212+ add_argument ("refresh_token", ((GoogleSession) session).get_refresh_token ());
1213+ add_argument ("grant_type", "refresh_token");
1214 }
1215 }
1216
1217 public class AuthenticatedTransaction : Publishing.RESTSupport.Transaction {
1218- private AuthenticatedTransaction.with_endpoint_url(GoogleSession session,
1219- string endpoint_url, Publishing.RESTSupport.HttpMethod method) {
1220- base.with_endpoint_url(session, endpoint_url, method);
1221+ private AuthenticatedTransaction.with_endpoint_url (GoogleSession session,
1222+ string endpoint_url, Publishing.RESTSupport.HttpMethod method) {
1223+ base.with_endpoint_url (session, endpoint_url, method);
1224 }
1225
1226- public AuthenticatedTransaction(GoogleSession session, string endpoint_url,
1227- Publishing.RESTSupport.HttpMethod method) {
1228- base.with_endpoint_url(session, endpoint_url, method);
1229- assert(session.is_authenticated());
1230+ public AuthenticatedTransaction (GoogleSession session, string endpoint_url,
1231+ Publishing.RESTSupport.HttpMethod method) {
1232+ base.with_endpoint_url (session, endpoint_url, method);
1233+ assert (session.is_authenticated ());
1234
1235- add_header("Authorization", "Bearer " + session.get_access_token());
1236+ add_header ("Authorization", "Bearer " + session.get_access_token ());
1237 }
1238 }
1239
1240 private class UsernameFetchTransaction : AuthenticatedTransaction {
1241 private const string ENDPOINT_URL = "https://www.googleapis.com/oauth2/v1/userinfo";
1242-
1243- public UsernameFetchTransaction(GoogleSession session) {
1244- base(session, ENDPOINT_URL, Publishing.RESTSupport.HttpMethod.GET);
1245+
1246+ public UsernameFetchTransaction (GoogleSession session) {
1247+ base (session, ENDPOINT_URL, Publishing.RESTSupport.HttpMethod.GET);
1248 }
1249 }
1250-
1251+
1252 private string scope;
1253 private GoogleSessionImpl session;
1254 private WebAuthenticationPane? web_auth_pane;
1255 private weak Spit.Publishing.PluginHost host;
1256 private weak Spit.Publishing.Service service;
1257-
1258- protected GooglePublisher(Spit.Publishing.Service service, Spit.Publishing.PluginHost host,
1259- string scope) {
1260+
1261+ protected GooglePublisher (Spit.Publishing.Service service, Spit.Publishing.PluginHost host,
1262+ string scope) {
1263 this.scope = scope;
1264- this.session = new GoogleSessionImpl();
1265+ this.session = new GoogleSessionImpl ();
1266 this.service = service;
1267 this.host = host;
1268 this.web_auth_pane = null;
1269 }
1270-
1271- private void on_web_auth_pane_authorized(string auth_code) {
1272- web_auth_pane.authorized.disconnect(on_web_auth_pane_authorized);
1273-
1274- debug("EVENT: user authorized scope %s with auth_code %s", scope, auth_code);
1275-
1276- if (!is_running())
1277- return;
1278-
1279- do_get_access_tokens(auth_code);
1280- }
1281-
1282- private void on_get_access_tokens_complete(Publishing.RESTSupport.Transaction txn) {
1283- txn.completed.disconnect(on_get_access_tokens_complete);
1284- txn.network_error.disconnect(on_get_access_tokens_error);
1285-
1286- debug("EVENT: network transaction to exchange authorization code for access tokens " +
1287- "completed successfully.");
1288-
1289- if (!is_running())
1290- return;
1291-
1292- do_extract_tokens(txn.get_response());
1293- }
1294-
1295- private void on_get_access_tokens_error(Publishing.RESTSupport.Transaction txn,
1296- Spit.Publishing.PublishingError err) {
1297- txn.completed.disconnect(on_get_access_tokens_complete);
1298- txn.network_error.disconnect(on_get_access_tokens_error);
1299-
1300- debug("EVENT: network transaction to exchange authorization code for access tokens " +
1301- "failed; response = '%s'", txn.get_response());
1302-
1303- if (!is_running())
1304- return;
1305-
1306- host.post_error(err);
1307- }
1308-
1309- private void on_refresh_access_token_transaction_completed(Publishing.RESTSupport.Transaction
1310- txn) {
1311- txn.completed.disconnect(on_refresh_access_token_transaction_completed);
1312- txn.network_error.disconnect(on_refresh_access_token_transaction_error);
1313-
1314- debug("EVENT: refresh access token transaction completed successfully.");
1315-
1316- if (!is_running())
1317- return;
1318-
1319- if (session.is_authenticated()) // ignore these events if the session is already auth'd
1320- return;
1321-
1322- do_extract_tokens(txn.get_response());
1323- }
1324-
1325- private void on_refresh_access_token_transaction_error(Publishing.RESTSupport.Transaction txn,
1326- Spit.Publishing.PublishingError err) {
1327- txn.completed.disconnect(on_refresh_access_token_transaction_completed);
1328- txn.network_error.disconnect(on_refresh_access_token_transaction_error);
1329-
1330- debug("EVENT: refresh access token transaction caused a network error.");
1331-
1332- if (!is_running())
1333- return;
1334-
1335- if (session.is_authenticated()) // ignore these events if the session is already auth'd
1336- return;
1337-
1338+
1339+ private void on_web_auth_pane_authorized (string auth_code) {
1340+ web_auth_pane.authorized.disconnect (on_web_auth_pane_authorized);
1341+
1342+ debug ("EVENT: user authorized scope %s with auth_code %s", scope, auth_code);
1343+
1344+ if (!is_running ())
1345+ return;
1346+
1347+ do_get_access_tokens (auth_code);
1348+ }
1349+
1350+ private void on_get_access_tokens_complete (Publishing.RESTSupport.Transaction txn) {
1351+ txn.completed.disconnect (on_get_access_tokens_complete);
1352+ txn.network_error.disconnect (on_get_access_tokens_error);
1353+
1354+ debug ("EVENT: network transaction to exchange authorization code for access tokens " +
1355+ "completed successfully.");
1356+
1357+ if (!is_running ())
1358+ return;
1359+
1360+ do_extract_tokens (txn.get_response ());
1361+ }
1362+
1363+ private void on_get_access_tokens_error (Publishing.RESTSupport.Transaction txn,
1364+ Spit.Publishing.PublishingError err) {
1365+ txn.completed.disconnect (on_get_access_tokens_complete);
1366+ txn.network_error.disconnect (on_get_access_tokens_error);
1367+
1368+ debug ("EVENT: network transaction to exchange authorization code for access tokens " +
1369+ "failed; response = '%s'", txn.get_response ());
1370+
1371+ if (!is_running ())
1372+ return;
1373+
1374+ host.post_error (err);
1375+ }
1376+
1377+ private void on_refresh_access_token_transaction_completed (Publishing.RESTSupport.Transaction
1378+ txn) {
1379+ txn.completed.disconnect (on_refresh_access_token_transaction_completed);
1380+ txn.network_error.disconnect (on_refresh_access_token_transaction_error);
1381+
1382+ debug ("EVENT: refresh access token transaction completed successfully.");
1383+
1384+ if (!is_running ())
1385+ return;
1386+
1387+ if (session.is_authenticated ()) // ignore these events if the session is already auth'd
1388+ return;
1389+
1390+ do_extract_tokens (txn.get_response ());
1391+ }
1392+
1393+ private void on_refresh_access_token_transaction_error (Publishing.RESTSupport.Transaction txn,
1394+ Spit.Publishing.PublishingError err) {
1395+ txn.completed.disconnect (on_refresh_access_token_transaction_completed);
1396+ txn.network_error.disconnect (on_refresh_access_token_transaction_error);
1397+
1398+ debug ("EVENT: refresh access token transaction caused a network error.");
1399+
1400+ if (!is_running ())
1401+ return;
1402+
1403+ if (session.is_authenticated ()) // ignore these events if the session is already auth'd
1404+ return;
1405+
1406 // 400 errors indicate that the OAuth client ID and secret have become invalid. In most
1407 // cases, this can be fixed by logging the user out
1408- if (txn.get_status_code() == 400) {
1409- do_logout();
1410+ if (txn.get_status_code () == 400) {
1411+ do_logout ();
1412 return;
1413 }
1414-
1415- host.post_error(err);
1416+
1417+ host.post_error (err);
1418 }
1419
1420- private void on_refresh_token_available(string token) {
1421- debug("EVENT: an OAuth refresh token has become available; token = '%s'.", token);
1422+ private void on_refresh_token_available (string token) {
1423+ debug ("EVENT: an OAuth refresh token has become available; token = '%s'.", token);
1424
1425- if (!is_running())
1426+ if (!is_running ())
1427 return;
1428
1429 session.refresh_token = token;
1430 }
1431-
1432- private void on_access_token_available(string token) {
1433- debug("EVENT: an OAuth access token has become available; token = '%s'.", token);
1434-
1435- if (!is_running())
1436+
1437+ private void on_access_token_available (string token) {
1438+ debug ("EVENT: an OAuth access token has become available; token = '%s'.", token);
1439+
1440+ if (!is_running ())
1441 return;
1442
1443 session.access_token = token;
1444-
1445- do_fetch_username();
1446- }
1447-
1448- private void on_fetch_username_transaction_completed(Publishing.RESTSupport.Transaction txn) {
1449- txn.completed.disconnect(on_fetch_username_transaction_completed);
1450- txn.network_error.disconnect(on_fetch_username_transaction_error);
1451-
1452- debug("EVENT: username fetch transaction completed successfully.");
1453-
1454- if (!is_running())
1455- return;
1456-
1457- do_extract_username(txn.get_response());
1458- }
1459-
1460- private void on_fetch_username_transaction_error(Publishing.RESTSupport.Transaction txn,
1461- Spit.Publishing.PublishingError err) {
1462- txn.completed.disconnect(on_fetch_username_transaction_completed);
1463- txn.network_error.disconnect(on_fetch_username_transaction_error);
1464-
1465- debug("EVENT: username fetch transaction caused a network error");
1466-
1467- if (!is_running())
1468- return;
1469-
1470- host.post_error(err);
1471- }
1472-
1473- private void do_get_access_tokens(string auth_code) {
1474- debug("ACTION: exchanging authorization code for access & refresh tokens");
1475-
1476- host.install_login_wait_pane();
1477-
1478- GetAccessTokensTransaction tokens_txn = new GetAccessTokensTransaction(session, auth_code);
1479- tokens_txn.completed.connect(on_get_access_tokens_complete);
1480- tokens_txn.network_error.connect(on_get_access_tokens_error);
1481-
1482+
1483+ do_fetch_username ();
1484+ }
1485+
1486+ private void on_fetch_username_transaction_completed (Publishing.RESTSupport.Transaction txn) {
1487+ txn.completed.disconnect (on_fetch_username_transaction_completed);
1488+ txn.network_error.disconnect (on_fetch_username_transaction_error);
1489+
1490+ debug ("EVENT: username fetch transaction completed successfully.");
1491+
1492+ if (!is_running ())
1493+ return;
1494+
1495+ do_extract_username (txn.get_response ());
1496+ }
1497+
1498+ private void on_fetch_username_transaction_error (Publishing.RESTSupport.Transaction txn,
1499+ Spit.Publishing.PublishingError err) {
1500+ txn.completed.disconnect (on_fetch_username_transaction_completed);
1501+ txn.network_error.disconnect (on_fetch_username_transaction_error);
1502+
1503+ debug ("EVENT: username fetch transaction caused a network error");
1504+
1505+ if (!is_running ())
1506+ return;
1507+
1508+ host.post_error (err);
1509+ }
1510+
1511+ private void do_get_access_tokens (string auth_code) {
1512+ debug ("ACTION: exchanging authorization code for access & refresh tokens");
1513+
1514+ host.install_login_wait_pane ();
1515+
1516+ GetAccessTokensTransaction tokens_txn = new GetAccessTokensTransaction (session, auth_code);
1517+ tokens_txn.completed.connect (on_get_access_tokens_complete);
1518+ tokens_txn.network_error.connect (on_get_access_tokens_error);
1519+
1520 try {
1521- tokens_txn.execute();
1522+ tokens_txn.execute ();
1523 } catch (Spit.Publishing.PublishingError err) {
1524- host.post_error(err);
1525+ host.post_error (err);
1526 }
1527 }
1528-
1529- private void do_hosted_web_authentication() {
1530- debug("ACTION: running OAuth authentication flow in hosted web pane.");
1531-
1532+
1533+ private void do_hosted_web_authentication () {
1534+ debug ("ACTION: running OAuth authentication flow in hosted web pane.");
1535+
1536 string user_authorization_url = "https://accounts.google.com/o/oauth2/auth?" +
1537- "response_type=code&" +
1538- "client_id=" + OAUTH_CLIENT_ID + "&" +
1539- "redirect_uri=" + Soup.URI.encode("urn:ietf:wg:oauth:2.0:oob", null) + "&" +
1540- "scope=" + Soup.URI.encode(scope, null) + "+" +
1541- Soup.URI.encode("https://www.googleapis.com/auth/userinfo.profile", null) + "&" +
1542- "state=connect&" +
1543- "access_type=offline&" +
1544- "approval_prompt=force";
1545-
1546- web_auth_pane = new WebAuthenticationPane(user_authorization_url);
1547- web_auth_pane.authorized.connect(on_web_auth_pane_authorized);
1548-
1549- host.install_dialog_pane(web_auth_pane);
1550-
1551+ "response_type=code&" +
1552+ "client_id=" + OAUTH_CLIENT_ID + "&" +
1553+ "redirect_uri=" + Soup.URI.encode ("urn:ietf:wg:oauth:2.0:oob", null) + "&" +
1554+ "scope=" + Soup.URI.encode (scope, null) + "+" +
1555+ Soup.URI.encode ("https://www.googleapis.com/auth/userinfo.profile", null) + "&" +
1556+ "state=connect&" +
1557+ "access_type=offline&" +
1558+ "approval_prompt=force";
1559+
1560+ web_auth_pane = new WebAuthenticationPane (user_authorization_url);
1561+ web_auth_pane.authorized.connect (on_web_auth_pane_authorized);
1562+
1563+ host.install_dialog_pane (web_auth_pane);
1564+
1565 }
1566
1567- private void do_exchange_refresh_token_for_access_token() {
1568- debug("ACTION: exchanging OAuth refresh token for OAuth access token.");
1569-
1570- host.install_login_wait_pane();
1571-
1572- RefreshAccessTokenTransaction txn = new RefreshAccessTokenTransaction(session);
1573-
1574- txn.completed.connect(on_refresh_access_token_transaction_completed);
1575- txn.network_error.connect(on_refresh_access_token_transaction_error);
1576-
1577+ private void do_exchange_refresh_token_for_access_token () {
1578+ debug ("ACTION: exchanging OAuth refresh token for OAuth access token.");
1579+
1580+ host.install_login_wait_pane ();
1581+
1582+ RefreshAccessTokenTransaction txn = new RefreshAccessTokenTransaction (session);
1583+
1584+ txn.completed.connect (on_refresh_access_token_transaction_completed);
1585+ txn.network_error.connect (on_refresh_access_token_transaction_error);
1586+
1587 try {
1588- txn.execute();
1589+ txn.execute ();
1590 } catch (Spit.Publishing.PublishingError err) {
1591- host.post_error(err);
1592+ host.post_error (err);
1593 }
1594 }
1595
1596- private void do_extract_tokens(string response_body) {
1597- debug("ACTION: extracting OAuth tokens from body of server response");
1598-
1599- Json.Parser parser = new Json.Parser();
1600-
1601+ private void do_extract_tokens (string response_body) {
1602+ debug ("ACTION: extracting OAuth tokens from body of server response");
1603+
1604+ Json.Parser parser = new Json.Parser ();
1605+
1606 try {
1607- parser.load_from_data(response_body);
1608+ parser.load_from_data (response_body);
1609 } catch (Error err) {
1610- host.post_error(new Spit.Publishing.PublishingError.MALFORMED_RESPONSE(
1611- "Couldn't parse JSON response: " + err.message));
1612- return;
1613- }
1614-
1615- Json.Object response_obj = parser.get_root().get_object();
1616-
1617- if ((!response_obj.has_member("access_token")) && (!response_obj.has_member("refresh_token"))) {
1618- host.post_error(new Spit.Publishing.PublishingError.MALFORMED_RESPONSE(
1619- "neither access_token nor refresh_token not present in server response"));
1620- return;
1621- }
1622-
1623- if (response_obj.has_member("refresh_token")) {
1624- string refresh_token = response_obj.get_string_member("refresh_token");
1625+ host.post_error (new Spit.Publishing.PublishingError.MALFORMED_RESPONSE (
1626+ "Couldn't parse JSON response: " + err.message));
1627+ return;
1628+ }
1629+
1630+ Json.Object response_obj = parser.get_root ().get_object ();
1631+
1632+ if ((!response_obj.has_member ("access_token")) && (!response_obj.has_member ("refresh_token"))) {
1633+ host.post_error (new Spit.Publishing.PublishingError.MALFORMED_RESPONSE (
1634+ "neither access_token nor refresh_token not present in server response"));
1635+ return;
1636+ }
1637+
1638+ if (response_obj.has_member ("refresh_token")) {
1639+ string refresh_token = response_obj.get_string_member ("refresh_token");
1640
1641 if (refresh_token != "")
1642- on_refresh_token_available(refresh_token);
1643+ on_refresh_token_available (refresh_token);
1644 }
1645-
1646- if (response_obj.has_member("access_token")) {
1647- string access_token = response_obj.get_string_member("access_token");
1648+
1649+ if (response_obj.has_member ("access_token")) {
1650+ string access_token = response_obj.get_string_member ("access_token");
1651
1652 if (access_token != "")
1653- on_access_token_available(access_token);
1654- }
1655- }
1656-
1657- private void do_fetch_username() {
1658- debug("ACTION: running network transaction to fetch username.");
1659-
1660- host.install_login_wait_pane();
1661- host.set_service_locked(true);
1662-
1663- UsernameFetchTransaction txn = new UsernameFetchTransaction(session);
1664- txn.completed.connect(on_fetch_username_transaction_completed);
1665- txn.network_error.connect(on_fetch_username_transaction_error);
1666-
1667- try {
1668- txn.execute();
1669- } catch (Error err) {
1670- host.post_error(err);
1671- }
1672- }
1673-
1674- private void do_extract_username(string response_body) {
1675- debug("ACTION: extracting username from body of server response");
1676-
1677- Json.Parser parser = new Json.Parser();
1678-
1679- try {
1680- parser.load_from_data(response_body);
1681- } catch (Error err) {
1682- host.post_error(new Spit.Publishing.PublishingError.MALFORMED_RESPONSE(
1683- "Couldn't parse JSON response: " + err.message));
1684+ on_access_token_available (access_token);
1685+ }
1686+ }
1687+
1688+ private void do_fetch_username () {
1689+ debug ("ACTION: running network transaction to fetch username.");
1690+
1691+ host.install_login_wait_pane ();
1692+ host.set_service_locked (true);
1693+
1694+ UsernameFetchTransaction txn = new UsernameFetchTransaction (session);
1695+ txn.completed.connect (on_fetch_username_transaction_completed);
1696+ txn.network_error.connect (on_fetch_username_transaction_error);
1697+
1698+ try {
1699+ txn.execute ();
1700+ } catch (Error err) {
1701+ host.post_error (err);
1702+ }
1703+ }
1704+
1705+ private void do_extract_username (string response_body) {
1706+ debug ("ACTION: extracting username from body of server response");
1707+
1708+ Json.Parser parser = new Json.Parser ();
1709+
1710+ try {
1711+ parser.load_from_data (response_body);
1712+ } catch (Error err) {
1713+ host.post_error (new Spit.Publishing.PublishingError.MALFORMED_RESPONSE (
1714+ "Couldn't parse JSON response: " + err.message));
1715 return;
1716 }
1717-
1718- Json.Object response_obj = parser.get_root().get_object();
1719-
1720- if (response_obj.has_member("name")) {
1721- string username = response_obj.get_string_member("name");
1722+
1723+ Json.Object response_obj = parser.get_root ().get_object ();
1724+
1725+ if (response_obj.has_member ("name")) {
1726+ string username = response_obj.get_string_member ("name");
1727
1728 if (username != "")
1729 session.user_name = username;
1730 }
1731-
1732- if (response_obj.has_member("access_token")) {
1733- string access_token = response_obj.get_string_member("access_token");
1734+
1735+ if (response_obj.has_member ("access_token")) {
1736+ string access_token = response_obj.get_string_member ("access_token");
1737
1738 if (access_token != "")
1739 session.access_token = access_token;
1740 }
1741-
1742+
1743 // by the time we get a username, the session should be authenticated, or else something
1744 // really tragic has happened
1745- assert(session.is_authenticated());
1746-
1747- on_login_flow_complete();
1748+ assert (session.is_authenticated ());
1749+
1750+ on_login_flow_complete ();
1751 }
1752
1753- protected unowned Spit.Publishing.PluginHost get_host() {
1754+ protected unowned Spit.Publishing.PluginHost get_host () {
1755 return host;
1756 }
1757
1758- protected GoogleSession get_session() {
1759+ protected GoogleSession get_session () {
1760 return session;
1761 }
1762
1763- protected void start_oauth_flow(string? refresh_token = null) {
1764+ protected void start_oauth_flow (string? refresh_token = null) {
1765 if (refresh_token != null && refresh_token != "") {
1766 session.refresh_token = refresh_token;
1767- do_exchange_refresh_token_for_access_token();
1768+ do_exchange_refresh_token_for_access_token ();
1769 } else {
1770- if (WebAuthenticationPane.is_cache_dirty()) {
1771- host.install_static_message_pane(_("You have already logged in and out of a Google service during this Shotwell session.\n\nTo continue publishing to Google services, quit and restart Shotwell, then try publishing again."));
1772+ if (WebAuthenticationPane.is_cache_dirty ()) {
1773+ host.install_static_message_pane (_ ("You have already logged in and out of a Google service during this Shotwell session.\n\nTo continue publishing to Google services, quit and restart Shotwell, then try publishing again."));
1774 return;
1775 }
1776
1777- do_hosted_web_authentication();
1778+ do_hosted_web_authentication ();
1779 }
1780 }
1781-
1782- protected abstract void on_login_flow_complete();
1783-
1784- protected abstract void do_logout();
1785-
1786- public abstract bool is_running();
1787-
1788- public abstract void start();
1789-
1790- public abstract void stop();
1791-
1792- public Spit.Publishing.Service get_service() {
1793+
1794+ protected abstract void on_login_flow_complete ();
1795+
1796+ protected abstract void do_logout ();
1797+
1798+ public abstract bool is_running ();
1799+
1800+ public abstract void start ();
1801+
1802+ public abstract void stop ();
1803+
1804+ public Spit.Publishing.Service get_service () {
1805 return service;
1806 }
1807 }
1808
1809=== modified file 'plugins/common/Resources.vala'
1810--- plugins/common/Resources.vala 2013-01-21 21:16:09 +0000
1811+++ plugins/common/Resources.vala 2014-08-08 21:16:43 +0000
1812@@ -6,26 +6,26 @@
1813
1814 namespace Resources {
1815
1816-public const string WEBSITE_NAME = _("Visit the Yorba web site");
1817+public const string WEBSITE_NAME = _ ("Visit the Yorba web site");
1818 public const string WEBSITE_URL = "http://www.yorba.org";
1819
1820 public const string LICENSE = """
1821-Shotwell is free software; you can redistribute it and/or modify it under the
1822-terms of the GNU Lesser General Public License as published by the Free
1823-Software Foundation; either version 2.1 of the License, or (at your option)
1824-any later version.
1825-
1826-Shotwell is distributed in the hope that it will be useful, but WITHOUT
1827-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1828-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
1829-more details.
1830-
1831-You should have received a copy of the GNU Lesser General Public License
1832-along with Shotwell; if not, write to the Free Software Foundation, Inc.,
1833-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1834-""";
1835-
1836-public const string TRANSLATORS = _("translator-credits");
1837+ Shotwell is free software; you can redistribute it and/or modify it under the
1838+ terms of the GNU Lesser General Public License as published by the Free
1839+ Software Foundation; either version 2.1 of the License, or (at your option)
1840+ any later version.
1841+
1842+ Shotwell is distributed in the hope that it will be useful, but WITHOUT
1843+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1844+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
1845+ more details.
1846+
1847+ You should have received a copy of the GNU Lesser General Public License
1848+ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
1849+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1850+ """;
1851+
1852+public const string TRANSLATORS = _ ("translator-credits");
1853
1854 // TODO: modify to load multiple icons
1855 //
1856@@ -34,20 +34,20 @@
1857 // pretty common in the GNOME world), then this function can be modified to load an entire icon
1858 // set without its interface needing to change, since given one icon filename, we can
1859 // determine the others.
1860-public Gdk.Pixbuf[]? load_icon_set(GLib.File? icon_file) {
1861+public Gdk.Pixbuf[]? load_icon_set (GLib.File? icon_file) {
1862 Gdk.Pixbuf? icon = null;
1863 try {
1864- icon = new Gdk.Pixbuf.from_file(icon_file.get_path());
1865+ icon = new Gdk.Pixbuf.from_file (icon_file.get_path ());
1866 } catch (Error err) {
1867- warning("couldn't load icon set from %s.", icon_file.get_path());
1868+ warning ("couldn't load icon set from %s.", icon_file.get_path ());
1869 }
1870-
1871+
1872 if (icon_file != null) {
1873 Gdk.Pixbuf[] icon_pixbuf_set = new Gdk.Pixbuf[0];
1874 icon_pixbuf_set += icon;
1875 return icon_pixbuf_set;
1876 }
1877-
1878+
1879 return null;
1880 }
1881
1882
1883=== modified file 'plugins/common/SqliteSupport.vala'
1884--- plugins/common/SqliteSupport.vala 2013-01-21 21:16:09 +0000
1885+++ plugins/common/SqliteSupport.vala 2014-08-08 21:16:43 +0000
1886@@ -14,62 +14,62 @@
1887 }
1888
1889 public abstract class ImportableDatabaseTable {
1890-
1891+
1892 protected static Sqlite.Database db;
1893-
1894+
1895 public string table_name = null;
1896-
1897- protected void set_table_name(string table_name) {
1898+
1899+ protected void set_table_name (string table_name) {
1900 this.table_name = table_name;
1901 }
1902-
1903+
1904 // This method will throw an error on an SQLite return code unless it's OK, DONE, or ROW, which
1905 // are considered normal results.
1906- protected static void throw_error(string method, int res) throws DatabaseError {
1907- string msg = "(%s) [%d] - %s".printf(method, res, db.errmsg());
1908-
1909+ protected static void throw_error (string method, int res) throws DatabaseError {
1910+ string msg = "(%s) [%d] - %s".printf (method, res, db.errmsg ());
1911+
1912 switch (res) {
1913- case Sqlite.OK:
1914- case Sqlite.DONE:
1915- case Sqlite.ROW:
1916- return;
1917-
1918- case Sqlite.PERM:
1919- case Sqlite.BUSY:
1920- case Sqlite.READONLY:
1921- case Sqlite.IOERR:
1922- case Sqlite.CORRUPT:
1923- case Sqlite.CANTOPEN:
1924- case Sqlite.NOLFS:
1925- case Sqlite.AUTH:
1926- case Sqlite.FORMAT:
1927- case Sqlite.NOTADB:
1928- throw new DatabaseError.BACKING(msg);
1929-
1930- case Sqlite.NOMEM:
1931- throw new DatabaseError.MEMORY(msg);
1932-
1933- case Sqlite.ABORT:
1934- case Sqlite.LOCKED:
1935- case Sqlite.INTERRUPT:
1936- throw new DatabaseError.ABORT(msg);
1937-
1938- case Sqlite.FULL:
1939- case Sqlite.EMPTY:
1940- case Sqlite.TOOBIG:
1941- case Sqlite.CONSTRAINT:
1942- case Sqlite.RANGE:
1943- throw new DatabaseError.LIMITS(msg);
1944-
1945- case Sqlite.SCHEMA:
1946- case Sqlite.MISMATCH:
1947- throw new DatabaseError.TYPESPEC(msg);
1948-
1949- case Sqlite.ERROR:
1950- case Sqlite.INTERNAL:
1951- case Sqlite.MISUSE:
1952- default:
1953- throw new DatabaseError.ERROR(msg);
1954+ case Sqlite.OK:
1955+ case Sqlite.DONE:
1956+ case Sqlite.ROW:
1957+ return;
1958+
1959+ case Sqlite.PERM:
1960+ case Sqlite.BUSY:
1961+ case Sqlite.READONLY:
1962+ case Sqlite.IOERR:
1963+ case Sqlite.CORRUPT:
1964+ case Sqlite.CANTOPEN:
1965+ case Sqlite.NOLFS:
1966+ case Sqlite.AUTH:
1967+ case Sqlite.FORMAT:
1968+ case Sqlite.NOTADB:
1969+ throw new DatabaseError.BACKING (msg);
1970+
1971+ case Sqlite.NOMEM:
1972+ throw new DatabaseError.MEMORY (msg);
1973+
1974+ case Sqlite.ABORT:
1975+ case Sqlite.LOCKED:
1976+ case Sqlite.INTERRUPT:
1977+ throw new DatabaseError.ABORT (msg);
1978+
1979+ case Sqlite.FULL:
1980+ case Sqlite.EMPTY:
1981+ case Sqlite.TOOBIG:
1982+ case Sqlite.CONSTRAINT:
1983+ case Sqlite.RANGE:
1984+ throw new DatabaseError.LIMITS (msg);
1985+
1986+ case Sqlite.SCHEMA:
1987+ case Sqlite.MISMATCH:
1988+ throw new DatabaseError.TYPESPEC (msg);
1989+
1990+ case Sqlite.ERROR:
1991+ case Sqlite.INTERNAL:
1992+ case Sqlite.MISUSE:
1993+ default:
1994+ throw new DatabaseError.ERROR (msg);
1995 }
1996 }
1997 }
1998
1999=== modified file 'plugins/common/VersionNumber.vala'
2000--- plugins/common/VersionNumber.vala 2013-01-21 21:16:09 +0000
2001+++ plugins/common/VersionNumber.vala 2014-08-08 21:16:43 +0000
2002@@ -12,30 +12,30 @@
2003 */
2004 public class VersionNumber : Object, Gee.Comparable<VersionNumber> {
2005 private int[] version;
2006-
2007- public VersionNumber(int[] version) {
2008+
2009+ public VersionNumber (int[] version) {
2010 this.version = version;
2011 }
2012-
2013- public VersionNumber.from_string(string str_version, string separator = ".") {
2014- string[] version_items = str_version.split(separator);
2015+
2016+ public VersionNumber.from_string (string str_version, string separator = ".") {
2017+ string[] version_items = str_version.split (separator);
2018 this.version = new int[version_items.length];
2019 for (int i = 0; i < version_items.length; i++)
2020- this.version[i] = int.parse(version_items[i]);
2021+ this.version[i] = int.parse (version_items[i]);
2022 }
2023-
2024- public string to_string() {
2025+
2026+ public string to_string () {
2027 string[] version_items = new string[this.version.length];
2028 for (int i = 0; i < this.version.length; i++)
2029- version_items[i] = this.version[i].to_string();
2030- return string.joinv(".", version_items);
2031+ version_items[i] = this.version[i].to_string ();
2032+ return string.joinv (".", version_items);
2033 }
2034-
2035- public int compare_to(VersionNumber other) {
2036+
2037+ public int compare_to (VersionNumber other) {
2038 int max_len = ((this.version.length > other.version.length) ?
2039 this.version.length : other.version.length);
2040 int res = 0;
2041- for(int i = 0; i < max_len; i++) {
2042+ for (int i = 0; i < max_len; i++) {
2043 int this_v = (i < this.version.length ? this.version[i] : 0);
2044 int other_v = (i < other.version.length ? other.version[i] : 0);
2045 res = this_v - other_v;
2046
2047=== modified file 'plugins/shotwell-data-imports/FSpotDatabase.vala'
2048--- plugins/shotwell-data-imports/FSpotDatabase.vala 2013-01-21 21:16:09 +0000
2049+++ plugins/shotwell-data-imports/FSpotDatabase.vala 2014-08-08 21:16:43 +0000
2050@@ -12,8 +12,8 @@
2051 /**
2052 * Initialization method for the whole module.
2053 */
2054-public void init() {
2055- FSpotDatabaseBehavior.create_behavior_map();
2056+public void init () {
2057+ FSpotDatabaseBehavior.create_behavior_map ();
2058 }
2059
2060 /**
2061@@ -28,29 +28,29 @@
2062 public FSpotTagsTable tags_table;
2063 public FSpotRollsTable rolls_table;
2064 public int64 hidden_tag_id;
2065-
2066- public FSpotDatabase(File db_file) throws DatabaseError, Spit.DataImports.DataImportError {
2067- string filename = db_file.get_path();
2068- int res = Sqlite.Database.open_v2(filename, out fspot_db,
2069- Sqlite.OPEN_READONLY, null);
2070+
2071+ public FSpotDatabase (File db_file) throws DatabaseError, Spit.DataImports.DataImportError {
2072+ string filename = db_file.get_path ();
2073+ int res = Sqlite.Database.open_v2 (filename, out fspot_db,
2074+ Sqlite.OPEN_READONLY, null);
2075 if (res != Sqlite.OK)
2076- throw new DatabaseError.ERROR("Unable to open F-Spot database %s: %d", filename, res);
2077- meta_table = new FSpotMetaTable(fspot_db);
2078- hidden_tag_id = meta_table.get_hidden_tag_id();
2079-
2080- FSpotDatabaseBehavior db_behavior = new FSpotDatabaseBehavior(get_version());
2081-
2082- photos_table = new FSpotPhotosTable(fspot_db, db_behavior);
2083- photo_versions_table = new FSpotPhotoVersionsTable(fspot_db, db_behavior);
2084- tags_table = new FSpotTagsTable(fspot_db, db_behavior);
2085- rolls_table = new FSpotRollsTable(fspot_db, db_behavior);
2086- }
2087-
2088- ~FSpotDatabase() {
2089- }
2090-
2091- private Utils.VersionNumber get_version() throws DatabaseError {
2092- return new Utils.VersionNumber.from_string(meta_table.get_db_version());
2093+ throw new DatabaseError.ERROR ("Unable to open F-Spot database %s: %d", filename, res);
2094+ meta_table = new FSpotMetaTable (fspot_db);
2095+ hidden_tag_id = meta_table.get_hidden_tag_id ();
2096+
2097+ FSpotDatabaseBehavior db_behavior = new FSpotDatabaseBehavior (get_version ());
2098+
2099+ photos_table = new FSpotPhotosTable (fspot_db, db_behavior);
2100+ photo_versions_table = new FSpotPhotoVersionsTable (fspot_db, db_behavior);
2101+ tags_table = new FSpotTagsTable (fspot_db, db_behavior);
2102+ rolls_table = new FSpotRollsTable (fspot_db, db_behavior);
2103+ }
2104+
2105+ ~FSpotDatabase () {
2106+ }
2107+
2108+ private Utils.VersionNumber get_version () throws DatabaseError {
2109+ return new Utils.VersionNumber.from_string (meta_table.get_db_version ());
2110 }
2111 }
2112
2113
2114=== modified file 'plugins/shotwell-data-imports/FSpotDatabaseBehavior.vala'
2115--- plugins/shotwell-data-imports/FSpotDatabaseBehavior.vala 2013-01-21 21:16:09 +0000
2116+++ plugins/shotwell-data-imports/FSpotDatabaseBehavior.vala 2014-08-08 21:16:43 +0000
2117@@ -9,17 +9,17 @@
2118 private class FSpotBehaviorEntry {
2119 private Utils.VersionNumber version;
2120 private FSpotTableBehavior behavior;
2121-
2122- public FSpotBehaviorEntry(Utils.VersionNumber version, FSpotTableBehavior behavior) {
2123+
2124+ public FSpotBehaviorEntry (Utils.VersionNumber version, FSpotTableBehavior behavior) {
2125 this.version = version;
2126 this.behavior = behavior;
2127 }
2128-
2129- public Utils.VersionNumber get_version() {
2130+
2131+ public Utils.VersionNumber get_version () {
2132 return version;
2133 }
2134-
2135- public FSpotTableBehavior get_behavior() {
2136+
2137+ public FSpotTableBehavior get_behavior () {
2138 return behavior;
2139 }
2140 }
2141@@ -35,171 +35,171 @@
2142 // guaranteed as it hasn't been tested so it's probably better to just
2143 // bomb out at that point rather than risk importing incorrect data
2144 public static Utils.VersionNumber MIN_UNSUPPORTED_VERSION =
2145- new Utils.VersionNumber({ 19 });
2146+ new Utils.VersionNumber ({ 19 });
2147 private static Gee.Map<string, Gee.List<FSpotBehaviorEntry>> behavior_map;
2148-
2149+
2150 private FSpotTableBehavior<FSpotPhotoRow> photos_behavior;
2151 private FSpotTableBehavior<FSpotTagRow> tags_behavior;
2152 private FSpotTableBehavior<FSpotPhotoTagRow> photo_tags_behavior;
2153 private FSpotTableBehavior<FSpotPhotoVersionRow> photo_versions_behavior;
2154 private FSpotTableBehavior<FSpotRollRow> rolls_behavior;
2155-
2156- public static void create_behavior_map() {
2157- behavior_map = new Gee.HashMap<string, Gee.List<FSpotBehaviorEntry>>();
2158+
2159+ public static void create_behavior_map () {
2160+ behavior_map = new Gee.HashMap<string, Gee.List<FSpotBehaviorEntry>> ();
2161 // photos table
2162- Gee.List<FSpotBehaviorEntry> photos_list = new Gee.ArrayList<FSpotBehaviorEntry>();
2163+ Gee.List<FSpotBehaviorEntry> photos_list = new Gee.ArrayList<FSpotBehaviorEntry> ();
2164 // v0-4
2165- photos_list.add(new FSpotBehaviorEntry(
2166- new Utils.VersionNumber({ 0 }),
2167- FSpotPhotosV0Behavior.get_instance()
2168- ));
2169+ photos_list.add (new FSpotBehaviorEntry (
2170+ new Utils.VersionNumber ({ 0 }),
2171+ FSpotPhotosV0Behavior.get_instance ()
2172+ ));
2173 // v5-6
2174- photos_list.add(new FSpotBehaviorEntry(
2175- new Utils.VersionNumber({ 5 }),
2176- FSpotPhotosV5Behavior.get_instance()
2177- ));
2178+ photos_list.add (new FSpotBehaviorEntry (
2179+ new Utils.VersionNumber ({ 5 }),
2180+ FSpotPhotosV5Behavior.get_instance ()
2181+ ));
2182 // v7-10
2183- photos_list.add(new FSpotBehaviorEntry(
2184- new Utils.VersionNumber({ 7 }),
2185- FSpotPhotosV7Behavior.get_instance()
2186- ));
2187+ photos_list.add (new FSpotBehaviorEntry (
2188+ new Utils.VersionNumber ({ 7 }),
2189+ FSpotPhotosV7Behavior.get_instance ()
2190+ ));
2191 // v11-15
2192- photos_list.add(new FSpotBehaviorEntry(
2193- new Utils.VersionNumber({ 11 }),
2194- FSpotPhotosV11Behavior.get_instance()
2195- ));
2196+ photos_list.add (new FSpotBehaviorEntry (
2197+ new Utils.VersionNumber ({ 11 }),
2198+ FSpotPhotosV11Behavior.get_instance ()
2199+ ));
2200 // v16
2201- photos_list.add(new FSpotBehaviorEntry(
2202- new Utils.VersionNumber({ 16 }),
2203- FSpotPhotosV16Behavior.get_instance()
2204- ));
2205+ photos_list.add (new FSpotBehaviorEntry (
2206+ new Utils.VersionNumber ({ 16 }),
2207+ FSpotPhotosV16Behavior.get_instance ()
2208+ ));
2209 // v17
2210- photos_list.add(new FSpotBehaviorEntry(
2211- new Utils.VersionNumber({ 17 }),
2212- FSpotPhotosV17Behavior.get_instance()
2213- ));
2214+ photos_list.add (new FSpotBehaviorEntry (
2215+ new Utils.VersionNumber ({ 17 }),
2216+ FSpotPhotosV17Behavior.get_instance ()
2217+ ));
2218 // v18+
2219- photos_list.add(new FSpotBehaviorEntry(
2220- new Utils.VersionNumber({ 18 }),
2221- FSpotPhotosV18Behavior.get_instance()
2222- ));
2223- behavior_map.set(FSpotPhotosTable.TABLE_NAME, photos_list);
2224+ photos_list.add (new FSpotBehaviorEntry (
2225+ new Utils.VersionNumber ({ 18 }),
2226+ FSpotPhotosV18Behavior.get_instance ()
2227+ ));
2228+ behavior_map.set (FSpotPhotosTable.TABLE_NAME, photos_list);
2229 // tags table
2230- Gee.List<FSpotBehaviorEntry> tags_list = new Gee.ArrayList<FSpotBehaviorEntry>();
2231+ Gee.List<FSpotBehaviorEntry> tags_list = new Gee.ArrayList<FSpotBehaviorEntry> ();
2232 // v0+
2233- tags_list.add(new FSpotBehaviorEntry(
2234- new Utils.VersionNumber({ 0 }),
2235- FSpotTagsV0Behavior.get_instance()
2236- ));
2237- behavior_map.set(FSpotTagsTable.TABLE_NAME, tags_list);
2238+ tags_list.add (new FSpotBehaviorEntry (
2239+ new Utils.VersionNumber ({ 0 }),
2240+ FSpotTagsV0Behavior.get_instance ()
2241+ ));
2242+ behavior_map.set (FSpotTagsTable.TABLE_NAME, tags_list);
2243 // photo_tags table
2244- Gee.List<FSpotBehaviorEntry> photo_tags_list = new Gee.ArrayList<FSpotBehaviorEntry>();
2245+ Gee.List<FSpotBehaviorEntry> photo_tags_list = new Gee.ArrayList<FSpotBehaviorEntry> ();
2246 // v0+
2247- photo_tags_list.add(new FSpotBehaviorEntry(
2248- new Utils.VersionNumber({ 0 }),
2249- FSpotPhotoTagsV0Behavior.get_instance()
2250- ));
2251- behavior_map.set(FSpotPhotoTagsTable.TABLE_NAME, photo_tags_list);
2252+ photo_tags_list.add (new FSpotBehaviorEntry (
2253+ new Utils.VersionNumber ({ 0 }),
2254+ FSpotPhotoTagsV0Behavior.get_instance ()
2255+ ));
2256+ behavior_map.set (FSpotPhotoTagsTable.TABLE_NAME, photo_tags_list);
2257 // photo_versions table
2258- Gee.List<FSpotBehaviorEntry> photo_versions_list = new Gee.ArrayList<FSpotBehaviorEntry>();
2259+ Gee.List<FSpotBehaviorEntry> photo_versions_list = new Gee.ArrayList<FSpotBehaviorEntry> ();
2260 // v0-8
2261- photo_versions_list.add(new FSpotBehaviorEntry(
2262- new Utils.VersionNumber({ 0 }),
2263- FSpotPhotoVersionsV0Behavior.get_instance()
2264- ));
2265+ photo_versions_list.add (new FSpotBehaviorEntry (
2266+ new Utils.VersionNumber ({ 0 }),
2267+ FSpotPhotoVersionsV0Behavior.get_instance ()
2268+ ));
2269 // v9-15
2270- photo_versions_list.add(new FSpotBehaviorEntry(
2271- new Utils.VersionNumber({ 9 }),
2272- FSpotPhotoVersionsV9Behavior.get_instance()
2273- ));
2274+ photo_versions_list.add (new FSpotBehaviorEntry (
2275+ new Utils.VersionNumber ({ 9 }),
2276+ FSpotPhotoVersionsV9Behavior.get_instance ()
2277+ ));
2278 // v16
2279- photo_versions_list.add(new FSpotBehaviorEntry(
2280- new Utils.VersionNumber({ 16 }),
2281- FSpotPhotoVersionsV16Behavior.get_instance()
2282- ));
2283+ photo_versions_list.add (new FSpotBehaviorEntry (
2284+ new Utils.VersionNumber ({ 16 }),
2285+ FSpotPhotoVersionsV16Behavior.get_instance ()
2286+ ));
2287 // v17
2288- photo_versions_list.add(new FSpotBehaviorEntry(
2289- new Utils.VersionNumber({ 17 }),
2290- FSpotPhotoVersionsV17Behavior.get_instance()
2291- ));
2292+ photo_versions_list.add (new FSpotBehaviorEntry (
2293+ new Utils.VersionNumber ({ 17 }),
2294+ FSpotPhotoVersionsV17Behavior.get_instance ()
2295+ ));
2296 // v18+
2297- photo_versions_list.add(new FSpotBehaviorEntry(
2298- new Utils.VersionNumber({ 18 }),
2299- FSpotPhotoVersionsV18Behavior.get_instance()
2300- ));
2301- behavior_map.set(FSpotPhotoVersionsTable.TABLE_NAME, photo_versions_list);
2302+ photo_versions_list.add (new FSpotBehaviorEntry (
2303+ new Utils.VersionNumber ({ 18 }),
2304+ FSpotPhotoVersionsV18Behavior.get_instance ()
2305+ ));
2306+ behavior_map.set (FSpotPhotoVersionsTable.TABLE_NAME, photo_versions_list);
2307 // rolls table
2308- Gee.List<FSpotBehaviorEntry> rolls_list = new Gee.ArrayList<FSpotBehaviorEntry>();
2309+ Gee.List<FSpotBehaviorEntry> rolls_list = new Gee.ArrayList<FSpotBehaviorEntry> ();
2310 // v0-4
2311- rolls_list.add(new FSpotBehaviorEntry(
2312- new Utils.VersionNumber({ 0 }),
2313- FSpotRollsV0Behavior.get_instance()
2314- ));
2315+ rolls_list.add (new FSpotBehaviorEntry (
2316+ new Utils.VersionNumber ({ 0 }),
2317+ FSpotRollsV0Behavior.get_instance ()
2318+ ));
2319 // v5+
2320- rolls_list.add(new FSpotBehaviorEntry(
2321- new Utils.VersionNumber({ 5 }),
2322- FSpotRollsV5Behavior.get_instance()
2323- ));
2324- behavior_map.set(FSpotRollsTable.TABLE_NAME, rolls_list);
2325+ rolls_list.add (new FSpotBehaviorEntry (
2326+ new Utils.VersionNumber ({ 5 }),
2327+ FSpotRollsV5Behavior.get_instance ()
2328+ ));
2329+ behavior_map.set (FSpotRollsTable.TABLE_NAME, rolls_list);
2330 }
2331-
2332- public static FSpotTableBehavior? find_behavior(string table_name, Utils.VersionNumber version) {
2333+
2334+ public static FSpotTableBehavior? find_behavior (string table_name, Utils.VersionNumber version) {
2335 FSpotTableBehavior behavior = null;
2336- Gee.List<FSpotBehaviorEntry> behavior_list = behavior_map.get(table_name);
2337+ Gee.List<FSpotBehaviorEntry> behavior_list = behavior_map.get (table_name);
2338 if (behavior_list != null)
2339 foreach (FSpotBehaviorEntry entry in behavior_list) {
2340- if (version.compare_to(entry.get_version()) >= 0)
2341- behavior = entry.get_behavior();
2342+ if (version.compare_to (entry.get_version ()) >= 0)
2343+ behavior = entry.get_behavior ();
2344 }
2345 else
2346- warning("Could not find behavior list for table %s", table_name);
2347+ warning ("Could not find behavior list for table %s", table_name);
2348 return behavior;
2349
2350 }
2351- public FSpotDatabaseBehavior(Utils.VersionNumber version) throws Spit.DataImports.DataImportError {
2352- if (version.compare_to(MIN_UNSUPPORTED_VERSION) >= 0)
2353- throw new Spit.DataImports.DataImportError.UNSUPPORTED_VERSION("Version %s is not yet supported", version.to_string());
2354-
2355- FSpotTableBehavior? photos_generic_behavior = find_behavior(FSpotPhotosTable.TABLE_NAME, version);
2356+ public FSpotDatabaseBehavior (Utils.VersionNumber version) throws Spit.DataImports.DataImportError {
2357+ if (version.compare_to (MIN_UNSUPPORTED_VERSION) >= 0)
2358+ throw new Spit.DataImports.DataImportError.UNSUPPORTED_VERSION ("Version %s is not yet supported", version.to_string ());
2359+
2360+ FSpotTableBehavior? photos_generic_behavior = find_behavior (FSpotPhotosTable.TABLE_NAME, version);
2361 if (photos_generic_behavior != null)
2362 photos_behavior = photos_generic_behavior as FSpotTableBehavior<FSpotPhotoRow>;
2363- FSpotTableBehavior? tags_generic_behavior = find_behavior(FSpotTagsTable.TABLE_NAME, version);
2364+ FSpotTableBehavior? tags_generic_behavior = find_behavior (FSpotTagsTable.TABLE_NAME, version);
2365 if (tags_generic_behavior != null)
2366 tags_behavior = tags_generic_behavior as FSpotTableBehavior<FSpotTagRow>;
2367- FSpotTableBehavior? photo_tags_generic_behavior = find_behavior(FSpotPhotoTagsTable.TABLE_NAME, version);
2368+ FSpotTableBehavior? photo_tags_generic_behavior = find_behavior (FSpotPhotoTagsTable.TABLE_NAME, version);
2369 if (photo_tags_generic_behavior != null)
2370 photo_tags_behavior = photo_tags_generic_behavior as FSpotTableBehavior<FSpotPhotoTagRow>;
2371- FSpotTableBehavior? photo_versions_generic_behavior = find_behavior(FSpotPhotoVersionsTable.TABLE_NAME, version);
2372+ FSpotTableBehavior? photo_versions_generic_behavior = find_behavior (FSpotPhotoVersionsTable.TABLE_NAME, version);
2373 if (photo_versions_generic_behavior != null)
2374 photo_versions_behavior = photo_versions_generic_behavior as FSpotTableBehavior<FSpotPhotoVersionRow>;
2375- FSpotTableBehavior? rolls_generic_behavior = find_behavior(FSpotRollsTable.TABLE_NAME, version);
2376+ FSpotTableBehavior? rolls_generic_behavior = find_behavior (FSpotRollsTable.TABLE_NAME, version);
2377 if (rolls_generic_behavior != null)
2378 rolls_behavior = rolls_generic_behavior as FSpotTableBehavior<FSpotRollRow>;
2379-
2380+
2381 if (photos_behavior == null || tags_behavior == null ||
2382- photo_tags_behavior == null || photo_versions_behavior == null ||
2383- rolls_behavior == null
2384- )
2385- throw new Spit.DataImports.DataImportError.UNSUPPORTED_VERSION("Version %s is not supported", version.to_string());
2386+ photo_tags_behavior == null || photo_versions_behavior == null ||
2387+ rolls_behavior == null
2388+ )
2389+ throw new Spit.DataImports.DataImportError.UNSUPPORTED_VERSION ("Version %s is not supported", version.to_string ());
2390 }
2391-
2392- public FSpotTableBehavior<FSpotPhotoRow> get_photos_behavior() {
2393+
2394+ public FSpotTableBehavior<FSpotPhotoRow> get_photos_behavior () {
2395 return photos_behavior;
2396 }
2397-
2398- public FSpotTableBehavior<FSpotTagRow> get_tags_behavior() {
2399+
2400+ public FSpotTableBehavior<FSpotTagRow> get_tags_behavior () {
2401 return tags_behavior;
2402 }
2403-
2404- public FSpotTableBehavior<FSpotPhotoTagRow> get_photo_tags_behavior() {
2405+
2406+ public FSpotTableBehavior<FSpotPhotoTagRow> get_photo_tags_behavior () {
2407 return photo_tags_behavior;
2408 }
2409-
2410- public FSpotTableBehavior<FSpotPhotoVersionRow> get_photo_versions_behavior() {
2411+
2412+ public FSpotTableBehavior<FSpotPhotoVersionRow> get_photo_versions_behavior () {
2413 return photo_versions_behavior;
2414 }
2415-
2416- public FSpotTableBehavior<FSpotRollRow> get_rolls_behavior() {
2417+
2418+ public FSpotTableBehavior<FSpotRollRow> get_rolls_behavior () {
2419 return rolls_behavior;
2420 }
2421 }
2422
2423=== modified file 'plugins/shotwell-data-imports/FSpotDatabaseTable.vala'
2424--- plugins/shotwell-data-imports/FSpotDatabaseTable.vala 2013-01-21 21:16:09 +0000
2425+++ plugins/shotwell-data-imports/FSpotDatabaseTable.vala 2014-08-08 21:16:43 +0000
2426@@ -12,40 +12,40 @@
2427 public abstract class FSpotDatabaseTable<T> : ImportableDatabaseTable {
2428 protected unowned Sqlite.Database fspot_db;
2429 protected FSpotTableBehavior<T> behavior;
2430-
2431- public FSpotDatabaseTable(Sqlite.Database db) {
2432+
2433+ public FSpotDatabaseTable (Sqlite.Database db) {
2434 this.fspot_db = db;
2435 }
2436-
2437- public void set_behavior(FSpotTableBehavior<T> behavior) {
2438+
2439+ public void set_behavior (FSpotTableBehavior<T> behavior) {
2440 this.behavior = behavior;
2441- set_table_name(behavior.get_table_name());
2442+ set_table_name (behavior.get_table_name ());
2443 }
2444-
2445- public FSpotTableBehavior<T> get_behavior() {
2446+
2447+ public FSpotTableBehavior<T> get_behavior () {
2448 return behavior;
2449 }
2450-
2451- protected string get_joined_column_list(bool with_table = false) {
2452- string[] columns = behavior.list_columns();
2453+
2454+ protected string get_joined_column_list (bool with_table = false) {
2455+ string[] columns = behavior.list_columns ();
2456 if (with_table)
2457 for (int i = 0; i < columns.length; i++)
2458- columns[i] = "%s.%s".printf(table_name, columns[i]);
2459- return string.joinv(", ", columns);
2460+ columns[i] = "%s.%s".printf (table_name, columns[i]);
2461+ return string.joinv (", ", columns);
2462 }
2463-
2464- protected int select_all(out Sqlite.Statement stmt) throws DatabaseError {
2465- string column_list = get_joined_column_list();
2466- string sql = "SELECT %s FROM %s".printf(column_list, table_name);
2467-
2468- int res = fspot_db.prepare_v2(sql, -1, out stmt);
2469+
2470+ protected int select_all (out Sqlite.Statement stmt) throws DatabaseError {
2471+ string column_list = get_joined_column_list ();
2472+ string sql = "SELECT %s FROM %s".printf (column_list, table_name);
2473+
2474+ int res = fspot_db.prepare_v2 (sql, -1, out stmt);
2475 if (res != Sqlite.OK)
2476- throw_error("Statement failed: %s".printf(sql), res);
2477-
2478- res = stmt.step();
2479+ throw_error ("Statement failed: %s".printf (sql), res);
2480+
2481+ res = stmt.step ();
2482 if (res != Sqlite.ROW && res != Sqlite.DONE)
2483- throw_error("select_all %s %s".printf(table_name, column_list), res);
2484-
2485+ throw_error ("select_all %s %s".printf (table_name, column_list), res);
2486+
2487 return res;
2488 }
2489 }
2490
2491=== modified file 'plugins/shotwell-data-imports/FSpotImporter.vala'
2492--- plugins/shotwell-data-imports/FSpotImporter.vala 2013-01-21 21:16:09 +0000
2493+++ plugins/shotwell-data-imports/FSpotImporter.vala 2014-08-08 21:16:43 +0000
2494@@ -9,29 +9,29 @@
2495
2496 private static Gdk.Pixbuf[] icon_pixbuf_set = null;
2497
2498- public FSpotService(GLib.File resource_directory) {
2499+ public FSpotService (GLib.File resource_directory) {
2500 // initialize the database layer
2501- DataImports.FSpot.Db.init();
2502+ DataImports.FSpot.Db.init ();
2503 if (icon_pixbuf_set == null)
2504- icon_pixbuf_set = Resources.load_icon_set(resource_directory.get_child(ICON_FILENAME));
2505- }
2506-
2507- public int get_pluggable_interface(int min_host_interface, int max_host_interface) {
2508- return Spit.negotiate_interfaces(min_host_interface, max_host_interface,
2509- Spit.DataImports.CURRENT_INTERFACE);
2510- }
2511-
2512- public unowned string get_id() {
2513+ icon_pixbuf_set = Resources.load_icon_set (resource_directory.get_child (ICON_FILENAME));
2514+ }
2515+
2516+ public int get_pluggable_interface (int min_host_interface, int max_host_interface) {
2517+ return Spit.negotiate_interfaces (min_host_interface, max_host_interface,
2518+ Spit.DataImports.CURRENT_INTERFACE);
2519+ }
2520+
2521+ public unowned string get_id () {
2522 return "org.yorba.shotwell.dataimports.fspot";
2523 }
2524
2525- public unowned string get_pluggable_name() {
2526+ public unowned string get_pluggable_name () {
2527 return "F-Spot";
2528 }
2529
2530- public void get_info(ref Spit.PluggableInfo info) {
2531+ public void get_info (ref Spit.PluggableInfo info) {
2532 info.authors = "Bruno Girin";
2533- info.copyright = _("Copyright 2009-2013 Yorba Foundation");
2534+ info.copyright = _ ("Copyright 2009-2013 Yorba Foundation");
2535 info.translators = Resources.TRANSLATORS;
2536 info.version = _VERSION;
2537 info.website_name = Resources.WEBSITE_NAME;
2538@@ -41,11 +41,11 @@
2539 info.icons = icon_pixbuf_set;
2540 }
2541
2542- public void activation(bool enabled) {
2543+ public void activation (bool enabled) {
2544 }
2545-
2546- public Spit.DataImports.DataImporter create_data_importer(Spit.DataImports.PluginHost host) {
2547- return new DataImports.FSpot.FSpotDataImporter(this, host);
2548+
2549+ public Spit.DataImports.DataImporter create_data_importer (Spit.DataImports.PluginHost host) {
2550+ return new DataImports.FSpot.FSpotDataImporter (this, host);
2551 }
2552 }
2553
2554@@ -53,35 +53,35 @@
2555
2556 internal const string SERVICE_NAME = "F-Spot";
2557 internal const string SERVICE_WELCOME_MESSAGE =
2558- _("Welcome to the F-Spot library import service.\n\nPlease select a library to import, either by selecting one of the existing libraries found by Shotwell or by selecting an alternative F-Spot database file.");
2559+ _ ("Welcome to the F-Spot library import service.\n\nPlease select a library to import, either by selecting one of the existing libraries found by Shotwell or by selecting an alternative F-Spot database file.");
2560 internal const string SERVICE_WELCOME_MESSAGE_FILE_ONLY =
2561- _("Welcome to the F-Spot library import service.\n\nPlease select an F-Spot database file.");
2562+ _ ("Welcome to the F-Spot library import service.\n\nPlease select an F-Spot database file.");
2563 internal const string FILE_IMPORT_LABEL =
2564- _("Manually select an F-Spot database file to import:");
2565+ _ ("Manually select an F-Spot database file to import:");
2566 internal const string ERROR_CANT_OPEN_DB_FILE =
2567- _("Cannot open the selected F-Spot database file: the file does not exist or is not an F-Spot database");
2568+ _ ("Cannot open the selected F-Spot database file: the file does not exist or is not an F-Spot database");
2569 internal const string ERROR_UNSUPPORTED_DB_VERSION =
2570- _("Cannot open the selected F-Spot database file: this version of the F-Spot database is not supported by Shotwell");
2571+ _ ("Cannot open the selected F-Spot database file: this version of the F-Spot database is not supported by Shotwell");
2572 internal const string ERROR_CANT_READ_TAGS_TABLE =
2573- _("Cannot read the selected F-Spot database file: error while reading tags table");
2574+ _ ("Cannot read the selected F-Spot database file: error while reading tags table");
2575 internal const string ERROR_CANT_READ_PHOTOS_TABLE =
2576- _("Cannot read the selected F-Spot database file: error while reading photos table");
2577+ _ ("Cannot read the selected F-Spot database file: error while reading photos table");
2578 internal const string MESSAGE_FINAL_SCREEN =
2579- _("Shotwell has found %d photos in the F-Spot library and is currently importing them. Duplicates will be automatically detected and removed.\n\nYou can close this dialog and start using Shotwell while the import is taking place in the background.");
2580+ _ ("Shotwell has found %d photos in the F-Spot library and is currently importing them. Duplicates will be automatically detected and removed.\n\nYou can close this dialog and start using Shotwell while the import is taking place in the background.");
2581
2582 public class FSpotImportableLibrary : Spit.DataImports.ImportableLibrary, GLib.Object {
2583 private File db_file;
2584-
2585- public FSpotImportableLibrary(File db_file) {
2586+
2587+ public FSpotImportableLibrary (File db_file) {
2588 this.db_file = db_file;
2589 }
2590-
2591- public File get_db_file() {
2592+
2593+ public File get_db_file () {
2594 return db_file;
2595 }
2596-
2597- public string get_display_name() {
2598- return _("F-Spot library: %s").printf(db_file.get_path());
2599+
2600+ public string get_display_name () {
2601+ return _ ("F-Spot library: %s").printf (db_file.get_path ());
2602 }
2603 }
2604
2605@@ -94,8 +94,8 @@
2606 private FSpotImportableRating rating;
2607 private string folder_path;
2608 private string filename;
2609-
2610- public FSpotImportableItem(
2611+
2612+ public FSpotImportableItem (
2613 DataImports.FSpot.Db.FSpotPhotoRow photo_row,
2614 DataImports.FSpot.Db.FSpotPhotoVersionRow? photo_version_row,
2615 DataImports.FSpot.Db.FSpotRollRow? roll_row,
2616@@ -110,84 +110,84 @@
2617 this.tags = tags;
2618 this.event = event;
2619 if (photo_row.rating > 0)
2620- this.rating = new FSpotImportableRating(photo_row.rating);
2621+ this.rating = new FSpotImportableRating (photo_row.rating);
2622 else if (is_hidden)
2623- this.rating = new FSpotImportableRating(FSpotImportableRating.REJECTED);
2624+ this.rating = new FSpotImportableRating (FSpotImportableRating.REJECTED);
2625 else if (is_favorite)
2626- this.rating = new FSpotImportableRating(5);
2627+ this.rating = new FSpotImportableRating (5);
2628 else
2629- this.rating = new FSpotImportableRating(FSpotImportableRating.UNRATED);
2630-
2631+ this.rating = new FSpotImportableRating (FSpotImportableRating.UNRATED);
2632+
2633 // store path and filename
2634 folder_path = (photo_version_row != null) ?
2635- photo_version_row.base_path.get_path() :
2636- photo_row.base_path.get_path();
2637+ photo_version_row.base_path.get_path () :
2638+ photo_row.base_path.get_path ();
2639 filename = (photo_version_row != null) ?
2640- photo_version_row.filename :
2641- photo_row.filename;
2642-
2643+ photo_version_row.filename :
2644+ photo_row.filename;
2645+
2646 // In theory, neither field should be null at that point but belts
2647 // and braces don't hurt
2648 if (folder_path != null && filename != null) {
2649 // check if file exist and if not decode as URL
2650- File photo = File.new_for_path(folder_path).get_child(filename);
2651-
2652+ File photo = File.new_for_path (folder_path).get_child (filename);
2653+
2654 // If file not found, parse as URI and store back
2655- if (!photo.query_exists()) {
2656- folder_path = decode_url(folder_path);
2657- filename = decode_url(filename);
2658+ if (!photo.query_exists ()) {
2659+ folder_path = decode_url (folder_path);
2660+ filename = decode_url (filename);
2661 }
2662 }
2663 }
2664-
2665- public Spit.DataImports.ImportableTag[] get_tags() {
2666+
2667+ public Spit.DataImports.ImportableTag[] get_tags () {
2668 Spit.DataImports.ImportableTag[] importable_tags = new Spit.DataImports.ImportableTag[0];
2669 foreach (FSpotImportableTag tag in tags)
2670 importable_tags += tag;
2671 return importable_tags;
2672 }
2673-
2674- public Spit.DataImports.ImportableEvent? get_event() {
2675+
2676+ public Spit.DataImports.ImportableEvent? get_event () {
2677 return event;
2678 }
2679-
2680- public string get_folder_path() {
2681+
2682+ public string get_folder_path () {
2683 return folder_path;
2684 }
2685-
2686- public string get_filename() {
2687+
2688+ public string get_filename () {
2689 return filename;
2690 }
2691-
2692- public string? get_title() {
2693+
2694+ public string? get_title () {
2695 return (photo_row.description == null || photo_row.description == "") ? null : photo_row.description;
2696 }
2697-
2698- public Spit.DataImports.ImportableRating get_rating() {
2699+
2700+ public Spit.DataImports.ImportableRating get_rating () {
2701 return rating;
2702 }
2703-
2704- private string decode_url(string url) {
2705- StringBuilder builder = new StringBuilder();
2706+
2707+ private string decode_url (string url) {
2708+ StringBuilder builder = new StringBuilder ();
2709 for (int idx = 0; idx < url.length; ) {
2710- int cidx = url.index_of_char('%', idx);
2711+ int cidx = url.index_of_char ('%', idx);
2712 if (cidx > idx) {
2713- builder.append(url.slice(idx, cidx));
2714+ builder.append (url.slice (idx, cidx));
2715 }
2716 if (cidx >= 0) {
2717 if (cidx < url.length - 2) {
2718- char c1 = url.get(cidx + 1);
2719- char c2 = url.get(cidx + 2);
2720- if (c1.isxdigit() && c1.isxdigit()) {
2721- int ccode = 0x10 * c1.xdigit_value() + c2.xdigit_value();
2722- builder.append_c((char)ccode);
2723+ char c1 = url.get (cidx + 1);
2724+ char c2 = url.get (cidx + 2);
2725+ if (c1.isxdigit () && c1.isxdigit ()) {
2726+ int ccode = 0x10 * c1.xdigit_value () + c2.xdigit_value ();
2727+ builder.append_c ((char)ccode);
2728 }
2729 idx = cidx + 3;
2730 } else {
2731 idx = cidx + 1;
2732 }
2733 } else {
2734- builder.append(url.substring(idx));
2735+ builder.append (url.substring (idx));
2736 idx = url.length;
2737 }
2738 }
2739@@ -198,49 +198,49 @@
2740 public class FSpotImportableTag : Spit.DataImports.ImportableTag, GLib.Object {
2741 private DataImports.FSpot.Db.FSpotTagRow row;
2742 private FSpotImportableTag? parent;
2743-
2744- public FSpotImportableTag(DataImports.FSpot.Db.FSpotTagRow row, FSpotImportableTag? parent) {
2745+
2746+ public FSpotImportableTag (DataImports.FSpot.Db.FSpotTagRow row, FSpotImportableTag? parent) {
2747 this.row = row;
2748 this.parent = parent;
2749 }
2750-
2751- public int64 get_id() {
2752+
2753+ public int64 get_id () {
2754 return row.tag_id;
2755 }
2756-
2757- public string get_name() {
2758+
2759+ public string get_name () {
2760 return row.name;
2761 }
2762-
2763- public Spit.DataImports.ImportableTag? get_parent() {
2764- return parent;
2765- }
2766-
2767- public FSpotImportableTag? get_fspot_parent() {
2768- return parent;
2769- }
2770-
2771- public string get_stock_icon() {
2772+
2773+ public Spit.DataImports.ImportableTag? get_parent () {
2774+ return parent;
2775+ }
2776+
2777+ public FSpotImportableTag? get_fspot_parent () {
2778+ return parent;
2779+ }
2780+
2781+ public string get_stock_icon () {
2782 return row.stock_icon;
2783 }
2784-
2785- public bool is_stock() {
2786- return (row.stock_icon.has_prefix(DataImports.FSpot.Db.FSpotTagsTable.PREFIX_STOCK_ICON));
2787+
2788+ public bool is_stock () {
2789+ return (row.stock_icon.has_prefix (DataImports.FSpot.Db.FSpotTagsTable.PREFIX_STOCK_ICON));
2790 }
2791-
2792- public FSpotImportableEvent to_event() {
2793- return new FSpotImportableEvent(this.row);
2794+
2795+ public FSpotImportableEvent to_event () {
2796+ return new FSpotImportableEvent (this.row);
2797 }
2798 }
2799
2800 public class FSpotImportableEvent : Spit.DataImports.ImportableEvent, GLib.Object {
2801 private DataImports.FSpot.Db.FSpotTagRow row;
2802-
2803- public FSpotImportableEvent(DataImports.FSpot.Db.FSpotTagRow row) {
2804+
2805+ public FSpotImportableEvent (DataImports.FSpot.Db.FSpotTagRow row) {
2806 this.row = row;
2807 }
2808-
2809- public string get_name() {
2810+
2811+ public string get_name () {
2812 return row.name;
2813 }
2814 }
2815@@ -248,62 +248,62 @@
2816 public class FSpotImportableRating : Spit.DataImports.ImportableRating, GLib.Object {
2817 public static const int REJECTED = -1;
2818 public static const int UNRATED = 0;
2819-
2820+
2821 private int rating_value;
2822-
2823- public FSpotImportableRating(int rating_value) {
2824+
2825+ public FSpotImportableRating (int rating_value) {
2826 if (rating_value < -1)
2827 rating_value = -1;
2828 else if (rating_value > 5)
2829 rating_value = 5;
2830 this.rating_value = rating_value;
2831 }
2832-
2833- public bool is_rejected() {
2834+
2835+ public bool is_rejected () {
2836 return (rating_value == REJECTED);
2837 }
2838-
2839- public bool is_unrated() {
2840+
2841+ public bool is_unrated () {
2842 return (rating_value == UNRATED);
2843 }
2844-
2845- public int get_value() {
2846+
2847+ public int get_value () {
2848 return rating_value;
2849 }
2850 }
2851
2852 internal class FSpotTagsCache : Object {
2853 private DataImports.FSpot.Db.FSpotTagsTable tags_table;
2854- private Gee.HashMap<int64?, FSpotImportableTag> tags_map;
2855-
2856- public FSpotTagsCache(DataImports.FSpot.Db.FSpotTagsTable tags_table) throws DatabaseError {
2857+ private Gee.HashMap < int64?, FSpotImportableTag > tags_map;
2858+
2859+ public FSpotTagsCache (DataImports.FSpot.Db.FSpotTagsTable tags_table) throws DatabaseError {
2860 this.tags_table = tags_table;
2861- tags_map = new Gee.HashMap<int64?, FSpotImportableTag> ();
2862+ tags_map = new Gee.HashMap < int64?, FSpotImportableTag > ();
2863 }
2864-
2865- public FSpotImportableTag get_tag(DataImports.FSpot.Db.FSpotTagRow tag_row) throws DatabaseError {
2866- FSpotImportableTag? tag = tags_map.get(tag_row.tag_id);
2867+
2868+ public FSpotImportableTag get_tag (DataImports.FSpot.Db.FSpotTagRow tag_row) throws DatabaseError {
2869+ FSpotImportableTag? tag = tags_map.get (tag_row.tag_id);
2870 if (tag != null) {
2871 return tag;
2872 } else {
2873- FSpotImportableTag? parent_tag = get_tag_from_id(tag_row.category_id);
2874- FSpotImportableTag new_tag = new FSpotImportableTag(tag_row, parent_tag);
2875+ FSpotImportableTag? parent_tag = get_tag_from_id (tag_row.category_id);
2876+ FSpotImportableTag new_tag = new FSpotImportableTag (tag_row, parent_tag);
2877 tags_map[tag_row.tag_id] = new_tag;
2878 return new_tag;
2879 }
2880 }
2881-
2882- private FSpotImportableTag? get_tag_from_id(int64 tag_id) throws DatabaseError {
2883+
2884+ private FSpotImportableTag? get_tag_from_id (int64 tag_id) throws DatabaseError {
2885 // check whether the tag ID is valid first, otherwise return null
2886 if (tag_id < 1)
2887 return null;
2888- FSpotImportableTag? tag = tags_map.get(tag_id);
2889+ FSpotImportableTag? tag = tags_map.get (tag_id);
2890 if (tag != null)
2891 return tag;
2892- DataImports.FSpot.Db.FSpotTagRow? tag_row = tags_table.get_by_id(tag_id);
2893+ DataImports.FSpot.Db.FSpotTagRow? tag_row = tags_table.get_by_id (tag_id);
2894 if (tag_row != null) {
2895- FSpotImportableTag? parent_tag = get_tag_from_id(tag_row.category_id);
2896- FSpotImportableTag new_tag = new FSpotImportableTag(tag_row, parent_tag);
2897+ FSpotImportableTag? parent_tag = get_tag_from_id (tag_row.category_id);
2898+ FSpotImportableTag new_tag = new FSpotImportableTag (tag_row, parent_tag);
2899 tags_map[tag_id] = new_tag;
2900 return new_tag;
2901 }
2902@@ -317,78 +317,78 @@
2903 private weak Spit.DataImports.Service service = null;
2904 private bool running = false;
2905
2906- public FSpotDataImporter(Spit.DataImports.Service service,
2907- Spit.DataImports.PluginHost host) {
2908- debug("FSpotDataImporter instantiated.");
2909+ public FSpotDataImporter (Spit.DataImports.Service service,
2910+ Spit.DataImports.PluginHost host) {
2911+ debug ("FSpotDataImporter instantiated.");
2912 this.service = service;
2913 this.host = host;
2914 }
2915-
2916- private bool is_running() {
2917+
2918+ private bool is_running () {
2919 return running;
2920 }
2921-
2922- public Spit.DataImports.Service get_service() {
2923+
2924+ public Spit.DataImports.Service get_service () {
2925 return service;
2926 }
2927
2928- public void start() {
2929- if (is_running())
2930+ public void start () {
2931+ if (is_running ())
2932 return;
2933-
2934- debug("FSpotDataImporter: starting interaction.");
2935-
2936+
2937+ debug ("FSpotDataImporter: starting interaction.");
2938+
2939 running = true;
2940-
2941- do_discover_importable_libraries();
2942+
2943+ do_discover_importable_libraries ();
2944 }
2945
2946- public void stop() {
2947- debug("FSpotDataImporter: stopping interaction.");
2948-
2949+ public void stop () {
2950+ debug ("FSpotDataImporter: stopping interaction.");
2951+
2952 running = false;
2953 }
2954-
2955+
2956 // Actions and event implementation
2957-
2958+
2959 /**
2960 * Action that discovers importable libraries based on standard locations.
2961 */
2962- private void do_discover_importable_libraries() {
2963+ private void do_discover_importable_libraries () {
2964 Spit.DataImports.ImportableLibrary[] discovered_libraries =
2965 new Spit.DataImports.ImportableLibrary[0];
2966-
2967+
2968 File[] db_files = {
2969 // where the DB is in Ubuntu Lucid
2970- File.new_for_path(Environment.get_user_config_dir()).
2971- get_child("f-spot").get_child("photos.db"),
2972+ File.new_for_path (Environment.get_user_config_dir ()).
2973+ get_child ("f-spot").get_child ("photos.db"),
2974 // where it seems to be in Ubuntu Jaunty
2975- File.new_for_path(Environment.get_home_dir()).get_child(".gnome2").
2976- get_child("f-spot").get_child("photos.db"),
2977+ File.new_for_path (Environment.get_home_dir ()).get_child (".gnome2").
2978+ get_child ("f-spot").get_child ("photos.db"),
2979 // where it should really be if it followed the XDG spec
2980- File.new_for_path(Environment.get_user_data_dir()).
2981- get_child("f-spot").get_child("photos.db")
2982+ File.new_for_path (Environment.get_user_data_dir ()).
2983+ get_child ("f-spot").get_child ("photos.db")
2984 };
2985-
2986+
2987 foreach (File db_file in db_files) {
2988- if (db_file.query_exists(null)) {
2989- discovered_libraries += new FSpotImportableLibrary(db_file);
2990- message("Discovered importable library: %s", db_file.get_path());
2991+ if (db_file.query_exists (null)) {
2992+ discovered_libraries += new FSpotImportableLibrary (db_file);
2993+ message ("Discovered importable library: %s", db_file.get_path ());
2994 }
2995 }
2996-
2997- host.install_library_selection_pane(
2998+
2999+ host.install_library_selection_pane (
3000 (discovered_libraries.length > 0 ? SERVICE_WELCOME_MESSAGE : SERVICE_WELCOME_MESSAGE_FILE_ONLY),
3001 discovered_libraries,
3002 FILE_IMPORT_LABEL
3003 );
3004 }
3005-
3006- public void on_library_selected(Spit.DataImports.ImportableLibrary library) {
3007- on_file_selected(((FSpotImportableLibrary)library).get_db_file());
3008+
3009+ public void on_library_selected (Spit.DataImports.ImportableLibrary library) {
3010+ on_file_selected (((FSpotImportableLibrary)library).get_db_file ());
3011 }
3012-
3013- public void on_file_selected(File file) {
3014+
3015+ public void on_file_selected (File file) {
3016 DataImports.FSpot.Db.FSpotDatabase database;
3017 FSpotTagsCache tags_cache;
3018 Gee.ArrayList<DataImports.FSpot.Db.FSpotPhotoRow> all_photos;
3019@@ -396,29 +396,29 @@
3020 double progress_plugin_to_host_ratio = 0.5;
3021 double current_progress = 0.0;
3022 try {
3023- database = new DataImports.FSpot.Db.FSpotDatabase(file);
3024- } catch(DatabaseError e) {
3025- debug("FSpotDataImporter: Can't open database file: %s".printf(e.message));
3026- host.post_error_message(ERROR_CANT_OPEN_DB_FILE);
3027- return;
3028- } catch(Spit.DataImports.DataImportError e) {
3029- debug("FSpotDataImporter: Unsupported F-Spot database version: %s".printf(e.message));
3030- host.post_error_message(ERROR_UNSUPPORTED_DB_VERSION);
3031- return;
3032- }
3033- try {
3034- tags_cache = new FSpotTagsCache(database.tags_table);
3035- } catch(DatabaseError e) {
3036- debug("FSpotDataImporter: Can't read tags table: %s".printf(e.message));
3037- host.post_error_message(ERROR_CANT_READ_TAGS_TABLE);
3038- return;
3039- }
3040- host.install_import_progress_pane(_("Preparing to import"));
3041- try {
3042- all_photos = database.photos_table.get_all();
3043- } catch(DatabaseError e) {
3044- debug("FSpotDataImporter: Can't read photos table: %s".printf(e.message));
3045- host.post_error_message(ERROR_CANT_READ_PHOTOS_TABLE);
3046+ database = new DataImports.FSpot.Db.FSpotDatabase (file);
3047+ } catch (DatabaseError e) {
3048+ debug ("FSpotDataImporter: Can't open database file: %s".printf (e.message));
3049+ host.post_error_message (ERROR_CANT_OPEN_DB_FILE);
3050+ return;
3051+ } catch (Spit.DataImports.DataImportError e) {
3052+ debug ("FSpotDataImporter: Unsupported F-Spot database version: %s".printf (e.message));
3053+ host.post_error_message (ERROR_UNSUPPORTED_DB_VERSION);
3054+ return;
3055+ }
3056+ try {
3057+ tags_cache = new FSpotTagsCache (database.tags_table);
3058+ } catch (DatabaseError e) {
3059+ debug ("FSpotDataImporter: Can't read tags table: %s".printf (e.message));
3060+ host.post_error_message (ERROR_CANT_READ_TAGS_TABLE);
3061+ return;
3062+ }
3063+ host.install_import_progress_pane (_ ("Preparing to import"));
3064+ try {
3065+ all_photos = database.photos_table.get_all ();
3066+ } catch (DatabaseError e) {
3067+ debug ("FSpotDataImporter: Can't read photos table: %s".printf (e.message));
3068+ host.post_error_message (ERROR_CANT_READ_PHOTOS_TABLE);
3069 return;
3070 }
3071 if (all_photos.size > 0)
3072@@ -429,7 +429,7 @@
3073 FSpotImportableTag[] tags = new FSpotImportableTag[0];
3074 FSpotImportableEvent? event = null;
3075 DataImports.FSpot.Db.FSpotRollRow? roll_row = null;
3076-
3077+
3078 // TODO: We do not convert F-Spot events to Shotwell events because F-Spot's events
3079 // are essentially tags. We would need to detect if the tag is an event (use
3080 // is_tag_event) and then assign the event to the photo ... since a photo can be
3081@@ -438,126 +438,126 @@
3082 try {
3083 foreach (
3084 DataImports.FSpot.Db.FSpotTagRow tag_row in
3085- database.tags_table.get_by_photo_id(photo_row.photo_id)
3086+ database.tags_table.get_by_photo_id (photo_row.photo_id)
3087 ) {
3088- FSpotImportableTag tag = tags_cache.get_tag(tag_row);
3089- if (is_tag_hidden(tag, database.hidden_tag_id))
3090+ FSpotImportableTag tag = tags_cache.get_tag (tag_row);
3091+ if (is_tag_hidden (tag, database.hidden_tag_id))
3092 hidden = true;
3093- else if (is_tag_favorite(tag))
3094+ else if (is_tag_favorite (tag))
3095 favorite = true;
3096 else
3097 tags += tag;
3098 }
3099- } catch(DatabaseError e) {
3100+ } catch (DatabaseError e) {
3101 // log the error and leave the tag list empty
3102- message("Failed to retrieve tags for photo ID %ld: %s", (long) photo_row.photo_id,
3103- e.message);
3104+ message ("Failed to retrieve tags for photo ID %ld: %s", (long) photo_row.photo_id,
3105+ e.message);
3106 }
3107-
3108+
3109 try {
3110- roll_row = database.rolls_table.get_by_id(photo_row.roll_id);
3111+ roll_row = database.rolls_table.get_by_id (photo_row.roll_id);
3112 } catch (DatabaseError e) {
3113 // log the error and leave the roll row null
3114- message("Failed to retrieve roll for photo ID %ld: %s", (long) photo_row.photo_id,
3115- e.message);
3116+ message ("Failed to retrieve roll for photo ID %ld: %s", (long) photo_row.photo_id,
3117+ e.message);
3118 }
3119-
3120+
3121 Spit.DataImports.ImportableMediaItem[] importable_items = new Spit.DataImports.ImportableMediaItem[0];
3122 try {
3123 Gee.ArrayList<DataImports.FSpot.Db.FSpotPhotoVersionRow> photo_versions =
3124- database.photo_versions_table.get_by_photo_id(photo_row.photo_id);
3125+ database.photo_versions_table.get_by_photo_id (photo_row.photo_id);
3126 bool photo_versions_added = false; // set to true if at least one version was added
3127 bool photo_versions_skipped = false; // set to true if at least one version was skipped due to missing file details
3128 foreach (DataImports.FSpot.Db.FSpotPhotoVersionRow photo_version_row in photo_versions) {
3129 if (photo_version_row.base_path != null && photo_version_row.filename != null) {
3130- importable_items += new FSpotImportableItem(
3131- photo_row, photo_version_row, roll_row, tags, event, hidden, favorite
3132- );
3133+ importable_items += new FSpotImportableItem (
3134+ photo_row, photo_version_row, roll_row, tags, event, hidden, favorite
3135+ );
3136 photo_versions_added = true;
3137 } else {
3138 photo_versions_skipped = true;
3139 }
3140 }
3141-
3142+
3143 // Older versions of F-Spot (0.4.3.1 at least, perhaps later) did not maintain photo_versions,
3144 // this handles that case
3145 // It also handles the case when we had to skip any photo version due to missing
3146 // file details
3147 if (photo_versions_skipped || !photo_versions_added) {
3148 if (photo_row.base_path != null && photo_row.filename != null) {
3149- importable_items += new FSpotImportableItem(
3150- photo_row, null, roll_row, tags, event, hidden, favorite
3151- );
3152+ importable_items += new FSpotImportableItem (
3153+ photo_row, null, roll_row, tags, event, hidden, favorite
3154+ );
3155 }
3156 }
3157 } catch (DatabaseError e) {
3158 // if we can't load the different versions, do the best we can
3159 // and create one photo from the photo row that was found earlier
3160- message("Failed to retrieve versions for photo ID %ld: %s", (long) photo_row.photo_id,
3161- e.message);
3162+ message ("Failed to retrieve versions for photo ID %ld: %s", (long) photo_row.photo_id,
3163+ e.message);
3164 if (photo_row.base_path != null && photo_row.filename != null) {
3165- importable_items += new FSpotImportableItem(
3166- photo_row, null, roll_row, tags, event, hidden, favorite
3167- );
3168+ importable_items += new FSpotImportableItem (
3169+ photo_row, null, roll_row, tags, event, hidden, favorite
3170+ );
3171 }
3172 }
3173 // If the importer is still running, import the items and loop,
3174 // otherwise break the loop
3175 if (running) {
3176- host.prepare_media_items_for_import(
3177+ host.prepare_media_items_for_import (
3178 importable_items,
3179 current_progress + (progress_delta_per_photo * progress_plugin_to_host_ratio),
3180 progress_delta_per_photo * (1 - progress_plugin_to_host_ratio),
3181 null
3182 );
3183 current_progress += progress_delta_per_photo;
3184- host.update_import_progress_pane(current_progress);
3185+ host.update_import_progress_pane (current_progress);
3186 } else {
3187 break;
3188 }
3189 }
3190- host.finalize_import(on_imported_items_count);
3191+ host.finalize_import (on_imported_items_count);
3192 }
3193-
3194- public void on_imported_items_count(int imported_items_count) {
3195- host.install_static_message_pane(
3196- MESSAGE_FINAL_SCREEN.printf(imported_items_count),
3197+
3198+ public void on_imported_items_count (int imported_items_count) {
3199+ host.install_static_message_pane (
3200+ MESSAGE_FINAL_SCREEN.printf (imported_items_count),
3201 Spit.DataImports.PluginHost.ButtonMode.CLOSE
3202 );
3203 }
3204-
3205- private bool is_tag_event(FSpotImportableTag tag) {
3206- bool result = (DataImports.FSpot.Db.FSpotTagsTable.STOCK_ICON_EVENTS == tag.get_stock_icon());
3207- if (!result) {
3208- FSpotImportableTag? parent = tag.get_fspot_parent();
3209- if (parent == null)
3210- result = false;
3211- else
3212- result = is_tag_event(parent);
3213- }
3214- return result;
3215- }
3216-
3217- private bool is_tag_hidden(FSpotImportableTag tag, int64 hidden_tag_id) {
3218- bool result = (hidden_tag_id == tag.get_id());
3219- if (!result) {
3220- FSpotImportableTag? parent = tag.get_fspot_parent();
3221- if (parent == null)
3222- result = false;
3223- else
3224- result = is_tag_hidden(parent, hidden_tag_id);
3225- }
3226- return result;
3227- }
3228-
3229- private bool is_tag_favorite(FSpotImportableTag tag) {
3230- bool result = (DataImports.FSpot.Db.FSpotTagsTable.STOCK_ICON_FAV == tag.get_stock_icon());
3231- if (!result) {
3232- FSpotImportableTag? parent = tag.get_fspot_parent();
3233- if (parent == null)
3234- result = false;
3235- else
3236- result = is_tag_favorite(parent);
3237+
3238+ private bool is_tag_event (FSpotImportableTag tag) {
3239+ bool result = (DataImports.FSpot.Db.FSpotTagsTable.STOCK_ICON_EVENTS == tag.get_stock_icon ());
3240+ if (!result) {
3241+ FSpotImportableTag? parent = tag.get_fspot_parent ();
3242+ if (parent == null)
3243+ result = false;
3244+ else
3245+ result = is_tag_event (parent);
3246+ }
3247+ return result;
3248+ }
3249+
3250+ private bool is_tag_hidden (FSpotImportableTag tag, int64 hidden_tag_id) {
3251+ bool result = (hidden_tag_id == tag.get_id ());
3252+ if (!result) {
3253+ FSpotImportableTag? parent = tag.get_fspot_parent ();
3254+ if (parent == null)
3255+ result = false;
3256+ else
3257+ result = is_tag_hidden (parent, hidden_tag_id);
3258+ }
3259+ return result;
3260+ }
3261+
3262+ private bool is_tag_favorite (FSpotImportableTag tag) {
3263+ bool result = (DataImports.FSpot.Db.FSpotTagsTable.STOCK_ICON_FAV == tag.get_stock_icon ());
3264+ if (!result) {
3265+ FSpotImportableTag? parent = tag.get_fspot_parent ();
3266+ if (parent == null)
3267+ result = false;
3268+ else
3269+ result = is_tag_favorite (parent);
3270 }
3271 return result;
3272 }
3273
3274=== modified file 'plugins/shotwell-data-imports/FSpotMetaTable.vala'
3275--- plugins/shotwell-data-imports/FSpotMetaTable.vala 2013-01-21 21:16:09 +0000
3276+++ plugins/shotwell-data-imports/FSpotMetaTable.vala 2014-08-08 21:16:43 +0000
3277@@ -30,50 +30,50 @@
3278 * attempting to read the rest of the database so we might as well abort.
3279 */
3280 public class FSpotMetaTable : FSpotDatabaseTable<FSpotMetaRow> {
3281-
3282- public FSpotMetaTable(Sqlite.Database db) {
3283- base(db);
3284- set_behavior(FSpotMetaBehavior.get_instance());
3285+
3286+ public FSpotMetaTable (Sqlite.Database db) {
3287+ base (db);
3288+ set_behavior (FSpotMetaBehavior.get_instance ());
3289 }
3290-
3291- public string? get_data(string name) throws DatabaseError {
3292- string[] columns = behavior.list_columns();
3293- string column_list = string.joinv(", ", columns);
3294- string sql = "SELECT %s FROM %s WHERE name=?".printf(column_list, table_name);
3295+
3296+ public string? get_data (string name) throws DatabaseError {
3297+ string[] columns = behavior.list_columns ();
3298+ string column_list = string.joinv (", ", columns);
3299+ string sql = "SELECT %s FROM %s WHERE name=?".printf (column_list, table_name);
3300 Sqlite.Statement stmt;
3301- int res = fspot_db.prepare_v2(sql, -1, out stmt);
3302- if (res != Sqlite.OK)
3303- throw_error("Statement failed: %s".printf(sql), res);
3304-
3305- res = stmt.bind_text(1, name);
3306- if (res != Sqlite.OK)
3307- throw_error("Bind failed for name %s".printf(name), res);
3308-
3309- res = stmt.step();
3310+ int res = fspot_db.prepare_v2 (sql, -1, out stmt);
3311+ if (res != Sqlite.OK)
3312+ throw_error ("Statement failed: %s".printf (sql), res);
3313+
3314+ res = stmt.bind_text (1, name);
3315+ if (res != Sqlite.OK)
3316+ throw_error ("Bind failed for name %s".printf (name), res);
3317+
3318+ res = stmt.step ();
3319 if (res != Sqlite.ROW) {
3320 if (res != Sqlite.DONE)
3321- throw_error("FSpotMetaTable.get_data", res);
3322-
3323+ throw_error ("FSpotMetaTable.get_data", res);
3324+
3325 return null;
3326 }
3327-
3328+
3329 FSpotMetaRow row;
3330- behavior.build_row(stmt, out row);
3331+ behavior.build_row (stmt, out row);
3332 return row.data;
3333 }
3334-
3335- public string? get_app_version() throws DatabaseError {
3336- return get_data("F-Spot Version");
3337- }
3338-
3339- public string? get_db_version() throws DatabaseError {
3340- return get_data("F-Spot Database Version");
3341- }
3342-
3343- public int64 get_hidden_tag_id() throws DatabaseError {
3344- string id_str = get_data("Hidden Tag Id");
3345- if(id_str != null) {
3346- return int64.parse(id_str);
3347+
3348+ public string? get_app_version () throws DatabaseError {
3349+ return get_data ("F-Spot Version");
3350+ }
3351+
3352+ public string? get_db_version () throws DatabaseError {
3353+ return get_data ("F-Spot Database Version");
3354+ }
3355+
3356+ public int64 get_hidden_tag_id () throws DatabaseError {
3357+ string id_str = get_data ("Hidden Tag Id");
3358+ if (id_str != null) {
3359+ return int64.parse (id_str);
3360 } else {
3361 return -1;
3362 }
3363@@ -82,30 +82,30 @@
3364
3365 public class FSpotMetaBehavior : FSpotTableBehavior<FSpotMetaRow>, Object {
3366 public static const string TABLE_NAME = "Meta";
3367-
3368+
3369 private static FSpotMetaBehavior instance;
3370-
3371- private FSpotMetaBehavior() {
3372+
3373+ private FSpotMetaBehavior () {
3374 }
3375-
3376- public static FSpotMetaBehavior get_instance() {
3377+
3378+ public static FSpotMetaBehavior get_instance () {
3379 if (instance == null)
3380- instance = new FSpotMetaBehavior();
3381+ instance = new FSpotMetaBehavior ();
3382 return instance;
3383 }
3384-
3385- public string get_table_name() {
3386+
3387+ public string get_table_name () {
3388 return TABLE_NAME;
3389 }
3390-
3391- public string[] list_columns() {
3392+
3393+ public string[] list_columns () {
3394 return { "name", "data" };
3395 }
3396-
3397- public void build_row(Sqlite.Statement stmt, out FSpotMetaRow row, int offset = 0) {
3398- row = new FSpotMetaRow();
3399- row.name = stmt.column_text(offset + 0);
3400- row.data = stmt.column_text(offset + 1);
3401+
3402+ public void build_row (Sqlite.Statement stmt, out FSpotMetaRow row, int offset = 0) {
3403+ row = new FSpotMetaRow ();
3404+ row.name = stmt.column_text (offset + 0);
3405+ row.data = stmt.column_text (offset + 1);
3406 }
3407 }
3408
3409
3410=== modified file 'plugins/shotwell-data-imports/FSpotPhotoTagsTable.vala'
3411--- plugins/shotwell-data-imports/FSpotPhotoTagsTable.vala 2013-01-21 21:16:09 +0000
3412+++ plugins/shotwell-data-imports/FSpotPhotoTagsTable.vala 2014-08-08 21:16:43 +0000
3413@@ -19,37 +19,37 @@
3414 */
3415 public class FSpotPhotoTagsTable : FSpotDatabaseTable<FSpotPhotoTagRow> {
3416 public static const string TABLE_NAME = "Photo_Tags";
3417-
3418- public FSpotPhotoTagsTable(Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
3419- base(db);
3420- set_behavior(db_behavior.get_photo_tags_behavior());
3421+
3422+ public FSpotPhotoTagsTable (Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
3423+ base (db);
3424+ set_behavior (db_behavior.get_photo_tags_behavior ());
3425 }
3426 }
3427
3428 public class FSpotPhotoTagsV0Behavior : FSpotTableBehavior<FSpotPhotoTagRow>, Object {
3429 private static FSpotPhotoTagsV0Behavior instance;
3430-
3431- private FSpotPhotoTagsV0Behavior() {
3432+
3433+ private FSpotPhotoTagsV0Behavior () {
3434 }
3435-
3436- public static FSpotPhotoTagsV0Behavior get_instance() {
3437+
3438+ public static FSpotPhotoTagsV0Behavior get_instance () {
3439 if (instance == null)
3440- instance = new FSpotPhotoTagsV0Behavior();
3441+ instance = new FSpotPhotoTagsV0Behavior ();
3442 return instance;
3443 }
3444-
3445- public string get_table_name() {
3446+
3447+ public string get_table_name () {
3448 return FSpotPhotoTagsTable.TABLE_NAME;
3449 }
3450
3451- public string[] list_columns() {
3452+ public string[] list_columns () {
3453 return { "photo_id", "tag_id" };
3454 }
3455-
3456- public void build_row(Sqlite.Statement stmt, out FSpotPhotoTagRow row, int offset = 0) {
3457- row = new FSpotPhotoTagRow();
3458- row.photo_id = stmt.column_int64(offset + 0);
3459- row.tag_id = stmt.column_int64(offset + 1);
3460+
3461+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoTagRow row, int offset = 0) {
3462+ row = new FSpotPhotoTagRow ();
3463+ row.photo_id = stmt.column_int64 (offset + 0);
3464+ row.tag_id = stmt.column_int64 (offset + 1);
3465 }
3466 }
3467
3468
3469=== modified file 'plugins/shotwell-data-imports/FSpotPhotoVersionsTable.vala'
3470--- plugins/shotwell-data-imports/FSpotPhotoVersionsTable.vala 2013-01-21 21:16:09 +0000
3471+++ plugins/shotwell-data-imports/FSpotPhotoVersionsTable.vala 2014-08-08 21:16:43 +0000
3472@@ -25,37 +25,37 @@
3473 public class FSpotPhotoVersionsTable : FSpotDatabaseTable<FSpotPhotoVersionRow> {
3474 public static const string TABLE_NAME = "Photo_versions";
3475
3476- public FSpotPhotoVersionsTable(Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
3477- base(db);
3478- set_behavior(db_behavior.get_photo_versions_behavior());
3479+ public FSpotPhotoVersionsTable (Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
3480+ base (db);
3481+ set_behavior (db_behavior.get_photo_versions_behavior ());
3482 }
3483-
3484- public Gee.ArrayList<FSpotPhotoVersionRow> get_by_photo_id(int64 photo_id) throws DatabaseError {
3485- Gee.ArrayList<FSpotPhotoVersionRow> rows = new Gee.ArrayList<FSpotPhotoVersionRow?>();
3486-
3487+
3488+ public Gee.ArrayList<FSpotPhotoVersionRow> get_by_photo_id (int64 photo_id) throws DatabaseError {
3489+ Gee.ArrayList<FSpotPhotoVersionRow> rows = new Gee.ArrayList < FSpotPhotoVersionRow?> ();
3490+
3491 Sqlite.Statement stmt;
3492-
3493- string column_list = get_joined_column_list();
3494- string sql = "SELECT %s FROM %s WHERE photo_id=?".printf(
3495+
3496+ string column_list = get_joined_column_list ();
3497+ string sql = "SELECT %s FROM %s WHERE photo_id=?".printf (
3498 column_list, table_name
3499 );
3500
3501- int res = fspot_db.prepare_v2(sql, -1, out stmt);
3502- if (res != Sqlite.OK)
3503- throw_error("Statement failed: %s".printf(sql), res);
3504-
3505- res = stmt.bind_int64(1, photo_id);
3506- if (res != Sqlite.OK)
3507- throw_error("Bind failed for photo_id", res);
3508-
3509- res = stmt.step();
3510+ int res = fspot_db.prepare_v2 (sql, -1, out stmt);
3511+ if (res != Sqlite.OK)
3512+ throw_error ("Statement failed: %s".printf (sql), res);
3513+
3514+ res = stmt.bind_int64 (1, photo_id);
3515+ if (res != Sqlite.OK)
3516+ throw_error ("Bind failed for photo_id", res);
3517+
3518+ res = stmt.step ();
3519 while (res == Sqlite.ROW) {
3520 FSpotPhotoVersionRow row;
3521- behavior.build_row(stmt, out row);
3522- rows.add(row);
3523- res = stmt.step();
3524+ behavior.build_row (stmt, out row);
3525+ rows.add (row);
3526+ res = stmt.step ();
3527 }
3528-
3529+
3530 return rows;
3531 }
3532 }
3533@@ -66,35 +66,35 @@
3534 // be handled in a way identical to v0-7
3535 public class FSpotPhotoVersionsV0Behavior : FSpotTableBehavior<FSpotPhotoVersionRow>, Object {
3536 private static FSpotPhotoVersionsV0Behavior instance;
3537-
3538- private FSpotPhotoVersionsV0Behavior() {
3539+
3540+ private FSpotPhotoVersionsV0Behavior () {
3541 }
3542-
3543- public static FSpotPhotoVersionsV0Behavior get_instance() {
3544+
3545+ public static FSpotPhotoVersionsV0Behavior get_instance () {
3546 if (instance == null)
3547- instance = new FSpotPhotoVersionsV0Behavior();
3548+ instance = new FSpotPhotoVersionsV0Behavior ();
3549 return instance;
3550 }
3551-
3552- public string get_table_name() {
3553+
3554+ public string get_table_name () {
3555 return FSpotPhotoVersionsTable.TABLE_NAME;
3556- }
3557-
3558- public string[] list_columns() {
3559+ }
3560+
3561+ public string[] list_columns () {
3562 return { "photo_id", "version_id", "name", "uri" };
3563 }
3564-
3565- public void build_row(Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3566- row = new FSpotPhotoVersionRow();
3567- row.photo_id = stmt.column_int64(offset + 0);
3568- row.version_id = stmt.column_int64(offset + 1);
3569- row.name = stmt.column_text(offset + 2);
3570-
3571- string? full_path = stmt.column_text(offset + 3);
3572+
3573+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3574+ row = new FSpotPhotoVersionRow ();
3575+ row.photo_id = stmt.column_int64 (offset + 0);
3576+ row.version_id = stmt.column_int64 (offset + 1);
3577+ row.name = stmt.column_text (offset + 2);
3578+
3579+ string? full_path = stmt.column_text (offset + 3);
3580 if (full_path != null) {
3581- File uri = File.new_for_uri(full_path);
3582- row.base_path = uri.get_parent();
3583- row.filename = uri.get_basename();
3584+ File uri = File.new_for_uri (full_path);
3585+ row.base_path = uri.get_parent ();
3586+ row.filename = uri.get_basename ();
3587 }
3588
3589 row.md5_sum = "";
3590@@ -106,40 +106,41 @@
3591 // add protected field
3592 public class FSpotPhotoVersionsV9Behavior : FSpotTableBehavior<FSpotPhotoVersionRow>, Object {
3593 private static FSpotPhotoVersionsV9Behavior instance;
3594-
3595- private FSpotPhotoVersionsV9Behavior() {
3596+
3597+ private FSpotPhotoVersionsV9Behavior () {
3598 }
3599-
3600- public static FSpotPhotoVersionsV9Behavior get_instance() {
3601+
3602+ public static FSpotPhotoVersionsV9Behavior get_instance () {
3603 if (instance == null)
3604- instance = new FSpotPhotoVersionsV9Behavior();
3605+ instance = new FSpotPhotoVersionsV9Behavior ();
3606 return instance;
3607 }
3608-
3609- public string get_table_name() {
3610+
3611+ public string get_table_name () {
3612 return FSpotPhotoVersionsTable.TABLE_NAME;
3613- }
3614-
3615- public string[] list_columns() {
3616+ }
3617+
3618+ public string[] list_columns () {
3619 return { "photo_id", "version_id", "name", "uri",
3620- "protected" };
3621+ "protected"
3622+ };
3623 }
3624-
3625- public void build_row(Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3626- row = new FSpotPhotoVersionRow();
3627- row.photo_id = stmt.column_int64(offset + 0);
3628- row.version_id = stmt.column_int64(offset + 1);
3629- row.name = stmt.column_text(offset + 2);
3630-
3631- string? full_path = stmt.column_text(offset + 3);
3632+
3633+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3634+ row = new FSpotPhotoVersionRow ();
3635+ row.photo_id = stmt.column_int64 (offset + 0);
3636+ row.version_id = stmt.column_int64 (offset + 1);
3637+ row.name = stmt.column_text (offset + 2);
3638+
3639+ string? full_path = stmt.column_text (offset + 3);
3640 if (full_path != null) {
3641- File uri = File.new_for_uri(full_path);
3642- row.base_path = uri.get_parent();
3643- row.filename = uri.get_basename();
3644+ File uri = File.new_for_uri (full_path);
3645+ row.base_path = uri.get_parent ();
3646+ row.filename = uri.get_basename ();
3647 }
3648
3649 row.md5_sum = "";
3650- row.is_protected = (stmt.column_int(offset + 4) > 0);
3651+ row.is_protected = (stmt.column_int (offset + 4) > 0);
3652 }
3653 }
3654
3655@@ -147,40 +148,41 @@
3656 // add md5_sum in photo_versions
3657 public class FSpotPhotoVersionsV16Behavior : FSpotTableBehavior<FSpotPhotoVersionRow>, Object {
3658 private static FSpotPhotoVersionsV16Behavior instance;
3659-
3660- private FSpotPhotoVersionsV16Behavior() {
3661+
3662+ private FSpotPhotoVersionsV16Behavior () {
3663 }
3664-
3665- public static FSpotPhotoVersionsV16Behavior get_instance() {
3666+
3667+ public static FSpotPhotoVersionsV16Behavior get_instance () {
3668 if (instance == null)
3669- instance = new FSpotPhotoVersionsV16Behavior();
3670+ instance = new FSpotPhotoVersionsV16Behavior ();
3671 return instance;
3672 }
3673-
3674- public string get_table_name() {
3675+
3676+ public string get_table_name () {
3677 return FSpotPhotoVersionsTable.TABLE_NAME;
3678- }
3679-
3680- public string[] list_columns() {
3681+ }
3682+
3683+ public string[] list_columns () {
3684 return { "photo_id", "version_id", "name", "uri",
3685- "md5_sum", "protected" };
3686+ "md5_sum", "protected"
3687+ };
3688 }
3689-
3690- public void build_row(Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3691- row = new FSpotPhotoVersionRow();
3692- row.photo_id = stmt.column_int64(offset + 0);
3693- row.version_id = stmt.column_int64(offset + 1);
3694- row.name = stmt.column_text(offset + 2);
3695-
3696- string? full_path = stmt.column_text(offset + 3);
3697+
3698+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3699+ row = new FSpotPhotoVersionRow ();
3700+ row.photo_id = stmt.column_int64 (offset + 0);
3701+ row.version_id = stmt.column_int64 (offset + 1);
3702+ row.name = stmt.column_text (offset + 2);
3703+
3704+ string? full_path = stmt.column_text (offset + 3);
3705 if (full_path != null) {
3706- File uri = File.new_for_uri(full_path);
3707- row.base_path = uri.get_parent();
3708- row.filename = uri.get_basename();
3709+ File uri = File.new_for_uri (full_path);
3710+ row.base_path = uri.get_parent ();
3711+ row.filename = uri.get_basename ();
3712 }
3713
3714- row.md5_sum = stmt.column_text(offset + 4);
3715- row.is_protected = (stmt.column_int(offset + 5) > 0);
3716+ row.md5_sum = stmt.column_text (offset + 4);
3717+ row.is_protected = (stmt.column_int (offset + 5) > 0);
3718 }
3719 }
3720
3721@@ -189,40 +191,41 @@
3722 // design introduced in v0, albeit with a URI rather than a file system path)
3723 public class FSpotPhotoVersionsV17Behavior : FSpotTableBehavior<FSpotPhotoVersionRow>, Object {
3724 private static FSpotPhotoVersionsV17Behavior instance;
3725-
3726- private FSpotPhotoVersionsV17Behavior() {
3727+
3728+ private FSpotPhotoVersionsV17Behavior () {
3729 }
3730-
3731- public static FSpotPhotoVersionsV17Behavior get_instance() {
3732+
3733+ public static FSpotPhotoVersionsV17Behavior get_instance () {
3734 if (instance == null)
3735- instance = new FSpotPhotoVersionsV17Behavior();
3736+ instance = new FSpotPhotoVersionsV17Behavior ();
3737 return instance;
3738 }
3739-
3740- public string get_table_name() {
3741+
3742+ public string get_table_name () {
3743 return FSpotPhotoVersionsTable.TABLE_NAME;
3744- }
3745-
3746- public string[] list_columns() {
3747+ }
3748+
3749+ public string[] list_columns () {
3750 return { "photo_id", "version_id", "name", "base_uri", "filename",
3751- "md5_sum", "protected" };
3752+ "md5_sum", "protected"
3753+ };
3754 }
3755-
3756- public void build_row(Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3757- row = new FSpotPhotoVersionRow();
3758- row.photo_id = stmt.column_int64(offset + 0);
3759- row.version_id = stmt.column_int64(offset + 1);
3760- row.name = stmt.column_text(offset + 2);
3761-
3762- string? base_path = stmt.column_text(offset + 3);
3763- string? filename = stmt.column_text(offset + 4);
3764+
3765+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3766+ row = new FSpotPhotoVersionRow ();
3767+ row.photo_id = stmt.column_int64 (offset + 0);
3768+ row.version_id = stmt.column_int64 (offset + 1);
3769+ row.name = stmt.column_text (offset + 2);
3770+
3771+ string? base_path = stmt.column_text (offset + 3);
3772+ string? filename = stmt.column_text (offset + 4);
3773 if (base_path != null && filename != null) {
3774- row.base_path = File.new_for_uri(base_path);
3775+ row.base_path = File.new_for_uri (base_path);
3776 row.filename = filename;
3777 }
3778-
3779- row.md5_sum = stmt.column_text(offset + 5);
3780- row.is_protected = (stmt.column_int(offset + 6) > 0);
3781+
3782+ row.md5_sum = stmt.column_text (offset + 5);
3783+ row.is_protected = (stmt.column_int (offset + 6) > 0);
3784 }
3785 }
3786
3787@@ -230,40 +233,41 @@
3788 // md5_sum renamed import_md5
3789 public class FSpotPhotoVersionsV18Behavior : FSpotTableBehavior<FSpotPhotoVersionRow>, Object {
3790 private static FSpotPhotoVersionsV18Behavior instance;
3791-
3792- private FSpotPhotoVersionsV18Behavior() {
3793+
3794+ private FSpotPhotoVersionsV18Behavior () {
3795 }
3796-
3797- public static FSpotPhotoVersionsV18Behavior get_instance() {
3798+
3799+ public static FSpotPhotoVersionsV18Behavior get_instance () {
3800 if (instance == null)
3801- instance = new FSpotPhotoVersionsV18Behavior();
3802+ instance = new FSpotPhotoVersionsV18Behavior ();
3803 return instance;
3804 }
3805-
3806- public string get_table_name() {
3807+
3808+ public string get_table_name () {
3809 return FSpotPhotoVersionsTable.TABLE_NAME;
3810- }
3811-
3812- public string[] list_columns() {
3813+ }
3814+
3815+ public string[] list_columns () {
3816 return { "photo_id", "version_id", "name", "base_uri", "filename",
3817- "import_md5", "protected" };
3818+ "import_md5", "protected"
3819+ };
3820 }
3821-
3822- public void build_row(Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3823- row = new FSpotPhotoVersionRow();
3824- row.photo_id = stmt.column_int64(offset + 0);
3825- row.version_id = stmt.column_int64(offset + 1);
3826- row.name = stmt.column_text(offset + 2);
3827-
3828- string? base_path = stmt.column_text(offset + 3);
3829- string? filename = stmt.column_text(offset + 4);
3830+
3831+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoVersionRow row, int offset = 0) {
3832+ row = new FSpotPhotoVersionRow ();
3833+ row.photo_id = stmt.column_int64 (offset + 0);
3834+ row.version_id = stmt.column_int64 (offset + 1);
3835+ row.name = stmt.column_text (offset + 2);
3836+
3837+ string? base_path = stmt.column_text (offset + 3);
3838+ string? filename = stmt.column_text (offset + 4);
3839 if (base_path != null && filename != null) {
3840- row.base_path = File.new_for_uri(base_path);
3841+ row.base_path = File.new_for_uri (base_path);
3842 row.filename = filename;
3843 }
3844-
3845- row.md5_sum = stmt.column_text(offset + 5);
3846- row.is_protected = (stmt.column_int(offset + 6) > 0);
3847+
3848+ row.md5_sum = stmt.column_text (offset + 5);
3849+ row.is_protected = (stmt.column_int (offset + 6) > 0);
3850 }
3851 }
3852
3853
3854=== modified file 'plugins/shotwell-data-imports/FSpotPhotosTable.vala'
3855--- plugins/shotwell-data-imports/FSpotPhotosTable.vala 2013-01-21 21:16:09 +0000
3856+++ plugins/shotwell-data-imports/FSpotPhotosTable.vala 2014-08-08 21:16:43 +0000
3857@@ -26,24 +26,24 @@
3858 */
3859 public class FSpotPhotosTable : FSpotDatabaseTable<FSpotPhotoRow> {
3860 public static const string TABLE_NAME = "Photos";
3861-
3862- public FSpotPhotosTable(Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
3863- base(db);
3864- set_behavior(db_behavior.get_photos_behavior());
3865+
3866+ public FSpotPhotosTable (Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
3867+ base (db);
3868+ set_behavior (db_behavior.get_photos_behavior ());
3869 }
3870-
3871- public Gee.ArrayList<FSpotPhotoRow> get_all() throws DatabaseError {
3872- Gee.ArrayList<FSpotPhotoRow> all = new Gee.ArrayList<FSpotPhotoRow?>();
3873-
3874+
3875+ public Gee.ArrayList<FSpotPhotoRow> get_all () throws DatabaseError {
3876+ Gee.ArrayList<FSpotPhotoRow> all = new Gee.ArrayList < FSpotPhotoRow?> ();
3877+
3878 Sqlite.Statement stmt;
3879- int res = select_all(out stmt);
3880+ int res = select_all (out stmt);
3881 while (res == Sqlite.ROW) {
3882 FSpotPhotoRow row;
3883- behavior.build_row(stmt, out row);
3884- all.add(row);
3885- res = stmt.step();
3886+ behavior.build_row (stmt, out row);
3887+ all.add (row);
3888+ res = stmt.step ();
3889 }
3890-
3891+
3892 return all;
3893 }
3894 }
3895@@ -52,40 +52,41 @@
3896 // The original table format
3897 public class FSpotPhotosV0Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
3898 private static FSpotPhotosV0Behavior instance;
3899-
3900- private FSpotPhotosV0Behavior() {
3901+
3902+ private FSpotPhotosV0Behavior () {
3903 }
3904-
3905- public static FSpotPhotosV0Behavior get_instance() {
3906+
3907+ public static FSpotPhotosV0Behavior get_instance () {
3908 if (instance == null)
3909- instance = new FSpotPhotosV0Behavior();
3910+ instance = new FSpotPhotosV0Behavior ();
3911 return instance;
3912 }
3913-
3914- public string get_table_name() {
3915+
3916+ public string get_table_name () {
3917 return FSpotPhotosTable.TABLE_NAME;
3918 }
3919-
3920- public string[] list_columns() {
3921+
3922+ public string[] list_columns () {
3923 return { "id", "time", "directory_path", "name", "description",
3924- "default_version_id" };
3925+ "default_version_id"
3926+ };
3927 }
3928-
3929- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
3930- row = new FSpotPhotoRow();
3931- row.photo_id = stmt.column_int64(offset + 0);
3932- row.time = (time_t) stmt.column_int64(offset + 1);
3933-
3934- string? base_path = stmt.column_text(offset + 2);
3935- string? filename = stmt.column_text(offset + 3);
3936+
3937+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
3938+ row = new FSpotPhotoRow ();
3939+ row.photo_id = stmt.column_int64 (offset + 0);
3940+ row.time = (time_t) stmt.column_int64 (offset + 1);
3941+
3942+ string? base_path = stmt.column_text (offset + 2);
3943+ string? filename = stmt.column_text (offset + 3);
3944 if (base_path != null && filename != null) {
3945- row.base_path = File.new_for_uri(base_path);
3946+ row.base_path = File.new_for_uri (base_path);
3947 row.filename = filename;
3948 }
3949-
3950- row.description = stmt.column_text(offset + 4);
3951+
3952+ row.description = stmt.column_text (offset + 4);
3953 row.roll_id = INVALID_ID;
3954- row.default_version_id = stmt.column_int64(offset + 5);
3955+ row.default_version_id = stmt.column_int64 (offset + 5);
3956 row.rating = 0;
3957 row.md5_sum = "";
3958 }
3959@@ -96,40 +97,41 @@
3960 // table migrated from imports)
3961 public class FSpotPhotosV5Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
3962 private static FSpotPhotosV5Behavior instance;
3963-
3964- private FSpotPhotosV5Behavior() {
3965+
3966+ private FSpotPhotosV5Behavior () {
3967 }
3968-
3969- public static FSpotPhotosV5Behavior get_instance() {
3970+
3971+ public static FSpotPhotosV5Behavior get_instance () {
3972 if (instance == null)
3973- instance = new FSpotPhotosV5Behavior();
3974+ instance = new FSpotPhotosV5Behavior ();
3975 return instance;
3976 }
3977-
3978- public string get_table_name() {
3979+
3980+ public string get_table_name () {
3981 return FSpotPhotosTable.TABLE_NAME;
3982 }
3983-
3984- public string[] list_columns() {
3985+
3986+ public string[] list_columns () {
3987 return { "id", "time", "directory_path", "name", "description", "roll_id",
3988- "default_version_id" };
3989+ "default_version_id"
3990+ };
3991 }
3992-
3993- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
3994- row = new FSpotPhotoRow();
3995- row.photo_id = stmt.column_int64(offset + 0);
3996- row.time = (time_t) stmt.column_int64(offset + 1);
3997-
3998- string? base_path = stmt.column_text(offset + 2);
3999- string? filename = stmt.column_text(offset + 3);
4000+
4001+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4002+ row = new FSpotPhotoRow ();
4003+ row.photo_id = stmt.column_int64 (offset + 0);
4004+ row.time = (time_t) stmt.column_int64 (offset + 1);
4005+
4006+ string? base_path = stmt.column_text (offset + 2);
4007+ string? filename = stmt.column_text (offset + 3);
4008 if (base_path != null && filename != null) {
4009- row.base_path = File.new_for_uri(base_path);
4010+ row.base_path = File.new_for_uri (base_path);
4011 row.filename = filename;
4012 }
4013-
4014- row.description = stmt.column_text(offset + 4);
4015- row.roll_id = stmt.column_int64(offset + 5);
4016- row.default_version_id = stmt.column_int64(offset + 6);
4017+
4018+ row.description = stmt.column_text (offset + 4);
4019+ row.roll_id = stmt.column_int64 (offset + 5);
4020+ row.default_version_id = stmt.column_int64 (offset + 6);
4021 row.rating = 0;
4022 row.md5_sum = "";
4023 }
4024@@ -141,40 +143,41 @@
4025 // different URI prefix such as remote files
4026 public class FSpotPhotosV7Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
4027 private static FSpotPhotosV7Behavior instance;
4028-
4029- private FSpotPhotosV7Behavior() {
4030+
4031+ private FSpotPhotosV7Behavior () {
4032 }
4033-
4034- public static FSpotPhotosV7Behavior get_instance() {
4035+
4036+ public static FSpotPhotosV7Behavior get_instance () {
4037 if (instance == null)
4038- instance = new FSpotPhotosV7Behavior();
4039+ instance = new FSpotPhotosV7Behavior ();
4040 return instance;
4041 }
4042-
4043- public string get_table_name() {
4044+
4045+ public string get_table_name () {
4046 return FSpotPhotosTable.TABLE_NAME;
4047 }
4048-
4049- public string[] list_columns() {
4050+
4051+ public string[] list_columns () {
4052 return { "id", "time", "uri", "description", "roll_id",
4053- "default_version_id" };
4054+ "default_version_id"
4055+ };
4056 }
4057-
4058- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4059- row = new FSpotPhotoRow();
4060- row.photo_id = stmt.column_int64(offset + 0);
4061- row.time = (time_t) stmt.column_int64(offset + 1);
4062-
4063- string? full_path = stmt.column_text(offset + 2);
4064+
4065+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4066+ row = new FSpotPhotoRow ();
4067+ row.photo_id = stmt.column_int64 (offset + 0);
4068+ row.time = (time_t) stmt.column_int64 (offset + 1);
4069+
4070+ string? full_path = stmt.column_text (offset + 2);
4071 if (full_path != null) {
4072- File uri = File.new_for_uri(full_path);
4073- row.base_path = uri.get_parent();
4074- row.filename = uri.get_basename();
4075+ File uri = File.new_for_uri (full_path);
4076+ row.base_path = uri.get_parent ();
4077+ row.filename = uri.get_basename ();
4078 }
4079
4080- row.description = stmt.column_text(offset + 3);
4081- row.roll_id = stmt.column_int64(offset + 4);
4082- row.default_version_id = stmt.column_int64(offset + 5);
4083+ row.description = stmt.column_text (offset + 3);
4084+ row.roll_id = stmt.column_int64 (offset + 4);
4085+ row.default_version_id = stmt.column_int64 (offset + 5);
4086 row.rating = 0;
4087 row.md5_sum = "";
4088 }
4089@@ -184,41 +187,42 @@
4090 // v11 introduced the concept of rating so add this to the list of fields
4091 public class FSpotPhotosV11Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
4092 private static FSpotPhotosV11Behavior instance;
4093-
4094- private FSpotPhotosV11Behavior() {
4095+
4096+ private FSpotPhotosV11Behavior () {
4097 }
4098-
4099- public static FSpotPhotosV11Behavior get_instance() {
4100+
4101+ public static FSpotPhotosV11Behavior get_instance () {
4102 if (instance == null)
4103- instance = new FSpotPhotosV11Behavior();
4104+ instance = new FSpotPhotosV11Behavior ();
4105 return instance;
4106 }
4107-
4108- public string get_table_name() {
4109+
4110+ public string get_table_name () {
4111 return FSpotPhotosTable.TABLE_NAME;
4112 }
4113-
4114- public string[] list_columns() {
4115+
4116+ public string[] list_columns () {
4117 return { "id", "time", "uri", "description", "roll_id",
4118- "default_version_id", "rating" };
4119+ "default_version_id", "rating"
4120+ };
4121 }
4122-
4123- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4124- row = new FSpotPhotoRow();
4125- row.photo_id = stmt.column_int64(offset + 0);
4126- row.time = (time_t) stmt.column_int64(offset + 1);
4127-
4128- string? full_path = stmt.column_text(offset + 2);
4129+
4130+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4131+ row = new FSpotPhotoRow ();
4132+ row.photo_id = stmt.column_int64 (offset + 0);
4133+ row.time = (time_t) stmt.column_int64 (offset + 1);
4134+
4135+ string? full_path = stmt.column_text (offset + 2);
4136 if (full_path != null) {
4137- File uri = File.new_for_uri(full_path);
4138- row.base_path = uri.get_parent();
4139- row.filename = uri.get_basename();
4140+ File uri = File.new_for_uri (full_path);
4141+ row.base_path = uri.get_parent ();
4142+ row.filename = uri.get_basename ();
4143 }
4144
4145- row.description = stmt.column_text(offset + 3);
4146- row.roll_id = stmt.column_int64(offset + 4);
4147- row.default_version_id = stmt.column_int64(offset + 5);
4148- row.rating = stmt.column_int(offset + 6);
4149+ row.description = stmt.column_text (offset + 3);
4150+ row.roll_id = stmt.column_int64 (offset + 4);
4151+ row.default_version_id = stmt.column_int64 (offset + 5);
4152+ row.rating = stmt.column_int (offset + 6);
4153 row.md5_sum = "";
4154 }
4155 }
4156@@ -227,42 +231,43 @@
4157 // v16 introduced the MD5 sum so add this to the list of fields
4158 public class FSpotPhotosV16Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
4159 private static FSpotPhotosV16Behavior instance;
4160-
4161- private FSpotPhotosV16Behavior() {
4162+
4163+ private FSpotPhotosV16Behavior () {
4164 }
4165-
4166- public static FSpotPhotosV16Behavior get_instance() {
4167+
4168+ public static FSpotPhotosV16Behavior get_instance () {
4169 if (instance == null)
4170- instance = new FSpotPhotosV16Behavior();
4171+ instance = new FSpotPhotosV16Behavior ();
4172 return instance;
4173 }
4174-
4175- public string get_table_name() {
4176+
4177+ public string get_table_name () {
4178 return FSpotPhotosTable.TABLE_NAME;
4179 }
4180-
4181- public string[] list_columns() {
4182+
4183+ public string[] list_columns () {
4184 return { "id", "time", "uri", "description", "roll_id",
4185- "default_version_id", "rating", "md5_sum" };
4186+ "default_version_id", "rating", "md5_sum"
4187+ };
4188 }
4189-
4190- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4191- row = new FSpotPhotoRow();
4192- row.photo_id = stmt.column_int64(offset + 0);
4193- row.time = (time_t) stmt.column_int64(offset + 1);
4194-
4195- string? full_path = stmt.column_text(offset + 2);
4196+
4197+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4198+ row = new FSpotPhotoRow ();
4199+ row.photo_id = stmt.column_int64 (offset + 0);
4200+ row.time = (time_t) stmt.column_int64 (offset + 1);
4201+
4202+ string? full_path = stmt.column_text (offset + 2);
4203 if (full_path != null) {
4204- File uri = File.new_for_uri(full_path);
4205- row.base_path = uri.get_parent();
4206- row.filename = uri.get_basename();
4207+ File uri = File.new_for_uri (full_path);
4208+ row.base_path = uri.get_parent ();
4209+ row.filename = uri.get_basename ();
4210 }
4211
4212- row.description = stmt.column_text(offset + 3);
4213- row.roll_id = stmt.column_int64(offset + 4);
4214- row.default_version_id = stmt.column_int64(offset + 5);
4215- row.rating = stmt.column_int(offset + 6);
4216- row.md5_sum = stmt.column_text(offset + 7);
4217+ row.description = stmt.column_text (offset + 3);
4218+ row.roll_id = stmt.column_int64 (offset + 4);
4219+ row.default_version_id = stmt.column_int64 (offset + 5);
4220+ row.rating = stmt.column_int (offset + 6);
4221+ row.md5_sum = stmt.column_text (offset + 7);
4222 }
4223 }
4224
4225@@ -271,83 +276,85 @@
4226 // design introduced in v0, albeit with a URI rather than a file system path)
4227 public class FSpotPhotosV17Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
4228 private static FSpotPhotosV17Behavior instance;
4229-
4230- private FSpotPhotosV17Behavior() {
4231+
4232+ private FSpotPhotosV17Behavior () {
4233 }
4234-
4235- public static FSpotPhotosV17Behavior get_instance() {
4236+
4237+ public static FSpotPhotosV17Behavior get_instance () {
4238 if (instance == null)
4239- instance = new FSpotPhotosV17Behavior();
4240+ instance = new FSpotPhotosV17Behavior ();
4241 return instance;
4242 }
4243-
4244- public string get_table_name() {
4245+
4246+ public string get_table_name () {
4247 return FSpotPhotosTable.TABLE_NAME;
4248 }
4249-
4250- public string[] list_columns() {
4251+
4252+ public string[] list_columns () {
4253 return { "id", "time", "base_uri", "filename", "description", "roll_id",
4254- "default_version_id", "rating", "md5_sum" };
4255+ "default_version_id", "rating", "md5_sum"
4256+ };
4257 }
4258-
4259- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4260- row = new FSpotPhotoRow();
4261- row.photo_id = stmt.column_int64(offset + 0);
4262- row.time = (time_t) stmt.column_int64(offset + 1);
4263-
4264- string? base_path = stmt.column_text(offset + 2);
4265- string? filename = stmt.column_text(offset + 3);
4266+
4267+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4268+ row = new FSpotPhotoRow ();
4269+ row.photo_id = stmt.column_int64 (offset + 0);
4270+ row.time = (time_t) stmt.column_int64 (offset + 1);
4271+
4272+ string? base_path = stmt.column_text (offset + 2);
4273+ string? filename = stmt.column_text (offset + 3);
4274 if (base_path != null && filename != null) {
4275- row.base_path = File.new_for_uri(base_path);
4276+ row.base_path = File.new_for_uri (base_path);
4277 row.filename = filename;
4278 }
4279-
4280- row.description = stmt.column_text(offset + 4);
4281- row.roll_id = stmt.column_int64(offset + 5);
4282- row.default_version_id = stmt.column_int64(offset + 6);
4283- row.rating = stmt.column_int(offset + 7);
4284- row.md5_sum = stmt.column_text(offset + 8);
4285+
4286+ row.description = stmt.column_text (offset + 4);
4287+ row.roll_id = stmt.column_int64 (offset + 5);
4288+ row.default_version_id = stmt.column_int64 (offset + 6);
4289+ row.rating = stmt.column_int (offset + 7);
4290+ row.md5_sum = stmt.column_text (offset + 8);
4291 }
4292 }
4293
4294 // v18: no more MD5 hash in the photos table: moved to photo_versions table
4295 public class FSpotPhotosV18Behavior : FSpotTableBehavior<FSpotPhotoRow>, Object {
4296 private static FSpotPhotosV18Behavior instance;
4297-
4298- private FSpotPhotosV18Behavior() {
4299+
4300+ private FSpotPhotosV18Behavior () {
4301 }
4302-
4303- public static FSpotPhotosV18Behavior get_instance() {
4304+
4305+ public static FSpotPhotosV18Behavior get_instance () {
4306 if (instance == null)
4307- instance = new FSpotPhotosV18Behavior();
4308+ instance = new FSpotPhotosV18Behavior ();
4309 return instance;
4310 }
4311-
4312- public string get_table_name() {
4313+
4314+ public string get_table_name () {
4315 return FSpotPhotosTable.TABLE_NAME;
4316 }
4317-
4318- public string[] list_columns() {
4319+
4320+ public string[] list_columns () {
4321 return { "id", "time", "base_uri", "filename", "description", "roll_id",
4322- "default_version_id", "rating" };
4323+ "default_version_id", "rating"
4324+ };
4325 }
4326-
4327- public void build_row(Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4328- row = new FSpotPhotoRow();
4329- row.photo_id = stmt.column_int64(offset + 0);
4330- row.time = (time_t) stmt.column_int64(offset + 1);
4331-
4332- string? base_path = stmt.column_text(offset + 2);
4333- string? filename = stmt.column_text(offset + 3);
4334+
4335+ public void build_row (Sqlite.Statement stmt, out FSpotPhotoRow row, int offset = 0) {
4336+ row = new FSpotPhotoRow ();
4337+ row.photo_id = stmt.column_int64 (offset + 0);
4338+ row.time = (time_t) stmt.column_int64 (offset + 1);
4339+
4340+ string? base_path = stmt.column_text (offset + 2);
4341+ string? filename = stmt.column_text (offset + 3);
4342 if (base_path != null && filename != null) {
4343- row.base_path = File.new_for_uri(base_path);
4344+ row.base_path = File.new_for_uri (base_path);
4345 row.filename = filename;
4346 }
4347-
4348- row.description = stmt.column_text(offset + 4);
4349- row.roll_id = stmt.column_int64(offset + 5);
4350- row.default_version_id = stmt.column_int64(offset + 6);
4351- row.rating = stmt.column_int(offset + 7);
4352+
4353+ row.description = stmt.column_text (offset + 4);
4354+ row.roll_id = stmt.column_int64 (offset + 5);
4355+ row.default_version_id = stmt.column_int64 (offset + 6);
4356+ row.rating = stmt.column_int (offset + 7);
4357 row.md5_sum = "";
4358 }
4359 }
4360
4361=== modified file 'plugins/shotwell-data-imports/FSpotRollsTable.vala'
4362--- plugins/shotwell-data-imports/FSpotRollsTable.vala 2013-01-21 21:16:09 +0000
4363+++ plugins/shotwell-data-imports/FSpotRollsTable.vala 2014-08-08 21:16:43 +0000
4364@@ -20,32 +20,32 @@
4365 public class FSpotRollsTable : FSpotDatabaseTable<FSpotRollRow> {
4366 public static const string TABLE_NAME = "Rolls";
4367 public static const string TABLE_NAME_PRE_V5 = "Imports";
4368-
4369- public FSpotRollsTable(Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
4370- base(db);
4371- set_behavior(db_behavior.get_rolls_behavior());
4372+
4373+ public FSpotRollsTable (Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
4374+ base (db);
4375+ set_behavior (db_behavior.get_rolls_behavior ());
4376 }
4377-
4378- public FSpotRollRow? get_by_id(int64 roll_id) throws DatabaseError {
4379+
4380+ public FSpotRollRow? get_by_id (int64 roll_id) throws DatabaseError {
4381 Sqlite.Statement stmt;
4382 FSpotRollRow? row = null;
4383- string column_list = get_joined_column_list();
4384- string sql = "SELECT %s FROM %s WHERE id=?".printf(column_list, table_name);
4385-
4386- int res = fspot_db.prepare_v2(sql, -1, out stmt);
4387- if (res != Sqlite.OK)
4388- throw_error("Statement failed: %s".printf(sql), res);
4389-
4390- res = stmt.bind_int64(1, roll_id);
4391- if (res != Sqlite.OK)
4392- throw_error("Bind failed for roll_id", res);
4393-
4394- res = stmt.step();
4395+ string column_list = get_joined_column_list ();
4396+ string sql = "SELECT %s FROM %s WHERE id=?".printf (column_list, table_name);
4397+
4398+ int res = fspot_db.prepare_v2 (sql, -1, out stmt);
4399+ if (res != Sqlite.OK)
4400+ throw_error ("Statement failed: %s".printf (sql), res);
4401+
4402+ res = stmt.bind_int64 (1, roll_id);
4403+ if (res != Sqlite.OK)
4404+ throw_error ("Bind failed for roll_id", res);
4405+
4406+ res = stmt.step ();
4407 if (res == Sqlite.ROW)
4408- behavior.build_row(stmt, out row);
4409+ behavior.build_row (stmt, out row);
4410 else if (res == Sqlite.DONE)
4411- message("Could not find roll row with ID %d", (int)roll_id);
4412-
4413+ message ("Could not find roll row with ID %d", (int)roll_id);
4414+
4415 return row;
4416 }
4417 }
4418@@ -53,28 +53,28 @@
4419 // Rolls table behavior for v0-4
4420 public class FSpotRollsV0Behavior : FSpotTableBehavior<FSpotRollRow>, Object {
4421 private static FSpotRollsV0Behavior instance;
4422-
4423- private FSpotRollsV0Behavior() {
4424+
4425+ private FSpotRollsV0Behavior () {
4426 }
4427-
4428- public static FSpotRollsV0Behavior get_instance() {
4429+
4430+ public static FSpotRollsV0Behavior get_instance () {
4431 if (instance == null)
4432- instance = new FSpotRollsV0Behavior();
4433+ instance = new FSpotRollsV0Behavior ();
4434 return instance;
4435 }
4436-
4437- public string get_table_name() {
4438+
4439+ public string get_table_name () {
4440 return FSpotRollsTable.TABLE_NAME_PRE_V5;
4441 }
4442
4443- public string[] list_columns() {
4444+ public string[] list_columns () {
4445 return { "id", "time" };
4446 }
4447-
4448- public void build_row(Sqlite.Statement stmt, out FSpotRollRow row, int offset = 0) {
4449- row = new FSpotRollRow();
4450- row.id = stmt.column_int64(offset + 0);
4451- row.time = (time_t) stmt.column_int64(offset + 1);
4452+
4453+ public void build_row (Sqlite.Statement stmt, out FSpotRollRow row, int offset = 0) {
4454+ row = new FSpotRollRow ();
4455+ row.id = stmt.column_int64 (offset + 0);
4456+ row.time = (time_t) stmt.column_int64 (offset + 1);
4457 }
4458 }
4459
4460@@ -82,28 +82,28 @@
4461 // Table name changed from "imports" to "rolls"
4462 public class FSpotRollsV5Behavior : FSpotTableBehavior<FSpotRollRow>, Object {
4463 private static FSpotRollsV5Behavior instance;
4464-
4465- private FSpotRollsV5Behavior() {
4466+
4467+ private FSpotRollsV5Behavior () {
4468 }
4469-
4470- public static FSpotRollsV5Behavior get_instance() {
4471+
4472+ public static FSpotRollsV5Behavior get_instance () {
4473 if (instance == null)
4474- instance = new FSpotRollsV5Behavior();
4475+ instance = new FSpotRollsV5Behavior ();
4476 return instance;
4477 }
4478-
4479- public string get_table_name() {
4480+
4481+ public string get_table_name () {
4482 return FSpotRollsTable.TABLE_NAME;
4483 }
4484
4485- public string[] list_columns() {
4486+ public string[] list_columns () {
4487 return { "id", "time" };
4488 }
4489-
4490- public void build_row(Sqlite.Statement stmt, out FSpotRollRow row, int offset = 0) {
4491- row = new FSpotRollRow();
4492- row.id = stmt.column_int64(offset + 0);
4493- row.time = (time_t) stmt.column_int64(offset + 1);
4494+
4495+ public void build_row (Sqlite.Statement stmt, out FSpotRollRow row, int offset = 0) {
4496+ row = new FSpotRollRow ();
4497+ row.id = stmt.column_int64 (offset + 0);
4498+ row.time = (time_t) stmt.column_int64 (offset + 1);
4499 }
4500 }
4501
4502
4503=== modified file 'plugins/shotwell-data-imports/FSpotTableBehavior.vala'
4504--- plugins/shotwell-data-imports/FSpotTableBehavior.vala 2013-01-21 21:16:09 +0000
4505+++ plugins/shotwell-data-imports/FSpotTableBehavior.vala 2014-08-08 21:16:43 +0000
4506@@ -17,11 +17,11 @@
4507 * contain the data for a single database row.
4508 */
4509 public interface FSpotTableBehavior<T> : Object {
4510- public abstract string get_table_name();
4511-
4512- public abstract string[] list_columns();
4513-
4514- public abstract void build_row(Sqlite.Statement stmt, out T row, int offset = 0);
4515+ public abstract string get_table_name ();
4516+
4517+ public abstract string[] list_columns ();
4518+
4519+ public abstract void build_row (Sqlite.Statement stmt, out T row, int offset = 0);
4520 }
4521
4522 }
4523
4524=== modified file 'plugins/shotwell-data-imports/FSpotTagsTable.vala'
4525--- plugins/shotwell-data-imports/FSpotTagsTable.vala 2013-01-21 21:16:09 +0000
4526+++ plugins/shotwell-data-imports/FSpotTagsTable.vala 2014-08-08 21:16:43 +0000
4527@@ -23,102 +23,102 @@
4528 */
4529 public class FSpotTagsTable : FSpotDatabaseTable<FSpotTagRow> {
4530 public static const string TABLE_NAME = "Tags";
4531-
4532+
4533 public static const string PREFIX_STOCK_ICON = "stock_icon:";
4534 public static const string STOCK_ICON_FAV = "stock_icon:emblem-favorite";
4535 public static const string STOCK_ICON_PEOPLE = "stock_icon:emblem-people";
4536 public static const string STOCK_ICON_PLACES = "stock_icon:emblem-places";
4537 public static const string STOCK_ICON_EVENTS = "stock_icon:emblem-event";
4538-
4539+
4540 private FSpotTableBehavior<FSpotPhotoTagRow> photo_tags_behavior;
4541-
4542- public FSpotTagsTable(Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
4543- base(db);
4544- set_behavior(db_behavior.get_tags_behavior());
4545- photo_tags_behavior = db_behavior.get_photo_tags_behavior();
4546+
4547+ public FSpotTagsTable (Sqlite.Database db, FSpotDatabaseBehavior db_behavior) {
4548+ base (db);
4549+ set_behavior (db_behavior.get_tags_behavior ());
4550+ photo_tags_behavior = db_behavior.get_photo_tags_behavior ();
4551 }
4552-
4553- public FSpotTagRow? get_by_id(int64 tag_id) throws DatabaseError {
4554+
4555+ public FSpotTagRow? get_by_id (int64 tag_id) throws DatabaseError {
4556 Sqlite.Statement stmt;
4557 FSpotTagRow? row = null;
4558- string column_list = get_joined_column_list();
4559- string sql = "SELECT %s FROM %s WHERE id=?".printf(column_list, table_name);
4560+ string column_list = get_joined_column_list ();
4561+ string sql = "SELECT %s FROM %s WHERE id=?".printf (column_list, table_name);
4562
4563- int res = fspot_db.prepare_v2(sql, -1, out stmt);
4564+ int res = fspot_db.prepare_v2 (sql, -1, out stmt);
4565 if (res != Sqlite.OK)
4566- throw_error("Statement failed: %s".printf(sql), res);
4567-
4568- res = stmt.bind_int64(1, tag_id);
4569- assert(res == Sqlite.OK);
4570-
4571- res = stmt.step();
4572+ throw_error ("Statement failed: %s".printf (sql), res);
4573+
4574+ res = stmt.bind_int64 (1, tag_id);
4575+ assert (res == Sqlite.OK);
4576+
4577+ res = stmt.step ();
4578 if (res == Sqlite.ROW)
4579- behavior.build_row(stmt, out row);
4580+ behavior.build_row (stmt, out row);
4581 else if (res == Sqlite.DONE)
4582- message("Could not find tag row with ID %d", (int)tag_id);
4583-
4584+ message ("Could not find tag row with ID %d", (int)tag_id);
4585+
4586 return row;
4587 }
4588-
4589- public Gee.ArrayList<FSpotTagRow> get_by_photo_id(int64 photo_id) throws DatabaseError {
4590- Gee.ArrayList<FSpotTagRow> rows = new Gee.ArrayList<FSpotTagRow?>();
4591-
4592+
4593+ public Gee.ArrayList<FSpotTagRow> get_by_photo_id (int64 photo_id) throws DatabaseError {
4594+ Gee.ArrayList<FSpotTagRow> rows = new Gee.ArrayList < FSpotTagRow?> ();
4595+
4596 Sqlite.Statement stmt;
4597-
4598- string column_list = get_joined_column_list(true);
4599- string sql = "SELECT %1$s FROM %2$s, %3$s WHERE %3$s.photo_id=? AND %3$s.tag_id = %2$s.id".printf(
4600- column_list, table_name, photo_tags_behavior.get_table_name()
4601+
4602+ string column_list = get_joined_column_list (true);
4603+ string sql = "SELECT %1$s FROM %2$s, %3$s WHERE %3$s.photo_id=? AND %3$s.tag_id = %2$s.id".printf (
4604+ column_list, table_name, photo_tags_behavior.get_table_name ()
4605 );
4606
4607- int res = fspot_db.prepare_v2(sql, -1, out stmt);
4608- if (res != Sqlite.OK)
4609- throw_error("Statement failed: %s".printf(sql), res);
4610-
4611- res = stmt.bind_int64(1, photo_id);
4612- if (res != Sqlite.OK)
4613- throw_error("Bind failed for photo_id", res);
4614-
4615- res = stmt.step();
4616+ int res = fspot_db.prepare_v2 (sql, -1, out stmt);
4617+ if (res != Sqlite.OK)
4618+ throw_error ("Statement failed: %s".printf (sql), res);
4619+
4620+ res = stmt.bind_int64 (1, photo_id);
4621+ if (res != Sqlite.OK)
4622+ throw_error ("Bind failed for photo_id", res);
4623+
4624+ res = stmt.step ();
4625 while (res == Sqlite.ROW) {
4626 FSpotTagRow row;
4627- behavior.build_row(stmt, out row);
4628- rows.add(row);
4629- res = stmt.step();
4630+ behavior.build_row (stmt, out row);
4631+ rows.add (row);
4632+ res = stmt.step ();
4633 }
4634-
4635+
4636 return rows;
4637 }
4638 }
4639
4640 public class FSpotTagsV0Behavior : FSpotTableBehavior<FSpotTagRow>, Object {
4641 private static FSpotTagsV0Behavior instance;
4642-
4643- private FSpotTagsV0Behavior() {
4644+
4645+ private FSpotTagsV0Behavior () {
4646 }
4647-
4648- public static FSpotTagsV0Behavior get_instance() {
4649+
4650+ public static FSpotTagsV0Behavior get_instance () {
4651 if (instance == null)
4652- instance = new FSpotTagsV0Behavior();
4653+ instance = new FSpotTagsV0Behavior ();
4654 return instance;
4655 }
4656-
4657- public string get_table_name() {
4658+
4659+ public string get_table_name () {
4660 return FSpotTagsTable.TABLE_NAME;
4661 }
4662
4663- public string[] list_columns() {
4664+ public string[] list_columns () {
4665 return { "id", "name", "category_id", "is_category", "sort_priority", "icon" };
4666 }
4667-
4668- public void build_row(Sqlite.Statement stmt, out FSpotTagRow row, int offset = 0) {
4669- row = new FSpotTagRow();
4670- row.tag_id = stmt.column_int64(offset + 0);
4671- row.name = stmt.column_text(offset + 1);
4672- row.category_id = stmt.column_int64(offset + 2);
4673- row.is_category = (stmt.column_int(offset + 3) > 0);
4674- row.sort_priority = stmt.column_int(offset + 4);
4675- string icon_str = stmt.column_text(offset + 5);
4676- if (icon_str != null && icon_str.has_prefix(FSpotTagsTable.PREFIX_STOCK_ICON))
4677+
4678+ public void build_row (Sqlite.Statement stmt, out FSpotTagRow row, int offset = 0) {
4679+ row = new FSpotTagRow ();
4680+ row.tag_id = stmt.column_int64 (offset + 0);
4681+ row.name = stmt.column_text (offset + 1);
4682+ row.category_id = stmt.column_int64 (offset + 2);
4683+ row.is_category = (stmt.column_int (offset + 3) > 0);
4684+ row.sort_priority = stmt.column_int (offset + 4);
4685+ string icon_str = stmt.column_text (offset + 5);
4686+ if (icon_str != null && icon_str.has_prefix (FSpotTagsTable.PREFIX_STOCK_ICON))
4687 row.stock_icon = icon_str;
4688 else
4689 row.stock_icon = "";
4690
4691=== modified file 'plugins/shotwell-data-imports/shotwell-data-imports.vala'
4692--- plugins/shotwell-data-imports/shotwell-data-imports.vala 2013-01-21 21:16:09 +0000
4693+++ plugins/shotwell-data-imports/shotwell-data-imports.vala 2014-08-08 21:16:43 +0000
4694@@ -12,35 +12,35 @@
4695
4696 // we need to get a module file handle because our pluggables have to load resources from the
4697 // module file directory
4698- public ShotwellDataImportsCoreServices(GLib.File module_file) {
4699- GLib.File resource_directory = module_file.get_parent();
4700-
4701- pluggables += new FSpotService(resource_directory);
4702- }
4703-
4704- public unowned string get_module_name() {
4705- return _("Core Data Import Services");
4706- }
4707-
4708- public unowned string get_version() {
4709+ public ShotwellDataImportsCoreServices (GLib.File module_file) {
4710+ GLib.File resource_directory = module_file.get_parent ();
4711+
4712+ pluggables += new FSpotService (resource_directory);
4713+ }
4714+
4715+ public unowned string get_module_name () {
4716+ return _ ("Core Data Import Services");
4717+ }
4718+
4719+ public unowned string get_version () {
4720 return _VERSION;
4721 }
4722-
4723- public unowned string get_id() {
4724+
4725+ public unowned string get_id () {
4726 return "org.yorba.shotwell.data_imports.core_services";
4727 }
4728-
4729- public unowned Spit.Pluggable[]? get_pluggables() {
4730+
4731+ public unowned Spit.Pluggable[]? get_pluggables () {
4732 return pluggables;
4733 }
4734 }
4735
4736 // This entry point is required for all SPIT modules.
4737-public Spit.Module? spit_entry_point(Spit.EntryPointParams *params) {
4738- params->module_spit_interface = Spit.negotiate_interfaces(params->host_min_spit_interface,
4739- params->host_max_spit_interface, Spit.CURRENT_INTERFACE);
4740-
4741+public Spit.Module? spit_entry_point (Spit.EntryPointParams *params) {
4742+ params->module_spit_interface = Spit.negotiate_interfaces (params->host_min_spit_interface,
4743+ params->host_max_spit_interface, Spit.CURRENT_INTERFACE);
4744+
4745 return (params->module_spit_interface != Spit.UNSUPPORTED_INTERFACE)
4746- ? new ShotwellDataImportsCoreServices(params->module_file) : null;
4747+ ? new ShotwellDataImportsCoreServices (params->module_file) : null;
4748 }
4749
4750
4751=== modified file 'plugins/shotwell-publishing-extras/TumblrPublishing.vala'
4752--- plugins/shotwell-publishing-extras/TumblrPublishing.vala 2014-01-15 19:51:09 +0000
4753+++ plugins/shotwell-publishing-extras/TumblrPublishing.vala 2014-08-08 21:16:43 +0000
4754@@ -6,33 +6,33 @@
4755 */
4756
4757
4758-extern string hmac_sha1(string key, string message);
4759+extern string hmac_sha1 (string key, string message);
4760 public class TumblrService : Object, Spit.Pluggable, Spit.Publishing.Service {
4761- private const string ICON_FILENAME = "tumblr.png";
4762+ private const string ICON_FILENAME = "tumblr.png";
4763
4764 private static Gdk.Pixbuf[] icon_pixbuf_set = null;
4765-
4766- public TumblrService(GLib.File resource_directory) {
4767+
4768+ public TumblrService (GLib.File resource_directory) {
4769 if (icon_pixbuf_set == null)
4770- icon_pixbuf_set = Resources.load_icon_set(resource_directory.get_child(ICON_FILENAME));
4771- }
4772-
4773- public int get_pluggable_interface(int min_host_interface, int max_host_interface) {
4774- return Spit.negotiate_interfaces(min_host_interface, max_host_interface,
4775- Spit.Publishing.CURRENT_INTERFACE);
4776- }
4777-
4778- public unowned string get_id() {
4779+ icon_pixbuf_set = Resources.load_icon_set (resource_directory.get_child (ICON_FILENAME));
4780+ }
4781+
4782+ public int get_pluggable_interface (int min_host_interface, int max_host_interface) {
4783+ return Spit.negotiate_interfaces (min_host_interface, max_host_interface,
4784+ Spit.Publishing.CURRENT_INTERFACE);
4785+ }
4786+
4787+ public unowned string get_id () {
4788 return "org.yorba.shotwell.publishing.tumblr";
4789 }
4790-
4791- public unowned string get_pluggable_name() {
4792+
4793+ public unowned string get_pluggable_name () {
4794 return "Tumblr";
4795 }
4796-
4797- public void get_info(ref Spit.PluggableInfo info) {
4798+
4799+ public void get_info (ref Spit.PluggableInfo info) {
4800 info.authors = "Jeroen Arnoldus";
4801- info.copyright = _("Copyright 2012 BJA Electronics");
4802+ info.copyright = _ ("Copyright 2012 BJA Electronics");
4803 info.translators = Resources.TRANSLATORS;
4804 info.version = _VERSION;
4805 info.website_name = Resources.WEBSITE_NAME;
4806@@ -42,16 +42,16 @@
4807 info.icons = icon_pixbuf_set;
4808 }
4809
4810- public void activation(bool enabled) {
4811- }
4812-
4813- public Spit.Publishing.Publisher create_publisher(Spit.Publishing.PluginHost host) {
4814- return new Publishing.Tumblr.TumblrPublisher(this, host);
4815- }
4816-
4817- public Spit.Publishing.Publisher.MediaType get_supported_media() {
4818+ public void activation (bool enabled) {
4819+ }
4820+
4821+ public Spit.Publishing.Publisher create_publisher (Spit.Publishing.PluginHost host) {
4822+ return new Publishing.Tumblr.TumblrPublisher (this, host);
4823+ }
4824+
4825+ public Spit.Publishing.Publisher.MediaType get_supported_media () {
4826 return (Spit.Publishing.Publisher.MediaType.PHOTO |
4827- Spit.Publishing.Publisher.MediaType.VIDEO);
4828+ Spit.Publishing.Publisher.MediaType.VIDEO);
4829 }
4830 }
4831
4832@@ -61,28 +61,28 @@
4833 internal const string ENDPOINT_URL = "http://www.tumblr.com/";
4834 internal const string API_KEY = "NdXvXQuKVccOsCOj0H4k9HUJcbcjDBYSo2AkaHzXFECHGNuP9k";
4835 internal const string API_SECRET = "BN0Uoig0MwbeD27OgA0IwYlp3Uvonyfsrl9pf1cnnMj1QoEUvi";
4836-internal const string ENCODE_RFC_3986_EXTRA = "!*'();:@&=+$,/?%#[] \\";
4837+internal const string ENCODE_RFC_3986_EXTRA = "!*' ();:@&=+$,/?%#[] \\";
4838 internal const int ORIGINAL_SIZE = -1;
4839
4840
4841
4842 private class BlogEntry {
4843- public string blog;
4844- public string url;
4845- public BlogEntry(string creator_blog, string creator_url) {
4846- blog = creator_blog;
4847- url = creator_url;
4848- }
4849+ public string blog;
4850+ public string url;
4851+ public BlogEntry (string creator_blog, string creator_url) {
4852+ blog = creator_blog;
4853+ url = creator_url;
4854+ }
4855 }
4856
4857 private class SizeEntry {
4858- public string title;
4859- public int size;
4860+ public string title;
4861+ public int size;
4862
4863- public SizeEntry(string creator_title, int creator_size) {
4864- title = creator_title;
4865- size = creator_size;
4866- }
4867+ public SizeEntry (string creator_title, int creator_size) {
4868+ title = creator_title;
4869+ size = creator_size;
4870+ }
4871 }
4872
4873 public class TumblrPublisher : Spit.Publishing.Publisher, GLib.Object {
4874@@ -95,73 +95,73 @@
4875 private PublishingOptionsPane publishing_options_pane = null;
4876 private SizeEntry[] sizes = null;
4877 private BlogEntry[] blogs = null;
4878- private string username = "";
4879-
4880-
4881- private SizeEntry[] create_sizes() {
4882+ private string username = "";
4883+
4884+
4885+ private SizeEntry[] create_sizes () {
4886 SizeEntry[] result = new SizeEntry[0];
4887
4888- result += new SizeEntry(_("500 x 375 pixels"), 500);
4889- result += new SizeEntry(_("1024 x 768 pixels"), 1024);
4890- result += new SizeEntry(_("1280 x 853 pixels"), 1280);
4891-//Larger images make no sense for Tumblr
4892-// result += new SizeEntry(_("2048 x 1536 pixels"), 2048);
4893-// result += new SizeEntry(_("4096 x 3072 pixels"), 4096);
4894-// result += new SizeEntry(_("Original size"), ORIGINAL_SIZE);
4895+ result += new SizeEntry (_ ("500 x 375 pixels"), 500);
4896+ result += new SizeEntry (_ ("1024 x 768 pixels"), 1024);
4897+ result += new SizeEntry (_ ("1280 x 853 pixels"), 1280);
4898+ //Larger images make no sense for Tumblr
4899+ // result += new SizeEntry(_("2048 x 1536 pixels"), 2048);
4900+ // result += new SizeEntry(_("4096 x 3072 pixels"), 4096);
4901+ // result += new SizeEntry(_("Original size"), ORIGINAL_SIZE);
4902
4903 return result;
4904 }
4905
4906- private BlogEntry[] create_blogs() {
4907+ private BlogEntry[] create_blogs () {
4908 BlogEntry[] result = new BlogEntry[0];
4909
4910
4911 return result;
4912 }
4913
4914- public TumblrPublisher(Spit.Publishing.Service service,
4915- Spit.Publishing.PluginHost host) {
4916- debug("TumblrPublisher instantiated.");
4917+ public TumblrPublisher (Spit.Publishing.Service service,
4918+ Spit.Publishing.PluginHost host) {
4919+ debug ("TumblrPublisher instantiated.");
4920 this.service = service;
4921 this.host = host;
4922- this.session = new Session();
4923- this.sizes = this.create_sizes();
4924- this.blogs = this.create_blogs();
4925- session.authenticated.connect(on_session_authenticated);
4926- }
4927-
4928- ~TumblrPublisher() {
4929- session.authenticated.disconnect(on_session_authenticated);
4930- }
4931-
4932- private void invalidate_persistent_session() {
4933- set_persistent_access_phase_token("");
4934- set_persistent_access_phase_token_secret("");
4935+ this.session = new Session ();
4936+ this.sizes = this.create_sizes ();
4937+ this.blogs = this.create_blogs ();
4938+ session.authenticated.connect (on_session_authenticated);
4939+ }
4940+
4941+ ~TumblrPublisher () {
4942+ session.authenticated.disconnect (on_session_authenticated);
4943+ }
4944+
4945+ private void invalidate_persistent_session () {
4946+ set_persistent_access_phase_token ("");
4947+ set_persistent_access_phase_token_secret ("");
4948 }
4949 // Publisher interface implementation
4950-
4951- public Spit.Publishing.Service get_service() {
4952+
4953+ public Spit.Publishing.Service get_service () {
4954 return service;
4955 }
4956-
4957- public Spit.Publishing.PluginHost get_host() {
4958+
4959+ public Spit.Publishing.PluginHost get_host () {
4960 return host;
4961 }
4962
4963- public bool is_running() {
4964+ public bool is_running () {
4965 return running;
4966 }
4967
4968- private bool is_persistent_session_valid() {
4969- string? access_phase_token = get_persistent_access_phase_token();
4970- string? access_phase_token_secret = get_persistent_access_phase_token_secret();
4971+ private bool is_persistent_session_valid () {
4972+ string? access_phase_token = get_persistent_access_phase_token ();
4973+ string? access_phase_token_secret = get_persistent_access_phase_token_secret ();
4974
4975 bool valid = ((access_phase_token != null) && (access_phase_token_secret != null));
4976
4977 if (valid)
4978- debug("existing Tumblr session found in configuration database; using it.");
4979+ debug ("existing Tumblr session found in configuration database; using it.");
4980 else
4981- debug("no persisted Tumblr session exists.");
4982+ debug ("no persisted Tumblr session exists.");
4983
4984 return valid;
4985 }
4986@@ -169,40 +169,40 @@
4987
4988
4989
4990- public string? get_persistent_access_phase_token() {
4991- return host.get_config_string("token", null);
4992- }
4993-
4994- private void set_persistent_access_phase_token(string? token) {
4995- host.set_config_string("token", token);
4996- }
4997-
4998- public string? get_persistent_access_phase_token_secret() {
4999- return host.get_config_string("token_secret", null);
5000- }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: