1
1
function createContentHubApi(backendBridge) {
2
2
var PLUGIN_URI = 'ContentHub';
4
function ContentTransfer(objectid) {
4
function ContentTransfer(objectid, content) {
5
5
this._proxy = backendBridge.createRemoteObject(
6
6
PLUGIN_URI, 'ContentTransfer', objectid);
8
this._store = content && content.store
9
? content.store : null;
10
this._state = content && content.state
11
? content.state : null;
8
13
ContentTransfer.prototype = {
28
* Retrieves the current store.
30
* If the callback parameter is not set, the current "local" value is retrieved.
33
* @param callback (optional) {Function(String)}
35
store: function(callback) {
36
if (callback && typeof(callback) === 'function') {
37
this._proxy.call('store', [], callback);
43
* Sets the current store for the ContentTransfer.
46
* @param store {ContentStore}
47
* @param callback (optional) {Function()}
49
setStore: function(store, callback) {
50
this._proxy.call('setStore', [store.serialize(), callback]);
54
* Retrieves the current state.
56
* If the callback parameter is not set, the current "local" value is retrieved.
59
* @param callback (optional) {Function(ContentTransfer.State)}
61
state: function(callback) {
62
if (callback && typeof(callback) === 'function') {
63
this._proxy.call('state', [], callback);
69
* Sets the state of the transfer.
72
* @param state {ContentTransfer.State}
73
* @param callback {Function()} called when the state has been updated
75
setState: function(state, callback) {
76
this._proxy.call('setState', [state, callback]);
23
80
* Retrieves the current selection type.
25
82
* @method selectionType
34
91
* @method setSelectionType
35
92
* @param selectionType {ContentTransfer.SelectionType}
93
* @param callback {Function()} called when the state has been updated
37
setSelectionType: function(selectionType) {
38
this._proxy.call('setSelectionType', [selectionType]);
95
setSelectionType: function(selectionType, callback) {
96
this._proxy.call('setSelectionType', [selectionType, callback]);
53
111
* @method setDirection
54
112
* @param direction {ContentTransfer.Direction}
113
* @param callback {Function()} called when the state has been updated
56
setDirection: function(direction) {
57
this._proxy.call('setDirection', [direction]);
115
setDirection: function(direction, callback) {
116
this._proxy.call('setDirection', [direction, callback]);
61
* Retrieves the list of items included in the ContentTransfer.
120
* Retrieves the list of items associated with the ContentTransfer.
64
123
* @param callback {Function( {Object{name: , url: }} )}
66
125
items: function(callback) {
67
126
this._proxy.call('items', [], callback);
129
* Sets the list of items for the associated ContentTransfer (used when exporting).
132
* @param items {Array of Object{name: String, url: String}}
133
* @param callback {Function()} called when the state has been updated
135
setItems: function(items, callback) {
136
this._proxy.call('setItems', [items, callback]);
202
271
* @param callback (optional) {Function(String)}
273
uri: function(callback) {
205
274
if (callback && typeof(callback) === 'function') {
206
275
this._proxy.call('uri', [], callback);
387
* Returns all possible peers for the given ContentType.
389
* @method knownSourcesForType
390
* @param type {ContentType} Content type.
391
* @param callback {Function ({ Array of {ContentPeer} })} Function called with the possible ContentPeers.
393
knownSourcesForType: function(type, callback) {
394
backendBridge.call('ContentHub.knownSourcesForType',
397
var wrappedPeers = [];
399
// FIXME: do this above recursively in the (bridge.js)
400
for (var i = 0; i < peers.length; ++i) {
406
callback (wrappedPeers);
318
411
* Creates a ContentStore object for the given content type.
320
413
* @method importContent
438
* Creates a ContentStore object for the given ContentPeer.
440
* @method importContent
441
* @param callback {Function} function({ContentTransfer}) Function when one requests a resource to be exported.
442
* The corresponding ContentTransfer is provided as a parameter.
444
onExportRequested: function(callback) {
445
backendBridge.call('ContentHub.onExportRequested',