~ubuntu-branches/ubuntu/quantal/shotwell/quantal

« back to all changes in this revision

Viewing changes to src/plugins/DataImportsInterfaces.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-02-21 13:52:58 UTC
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: package-import@ubuntu.com-20120221135258-ao9jiib5qicomq7q
Tags: upstream-0.11.92
Import upstream version 0.11.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2011 Yorba Foundation
 
2
 *
 
3
 * This software is licensed under the GNU Lesser General Public License
 
4
 * (version 2.1 or later).  See the COPYING file in this distribution. 
 
5
 */
 
6
 
 
7
/**
 
8
 * Shotwell Pluggable Data Imports API
 
9
 *
 
10
 * The Shotwell Pluggable Data Imports API allows you to write plugins that import
 
11
 * information from other media library databases to help migration to Shotwell.
 
12
 * The Shotwell distribution includes import support for F-Spot.
 
13
 * To enable Shotwell to import from additional libaries, developers like you write
 
14
 * data import plugins, dynamically-loadable shared objects that are linked into the
 
15
 * Shotwell process at runtime. Data import plugins are just one of several kinds of
 
16
 * plugins supported by {@link Spit}, the Shotwell Pluggable Interfaces Technology.
 
17
 */
 
18
namespace Spit.DataImports {
 
19
 
 
20
/**
 
21
 * The current version of the Pluggable Data Import API
 
22
 */
 
23
public const int CURRENT_INTERFACE = 0;
 
24
 
 
25
/**
 
26
 * The error domain for alien databases
 
27
 */
 
28
public errordomain DataImportError {
 
29
    /**
 
30
     * Indicates that the version of the external database being imported is
 
31
     * not supported by this version of the plugin.
 
32
     *
 
33
     * This occurs for example when trying to import an F-Spot database that
 
34
     * has a version that is more recent than what the current plugin supports.
 
35
     */
 
36
    UNSUPPORTED_VERSION
 
37
}
 
38
 
 
39
/** 
 
40
 * Represents a module that is able to import data from a specific database format.
 
41
 *
 
42
 * Developers of data import plugins provide a class that implements this interface. At
 
43
 * any given time, only one DataImporter can be running. When a data importer is running, it
 
44
 * has exclusive use of the shared user-interface and
 
45
 * configuration services provided by the {@link PluginHost}. Data importers are created in
 
46
 * a non-running state and do not begin running until start( ) is invoked. Data importers
 
47
 * run until stop( ) is invoked.
 
48
 */
 
49
public interface DataImporter : GLib.Object {
 
50
    /**
 
51
     * Returns a {@link Service} object describing the service to which this connects.
 
52
     */
 
53
    public abstract Service get_service();
 
54
 
 
55
    /**
 
56
     * Makes this data importer enter the running state and endows it with exclusive access
 
57
     * to the shared services provided by the {@link PluginHost}. Through the host’s interface,
 
58
     * this data importer can install user interface panes and query configuration information.
 
59
     */
 
60
    public abstract void start();
 
61
 
 
62
    /**
 
63
     * Returns true if this data importer is in the running state; false otherwise.
 
64
     */
 
65
    public abstract bool is_running();
 
66
    
 
67
    /**
 
68
     * Causes this data importer to enter a non-running state. This data importer should stop all
 
69
     * data access operations and cease use of the shared services provided by the {@link PluginHost}.
 
70
     */
 
71
    public abstract void stop();
 
72
    
 
73
    /**
 
74
     * Causes this data importer to enter start the import of a library.
 
75
     */
 
76
    public abstract void on_library_selected(ImportableLibrary library);
 
77
    
 
78
    /**
 
79
     * Causes this data importer to enter start the import of a library file.
 
80
     */
 
81
    public abstract void on_file_selected(File file);
 
82
    
 
83
    //
 
84
    // For future expansion.
 
85
    //
 
86
    protected virtual void reserved0() {}
 
87
    protected virtual void reserved1() {}
 
88
    protected virtual void reserved2() {}
 
89
    protected virtual void reserved3() {}
 
90
    protected virtual void reserved4() {}
 
91
    protected virtual void reserved5() {}
 
92
    protected virtual void reserved6() {}
 
93
    protected virtual void reserved7() {}
 
94
}
 
95
 
 
96
/**
 
97
 * Represents a libary of importable media items.
 
98
 *
 
99
 * Developers of data import plugins provide a class that implements this interface.
 
100
 */
 
101
public interface ImportableLibrary : GLib.Object {
 
102
    public abstract string get_display_name();
 
103
}
 
104
 
 
105
/**
 
106
 * Represents an importable media item such as a photo or a video file.
 
107
 *
 
108
 * Developers of data import plugins provide a class that implements this interface.
 
109
 */
 
110
public interface ImportableMediaItem : GLib.Object {
 
111
    public abstract ImportableTag[] get_tags();
 
112
    
 
113
    public abstract ImportableEvent? get_event();
 
114
    
 
115
    public abstract ImportableRating get_rating();
 
116
    
 
117
    public abstract string? get_title();
 
118
    
 
119
    public abstract string get_folder_path();
 
120
    
 
121
    public abstract string get_filename();
 
122
}
 
123
 
 
124
/**
 
125
 * Represents an importable tag.
 
126
 *
 
127
 * Developers of data import plugins provide a class that implements this interface.
 
128
 */
 
129
public interface ImportableTag : GLib.Object {
 
130
    public abstract string get_name();
 
131
    
 
132
    public abstract ImportableTag? get_parent();
 
133
}
 
134
 
 
135
/**
 
136
 * Represents an importable event.
 
137
 *
 
138
 * Developers of data import plugins provide a class that implements this interface.
 
139
 */
 
140
public interface ImportableEvent : GLib.Object {
 
141
    public abstract string get_name();
 
142
}
 
143
 
 
144
/**
 
145
 * Represents an importable rating value.
 
146
 *
 
147
 * Developers of data import plugins provide a class that implements this interface.
 
148
 * Note that the value returned by the get_value method should be a value between
 
149
 * 1 and 5, unless the rating object is unrated or rejected, in which case the
 
150
 * value is unspecified.
 
151
 */
 
152
public interface ImportableRating : GLib.Object {
 
153
    public abstract bool is_unrated();
 
154
    
 
155
    public abstract bool is_rejected();
 
156
    
 
157
    public abstract int get_value();
 
158
}
 
159
 
 
160
/**
 
161
 * Encapsulates a pane that can be installed in the on-screen import dialog box to
 
162
 * communicate status to and to get information from the user.
 
163
 *
 
164
 */
 
165
public interface DialogPane : GLib.Object {
 
166
 
 
167
    /**
 
168
     * Describes how the on-screen publishing dialog box should look and behave when an associated
 
169
     * pane is installed in the on-screen publishing dialog box.
 
170
     */
 
171
    public enum GeometryOptions {
 
172
    
 
173
        /**
 
174
         * When the associated pane is installed, the on-screen publishing dialog box will be
 
175
         * sized normally and will not allow the user to change its size.
 
176
         */
 
177
        NONE =          0,
 
178
 
 
179
        /**
 
180
         * If this bit is set, when the associated pane is installed, the on-screen publishing
 
181
         * dialog box will grow to a larger size.
 
182
         */
 
183
        EXTENDED_SIZE = 1 << 0,
 
184
 
 
185
        /**
 
186
         * If this bit is set, when the associated pane is installed, the on-screen publishing
 
187
         * dialog box will allow the user to change its size.
 
188
         */
 
189
        RESIZABLE =     1 << 1,
 
190
 
 
191
        /**
 
192
         * If this bit is set, when the associated pane is installed, the on-screen publishing
 
193
         * dialog box will grow to accomodate a full-width 1024 pixel web page. If both
 
194
         * EXTENDED_SIZE and COLOSSAL_SIZE are set, EXTENDED_SIZE takes precedence.
 
195
         */
 
196
        COLOSSAL_SIZE = 1 << 2;
 
197
    }
 
198
 
 
199
    /**
 
200
     * Returns the Gtk.Widget that is this pane's on-screen representation.
 
201
     */
 
202
    public abstract Gtk.Widget get_widget();
 
203
    
 
204
    /**
 
205
     * Returns a {@link GeometryOptions} bitfield describing how the on-screen publishing dialog
 
206
     * box should look and behave when this pane is installed.
 
207
     */
 
208
    public abstract GeometryOptions get_preferred_geometry();
 
209
 
 
210
    /**
 
211
     * Invoked automatically by Shotwell when this pane has been installed into the on-screen
 
212
     * publishing dialog box and become visible to the user.
 
213
     */
 
214
    public abstract void on_pane_installed();
 
215
 
 
216
    /**
 
217
     * Invoked automatically by Shotwell when this pane has been removed from the on-screen
 
218
     * publishing dialog box and is no longer visible to the user.
 
219
     */
 
220
    public abstract void on_pane_uninstalled();
 
221
    
 
222
    //
 
223
    // For future expansion.
 
224
    //
 
225
    protected virtual void reserved0() {}
 
226
    protected virtual void reserved1() {}
 
227
    protected virtual void reserved2() {}
 
228
    protected virtual void reserved3() {}
 
229
    protected virtual void reserved4() {}
 
230
    protected virtual void reserved5() {}
 
231
    protected virtual void reserved6() {}
 
232
    protected virtual void reserved7() {}
 
233
}
 
234
 
 
235
/**
 
236
 * Called by the data imports system at the end of an import batch to report
 
237
 * to the plugin the number of items that were really imported. This enables
 
238
 * the plugin to display a final message to the user. However, the plugin
 
239
 * should not rely on this callback being called in order to clean up.
 
240
 */
 
241
public delegate void ImportedItemsCountCallback(int imported_items_count);
 
242
 
 
243
/**
 
244
 * Manages and provides services for data import plugins.
 
245
 *
 
246
 * Implemented inside Shotwell, the PluginHost provides an interface through which the
 
247
 * developers of data import plugins can query and make changes to the import
 
248
 * environment. Plugins can use the services of the PluginHost only when their
 
249
 * {@link DataImporter} is in the running state. This ensures that non-running data importers
 
250
 * don’t destructively interfere with the actively running importer.
 
251
 */
 
252
public interface PluginHost : GLib.Object, Spit.HostInterface {
 
253
 
 
254
    /**
 
255
     * Specifies the label text on the push button control that appears in the
 
256
     * lower-right-hand corner of the on-screen publishing dialog box.
 
257
     */
 
258
    public enum ButtonMode {
 
259
        CLOSE = 0,
 
260
        CANCEL = 1
 
261
    }
 
262
    
 
263
    /**
 
264
     * Notifies the user that an unrecoverable import error has occurred and halts
 
265
     * the import process.
 
266
     *
 
267
     * @param err An error object that describes the kind of error that occurred.
 
268
     */
 
269
    public abstract void post_error(Error err);
 
270
 
 
271
    /**
 
272
     * Notifies the user that an unrecoverable import error has occurred and halts
 
273
     * the import process.
 
274
     *
 
275
     * @param msg A message that describes the kind of error that occurred.
 
276
     */
 
277
    public abstract void post_error_message(string msg);
 
278
 
 
279
    /**
 
280
     * Starts the import process.
 
281
     *
 
282
     * Calling this method starts the import activity for this host.
 
283
     */
 
284
    public abstract void start_importing();
 
285
 
 
286
    /**
 
287
     * Halts the import process.
 
288
     *
 
289
     * Calling this method stops all import activity and hides the on-screen import
 
290
     * dialog box.
 
291
     */
 
292
    public abstract void stop_importing();
 
293
 
 
294
    /**
 
295
     * Returns a reference to the {@link DataImporter} object that this is currently hosting.
 
296
     */
 
297
    public abstract DataImporter get_data_importer();
 
298
 
 
299
    /**
 
300
     * Attempts to install a pane in the on-screen data import dialog box, making the pane visible
 
301
     * and allowing it to interact with the user.
 
302
     *
 
303
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
304
     * 
 
305
     * @param pane the pane to install
 
306
     *
 
307
     * @param mode allows you to set the text displayed on the close/cancel button in the
 
308
     * lower-right-hand corner of the on-screen data import dialog box when pane is installed.
 
309
     * If mode is ButtonMode.CLOSE, the button will have the title "Close." If mode is
 
310
     * ButtonMode.CANCEL, the button will be titled "Cancel." You should set mode depending on
 
311
     * whether a cancellable action is in progress. For example, if your importer is in the
 
312
     * middle of processing 3 of 8 videos, then mode should be ButtonMode.CANCEL. However, if
 
313
     * the processing operation has completed and the success pane is displayed, then mode
 
314
     * should be ButtonMode.CLOSE, because all cancellable actions have already
 
315
     * occurred.
 
316
     */
 
317
    public abstract void install_dialog_pane(Spit.DataImports.DialogPane pane,
 
318
        ButtonMode mode = ButtonMode.CANCEL);
 
319
 
 
320
    /**
 
321
     * Attempts to install a pane in the on-screen data import dialog box that contains
 
322
     * static text.
 
323
     *
 
324
     * The text appears centered in the data import dialog box and is drawn in
 
325
     * the system font. This is a convenience method only; similar results could be
 
326
     * achieved by manually constructing a Gtk.Label widget, wrapping it inside a
 
327
     * {@link DialogPane}, and installing it manually with a call to
 
328
     * install_dialog_pane( ). To provide visual consistency across data import services,
 
329
     * however, always use this convenience method instead of constructing label panes when
 
330
     * you need to display static text to the user.
 
331
     *
 
332
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
333
     * 
 
334
     * @param message the text to show in the pane
 
335
     *
 
336
     * @param mode allows you to set the text displayed on the close/cancel button in the
 
337
     * lower-right-hand corner of the on-screen data import dialog box when pane is installed.
 
338
     * If mode is ButtonMode.CLOSE, the button will have the title "Close." If mode is
 
339
     * ButtonMode.CANCEL, the button will be titled "Cancel." You should set mode depending on
 
340
     * whether a cancellable action is in progress. For example, if your importer is in the
 
341
     * middle of processing 3 of 8 videos, then mode should be ButtonMode.CANCEL. However, if
 
342
     * the processing operation has completed and the success pane is displayed, then mode
 
343
     * should be ButtonMode.CLOSE, because all cancellable actions have already
 
344
     * occurred.
 
345
     */
 
346
    public abstract void install_static_message_pane(string message,
 
347
        ButtonMode mode = ButtonMode.CANCEL);
 
348
    
 
349
    /**
 
350
     * Attempts to install a library selection pane that presents a list of
 
351
     * discovered libraries to the user.
 
352
     *
 
353
     * When the user clicks the “OK” button, you’ll be notified of the user’s action through
 
354
     * the 'on_library_selected' callback if a discovered library was selected or through
 
355
     * the 'on_file_selected' callback if a file was selected.
 
356
     *
 
357
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
358
     *
 
359
     * @param welcome_message the text to be displayed above the list of discovered
 
360
     * libraries.
 
361
     *
 
362
     * @param discovered_libraries the list of importable libraries that the plugin
 
363
     * has discovered in well known locations.
 
364
     *
 
365
     * @param file_select_label the label to display for the file selection
 
366
     * option. If this label is null, the
 
367
     * user will not be presented with a file selection option.
 
368
     */
 
369
    public abstract void install_library_selection_pane(
 
370
        string welcome_message,
 
371
        ImportableLibrary[] discovered_libraries,
 
372
        string? file_select_label
 
373
    );
 
374
    
 
375
    /**
 
376
     * Attempts to install a progress pane that provides the user with feedback
 
377
     * on import preparation.
 
378
     *
 
379
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
380
     *
 
381
     * @param message the text to be displayed above the progress bar.
 
382
     */
 
383
    public abstract void install_import_progress_pane(
 
384
        string message
 
385
    );
 
386
    
 
387
    /**
 
388
     * Update the progress bar installed by install_import_progress_pane.
 
389
     *
 
390
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
391
     *
 
392
     * @param progress a value between 0.0 and 1.0 identifying progress for the
 
393
     * plugin.
 
394
     *
 
395
     * @param progress_label the text to be displayed below the progress bar. If that
 
396
     * parameter is null, the message will be left unchanged.
 
397
     */
 
398
    public abstract void update_import_progress_pane(
 
399
        double progress,
 
400
        string? progress_message = null
 
401
    );
 
402
    
 
403
    /**
 
404
     * Sends an importable media item to the host in order to prepare it for import
 
405
     * and update the progress bar installed by install_import_progress_pane.
 
406
     *
 
407
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
408
     *
 
409
     * @param item the importable media item to prepare for import.
 
410
     *
 
411
     * @param progress a value between 0.0 and 1.0 identifying progress for the
 
412
     * plugin.
 
413
     *
 
414
     * @param host_progress_delta the amount of progress the host should update
 
415
     * the progress bar during import preparation. Plugins should ensure that
 
416
     * a proportion of progress for each media item is set aside for the host
 
417
     * in oder to ensure a smoother update to the progress bar.
 
418
     *
 
419
     * @param progress_message the text to be displayed below the progress bar. If that
 
420
     * parameter is null, the message will be left unchanged.
 
421
     */
 
422
    public abstract void prepare_media_items_for_import(
 
423
        ImportableMediaItem[] items,
 
424
        double progress,
 
425
        double host_progress_delta = 0.0,
 
426
        string? progress_message = null
 
427
    );
 
428
    
 
429
    /**
 
430
     * Finalize the import sequence for the plugin. This tells the host that
 
431
     * all media items have been processed and that the plugin has finished all
 
432
     * import work. Once this method has been called, all resources used by the
 
433
     * plugin for import should be released and the plugin should be back to the
 
434
     * state it had just after running the start method. The host will then display
 
435
     * the final message and show progress as fully complete. In a standard import
 
436
     * scenario, the user is expected to click the Close button to dismiss the
 
437
     * dialog. On first run, the host may call the LibrarySelectedCallback again
 
438
     * to import another library handled by the same plugin.
 
439
     *
 
440
     * If an error has posted, the {@link PluginHost} will not honor this request.
 
441
     *
 
442
     * @param finalize_message the text to be displayed below the progress bar. If that
 
443
     * parameter is null, the message will be left unchanged.
 
444
     */
 
445
    public abstract void finalize_import(
 
446
        ImportedItemsCountCallback report_imported_items_count,
 
447
        string? finalize_message = null
 
448
    );
 
449
    
 
450
    //
 
451
    // For future expansion.
 
452
    //
 
453
    protected virtual void reserved0() {}
 
454
    protected virtual void reserved1() {}
 
455
    protected virtual void reserved2() {}
 
456
    protected virtual void reserved3() {}
 
457
    protected virtual void reserved4() {}
 
458
    protected virtual void reserved5() {}
 
459
    protected virtual void reserved6() {}
 
460
    protected virtual void reserved7() {}
 
461
}
 
462
 
 
463
/**
 
464
 * Describes the features and capabilities of a data import service.
 
465
 *
 
466
 * Developers of data import plugins provide a class that implements this interface.
 
467
 */
 
468
public interface Service : Object, Spit.Pluggable {
 
469
    /**
 
470
     * A factory method that instantiates and returns a new {@link DataImporter} object
 
471
     * that this Service describes.
 
472
     */
 
473
    public abstract Spit.DataImports.DataImporter create_data_importer(Spit.DataImports.PluginHost host);
 
474
 
 
475
    //
 
476
    // For future expansion.
 
477
    //
 
478
    protected virtual void reserved0() {}
 
479
    protected virtual void reserved1() {}
 
480
    protected virtual void reserved2() {}
 
481
    protected virtual void reserved3() {}
 
482
    protected virtual void reserved4() {}
 
483
    protected virtual void reserved5() {}
 
484
    protected virtual void reserved6() {}
 
485
    protected virtual void reserved7() {}
 
486
}
 
487
 
 
488
}
 
489