diff options
author | John Mayhew | 2012-07-09 17:28:24 -0700 |
---|---|---|
committer | John Mayhew | 2012-07-09 17:28:24 -0700 |
commit | 770bcb52422742ff741a88a75ecefbeb90bc9247 (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/io/system/coreioapi.js | |
parent | 8c5ecaf90062f9e030386f338bdc19fd62b826c8 (diff) | |
parent | 2b2b5fbb4b6a786daa4e9d4ee9eba9ac78924842 (diff) | |
download | ninja-770bcb52422742ff741a88a75ecefbeb90bc9247.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Conflicts:
manifest.json
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-x | js/io/system/coreioapi.js | 593 |
1 files changed, 297 insertions, 296 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index d3977106..6f9766c6 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -32,87 +33,87 @@ POSSIBILITY OF SUCH DAMAGE. | |||
32 | //////////////////////////////////////////////////////////////////////// | 33 | //////////////////////////////////////////////////////////////////////// |
33 | NOTES: | 34 | NOTES: |
34 | 35 | ||
35 | Core API reference in NINJA: this.application.ninja.coreIoApi | 36 | Core API reference in NINJA: this.application.ninja.coreIoApi |
36 | 37 | ||
37 | //////////////////////////////////////////////////////////////////////// | 38 | //////////////////////////////////////////////////////////////////////// |
38 | ///////////////////////////////////////////////////////////////////// */ | 39 | ///////////////////////////////////////////////////////////////////// */ |
39 | var Montage = require("montage/core/core").Montage, | 40 | var Montage = require("montage/core/core").Montage, |
40 | Component = require("montage/ui/component").Component, | 41 | Component = require("montage/ui/component").Component, |
41 | Popup = require("js/components/popup.reel").Popup, | 42 | Popup = require("js/components/popup.reel").Popup, |
42 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, | 43 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, |
43 | ChromeApi = require("js/io/system/chromeapi").ChromeApi, | 44 | ChromeApi = require("js/io/system/chromeapi").ChromeApi, |
44 | NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; | 45 | NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; |
45 | //////////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////////// |
46 | //Exporting as Project I/O | 47 | //Exporting as Project I/O |
47 | exports.CoreIoApi = Montage.create(Component, { | 48 | exports.CoreIoApi = Montage.create(Component, { |
48 | //////////////////////////////////////////////////////////////////// | 49 | //////////////////////////////////////////////////////////////////// |
49 | // | 50 | // |
50 | deserializedFromTemplate: { | 51 | deserializedFromTemplate: { |
51 | enumerable: false, | 52 | enumerable: false, |
52 | value: function () { | 53 | value: function () { |
53 | //////////////////////////////////////////////////////////// | 54 | //////////////////////////////////////////////////////////// |
54 | //Checking for local storage of URL for IO | 55 | //Checking for local storage of URL for IO |
55 | if (this.application.localStorage.getItem("ioRootUrl")) { | 56 | if (this.application.localStorage.getItem("ioRootUrl")) { |
56 | //Getting URL from local storage | 57 | //Getting URL from local storage |
57 | this.rootUrl = this.application.localStorage.getItem("ioRootUrl"); | 58 | this.rootUrl = this.application.localStorage.getItem("ioRootUrl"); |
58 | //Checks for IO API to be active | 59 | //Checks for IO API to be active |
59 | this.ioServiceDetected = this.cloudAvailable(); | 60 | this.ioServiceDetected = this.cloudAvailable(); |
60 | } else { | 61 | } else { |
61 | //IO API to be inactive | 62 | //IO API to be inactive |
62 | this.ioServiceDetected = false; | 63 | this.ioServiceDetected = false; |
63 | } | 64 | } |
64 | //////////////////////////////////////////////////////////// | 65 | //////////////////////////////////////////////////////////// |
65 | //Instance of ninja library | 66 | //Instance of ninja library |
66 | this.ninjaLibrary = NinjaLibrary; | 67 | this.ninjaLibrary = NinjaLibrary; |
67 | this.ninjaLibrary.coreApi = this; | 68 | this.ninjaLibrary.coreApi = this; |
68 | //Getting reference of chrome file system API | 69 | //Getting reference of chrome file system API |
69 | this.chromeFileSystem = ChromeApi; | 70 | this.chromeFileSystem = ChromeApi; |
70 | //Sending size in MBs for file system storage | 71 | //Sending size in MBs for file system storage |
71 | var chromeFs = this.chromeFileSystem.init(20); | 72 | var chromeFs = this.chromeFileSystem.init(20); |
72 | //Checking for availability of API | 73 | //Checking for availability of API |
73 | if (chromeFs) { | 74 | if (chromeFs) { |
74 | this.chromeFileSystem.addEventListener('ready', this, false); | 75 | this.chromeFileSystem.addEventListener('ready', this, false); |
75 | } else { | 76 | } else { |
76 | //Error, Chrome File System API not detected | 77 | //Error, Chrome File System API not detected |
77 | } | 78 | } |
78 | //////////////////////////////////////////////////////////// | 79 | //////////////////////////////////////////////////////////// |
79 | } | 80 | } |
80 | }, | 81 | }, |
81 | //////////////////////////////////////////////////////////////////// | 82 | //////////////////////////////////////////////////////////////////// |
82 | // | 83 | // |
83 | handleReady: { | 84 | handleReady: { |
84 | enumerable: false, | 85 | enumerable: false, |
85 | value: function (e) { | 86 | value: function (e) { |
86 | //Removing events | 87 | //Removing events |
87 | this.chromeFileSystem.removeEventListener('ready', this, false); | 88 | this.chromeFileSystem.removeEventListener('ready', this, false); |
88 | //Listening for library to be copied event (builds list) | 89 | //Listening for library to be copied event (builds list) |
89 | this.chromeFileSystem.addEventListener('library', this, false); | 90 | this.chromeFileSystem.addEventListener('library', this, false); |
90 | //TODO: Add sync loading screen logic (Add screen here) | 91 | //TODO: Add sync loading screen logic (Add screen here) |
91 | } | 92 | } |
92 | }, | 93 | }, |
93 | //////////////////////////////////////////////////////////////////// | 94 | //////////////////////////////////////////////////////////////////// |
94 | // | 95 | // |
95 | handleLibrary: { | 96 | handleLibrary: { |
96 | enumerable: false, | 97 | enumerable: false, |
97 | value: function (e) { | 98 | value: function (e) { |
98 | //Removing events | 99 | //Removing events |
99 | this.chromeFileSystem.removeEventListener('library', this, false); | 100 | this.chromeFileSystem.removeEventListener('library', this, false); |
100 | //Listening for synced library event | 101 | //Listening for synced library event |
101 | this.ninjaLibrary.addEventListener('sync', this, false); | 102 | this.ninjaLibrary.addEventListener('sync', this, false); |
102 | //Sending library to be synced to chrome | 103 | //Sending library to be synced to chrome |
103 | this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); | 104 | this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); |
104 | 105 | ||
105 | } | 106 | } |
106 | }, | 107 | }, |
107 | //////////////////////////////////////////////////////////////////// | 108 | //////////////////////////////////////////////////////////////////// |
108 | // | 109 | // |
109 | handleSync: { | 110 | handleSync: { |
110 | enumerable: false, | 111 | enumerable: false, |
111 | value: function (e) { | 112 | value: function (e) { |
112 | console.log('Ninja Local Library: Ready'); | 113 | console.log('Ninja Local Library: Ready'); |
113 | //Removing events | 114 | //Removing events |
114 | this.ninjaLibrary.removeEventListener('sync', this, false); | 115 | this.ninjaLibrary.removeEventListener('sync', this, false); |
115 | //TODO: Add sync loading screen logic (Remove screen here) | 116 | //TODO: Add sync loading screen logic (Remove screen here) |
116 | } | 117 | } |
117 | }, | 118 | }, |
118 | //////////////////////////////////////////////////////////////////// | 119 | //////////////////////////////////////////////////////////////////// |
@@ -124,12 +125,12 @@ exports.CoreIoApi = Montage.create(Component, { | |||
124 | //////////////////////////////////////////////////////////////////// | 125 | //////////////////////////////////////////////////////////////////// |
125 | // | 126 | // |
126 | chromeNinjaLibrary: { | 127 | chromeNinjaLibrary: { |
127 | enumerable: false, | 128 | enumerable: false, |
128 | get: function() { | 129 | get: function() { |
129 | return this._chromeNinjaLibrary; | 130 | return this._chromeNinjaLibrary; |
130 | }, | 131 | }, |
131 | set: function(value) { | 132 | set: function(value) { |
132 | this._chromeNinjaLibrary = value; | 133 | this._chromeNinjaLibrary = value; |
133 | } | 134 | } |
134 | }, | 135 | }, |
135 | //////////////////////////////////////////////////////////////////// | 136 | //////////////////////////////////////////////////////////////////// |
@@ -141,15 +142,15 @@ exports.CoreIoApi = Montage.create(Component, { | |||
141 | //////////////////////////////////////////////////////////////////// | 142 | //////////////////////////////////////////////////////////////////// |
142 | // | 143 | // |
143 | chromeFileSystem: { | 144 | chromeFileSystem: { |
144 | enumerable: false, | 145 | enumerable: false, |
145 | get: function() { | 146 | get: function() { |
146 | return this._chromeFileSystem; | 147 | return this._chromeFileSystem; |
147 | }, | 148 | }, |
148 | set: function(value) { | 149 | set: function(value) { |
149 | this._chromeFileSystem = value; | 150 | this._chromeFileSystem = value; |
150 | } | 151 | } |
151 | }, | 152 | }, |
152 | //////////////////////////////////////////////////////////////////// | 153 | //////////////////////////////////////////////////////////////////// |
153 | // | 154 | // |
154 | _ioServiceDetected: { | 155 | _ioServiceDetected: { |
155 | enumerable: false, | 156 | enumerable: false, |
@@ -158,15 +159,15 @@ exports.CoreIoApi = Monta |