diff options
Diffstat (limited to 'js/io/system')
-rw-r--r-- | js/io/system/config.xml | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/coreioapi.js (renamed from js/io/system/shellapi.js) | 342 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/fileio.js | 175 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/filesystem.js | 78 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/projectio.js | 0 |
5 files changed, 420 insertions, 181 deletions
diff --git a/js/io/system/config.xml b/js/io/system/config.xml deleted file mode 100644 index 4660d647..00000000 --- a/js/io/system/config.xml +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <!-- COPY TO 'MainApp/cloud' and set your own URLs --> | ||
3 | <services> | ||
4 | <file><![CDATA[http://file.services.ninja.motorola.com/]]></file> | ||
5 | <directory><![CDATA[http://directory.services.ninja.motorola.com/]]></directory> | ||
6 | </services> | ||
diff --git a/js/io/system/shellapi.js b/js/io/system/coreioapi.js index 9976dbed..33c7bc28 100644..100755 --- a/js/io/system/shellapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -6,104 +6,139 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | /* ///////////////////////////////////////////////////////////////////// | 7 | /* ///////////////////////////////////////////////////////////////////// |
8 | //////////////////////////////////////////////////////////////////////// | 8 | //////////////////////////////////////////////////////////////////////// |
9 | NOTES: All logic should be handled in the FileSystem and I/O classes | 9 | NOTES: |
10 | |||
11 | Dialog methods on NativeShellApp | ||
12 | ShowFileOpenDialog(initialDir) - shows a file open dialog | ||
13 | initialDir is optional and if specified will cause the dialog to initially display that directory as the open location | ||
14 | ShowFileSaveAsDialog(initialURI) - shows a file Save As dialog | ||
15 | initialURI is optional and if specified will cause the dialog to initially display the directory as the default location | ||
16 | and the filename as the current filename. | ||
17 | ShowSelectDirectoryDialog(initialDir, dialogTitle) - displays a directory select/chooser dialog | ||
18 | intitalDir is optional and specifies the directory that should be selected/shown when the dialog opens | ||
19 | dialogTitle is optional and specifies the title that should appear in the dialog caption | ||
20 | //////////////////////////////////////////////////////////////////////// | 10 | //////////////////////////////////////////////////////////////////////// |
21 | ///////////////////////////////////////////////////////////////////// */ | 11 | ///////////////////////////////////////////////////////////////////// */ |
12 | var Montage = require("montage/core/core").Montage, | ||
13 | Component = require("montage/ui/component").Component; | ||
14 | //////////////////////////////////////////////////////////////////////// | ||
22 | //Exporting as Project I/O | 15 | //Exporting as Project I/O |
23 | exports.ShellApi = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { | 16 | exports.CoreIoApi = Montage.create(Component, { |
24 | //////////////////////////////////////////////////////////////////// | 17 | //////////////////////////////////////////////////////////////////// |
25 | // | 18 | // |
26 | init: { | 19 | deserializedFromTemplate: { |
27 | enumerable: false, | 20 | enumerable: false, |
28 | value: function() { | 21 | value: function () { |
29 | try { | 22 | //Checking for local storage of URL for IO |
30 | var xhr = new XMLHttpRequest(), file, directory; | 23 | if (window.localStorage['ioRootUrl']) { |
31 | // | 24 | //Getting URL from local storage |
32 | xhr.open("GET", 'cloud/config.xml', false); | 25 | this.rootUrl = window.localStorage['ioRootUrl']; |
33 | xhr.send(); | 26 | //Checks for IO API to be active |
27 | this.ioServiceDetected = this.cloudAvailable(); | ||
34 | // | 28 | // |
35 | if (xhr.readyState === 4) { | 29 | console.log('FileIO: localStorage URL detected | IO Service Detected: '+ this.ioServiceDetected); |
36 | file = xhr.responseXML.getElementsByTagName('file')[0].firstChild.nodeValue; | 30 | // |
37 | directory = xhr.responseXML.getElementsByTagName('directory')[0].firstChild.nodeValue; | 31 | } else { |
38 | if (file.length) | 32 | //TODO: Remove, automatically prompt user on welcome |
39 | this._fileServiceURL = file; | 33 | this.rootUrl = 'http://localhost:16380'; |
40 | if (directory.length) | 34 | //TODO: Changed to false, welcome screen prompts user |
41 | this._directoryServiceURL = directory; | 35 | this.ioServiceDetected = this.cloudAvailable(); |
42 | // | 36 | // |
43 | //console.log(file, directory); | 37 | console.log('FileIO: localStorage URL NOT detected | IO Service Detected: '+ this.ioServiceDetected); |
44 | } | 38 | // |
45 | } | 39 | } |
46 | catch(error) { | 40 | } |
47 | console.log(error); | 41 | }, |
48 | } | 42 | //////////////////////////////////////////////////////////////////// |
49 | } | 43 | //Method to check status of I/O API, will return false if not active |
44 | cloudAvailable: { | ||
45 | enumerable: false, | ||
46 | value: function () { | ||
47 | // | ||
48 | if (this.getCloudStatus().status === 200) { | ||
49 | //Active | ||
50 | return true; | ||
51 | } else { | ||
52 | //Inactive | ||
53 | //TODO: Logic to prompt the user for cloud, otherwise return false | ||
54 | return false; | ||
55 | } | ||
56 | } | ||
57 | }, | ||
58 | //////////////////////////////////////////////////////////////////// | ||
59 | // | ||
60 | _ioServiceDetected: { | ||
61 | enumerable: false, | ||
62 | value: false | ||
63 | }, | ||
64 | //////////////////////////////////////////////////////////////////// | ||
65 | //Checking for service availability on boot | ||
66 | ioServiceDetected: { | ||
67 | enumerable: false, | ||
68 | get: function() { | ||
69 | return this._ioServiceDetected; | ||
70 | }, | ||
71 | set: function(value) { | ||
72 | this._ioServiceDetected = value; | ||
73 | } | ||
74 | }, | ||
75 | //////////////////////////////////////////////////////////////////// | ||
76 | //Root API URL | ||
77 | _rootUrl: { | ||
78 | enumerable: false, | ||
79 | value: null | ||
50 | }, | 80 | }, |
51 | //////////////////////////////////////////////////////////////////// | 81 | //////////////////////////////////////////////////////////////////// |
52 | // | 82 | // |
53 | openShellDialog: { | 83 | rootUrl: { |
54 | enumerable: false, | 84 | enumerable: false, |
55 | value: function(dialog) { | 85 | get: function() { |
56 | //Initializing return variable | 86 | return this._rootUrl; |
57 | var input = null; | 87 | }, |
58 | //Checking for the type of prompt set via object | 88 | set: function(value) { |
59 | switch (dialog.type) { | 89 | this._rootUrl = window.localStorage["ioRootUrl"] = value; |
60 | case 'file': | 90 | } |
61 | //Checking for action the prompt will ask the user | 91 | }, |
62 | if (dialog.action.toLowerCase() == 'open') { | 92 | //////////////////////////////////////////////////////////////////// |
63 | //File open dialog | 93 | //API service URL |
64 | input = window.NativeShellApp.ShowFileOpenDialog(); | 94 | _apiServiceURL: { |
65 | } else if (dialog.action.toLowerCase() == 'new') { | 95 | enumerable: false, |
66 | //File new dialog | 96 | value: '/cloudstatus' |
67 | input = window.NativeShellApp.ShowFileSaveAsDialog(); | ||
68 | } | ||
69 | break; | ||
70 | case 'directory': | ||
71 | //Checking for action the prompt will ask the user | ||
72 | if (dialog.action.toLowerCase() == 'open') { | ||
73 | //Directory open dialog | ||
74 | input = window.NativeShellApp.ShowSelectDirectoryDialog(); | ||
75 | } else if (dialog.action.toLowerCase() == 'new') { | ||
76 | //Directory new dialog | ||
77 | input = window.NativeShellApp.ShowSelectDirectoryDialog(); | ||
78 | } | ||
79 | break; | ||
80 | break; | ||
81 | default: | ||
82 | break; | ||
83 | } | ||
84 | return input; | ||
85 | } | ||
86 | }, | 97 | }, |
87 | //////////////////////////////////////////////////////////////////// | 98 | //////////////////////////////////////////////////////////////////// |
88 | // | 99 | // |
89 | startServer: { | 100 | apiServiceURL: { |
90 | enumerable: false, | 101 | enumerable: false, |
91 | value: function (dir) { | 102 | get: function() { |
92 | var server = window.NativeShellApp.StartWebServer(dir); | 103 | return String(this.rootUrl+this._apiServiceURL); |
93 | return server; | 104 | }, |
105 | set: function(value) { | ||
106 | this._apiServiceURL = value; | ||
94 | } | 107 | } |
95 | }, | 108 | }, |
96 | //////////////////////////////////////////////////////////////////// | 109 | //////////////////////////////////////////////////////////////////// |
97 | // private property containing the file service URL to use for all file IO calls | 110 | //File service API URL |
98 | _fileServiceURL: { | 111 | _fileServiceURL: { |
99 | enumerable: false, | 112 | enumerable: false, |
100 | value: "http://localhost:16380/file" //default value.. updated with base uri in config.xml | 113 | value: '/file' |
114 | }, | ||
115 | //////////////////////////////////////////////////////////////////// | ||
116 | // | ||
117 | fileServiceURL: { | ||
118 | enumerable: false, | ||
119 | get: function() { | ||
120 | return String(this.rootUrl+this._fileServiceURL); | ||
121 | }, | ||
122 | set: function(value) { | ||
123 | this._fileServiceURL = value; | ||
124 | } | ||
101 | }, | 125 | }, |
102 | //////////////////////////////////////////////////////////////////// | 126 | //////////////////////////////////////////////////////////////////// |
103 | // private property containing the directory service URL to use for all file IO calls | 127 | //Directory service API URL |
104 | _directoryServiceURL: { | 128 | _directoryServiceURL: { |
105 | enumerable: false, | 129 | enumerable: false, |
106 | value: "http://localhost:16380/directory" //default value.. updated with base uri in config.xml | 130 | value: '/directory' |
131 | }, | ||
132 | //////////////////////////////////////////////////////////////////// | ||
133 | // | ||
134 | directoryServiceURL: { | ||
135 | enumerable: false, | ||
136 | get: function() { | ||
137 | return String(this.rootUrl+this._directoryServiceURL); | ||
138 | }, | ||
139 | set: function(value) { | ||
140 | this._directoryServiceURL = value; | ||
141 | } | ||
107 | }, | 142 | }, |
108 | //////////////////////////////////////////////////////////////////// | 143 | //////////////////////////////////////////////////////////////////// |
109 | // private helper to parse URIs and append them to the service URL | 144 | // private helper to parse URIs and append them to the service URL |
@@ -117,6 +152,11 @@ exports.ShellApi = (require("montage/core/core").Montage).create(require("montag | |||
117 | if((urlOut.length > 0) && (urlOut.charAt(0) !== "/")){ | 152 | if((urlOut.length > 0) && (urlOut.charAt(0) !== "/")){ |
118 | urlOut = "/" + urlOut; |