Merge lp:~dbarth/cordova-ubuntu/3.4-core-platform-plugins into lp:cordova-ubuntu/container
- 3.4-core-platform-plugins
- Merge into container
Proposed by
David Barth
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | David Barth | ||||
Approved revision: | 22 | ||||
Merged at revision: | 19 | ||||
Proposed branch: | lp:~dbarth/cordova-ubuntu/3.4-core-platform-plugins | ||||
Merge into: | lp:cordova-ubuntu/container | ||||
Diff against target: |
10607 lines (+9988/-9) 98 files modified
apparmor.json (+1/-1) build/src/coreplugins.cpp (+17/-1) build/src/plugins/org.apache.cordova.battery-status/battery.cpp (+78/-0) build/src/plugins/org.apache.cordova.battery-status/battery.h (+62/-0) build/src/plugins/org.apache.cordova.camera/camera.cpp (+143/-0) build/src/plugins/org.apache.cordova.camera/camera.h (+76/-0) build/src/plugins/org.apache.cordova.console/console.cpp (+29/-0) build/src/plugins/org.apache.cordova.console/console.h (+43/-0) build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp (+58/-0) build/src/plugins/org.apache.cordova.device-motion/accelerometer.h (+55/-0) build/src/plugins/org.apache.cordova.device-orientation/compass.cpp (+75/-0) build/src/plugins/org.apache.cordova.device-orientation/compass.h (+58/-0) build/src/plugins/org.apache.cordova.device/device.cpp (+64/-0) build/src/plugins/org.apache.cordova.device/device.h (+47/-0) build/src/plugins/org.apache.cordova.dialogs/notification.cpp (+81/-0) build/src/plugins/org.apache.cordova.dialogs/notification.h (+63/-0) build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp (+247/-0) build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h (+97/-0) build/src/plugins/org.apache.cordova.file/file.cpp (+773/-0) build/src/plugins/org.apache.cordova.file/file.h (+73/-0) build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp (+119/-0) build/src/plugins/org.apache.cordova.geolocation/geolocation.h (+69/-0) build/src/plugins/org.apache.cordova.globalization/globalization.cpp (+342/-0) build/src/plugins/org.apache.cordova.globalization/globalization.h (+93/-0) build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp (+106/-0) build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h (+61/-0) build/src/plugins/org.apache.cordova.media-capture/capture.cpp (+167/-0) build/src/plugins/org.apache.cordova.media-capture/capture.h (+84/-0) build/src/plugins/org.apache.cordova.media/media.cpp (+128/-0) build/src/plugins/org.apache.cordova.media/media.h (+267/-0) build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp (+42/-0) build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h (+52/-0) build/src/plugins/org.apache.cordova.vibration/vibration.cpp (+38/-0) build/src/plugins/org.apache.cordova.vibration/vibration.h (+47/-0) config.xml (+19/-0) debian/changelog (+12/-0) debian/control (+6/-4) debian/rules (+22/-1) qml/CaptureWidget.qml (+119/-0) qml/InAppBrowser.qml (+69/-0) qml/MediaCaptureWidget.qml (+207/-0) qml/notification.qml (+44/-0) www/cordova_plugins.js (+407/-2) www/plugins/org.apache.cordova.battery-status/www/battery.js (+101/-0) www/plugins/org.apache.cordova.camera/www/Camera.js (+77/-0) www/plugins/org.apache.cordova.camera/www/CameraConstants.js (+55/-0) www/plugins/org.apache.cordova.camera/www/CameraPopoverHandle.js (+35/-0) www/plugins/org.apache.cordova.camera/www/CameraPopoverOptions.js (+39/-0) www/plugins/org.apache.cordova.console/www/console-via-logger.js (+189/-0) www/plugins/org.apache.cordova.console/www/logger.js (+357/-0) www/plugins/org.apache.cordova.device-motion/www/Acceleration.js (+31/-0) www/plugins/org.apache.cordova.device-motion/www/accelerometer.js (+171/-0) www/plugins/org.apache.cordova.device-orientation/www/CompassError.js (+36/-0) www/plugins/org.apache.cordova.device-orientation/www/CompassHeading.js (+31/-0) www/plugins/org.apache.cordova.device-orientation/www/compass.js (+105/-0) www/plugins/org.apache.cordova.device/src/ubuntu/device.js (+36/-0) www/plugins/org.apache.cordova.device/www/device.js (+79/-0) www/plugins/org.apache.cordova.dialogs/www/notification.js (+112/-0) www/plugins/org.apache.cordova.file-transfer/www/FileTransfer.js (+210/-0) www/plugins/org.apache.cordova.file-transfer/www/FileTransferError.js (+41/-0) www/plugins/org.apache.cordova.file/www/DirectoryEntry.js (+110/-0) www/plugins/org.apache.cordova.file/www/DirectoryReader.js (+74/-0) www/plugins/org.apache.cordova.file/www/Entry.js (+229/-0) www/plugins/org.apache.cordova.file/www/File.js (+79/-0) www/plugins/org.apache.cordova.file/www/FileEntry.js (+83/-0) www/plugins/org.apache.cordova.file/www/FileError.js (+48/-0) www/plugins/org.apache.cordova.file/www/FileReader.js (+389/-0) www/plugins/org.apache.cordova.file/www/FileSystem.js (+46/-0) www/plugins/org.apache.cordova.file/www/FileUploadOptions.js (+43/-0) www/plugins/org.apache.cordova.file/www/FileUploadResult.js (+31/-0) www/plugins/org.apache.cordova.file/www/FileWriter.js (+303/-0) www/plugins/org.apache.cordova.file/www/Flags.js (+38/-0) www/plugins/org.apache.cordova.file/www/LocalFileSystem.js (+25/-0) www/plugins/org.apache.cordova.file/www/Metadata.js (+33/-0) www/plugins/org.apache.cordova.file/www/ProgressEvent.js (+69/-0) www/plugins/org.apache.cordova.file/www/requestFileSystem.js (+63/-0) www/plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js (+71/-0) www/plugins/org.apache.cordova.file/www/ubuntu/DirectoryEntry.js (+28/-0) www/plugins/org.apache.cordova.file/www/ubuntu/Entry.js (+34/-0) www/plugins/org.apache.cordova.file/www/ubuntu/FileWriter.js (+137/-0) www/plugins/org.apache.cordova.geolocation/www/Coordinates.js (+71/-0) www/plugins/org.apache.cordova.geolocation/www/Position.js (+35/-0) www/plugins/org.apache.cordova.geolocation/www/PositionError.js (+40/-0) www/plugins/org.apache.cordova.geolocation/www/geolocation.js (+213/-0) www/plugins/org.apache.cordova.globalization/www/GlobalizationError.js (+43/-0) www/plugins/org.apache.cordova.globalization/www/globalization.js (+393/-0) www/plugins/org.apache.cordova.globalization/www/ubuntu/globalization.js (+168/-0) www/plugins/org.apache.cordova.inappbrowser/www/InAppBrowser.js (+98/-0) www/plugins/org.apache.cordova.media-capture/www/CaptureAudioOptions.js (+34/-0) www/plugins/org.apache.cordova.media-capture/www/CaptureError.js (+42/-0) www/plugins/org.apache.cordova.media-capture/www/CaptureImageOptions.js (+32/-0) www/plugins/org.apache.cordova.media-capture/www/CaptureVideoOptions.js (+34/-0) www/plugins/org.apache.cordova.media-capture/www/MediaFile.js (+57/-0) www/plugins/org.apache.cordova.media-capture/www/MediaFileData.js (+41/-0) www/plugins/org.apache.cordova.media-capture/www/capture.js (+95/-0) www/plugins/org.apache.cordova.media/www/Media.js (+197/-0) www/plugins/org.apache.cordova.media/www/MediaError.js (+57/-0) www/plugins/org.apache.cordova.vibration/www/vibration.js (+40/-0) |
||||
To merge this branch: | bzr merge lp:~dbarth/cordova-ubuntu/3.4-core-platform-plugins | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Abreu (community) | Approve | ||
Review via email: mp+206982@code.launchpad.net |
Commit message
Description of the change
Add missing core plugins
To post a comment you must log in.
- 19. By David Barth
-
sync with trunk
- 20. By David Barth
-
add missing plugin javascript files & assets
- 21. By David Barth
-
rules file update, but doesn't manage to copy the 2 directories i need
- 22. By David Barth
-
it worked\!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'apparmor.json' | |||
2 | --- apparmor.json 2014-02-06 00:00:42 +0000 | |||
3 | +++ apparmor.json 2014-02-19 16:53:58 +0000 | |||
4 | @@ -1,1 +1,1 @@ | |||
5 | 1 | {"policy_groups":["networking","audio"],"policy_version":1} | ||
6 | 2 | \ No newline at end of file | 1 | \ No newline at end of file |
7 | 2 | {"policy_groups":["networking","audio","camera","sensors","location","microphone","video","audio","camera","microphone"],"policy_version":1} | ||
8 | 3 | \ No newline at end of file | 3 | \ No newline at end of file |
9 | 4 | 4 | ||
10 | === modified file 'build/src/coreplugins.cpp' | |||
11 | --- build/src/coreplugins.cpp 2014-02-05 23:42:31 +0000 | |||
12 | +++ build/src/coreplugins.cpp 2014-02-19 16:53:58 +0000 | |||
13 | @@ -19,6 +19,22 @@ | |||
14 | 19 | #include <QtCore> | 19 | #include <QtCore> |
15 | 20 | #include "cplugin.h" | 20 | #include "cplugin.h" |
16 | 21 | #include "coreplugins.h" | 21 | #include "coreplugins.h" |
17 | 22 | #include "plugins/org.apache.cordova.camera/camera.h" | ||
18 | 23 | #include "plugins/org.apache.cordova.console/console.h" | ||
19 | 24 | #include "plugins/org.apache.cordova.device/device.h" | ||
20 | 25 | #include "plugins/org.apache.cordova.device-motion/accelerometer.h" | ||
21 | 26 | #include "plugins/org.apache.cordova.device-orientation/compass.h" | ||
22 | 27 | #include "plugins/org.apache.cordova.file/file.h" | ||
23 | 28 | #include "plugins/org.apache.cordova.media-capture/capture.h" | ||
24 | 29 | #include "plugins/org.apache.cordova.media/media.h" | ||
25 | 30 | #include "plugins/org.apache.cordova.inappbrowser/inappbrowser.h" | ||
26 | 31 | #include "plugins/org.apache.cordova.splashscreen/splashscreen.h" | ||
27 | 32 | #include "plugins/org.apache.cordova.vibration/vibration.h" | ||
28 | 33 | #include "plugins/org.apache.cordova.geolocation/geolocation.h" | ||
29 | 34 | #include "plugins/org.apache.cordova.globalization/globalization.h" | ||
30 | 35 | #include "plugins/org.apache.cordova.battery-status/battery.h" | ||
31 | 36 | #include "plugins/org.apache.cordova.file-transfer/file-transfer.h" | ||
32 | 37 | #include "plugins/org.apache.cordova.dialogs/notification.h" | ||
33 | 22 | INSERT_HEADER_HERE | 38 | INSERT_HEADER_HERE |
34 | 23 | 39 | ||
35 | 24 | #define INIT_PLUGIN(class) \ | 40 | #define INIT_PLUGIN(class) \ |
36 | @@ -29,7 +45,7 @@ | |||
37 | 29 | Q_DECL_EXPORT QList<QSharedPointer<CPlugin>> cordovaGetPluginInstances(Cordova *cordova) { | 45 | Q_DECL_EXPORT QList<QSharedPointer<CPlugin>> cordovaGetPluginInstances(Cordova *cordova) { |
38 | 30 | QList<QSharedPointer<CPlugin>> res; | 46 | QList<QSharedPointer<CPlugin>> res; |
39 | 31 | 47 | ||
41 | 32 | INSERT_PLUGIN_HERE | 48 | INIT_PLUGIN(Camera);INIT_PLUGIN(Console);INIT_PLUGIN(Device);INIT_PLUGIN(DeviceMotion);INIT_PLUGIN(DeviceOrientation);INIT_PLUGIN(File);INIT_PLUGIN(MediaCapture);INIT_PLUGIN(Media);INIT_PLUGIN(Inappbrowser);INIT_PLUGIN(Splashscreen);INIT_PLUGIN(Vibration);INIT_PLUGIN(Geolocation);INIT_PLUGIN(Globalization);INIT_PLUGIN(BatteryStatus);INIT_PLUGIN(FileTransfer);INIT_PLUGIN(Dialogs);INSERT_PLUGIN_HERE |
42 | 33 | 49 | ||
43 | 34 | return res; | 50 | return res; |
44 | 35 | } | 51 | } |
45 | 36 | 52 | ||
46 | === added directory 'build/src/plugins/org.apache.cordova.battery-status' | |||
47 | === added file 'build/src/plugins/org.apache.cordova.battery-status/battery.cpp' | |||
48 | --- build/src/plugins/org.apache.cordova.battery-status/battery.cpp 1970-01-01 00:00:00 +0000 | |||
49 | +++ build/src/plugins/org.apache.cordova.battery-status/battery.cpp 2014-02-19 16:53:58 +0000 | |||
50 | @@ -0,0 +1,78 @@ | |||
51 | 1 | /* | ||
52 | 2 | * Licensed to the Apache Software Foundation (ASF) under one | ||
53 | 3 | * or more contributor license agreements. See the NOTICE file | ||
54 | 4 | * distributed with this work for additional information | ||
55 | 5 | * regarding copyright ownership. The ASF licenses this file | ||
56 | 6 | * to you under the Apache License, Version 2.0 (the | ||
57 | 7 | * "License"); you may not use this file except in compliance | ||
58 | 8 | * with the License. You may obtain a copy of the License at | ||
59 | 9 | * | ||
60 | 10 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
61 | 11 | * | ||
62 | 12 | * Unless required by applicable law or agreed to in writing, | ||
63 | 13 | * software distributed under the License is distributed on an | ||
64 | 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
65 | 15 | * KIND, either express or implied. See the License for the | ||
66 | 16 | * specific language governing permissions and limitations | ||
67 | 17 | * under the License. | ||
68 | 18 | * | ||
69 | 19 | */ | ||
70 | 20 | |||
71 | 21 | #include <QtCore> | ||
72 | 22 | |||
73 | 23 | #include "battery.h" | ||
74 | 24 | |||
75 | 25 | BatteryStatus::BatteryStatus(Cordova *cordova) : CPlugin(cordova) { | ||
76 | 26 | _scId = 0; | ||
77 | 27 | |||
78 | 28 | connect(&_batteryInfo, SIGNAL(remainingCapacityChanged(int,int)), this, SLOT(remainingCapacityChanged(int,int))); | ||
79 | 29 | connect(&_batteryInfo, SIGNAL(chargerTypeChanged(QBatteryInfo::ChargerType)), this, SLOT(chargerTypeChanged(QBatteryInfo::ChargerType))); | ||
80 | 30 | } | ||
81 | 31 | |||
82 | 32 | void BatteryStatus::remainingCapacityChanged(int battery, int capacity) { | ||
83 | 33 | Q_UNUSED(battery); | ||
84 | 34 | Q_UNUSED(capacity); | ||
85 | 35 | |||
86 | 36 | fireEvents(); | ||
87 | 37 | } | ||
88 | 38 | |||
89 | 39 | void BatteryStatus::chargerTypeChanged(QBatteryInfo::ChargerType type) { | ||
90 | 40 | Q_UNUSED(type); | ||
91 | 41 | |||
92 | 42 | fireEvents(); | ||
93 | 43 | } | ||
94 | 44 | |||
95 | 45 | void BatteryStatus::fireEvents() { | ||
96 | 46 | int fullCount = 0; | ||
97 | 47 | bool isPlugged = false; | ||
98 | 48 | |||
99 | 49 | int remaining = 0, total = 0; | ||
100 | 50 | for (int i = 0; i < _batteryInfo.batteryCount(); i++) { | ||
101 | 51 | isPlugged = (_batteryInfo.chargingState(i) == QBatteryInfo::Charging) || isPlugged; | ||
102 | 52 | fullCount += _batteryInfo.chargingState(i) == QBatteryInfo::Full; | ||
103 | 53 | |||
104 | 54 | remaining += _batteryInfo.remainingCapacity(i); | ||
105 | 55 | total += _batteryInfo.maximumCapacity(i); | ||
106 | 56 | } | ||
107 | 57 | |||
108 | 58 | isPlugged = isPlugged || (_batteryInfo.batteryCount() == fullCount); | ||
109 | 59 | |||
110 | 60 | if (_scId) { | ||
111 | 61 | QVariantMap obj; | ||
112 | 62 | obj.insert("isPlugged", (int)isPlugged); | ||
113 | 63 | if (total != 0) | ||
114 | 64 | obj.insert("level", remaining * 100 / total); | ||
115 | 65 | else | ||
116 | 66 | obj.insert("level", 100); | ||
117 | 67 | |||
118 | 68 | this->callbackWithoutRemove(_scId, CordovaInternal::format(obj)); | ||
119 | 69 | } | ||
120 | 70 | } | ||
121 | 71 | |||
122 | 72 | void BatteryStatus::start(int scId, int) { | ||
123 | 73 | _scId = scId; | ||
124 | 74 | } | ||
125 | 75 | |||
126 | 76 | void BatteryStatus::stop(int, int) { | ||
127 | 77 | _scId = 0; | ||
128 | 78 | } | ||
129 | 0 | 79 | ||
130 | === added file 'build/src/plugins/org.apache.cordova.battery-status/battery.h' | |||
131 | --- build/src/plugins/org.apache.cordova.battery-status/battery.h 1970-01-01 00:00:00 +0000 | |||
132 | +++ build/src/plugins/org.apache.cordova.battery-status/battery.h 2014-02-19 16:53:58 +0000 | |||
133 | @@ -0,0 +1,62 @@ | |||
134 | 1 | /* | ||
135 | 2 | * Licensed to the Apache Software Foundation (ASF) under one | ||
136 | 3 | * or more contributor license agreements. See the NOTICE file | ||
137 | 4 | * distributed with this work for additional information | ||
138 | 5 | * regarding copyright ownership. The ASF licenses this file | ||
139 | 6 | * to you under the Apache License, Version 2.0 (the | ||
140 | 7 | * "License"); you may not use this file except in compliance | ||
141 | 8 | * with the License. You may obtain a copy of the License at | ||
142 | 9 | * | ||
143 | 10 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
144 | 11 | * | ||
145 | 12 | * Unless required by applicable law or agreed to in writing, | ||
146 | 13 | * software distributed under the License is distributed on an | ||
147 | 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
148 | 15 | * KIND, either express or implied. See the License for the | ||
149 | 16 | * specific language governing permissions and limitations | ||
150 | 17 | * under the License. | ||
151 | 18 | * | ||
152 | 19 | */ | ||
153 | 20 | |||
154 | 21 | #ifndef BATTERY_H_AAAAAAAA | ||
155 | 22 | #define BATTERY_H_AAAAAAAA | ||
156 | 23 | |||
157 | 24 | #include <QBatteryInfo> | ||
158 | 25 | |||
159 | 26 | #include <cplugin.h> | ||
160 | 27 | |||
161 | 28 | class BatteryStatus: public CPlugin { | ||
162 | 29 | Q_OBJECT | ||
163 | 30 | public: | ||
164 | 31 | explicit BatteryStatus(Cordova *cordova); | ||
165 | 32 | |||
166 | 33 | virtual const QString fullName() override { | ||
167 | 34 | return BatteryStatus::fullID(); | ||
168 | 35 | } | ||
169 | 36 | |||
170 | 37 | virtual const QString shortName() override { | ||
171 | 38 | return "Battery"; | ||
172 | 39 | } | ||
173 | 40 | |||
174 | 41 | static const QString fullID() { | ||
175 | 42 | return "Battery"; | ||
176 | 43 | } | ||
177 | 44 | |||
178 | 45 | public slots: | ||
179 | 46 | void start(int scId, int ecId); | ||
180 | 47 | void stop(int scId, int ecId); | ||
181 | 48 | |||
182 | 49 | private slots: | ||
183 | 50 | void remainingCapacityChanged(int battery, int capacity); | ||
184 | 51 | void chargerTypeChanged(QBatteryInfo::ChargerType type); | ||
185 | 52 | void onlineStatusChanged(bool isOnline); | ||
186 | 53 | |||
187 | 54 | private: | ||
188 | 55 | void fireEvents(); | ||
189 | 56 | |||
190 | 57 | QBatteryInfo _batteryInfo; | ||
191 | 58 | |||
192 | 59 | int _scId; | ||
193 | 60 | }; | ||
194 | 61 | |||
195 | 62 | #endif | ||
196 | 0 | 63 | ||
197 | === added directory 'build/src/plugins/org.apache.cordova.camera' | |||
198 | === added file 'build/src/plugins/org.apache.cordova.camera/camera.cpp' | |||
199 | --- build/src/plugins/org.apache.cordova.camera/camera.cpp 1970-01-01 00:00:00 +0000 | |||
200 | +++ build/src/plugins/org.apache.cordova.camera/camera.cpp 2014-02-19 16:53:58 +0000 | |||
201 | @@ -0,0 +1,143 @@ | |||
202 | 1 | /* | ||
203 | 2 | * | ||
204 | 3 | * Licensed to the Apache Software Foundation (ASF) under one | ||
205 | 4 | * or more contributor license agreements. See the NOTICE file | ||
206 | 5 | * distributed with this work for additional information | ||
207 | 6 | * regarding copyright ownership. The ASF licenses this file | ||
208 | 7 | * to you under the Apache License, Version 2.0 (the | ||
209 | 8 | * "License"); you may not use this file except in compliance | ||
210 | 9 | * with the License. You may obtain a copy of the License at | ||
211 | 10 | * | ||
212 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
213 | 12 | * | ||
214 | 13 | * Unless required by applicable law or agreed to in writing, | ||
215 | 14 | * software distributed under the License is distributed on an | ||
216 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
217 | 16 | * KIND, either express or implied. See the License for the | ||
218 | 17 | * specific language governing permissions and limitations | ||
219 | 18 | * under the License. | ||
220 | 19 | * | ||
221 | 20 | */ | ||
222 | 21 | |||
223 | 22 | #include "camera.h" | ||
224 | 23 | #include <cordova.h> | ||
225 | 24 | |||
226 | 25 | #include <QCameraViewfinder> | ||
227 | 26 | #include <QCameraImageCapture> | ||
228 | 27 | #include <QGraphicsObject> | ||
229 | 28 | #include <QCloseEvent> | ||
230 | 29 | #include <QQuickItem> | ||
231 | 30 | |||
232 | 31 | const char code[] = "\ | ||
233 | 32 | var component, object; \ | ||
234 | 33 | function createObject() { \ | ||
235 | 34 | component = Qt.createComponent(%1); \ | ||
236 | 35 | if (component.status == Component.Ready) \ | ||
237 | 36 | finishCreation(); \ | ||
238 | 37 | else \ | ||
239 | 38 | component.statusChanged.connect(finishCreation); \ | ||
240 | 39 | } \ | ||
241 | 40 | function finishCreation() { \ | ||
242 | 41 | CordovaWrapper.object = component.createObject(root, \ | ||
243 | 42 | {root: root, cordova: cordova}); \ | ||
244 | 43 | } \ | ||
245 | 44 | createObject()"; | ||
246 | 45 | |||
247 | 46 | |||
248 | 47 | Camera::Camera(Cordova *cordova): | ||
249 | 48 | CPlugin(cordova), | ||
250 | 49 | _lastScId(0), | ||
251 | 50 | _lastEcId(0) { | ||
252 | 51 | } | ||
253 | 52 | |||
254 | 53 | bool Camera::preprocessImage(QString &path) { | ||
255 | 54 | bool convertToPNG = (*_options.find("encodingType")).toInt() == Camera::PNG; | ||
256 | 55 | int quality = (*_options.find("quality")).toInt(); | ||
257 | 56 | int width = (*_options.find("targetWidth")).toInt(); | ||
258 | 57 | int height = (*_options.find("targetHeight")).toInt(); | ||
259 | 58 | |||
260 | 59 | QImage image(path); | ||
261 | 60 | if (width <= 0) | ||
262 | 61 | width = image.width(); | ||
263 | 62 | if (height <= 0) | ||
264 | 63 | height = image.height(); | ||
265 | 64 | image = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); | ||
266 | 65 | |||
267 | 66 | QFile oldImage(path); | ||
268 | 67 | QTemporaryFile newImage; | ||
269 | 68 | |||
270 | 69 | const char *type; | ||
271 | 70 | if (convertToPNG) { | ||
272 | 71 | newImage.setFileTemplate("imgXXXXXX.png"); | ||
273 | 72 | type = "png"; | ||
274 | 73 | } else { | ||
275 | 74 | newImage.setFileTemplate("imgXXXXXX.jpg"); | ||
276 | 75 | type = "jpg"; | ||
277 | 76 | } | ||
278 | 77 | |||
279 | 78 | newImage.open(); | ||
280 | 79 | newImage.setAutoRemove(false); | ||
281 | 80 | image.save(newImage.fileName(), type, quality); | ||
282 | 81 | |||
283 | 82 | path = newImage.fileName(); | ||
284 | 83 | oldImage.remove(); | ||
285 | 84 | |||
286 | 85 | return true; | ||
287 | 86 | } | ||
288 | 87 | |||
289 | 88 | void Camera::onImageSaved(QString path) { | ||
290 | 89 | bool dataURL = _options.find("destinationType")->toInt() == Camera::DATA_URL; | ||
291 | 90 | |||
292 | 91 | QString cbParams; | ||
293 | 92 | if (preprocessImage(path)) { | ||
294 | 93 | QString absolutePath = QFileInfo(path).absoluteFilePath(); | ||
295 | 94 | if (dataURL) { | ||
296 | 95 | QFile image(absolutePath); | ||
297 | 96 | image.open(QIODevice::ReadOnly); | ||
298 | 97 | QByteArray content = image.readAll().toBase64(); | ||
299 | 98 | cbParams = QString("\"%1\"").arg(content.data()); | ||
300 | 99 | image.remove(); | ||
301 | 100 | } else { | ||
302 | 101 | cbParams = CordovaInternal::format(QUrl::fromLocalFile(absolutePath).toString()); | ||
303 | 102 | } | ||
304 | 103 | } | ||
305 | 104 | |||
306 | 105 | this->callback(_lastScId, cbParams); | ||
307 | 106 | |||
308 | 107 | _lastEcId = _lastScId = 0; | ||
309 | 108 | } | ||
310 | 109 | |||
311 | 110 | void Camera::takePicture(int scId, int ecId, int quality, int destinationType, int/*sourceType*/, int targetWidth, int targetHeight, int encodingType, | ||
312 | 111 | int/*mediaType*/, bool/*allowEdit*/, bool/*correctOrientation*/, bool/*saveToPhotoAlbum*/, const QVariantMap &/*popoverOptions*/, int/*cameraDirection*/) { | ||
313 | 112 | if (_camera.isNull()) { | ||
314 | 113 | _camera = QSharedPointer<QCamera>(new QCamera()); | ||
315 | 114 | } | ||
316 | 115 | |||
317 | 116 | if (((_lastScId || _lastEcId) && (_lastScId != scId && _lastEcId != ecId)) || !_camera->isAvailable() || _camera->lockStatus() != QCamera::Unlocked) { | ||
318 | 117 | this->cb(_lastEcId, "Device is busy"); | ||
319 | 118 | return; | ||
320 | 119 | } | ||
321 | 120 | |||
322 | 121 | _options.clear(); | ||
323 | 122 | _options.insert("quality", quality); | ||
324 | 123 | _options.insert("destinationType", destinationType); | ||
325 | 124 | _options.insert("targetWidth", targetWidth); | ||
326 | 125 | _options.insert("targetHeight", targetHeight); | ||
327 | 126 | _options.insert("encodingType", encodingType); | ||
328 | 127 | |||
329 | 128 | _lastScId = scId; | ||
330 | 129 | _lastEcId = ecId; | ||
331 | 130 | |||
332 | 131 | QString path = m_cordova->get_app_dir() + "/../qml/CaptureWidget.qml"; | ||
333 | 132 | |||
334 | 133 | // TODO: relative url | ||
335 | 134 | QString qml = QString(code).arg(CordovaInternal::format(path)); | ||
336 | 135 | m_cordova->execQML(qml); | ||
337 | 136 | } | ||
338 | 137 | |||
339 | 138 | void Camera::cancel() { | ||
340 | 139 | m_cordova->execQML("CordovaWrapper.object.destroy()"); | ||
341 | 140 | this->cb(_lastEcId, "canceled"); | ||
342 | 141 | |||
343 | 142 | _lastEcId = _lastScId = 0; | ||
344 | 143 | } | ||
345 | 0 | 144 | ||
346 | === added file 'build/src/plugins/org.apache.cordova.camera/camera.h' | |||
347 | --- build/src/plugins/org.apache.cordova.camera/camera.h 1970-01-01 00:00:00 +0000 | |||
348 | +++ build/src/plugins/org.apache.cordova.camera/camera.h 2014-02-19 16:53:58 +0000 | |||
349 | @@ -0,0 +1,76 @@ | |||
350 | 1 | /* | ||
351 | 2 | * | ||
352 | 3 | * Licensed to the Apache Software Foundation (ASF) under one | ||
353 | 4 | * or more contributor license agreements. See the NOTICE file | ||
354 | 5 | * distributed with this work for additional information | ||
355 | 6 | * regarding copyright ownership. The ASF licenses this file | ||
356 | 7 | * to you under the Apache License, Version 2.0 (the | ||
357 | 8 | * "License"); you may not use this file except in compliance | ||
358 | 9 | * with the License. You may obtain a copy of the License at | ||
359 | 10 | * | ||
360 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
361 | 12 | * | ||
362 | 13 | * Unless required by applicable law or agreed to in writing, | ||
363 | 14 | * software distributed under the License is distributed on an | ||
364 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
365 | 16 | * KIND, either express or implied. See the License for the | ||
366 | 17 | * specific language governing permissions and limitations | ||
367 | 18 | * under the License. | ||
368 | 19 | * | ||
369 | 20 | */ | ||
370 | 21 | |||
371 | 22 | #ifndef CAMERA_H | ||
372 | 23 | #define CAMERA_H | ||
373 | 24 | |||
374 | 25 | #include <cplugin.h> | ||
375 | 26 | |||
376 | 27 | #include <QtCore> | ||
377 | 28 | #include <QQuickView> | ||
378 | 29 | #include <QCamera> | ||
379 | 30 | #include <QtMultimediaWidgets/QCameraViewfinder> | ||
380 | 31 | #include <QCameraImageCapture> | ||
381 | 32 | |||
382 | 33 | class Camera: public CPlugin { | ||
383 | 34 | Q_OBJECT | ||
384 | 35 | public: | ||
385 | 36 | explicit Camera(Cordova *cordova); | ||
386 | 37 | |||
387 | 38 | virtual const QString fullName() override { | ||
388 | 39 | return Camera::fullID(); | ||
389 | 40 | } | ||
390 | 41 | |||
391 | 42 | virtual const QString shortName() override { | ||
392 | 43 | return "Camera"; | ||
393 | 44 | } | ||
394 | 45 | |||
395 | 46 | static const QString fullID() { | ||
396 | 47 | return "Camera"; | ||
397 | 48 | } | ||
398 | 49 | |||
399 | 50 | public slots: | ||
400 | 51 | void takePicture(int scId, int ecId, int quality, int destinationType, int/*sourceType*/, int targetWidth, int targetHeight, int encodingType, | ||
401 | 52 | int/*mediaType*/, bool/*allowEdit*/, bool/*correctOrientation*/, bool/*saveToPhotoAlbum*/, const QVariantMap &popoverOptions, int cameraDirection); | ||
402 | 53 | void cancel(); | ||
403 | 54 | |||
404 | 55 | void onImageSaved(QString path); | ||
405 | 56 | |||
406 | 57 | private: | ||
407 | 58 | bool preprocessImage(QString &path); | ||
408 | 59 | |||
409 | 60 | int _lastScId; | ||
410 | 61 | int _lastEcId; | ||
411 | 62 | QSharedPointer<QCamera> _camera; | ||
412 | 63 | |||
413 | 64 | QVariantMap _options; | ||
414 | 65 | protected: | ||
415 | 66 | enum DestinationType { | ||
416 | 67 | DATA_URL = 0, | ||
417 | 68 | FILE_URI = 1 | ||
418 | 69 | }; | ||
419 | 70 | enum EncodingType { | ||
420 | 71 | JPEG = 0, | ||
421 | 72 | PNG = 1 | ||
422 | 73 | }; | ||
423 | 74 | }; | ||
424 | 75 | |||
425 | 76 | #endif // CAMERA_H | ||
426 | 0 | 77 | ||
427 | === added directory 'build/src/plugins/org.apache.cordova.console' | |||
428 | === added file 'build/src/plugins/org.apache.cordova.console/console.cpp' | |||
429 | --- build/src/plugins/org.apache.cordova.console/console.cpp 1970-01-01 00:00:00 +0000 | |||
430 | +++ build/src/plugins/org.apache.cordova.console/console.cpp 2014-02-19 16:53:58 +0000 | |||
431 | @@ -0,0 +1,29 @@ | |||
432 | 1 | /* | ||
433 | 2 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
434 | 3 | * you may not use this file except in compliance with the License. | ||
435 | 4 | * You may obtain a copy of the License at | ||
436 | 5 | * | ||
437 | 6 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
438 | 7 | * | ||
439 | 8 | * Unless required by applicable law or agreed to in writing, software | ||
440 | 9 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
441 | 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
442 | 11 | * See the License for the specific language governing permissions and | ||
443 | 12 | * limitations under the License. | ||
444 | 13 | */ | ||
445 | 14 | |||
446 | 15 | #include "console.h" | ||
447 | 16 | |||
448 | 17 | #include <iostream> | ||
449 | 18 | |||
450 | 19 | Console::Console(Cordova *cordova) : CPlugin(cordova) { | ||
451 | 20 | } | ||
452 | 21 | |||
453 | 22 | void Console::logLevel(int scId, int ecId, QString level, QString message) { | ||
454 | 23 | Q_UNUSED(scId) | ||
455 | 24 | Q_UNUSED(ecId) | ||
456 | 25 | |||
457 | 26 | if (level != "LOG") | ||
458 | 27 | std::cout << "[" << level.toStdString() << "] "; | ||
459 | 28 | std::cout << message.toStdString() << std::endl; | ||
460 | 29 | } | ||
461 | 0 | 30 | ||
462 | === added file 'build/src/plugins/org.apache.cordova.console/console.h' | |||
463 | --- build/src/plugins/org.apache.cordova.console/console.h 1970-01-01 00:00:00 +0000 | |||
464 | +++ build/src/plugins/org.apache.cordova.console/console.h 2014-02-19 16:53:58 +0000 | |||
465 | @@ -0,0 +1,43 @@ | |||
466 | 1 | /* | ||
467 | 2 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
468 | 3 | * you may not use this file except in compliance with the License. | ||
469 | 4 | * You may obtain a copy of the License at | ||
470 | 5 | * | ||
471 | 6 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
472 | 7 | * | ||
473 | 8 | * Unless required by applicable law or agreed to in writing, software | ||
474 | 9 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
475 | 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
476 | 11 | * See the License for the specific language governing permissions and | ||
477 | 12 | * limitations under the License. | ||
478 | 13 | */ | ||
479 | 14 | |||
480 | 15 | #ifndef CONSOLE_H_FDSVCXGFRS | ||
481 | 16 | #define CONSOLE_H_FDSVCXGFRS | ||
482 | 17 | |||
483 | 18 | #include <cplugin.h> | ||
484 | 19 | |||
485 | 20 | #include <QtCore> | ||
486 | 21 | |||
487 | 22 | class Console : public CPlugin { | ||
488 | 23 | Q_OBJECT | ||
489 | 24 | public: | ||
490 | 25 | explicit Console(Cordova *cordova); | ||
491 | 26 | |||
492 | 27 | virtual const QString fullName() override { | ||
493 | 28 | return Console::fullID(); | ||
494 | 29 | } | ||
495 | 30 | |||
496 | 31 | virtual const QString shortName() override { | ||
497 | 32 | return "Console"; | ||
498 | 33 | } | ||
499 | 34 | |||
500 | 35 | static const QString fullID() { | ||
501 | 36 | return "Console"; | ||
502 | 37 | } | ||
503 | 38 | |||
504 | 39 | public slots: | ||
505 | 40 | void logLevel(int scId, int ecId, QString level, QString message); | ||
506 | 41 | }; | ||
507 | 42 | |||
508 | 43 | #endif | ||
509 | 0 | 44 | ||
510 | === added directory 'build/src/plugins/org.apache.cordova.device' | |||
511 | === added directory 'build/src/plugins/org.apache.cordova.device-motion' | |||
512 | === added file 'build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp' | |||
513 | --- build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp 1970-01-01 00:00:00 +0000 | |||
514 | +++ build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp 2014-02-19 16:53:58 +0000 | |||
515 | @@ -0,0 +1,58 @@ | |||
516 | 1 | /* | ||
517 | 2 | * | ||
518 | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
519 | 4 | * you may not use this file except in compliance with the License. | ||
520 | 5 | * You may obtain a copy of the License at | ||
521 | 6 | * | ||
522 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
523 | 8 | * | ||
524 | 9 | * Unless required by applicable law or agreed to in writing, | ||
525 | 10 | * software distributed under the License is distributed on an | ||
526 | 11 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
527 | 12 | * KIND, either express or implied. See the License for the | ||
528 | 13 | * specific language governing permissions and limitations | ||
529 | 14 | * under the License. | ||
530 | 15 | * | ||
531 | 16 | */ | ||
532 | 17 | |||
533 | 18 | #include <cassert> | ||
534 | 19 | #include "accelerometer.h" | ||
535 | 20 | |||
536 | 21 | DeviceMotion::DeviceMotion(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) { | ||
537 | 22 | _accelerometerSource = QSharedPointer<QAccelerometer>(new QAccelerometer()); | ||
538 | 23 | _sensorAvaliable = _accelerometerSource->start(); | ||
539 | 24 | connect(_accelerometerSource.data(), SIGNAL(readingChanged()), SLOT(updateSensor())); | ||
540 | 25 | } | ||
541 | 26 | |||
542 | 27 | void DeviceMotion::start(int scId, int ecId) { | ||
543 | 28 | assert(_ecId == 0); | ||
544 | 29 | assert(_scId == 0); | ||
545 | 30 | |||
546 | 31 | _ecId = ecId; | ||
547 | 32 | _scId = scId; | ||
548 | 33 | |||
549 | 34 | if (!_sensorAvaliable) { | ||
550 | 35 | this->cb(ecId); | ||
551 | 36 | return; | ||
552 | 37 | } | ||
553 | 38 | } | ||
554 | 39 | |||
555 | 40 | void DeviceMotion::stop(int, int) { | ||
556 | 41 | _scId = 0; | ||
557 | 42 | _ecId = 0; | ||
558 | 43 | } | ||
559 | 44 | |||
560 | 45 | void DeviceMotion::updateSensor() { | ||
561 | 46 | QAccelerometerReading *accelerometer = _accelerometerSource->reading(); | ||
562 | 47 | |||
563 | 48 | QVariantMap obj; | ||
564 | 49 | obj.insert("x", accelerometer->x()); | ||
565 | 50 | obj.insert("y", accelerometer->y()); | ||
566 | 51 | obj.insert("z", accelerometer->z()); | ||
567 | 52 | // accelerometer->timestamp() is not sutiable. | ||
568 | 53 | // Timestamps values are microseconds since _a_ fixed point(depend on backend). | ||
569 | 54 | obj.insert("timestamp", QDateTime::currentDateTime().toMSecsSinceEpoch()); | ||
570 | 55 | |||
571 | 56 | if (_scId) | ||
572 | 57 | this->cb(_scId, obj); | ||
573 | 58 | } | ||
574 | 0 | 59 | ||
575 | === added file 'build/src/plugins/org.apache.cordova.device-motion/accelerometer.h' | |||
576 | --- build/src/plugins/org.apache.cordova.device-motion/accelerometer.h 1970-01-01 00:00:00 +0000 | |||
577 | +++ build/src/plugins/org.apache.cordova.device-motion/accelerometer.h 2014-02-19 16:53:58 +0000 | |||
578 | @@ -0,0 +1,55 @@ | |||
579 | 1 | /* | ||
580 | 2 | * | ||
581 | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
582 | 4 | * you may not use this file except in compliance with the License. | ||
583 | 5 | * You may obtain a copy of the License at | ||
584 | 6 | * | ||
585 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
586 | 8 | * | ||
587 | 9 | * Unless required by applicable law or agreed to in writing, | ||
588 | 10 | * software distributed under the License is distributed on an | ||
589 | 11 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
590 | 12 | * KIND, either express or implied. See the License for the | ||
591 | 13 | * specific language governing permissions and limitations | ||
592 | 14 | * under the License. | ||
593 | 15 | * | ||
594 | 16 | */ | ||
595 | 17 | |||
596 | 18 | #ifndef ACCELEROMETER_H | ||
597 | 19 | #define ACCELEROMETER_H | ||
598 | 20 | |||
599 | 21 | #include <cplugin.h> | ||
600 | 22 | #include <QAccelerometer> | ||
601 | 23 | #include <QtCore> | ||
602 | 24 | |||
603 | 25 | class DeviceMotion: public CPlugin { | ||
604 | 26 | Q_OBJECT | ||
605 | 27 | public: | ||
606 | 28 | explicit DeviceMotion(Cordova *cordova); | ||
607 | 29 | |||
608 | 30 | virtual const QString fullName() override { | ||
609 | 31 | return DeviceMotion::fullID(); | ||
610 | 32 | } | ||
611 | 33 | |||
612 | 34 | virtual const QString shortName() override { | ||
613 | 35 | return "Accelerometer"; | ||
614 | 36 | } | ||
615 | 37 | |||
616 | 38 | static const QString fullID() { | ||
617 | 39 | return "Accelerometer"; | ||
618 | 40 | } | ||
619 | 41 | |||
620 | 42 | public slots: | ||
621 | 43 | void start(int scId, int ecId); | ||
622 | 44 | void stop(int scId, int ecId); | ||
623 | 45 | |||
624 | 46 | protected slots: | ||
625 | 47 | void updateSensor(); | ||
626 | 48 | |||
627 | 49 | private: | ||
628 | 50 | int _scId, _ecId; | ||
629 | 51 | bool _sensorAvaliable; | ||
630 | 52 | QSharedPointer<QAccelerometer> _accelerometerSource; | ||
631 | 53 | }; | ||
632 | 54 | |||
633 | 55 | #endif | ||
634 | 0 | 56 | ||
635 | === added directory 'build/src/plugins/org.apache.cordova.device-orientation' | |||
636 | === added file 'build/src/plugins/org.apache.cordova.device-orientation/compass.cpp' | |||
637 | --- build/src/plugins/org.apache.cordova.device-orientation/compass.cpp 1970-01-01 00:00:00 +0000 | |||
638 | +++ build/src/plugins/org.apache.cordova.device-orientation/compass.cpp 2014-02-19 16:53:58 +0000 | |||
639 | @@ -0,0 +1,75 @@ | |||
640 | 1 | /* | ||
641 | 2 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
642 | 3 | * you may not use this file except in compliance with the License. | ||
643 | 4 | * You may obtain a copy of the License at | ||
644 | 5 | * | ||
645 | 6 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
646 | 7 | * | ||
647 | 8 | * Unless required by applicable law or agreed to in writing, software | ||
648 | 9 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
649 | 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
650 | 11 | * See the License for the specific language governing permissions and | ||
651 | 12 | * limitations under the License. | ||
652 | 13 | */ | ||
653 | 14 | |||
654 | 15 | #include "compass.h" | ||
655 | 16 | |||
656 | 17 | DeviceOrientation::DeviceOrientation(Cordova *cordova): CPlugin(cordova), _validData(false) { | ||
657 | 18 | _compass.connectToBackend(); | ||
658 | 19 | connect(&_compass, SIGNAL(readingChanged()), SLOT(updateSensor())); | ||
659 | 20 | connect(&_compass, SIGNAL(sensorError(int)), SLOT(sensorError(int))); | ||
660 | 21 | } | ||
661 | 22 | |||
662 | 23 | void DeviceOrientation::getHeading(int scId, int ecId, QVariantMap options) { | ||
663 | 24 | Q_UNUSED(options); | ||
664 | 25 | if (_compass.isConnectedToBackend() || !_compass.start()) { | ||
665 | 26 | this->callback(ecId, "CompassError.COMPASS_NOT_SUPPORTED"); | ||
666 | 27 | return; | ||
667 | 28 | } | ||
668 | 29 | |||
669 | 30 | _successCallbacks << scId; | ||
670 | 31 | _errorCallbacks << ecId; | ||
671 | 32 | |||
672 | 33 | if (_validData) { | ||
673 | 34 | reportResult(); | ||
674 | 35 | return; | ||
675 | 36 | } | ||
676 | 37 | } | ||
677 | 38 | |||
678 | 39 | void DeviceOrientation::sensorError(int error) { | ||
679 | 40 | Q_UNUSED(error); | ||
680 | 41 | |||
681 | 42 | for (int ecId: _errorCallbacks) { | ||
682 | 43 | this->callback(ecId, "CompassError.COMPASS_INTERNAL_ERR"); | ||
683 | 44 | } | ||
684 | 45 | |||
685 | 46 | _errorCallbacks.clear(); | ||
686 | 47 | _successCallbacks.clear(); | ||
687 | 48 | _validData = false; | ||
688 | 49 | } | ||
689 | 50 | |||
690 | 51 | void DeviceOrientation::reportResult() { | ||
691 | 52 | QVariantMap obj; | ||
692 | 53 | |||
693 | 54 | obj.insert("magneticHeading", _azymuth); | ||
694 | 55 | obj.insert("trueHeading", _azymuth); | ||
695 | 56 | obj.insert("headingAccuracy", _accuracy); | ||
696 | 57 | obj.insert("timestamp", _timestamp); | ||
697 | 58 | |||
698 | 59 | for (int scId: _successCallbacks) { | ||
699 | 60 | this->cb(scId, obj); | ||
700 | 61 | } | ||
701 | 62 | |||
702 | 63 | _errorCallbacks.clear(); | ||
703 | 64 | _successCallbacks.clear(); | ||
704 | 65 | } | ||
705 | 66 | |||
706 | 67 | void DeviceOrientation::updateSensor(){ | ||
707 | 68 | QCompassReading *heading = _compass.reading(); | ||
708 | 69 | _azymuth = heading->azimuth(); | ||
709 | 70 | _accuracy = heading->calibrationLevel(); | ||
710 | 71 | _timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch(); | ||
711 | 72 | |||
712 | 73 | _validData = true; | ||
713 | 74 | reportResult(); | ||
714 | 75 | } | ||
715 | 0 | 76 | ||
716 | === added file 'build/src/plugins/org.apache.cordova.device-orientation/compass.h' | |||
717 | --- build/src/plugins/org.apache.cordova.device-orientation/compass.h 1970-01-01 00:00:00 +0000 | |||
718 | +++ build/src/plugins/org.apache.cordova.device-orientation/compass.h 2014-02-19 16:53:58 +0000 | |||
719 | @@ -0,0 +1,58 @@ | |||
720 | 1 | /* | ||
721 | 2 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
722 | 3 | * you may not use this file except in compliance with the License. | ||
723 | 4 | * You may obtain a copy of the License at | ||
724 | 5 | * | ||
725 | 6 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
726 | 7 | * | ||
727 | 8 | * Unless required by applicable law or agreed to in writing, software | ||
728 | 9 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
729 | 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
730 | 11 | * See the License for the specific language governing permissions and | ||
731 | 12 | * limitations under the License. | ||
732 | 13 | */ | ||
733 | 14 | |||
734 | 15 | #ifndef COMPASS_H_HKFSAHKDFAS | ||
735 | 16 | #define COMPASS_H_HKFSAHKDFAS | ||
736 | 17 | |||
737 | 18 | #include <cplugin.h> | ||
738 | 19 | #include <QCompass> | ||
739 | 20 | #include <QtCore> | ||
740 | 21 | |||
741 | 22 | class DeviceOrientation: public CPlugin { | ||
742 | 23 | Q_OBJECT | ||
743 | 24 | public: | ||
744 | 25 | explicit DeviceOrientation(Cordova *cordova); | ||
745 | 26 | |||
746 | 27 | virtual const QString fullName() override { | ||
747 | 28 | return DeviceOrientation::fullID(); | ||
748 | 29 | } | ||
749 | 30 | |||
750 | 31 | virtual const QString shortName() override { | ||
751 | 32 | return "Compass"; | ||
752 | 33 | } | ||
753 | 34 | |||
754 | 35 | static const QString fullID() { | ||
755 | 36 | return "Compass"; | ||
756 | 37 | } | ||
757 | 38 | |||
758 | 39 | public slots: | ||
759 | 40 | void getHeading(int scId, int ecId, QVariantMap options); | ||
760 | 41 | |||
761 | 42 | protected slots: | ||
762 | 43 | void updateSensor(); | ||
763 | 44 | void sensorError(int error); | ||
764 | 45 | |||
765 | 46 | private: | ||
766 | 47 | void reportResult(); | ||
767 | 48 | QCompass _compass; | ||
768 | 49 | QList<int> _successCallbacks; | ||
769 | 50 | QList<int> _errorCallbacks; | ||
770 | 51 | |||
771 | 52 | double _azymuth; | ||
772 | 53 | double _accuracy; | ||
773 | 54 | qtimestamp _timestamp; | ||
774 | 55 | bool _validData; | ||
775 | 56 | }; | ||
776 | 57 | |||
777 | 58 | #endif | ||
778 | 0 | 59 | ||
779 | === added file 'build/src/plugins/org.apache.cordova.device/device.cpp' | |||
780 | --- build/src/plugins/org.apache.cordova.device/device.cpp 1970-01-01 00:00:00 +0000 | |||
781 | +++ build/src/plugins/org.apache.cordova.device/device.cpp 2014-02-19 16:53:58 +0000 | |||
782 | @@ -0,0 +1,64 @@ | |||
783 | 1 | /* | ||
784 | 2 | * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ | ||
785 | 3 | * | ||
786 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
787 | 5 | * you may not use this file except in compliance with the License. | ||
788 | 6 | * You may obtain a copy of the License at | ||
789 | 7 | * | ||
790 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
791 | 9 | * | ||
792 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
793 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
794 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
795 | 13 | * See the License for the specific language governing permissions and | ||
796 | 14 | * limitations under the License. | ||
797 | 15 | */ | ||
798 | 16 | |||
799 | 17 | #include <QDeviceInfo> | ||
800 | 18 | #include <QtSystemInfo> | ||
801 | 19 | |||
802 | 20 | #include"device.h" | ||
803 | 21 | |||
804 | 22 | #define CORDOVA "3.0.0" | ||
805 | 23 | |||
806 | 24 | Device::Device(Cordova *cordova) : CPlugin(cordova) { | ||
807 | 25 | } | ||
808 | 26 | |||
809 | 27 | static QString getOSName() { | ||
810 | 28 | #ifdef Q_OS_SYMBIAN | ||
811 | 29 | QString platform = "Symbian"; | ||
812 | 30 | #endif | ||
813 | 31 | #ifdef Q_OS_WIN | ||
814 | 32 | QString platform = "Windows"; | ||
815 | 33 | #endif | ||
816 | 34 | #ifdef Q_OS_WINCE | ||
817 | 35 | QString platform = "Windows CE"; | ||
818 | 36 | #endif | ||
819 | 37 | #ifdef Q_OS_LINUX | ||
820 | 38 | QString platform = "Linux"; | ||
821 | 39 | #endif | ||
822 | 40 | return platform; | ||
823 | 41 | } | ||
824 | 42 | |||
825 | 43 | void Device::getInfo(int scId, int ecId) { | ||
826 | 44 | Q_UNUSED(ecId) | ||
827 | 45 | |||
828 | 46 | QDeviceInfo systemDeviceInfo; | ||
829 | 47 | QDeviceInfo systemInfo; | ||
830 | 48 | |||
831 | 49 | QString platform = getOSName(); | ||
832 | 50 | |||
833 | 51 | QString uuid = systemDeviceInfo.uniqueDeviceID(); | ||
834 | 52 | if (uuid.isEmpty()) { | ||
835 | 53 | QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform; | ||
836 | 54 | QString user = qgetenv("USER"); | ||
837 | 55 | if (user.isEmpty()) { | ||
838 | 56 | user = qgetenv("USERNAME"); | ||
839 | 57 | if (user.isEmpty()) | ||
840 | 58 | user = QDir::homePath(); | ||
841 | 59 | } | ||
842 | 60 | uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex()); | ||
843 | 61 | } | ||
844 | 62 | |||
845 | 63 | this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os)); | ||
846 | 64 | } | ||
847 | 0 | 65 | ||
848 | === added file 'build/src/plugins/org.apache.cordova.device/device.h' | |||
849 | --- build/src/plugins/org.apache.cordova.device/device.h 1970-01-01 00:00:00 +0000 | |||
850 | +++ build/src/plugins/org.apache.cordova.device/device.h 2014-02-19 16:53:58 +0000 | |||
851 | @@ -0,0 +1,47 @@ | |||
852 | 1 | /* | ||
853 | 2 | * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ | ||
854 | 3 | * | ||
855 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
856 | 5 | * you may not use this file except in compliance with the License. | ||
857 | 6 | * You may obtain a copy of the License at | ||
858 | 7 | * | ||
859 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
860 | 9 | * | ||
861 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
862 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
863 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
864 | 13 | * See the License for the specific language governing permissions and | ||
865 | 14 | * limitations under the License. | ||
866 | 15 | */ | ||
867 | 16 | |||
868 | 17 | #ifndef DEVICE_H_FDSAFAS | ||
869 | 18 | #define DEVICE_H_FDSAFAS | ||
870 | 19 | |||
871 | 20 | #include <QtCore> | ||
872 | 21 | |||
873 | 22 | #include <cplugin.h> | ||
874 | 23 | |||
875 | 24 | class Device: public CPlugin { | ||
876 | 25 | Q_OBJECT | ||
877 | 26 | public: | ||
878 | 27 | explicit Device(Cordova *cordova); | ||
879 | 28 | |||
880 | 29 | virtual const QString fullName() override { | ||
881 | 30 | return Device::fullID(); | ||
882 | 31 | } | ||
883 | 32 | |||
884 | 33 | virtual const QString shortName() override { | ||
885 | 34 | return "Device"; | ||
886 | 35 | } | ||
887 | 36 | |||
888 | 37 | static const QString fullID() { | ||
889 | 38 | return "com.cordova.Device"; | ||
890 | 39 | } | ||
891 | 40 | |||
892 | 41 | signals: | ||
893 | 42 | |||
894 | 43 | public slots: | ||
895 | 44 | void getInfo(int scId, int ecId); | ||
896 | 45 | }; | ||
897 | 46 | |||
898 | 47 | #endif | ||
899 | 0 | 48 | ||
900 | === added directory 'build/src/plugins/org.apache.cordova.dialogs' | |||
901 | === added file 'build/src/plugins/org.apache.cordova.dialogs/notification.cpp' | |||
902 | --- build/src/plugins/org.apache.cordova.dialogs/notification.cpp 1970-01-01 00:00:00 +0000 | |||
903 | +++ build/src/plugins/org.apache.cordova.dialogs/notification.cpp 2014-02-19 16:53:58 +0000 | |||
904 | @@ -0,0 +1,81 @@ | |||
905 | 1 | /* | ||
906 | 2 | * | ||
907 | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
908 | 4 | * you may not use this file except in compliance with the License. | ||
909 | 5 | * You may obtain a copy of the License at | ||
910 | 6 | * | ||
911 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
912 | 8 | * | ||
913 | 9 | * Unless required by applicable law or agreed to in writing, software | ||
914 | 10 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
915 | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
916 | 12 | * See the License for the specific language governing permissions and | ||
917 | 13 | * limitations under the License. | ||
918 | 14 | */ | ||
919 | 15 | |||
920 | 16 | #include "notification.h" | ||
921 | 17 | |||
922 | 18 | #include <QApplication> | ||
923 | 19 | |||
924 | 20 | #include <QMediaPlayer> | ||
925 | 21 | #include <QMessageBox> | ||
926 | 22 | |||
927 | 23 | void Dialogs::beep(int scId, int ecId, int times) { | ||
928 | 24 | Q_UNUSED(scId) | ||
929 | 25 | Q_UNUSED(ecId) | ||
930 | 26 | Q_UNUSED(times) | ||
931 | 27 | QMediaPlayer* player = new QMediaPlayer; | ||
932 | 28 | player->setVolume(100); | ||
933 | 29 | player->setMedia(QUrl::fromLocalFile("/usr/share/sounds/ubuntu/stereo/bell.ogg")); | ||
934 | 30 | player->play(); | ||
935 | 31 | } | ||
936 | 32 | |||
937 | 33 | void Dialogs::alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel) { | ||
938 | 34 | QStringList list; | ||
939 | 35 | list.append(buttonLabel); | ||
940 | 36 | |||
941 | 37 | confirm(scId, ecId, message, title, list); | ||
942 | 38 | } | ||
943 | 39 | |||
944 | 40 | void Dialogs::confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels) { | ||
945 | 41 | Q_UNUSED(ecId); | ||
946 | 42 | |||
947 | 43 | //FIXME: | ||
948 | 44 | assert(!_alertCallback); | ||
949 | 45 | _alertCallback = scId; | ||
950 | 46 | |||
951 | 47 | QString s1, s2, s3; | ||
952 | 48 | if (buttonLabels.size() > 0) | ||
953 | 49 | s1 = buttonLabels[0]; | ||
954 | 50 | if (buttonLabels.size() > 1) | ||
955 | 51 | s2 = buttonLabels[1]; | ||
956 | 52 | if (buttonLabels.size() > 2) | ||
957 | 53 | s3 = buttonLabels[2]; | ||
958 | 54 | |||
959 | 55 | QString path = m_cordova->get_app_dir() + "/../qml/notification.qml"; | ||
960 | 56 | //FIXME: | ||
961 | 57 | QString qml = QString("PopupUtils.open(\"%1\", root, { root: root, cordova: cordova, title: \"%2\", text: \"%3\", promptVisible: false, button1Text: \"%4\", button2Text: \"%5\", button3Text: \"%6\" })") | ||
962 | 58 | .arg(path).arg(title).arg(message).arg(s1).arg(s2).arg(s3); | ||
963 | 59 | m_cordova->execQML(qml); | ||
964 | 60 | } | ||
965 | 61 | |||
966 | 62 | void Dialogs::prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText) { | ||
967 | 63 | Q_UNUSED(ecId) | ||
968 | 64 | |||
969 | 65 | assert(!_alertCallback); | ||
970 | 66 | _alertCallback = scId; | ||
971 | 67 | |||
972 | 68 | QString s1, s2, s3; | ||
973 | 69 | if (buttonLabels.size() > 0) | ||
974 | 70 | s1 = buttonLabels[0]; | ||
975 | 71 | if (buttonLabels.size() > 1) | ||
976 | 72 | s2 = buttonLabels[1]; | ||
977 | 73 | if (buttonLabels.size() > 2) | ||
978 | 74 | s3 = buttonLabels[2]; | ||
979 | 75 | QString path = m_cordova->get_app_dir() + "/../qml/notification.qml"; | ||
980 | 76 | QString qml = QString("PopupUtils.open(\"%1\", root, { root: root, cordova: cordova, title: \"%2\", text: \"%3\", promptVisible: true, defaultPromptText: \"%7\", button1Text: \"%4\", button2Text: \"%5\", button3Text: \"%6\" })") | ||
981 | 77 | .arg(path).arg(title).arg(message).arg(s1).arg(s2).arg(s3).arg(defaultText); | ||
982 | 78 | |||
983 | 79 | qDebug() << qml; | ||
984 | 80 | m_cordova->execQML(qml); | ||
985 | 81 | } | ||
986 | 0 | 82 | ||
987 | === added file 'build/src/plugins/org.apache.cordova.dialogs/notification.h' | |||
988 | --- build/src/plugins/org.apache.cordova.dialogs/notification.h 1970-01-01 00:00:00 +0000 | |||
989 | +++ build/src/plugins/org.apache.cordova.dialogs/notification.h 2014-02-19 16:53:58 +0000 | |||
990 | @@ -0,0 +1,63 @@ | |||
991 | 1 | /* | ||
992 | 2 | * | ||
993 | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
994 | 4 | * you may not use this file except in compliance with the License. | ||
995 | 5 | * You may obtain a copy of the License at | ||
996 | 6 | * | ||
997 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
998 | 8 | * | ||
999 | 9 | * Unless required by applicable law or agreed to in writing, software | ||
1000 | 10 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1001 | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1002 | 12 | * See the License for the specific language governing permissions and | ||
1003 | 13 | * limitations under the License. | ||
1004 | 14 | */ | ||
1005 | 15 | |||
1006 | 16 | #ifndef NOTIFICATION_H | ||
1007 | 17 | #define NOTIFICATION_H | ||
1008 | 18 | |||
1009 | 19 | #include <QtQuick> | ||
1010 | 20 | #include <cplugin.h> | ||
1011 | 21 | #include <cordova.h> | ||
1012 | 22 | |||
1013 | 23 | class Dialogs: public CPlugin { | ||
1014 | 24 | Q_OBJECT | ||
1015 | 25 | public: | ||
1016 | 26 | explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) { | ||
1017 | 27 | } | ||
1018 | 28 | |||
1019 | 29 | virtual const QString fullName() override { | ||
1020 | 30 | return Dialogs::fullID(); | ||
1021 | 31 | } | ||
1022 | 32 | |||
1023 | 33 | virtual const QString shortName() override { | ||
1024 | 34 | return "Notification"; | ||
1025 | 35 | } | ||
1026 | 36 | |||
1027 | 37 | static const QString fullID() { | ||
1028 | 38 | return "Notification"; | ||
1029 | 39 | } | ||
1030 | 40 | public slots: | ||
1031 | 41 | void beep(int scId, int ecId, int times); | ||
1032 | 42 | void alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel); | ||
1033 | 43 | void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels); | ||
1034 | 44 | void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText); | ||
1035 | 45 | |||
1036 | 46 | void notificationDialogButtonPressed(int buttonId, const QString &text) { | ||
1037 | 47 | if (text.size()) { | ||
1038 | 48 | QVariantMap res; | ||
1039 | 49 | res.insert("buttonIndex", buttonId); | ||
1040 | 50 | res.insert("input1", text); | ||
1041 | 51 | this->cb(_alertCallback, res); | ||
1042 | 52 | } else { | ||
1043 | 53 | this->cb(_alertCallback, buttonId); | ||
1044 | 54 | } | ||
1045 | 55 | _alertCallback = 0; | ||
1046 | 56 | } | ||
1047 | 57 | |||
1048 | 58 | private: | ||
1049 | 59 | QQmlComponent *_component; | ||
1050 | 60 | int _alertCallback; | ||
1051 | 61 | }; | ||
1052 | 62 | |||
1053 | 63 | #endif | ||
1054 | 0 | 64 | ||
1055 | === added directory 'build/src/plugins/org.apache.cordova.file' | |||
1056 | === added directory 'build/src/plugins/org.apache.cordova.file-transfer' | |||
1057 | === added file 'build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp' | |||
1058 | --- build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp 1970-01-01 00:00:00 +0000 | |||
1059 | +++ build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp 2014-02-19 16:53:58 +0000 | |||
1060 | @@ -0,0 +1,247 @@ | |||
1061 | 1 | /* | ||
1062 | 2 | * | ||
1063 | 3 | * Copyright 2013 Canonical Ltd. | ||
1064 | 4 | * | ||
1065 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1066 | 6 | * you may not use this file except in compliance with the License. | ||
1067 | 7 | * You may obtain a copy of the License at | ||
1068 | 8 | * | ||
1069 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1070 | 10 | * | ||
1071 | 11 | * Unless required by applicable law or agreed to in writing, | ||
1072 | 12 | * software distributed under the License is distributed on an | ||
1073 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
1074 | 14 | * KIND, either express or implied. See the License for the | ||
1075 | 15 | * specific language governing permissions and limitations | ||
1076 | 16 | * under the License. | ||
1077 | 17 | * | ||
1078 | 18 | */ | ||
1079 | 19 | |||
1080 | 20 | #include "file-transfer.h" | ||
1081 | 21 | #include <cassert> | ||
1082 | 22 | |||
1083 | 23 | void FileTransfer::download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &/*headers*/) { | ||
1084 | 24 | QSharedPointer<FileTransferRequest> request(new FileTransferRequest(_manager, scId, ecId, id, this)); | ||
1085 | 25 | |||
1086 | 26 | assert(_id2request.find(id) == _id2request.end()); | ||
1087 | 27 | |||
1088 | 28 | _id2request.insert(id, request); | ||
1089 | 29 | |||
1090 | 30 | request->connect(request.data(), &FileTransferRequest::done, [&]() { | ||
1091 | 31 | auto it = _id2request.find(id); | ||
1092 | 32 | while (it != _id2request.end() && it.key() == id) { | ||
1093 | 33 | if (it.value().data() == request.data()) { | ||
1094 | 34 | _id2request.erase(it); | ||
1095 | 35 | break; | ||
1096 | 36 | } | ||
1097 | 37 | it++; | ||
1098 | 38 | } | ||
1099 | 39 | }); | ||
1100 | 40 | request->download(url, target); | ||
1101 | 41 | } | ||
1102 | 42 | |||
1103 | 43 | void FileTransfer::upload(int scId, int ecId, const QString &filePath, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType, | ||
1104 | 44 | const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &httpMethod) { | ||
1105 | 45 | QSharedPointer<FileTransferRequest> request(new FileTransferRequest(_manager, scId, ecId, id, this)); | ||
1106 | 46 | |||
1107 | 47 | assert(_id2request.find(id) == _id2request.end()); | ||
1108 | 48 | |||
1109 | 49 | _id2request.insert(id, request); | ||
1110 | 50 | |||
1111 | 51 | request->connect(request.data(), &FileTransferRequest::done, [&]() { | ||
1112 | 52 | auto it = _id2request.find(id); | ||
1113 | 53 | while (it != _id2request.end() && it.key() == id) { | ||
1114 | 54 | if (it.value().data() == request.data()) { | ||
1115 | 55 | _id2request.erase(it); | ||
1116 | 56 | break; | ||
1117 | 57 | } | ||
1118 | 58 | it++; | ||
1119 | 59 | } | ||
1120 | 60 | }); | ||
1121 | 61 | request->upload(url, filePath, fileKey, fileName, mimeType, params, headers); | ||
1122 | 62 | } | ||
1123 | 63 | |||
1124 | 64 | void FileTransfer::abort(int scId, int ecId, int id) { | ||
1125 | 65 | Q_UNUSED(scId) | ||
1126 | 66 | Q_UNUSED(ecId) | ||
1127 | 67 | |||
1128 | 68 | auto it = _id2request.find(id); | ||
1129 | 69 | while (it != _id2request.end() && it.key() == id) { | ||
1130 | 70 | (*it)->abort(); | ||
1131 | 71 | it++; | ||
1132 | 72 | } | ||
1133 | 73 | } | ||
1134 | 74 | |||
1135 | 75 | void FileTransferRequest::download(const QString& uri, const QString &target) { | ||
1136 | 76 | QUrl url(uri); | ||
1137 | 77 | QNetworkRequest request; | ||
1138 | 78 | |||
1139 | 79 | if (!url.isValid()) { | ||
1140 | 80 | QVariantMap map; | ||
1141 | 81 | map.insert("code", INVALID_URL_ERR); | ||
1142 | 82 | map.insert("source", uri); | ||
1143 | 83 | map.insert("target", target); | ||
1144 | 84 | _plugin->cb(_ecId, map); | ||
1145 | 85 | emit done(); | ||
1146 | 86 | return; | ||
1147 | 87 | } | ||
1148 | 88 | |||
1149 | 89 | request.setUrl(url); | ||
1150 | 90 | if (url.password().size() || url.userName().size()) { | ||
1151 | 91 | QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64(); | ||
1152 | 92 | request.setRawHeader("Authorization", headerData.toLocal8Bit()); | ||
1153 | 93 | } | ||
1154 | 94 | _reply = QSharedPointer<QNetworkReply>(_manager.get(request)); | ||
1155 | 95 | |||
1156 | 96 | _reply->connect(_reply.data(), &QNetworkReply::finished, [this, target, uri]() { | ||
1157 | 97 | if (!_scId || _reply->error() != QNetworkReply::NoError) | ||
1158 | 98 | return; | ||
1159 | 99 | |||
1160 | 100 | QFile res(target); | ||
1161 | 101 | qCritical() << target; | ||
1162 | 102 | if (target[0] != '/' || !res.open(QIODevice::WriteOnly)) { | ||
1163 | 103 | QVariantMap map; | ||
1164 | 104 | map.insert("code", INVALID_URL_ERR); | ||
1165 | 105 | map.insert("source", uri); | ||
1166 | 106 | map.insert("target", target); | ||
1167 | 107 | _plugin->cb(_ecId, map); | ||
1168 | 108 | emit done(); | ||
1169 | 109 | return; | ||
1170 | 110 | } | ||
1171 | 111 | res.write(_reply->readAll()); | ||
1172 | 112 | |||
1173 | 113 | QFileInfo info(target); | ||
1174 | 114 | QVariantMap map; | ||
1175 | 115 | map.insert("isFile", true); | ||
1176 | 116 | map.insert("isDirectory", false); | ||
1177 | 117 | map.insert("name", info.fileName()); | ||
1178 | 118 | map.insert("fullPath", info.absoluteFilePath()); | ||
1179 | 119 | |||
1180 | 120 | _plugin->cb(_scId, map); | ||
1181 | 121 | |||
1182 | 122 | emit done(); | ||
1183 | 123 | }); | ||
1184 | 124 | _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); | ||
1185 | 125 | _reply->connect(_reply.data(), SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); | ||
1186 | 126 | } | ||
1187 | 127 | |||
1188 | 128 | void FileTransferRequest::upload(const QString& _url, const QString& filePath, QString fileKey, QString fileName, QString mimeType, const QVariantMap ¶ms, const QVariantMap &headers) { | ||
1189 | 129 | QUrl url(_url); | ||
1190 | 130 | QNetworkRequest request; | ||
1191 | 131 | |||
1192 | 132 | if (!url.isValid()) { | ||
1193 | 133 | QVariantMap map; | ||
1194 | 134 | map.insert("code", INVALID_URL_ERR); | ||
1195 | 135 | map.insert("source", filePath); | ||
1196 | 136 | map.insert("target", _url); | ||
1197 | 137 | _plugin->cb(_ecId, map); | ||
1198 | 138 | emit done(); | ||
1199 | 139 | return; | ||
1200 | 140 | } | ||
1201 | 141 | |||
1202 | 142 | QFile file(filePath); | ||
1203 | 143 | if (filePath[0] != '/' || !file.open(QIODevice::ReadOnly)) { | ||
1204 | 144 | QVariantMap map; | ||
1205 | 145 | map.insert("code", FILE_NOT_FOUND_ERR); | ||
1206 | 146 | map.insert("source", filePath); | ||
1207 | 147 | map.insert("target", _url); | ||
1208 | 148 | _plugin->cb(_ecId, map); | ||
1209 | 149 | emit done(); | ||
1210 | 150 | return; | ||
1211 | 151 | } | ||
1212 | 152 | QString content{file.readAll()}; | ||
1213 | 153 | |||
1214 | 154 | request.setUrl(url); | ||
1215 | 155 | if (url.password().size() || url.userName().size()) { | ||
1216 | 156 | QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64(); | ||
1217 | 157 | request.setRawHeader("Authorization", headerData.toLocal8Bit()); | ||
1218 | 158 | } | ||
1219 | 159 | |||
1220 | 160 | for (const QString &key: headers.keys()) { | ||
1221 | 161 | const QString &value = headers.find(key)->toString(); | ||
1222 | 162 | request.setRawHeader(key.toUtf8(), value.toUtf8()); | ||
1223 | 163 | } | ||
1224 | 164 | |||
1225 | 165 | QString boundary = QString("CORDOVA-QT-%1A").arg(qrand()); | ||
1226 | 166 | while (content.contains(boundary)) { | ||
1227 | 167 | boundary += QString("B%1A").arg(qrand()); | ||
1228 | 168 | } | ||
1229 | 169 | |||
1230 | 170 | request.setHeader(QNetworkRequest::ContentTypeHeader, QString("multipart/form-data; boundary=") + boundary); | ||
1231 | 171 | |||
1232 | 172 | fileKey.replace("\"", ""); | ||
1233 | 173 | fileName.replace("\"", ""); | ||
1234 | 174 | mimeType.replace("\"", ""); | ||
1235 | 175 | QString part = "--" + boundary + "\r\n"; | ||
1236 | 176 | |||
1237 | 177 | part += "Content-Disposition: form-data; name=\"" + fileKey +"\"; filename=\"" + fileName + "\"\r\n"; | ||
1238 | 178 | part += "Content-Type: " + mimeType + "\r\n\r\n"; | ||
1239 | 179 | part += content + "\r\n"; | ||
1240 | 180 | |||
1241 | 181 | for (QString key: params.keys()) { | ||
1242 | 182 | part += "--" + boundary + "\r\n"; | ||
1243 | 183 | part += "Content-Disposition: form-data; name=\"" + key + "\";\r\n\r\n"; | ||
1244 | 184 | part += params.find(key)->toString(); | ||
1245 | 185 | part += "\r\n"; | ||
1246 | 186 | } | ||
1247 | 187 | |||
1248 | 188 | part += QString("--") + boundary + "--" + "\r\n"; | ||
1249 | 189 | |||
1250 | 190 | _reply = QSharedPointer<QNetworkReply>(_manager.post(request, QByteArray(part.toUtf8()))); | ||
1251 | 191 | |||
1252 | 192 | _reply->connect(_reply.data(), &QNetworkReply::finished, [this, content]() { | ||
1253 | 193 | if (_reply->error() != QNetworkReply::NoError) | ||
1254 | 194 | return; | ||
1255 | 195 | int status = 200; | ||
1256 | 196 | QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); | ||
1257 | 197 | |||
1258 | 198 | if (statusCode.isValid()) { | ||
1259 | 199 | status = statusCode.toInt(); | ||
1260 | 200 | } | ||
1261 | 201 | |||
1262 | 202 | QVariantMap map; | ||
1263 | 203 | map.insert("responseCode", status); | ||
1264 | 204 | map.insert("response", QString(_reply->readAll())); | ||
1265 | 205 | map.insert("bytesSent", content.size()); | ||
1266 | 206 | _plugin->cb(_scId, map); | ||
1267 | 207 | emit done(); | ||
1268 | 208 | }); | ||
1269 | 209 | _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); | ||
1270 | 210 | _reply->connect(_reply.data(), SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); | ||
1271 | 211 | } | ||
1272 | 212 | |||
1273 | 213 | void FileTransferRequest::abort() { | ||
1274 | 214 | QVariantMap map; | ||
1275 | 215 | map.insert("code", ABORT_ERR); | ||
1276 | 216 | _plugin->cb(_ecId, map); | ||
1277 | 217 | _scId = 0; | ||
1278 | 218 | emit done(); | ||
1279 | 219 | } | ||
1280 | 220 | |||
1281 | 221 | void FileTransferRequest::error(QNetworkReply::NetworkError code) { | ||
1282 | 222 | Q_UNUSED(code); | ||
1283 | 223 | |||
1284 | 224 | int status = 404; | ||
1285 | 225 | QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); | ||
1286 | 226 | |||
1287 | 227 | if (statusCode.isValid()) { | ||
1288 | 228 | status = statusCode.toInt(); | ||
1289 | 229 | } | ||
1290 | 230 | |||
1291 | 231 | QVariantMap map; | ||
1292 | 232 | map.insert("http_status", status); | ||
1293 | 233 | map.insert("body", QString(_reply->readAll())); | ||
1294 | 234 | map.insert("code", CONNECTION_ERR); | ||
1295 | 235 | _plugin->cb(_ecId, map); | ||
1296 | 236 | emit done(); | ||
1297 | 237 | } | ||
1298 | 238 | |||
1299 | 239 | void FileTransferRequest::progress(qint64 bytesReceived, qint64 bytesTotal) { | ||
1300 | 240 | QVariantMap map; | ||
1301 | 241 | map.insert("lengthComputable", true); | ||
1302 | 242 | map.insert("total", bytesTotal); | ||
1303 | 243 | map.insert("loaded", bytesReceived); | ||
1304 | 244 | |||
1305 | 245 | if (bytesReceived && bytesTotal && _scId) | ||
1306 | 246 | _plugin->callbackWithoutRemove(_scId, CordovaInternal::format(map)); | ||
1307 | 247 | } | ||
1308 | 0 | 248 | ||
1309 | === added file 'build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h' | |||
1310 | --- build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h 1970-01-01 00:00:00 +0000 | |||
1311 | +++ build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h 2014-02-19 16:53:58 +0000 | |||
1312 | @@ -0,0 +1,97 @@ | |||
1313 | 1 | /* | ||
1314 | 2 | * | ||
1315 | 3 | * Copyright 2013 Canonical Ltd. | ||
1316 | 4 | * | ||
1317 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1318 | 6 | * you may not use this file except in compliance with the License. | ||
1319 | 7 | * You may obtain a copy of the License at | ||
1320 | 8 | * | ||
1321 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1322 | 10 | * | ||
1323 | 11 | * Unless required by applicable law or agreed to in writing, | ||
1324 | 12 | * software distributed under the License is distributed on an | ||
1325 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
1326 | 14 | * KIND, either express or implied. See the License for the | ||
1327 | 15 | * specific language governing permissions and limitations | ||
1328 | 16 | * under the License. | ||
1329 | 17 | * | ||
1330 | 18 | */ | ||
1331 | 19 | |||
1332 | 20 | #ifndef FILE_TRANSFER_H_SDASDASDAS | ||
1333 | 21 | #define FILE_TRANSFER_H_SDASDASDAS | ||
1334 | 22 | |||
1335 | 23 | #include <QtCore> | ||
1336 | 24 | #include <QtNetwork> | ||
1337 | 25 | |||
1338 | 26 | #include <cplugin.h> | ||
1339 | 27 | |||
1340 | 28 | class FileTransferRequest: public QObject { | ||
1341 | 29 | Q_OBJECT | ||
1342 | 30 | |||
1343 | 31 | QNetworkAccessManager &_manager; | ||
1344 | 32 | int _scId, _ecId; | ||
1345 | 33 | int _id; | ||
1346 | 34 | QSharedPointer<QNetworkReply> _reply; | ||
1347 | 35 | |||
1348 | 36 | enum FileTransferError { | ||
1349 | 37 | FILE_NOT_FOUND_ERR = 1, | ||
1350 | 38 | INVALID_URL_ERR = 2, | ||
1351 | 39 | CONNECTION_ERR = 3, | ||
1352 | 40 | ABORT_ERR = 4 | ||
1353 | 41 | }; | ||
1354 | 42 | |||
1355 | 43 | public: | ||
1356 | 44 | FileTransferRequest(QNetworkAccessManager &manager, int scId, int ecId, int id, CPlugin *plugin): | ||
1357 | 45 | _manager(manager), | ||
1358 | 46 | _scId(scId), | ||
1359 | 47 | _ecId(ecId), | ||
1360 | 48 | _id(id), | ||
1361 | 49 | _plugin(plugin) { | ||
1362 | 50 | } | ||
1363 | 51 | |||
1364 | 52 | void download(const QString& url, const QString &target); | ||
1365 | 53 | void upload(const QString& _url, const QString& filePath, QString fileKey, QString fileName, QString mimeType, const QVariantMap ¶ms, const QVariantMap &headers); | ||
1366 | 54 | void abort(); | ||
1367 | 55 | |||
1368 | 56 | signals: | ||
1369 | 57 | void done(); | ||
1370 | 58 | |||
1371 | 59 | private slots: | ||
1372 | 60 | void progress(qint64 bytesReceived, qint64 bytesTotal); | ||
1373 | 61 | void error(QNetworkReply::NetworkError code); | ||
1374 | 62 | private: | ||
1375 | 63 | CPlugin *_plugin; | ||
1376 | 64 | Q_DISABLE_COPY(FileTransferRequest); | ||
1377 | 65 | }; | ||
1378 | 66 | |||
1379 | 67 | class FileTransfer : public CPlugin { | ||
1380 | 68 | Q_OBJECT | ||
1381 | 69 | public: | ||
1382 | 70 | explicit FileTransfer(Cordova *cordova): CPlugin(cordova) { | ||
1383 | 71 | } | ||
1384 | 72 | |||
1385 | 73 | virtual const QString fullName() override { | ||
1386 | 74 | return FileTransfer::fullID(); | ||
1387 | 75 | } | ||
1388 | 76 | |||
1389 | 77 | virtual const QString shortName() override { | ||
1390 | 78 | return "FileTransfer"; | ||
1391 | 79 | } | ||
1392 | 80 | |||
1393 | 81 | static const QString fullID() { | ||
1394 | 82 | return "FileTransfer"; | ||
1395 | 83 | } | ||
1396 | 84 | |||
1397 | 85 | public slots: | ||
1398 | 86 | void abort(int scId, int ecId, int id); | ||
1399 | 87 | void download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &/*headers*/); | ||
1400 | 88 | void upload(int scId, int ecId, const QString &filePath, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType, | ||
1401 | 89 | const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &httpMethod); | ||
1402 | 90 | |||
1403 | 91 | private: | ||
1404 | 92 | QNetworkAccessManager _manager; | ||
1405 | 93 | QMultiMap<int, QSharedPointer<FileTransferRequest> > _id2request; | ||
1406 | 94 | int lastRequestId; | ||
1407 | 95 | }; | ||
1408 | 96 | |||
1409 | 97 | #endif | ||
1410 | 0 | 98 | ||
1411 | === added file 'build/src/plugins/org.apache.cordova.file/file.cpp' | |||
1412 | --- build/src/plugins/org.apache.cordova.file/file.cpp 1970-01-01 00:00:00 +0000 | |||
1413 | +++ build/src/plugins/org.apache.cordova.file/file.cpp 2014-02-19 16:53:58 +0000 | |||
1414 | @@ -0,0 +1,773 @@ | |||
1415 | 1 | /* | ||
1416 | 2 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1417 | 3 | * you may not use this file except in compliance with the License. | ||
1418 | 4 | * You may obtain a copy of the License at | ||
1419 | 5 | * | ||
1420 | 6 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1421 | 7 | * | ||
1422 | 8 | * Unless required by applicable law or agreed to in writing, software | ||
1423 | 9 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1424 | 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1425 | 11 | * See the License for the specific language governing permissions and | ||
1426 | 12 | * limitations under the License. | ||
1427 | 13 | */ | ||
1428 | 14 | |||
1429 | 15 | #include "file.h" | ||
1430 | 16 | |||
1431 | 17 | #include <QApplication> | ||
1432 | 18 | |||
1433 | 19 | namespace { | ||
1434 | 20 | class FileError { | ||
1435 | 21 | public: | ||
1436 | 22 | static const QString kEncodingErr; | ||
1437 | 23 | static const QString kTypeMismatchErr; | ||
1438 | 24 | static const QString kNotFoundErr; | ||
1439 | 25 | static const QString kSecurityErr; | ||
1440 | 26 | static const QString kAbortErr; | ||
1441 | 27 | static const QString kNotReadableErr; | ||
1442 | 28 | static const QString kNoModificationAllowedErr; | ||
1443 | 29 | static const QString kInvalidStateErr; | ||
1444 | 30 | static const QString kSyntaxErr; | ||
1445 | 31 | static const QString kInvalidModificationErr; | ||
1446 | 32 | static const QString kQuotaExceededErr; | ||
1447 | 33 | static const QString kPathExistsErr; | ||
1448 | 34 | }; | ||
1449 | 35 | |||
1450 | 36 | QVariantMap file2map(const QFileInfo &fileInfo) { | ||
1451 | 37 | QVariantMap res; | ||
1452 | 38 | |||
1453 | 39 | res.insert("name", fileInfo.fileName()); | ||
1454 | 40 | res.insert("fullPath", fileInfo.isDir() ? QDir::cleanPath(fileInfo.absoluteFilePath()) : fileInfo.absoluteFilePath()); | ||
1455 | 41 | res.insert("isDirectory", (int)fileInfo.isDir()); | ||
1456 | 42 | res.insert("isFile", (int)fileInfo.isFile()); | ||
1457 | 43 | |||
1458 | 44 | return res; | ||
1459 | 45 | } | ||
1460 | 46 | QVariantMap dir2map(const QDir &dir) { | ||
1461 | 47 | return file2map(QFileInfo(dir.absolutePath())); | ||
1462 | 48 | } | ||
1463 | 49 | }; | ||
1464 | 50 | |||
1465 | 51 | const QString FileError::kEncodingErr("FileError.ENCODING_ERR"); | ||
1466 | 52 | const QString FileError::kTypeMismatchErr("FileError.TYPE_MISMATCH_ERR"); | ||
1467 | 53 | const QString FileError::kNotFoundErr("FileError.NOT_FOUND_ERR"); | ||
1468 | 54 | const QString FileError::kSecurityErr("FileError.SECURITY_ERR"); | ||
1469 | 55 | const QString FileError::kAbortErr("FileError.ABORT_ERR"); | ||
1470 | 56 | const QString FileError::kNotReadableErr("FileError.NOT_READABLE_ERR"); | ||
1471 | 57 | const QString FileError::kNoModificationAllowedErr("FileError.NO_MODIFICATION_ALLOWED_ERR"); | ||
1472 | 58 | const QString FileError::kInvalidStateErr("FileError.INVALID_STATE_ERR"); | ||
1473 | 59 | const QString FileError::kSyntaxErr("FileError.SYNTAX_ERR"); | ||
1474 | 60 | const QString FileError::kInvalidModificationErr("FileError.INVALID_MODIFICATION_ERR"); | ||
1475 | 61 | const QString FileError::kQuotaExceededErr("FileError.QUOTA_EXCEEDED_ERR"); | ||
1476 | 62 | const QString FileError::kPathExistsErr("FileError.PATH_EXISTS_ERR"); | ||
1477 | 63 | |||
1478 | 64 | File::File(Cordova *cordova) : | ||
1479 | 65 | CPlugin(cordova), | ||
1480 | 66 | _persistentDir(QString("%1/.local/share/%2/persistent").arg(QDir::homePath()).arg(QCoreApplication::applicationName())) { | ||
1481 | 67 | QDir::root().mkpath(QDir(_persistentDir).absolutePath()); | ||
1482 | 68 | } | ||
1483 | 69 | |||
1484 | 70 | void File::requestFileSystem(int scId, int ecId, unsigned short type, unsigned long long size) { | ||
1485 | 71 | QDir dir; | ||
1486 | 72 | |||
1487 | 73 | //FIXEME,what is quota value | ||
1488 | 74 | if (size >= 10000){ | ||
1489 | 75 | this->callback(ecId, FileError::kQuotaExceededErr); | ||
1490 | 76 | return; | ||
1491 | 77 | } | ||
1492 | 78 | |||
1493 | 79 | if (type == 0) | ||
1494 | 80 | dir = QDir::temp(); | ||
1495 | 81 | else | ||
1496 | 82 | dir = QDir(_persistentDir); | ||
1497 | 83 | |||
1498 | 84 | if (type > 1) { | ||
1499 | 85 | this->callback(ecId, FileError::kSyntaxErr); | ||
1500 | 86 | return; | ||
1501 | 87 | } else { | ||
1502 | 88 | QVariantMap res; | ||
1503 | 89 | res.insert("root", dir2map(dir)); | ||
1504 | 90 | if (type == 0) | ||
1505 | 91 | res.insert("name", "temporary"); | ||
1506 | 92 | else | ||
1507 | 93 | res.insert("name", "persistent"); | ||
1508 | 94 | |||
1509 | 95 | this->cb(scId, res); | ||
1510 | 96 | } | ||
1511 | 97 | } | ||
1512 | 98 | |||
1513 | 99 | void File::resolveLocalFileSystemURI(int scId, int ecId, QString uri) { | ||
1514 | 100 | QUrl url = QUrl::fromUserInput(uri); | ||
1515 | 101 | |||
1516 | 102 | if (!url.isValid() || uri[0] == '/' || uri[0] == '.') { | ||
1517 | 103 | this->callback(ecId, FileError::kEncodingErr); | ||
1518 | 104 | return; | ||
1519 | 105 | } | ||
1520 | 106 | |||
1521 | 107 | if (url.scheme() != "file") { | ||
1522 | 108 | this->callback(ecId, FileError::kTypeMismatchErr); | ||
1523 | 109 | return; | ||
1524 | 110 | } | ||
1525 | 111 | |||
1526 | 112 | QFileInfo fileInfo(url.path()); | ||
1527 | 113 | |||
1528 | 114 | if (!fileInfo.exists()) { | ||
1529 | 115 | this->callback(ecId, FileError::kNotFoundErr); | ||
1530 | 116 | return; | ||
1531 | 117 | } | ||
1532 | 118 | |||
1533 | 119 | this->cb(scId, file2map(fileInfo)); | ||
1534 | 120 | } | ||
1535 | 121 | |||
1536 | 122 | void File::getFile(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options) { | ||
1537 | 123 | QString path(rpath); | ||
1538 | 124 | |||
1539 | 125 | if (rpath[0] != '/') { | ||
1540 | 126 | if (!parentPath.size() || !QFileInfo(parentPath).isDir()) | ||
1541 | 127 | path = _persistentDir + "/" + rpath; | ||
1542 | 128 | else | ||
1543 | 129 | path = parentPath + "/" + rpath; | ||
1544 | 130 | } | ||
1545 | 131 | |||
1546 | 132 | //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here. | ||
1547 | 133 | if (path.contains(":")){ | ||
1548 | 134 | this->callback(ecId, FileError::kEncodingErr); | ||
1549 | 135 | return; | ||
1550 | 136 | } | ||
1551 | 137 | |||
1552 | 138 | QUrl url = QUrl::fromUserInput(path); | ||
1553 | 139 | if (!url.isValid()) { | ||
1554 | 140 | this->callback(ecId, FileError::kEncodingErr); | ||
1555 | 141 | return; | ||
1556 | 142 | } | ||
1557 | 143 | |||
1558 | 144 | if (url.scheme() != "file") { | ||
1559 | 145 | this->callback(ecId, FileError::kTypeMismatchErr); | ||
1560 | 146 | return; | ||
1561 | 147 | } | ||
1562 | 148 | |||
1563 | 149 | bool create = options.value("create").toBool(); | ||
1564 | 150 | bool exclusive = options.value("exclusive").toBool(); | ||
1565 | 151 | QFile file(path); | ||
1566 | 152 | |||
1567 | 153 | // if create is false and the path represents a directory, return error | ||
1568 | 154 | QFileInfo fileInfo(url.path()); | ||
1569 | 155 | if ((!create) && fileInfo.isDir()) { | ||
1570 | 156 | this->callback(ecId, FileError::kTypeMismatchErr); | ||
1571 | 157 | return; | ||
1572 | 158 | } | ||
1573 | 159 | |||
1574 | 160 | // if file does exist, and create is true and exclusive is true, return error | ||
1575 | 161 | if (file.exists()) { | ||
1576 | 162 | if (create && exclusive) { | ||
1577 | 163 | this->callback(ecId, FileError::kPathExistsErr); | ||
1578 | 164 | return; | ||
1579 | 165 | } | ||
1580 | 166 | } | ||
1581 | 167 | else { | ||
1582 | 168 | // if file does not exist and create is false, return error | ||
1583 | 169 | if (!create) { | ||
1584 | 170 | this->callback(ecId, FileError::kNotFoundErr); | ||
1585 | 171 | return; | ||
1586 | 172 | } | ||
1587 | 173 | |||
1588 | 174 | file.open(QIODevice::WriteOnly); | ||
1589 | 175 | file.close(); | ||
1590 | 176 | |||
1591 | 177 | // Check if creation was successfull | ||
1592 | 178 | if (!file.exists()) { | ||
1593 | 179 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
1594 | 180 | return; | ||
1595 | 181 | } | ||
1596 | 182 | } | ||
1597 | 183 | |||
1598 | 184 | this->cb(scId, file2map(QFileInfo(file))); | ||
1599 | 185 | } | ||
1600 | 186 | |||
1601 | 187 | void File::getDirectory(int scId, int ecId, QString parentPath, QString rpath, QVariantMap options) { | ||
1602 | 188 | QString path(rpath); | ||
1603 | 189 | if (rpath[0] != '/') { | ||
1604 | 190 | path = parentPath + "/" + rpath; | ||
1605 | 191 | } | ||
1606 | 192 | |||
1607 | 193 | //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here. | ||
1608 | 194 | if (path.contains(":")){ | ||
1609 | 195 | this->callback(ecId, FileError::kEncodingErr); | ||
1610 | 196 | return; | ||
1611 | 197 | } | ||
1612 | 198 | |||
1613 | 199 | QUrl url = QUrl::fromUserInput(path); | ||
1614 | 200 | if (!url.isValid()) { | ||
1615 | 201 | this->callback(ecId, FileError::kEncodingErr); | ||
1616 | 202 | return; | ||
1617 | 203 | } | ||
1618 | 204 | |||
1619 | 205 | if (url.scheme() != "file") { | ||
1620 | 206 | this->callback(ecId, FileError::kTypeMismatchErr); | ||
1621 | 207 | return; | ||
1622 | 208 | } | ||
1623 | 209 | |||
1624 | 210 | bool create = options.value("create").toBool(); | ||
1625 | 211 | bool exclusive = options.value("exclusive").toBool(); | ||
1626 | 212 | QDir dir(path); | ||
1627 | 213 | |||
1628 | 214 | // if create is false and the path represents a file, return error | ||
1629 | 215 | QFileInfo fileInfo(url.path()); | ||
1630 | 216 | if ((!create) && fileInfo.isFile()) { | ||
1631 | 217 | this->callback(ecId, FileError::kTypeMismatchErr); | ||
1632 | 218 | return; | ||
1633 | 219 | } | ||
1634 | 220 | |||
1635 | 221 | // if directory does exist and create is true and exclusive is true, return error | ||
1636 | 222 | if (dir.exists()) { | ||
1637 | 223 | if (create && exclusive) { | ||
1638 | 224 | this->callback(ecId, FileError::kPathExistsErr); | ||
1639 | 225 | return; | ||
1640 | 226 | } | ||
1641 | 227 | } | ||
1642 | 228 | else { | ||
1643 | 229 | // if directory does not exist and create is false and directory does not exist, return error | ||
1644 | 230 | if (!create) { | ||
1645 | 231 | this->callback(ecId, FileError::kNotFoundErr); | ||
1646 | 232 | return; | ||
1647 | 233 | } | ||
1648 | 234 | |||
1649 | 235 | // if directory does not exist and create is false and directory does not exist, return error | ||
1650 | 236 | QString folderName = dir.dirName(); | ||
1651 | 237 | dir.cdUp(); | ||
1652 | 238 | dir.mkdir(folderName); | ||
1653 | 239 | dir.cd(folderName); | ||
1654 | 240 | |||
1655 | 241 | if (!dir.exists()) { | ||
1656 | 242 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
1657 | 243 | return; | ||
1658 | 244 | } | ||
1659 | 245 | } | ||
1660 | 246 | |||
1661 | 247 | QVariantMap res; | ||
1662 | 248 | res.insert("name", dir.dirName()); | ||
1663 | 249 | res.insert("fullPath", dir.absolutePath()); | ||
1664 | 250 | this->cb(scId, res); | ||
1665 | 251 | } | ||
1666 | 252 | |||
1667 | 253 | void File::removeRecursively(int scId, int ecId, QString path) { | ||
1668 | 254 | QDir dir(path); | ||
1669 | 255 | if (File::rmDir(dir)) | ||
1670 | 256 | this->cb(scId); | ||
1671 | 257 | else | ||
1672 | 258 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
1673 | 259 | } | ||
1674 | 260 | |||
1675 | 261 | void File::write(int scId, int ecId, const QString &path, const QString &_data, unsigned long long position, bool binary) { | ||
1676 | 262 | QFile file(path); | ||
1677 | 263 | |||
1678 | 264 | file.open(QIODevice::WriteOnly); | ||
1679 | 265 | file.close(); | ||
1680 | 266 | |||
1681 | 267 | if (!file.exists()) { | ||
1682 | 268 | this->callback(ecId, FileError::kNotFoundErr); | ||
1683 | 269 | return; | ||
1684 | 270 | } | ||
1685 | 271 | |||
1686 | 272 | QFileInfo fileInfo(file); | ||
1687 | 273 | if (!file.open(QIODevice::ReadWrite)) { | ||
1688 | 274 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
1689 | 275 | return; | ||
1690 | 276 | } | ||
1691 | 277 | |||
1692 | 278 | if (!binary) { | ||
1693 | 279 | QTextStream textStream(&file); | ||
1694 | 280 | textStream.setCodec("UTF-8"); | ||
1695 | 281 | textStream.setAutoDetectUnicode(true); | ||
1696 | 282 | |||
1697 | 283 | if (!textStream.seek(position)) { | ||
1698 | 284 | file.close(); | ||
1699 | 285 | fileInfo.refresh(); | ||
1700 | 286 | |||
1701 | 287 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
1702 | 288 | return; | ||
1703 | 289 | } | ||
1704 | 290 | |||
1705 | 291 | textStream << _data; | ||
1706 | 292 | textStream.flush(); | ||
1707 | 293 | } else { | ||
1708 | 294 | QByteArray data(_data.toUtf8()); | ||
1709 | 295 | if (!file.seek(position)) { | ||
1710 | 296 | file.close(); | ||
1711 | 297 | fileInfo.refresh(); | ||
1712 | 298 | |||
1713 | 299 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
1714 | 300 | return; | ||
1715 | 301 | } | ||
1716 | 302 | |||
1717 | 303 | file.write(data.data(), data.length()); | ||
1718 | 304 | } | ||
1719 | 305 | |||
1720 | 306 | file.flush(); | ||
1721 | 307 | file.close(); | ||
1722 | 308 | fileInfo.refresh(); | ||
1723 | 309 | |||
1724 | 310 | this->cb(scId, fileInfo.size() - position); | ||
1725 | 311 | } | ||
1726 | 312 | |||
1727 | 313 | void File::truncate(int scId, int ecId, const QString &path, unsigned long long size) { | ||
1728 | 314 | QFile file(path); | ||
1729 | 315 | |||
1730 | 316 | if (!file.exists()) { | ||
1731 | 317 | this->callback(ecId, FileError::kNotFoundErr); | ||
1732 | 318 | return; | ||
1733 | 319 | } | ||
1734 | 320 | |||
1735 | 321 | if (!file.resize(size)) { | ||
1736 | 322 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
1737 | 323 | return; | ||
1738 | 324 | } | ||
1739 | 325 | |||
1740 | 326 | this->cb(scId, size); | ||
1741 | 327 | } | ||
1742 | 328 | |||
1743 | 329 | void File::getParent(int scId, int ecId, QString path) { | ||
1744 | 330 | QDir dir(path); | ||
1745 | 331 | |||
1746 | 332 | //can't cdup more than app's root | ||
1747 | 333 | // Try to change into upper directory | ||
1748 | 334 | if (path != _persistentDir){ | ||
1749 | 335 | if (!dir.cdUp()) { | ||
1750 | 336 | this->callback(ecId, FileError::kNotFoundErr); | ||
1751 | 337 | return; | ||
1752 | 338 | } | ||
1753 | 339 | |||
1754 | 340 | } | ||
1755 | 341 | this->cb(scId, dir2map(dir)); | ||
1756 | 342 | } | ||
1757 | 343 | |||
1758 | 344 | void File::remove(int scId, int ecId, QString path) { | ||
1759 | 345 | QFileInfo fileInfo(path); | ||
1760 | 346 | if (!fileInfo.exists() || (path == _persistentDir)) { | ||
1761 | 347 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
1762 | 348 | return; | ||
1763 | 349 | } | ||
1764 | 350 | |||
1765 | 351 | if (fileInfo.isDir()) { | ||
1766 | 352 | QDir dir(path); | ||
1767 | 353 | if (dir.rmdir(dir.absolutePath())) { | ||
1768 | 354 | this->cb(scId); | ||
1769 | 355 | return; | ||
1770 | 356 | } | ||
1771 | 357 | } else { | ||
1772 | 358 | QFile file(path); | ||
1773 | 359 | if (file.remove()) { | ||
1774 | 360 | this->cb(scId); | ||
1775 | 361 | return; | ||
1776 | 362 | } | ||
1777 | 363 | } | ||
1778 | 364 | |||
1779 | 365 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
1780 | 366 | } | ||
1781 | 367 | |||
1782 | 368 | void File::getFileMetadata(int scId, int ecId, const QString &path) { | ||
1783 | 369 | QFileInfo fileInfo(path); | ||
1784 | 370 | |||
1785 | 371 | if (!fileInfo.exists()) { | ||
1786 | 372 | this->callback(ecId, FileError::kNotFoundErr); | ||
1787 | 373 | } else { | ||
1788 | 374 | QMimeType mime = _db.mimeTypeForFile(fileInfo.fileName()); | ||
1789 | 375 | |||
1790 | 376 | QString args = QString("{name: %1, fullPath: %2, type: %3, lastModifiedDate: new Date(%4), size: %5}") | ||
1791 | 377 | .arg(CordovaInternal::format(fileInfo.fileName())).arg(CordovaInternal::format(fileInfo.absoluteFilePath())) | ||
1792 | 378 | .arg(CordovaInternal::format(mime.name())).arg(fileInfo.lastModified().toMSecsSinceEpoch()) | ||
1793 | 379 | .arg(fileInfo.size()); | ||
1794 | 380 | |||
1795 | 381 | this->callback(scId, args); | ||
1796 | 382 | } | ||
1797 | 383 | } | ||
1798 | 384 | |||
1799 | 385 | void File::getMetadata(int scId, int ecId, const QString &path) { | ||
1800 | 386 | QFileInfo fileInfo(path); | ||
1801 | 387 | |||
1802 | 388 | if (!fileInfo.exists()) | ||
1803 | 389 | this->callback(ecId, FileError::kNotFoundErr); | ||
1804 | 390 | else | ||
1805 | 391 | this->cb(scId, fileInfo.lastModified().toMSecsSinceEpoch()); | ||
1806 | 392 | } | ||
1807 | 393 | |||
1808 | 394 | void File::readEntries(int scId, int ecId, QString path) { | ||
1809 | 395 | QDir dir(path); | ||
1810 | 396 | QString entriesList; | ||
1811 | 397 | |||
1812 | 398 | if (!dir.exists()) { | ||
1813 | 399 | this->callback(ecId, FileError::kNotFoundErr); | ||
1814 | 400 | return; | ||
1815 | 401 | } | ||
1816 | 402 | |||
1817 | 403 | for (const QFileInfo &fileInfo: dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { | ||
1818 | 404 | entriesList += CordovaInternal::format(file2map(fileInfo)) + ","; | ||
1819 | 405 | } | ||
1820 | 406 | |||
1821 | 407 | // Remove trailing comma | ||
1822 | 408 | if (entriesList.size() > 0) | ||
1823 | 409 | entriesList.remove(entriesList.size()-1, 1); | ||
1824 | 410 | entriesList = "new Array(" + entriesList + ")"; | ||
1825 | 411 | |||
1826 | 412 | this->callback(scId, entriesList); | ||
1827 | 413 | } | ||
1828 | 414 | |||
1829 | 415 | void File::readAsText(int scId, int ecId, const QString &path, const QString &encoding, int sliceStart, int sliceEnd) { | ||
1830 | 416 | QFile file(path); | ||
1831 | 417 | |||
1832 | 418 | if (!file.exists()) { | ||
1833 | 419 | this->callback(ecId, FileError::kNotFoundErr); | ||
1834 | 420 | return; | ||
1835 | 421 | } | ||
1836 | 422 | |||
1837 | 423 | if (!file.open(QIODevice::ReadOnly)) { | ||
1838 | 424 | this->callback(ecId, FileError::kNotReadableErr); | ||
1839 | 425 | return; | ||
1840 | 426 | } | ||
1841 | 427 | |||
1842 | 428 | QByteArray content = file.readAll(); | ||
1843 | 429 | |||
1844 | 430 | if (sliceEnd == -1) | ||
1845 | 431 | sliceEnd = content.size(); | ||
1846 | 432 | if (sliceEnd < 0) { | ||
1847 | 433 | sliceEnd++; | ||
1848 | 434 | sliceEnd = std::max(0, content.size() + sliceEnd); | ||
1849 | 435 | } | ||
1850 | 436 | if (sliceEnd > content.size()) | ||
1851 | 437 | sliceEnd = content.size(); | ||
1852 | 438 | |||
1853 | 439 | if (sliceStart < 0) | ||
1854 | 440 | sliceStart = std::max(0, content.size() + sliceStart); | ||
1855 | 441 | if (sliceStart > content.size()) | ||
1856 | 442 | sliceStart = content.size(); | ||
1857 | 443 | |||
1858 | 444 | if (sliceStart > sliceEnd) | ||
1859 | 445 | sliceEnd = sliceStart; | ||
1860 | 446 | |||
1861 | 447 | //FIXME: encoding | ||
1862 | 448 | content = content.mid(sliceStart, sliceEnd - sliceStart); | ||
1863 | 449 | |||
1864 | 450 | this->cb(scId, content); | ||
1865 | 451 | } | ||
1866 | 452 | |||
1867 | 453 | void File::readAsArrayBuffer(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd) { | ||
1868 | 454 | const QString str2array("\ | ||
1869 | 455 | (function strToArray(str) { \ | ||
1870 | 456 | var res = new Uint8Array(str.length); \ | ||
1871 | 457 | for (var i = 0; i < str.length; i++) { \ | ||
1872 | 458 | res[i] = str.charCodeAt(i); \ | ||
1873 | 459 | } \ | ||
1874 | 460 | return res; \ | ||
1875 | 461 | })(\"%1\")"); | ||
1876 | 462 | QFile file(path); | ||
1877 | 463 | |||
1878 | 464 | if (!file.exists()) { | ||
1879 | 465 | this->callback(ecId, FileError::kNotFoundErr); | ||
1880 | 466 | return; | ||
1881 | 467 | } | ||
1882 | 468 | |||
1883 | 469 | if (!file.open(QIODevice::ReadOnly)) { | ||
1884 | 470 | this->callback(ecId, FileError::kNotReadableErr); | ||
1885 | 471 | return; | ||
1886 | 472 | } | ||
1887 | 473 | QString res; | ||
1888 | 474 | QByteArray content = file.readAll(); | ||
1889 | 475 | |||
1890 | 476 | if (sliceEnd == -1) | ||
1891 | 477 | sliceEnd = content.size(); | ||
1892 | 478 | if (sliceEnd < 0) { | ||
1893 | 479 | sliceEnd++; | ||
1894 | 480 | sliceEnd = std::max(0, content.size() + sliceEnd); | ||
1895 | 481 | } | ||
1896 | 482 | if (sliceEnd > content.size()) | ||
1897 | 483 | sliceEnd = content.size(); | ||
1898 | 484 | |||
1899 | 485 | if (sliceStart < 0) | ||
1900 | 486 | sliceStart = std::max(0, content.size() + sliceStart); | ||
1901 | 487 | if (sliceStart > content.size()) | ||
1902 | 488 | sliceStart = content.size(); | ||
1903 | 489 | |||
1904 | 490 | if (sliceStart > sliceEnd) | ||
1905 | 491 | sliceEnd = sliceStart; | ||
1906 | 492 | |||
1907 | 493 | content = content.mid(sliceStart, sliceEnd - sliceStart); | ||
1908 | 494 | |||
1909 | 495 | res.reserve(content.length() * 6); | ||
1910 | 496 | for (uchar c: content) { | ||
1911 | 497 | res += "\\x"; | ||
1912 | 498 | res += QString::number(c, 16).rightJustified(2, '0').toUpper(); | ||
1913 | 499 | } | ||
1914 | 500 | |||
1915 | 501 | this->callback(scId, str2array.arg(res)); | ||
1916 | 502 | } | ||
1917 | 503 | |||
1918 | 504 | void File::readAsBinaryString(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd) { | ||
1919 | 505 | QFile file(path); | ||
1920 | 506 | |||
1921 | 507 | if (!file.exists()) { | ||
1922 | 508 | this->callback(ecId, FileError::kNotFoundErr); | ||
1923 | 509 | return; | ||
1924 | 510 | } | ||
1925 | 511 | |||
1926 | 512 | if (!file.open(QIODevice::ReadOnly)) { | ||
1927 | 513 | this->callback(ecId, FileError::kNotReadableErr); | ||
1928 | 514 | return; | ||
1929 | 515 | } | ||
1930 | 516 | QString res; | ||
1931 | 517 | QByteArray content = file.readAll(); | ||
1932 | 518 | |||
1933 | 519 | if (sliceEnd == -1) | ||
1934 | 520 | sliceEnd = content.size(); | ||
1935 | 521 | if (sliceEnd < 0) { | ||
1936 | 522 | sliceEnd++; | ||
1937 | 523 | sliceEnd = std::max(0, content.size() + sliceEnd); | ||
1938 | 524 | } | ||
1939 | 525 | if (sliceEnd > content.size()) | ||
1940 | 526 | sliceEnd = content.size(); | ||
1941 | 527 | |||
1942 | 528 | if (sliceStart < 0) | ||
1943 | 529 | sliceStart = std::max(0, content.size() + sliceStart); | ||
1944 | 530 | if (sliceStart > content.size()) | ||
1945 | 531 | sliceStart = content.size(); | ||
1946 | 532 | |||
1947 | 533 | if (sliceStart > sliceEnd) | ||
1948 | 534 | sliceEnd = sliceStart; | ||
1949 | 535 | |||
1950 | 536 | content = content.mid(sliceStart, sliceEnd - sliceStart); | ||
1951 | 537 | |||
1952 | 538 | res.reserve(content.length() * 6); | ||
1953 | 539 | for (uchar c: content) { | ||
1954 | 540 | res += "\\x"; | ||
1955 | 541 | res += QString::number(c, 16).rightJustified(2, '0').toUpper(); | ||
1956 | 542 | } | ||
1957 | 543 | this->callback(scId, "\"" + res + "\""); | ||
1958 | 544 | } | ||
1959 | 545 | |||
1960 | 546 | void File::readAsDataURL(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd) { | ||
1961 | 547 | QFile file(path); | ||
1962 | 548 | QFileInfo fileInfo(path); | ||
1963 | 549 | |||
1964 | 550 | if (path.startsWith("content:")){ | ||
1965 | 551 | this->callback(ecId, FileError::kNotReadableErr); | ||
1966 | 552 | return; | ||
1967 | 553 | } | ||
1968 | 554 | |||
1969 | 555 | if (!file.exists()) { | ||
1970 | 556 | this->callback(ecId, FileError::kNotReadableErr); | ||
1971 | 557 | return; | ||
1972 | 558 | } | ||
1973 | 559 | // Try to open file for reading | ||
1974 | 560 | if (!file.open(QIODevice::ReadOnly)) { | ||
1975 | 561 | this->callback(ecId, FileError::kNotReadableErr); | ||
1976 | 562 | return; | ||
1977 | 563 | } | ||
1978 | 564 | // Read the file content | ||
1979 | 565 | QByteArray content = file.readAll(); | ||
1980 | 566 | QString contentType(_db.mimeTypeForFile(fileInfo.fileName()).name()); | ||
1981 | 567 | |||
1982 | 568 | if (sliceEnd == -1) | ||
1983 | 569 | sliceEnd = content.size(); | ||
1984 | 570 | if (sliceEnd < 0) { | ||
1985 | 571 | sliceEnd++; | ||
1986 | 572 | sliceEnd = std::max(0, content.size() + sliceEnd); | ||
1987 | 573 | } | ||
1988 | 574 | if (sliceEnd > content.size()) | ||
1989 | 575 | sliceEnd = content.size(); | ||
1990 | 576 | |||
1991 | 577 | if (sliceStart < 0) | ||
1992 | 578 | sliceStart = std::max(0, content.size() + sliceStart); | ||
1993 | 579 | if (sliceStart > content.size()) | ||
1994 | 580 | sliceStart = content.size(); | ||
1995 | 581 | |||
1996 | 582 | if (sliceStart > sliceEnd) | ||
1997 | 583 | sliceEnd = sliceStart; | ||
1998 | 584 | |||
1999 | 585 | content = content.mid(sliceStart, sliceEnd - sliceStart); | ||
2000 | 586 | |||
2001 | 587 | this->cb(scId, QString("data:%1;base64,").arg(contentType) + content.toBase64()); | ||
2002 | 588 | } | ||
2003 | 589 | |||
2004 | 590 | bool File::rmDir(QDir dir) { | ||
2005 | 591 | if (dir == _persistentDir) {//can't remove root dir | ||
2006 | 592 | return false; | ||
2007 | 593 | } | ||
2008 | 594 | bool result = true; | ||
2009 | 595 | if (dir.exists()) { | ||
2010 | 596 | // Iterate over entries and remove them | ||
2011 | 597 | Q_FOREACH(const QFileInfo &fileInfo, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { | ||
2012 | 598 | if (fileInfo.isDir()) { | ||
2013 | 599 | result = rmDir(fileInfo.absoluteFilePath()); | ||
2014 | 600 | } | ||
2015 | 601 | else { | ||
2016 | 602 | result = QFile::remove(fileInfo.absoluteFilePath()); | ||
2017 | 603 | } | ||
2018 | 604 | |||
2019 | 605 | if (!result) { | ||
2020 | 606 | return result; | ||
2021 | 607 | } | ||
2022 | 608 | } | ||
2023 | 609 | |||
2024 | 610 | // Finally remove the current dir | ||
2025 | 611 | return dir.rmdir(dir.absolutePath()); | ||
2026 | 612 | } | ||
2027 | 613 | return result; | ||
2028 | 614 | } | ||
2029 | 615 | |||
2030 | 616 | bool File::copyFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName) { | ||
2031 | 617 | if (!QDir(destinationParentDir).exists()){ | ||
2032 | 618 | this->callback(ecId, FileError::kNotFoundErr); | ||
2033 | 619 | return false; | ||
2034 | 620 | } | ||
2035 | 621 | |||
2036 | 622 | QFileInfo fileInfo(sourceFile); | ||
2037 | 623 | QString fileName = ((newName.isEmpty()) ? fileInfo.fileName() : newName); | ||
2038 | 624 | QString destinationFile(destinationParentDir + "/" + fileName); | ||
2039 | 625 | |||
2040 | 626 | //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here. | ||
2041 | 627 | if (!QUrl::fromUserInput(destinationFile).isValid() || destinationFile.contains(":")){ | ||
2042 | 628 | this->callback(ecId, FileError::kEncodingErr); | ||
2043 | 629 | return false; | ||
2044 | 630 | } | ||
2045 | 631 | |||
2046 | 632 | if (QFile::copy(sourceFile, destinationFile)){ | ||
2047 | 633 | this->cb(scId, file2map(QFileInfo(destinationFile))); | ||
2048 | 634 | return true; | ||
2049 | 635 | } else { | ||
2050 | 636 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2051 | 637 | return false; | ||
2052 | 638 | } | ||
2053 | 639 | } | ||
2054 | 640 | |||
2055 | 641 | void File::copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destinationParentDir, const QString& newName) { | ||
2056 | 642 | QDir sourceDir(sourceFolder); | ||
2057 | 643 | QString dirName = ((newName.isEmpty()) ? sourceDir.dirName() : newName); | ||
2058 | 644 | QString destFolder(destinationParentDir + "/" + dirName); | ||
2059 | 645 | |||
2060 | 646 | if (QFileInfo(destFolder).isFile()){ | ||
2061 | 647 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2062 | 648 | return; | ||
2063 | 649 | } | ||
2064 | 650 | QDir destDir(destFolder); | ||
2065 | 651 | |||
2066 | 652 | if ((sourceFolder == destFolder) || (sourceFolder == destinationParentDir)){ | ||
2067 | 653 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2068 | 654 | return; | ||
2069 | 655 | } | ||
2070 | 656 | |||
2071 | 657 | if (!destDir.exists()){ | ||
2072 | 658 | destDir.mkdir(destFolder);; | ||
2073 | 659 | } else{ | ||
2074 | 660 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2075 | 661 | return; | ||
2076 | 662 | } | ||
2077 | 663 | |||
2078 | 664 | if (copyFolder(sourceFolder, destFolder)){ | ||
2079 | 665 | this->cb(scId, dir2map(destDir)); | ||
2080 | 666 | return; | ||
2081 | 667 | } else { | ||
2082 | 668 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2083 | 669 | return; | ||
2084 | 670 | } | ||
2085 | 671 | } | ||
2086 | 672 | |||
2087 | 673 | void File::copyTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName) { | ||
2088 | 674 | if (QFileInfo(source).isDir()) | ||
2089 | 675 | copyDir(scId, ecId, source, destinationDir, newName); | ||
2090 | 676 | else | ||
2091 | 677 | copyFile(scId, ecId, source, destinationDir, newName); | ||
2092 | 678 | } | ||
2093 | 679 | |||
2094 | 680 | void File::moveFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName) { | ||
2095 | 681 | QString fileName = ((newName.isEmpty()) ? QFileInfo(sourceFile).fileName() : newName); | ||
2096 | 682 | QString destinationFile(destinationParentDir + "/" + fileName); | ||
2097 | 683 | |||
2098 | 684 | if (QFileInfo(sourceFile) == QFileInfo(destinationFile)) { | ||
2099 | 685 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2100 | 686 | return; | ||
2101 | 687 | } | ||
2102 | 688 | |||
2103 | 689 | if (!QFileInfo(destinationParentDir).exists()) { | ||
2104 | 690 | this->callback(ecId, FileError::kNotFoundErr); | ||
2105 | 691 | return; | ||
2106 | 692 | } | ||
2107 | 693 | |||
2108 | 694 | if (QFileInfo(destinationFile).exists()) { | ||
2109 | 695 | if (!QFile::remove(QFileInfo(destinationFile).absoluteFilePath())) { | ||
2110 | 696 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2111 | 697 | return; | ||
2112 | 698 | } | ||
2113 | 699 | } | ||
2114 | 700 | |||
2115 | 701 | QFile::rename(sourceFile, destinationFile); | ||
2116 | 702 | this->cb(scId, file2map(QFileInfo(destinationFile))); | ||
2117 | 703 | } | ||
2118 | 704 | |||
2119 | 705 | void File::moveDir(int scId, int ecId,const QString& sourceDir, const QString& destinationParentDir, const QString& newName){ | ||
2120 | 706 | QString dirName = ((newName.isEmpty()) ? QDir(sourceDir).dirName() : newName); | ||
2121 | 707 | QString destFolder(destinationParentDir + "/" + dirName); | ||
2122 | 708 | QDir destDir(destFolder); | ||
2123 | 709 | |||
2124 | 710 | if (!QFileInfo(destinationParentDir).exists()){ | ||
2125 | 711 | this->callback(ecId, FileError::kNotFoundErr); | ||
2126 | 712 | return; | ||
2127 | 713 | } | ||
2128 | 714 | |||
2129 | 715 | if (QFileInfo(destFolder).isFile()){ | ||
2130 | 716 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2131 | 717 | return; | ||
2132 | 718 | } | ||
2133 | 719 | |||
2134 | 720 | if ((QFileInfo(sourceDir) == QFileInfo(destFolder)) || (QFileInfo(sourceDir) == QFileInfo(destinationParentDir))) { | ||
2135 | 721 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2136 | 722 | return; | ||
2137 | 723 | } | ||
2138 | 724 | |||
2139 | 725 | if (destDir.exists() && !QDir(destinationParentDir).rmdir(dirName)) { | ||
2140 | 726 | this->callback(ecId, FileError::kInvalidModificationErr); | ||
2141 | 727 | return; | ||
2142 | 728 | } | ||
2143 | 729 | |||
2144 | 730 | if (copyFolder(sourceDir, destFolder)) { | ||
2145 | 731 | rmDir(sourceDir); | ||
2146 | 732 | this->cb(scId, file2map(QFileInfo(destFolder))); | ||
2147 | 733 | } else { | ||
2148 | 734 | this->callback(ecId, FileError::kNoModificationAllowedErr); | ||
2149 | 735 | } | ||
2150 | 736 | } | ||
2151 | 737 | |||
2152 | 738 | void File::moveTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName) { | ||
2153 | 739 | if (newName.contains(":")) { | ||
2154 | 740 | this->callback(ecId, FileError::kEncodingErr); | ||
2155 | 741 | return; | ||
2156 | 742 | } | ||
2157 | 743 | if (QFileInfo(source).isDir()) | ||
2158 | 744 | moveDir(scId, ecId, source, destinationDir, newName); | ||
2159 | 745 | else | ||
2160 | 746 | moveFile(scId, ecId, source, destinationDir, newName); | ||
2161 | 747 | } | ||
2162 | 748 | |||
2163 | 749 | bool File::copyFolder(const QString& sourceFolder, const QString& destFolder) { | ||
2164 | 750 | QDir sourceDir(sourceFolder); | ||
2165 | 751 | if (!sourceDir.exists()) | ||
2166 | 752 | return false; | ||
2167 | 753 | QDir destDir(destFolder); | ||
2168 | 754 | if (!destDir.exists()){ | ||
2169 | 755 | destDir.mkdir(destFolder); | ||
2170 | 756 | } | ||
2171 | 757 | QStringList files = sourceDir.entryList(QDir::Files); | ||
2172 | 758 | for (int i = 0; i< files.count(); i++) | ||
2173 | 759 | { | ||
2174 | 760 | QString srcName = sourceFolder + "/" + files[i]; | ||
2175 | 761 | QString destName = destFolder + "/" + files[i]; | ||
2176 | 762 | QFile::copy(srcName, destName); | ||
2177 | 763 | } | ||
2178 | 764 | files.clear(); | ||
2179 | 765 | files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); | ||
2180 | 766 | for (int i = 0; i< files.count(); i++) | ||
2181 | 767 | { | ||
2182 | 768 | QString srcName = sourceFolder + "/" + files[i]; | ||
2183 | 769 | QString destName = destFolder + "/" + files[i]; | ||
2184 | 770 | copyFolder(srcName, destName); | ||
2185 | 771 | } | ||
2186 | 772 | return true; | ||
2187 | 773 | } | ||
2188 | 0 | 774 | ||
2189 | === added file 'build/src/plugins/org.apache.cordova.file/file.h' | |||
2190 | --- build/src/plugins/org.apache.cordova.file/file.h 1970-01-01 00:00:00 +0000 | |||
2191 | +++ build/src/plugins/org.apache.cordova.file/file.h 2014-02-19 16:53:58 +0000 | |||
2192 | @@ -0,0 +1,73 @@ | |||
2193 | 1 | /* | ||
2194 | 2 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2195 | 3 | * you may not use this file except in compliance with the License. | ||
2196 | 4 | * You may obtain a copy of the License at | ||
2197 | 5 | * | ||
2198 | 6 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2199 | 7 | * | ||
2200 | 8 | * Unless required by applicable law or agreed to in writing, software | ||
2201 | 9 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
2202 | 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
2203 | 11 | * See the License for the specific language governing permissions and | ||
2204 | 12 | * limitations under the License. | ||
2205 | 13 | */ | ||
2206 | 14 | |||
2207 | 15 | #ifndef FILEAPI_H_SDASDASDAS | ||
2208 | 16 | #define FILEAPI_H_SDASDASDAS | ||
2209 | 17 | |||
2210 | 18 | #include <QNetworkReply> | ||
2211 | 19 | #include <QtCore> | ||
2212 | 20 | |||
2213 | 21 | #include <cplugin.h> | ||
2214 | 22 | #include <cordova.h> | ||
2215 | 23 | |||
2216 | 24 | class File: public CPlugin { | ||
2217 | 25 | Q_OBJECT | ||
2218 | 26 | public: | ||
2219 | 27 | explicit File(Cordova *cordova); | ||
2220 | 28 | |||
2221 | 29 | virtual const QString fullName() override { | ||
2222 | 30 | return File::fullID(); | ||
2223 | 31 | } | ||
2224 | 32 | |||
2225 | 33 | virtual const QString shortName() override { | ||
2226 | 34 | return "File"; | ||
2227 | 35 | } | ||
2228 | 36 | |||
2229 | 37 | static const QString fullID() { | ||
2230 | 38 | return "File"; | ||
2231 | 39 | } | ||
2232 | 40 | |||
2233 | 41 | public slots: | ||
2234 | 42 | void requestFileSystem(int scId, int ecId, unsigned short type, unsigned long long size); | ||
2235 | 43 | void resolveLocalFileSystemURI(int scId, int ecId, QString uri); | ||
2236 | 44 | void getDirectory(int scId, int ecId, QString parentPath, QString path, QVariantMap options); | ||
2237 | 45 | void getFile(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options); | ||
2238 | 46 | void readEntries(int scId, int ecId, QString path); | ||
2239 | 47 | void getParent(int scId, int ecId, QString path); | ||
2240 | 48 | void copyTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName); | ||
2241 | 49 | void moveTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName); | ||
2242 | 50 | void getFileMetadata(int scId, int ecId, const QString &path); | ||
2243 | 51 | void getMetadata(int scId, int ecId, const QString &path); | ||
2244 | 52 | void remove(int scId, int ecId, QString path); | ||
2245 | 53 | void removeRecursively(int scId, int ecId, QString path); | ||
2246 | 54 | void readAsText(int scId, int ecId, const QString &path, const QString &encoding, int sliceStart, int sliceEnd); | ||
2247 | 55 | void write(int scId, int ecId, const QString &path, const QString &_data, unsigned long long position, bool binary); | ||
2248 | 56 | void readAsDataURL(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd); | ||
2249 | 57 | void readAsArrayBuffer(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd); | ||
2250 | 58 | void readAsBinaryString(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd); | ||
2251 | 59 | void truncate(int scId, int ecId, const QString &path, unsigned long long size); | ||
2252 | 60 | private: | ||
2253 | 61 | void moveFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName); | ||
2254 | 62 | void moveDir(int scId, int ecId,const QString& sourceFolder, const QString& destFolder, const QString& newName); | ||
2255 | 63 | bool copyFile(int scId, int ecId, const QString& sourceFile, const QString& destinationParentDir, const QString& newName); | ||
2256 | 64 | void copyDir(int scId, int ecId, const QString& sourceFolder, const QString& destFolder, const QString& newName); | ||
2257 | 65 | bool rmDir(QDir dir); | ||
2258 | 66 | bool copyFolder(const QString& sourceFolder, const QString& destFolder); | ||
2259 | 67 | |||
2260 | 68 | QMimeDatabase _db; | ||
2261 | 69 | const QString _persistentDir; | ||
2262 | 70 | QNetworkAccessManager _manager; | ||
2263 | 71 | }; | ||
2264 | 72 | |||
2265 | 73 | #endif | ||
2266 | 0 | 74 | ||
2267 | === added directory 'build/src/plugins/org.apache.cordova.geolocation' | |||
2268 | === added file 'build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp' | |||
2269 | --- build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp 1970-01-01 00:00:00 +0000 | |||
2270 | +++ build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp 2014-02-19 16:53:58 +0000 | |||
2271 | @@ -0,0 +1,119 @@ | |||
2272 | 1 | /* | ||
2273 | 2 | * | ||
2274 | 3 | * Copyright 2013 Canonical Ltd. | ||
2275 | 4 | * | ||
2276 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2277 | 6 | * you may not use this file except in compliance with the License. | ||
2278 | 7 | * You may obtain a copy of the License at | ||
2279 | 8 | * | ||
2280 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2281 | 10 | * | ||
2282 | 11 | * Unless required by applicable law or agreed to in writing, | ||
2283 | 12 | * software distributed under the License is distributed on an | ||
2284 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
2285 | 14 | * KIND, either express or implied. See the License for the | ||
2286 | 15 | * specific language governing permissions and limitations | ||
2287 | 16 | * under the License. | ||
2288 | 17 | * | ||
2289 | 18 | */ | ||
2290 | 19 | |||
2291 | 20 | #include <QUuid> | ||
2292 | 21 | |||
2293 | 22 | #include "geolocation.h" | ||
2294 | 23 | |||
2295 | 24 | Geolocation::Geolocation(Cordova *cordova): CPlugin(cordova), | ||
2296 | 25 | _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) { | ||
2297 | 26 | if (_geoPositionInfoSource.data() != 0) { | ||
2298 | 27 | QObject::connect(_geoPositionInfoSource.data(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); | ||
2299 | 28 | QObject::connect(_geoPositionInfoSource.data(), SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); | ||
2300 | 29 | } | ||
2301 | 30 | } | ||
2302 | 31 | |||
2303 | 32 | void Geolocation::addWatch(int scId, int ecId, const QString &id, bool enableHighAccuracy) { | ||
2304 | 33 | Q_UNUSED(enableHighAccuracy); | ||
2305 | 34 | |||
2306 | 35 | assert(_id2sc.find(id) == _id2sc.end()); | ||
2307 | 36 | |||
2308 | 37 | if (!_geoPositionInfoSource.data()) { | ||
2309 | 38 | QVariantMap err; | ||
2310 | 39 | err.insert("code", POSITION_UNAVAILABLE); | ||
2311 | 40 | err.insert("message", "unavailable"); | ||
2312 | 41 | |||
2313 | 42 | this->cb(ecId, err); | ||
2314 | 43 | return; | ||
2315 | 44 | } | ||
2316 | 45 | |||
2317 | 46 | _id2sc[id] = scId; | ||
2318 | 47 | _id2ec[id] = ecId; | ||
2319 | 48 | } | ||
2320 | 49 | |||
2321 | 50 | void Geolocation::clearWatch(int scId, int ecId, const QString &id) { | ||
2322 | 51 | _id2sc.remove(id); | ||
2323 | 52 | _id2ec.remove(id); | ||
2324 | 53 | } | ||
2325 | 54 | |||
2326 | 55 | void Geolocation::getLocation(int scId, int ecId, bool enableHighAccuracy, qint64 maximumAge) { | ||
2327 | 56 | Q_UNUSED(maximumAge); | ||
2328 | 57 | Q_UNUSED(enableHighAccuracy); | ||
2329 | 58 | |||
2330 | 59 | if (!_geoPositionInfoSource.data()) { | ||
2331 | 60 | QVariantMap err; | ||
2332 | 61 | err.insert("code", POSITION_UNAVAILABLE); | ||
2333 | 62 | err.insert("message", "unavailable"); | ||
2334 | 63 | |||
2335 | 64 | this->cb(ecId, err); | ||
2336 | 65 | return; | ||
2337 | 66 | } | ||
2338 | 67 | |||
2339 | 68 | _geoPositionInfoSource->requestUpdate(); | ||
2340 | 69 | |||
2341 | 70 | QString id = QString("_INTERNAL_") + QUuid::createUuid().toString(); | ||
2342 | 71 | |||
2343 | 72 | _id2sc[id] = scId; | ||
2344 | 73 | _id2ec[id] = ecId; | ||
2345 | 74 | _singleUpdate.insert(id); | ||
2346 | 75 | } | ||
2347 | 76 | |||
2348 | 77 | void Geolocation::positionUpdated(const QGeoPositionInfo &update) { | ||
2349 | 78 | QGeoCoordinate coordinate = update.coordinate(); | ||
2350 | 79 | |||
2351 | 80 | QVariantMap p; | ||
2352 | 81 | |||
2353 | 82 | p.insert("latitude", coordinate.latitude()); | ||
2354 | 83 | p.insert("longitude", coordinate.longitude()); | ||
2355 | 84 | p.insert("altitude", coordinate.altitude()); | ||
2356 | 85 | |||
2357 | 86 | if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) | ||
2358 | 87 | p.insert("accuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy)); | ||
2359 | 88 | if (update.hasAttribute(QGeoPositionInfo::Direction)) | ||
2360 | 89 | p.insert("heading", update.attribute(QGeoPositionInfo::Direction)); | ||
2361 | 90 | if (update.hasAttribute(QGeoPositionInfo::GroundSpeed)) | ||
2362 | 91 | p.insert("velocity", update.attribute(QGeoPositionInfo::GroundSpeed)); | ||
2363 | 92 | if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) | ||
2364 | 93 | p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy)); | ||
2365 | 94 | p.insert("timestamp", update.timestamp().toMSecsSinceEpoch()); | ||
2366 | 95 | |||
2367 | 96 | for (const QString &id: _id2sc.keys()) { | ||
2368 | 97 | int scId = _id2sc[id]; | ||
2369 | 98 | this->cb(scId, p); | ||
2370 | 99 | if (_singleUpdate.contains(id)) { | ||
2371 | 100 | _singleUpdate.remove(id); | ||
2372 | 101 | _id2sc.remove(id); | ||
2373 | 102 | _id2ec.remove(id); | ||
2374 | 103 | } | ||
2375 | 104 | } | ||
2376 | 105 | } | ||
2377 | 106 | |||
2378 | 107 | void Geolocation::updateTimeout() { | ||
2379 | 108 | QVariantMap err; | ||
2380 | 109 | err.insert("code", TIMEOUT); | ||
2381 | 110 | err.insert("message", "timeout"); | ||
2382 | 111 | |||
2383 | 112 | for (int ecId: _id2ec) { | ||
2384 | 113 | this->cb(ecId, err); | ||
2385 | 114 | } | ||
2386 | 115 | |||
2387 | 116 | _id2ec.clear(); | ||
2388 | 117 | _id2sc.clear(); | ||
2389 | 118 | _singleUpdate.clear(); | ||
2390 | 119 | } | ||
2391 | 0 | 120 | ||
2392 | === added file 'build/src/plugins/org.apache.cordova.geolocation/geolocation.h' | |||
2393 | --- build/src/plugins/org.apache.cordova.geolocation/geolocation.h 1970-01-01 00:00:00 +0000 | |||
2394 | +++ build/src/plugins/org.apache.cordova.geolocation/geolocation.h 2014-02-19 16:53:58 +0000 | |||
2395 | @@ -0,0 +1,69 @@ | |||
2396 | 1 | /* | ||
2397 | 2 | * | ||
2398 | 3 | * Copyright 2013 Canonical Ltd. | ||
2399 | 4 | * | ||
2400 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2401 | 6 | * you may not use this file except in compliance with the License. | ||
2402 | 7 | * You may obtain a copy of the License at | ||
2403 | 8 | * | ||
2404 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2405 | 10 | * | ||
2406 | 11 | * Unless required by applicable law or agreed to in writing, | ||
2407 | 12 | * software distributed under the License is distributed on an | ||
2408 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
2409 | 14 | * KIND, either express or implied. See the License for the | ||
2410 | 15 | * specific language governing permissions and limitations | ||
2411 | 16 | * under the License. | ||
2412 | 17 | * | ||
2413 | 18 | */ | ||
2414 | 19 | |||
2415 | 20 | #ifndef GEOLOCATION_H_SVO2013 | ||
2416 | 21 | #define GEOLOCATION_H_SVO2013 | ||
2417 | 22 | |||
2418 | 23 | #include <QGeoPositionInfoSource> | ||
2419 | 24 | #include <QGeoPositionInfo> | ||
2420 | 25 | #include <QtCore> | ||
2421 | 26 | #include <cassert> | ||
2422 | 27 | |||
2423 | 28 | #include <cplugin.h> | ||
2424 | 29 | |||
2425 | 30 | class Geolocation: public CPlugin { | ||
2426 | 31 | Q_OBJECT | ||
2427 | 32 | public: | ||
2428 | 33 | explicit Geolocation(Cordova *cordova); | ||
2429 | 34 | |||
2430 | 35 | virtual const QString fullName() override { | ||
2431 | 36 | return Geolocation::fullID(); | ||
2432 | 37 | } | ||
2433 | 38 | |||
2434 | 39 | virtual const QString shortName() override { | ||
2435 | 40 | return "Geolocation"; | ||
2436 | 41 | } | ||
2437 | 42 | |||
2438 | 43 | static const QString fullID() { | ||
2439 | 44 | return "Geolocation"; | ||
2440 | 45 | } | ||
2441 | 46 | |||
2442 | 47 | public slots: | ||
2443 | 48 | void getLocation(int scId, int ecId, bool enableHighAccuracy, qint64 maximumAge); | ||
2444 | 49 | void addWatch(int scId, int ecId, const QString &id, bool enableHighAccuracy); | ||
2445 | 50 | void clearWatch(int scId, int ecId, const QString &id); | ||
2446 | 51 | |||
2447 | 52 | protected slots: | ||
2448 | 53 | void positionUpdated(const QGeoPositionInfo &update); | ||
2449 | 54 | void updateTimeout(); | ||
2450 | 55 | |||
2451 | 56 | private: | ||
2452 | 57 | QMap<QString, int> _id2sc; | ||
2453 | 58 | QMap<QString, int> _id2ec; | ||
2454 | 59 | QSet<QString> _singleUpdate; | ||
2455 | 60 | QSharedPointer<QGeoPositionInfoSource> _geoPositionInfoSource; | ||
2456 | 61 | |||
2457 | 62 | enum PositionError { | ||
2458 | 63 | PERMISSION_DENIED = 1, | ||
2459 | 64 | POSITION_UNAVAILABLE = 2, | ||
2460 | 65 | TIMEOUT = 3 | ||
2461 | 66 | }; | ||
2462 | 67 | }; | ||
2463 | 68 | |||
2464 | 69 | #endif | ||
2465 | 0 | 70 | ||
2466 | === added directory 'build/src/plugins/org.apache.cordova.globalization' | |||
2467 | === added file 'build/src/plugins/org.apache.cordova.globalization/globalization.cpp' | |||
2468 | --- build/src/plugins/org.apache.cordova.globalization/globalization.cpp 1970-01-01 00:00:00 +0000 | |||
2469 | +++ build/src/plugins/org.apache.cordova.globalization/globalization.cpp 2014-02-19 16:53:58 +0000 | |||
2470 | @@ -0,0 +1,342 @@ | |||
2471 | 1 | /* | ||
2472 | 2 | * | ||
2473 | 3 | * Copyright 2013 Canonical Ltd. | ||
2474 | 4 | * | ||
2475 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2476 | 6 | * you may not use this file except in compliance with the License. | ||
2477 | 7 | * You may obtain a copy of the License at | ||
2478 | 8 | * | ||
2479 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2480 | 10 | * | ||
2481 | 11 | * Unless required by applicable law or agreed to in writing, | ||
2482 | 12 | * software distributed under the License is distributed on an | ||
2483 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
2484 | 14 | * KIND, either express or implied. See the License for the | ||
2485 | 15 | * specific language governing permissions and limitations | ||
2486 | 16 | * under the License. | ||
2487 | 17 | * | ||
2488 | 18 | */ | ||
2489 | 19 | |||
2490 | 20 | #include <ctime> //TODO: switch to QTimeZone (QT 5.1) | ||
2491 | 21 | #include <unicode/decimfmt.h> | ||
2492 | 22 | #include <unicode/timezone.h> | ||
2493 | 23 | |||
2494 | 24 | #include "globalization.h" | ||
2495 | 25 | |||
2496 | 26 | Globalization::Globalization(Cordova *cordova): | ||
2497 | 27 | CPlugin(cordova) { | ||
2498 | 28 | } | ||
2499 | 29 | |||
2500 | 30 | void Globalization::getPreferredLanguage(int scId, int ecId) { | ||
2501 | 31 | Q_UNUSED(ecId) | ||
2502 | 32 | |||
2503 | 33 | QLocale locale; | ||
2504 | 34 | QString lang = QLocale::languageToString(locale.language()); | ||
2505 | 35 | QVariantMap obj; | ||
2506 | 36 | obj.insert("value", lang); | ||
2507 | 37 | this->cb(scId, obj); | ||
2508 | 38 | } | ||
2509 | 39 | |||
2510 | 40 | void Globalization::getLocaleName(int scId, int ecId) { | ||
2511 | 41 | Q_UNUSED(ecId) | ||
2512 | 42 | |||
2513 | 43 | QVariantMap obj; | ||
2514 | 44 | obj.insert("value", QLocale().name()); | ||
2515 | 45 | this->cb(scId, obj); | ||
2516 | 46 | } | ||
2517 | 47 | |||
2518 | 48 | void Globalization::getFirstDayOfWeek(int scId, int ecId) { | ||
2519 | 49 | Q_UNUSED(ecId) | ||
2520 | 50 | |||
2521 | 51 | QLocale locale; | ||
2522 | 52 | |||
2523 | 53 | int res; | ||
2524 | 54 | if (locale.firstDayOfWeek() == Qt::Sunday) { | ||
2525 | 55 | res = 1; | ||
2526 | 56 | } else { | ||
2527 | 57 | res = (2 - Qt::Monday) + locale.firstDayOfWeek(); | ||
2528 | 58 | } | ||
2529 | 59 | |||
2530 | 60 | QVariantMap obj; | ||
2531 | 61 | obj.insert("value", res); | ||
2532 | 62 | this->cb(scId, obj); | ||
2533 | 63 | } | ||
2534 | 64 | |||
2535 | 65 | void Globalization::isDayLightSavingsTime(int scId, int ecId, const QVariantMap &options) { | ||
2536 | 66 | time_t time = options.find("time_t")->toLongLong() / 1000; | ||
2537 | 67 | const tm *desc = std::localtime(&time); | ||
2538 | 68 | if (desc->tm_isdst < 0) { | ||
2539 | 69 | this->callback(ecId, QString("new GlobalizationError(%1, 'information is not available');").arg(Globalization::UNKNOWN_ERROR)); | ||
2540 | 70 | return; | ||
2541 | 71 | } | ||
2542 | 72 | this->callback(scId, QString("{dst:%1}").arg(desc->tm_isdst > 0 ? "true" : "false")); | ||
2543 | 73 | } | ||
2544 | 74 | |||
2545 | 75 | QLocale::FormatType translateFormat(Globalization::Format formatLength) { | ||
2546 | 76 | QLocale::FormatType format = QLocale::ShortFormat; | ||
2547 | 77 | switch (formatLength) { | ||
2548 | 78 | case Globalization::FORMAT_FULL: | ||
2549 | 79 | case Globalization::FORMAT_LONG: | ||
2550 | 80 | format = QLocale::ShortFormat; // TODO: Qt cant parse string produced with QLocale::LongFormat; | ||
2551 | 81 | break; | ||
2552 | 82 | case Globalization::FORMAT_MEDIUM: | ||
2553 | 83 | format = QLocale::ShortFormat; | ||
2554 | 84 | break; | ||
2555 | 85 | case Globalization::FORMAT_SHORT: | ||
2556 | 86 | format = QLocale::NarrowFormat; | ||
2557 | 87 | break; | ||
2558 | 88 | } | ||
2559 | 89 | return format; | ||
2560 | 90 | } | ||
2561 | 91 | |||
2562 | 92 | void Globalization::dateToString(int scId, int ecId, const QVariantMap &options) { | ||
2563 | 93 | time_t time = options.find("time_t")->toLongLong() / 1000; | ||
2564 | 94 | |||
2565 | 95 | Globalization::Format formatLength = static_cast<Globalization::Format>(options.find("formatLength")->toInt()); | ||
2566 | 96 | Globalization::Selector selector = static_cast<Globalization::Selector>(options.find("selector")->toInt()); | ||
2567 | 97 | |||
2568 | 98 | QLocale::FormatType format = translateFormat(formatLength); | ||
2569 | 99 | if (time < 0) { | ||
2570 | 100 | this->callback(ecId, QString("new GlobalizationError(%1, 'unsupported operation');").arg(Globalization::FORMATTING_ERROR)); | ||
2571 | 101 | return; | ||
2572 | 102 | } | ||
2573 | 103 | |||
2574 | 104 | QLocale locale; | ||
2575 | 105 | QString res; | ||
2576 | 106 | QDateTime dateTime = QDateTime::fromTime_t((uint)time); | ||
2577 | 107 | switch (selector) { | ||
2578 | 108 | case SELECTOR_ALL: | ||
2579 | 109 | res = locale.toString(dateTime,format); | ||
2580 | 110 | break; | ||
2581 | 111 | case SELECTOR_TIME: | ||
2582 | 112 | res = locale.toString(dateTime.time(), format); | ||
2583 | 113 | break; | ||
2584 | 114 | case SELECTOR_DATE: | ||
2585 | 115 | res = locale.toString(dateTime.date(), format); | ||
2586 | 116 | break; | ||
2587 | 117 | } | ||
2588 | 118 | QVariantMap obj; | ||
2589 | 119 | obj.insert("value", res); | ||
2590 | 120 | this->cb(scId, obj); | ||
2591 | 121 | } | ||
2592 | 122 | |||
2593 | 123 | void Globalization::stringToDate(int scId, int ecId, const QVariantMap &options) { | ||
2594 | 124 | QString dateString = options.find("dateString")->toString(); | ||
2595 | 125 | Globalization::Format formatLength = static_cast<Globalization::Format>(options.find("formatLength")->toInt()); | ||
2596 | 126 | Globalization::Selector selector = static_cast<Globalization::Selector>(options.find("selector")->toInt()); | ||
2597 | 127 | |||
2598 | 128 | QLocale::FormatType format = translateFormat(formatLength); | ||
2599 | 129 | QLocale locale; | ||
2600 | 130 | bool valid(true); | ||
2601 | 131 | int year(0), month(0), day(0), hour(0), minute(0), second(0), millisecond(0); | ||
2602 | 132 | switch (selector) { | ||
2603 | 133 | case SELECTOR_ALL: | ||
2604 | 134 | { | ||
2605 | 135 | QDateTime dateTime = locale.toDateTime(dateString, format); | ||
2606 | 136 | valid = dateTime.isValid(); | ||
2607 | 137 | QTime time = dateTime.time(); | ||
2608 | 138 | hour = time.hour(); minute = time.minute(); second = time.second(); millisecond = time.msec(); | ||
2609 | 139 | QDate date = dateTime.date(); | ||
2610 | 140 | year = date.year(); month = date.month(); day = date.day(); | ||
2611 | 141 | } | ||
2612 | 142 | break; | ||
2613 | 143 | case SELECTOR_TIME: | ||
2614 | 144 | { | ||
2615 | 145 | QTime time = locale.toTime(dateString, format); | ||
2616 | 146 | valid = time.isValid(); | ||
2617 | 147 | hour = time.hour(); minute = time.minute(); second = time.second(); millisecond = time.msec(); | ||
2618 | 148 | } | ||
2619 | 149 | break; | ||
2620 | 150 | case SELECTOR_DATE: | ||
2621 | 151 | { | ||
2622 | 152 | QDate date = locale.toDate(dateString, format); | ||
2623 | 153 | valid = date.isValid(); | ||
2624 | 154 | year = date.year(); month = date.month(); day = date.day(); | ||
2625 | 155 | } | ||
2626 | 156 | break; | ||
2627 | 157 | } | ||
2628 | 158 | if ((format == QLocale::NarrowFormat || format == QLocale::ShortFormat) && year < 2000 && year > 1900) { | ||
2629 | 159 | year += 100; | ||
2630 | 160 | } | ||
2631 | 161 | if (!valid) { | ||
2632 | 162 | this->callback(ecId, QString("new GlobalizationError(%1, 'parsing error')").arg(Globalization::PARSING_ERROR)); | ||
2633 | 163 | } else { | ||
2634 | 164 | QVariantMap obj; | ||
2635 | 165 | obj.insert("year", year); | ||
2636 | 166 | obj.insert("month", month - 1); | ||
2637 | 167 | obj.insert("day", day); | ||
2638 | 168 | obj.insert("hour", hour); | ||
2639 | 169 | obj.insert("minute", minute); | ||
2640 | 170 | obj.insert("second", second); | ||
2641 | 171 | obj.insert("millisecond", millisecond); | ||
2642 | 172 | this->cb(scId, obj); | ||
2643 | 173 | } | ||
2644 | 174 | } | ||
2645 | 175 | |||
2646 | 176 | void Globalization::getDateNames(int scId, int ecId, const QVariantMap &options) { | ||
2647 | 177 | Q_UNUSED(ecId) | ||
2648 | 178 | |||
2649 | 179 | int type = options.find("type")->toInt(); | ||
2650 | 180 | int item = options.find("item")->toInt(); | ||
2651 | 181 | |||
2652 | 182 | QLocale::FormatType format; | ||
2653 | 183 | if (type == FORMAT_SHORT) | ||
2654 | 184 | format = QLocale::ShortFormat; | ||
2655 | 185 | else | ||
2656 | 186 | format = QLocale::LongFormat; | ||
2657 | 187 | QLocale locale; | ||
2658 | 188 | QList<QString> res; | ||
2659 | 189 | if (item == REQUEST_DAY_NAMES) { | ||
2660 | 190 | for (int i = 1; i <= 7; i++) { | ||
2661 | 191 | res.append(locale.dayName(i, format)); | ||
2662 | 192 | } | ||
2663 | 193 | } else { //REQUEST_MONTH_NAMES | ||
2664 | 194 | for (int i = 1; i <= 12; i++) { | ||
2665 | 195 | res.append(locale.monthName(i, format)); | ||
2666 | 196 | } | ||
2667 | 197 | } | ||
2668 | 198 | |||
2669 | 199 | QString result; | ||
2670 | 200 | for (QList<QString>::iterator it = res.begin(); it != res.end(); it++) { | ||
2671 | 201 | result += QString("'%1',").arg(*it); | ||
2672 | 202 | } | ||
2673 | 203 | this->callback(scId, QString("{ value: [ %1 ]}").arg(result)); | ||
2674 | 204 | } | ||
2675 | 205 | |||
2676 | 206 | template<class T> | ||
2677 | 207 | static QString format(T number, Globalization::NumberType type) { | ||
2678 | 208 | QString res; | ||
2679 | 209 | QLocale locale; | ||
2680 | 210 | switch (type) { | ||
2681 | 211 | case Globalization::DECIMAL: | ||
2682 | 212 | res = locale.toString(number); | ||
2683 | 213 | break; | ||
2684 | 214 | case Globalization::PERCENT: | ||
2685 | 215 | res = locale.toString(number) + locale.percent(); | ||
2686 | 216 | break; | ||
2687 | 217 | case Globalization::CURRENCY: | ||
2688 | 218 | res = locale.toCurrencyString(number); | ||
2689 | 219 | break; | ||
2690 | 220 | }; | ||
2691 | 221 | return res; | ||
2692 | 222 | } | ||
2693 | 223 | |||
2694 | 224 | void Globalization::numberToString(int scId, int ecId, const QVariantMap &options) { | ||
2695 | 225 | Q_UNUSED(ecId) | ||
2696 | 226 | |||
2697 | 227 | bool isInt = options.find("isInt")->toBool(); | ||
2698 | 228 | NumberType type = static_cast<NumberType>(options.find("type")->toBool()); | ||
2699 | 229 | |||
2700 | 230 | QString res; | ||
2701 | 231 | if (isInt) { | ||
2702 | 232 | long long number = options.find("number")->toLongLong(); | ||
2703 | 233 | res = format(number, type); | ||
2704 | 234 | } else { | ||
2705 | 235 | double number = options.find("number")->toDouble(); | ||
2706 | 236 | res = format(number, type); | ||
2707 | 237 | } | ||
2708 | 238 | this->callback(scId, QString("{ value: '%1' }").arg(res)); | ||
2709 | 239 | } | ||
2710 | 240 | |||
2711 | 241 | void Globalization::stringToNumber(int scId, int ecId, int type, QString string) { | ||
2712 | 242 | switch ((NumberType)type) { | ||
2713 | 243 | case Globalization::DECIMAL: | ||
2714 | 244 | string = string.remove(QLocale().groupSeparator()); | ||
2715 | 245 | break; | ||
2716 | 246 | case Globalization::PERCENT: | ||
2717 | 247 | string = string.remove(QLocale().percent()).remove(QLocale().groupSeparator()); | ||
2718 | 248 | break; | ||
2719 | 249 | case Globalization::CURRENCY: | ||
2720 | 250 | string = string.remove(QLocale().currencySymbol()).remove(QLocale().groupSeparator()); | ||
2721 | 251 | break; | ||
2722 | 252 | }; | ||
2723 | 253 | bool ok; | ||
2724 | 254 | double res = QLocale().toDouble(string, &ok); | ||
2725 | 255 | if (ok) | ||
2726 | 256 | this->callback(scId, QString("{ value: %1 }").arg(res)); | ||
2727 | 257 | else | ||
2728 | 258 | this->callback(ecId, QString("new GlobalizationError(%1, 'parsing error')").arg(Globalization::PARSING_ERROR)); | ||
2729 | 259 | } | ||
2730 | 260 | |||
2731 | 261 | static QString ustr2qstr(UnicodeString &ustr) { | ||
2732 | 262 | std::string res; | ||
2733 | 263 | ustr.toUTF8String(res); | ||
2734 | 264 | |||
2735 | 265 | return QString(res.c_str()); | ||
2736 | 266 | } | ||
2737 | 267 | |||
2738 | 268 | void Globalization::getNumberPattern(int scId, int ecId, int type) { | ||
2739 | 269 | Q_UNUSED(ecId); | ||
2740 | 270 | UErrorCode status = U_ZERO_ERROR; | ||
2741 | 271 | icu::DecimalFormat icu(status); | ||
2742 | 272 | |||
2743 | 273 | icu::UnicodeString pattern; | ||
2744 | 274 | icu.toPattern(pattern); | ||
2745 | 275 | |||
2746 | 276 | QLocale locale; | ||
2747 | 277 | QVariantMap obj; | ||
2748 | 278 | |||
2749 | 279 | obj.insert("pattern", ustr2qstr(pattern)); | ||
2750 | 280 | |||
2751 | 281 | switch ((NumberType)type) { | ||
2752 | 282 | case Globalization::DECIMAL: | ||
2753 | 283 | obj.insert("symbol", ""); | ||
2754 | 284 | break; | ||
2755 | 285 | case Globalization::PERCENT: | ||
2756 | 286 | obj.insert("symbol", QString(locale.percent())); | ||
2757 | 287 | break; | ||
2758 | 288 | case Globalization::CURRENCY: | ||
2759 | 289 | obj.insert("symbol", QString(locale.currencySymbol())); | ||
2760 | 290 | break; | ||
2761 | 291 | }; | ||
2762 | 292 | |||
2763 | 293 | obj.insert("fraction", icu.getMaximumFractionDigits()); | ||
2764 | 294 | obj.insert("rounding", icu.getRoundingIncrement()); | ||
2765 | 295 | obj.insert("positive", QString(locale.positiveSign())); | ||
2766 | 296 | obj.insert("negative", QString(locale.negativeSign())); | ||
2767 | 297 | obj.insert("decimal", QString(locale.decimalPoint())); | ||
2768 | 298 | obj.insert("grouping", QString(locale.groupSeparator())); | ||
2769 | 299 | |||
2770 | 300 | this->cb(scId, obj); | ||
2771 | 301 | } | ||
2772 | 302 | |||
2773 | 303 | static bool inDayLightSavingsTime() { | ||
2774 | 304 | time_t now; | ||
2775 | 305 | |||
2776 | 306 | time(&now); | ||
2777 | 307 | |||
2778 | 308 | const tm *desc = std::localtime(&now); | ||
2779 | 309 | |||
2780 | 310 | return desc->tm_isdst > 0; | ||
2781 | 311 | } | ||
2782 | 312 | |||
2783 | 313 | void Globalization::getDatePattern(int scId, int ecId, int formatLength, int selector) { | ||
2784 | 314 | Q_UNUSED(ecId); | ||
2785 | 315 | |||
2786 | 316 | QLocale locale; | ||
2787 | 317 | QVariantMap res; | ||
2788 | 318 | QLocale::FormatType format = translateFormat((Format)formatLength); | ||
2789 | 319 | |||
2790 | 320 | switch ((Selector)selector) { | ||
2791 | 321 | case Selector::SELECTOR_TIME: | ||
2792 | 322 | res.insert("pattern", locale.timeFormat(format)); | ||
2793 | 323 | break; | ||
2794 | 324 | case Selector::SELECTOR_DATE: | ||
2795 | 325 | res.insert("pattern", locale.dateFormat(format)); | ||
2796 | 326 | break; | ||
2797 | 327 | case Selector::SELECTOR_ALL: | ||
2798 | 328 | res.insert("pattern", locale.dateTimeFormat(format)); | ||
2799 | 329 | break; | ||
2800 | 330 | }; | ||
2801 | 331 | |||
2802 | 332 | UnicodeString result; | ||
2803 | 333 | QSharedPointer<TimeZone> timezone = QSharedPointer<TimeZone>(TimeZone::createDefault()); | ||
2804 | 334 | timezone->getDisplayName(inDayLightSavingsTime(), TimeZone::SHORT, result); | ||
2805 | 335 | |||
2806 | 336 | res.insert("timezone", ustr2qstr(result)); | ||
2807 | 337 | res.insert("utc_offset", timezone->getRawOffset() / 1000 + timezone->getDSTSavings() / 1000); | ||
2808 | 338 | res.insert("dst_offset", timezone->getDSTSavings() / 1000); | ||
2809 | 339 | |||
2810 | 340 | this->cb(scId, res); | ||
2811 | 341 | } | ||
2812 | 342 | |||
2813 | 0 | 343 | ||
2814 | === added file 'build/src/plugins/org.apache.cordova.globalization/globalization.h' | |||
2815 | --- build/src/plugins/org.apache.cordova.globalization/globalization.h 1970-01-01 00:00:00 +0000 | |||
2816 | +++ build/src/plugins/org.apache.cordova.globalization/globalization.h 2014-02-19 16:53:58 +0000 | |||
2817 | @@ -0,0 +1,93 @@ | |||
2818 | 1 | /* | ||
2819 | 2 | * | ||
2820 | 3 | * Copyright 2013 Canonical Ltd. | ||
2821 | 4 | * | ||
2822 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2823 | 6 | * you may not use this file except in compliance with the License. | ||
2824 | 7 | * You may obtain a copy of the License at | ||
2825 | 8 | * | ||
2826 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2827 | 10 | * | ||
2828 | 11 | * Unless required by applicable law or agreed to in writing, | ||
2829 | 12 | * software distributed under the License is distributed on an | ||
2830 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
2831 | 14 | * KIND, either express or implied. See the License for the | ||
2832 | 15 | * specific language governing permissions and limitations | ||
2833 | 16 | * under the License. | ||
2834 | 17 | * | ||
2835 | 18 | */ | ||
2836 | 19 | #ifndef GLOBALIZATION_H_SVO2013 | ||
2837 | 20 | #define GLOBALIZATION_H_SVO2013 | ||
2838 | 21 | |||
2839 | 22 | #include <QtCore> | ||
2840 | 23 | #include <QLocale> | ||
2841 | 24 | |||
2842 | 25 | #include <cplugin.h> | ||
2843 | 26 | |||
2844 | 27 | class Globalization: public CPlugin { | ||
2845 | 28 | Q_OBJECT | ||
2846 | 29 | enum GlobalizationError { | ||
2847 | 30 | UNKNOWN_ERROR = 0, | ||
2848 | 31 | FORMATTING_ERROR = 1, | ||
2849 | 32 | PARSING_ERROR = 2, | ||
2850 | 33 | PATTERN_ERROR = 3 | ||
2851 | 34 | }; | ||
2852 | 35 | |||
2853 | 36 | enum Selector { | ||
2854 | 37 | SELECTOR_DATE = 0, | ||
2855 | 38 | SELECTOR_TIME = 1, | ||
2856 | 39 | SELECTOR_ALL = 2 | ||
2857 | 40 | }; | ||
2858 | 41 | |||
2859 | 42 | enum Format { | ||
2860 | 43 | FORMAT_SHORT = 0, | ||
2861 | 44 | FORMAT_MEDIUM = 1, | ||
2862 | 45 | FORMAT_LONG = 2, | ||
2863 | 46 | FORMAT_FULL = 3 | ||
2864 | 47 | }; | ||
2865 | 48 | |||
2866 | 49 | enum { | ||
2867 | 50 | REQUEST_DAY_NAMES = 0, | ||
2868 | 51 | REQUEST_MONTH_NAMES = 1 | ||
2869 | 52 | }; | ||
2870 | 53 | |||
2871 | 54 | enum NumberType { | ||
2872 | 55 | DECIMAL, | ||
2873 | 56 | PERCENT, | ||
2874 | 57 | CURRENCY | ||
2875 | 58 | }; | ||
2876 | 59 | |||
2877 | 60 | public: | ||
2878 | 61 | explicit Globalization(Cordova *cordova); | ||
2879 | 62 | |||
2880 | 63 | virtual const QString fullName() override { | ||
2881 | 64 | return Globalization::fullID(); | ||
2882 | 65 | } | ||
2883 | 66 | |||
2884 | 67 | virtual const QString shortName() override { | ||
2885 | 68 | return "Globalization"; | ||
2886 | 69 | } | ||
2887 | 70 | |||
2888 | 71 | static const QString fullID() { | ||
2889 | 72 | return "Globalization"; | ||
2890 | 73 | } | ||
2891 | 74 | |||
2892 | 75 | public slots: | ||
2893 | 76 | void getPreferredLanguage(int scId, int ecId); | ||
2894 | 77 | void getLocaleName(int scId, int ecId); | ||
2895 | 78 | void getFirstDayOfWeek(int scId, int ecId); | ||
2896 | 79 | void isDayLightSavingsTime(int scId, int ecId, const QVariantMap &options); | ||
2897 | 80 | void dateToString(int scId, int ecId, const QVariantMap &options); | ||
2898 | 81 | void stringToDate(int scId, int ecId, const QVariantMap &options); | ||
2899 | 82 | |||
2900 | 83 | void getDateNames(int scId, int ecId, const QVariantMap &options); | ||
2901 | 84 | void numberToString(int scId, int ecId, const QVariantMap &options); | ||
2902 | 85 | void stringToNumber(int scId, int ecId, int type, QString string); | ||
2903 | 86 | void getNumberPattern(int scId, int ecId, int type); | ||
2904 | 87 | void getDatePattern(int scId, int ecId, int formatLength, int selector); | ||
2905 | 88 | private: | ||
2906 | 89 | friend QLocale::FormatType translateFormat(Globalization::Format formatLength); | ||
2907 | 90 | template<class T> friend QString format(T number, Globalization::NumberType type); | ||
2908 | 91 | }; | ||
2909 | 92 | |||
2910 | 93 | #endif | ||
2911 | 0 | 94 | ||
2912 | === added directory 'build/src/plugins/org.apache.cordova.inappbrowser' | |||
2913 | === added file 'build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp' | |||
2914 | --- build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp 1970-01-01 00:00:00 +0000 | |||
2915 | +++ build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp 2014-02-19 16:53:58 +0000 | |||
2916 | @@ -0,0 +1,106 @@ | |||
2917 | 1 | /* | ||
2918 | 2 | * | ||
2919 | 3 | * Copyright 2013 Canonical Ltd. | ||
2920 | 4 | * | ||
2921 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
2922 | 6 | * or more contributor license agreements. See the NOTICE file | ||
2923 | 7 | * distributed with this work for additional information | ||
2924 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
2925 | 9 | * to you under the Apache License, Version 2.0 (the | ||
2926 | 10 | * "License"); you may not use this file except in compliance | ||
2927 | 11 | * with the License. You may obtain a copy of the License at | ||
2928 | 12 | * | ||
2929 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2930 | 14 | * | ||
2931 | 15 | * Unless required by applicable law or agreed to in writing, | ||
2932 | 16 | * software distributed under the License is distributed on an | ||
2933 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
2934 | 18 | * KIND, either express or implied. See the License for the | ||
2935 | 19 | * specific language governing permissions and limitations | ||
2936 | 20 | * under the License. | ||
2937 | 21 | * | ||
2938 | 22 | */ | ||
2939 | 23 | |||
2940 | 24 | #include <QQuickView> | ||
2941 | 25 | #include <QQuickItem> | ||
2942 | 26 | |||
2943 | 27 | #include "inappbrowser.h" | ||
2944 | 28 | #include <cordova.h> | ||
2945 | 29 | |||
2946 | 30 | Inappbrowser::Inappbrowser(Cordova *cordova): CPlugin(cordova), _eventCb(0) { | ||
2947 | 31 | } | ||
2948 | 32 | |||
2949 | 33 | const char code[] = "\ | ||
2950 | 34 | var component, object; \ | ||
2951 | 35 | function createObject() { \ | ||
2952 | 36 | component = Qt.createComponent(%1); \ | ||
2953 | 37 | if (component.status == Component.Ready) \ | ||
2954 | 38 | finishCreation(); \ | ||
2955 | 39 | else \ | ||
2956 | 40 | component.statusChanged.connect(finishCreation); \ | ||
2957 | 41 | } \ | ||
2958 | 42 | function finishCreation() { \ | ||
2959 | 43 | CordovaWrapper.object = component.createObject(root, \ | ||
2960 | 44 | {root: root, cordova: cordova, url1: %2}); \ | ||
2961 | 45 | } \ | ||
2962 | 46 | createObject()"; | ||
2963 | 47 | |||
2964 | 48 | const char EXIT_EVENT[] = "'exit'"; | ||
2965 | 49 | const char LOADSTART_EVENT[] = "'loadstart'"; | ||
2966 | 50 | const char LOADSTOP_EVENT[] = "'loadstop'"; | ||
2967 | 51 | const char LOADERROR_EVENT[] = "'loaderror'"; | ||
2968 | 52 | |||
2969 | 53 | void Inappbrowser::open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures) { | ||
2970 | 54 | assert(_eventCb == 0); | ||
2971 | 55 | |||
2972 | 56 | _eventCb = cb; | ||
2973 | 57 | |||
2974 | 58 | QString path = m_cordova->get_app_dir() + "/../qml/InAppBrowser.qml"; | ||
2975 | 59 | |||
2976 | 60 | // TODO: relative url | ||
2977 | 61 | QString qml = QString(code) | ||
2978 | 62 | .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(url)); | ||
2979 | 63 | m_cordova->execQML(qml); | ||
2980 | 64 | } | ||
2981 | 65 | |||
2982 | 66 | void Inappbrowser::show(int, int) { | ||
2983 | 67 | m_cordova->execQML("CordovaWrapper.object.visible = true"); | ||
2984 | 68 | } | ||
2985 | 69 | |||
2986 | 70 | void Inappbrowser::close(int, int) { | ||
2987 | 71 | m_cordova->execQML("CordovaWrapper.object.destroy()"); | ||
2988 | 72 | this->callbackWithoutRemove(_eventCb, EXIT_EVENT); | ||
2989 | 73 | _eventCb = 0; | ||
2990 | 74 | } | ||
2991 | 75 | |||
2992 | 76 | void Inappbrowser::injectStyleFile(int cb, int, const QString&, bool) { | ||
2993 | 77 | // TODO: | ||
2994 | 78 | qCritical() << "unimplemented " << __PRETTY_FUNCTION__; | ||
2995 | 79 | } | ||
2996 | 80 | |||
2997 | 81 | void Inappbrowser::injectStyleCode(int cb, int, const QString&, bool) { | ||
2998 | 82 | // TODO: | ||
2999 | 83 | qCritical() << "unimplemented " << __PRETTY_FUNCTION__; | ||
3000 | 84 | } | ||
3001 | 85 | |||
3002 | 86 | void Inappbrowser::injectScriptFile(int cb, int, const QString&, bool) { | ||
3003 | 87 | // TODO: | ||
3004 | 88 | qCritical() << "unimplemented " << __PRETTY_FUNCTION__; | ||
3005 | 89 | } | ||
3006 | 90 | |||
3007 | 91 | void Inappbrowser::injectScriptCode(int cb, int, const QString&, bool) { | ||
3008 | 92 | // TODO: | ||
3009 | 93 | qCritical() << "unimplemented " << __PRETTY_FUNCTION__; | ||
3010 | 94 | } | ||
3011 | 95 | |||
3012 | 96 | void Inappbrowser::loadFinished(int status) { | ||
3013 | 97 | if (status == 2) { | ||
3014 | 98 | this->callbackWithoutRemove(_eventCb, LOADERROR_EVENT); | ||
3015 | 99 | } | ||
3016 | 100 | if (status == 0) { | ||
3017 | 101 | this->callbackWithoutRemove(_eventCb, LOADSTART_EVENT); | ||
3018 | 102 | } | ||
3019 | 103 | if (status == 3) { | ||
3020 | 104 | this->callbackWithoutRemove(_eventCb, LOADSTOP_EVENT); | ||
3021 | 105 | } | ||
3022 | 106 | } | ||
3023 | 0 | 107 | ||
3024 | === added file 'build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h' | |||
3025 | --- build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h 1970-01-01 00:00:00 +0000 | |||
3026 | +++ build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h 2014-02-19 16:53:58 +0000 | |||
3027 | @@ -0,0 +1,61 @@ | |||
3028 | 1 | /* | ||
3029 | 2 | * | ||
3030 | 3 | * Copyright 2013 Canonical Ltd. | ||
3031 | 4 | * | ||
3032 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
3033 | 6 | * or more contributor license agreements. See the NOTICE file | ||
3034 | 7 | * distributed with this work for additional information | ||
3035 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
3036 | 9 | * to you under the Apache License, Version 2.0 (the | ||
3037 | 10 | * "License"); you may not use this file except in compliance | ||
3038 | 11 | * with the License. You may obtain a copy of the License at | ||
3039 | 12 | * | ||
3040 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3041 | 14 | * | ||
3042 | 15 | * Unless required by applicable law or agreed to in writing, | ||
3043 | 16 | * software distributed under the License is distributed on an | ||
3044 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3045 | 18 | * KIND, either express or implied. See the License for the | ||
3046 | 19 | * specific language governing permissions and limitations | ||
3047 | 20 | * under the License. | ||
3048 | 21 | * | ||
3049 | 22 | */ | ||
3050 | 23 | #ifndef INAPPBROWSER_H | ||
3051 | 24 | #define INAPPBROWSER_H | ||
3052 | 25 | |||
3053 | 26 | #include <QtCore> | ||
3054 | 27 | #include <cplugin.h> | ||
3055 | 28 | |||
3056 | 29 | class Inappbrowser: public CPlugin { | ||
3057 | 30 | Q_OBJECT | ||
3058 | 31 | public: | ||
3059 | 32 | Inappbrowser(Cordova *cordova); | ||
3060 | 33 | |||
3061 | 34 | virtual const QString fullName() override { | ||
3062 | 35 | return Inappbrowser::fullID(); | ||
3063 | 36 | } | ||
3064 | 37 | |||
3065 | 38 | virtual const QString shortName() override { | ||
3066 | 39 | return "InAppBrowser"; | ||
3067 | 40 | } | ||
3068 | 41 | |||
3069 | 42 | static const QString fullID() { | ||
3070 | 43 | return "InAppBrowser"; | ||
3071 | 44 | } | ||
3072 | 45 | |||
3073 | 46 | public slots: | ||
3074 | 47 | void open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures); | ||
3075 | 48 | void show(int, int); | ||
3076 | 49 | void close(int, int); | ||
3077 | 50 | void injectStyleFile(int cb, int, const QString&, bool); | ||
3078 | 51 | void injectStyleCode(int cb, int, const QString&, bool); | ||
3079 | 52 | void injectScriptFile(int cb, int, const QString&, bool); | ||
3080 | 53 | void injectScriptCode(int cb, int, const QString&, bool); | ||
3081 | 54 | |||
3082 | 55 | void loadFinished(int status); | ||
3083 | 56 | |||
3084 | 57 | private: | ||
3085 | 58 | int _eventCb; | ||
3086 | 59 | }; | ||
3087 | 60 | |||
3088 | 61 | #endif | ||
3089 | 0 | 62 | ||
3090 | === added directory 'build/src/plugins/org.apache.cordova.media' | |||
3091 | === added directory 'build/src/plugins/org.apache.cordova.media-capture' | |||
3092 | === added file 'build/src/plugins/org.apache.cordova.media-capture/capture.cpp' | |||
3093 | --- build/src/plugins/org.apache.cordova.media-capture/capture.cpp 1970-01-01 00:00:00 +0000 | |||
3094 | +++ build/src/plugins/org.apache.cordova.media-capture/capture.cpp 2014-02-19 16:53:58 +0000 | |||
3095 | @@ -0,0 +1,167 @@ | |||
3096 | 1 | /* | ||
3097 | 2 | * | ||
3098 | 3 | * Copyright 2013 Canonical Ltd. | ||
3099 | 4 | * | ||
3100 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3101 | 6 | * you may not use this file except in compliance with the License. | ||
3102 | 7 | * You may obtain a copy of the License at | ||
3103 | 8 | * | ||
3104 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3105 | 10 | * | ||
3106 | 11 | * Unless required by applicable law or agreed to in writing, | ||
3107 | 12 | * software distributed under the License is distributed on an | ||
3108 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3109 | 14 | * KIND, either express or implied. See the License for the | ||
3110 | 15 | * specific language governing permissions and limitations | ||
3111 | 16 | * under the License. | ||
3112 | 17 | * | ||
3113 | 18 | */ | ||
3114 | 19 | #include "capture.h" | ||
3115 | 20 | |||
3116 | 21 | const char code[] = "\ | ||
3117 | 22 | var component, object; \ | ||
3118 | 23 | function createObject() { \ | ||
3119 | 24 | component = Qt.createComponent(%1); \ | ||
3120 | 25 | if (component.status == Component.Ready) \ | ||
3121 | 26 | finishCreation(); \ | ||
3122 | 27 | else \ | ||
3123 | 28 | component.statusChanged.connect(finishCreation); \ | ||
3124 | 29 | } \ | ||
3125 | 30 | function finishCreation() { \ | ||
3126 | 31 | CordovaWrapper.captureObject = component.createObject(root, \ | ||
3127 | 32 | {root: root, cordova: cordova, state: \"%2\"}); \ | ||
3128 | 33 | } \ | ||
3129 | 34 | createObject()"; | ||
3130 | 35 | |||
3131 | 36 | static QString formatFile(const QMimeDatabase &db, const QString &path) { | ||
3132 | 37 | QFileInfo info(path); | ||
3133 | 38 | QMimeType mime = db.mimeTypeForFile(info.fileName()); | ||
3134 | 39 | |||
3135 | 40 | QVariantMap file; | ||
3136 | 41 | file.insert("name", info.fileName()); | ||
3137 | 42 | file.insert("fullPath", info.absoluteFilePath()); | ||
3138 | 43 | file.insert("lastModifiedDate", info.lastModified().toMSecsSinceEpoch()); | ||
3139 | 44 | file.insert("size", info.size()); | ||
3140 | 45 | file.insert("type", mime.name()); | ||
3141 | 46 | |||
3142 | 47 | return CordovaInternal::format(file); | ||
3143 | 48 | } | ||
3144 | 49 | |||
3145 | 50 | MediaCapture::MediaCapture(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) { | ||
3146 | 51 | } | ||
3147 | 52 | |||
3148 | 53 | void MediaCapture::captureAudio(int scId, int ecId, QVariantMap options) { | ||
3149 | 54 | if (_scId || _ecId) { | ||
3150 | 55 | this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY)); | ||
3151 | 56 | return; | ||
3152 | 57 | } | ||
3153 | 58 | |||
3154 | 59 | QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml"; | ||
3155 | 60 | |||
3156 | 61 | // TODO: relative url | ||
3157 | 62 | QString qml = QString(code).arg(CordovaInternal::format(path)).arg("audio"); | ||
3158 | 63 | m_cordova->execQML(qml); | ||
3159 | 64 | |||
3160 | 65 | _scId = scId; | ||
3161 | 66 | _ecId = ecId; | ||
3162 | 67 | } | ||
3163 | 68 | |||
3164 | 69 | void MediaCapture::onAudioRecordError(QMediaRecorder::Error) { | ||
3165 | 70 | if (!_ecId) | ||
3166 | 71 | return; | ||
3167 | 72 | this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_INTERNAL_ERR)); | ||
3168 | 73 | _ecId = _scId = 0; | ||
3169 | 74 | |||
3170 | 75 | _recorder.clear(); | ||
3171 | 76 | _files.clear(); | ||
3172 | 77 | |||
3173 | 78 | m_cordova->execQML("CordovaWrapper.captureObject.destroy()"); | ||
3174 | 79 | } | ||
3175 | 80 | |||
3176 | 81 | void MediaCapture::recordAudio() { | ||
3177 | 82 | if (_recorder.data()) { | ||
3178 | 83 | QUrl url = _recorder->outputLocation(); | ||
3179 | 84 | |||
3180 | 85 | QString path = url.toString(); | ||
3181 | 86 | _recorder->stop(); | ||
3182 | 87 | |||
3183 | 88 | _recorder.clear(); | ||
3184 | 89 | |||
3185 | 90 | this->callback(_scId, QString("[%1]").arg(formatFile(_db, path))); | ||
3186 | 91 | _ecId = _scId = 0; | ||
3187 | 92 | |||
3188 | 93 | m_cordova->execQML("CordovaWrapper.captureObject.destroy()"); | ||
3189 | 94 | } else { | ||
3190 | 95 | _recorder = QSharedPointer<QAudioRecorder>(new QAudioRecorder); | ||
3191 | 96 | QObject::connect(_recorder.data(), SIGNAL(error(QMediaRecorder::Error)), this, SLOT(onAudioRecordError(QMediaRecorder::Error))); | ||
3192 | 97 | |||
3193 | 98 | if (_options.find("mode")->toString() == "audio/amr") { | ||
3194 | 99 | _recorder->setContainerFormat("amr"); | ||
3195 | 100 | _recorder->setOutputLocation(generateLocation("amr")); | ||
3196 | 101 | } else { | ||
3197 | 102 | _recorder->setContainerFormat("wav"); | ||
3198 | 103 | _recorder->setOutputLocation(generateLocation("wav")); | ||
3199 | 104 | } | ||
3200 | 105 | _recorder->record(); | ||
3201 | 106 | } | ||
3202 | 107 | } | ||
3203 | 108 | |||
3204 | 109 | void MediaCapture::cancel() { | ||
3205 | 110 | if (!_ecId) | ||
3206 | 111 | return; | ||
3207 | 112 | |||
3208 | 113 | m_cordova->execQML("CordovaWrapper.captureObject.destroy()"); | ||
3209 | 114 | |||
3210 | 115 | _recorder.clear(); | ||
3211 | 116 | this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_NO_MEDIA_FILES)); | ||
3212 | 117 | _ecId = _scId = 0; | ||
3213 | 118 | |||
3214 | 119 | _recorder.clear(); | ||
3215 | 120 | } | ||
3216 | 121 | |||
3217 | 122 | void MediaCapture::captureVideo(int scId, int ecId, QVariantMap options) { | ||
3218 | 123 | if (_scId || _ecId) { | ||
3219 | 124 | this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY)); | ||
3220 | 125 | return; | ||
3221 | 126 | } | ||
3222 | 127 | |||
3223 | 128 | QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml"; | ||
3224 | 129 | |||
3225 | 130 | // TODO: relative url | ||
3226 | 131 | QString qml = QString(code).arg(CordovaInternal::format(path)).arg("videoRecording"); | ||
3227 | 132 | m_cordova->execQML(qml); | ||
3228 | 133 | |||
3229 | 134 | _scId = scId; | ||
3230 | 135 | _ecId = ecId; | ||
3231 | 136 | } | ||
3232 | 137 | |||
3233 | 138 | void MediaCapture::onVideoRecordEnd(QString path) { | ||
3234 | 139 | assert(path.startsWith("file:")); | ||
3235 | 140 | path = path.mid(5); | ||
3236 | 141 | |||
3237 | 142 | this->callback(_scId, QString("[%1]").arg(formatFile(_db, path))); | ||
3238 | 143 | _ecId = _scId = 0; | ||
3239 | 144 | |||
3240 | 145 | m_cordova->execQML("CordovaWrapper.captureObject.destroy()"); | ||
3241 | 146 | } | ||
3242 | 147 | |||
3243 | 148 | void MediaCapture::captureImage(int scId, int ecId, QVariantMap options) { | ||
3244 | 149 | if (_scId || _ecId) { | ||
3245 | 150 | this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY)); | ||
3246 | 151 | return; | ||
3247 | 152 | } | ||
3248 | 153 | |||
3249 | 154 | QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml"; | ||
3250 | 155 | |||
3251 | 156 | // TODO: relative url | ||
3252 | 157 | QString qml = QString(code).arg(CordovaInternal::format(path)).arg("camera"); | ||
3253 | 158 | m_cordova->execQML(qml); | ||
3254 | 159 | |||
3255 | 160 | _scId = scId; | ||
3256 | 161 | _ecId = ecId; | ||
3257 | 162 | } | ||
3258 | 163 | |||
3259 | 164 | void MediaCapture::onImageSaved(const QString &path) { | ||
3260 | 165 | this->callback(_scId, QString("[%1]").arg(formatFile(_db, path))); | ||
3261 | 166 | _ecId = _scId = 0; | ||
3262 | 167 | } | ||
3263 | 0 | 168 | ||
3264 | === added file 'build/src/plugins/org.apache.cordova.media-capture/capture.h' | |||
3265 | --- build/src/plugins/org.apache.cordova.media-capture/capture.h 1970-01-01 00:00:00 +0000 | |||
3266 | +++ build/src/plugins/org.apache.cordova.media-capture/capture.h 2014-02-19 16:53:58 +0000 | |||
3267 | @@ -0,0 +1,84 @@ | |||
3268 | 1 | /* | ||
3269 | 2 | * | ||
3270 | 3 | * Copyright 2013 Canonical Ltd. | ||
3271 | 4 | * | ||
3272 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3273 | 6 | * you may not use this file except in compliance with the License. | ||
3274 | 7 | * You may obtain a copy of the License at | ||
3275 | 8 | * | ||
3276 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3277 | 10 | * | ||
3278 | 11 | * Unless required by applicable law or agreed to in writing, | ||
3279 | 12 | * software distributed under the License is distributed on an | ||
3280 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3281 | 14 | * KIND, either express or implied. See the License for the | ||
3282 | 15 | * specific language governing permissions and limitations | ||
3283 | 16 | * under the License. | ||
3284 | 17 | * | ||
3285 | 18 | */ | ||
3286 | 19 | #ifndef CAPTURE_H_ASCXZFG975 | ||
3287 | 20 | #define CAPTURE_H_ASCXZFG975 | ||
3288 | 21 | |||
3289 | 22 | #include <cordova.h> | ||
3290 | 23 | #include <cplugin.h> | ||
3291 | 24 | #include <QtMultimedia> | ||
3292 | 25 | #include <QtCore> | ||
3293 | 26 | #include <QtQuick> | ||
3294 | 27 | |||
3295 | 28 | class MediaCapture: public CPlugin { | ||
3296 | 29 | Q_OBJECT | ||
3297 | 30 | public: | ||
3298 | 31 | explicit MediaCapture(Cordova *cordova); | ||
3299 | 32 | |||
3300 | 33 | virtual const QString fullName() override { | ||
3301 | 34 | return MediaCapture::fullID(); | ||
3302 | 35 | } | ||
3303 | 36 | |||
3304 | 37 | virtual const QString shortName() override { | ||
3305 | 38 | return "Capture"; | ||
3306 | 39 | } | ||
3307 | 40 | |||
3308 | 41 | static const QString fullID() { | ||
3309 | 42 | return "Capture"; | ||
3310 | 43 | } | ||
3311 | 44 | |||
3312 | 45 | public slots: | ||
3313 | 46 | void captureAudio(int scId, int ecId, QVariantMap options); | ||
3314 | 47 | void captureImage(int scId, int ecId, QVariantMap options); | ||
3315 | 48 | void captureVideo(int scId, int ecId, QVariantMap options); | ||
3316 | 49 | |||
3317 | 50 | void recordAudio(); | ||
3318 | 51 | void cancel(); | ||
3319 | 52 | void onVideoRecordEnd(QString path); | ||
3320 | 53 | void onImageSaved(const QString &path); | ||
3321 | 54 | |||
3322 | 55 | QString generateLocation(const QString &extension) { | ||
3323 | 56 | int i = 1; | ||
3324 | 57 | for (;;++i) { | ||
3325 | 58 | QString path = QString("%1/.local/share/%2/persistent/%3.%4").arg(QDir::homePath()) | ||
3326 | 59 | .arg(QCoreApplication::applicationName()).arg(i).arg(extension); | ||
3327 | 60 | |||
3328 | 61 | if (!QFileInfo(path).exists()) | ||
3329 | 62 | return path; | ||
3330 | 63 | } | ||
3331 | 64 | } | ||
3332 | 65 | private slots: | ||
3333 | 66 | void onAudioRecordError(QMediaRecorder::Error); | ||
3334 | 67 | private: | ||
3335 | 68 | QSharedPointer<QAudioRecorder> _recorder; | ||
3336 | 69 | |||
3337 | 70 | int _scId, _ecId; | ||
3338 | 71 | QList<QString> _files; | ||
3339 | 72 | QVariantMap _options; | ||
3340 | 73 | QMimeDatabase _db; | ||
3341 | 74 | |||
3342 | 75 | enum CaptureError { | ||
3343 | 76 | CAPTURE_INTERNAL_ERR = 0, | ||
3344 | 77 | CAPTURE_APPLICATION_BUSY = 1, | ||
3345 | 78 | CAPTURE_INVALID_ARGUMENT = 2, | ||
3346 | 79 | CAPTURE_NO_MEDIA_FILES = 3, | ||
3347 | 80 | CAPTURE_NOT_SUPPORTED = 20 | ||
3348 | 81 | }; | ||
3349 | 82 | }; | ||
3350 | 83 | |||
3351 | 84 | #endif | ||
3352 | 0 | 85 | ||
3353 | === added file 'build/src/plugins/org.apache.cordova.media/media.cpp' | |||
3354 | --- build/src/plugins/org.apache.cordova.media/media.cpp 1970-01-01 00:00:00 +0000 | |||
3355 | +++ build/src/plugins/org.apache.cordova.media/media.cpp 2014-02-19 16:53:58 +0000 | |||
3356 | @@ -0,0 +1,128 @@ | |||
3357 | 1 | /* | ||
3358 | 2 | * | ||
3359 | 3 | * Licensed to the Apache Software Foundation (ASF) under one | ||
3360 | 4 | * or more contributor license agreements. See the NOTICE file | ||
3361 | 5 | * distributed with this work for additional information | ||
3362 | 6 | * regarding copyright ownership. The ASF licenses this file | ||
3363 | 7 | * to you under the Apache License, Version 2.0 (the | ||
3364 | 8 | * "License"); you may not use this file except in compliance | ||
3365 | 9 | * with the License. You may obtain a copy of the License at | ||
3366 | 10 | * | ||
3367 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3368 | 12 | * | ||
3369 | 13 | * Unless required by applicable law or agreed to in writing, | ||
3370 | 14 | * software distributed under the License is distributed on an | ||
3371 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3372 | 16 | * KIND, either express or implied. See the License for the | ||
3373 | 17 | * specific language governing permissions and limitations | ||
3374 | 18 | * under the License. | ||
3375 | 19 | * | ||
3376 | 20 | */ | ||
3377 | 21 | |||
3378 | 22 | #include "media.h" | ||
3379 | 23 | |||
3380 | 24 | void Media::create(int scId, int ecId, const QString &id, const QString &src) { | ||
3381 | 25 | Q_UNUSED(scId); | ||
3382 | 26 | Q_UNUSED(ecId); | ||
3383 | 27 | |||
3384 | 28 | if (_id2Player.find(id) != _id2Player.end()) { | ||
3385 | 29 | _id2Player[id]->stop(); | ||
3386 | 30 | _id2Player.remove(id); | ||
3387 | 31 | } | ||
3388 | 32 | |||
3389 | 33 | _id2Player[id] = QSharedPointer<Player>(new Player(id, src, this)); | ||
3390 | 34 | } | ||
3391 | 35 | |||
3392 | 36 | void Media::relase(int scId, int ecId, const QString &id) { | ||
3393 | 37 | Q_UNUSED(scId); | ||
3394 | 38 | Q_UNUSED(ecId); | ||
3395 | 39 | |||
3396 | 40 | if (_id2Player.find(id) == _id2Player.end()) | ||
3397 | 41 | return; | ||
3398 | 42 | _id2Player.remove(id); | ||
3399 | 43 | } | ||
3400 | 44 | |||
3401 | 45 | void Media::startPlayingAudio(int scId, int ecId, const QString &id, const QString &src, QVariantMap options) { | ||
3402 | 46 | Q_UNUSED(scId); | ||
3403 | 47 | Q_UNUSED(ecId); | ||
3404 | 48 | Q_UNUSED(src); | ||
3405 | 49 | Q_UNUSED(options); | ||
3406 | 50 | |||
3407 | 51 | if (_id2Player.find(id) == _id2Player.end()) | ||
3408 | 52 | return; | ||
3409 | 53 | QSharedPointer<Player> player = _id2Player[id]; | ||
3410 | 54 | player->play(); | ||
3411 | 55 | } | ||
3412 | 56 | |||
3413 | 57 | void Media::pausePlayingAudio(int scId, int ecId, const QString &id) { | ||
3414 | 58 | Q_UNUSED(scId); | ||
3415 | 59 | Q_UNUSED(ecId); | ||
3416 | 60 | |||
3417 | 61 | if (_id2Player.find(id) == _id2Player.end()) | ||
3418 | 62 | return; | ||
3419 | 63 | QSharedPointer<Player> player = _id2Player[id]; | ||
3420 | 64 | player->pause(); | ||
3421 | 65 | } | ||
3422 | 66 | |||
3423 | 67 | void Media::stopPlayingAudio(int scId, int ecId, const QString &id) { | ||
3424 | 68 | Q_UNUSED(scId); | ||
3425 | 69 | Q_UNUSED(ecId); | ||
3426 | 70 | |||
3427 | 71 | if (_id2Player.find(id) == _id2Player.end()) | ||
3428 | 72 | return; | ||
3429 | 73 | QSharedPointer<Player> player = _id2Player[id]; | ||
3430 | 74 | player->stop(); | ||
3431 | 75 | } | ||
3432 | 76 | |||
3433 | 77 | void Media::startRecordingAudio(int scId, int ecId, const QString &id, const QString &src) { | ||
3434 | 78 | Q_UNUSED(scId); | ||
3435 | 79 | Q_UNUSED(ecId); | ||
3436 | 80 | Q_UNUSED(src); | ||
3437 | 81 | |||
3438 | 82 | if (_id2Player.find(id) == _id2Player.end()) | ||
3439 | 83 | return; | ||
3440 | 84 | QSharedPointer<Player> player = _id2Player[id]; | ||
3441 | 85 | player->startRecording(); | ||
3442 | 86 | } | ||
3443 | 87 | |||
3444 | 88 | void Media::stopRecordingAudio(int scId, int ecId, const QString &id) { | ||
3445 | 89 | Q_UNUSED(scId); | ||
3446 | 90 | Q_UNUSED(ecId); | ||
3447 | 91 | |||
3448 | 92 | if (_id2Player.find(id) == _id2Player.end()) | ||
3449 | 93 | return; | ||
3450 | 94 | QSharedPointer<Player> player = _id2Player[id]; | ||
3451 | 95 | player->stopRecording(); | ||
3452 | 96 | } | ||
3453 | 97 | |||
3454 | 98 | void Media::getCurrentPositionAudio(int scId, int ecId, const QString &id) { | ||
3455 | 99 | Q_UNUSED(ecId); | ||
3456 | 100 | |||
3457 | 101 | if (_id2Player.find(id) == _id2Player.end()) | ||
3458 | 102 | return; | ||
3459 | 103 | |||
3460 | 104 | QSharedPointer<Player> player = _id2Player[id]; | ||
3461 | 105 | double position = player->getPosition(); | ||
3462 | 106 | this->cb(scId, position); | ||
3463 | 107 | } | ||
3464 | 108 | |||
3465 | 109 | void Media::seekToAudio(int scId, int ecId, const QString &id, qint64 position) { | ||
3466 | 110 | Q_UNUSED(scId); | ||
3467 | 111 | Q_UNUSED(ecId); | ||
3468 | 112 | |||
3469 | 113 | if (_id2Player.find(id) == _id2Player.end()) | ||
3470 | 114 | return; | ||
3471 | 115 | |||
3472 | 116 | QSharedPointer<Player> player = _id2Player[id]; | ||
3473 | 117 | player->seekTo(position); | ||
3474 | 118 | } | ||
3475 | 119 | |||
3476 | 120 | void Media::setVolume(int scId, int ecId, const QString &id, int volume) { | ||
3477 | 121 | Q_UNUSED(scId); | ||
3478 | 122 | Q_UNUSED(ecId); | ||
3479 | 123 | |||
3480 | 124 | if (_id2Player.find(id) == _id2Player.end()) | ||
3481 | 125 | return; | ||
3482 | 126 | QSharedPointer<Player> player = _id2Player[id]; | ||
3483 | 127 | player->setVolume(volume); | ||
3484 | 128 | } | ||
3485 | 0 | 129 | ||
3486 | === added file 'build/src/plugins/org.apache.cordova.media/media.h' | |||
3487 | --- build/src/plugins/org.apache.cordova.media/media.h 1970-01-01 00:00:00 +0000 | |||
3488 | +++ build/src/plugins/org.apache.cordova.media/media.h 2014-02-19 16:53:58 +0000 | |||
3489 | @@ -0,0 +1,267 @@ | |||
3490 | 1 | /* | ||
3491 | 2 | * | ||
3492 | 3 | * Licensed to the Apache Software Foundation (ASF) under one | ||
3493 | 4 | * or more contributor license agreements. See the NOTICE file | ||
3494 | 5 | * distributed with this work for additional information | ||
3495 | 6 | * regarding copyright ownership. The ASF licenses this file | ||
3496 | 7 | * to you under the Apache License, Version 2.0 (the | ||
3497 | 8 | * "License"); you may not use this file except in compliance | ||
3498 | 9 | * with the License. You may obtain a copy of the License at | ||
3499 | 10 | * | ||
3500 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3501 | 12 | * | ||
3502 | 13 | * Unless required by applicable law or agreed to in writing, | ||
3503 | 14 | * software distributed under the License is distributed on an | ||
3504 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3505 | 16 | * KIND, either express or implied. See the License for the | ||
3506 | 17 | * specific language governing permissions and limitations | ||
3507 | 18 | * under the License. | ||
3508 | 19 | * | ||
3509 | 20 | */ | ||
3510 | 21 | |||
3511 | 22 | #ifndef MEDIA_H_789768978 | ||
3512 | 23 | #define MEDIA_H_789768978 | ||
3513 | 24 | |||
3514 | 25 | #include <QtMultimedia/QMediaPlayer> | ||
3515 | 26 | #include <QtCore> | ||
3516 | 27 | #include <QAudioRecorder> | ||
3517 | 28 | #include <QtMultimedia/QAudioEncoderSettings> | ||
3518 | 29 | |||
3519 | 30 | #include <cplugin.h> | ||
3520 | 31 | #include <cordova.h> | ||
3521 | 32 | |||
3522 | 33 | class Player; | ||
3523 | 34 | |||
3524 | 35 | class Media: public CPlugin { | ||
3525 | 36 | Q_OBJECT | ||
3526 | 37 | public: | ||
3527 | 38 | explicit Media(Cordova *cordova): CPlugin(cordova) { | ||
3528 | 39 | } | ||
3529 | 40 | |||
3530 | 41 | virtual const QString fullName() override { | ||
3531 | 42 | return Media::fullID(); | ||
3532 | 43 | } | ||
3533 | 44 | |||
3534 | 45 | virtual const QString shortName() override { | ||
3535 | 46 | return "Media"; | ||
3536 | 47 | } | ||
3537 | 48 | |||
3538 | 49 | static const QString fullID() { | ||
3539 | 50 | return "Media"; | ||
3540 | 51 | } | ||
3541 | 52 | |||
3542 | 53 | enum State { | ||
3543 | 54 | MEDIA_NONE = 0, | ||
3544 | 55 | MEDIA_STARTING = 1, | ||
3545 | 56 | MEDIA_RUNNING = 2, | ||
3546 | 57 | MEDIA_PAUSED = 3, | ||
3547 | 58 | MEDIA_STOPPED = 4 | ||
3548 | 59 | }; | ||
3549 | 60 | enum ErrorCode { | ||
3550 | 61 | MEDIA_ERR_NONE_ACTIVE = 0, | ||
3551 | 62 | MEDIA_ERR_ABORTED = 1, | ||
3552 | 63 | MEDIA_ERR_NETWORK = 2, | ||
3553 | 64 | MEDIA_ERR_DECODE = 3, | ||
3554 | 65 | MEDIA_ERR_NONE_SUPPORTED = 4 | ||
3555 | 66 | }; | ||
3556 | 67 | |||
3557 | 68 | void execJS(const QString &js) { | ||
3558 | 69 | m_cordova->execJS(js); | ||
3559 | 70 | } | ||
3560 | 71 | public slots: | ||
3561 | 72 | void create(int scId, int ecId, const QString &id, const QString &src); | ||
3562 | 73 | void relase(int scId, int ecId, const QString &id); | ||
3563 | 74 | |||
3564 | 75 | void startRecordingAudio(int scId, int ecId, const QString &id, const QString &src); | ||
3565 | 76 | void stopRecordingAudio(int scId, int ecId, const QString &id); | ||
3566 | 77 | |||
3567 | 78 | void startPlayingAudio(int scId, int ecId, const QString &id, const QString &src, QVariantMap options); | ||
3568 | 79 | void pausePlayingAudio(int scId, int ecId, const QString &id); | ||
3569 | 80 | void stopPlayingAudio(int scId, int ecId, const QString &id); | ||
3570 | 81 | void getCurrentPositionAudio(int scId, int ecId, const QString &id); | ||
3571 | 82 | void seekToAudio(int scId, int ecId, const QString &id, qint64 position); | ||
3572 | 83 | void setVolume(int scId, int ecId, const QString &id, int volume); | ||
3573 | 84 | |||
3574 | 85 | private: | ||
3575 | 86 | QMap<QString, QSharedPointer<Player> > _id2Player; | ||
3576 | 87 | }; | ||
3577 | 88 | |||
3578 | 89 | class Player: public QObject { | ||
3579 | 90 | Q_OBJECT | ||
3580 | 91 | public: | ||
3581 | 92 | Player(const QString &id, QString src, Media *plugin): | ||
3582 | 93 | _state(Media::MEDIA_NONE), | ||
3583 | 94 | _src(src), | ||
3584 | 95 | _mode(MODE_NONE), | ||
3585 | 96 | _plugin(plugin), | ||
3586 | 97 | _id(id), | ||
3587 | 98 | _stateChanged(false) { | ||
3588 | 99 | QUrl url(src, QUrl::TolerantMode); | ||
3589 | 100 | |||
3590 | 101 | if (url.scheme().isEmpty()) { | ||
3591 | 102 | QAudioEncoderSettings audioSettings; | ||
3592 | 103 | |||
3593 | 104 | _recorder.setEncodingSettings(audioSettings); | ||
3594 | 105 | _recorder.setOutputLocation(QFileInfo(src).absoluteFilePath()); | ||
3595 | 106 | |||
3596 | 107 | _player.setMedia(QUrl::fromLocalFile(QFileInfo(src).absoluteFilePath())); | ||
3597 | 108 | } else { | ||
3598 | 109 | _player.setMedia(url); | ||
3599 | 110 | } | ||
3600 | 111 | QObject::connect(&_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(onMediaStatusChanged(QMediaPlayer::MediaStatus))); | ||
3601 | 112 | QObject::connect(&_recorder, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(onError(QMediaRecorder::Error))); | ||
3602 | 113 | |||
3603 | 114 | connect(&_timer, SIGNAL(timeout()), this, SLOT(reportPosition())); | ||
3604 | 115 | } | ||
3605 | 116 | |||
3606 | 117 | void startRecording() { | ||
3607 | 118 | if (recordMode() && _state != Media::MEDIA_RUNNING) { | ||
3608 | 119 | _recorder.record(); | ||
3609 | 120 | setState(Media::MEDIA_RUNNING); | ||
3610 | 121 | } | ||
3611 | 122 | } | ||
3612 | 123 | void stopRecording() { | ||
3613 | 124 | if (recordMode() && _state == Media::MEDIA_RUNNING) { | ||
3614 | 125 | _recorder.stop(); | ||
3615 | 126 | setState(Media::MEDIA_STOPPED); | ||
3616 | 127 | } | ||
3617 | 128 | } | ||
3618 | 129 | |||
3619 | 130 | void setVolume(int volume) { | ||
3620 | 131 | _player.setVolume(volume); | ||
3621 | 132 | } | ||
3622 | 133 | |||
3623 | 134 | void play() { | ||
3624 | 135 | if (playMode() && _state != Media::MEDIA_RUNNING) { | ||
3625 | 136 | _player.play(); | ||
3626 | 137 | setState(Media::MEDIA_RUNNING); | ||
3627 | 138 | } | ||
3628 | 139 | } | ||
3629 | 140 | void pause() { | ||
3630 | 141 | if (playMode() && _state == Media::MEDIA_RUNNING) { | ||
3631 | 142 | _player.pause(); | ||
3632 | 143 | setState(Media::MEDIA_PAUSED); | ||
3633 | 144 | } | ||
3634 | 145 | } | ||
3635 | 146 | void stop() { | ||
3636 | 147 | if (playMode() && (_state == Media::MEDIA_RUNNING || _state == Media::MEDIA_PAUSED)) { | ||
3637 | 148 | _player.stop(); | ||
3638 | 149 | setState(Media::MEDIA_STOPPED); | ||
3639 | 150 | } | ||
3640 | 151 | } | ||
3641 | 152 | double getDuration() { | ||
3642 | 153 | if (_mode == MODE_NONE || _player.duration() == -1) | ||
3643 | 154 | return -1; | ||
3644 | 155 | if (_mode != MODE_PLAY) | ||
3645 | 156 | return -2; | ||
3646 | 157 | return static_cast<double>(_player.duration()) / 1000.0; | ||
3647 | 158 | } | ||
3648 | 159 | double getPosition() { | ||
3649 | 160 | if (_mode != MODE_PLAY) | ||
3650 | 161 | return -1; | ||
3651 | 162 | return static_cast<double>(_player.position()) / 1000.0; | ||
3652 | 163 | } | ||
3653 | 164 | bool seekTo(qint64 position) { | ||
3654 | 165 | if (!_player.isSeekable()) | ||
3655 | 166 | return false; | ||
3656 | 167 | _player.setPosition(position * 1000); | ||
3657 | 168 | return true; | ||
3658 | 169 | } | ||
3659 | 170 | private slots: | ||
3660 | 171 | void reportPosition() { | ||
3661 | 172 | double position = getPosition(); | ||
3662 | 173 | _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_POSITION, %2)") | ||
3663 | 174 | .arg(_id).arg(position)); | ||
3664 | 175 | double duration = getDuration(); | ||
3665 | 176 | _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_DURATION, %2)") | ||
3666 | 177 | .arg(_id).arg(duration)); | ||
3667 | 178 | |||
3668 | 179 | if (_stateChanged && !(_state == Media::MEDIA_RUNNING && (duration == -1 || position == 0))) { | ||
3669 | 180 | qCritical() << _id << "POSITION" << position << ":" << duration; | ||
3670 | 181 | _stateChanged = false; | ||
3671 | 182 | _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_STATE, %2)").arg(_id).arg(_state)); | ||
3672 | 183 | } | ||
3673 | 184 | } | ||
3674 | 185 | |||
3675 | 186 | void onMediaStatusChanged(QMediaPlayer::MediaStatus status) { | ||
3676 | 187 | if (status == QMediaPlayer::InvalidMedia) { | ||
3677 | 188 | reportError(Media::MEDIA_ERR_ABORTED, "AudioPlayer Error: The current media cannot be played."); | ||
3678 | 189 | setState(Media::MEDIA_STOPPED); | ||
3679 | 190 | } | ||
3680 | 191 | if (status == QMediaPlayer::EndOfMedia) { | ||
3681 | 192 | setState(Media::MEDIA_STOPPED); | ||
3682 | 193 | seekTo(0); | ||
3683 | 194 | } | ||
3684 | 195 | } | ||
3685 | 196 | void onError(QMediaRecorder::Error) { | ||
3686 | 197 | reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: Device is not ready or not available."); | ||
3687 | 198 | setState(Media::MEDIA_STOPPED); | ||
3688 | 199 | } | ||
3689 | 200 | |||
3690 | 201 | private: | ||
3691 | 202 | void reportError(int code, const QString &descr) { | ||
3692 | 203 | Q_UNUSED(descr); | ||
3693 | 204 | _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_ERROR, {code: %2})") | ||
3694 | 205 | .arg(_id).arg(code)); | ||
3695 | 206 | } | ||
3696 | 207 | |||
3697 | 208 | bool playMode() { | ||
3698 | 209 | switch (_mode) { | ||
3699 | 210 | case Player::MODE_NONE: | ||
3700 | 211 | _mode = MODE_PLAY; | ||
3701 | 212 | break; | ||
3702 | 213 | case Player::MODE_PLAY: | ||
3703 | 214 | break; | ||
3704 | 215 | case Player::MODE_RECORD: | ||
3705 | 216 | reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: Can't play in record mode."); | ||
3706 | 217 | return false; | ||
3707 | 218 | break; | ||
3708 | 219 | } | ||
3709 | 220 | return true; | ||
3710 | 221 | } | ||
3711 | 222 | |||
3712 | 223 | bool recordMode() { | ||
3713 | 224 | switch (_mode) { | ||
3714 | 225 | case Player::MODE_NONE: | ||
3715 | 226 | if (_recorder.outputLocation().isEmpty()) { | ||
3716 | 227 | reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: unsupported output location."); | ||
3717 | 228 | return false; | ||
3718 | 229 | } | ||
3719 | 230 | _mode = MODE_RECORD; | ||
3720 | 231 | break; | ||
3721 | 232 | case Player::MODE_PLAY: | ||
3722 | 233 | reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: Can't play in play mode."); | ||
3723 | 234 | return false; | ||
3724 | 235 | break; | ||
3725 | 236 | case Player::MODE_RECORD: | ||
3726 | 237 | break; | ||
3727 | 238 | } | ||
3728 | 239 | return true; | ||
3729 | 240 | } | ||
3730 | 241 | |||
3731 | 242 | void setState(Media::State state) { | ||
3732 | 243 | _state = state; | ||
3733 | 244 | _stateChanged = true; | ||
3734 | 245 | _timer.start(250); | ||
3735 | 246 | } | ||
3736 | 247 | |||
3737 | 248 | QMediaPlayer _player; | ||
3738 | 249 | |||
3739 | 250 | QAudioRecorder _recorder; | ||
3740 | 251 | QTimer _timer; | ||
3741 | 252 | |||
3742 | 253 | Media::State _state; | ||
3743 | 254 | QString _src; | ||
3744 | 255 | enum Mode { | ||
3745 | 256 | MODE_NONE, | ||
3746 | 257 | MODE_PLAY, | ||
3747 | 258 | MODE_RECORD | ||
3748 | 259 | }; | ||
3749 | 260 | Mode _mode; | ||
3750 | 261 | Media *_plugin; | ||
3751 | 262 | QString _id; | ||
3752 | 263 | |||
3753 | 264 | bool _stateChanged; | ||
3754 | 265 | }; | ||
3755 | 266 | |||
3756 | 267 | #endif | ||
3757 | 0 | 268 | ||
3758 | === added directory 'build/src/plugins/org.apache.cordova.splashscreen' | |||
3759 | === added file 'build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp' | |||
3760 | --- build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp 1970-01-01 00:00:00 +0000 | |||
3761 | +++ build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp 2014-02-19 16:53:58 +0000 | |||
3762 | @@ -0,0 +1,42 @@ | |||
3763 | 1 | /* | ||
3764 | 2 | * | ||
3765 | 3 | * Copyright 2013 Canonical Ltd. | ||
3766 | 4 | * | ||
3767 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
3768 | 6 | * or more contributor license agreements. See the NOTICE file | ||
3769 | 7 | * distributed with this work for additional information | ||
3770 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
3771 | 9 | * to you under the Apache License, Version 2.0 (the | ||
3772 | 10 | * "License"); you may not use this file except in compliance | ||
3773 | 11 | * with the License. You may obtain a copy of the License at | ||
3774 | 12 | * | ||
3775 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3776 | 14 | * | ||
3777 | 15 | * Unless required by applicable law or agreed to in writing, | ||
3778 | 16 | * software distributed under the License is distributed on an | ||
3779 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3780 | 18 | * KIND, either express or implied. See the License for the | ||
3781 | 19 | * specific language governing permissions and limitations | ||
3782 | 20 | * under the License. | ||
3783 | 21 | * | ||
3784 | 22 | */ | ||
3785 | 23 | |||
3786 | 24 | #include <QQuickItem> | ||
3787 | 25 | |||
3788 | 26 | #include "splashscreen.h" | ||
3789 | 27 | #include <cordova.h> | ||
3790 | 28 | |||
3791 | 29 | #define SPLASHSCREEN_STATE_NAME "splashscreen" | ||
3792 | 30 | |||
3793 | 31 | Splashscreen::Splashscreen(Cordova *cordova): CPlugin(cordova) { | ||
3794 | 32 | } | ||
3795 | 33 | |||
3796 | 34 | void Splashscreen::show(int, int) { | ||
3797 | 35 | m_cordova->rootObject()->setProperty("splashscreenPath", m_cordova->getSplashscreenPath()); | ||
3798 | 36 | |||
3799 | 37 | m_cordova->pushViewState(SPLASHSCREEN_STATE_NAME); | ||
3800 | 38 | } | ||
3801 | 39 | |||
3802 | 40 | void Splashscreen::hide(int, int) { | ||
3803 | 41 | m_cordova->popViewState(SPLASHSCREEN_STATE_NAME); | ||
3804 | 42 | } | ||
3805 | 0 | 43 | ||
3806 | === added file 'build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h' | |||
3807 | --- build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h 1970-01-01 00:00:00 +0000 | |||
3808 | +++ build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h 2014-02-19 16:53:58 +0000 | |||
3809 | @@ -0,0 +1,52 @@ | |||
3810 | 1 | /* | ||
3811 | 2 | * | ||
3812 | 3 | * Copyright 2013 Canonical Ltd. | ||
3813 | 4 | * | ||
3814 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
3815 | 6 | * or more contributor license agreements. See the NOTICE file | ||
3816 | 7 | * distributed with this work for additional information | ||
3817 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
3818 | 9 | * to you under the Apache License, Version 2.0 (the | ||
3819 | 10 | * "License"); you may not use this file except in compliance | ||
3820 | 11 | * with the License. You may obtain a copy of the License at | ||
3821 | 12 | * | ||
3822 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3823 | 14 | * | ||
3824 | 15 | * Unless required by applicable law or agreed to in writing, | ||
3825 | 16 | * software distributed under the License is distributed on an | ||
3826 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3827 | 18 | * KIND, either express or implied. See the License for the | ||
3828 | 19 | * specific language governing permissions and limitations | ||
3829 | 20 | * under the License. | ||
3830 | 21 | * | ||
3831 | 22 | */ | ||
3832 | 23 | |||
3833 | 24 | #ifndef SPLASHSCREEN_H | ||
3834 | 25 | #define SPLASHSCREEN_H | ||
3835 | 26 | |||
3836 | 27 | #include <QtCore> | ||
3837 | 28 | #include <cplugin.h> | ||
3838 | 29 | |||
3839 | 30 | class Splashscreen: public CPlugin { | ||
3840 | 31 | Q_OBJECT | ||
3841 | 32 | public: | ||
3842 | 33 | explicit Splashscreen(Cordova *cordova); | ||
3843 | 34 | |||
3844 | 35 | virtual const QString fullName() override { | ||
3845 | 36 | return Splashscreen::fullID(); | ||
3846 | 37 | } | ||
3847 | 38 | |||
3848 | 39 | virtual const QString shortName() override { | ||
3849 | 40 | return "SplashScreen"; | ||
3850 | 41 | } | ||
3851 | 42 | |||
3852 | 43 | static const QString fullID() { | ||
3853 | 44 | return "SplashScreen"; | ||
3854 | 45 | } | ||
3855 | 46 | |||
3856 | 47 | public slots: | ||
3857 | 48 | void show(int, int); | ||
3858 | 49 | void hide(int, int); | ||
3859 | 50 | }; | ||
3860 | 51 | |||
3861 | 52 | #endif // SPLASHSCREEN_H | ||
3862 | 0 | 53 | ||
3863 | === added directory 'build/src/plugins/org.apache.cordova.vibration' | |||
3864 | === added file 'build/src/plugins/org.apache.cordova.vibration/vibration.cpp' | |||
3865 | --- build/src/plugins/org.apache.cordova.vibration/vibration.cpp 1970-01-01 00:00:00 +0000 | |||
3866 | +++ build/src/plugins/org.apache.cordova.vibration/vibration.cpp 2014-02-19 16:53:58 +0000 | |||
3867 | @@ -0,0 +1,38 @@ | |||
3868 | 1 | /* | ||
3869 | 2 | * | ||
3870 | 3 | * Copyright 2013 Canonical Ltd. | ||
3871 | 4 | * | ||
3872 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3873 | 6 | * you may not use this file except in compliance with the License. | ||
3874 | 7 | * You may obtain a copy of the License at | ||
3875 | 8 | * | ||
3876 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3877 | 10 | * | ||
3878 | 11 | * Unless required by applicable law or agreed to in writing, | ||
3879 | 12 | * software distributed under the License is distributed on an | ||
3880 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3881 | 14 | * KIND, either express or implied. See the License for the | ||
3882 | 15 | * specific language governing permissions and limitations | ||
3883 | 16 | * under the License. | ||
3884 | 17 | * | ||
3885 | 18 | */ | ||
3886 | 19 | |||
3887 | 20 | #include <QFeedbackHapticsEffect> | ||
3888 | 21 | #include "vibration.h" | ||
3889 | 22 | |||
3890 | 23 | void Vibration::vibrate(int, int, int mills) { | ||
3891 | 24 | QFeedbackHapticsEffect *vibrate = new QFeedbackHapticsEffect; | ||
3892 | 25 | vibrate->setIntensity(1.0); | ||
3893 | 26 | vibrate->setDuration(mills); | ||
3894 | 27 | |||
3895 | 28 | connect(vibrate, &QFeedbackHapticsEffect::stateChanged, [&]() { | ||
3896 | 29 | QFeedbackEffect *effect = qobject_cast<QFeedbackEffect *>(sender()); | ||
3897 | 30 | if (!effect) | ||
3898 | 31 | return; | ||
3899 | 32 | if (effect->state() == QFeedbackEffect::Stopped) | ||
3900 | 33 | effect->deleteLater(); | ||
3901 | 34 | }); | ||
3902 | 35 | |||
3903 | 36 | vibrate->start(); | ||
3904 | 37 | } | ||
3905 | 38 | |||
3906 | 0 | 39 | ||
3907 | === added file 'build/src/plugins/org.apache.cordova.vibration/vibration.h' | |||
3908 | --- build/src/plugins/org.apache.cordova.vibration/vibration.h 1970-01-01 00:00:00 +0000 | |||
3909 | +++ build/src/plugins/org.apache.cordova.vibration/vibration.h 2014-02-19 16:53:58 +0000 | |||
3910 | @@ -0,0 +1,47 @@ | |||
3911 | 1 | /* | ||
3912 | 2 | * | ||
3913 | 3 | * Copyright 2013 Canonical Ltd. | ||
3914 | 4 | * | ||
3915 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3916 | 6 | * you may not use this file except in compliance with the License. | ||
3917 | 7 | * You may obtain a copy of the License at | ||
3918 | 8 | * | ||
3919 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3920 | 10 | * | ||
3921 | 11 | * Unless required by applicable law or agreed to in writing, | ||
3922 | 12 | * software distributed under the License is distributed on an | ||
3923 | 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
3924 | 14 | * KIND, either express or implied. See the License for the | ||
3925 | 15 | * specific language governing permissions and limitations | ||
3926 | 16 | * under the License. | ||
3927 | 17 | * | ||
3928 | 18 | */ | ||
3929 | 19 | |||
3930 | 20 | #ifndef _VIBRATION_H_SFAFKNVX3456 | ||
3931 | 21 | #define _VIBRATION_H_SFAFKNVX3456 | ||
3932 | 22 | |||
3933 | 23 | #include <QtQuick> | ||
3934 | 24 | #include <cplugin.h> | ||
3935 | 25 | |||
3936 | 26 | class Vibration: public CPlugin { | ||
3937 | 27 | Q_OBJECT | ||
3938 | 28 | public: | ||
3939 | 29 | explicit Vibration(Cordova *cordova): CPlugin(cordova) { | ||
3940 | 30 | } | ||
3941 | 31 | |||
3942 | 32 | virtual const QString fullName() override { | ||
3943 | 33 | return Vibration::fullID(); | ||
3944 | 34 | } | ||
3945 | 35 | |||
3946 | 36 | virtual const QString shortName() override { | ||
3947 | 37 | return "Vibration"; | ||
3948 | 38 | } | ||
3949 | 39 | |||
3950 | 40 | static const QString fullID() { | ||
3951 | 41 | return "Vibration"; | ||
3952 | 42 | } | ||
3953 | 43 | public slots: | ||
3954 | 44 | void vibrate(int, int, int mills); | ||
3955 | 45 | }; | ||
3956 | 46 | |||
3957 | 47 | #endif | ||
3958 | 0 | 48 | ||
3959 | === modified file 'config.xml' | |||
3960 | --- config.xml 2014-02-05 23:42:31 +0000 | |||
3961 | +++ config.xml 2014-02-19 16:53:58 +0000 | |||
3962 | @@ -1,5 +1,24 @@ | |||
3963 | 1 | <?xml version='1.0' encoding='utf-8'?> | 1 | <?xml version='1.0' encoding='utf-8'?> |
3964 | 2 | <widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> | 2 | <widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> |
3965 | 3 | <preference name="loglevel" value="DEBUG" /> | ||
3966 | 4 | <feature name="Camera"> | ||
3967 | 5 | <param policy_group="camera" policy_version="1" /> | ||
3968 | 6 | </feature> | ||
3969 | 7 | <feature name="DeviceOrientation"> | ||
3970 | 8 | <param policy_group="sensors" policy_version="1" /> | ||
3971 | 9 | </feature> | ||
3972 | 10 | <feature name="Geolocation"> | ||
3973 | 11 | <param policy_group="location" policy_version="1" /> | ||
3974 | 12 | </feature> | ||
3975 | 13 | <feature name="Media"> | ||
3976 | 14 | <param policy_group="microphone" policy_version="1" /> | ||
3977 | 15 | <param policy_group="video" policy_version="1" /> | ||
3978 | 16 | </feature> | ||
3979 | 17 | <feature name="Capture"> | ||
3980 | 18 | <param policy_group="audio" policy_version="1" /> | ||
3981 | 19 | <param policy_group="camera" policy_version="1" /> | ||
3982 | 20 | <param policy_group="microphone" policy_version="1" /> | ||
3983 | 21 | </feature> | ||
3984 | 3 | <name>HelloCordova</name> | 22 | <name>HelloCordova</name> |
3985 | 4 | <description> | 23 | <description> |
3986 | 5 | A sample Apache Cordova application that responds to the deviceready event. | 24 | A sample Apache Cordova application that responds to the deviceready event. |
3987 | 6 | 25 | ||
3988 | === modified file 'debian/changelog' | |||
3989 | --- debian/changelog 2014-02-18 10:03:39 +0000 | |||
3990 | +++ debian/changelog 2014-02-19 16:53:58 +0000 | |||
3991 | @@ -1,3 +1,9 @@ | |||
3992 | 1 | cordova-ubuntu-3.4 (3.4~pre3.r17ubuntu2) trusty; urgency=low | ||
3993 | 2 | |||
3994 | 3 | * Test build with additional plugins | ||
3995 | 4 | |||
3996 | 5 | -- David Barth <david.barth@canonical.com> Wed, 19 Feb 2014 17:48:58 +0100 | ||
3997 | 6 | |||
3998 | 1 | cordova-ubuntu-3.4 (3.4~pre3.r17) trusty; urgency=medium | 7 | cordova-ubuntu-3.4 (3.4~pre3.r17) trusty; urgency=medium |
3999 | 2 | 8 | ||
4000 | 3 | [ Alexandre Abreu ] | 9 | [ Alexandre Abreu ] |
4001 | @@ -11,6 +17,12 @@ | |||
4002 | 11 | 17 | ||
4003 | 12 | -- Daniel Holbach <daniel.holbach@ubuntu.com> Fri, 14 Feb 2014 10:21:43 +0100 | 18 | -- Daniel Holbach <daniel.holbach@ubuntu.com> Fri, 14 Feb 2014 10:21:43 +0100 |
4004 | 13 | 19 | ||
4005 | 20 | cordova-ubuntu-3.4 (3.4~pre3ubuntu1) UNRELEASED; urgency=low | ||
4006 | 21 | |||
4007 | 22 | * Add the full set of platform plugins | ||
4008 | 23 | |||
4009 | 24 | -- David Barth <david.barth@canonical.com> Fri, 14 Feb 2014 16:17:05 +0100 | ||
4010 | 25 | |||
4011 | 14 | cordova-ubuntu-3.4 (3.4~pre3) trusty; urgency=low | 26 | cordova-ubuntu-3.4 (3.4~pre3) trusty; urgency=low |
4012 | 15 | 27 | ||
4013 | 16 | * Trusty build | 28 | * Trusty build |
4014 | 17 | 29 | ||
4015 | === modified file 'debian/control' | |||
4016 | --- debian/control 2014-02-17 16:24:58 +0000 | |||
4017 | +++ debian/control 2014-02-19 16:53:58 +0000 | |||
4018 | @@ -28,8 +28,10 @@ | |||
4019 | 28 | Architecture: any | 28 | Architecture: any |
4020 | 29 | Depends: ${misc:Depends}, | 29 | Depends: ${misc:Depends}, |
4021 | 30 | ${shlibs:Depends}, | 30 | ${shlibs:Depends}, |
4024 | 31 | Description: Ubuntu HTML5 Framework for building mobile web apps - development files | 31 | Description: Cordova Framework for building mobile web apps - development files |
4025 | 32 | This package contains files that are needed to build applications. | 32 | Cordova is a free and open source framework that allows you to create mobile |
4026 | 33 | apps using standardized web APIs for the platforms you care about. | ||
4027 | 33 | . | 34 | . |
4030 | 34 | They are not meant to be used locally, but are embedded in the resulting | 35 | This package contains library files that are needed to build applications. |
4031 | 35 | click packages. | 36 | The libraries are not meant to be installed on the system, but should be |
4032 | 37 | embedded in a click package. | ||
4033 | 36 | 38 | ||
4034 | === modified file 'debian/rules' | |||
4035 | --- debian/rules 2014-02-17 16:24:58 +0000 | |||
4036 | +++ debian/rules 2014-02-19 16:53:58 +0000 | |||
4037 | @@ -1,12 +1,33 @@ | |||
4038 | 1 | #!/usr/bin/make -f | 1 | #!/usr/bin/make -f |
4039 | 2 | # -*- makefile -*- | 2 | # -*- makefile -*- |
4040 | 3 | 3 | ||
4041 | 4 | # to update the source tree: | ||
4042 | 5 | # create a temporary directory to construct the runtime with the cordova CLI tool | ||
4043 | 6 | # cordova create runtime | ||
4044 | 7 | # cd runtime | ||
4045 | 8 | # cordova platform add ubuntu | ||
4046 | 9 | # cordova plugin add org.apache.cordova.camera | ||
4047 | 10 | # cordova plugin add <other plugins> | ||
4048 | 11 | # ... | ||
4049 | 12 | # cordova prepare | ||
4050 | 13 | # then copy back files from the platforms/ubuntu directory | ||
4051 | 14 | |||
4052 | 4 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) | 15 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) |
4053 | 16 | INSTALL_PREFIX="/usr/share/ubuntu-html5-platform-3.4/${DEB_HOST_MULTIARCH}" | ||
4054 | 17 | PACKAGE_NAME=ubuntu-html5-platform-3.4-dev | ||
4055 | 5 | 18 | ||
4056 | 6 | override_dh_auto_configure: | 19 | override_dh_auto_configure: |
4058 | 7 | cd build; cmake -DCMAKE_INSTALL_PREFIX=/usr/share/ubuntu-html5-platform-3.4/${DEB_HOST_MULTIARCH} \ | 20 | cd build; cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \ |
4059 | 8 | -DCMAKE_VERBOSE_MAKEFILE=ON \ | 21 | -DCMAKE_VERBOSE_MAKEFILE=ON \ |
4060 | 9 | -DCMAKE_BUILD_TYPE=RelWithDebInfo | 22 | -DCMAKE_BUILD_TYPE=RelWithDebInfo |
4061 | 10 | 23 | ||
4062 | 24 | override_dh_install: | ||
4063 | 25 | dh_install | ||
4064 | 26 | cp -R www debian/${PACKAGE_NAME}/${INSTALL_PREFIX}/; \ | ||
4065 | 27 | cp -R qml debian/${PACKAGE_NAME}/${INSTALL_PREFIX}/; \ | ||
4066 | 28 | rm -f debian/${PACKAGE_NAME}/${INSTALL_PREFIX}/cordova-ubuntu | ||
4067 | 29 | |||
4068 | 30 | override_dh_strip: | ||
4069 | 31 | |||
4070 | 11 | %: | 32 | %: |
4071 | 12 | dh $@ --sourcedirectory=build --fail-missing | 33 | dh $@ --sourcedirectory=build --fail-missing |
4072 | 13 | 34 | ||
4073 | === added directory 'qml' | |||
4074 | === added file 'qml/CaptureWidget.qml' | |||
4075 | --- qml/CaptureWidget.qml 1970-01-01 00:00:00 +0000 | |||
4076 | +++ qml/CaptureWidget.qml 2014-02-19 16:53:58 +0000 | |||
4077 | @@ -0,0 +1,119 @@ | |||
4078 | 1 | /* | ||
4079 | 2 | * | ||
4080 | 3 | * Copyright 2013 Canonical Ltd. | ||
4081 | 4 | * | ||
4082 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
4083 | 6 | * or more contributor license agreements. See the NOTICE file | ||
4084 | 7 | * distributed with this work for additional information | ||
4085 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
4086 | 9 | * to you under the Apache License, Version 2.0 (the | ||
4087 | 10 | * "License"); you may not use this file except in compliance | ||
4088 | 11 | * with the License. You may obtain a copy of the License at | ||
4089 | 12 | * | ||
4090 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
4091 | 14 | * | ||
4092 | 15 | * Unless required by applicable law or agreed to in writing, | ||
4093 | 16 | * software distributed under the License is distributed on an | ||
4094 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
4095 | 18 | * KIND, either express or implied. See the License for the | ||
4096 | 19 | * specific language governing permissions and limitations | ||
4097 | 20 | * under the License. | ||
4098 | 21 | * | ||
4099 | 22 | */ | ||
4100 | 23 | import QtQuick 2.0 | ||
4101 | 24 | import QtMultimedia 5.0 | ||
4102 | 25 | |||
4103 | 26 | Rectangle { | ||
4104 | 27 | property string shootImagePath: "shoot.png" | ||
4105 | 28 | function isSuffix(str, suffix) { | ||
4106 | 29 | return String(str).substr(String(str).length - suffix.length) == suffix | ||
4107 | 30 | } | ||
4108 | 31 | |||
4109 | 32 | id: ui | ||
4110 | 33 | color: "#252423" | ||
4111 | 34 | anchors.fill: parent | ||
4112 | 35 | |||
4113 | 36 | Camera { | ||
4114 | 37 | objectName: "camera" | ||
4115 | 38 | id: camera | ||
4116 | 39 | onError: { | ||
4117 | 40 | console.log(errorString); | ||
4118 | 41 | } | ||
4119 | 42 | videoRecorder.audioBitRate: 128000 | ||
4120 | 43 | videoRecorder.mediaContainer: "mp4" | ||
4121 | 44 | imageCapture { | ||
4122 | 45 | onImageSaved: { | ||
4123 | 46 | root.exec("Camera", "onImageSaved", [path]); | ||
4124 | 47 | ui.destroy(); | ||
4125 | 48 | } | ||
4126 | 49 | } | ||
4127 | 50 | } | ||
4128 | 51 | VideoOutput { | ||
4129 | 52 | id: output | ||
4130 | 53 | source: camera | ||
4131 | 54 | width: parent.width | ||
4132 | 55 | height: parent.height | ||
4133 | 56 | } | ||
4134 | 57 | |||
4135 | 58 | Item { | ||
4136 | 59 | anchors.bottom: parent.bottom | ||
4137 | 60 | width: parent.width | ||
4138 | 61 | height: shootButton.height | ||
4139 | 62 | BorderImage { | ||
4140 | 63 | id: leftBackground | ||
4141 | 64 | anchors.left: parent.left | ||
4142 | 65 | anchors.top: parent.top | ||
4143 | 66 | anchors.bottom: parent.bottom | ||
4144 | 67 | anchors.right: middle.left | ||
4145 | 68 | anchors.topMargin: units.dp(2) | ||
4146 | 69 | anchors.bottomMargin: units.dp(2) | ||
4147 | 70 | source: "toolbar-left.png" | ||
4148 | 71 | Image { | ||
4149 | 72 | anchors.verticalCenter: parent.verticalCenter | ||
4150 | 73 | anchors.left: parent.left | ||
4151 | 74 | anchors.leftMargin: parent.iconSpacing | ||
4152 | 75 | source: "back.png" | ||
4153 | 76 | width: units.gu(6) | ||
4154 | 77 | height: units.gu(5) | ||
4155 | 78 | MouseArea { | ||
4156 | 79 | anchors.fill: parent | ||
4157 | 80 | onClicked: { | ||
4158 | 81 | root.exec("Camera", "cancel"); | ||
4159 | 82 | } | ||
4160 | 83 | } | ||
4161 | 84 | } | ||
4162 | 85 | } | ||
4163 | 86 | BorderImage { | ||
4164 | 87 | id: middle | ||
4165 | 88 | anchors.top: parent.top | ||
4166 | 89 | anchors.bottom: parent.bottom | ||
4167 | 90 | anchors.horizontalCenter: parent.horizontalCenter | ||
4168 | 91 | height: shootButton.height + units.gu(1) | ||
4169 | 92 | width: shootButton.width | ||
4170 | 93 | source: "toolbar-middle.png" | ||
4171 | 94 | Image { | ||
4172 | 95 | id: shootButton | ||
4173 | 96 | width: units.gu(8) | ||
4174 | 97 | height: width | ||
4175 | 98 | anchors.horizontalCenter: parent.horizontalCenter | ||
4176 | 99 | source: shootImagePath | ||
4177 | 100 | MouseArea { | ||
4178 | 101 | anchors.fill: parent | ||
4179 | 102 | onClicked: { | ||
4180 | 103 | camera.imageCapture.capture(); | ||
4181 | 104 | } | ||
4182 | 105 | } | ||
4183 | 106 | } | ||
4184 | 107 | } | ||
4185 | 108 | BorderImage { | ||
4186 | 109 | id: rightBackground | ||
4187 | 110 | anchors.right: parent.right | ||
4188 | 111 | anchors.top: parent.top | ||
4189 | 112 | anchors.bottom: parent.bottom | ||
4190 | 113 | anchors.left: middle.right | ||
4191 | 114 | anchors.topMargin: units.dp(2) | ||
4192 | 115 | anchors.bottomMargin: units.dp(2) | ||
4193 | 116 | source: "toolbar-right.png" | ||
4194 | 117 | } | ||
4195 | 118 | } | ||
4196 | 119 | } | ||
4197 | 0 | 120 | ||
4198 | === added file 'qml/InAppBrowser.qml' | |||
4199 | --- qml/InAppBrowser.qml 1970-01-01 00:00:00 +0000 | |||
4200 | +++ qml/InAppBrowser.qml 2014-02-19 16:53:58 +0000 | |||
4201 | @@ -0,0 +1,69 @@ | |||
4202 | 1 | /* | ||
4203 | 2 | * | ||
4204 | 3 | * Copyright 2013 Canonical Ltd. | ||
4205 | 4 | * | ||
4206 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
4207 | 6 | * or more contributor license agreements. See the NOTICE file | ||
4208 | 7 | * distributed with this work for additional information | ||
4209 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
4210 | 9 | * to you under the Apache License, Version 2.0 (the | ||
4211 | 10 | * "License"); you may not use this file except in compliance | ||
4212 | 11 | * with the License. You may obtain a copy of the License at | ||
4213 | 12 | * | ||
4214 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
4215 | 14 | * | ||
4216 | 15 | * Unless required by applicable law or agreed to in writing, | ||
4217 | 16 | * software distributed under the License is distributed on an | ||
4218 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
4219 | 18 | * KIND, either express or implied. See the License for the | ||
4220 | 19 | * specific language governing permissions and limitations | ||
4221 | 20 | * under the License. | ||
4222 | 21 | * | ||
4223 | 22 | */ | ||
4224 | 23 | import QtQuick 2.0 | ||
4225 | 24 | import QtWebKit 3.0 | ||
4226 | 25 | import Ubuntu.Components.Popups 0.1 | ||
4227 | 26 | import Ubuntu.Components 0.1 | ||
4228 | 27 | |||
4229 | 28 | Rectangle { | ||
4230 | 29 | anchors.fill: parent | ||
4231 | 30 | id: inappbrowser | ||
4232 | 31 | property string url1 | ||
4233 | 32 | Rectangle { | ||
4234 | 33 | border.color: "black" | ||
4235 | 34 | width: parent.width | ||
4236 | 35 | height: urlEntry.height | ||
4237 | 36 | color: "gray" | ||
4238 | 37 | TextInput { | ||
4239 | 38 | id: urlEntry | ||
4240 | 39 | width: parent.width - closeButton.width | ||
4241 | 40 | text: url1 | ||
4242 | 41 | activeFocusOnPress: false | ||
4243 | 42 | } | ||
4244 | 43 | Image { | ||
4245 | 44 | id: closeButton | ||
4246 | 45 | width: height | ||
4247 | 46 | x: parent.width - width | ||
4248 | 47 | height: parent.height | ||
4249 | 48 | source: "close.png" | ||
4250 | 49 | MouseArea { | ||
4251 | 50 | anchors.fill: parent | ||
4252 | 51 | onClicked: { | ||
4253 | 52 | root.exec("InAppBrowser", "close", [0, 0]) | ||
4254 | 53 | } | ||
4255 | 54 | } | ||
4256 | 55 | } | ||
4257 | 56 | } | ||
4258 | 57 | |||
4259 | 58 | WebView { | ||
4260 | 59 | width: parent.width | ||
4261 | 60 | y: urlEntry.height | ||
4262 | 61 | height: parent.height - y | ||
4263 | 62 | url: url1 | ||
4264 | 63 | onLoadingChanged: { | ||
4265 | 64 | if (loadRequest.status) { | ||
4266 | 65 | root.exec("InAppBrowser", "loadFinished", [loadRequest.status]) | ||
4267 | 66 | } | ||
4268 | 67 | } | ||
4269 | 68 | } | ||
4270 | 69 | } | ||
4271 | 0 | 70 | ||
4272 | === added file 'qml/MediaCaptureWidget.qml' | |||
4273 | --- qml/MediaCaptureWidget.qml 1970-01-01 00:00:00 +0000 | |||
4274 | +++ qml/MediaCaptureWidget.qml 2014-02-19 16:53:58 +0000 | |||
4275 | @@ -0,0 +1,207 @@ | |||
4276 | 1 | /* | ||
4277 | 2 | * | ||
4278 | 3 | * Copyright 2013 Canonical Ltd. | ||
4279 | 4 | * | ||
4280 | 5 | * Licensed to the Apache Software Foundation (ASF) under one | ||
4281 | 6 | * or more contributor license agreements. See the NOTICE file | ||
4282 | 7 | * distributed with this work for additional information | ||
4283 | 8 | * regarding copyright ownership. The ASF licenses this file | ||
4284 | 9 | * to you under the Apache License, Version 2.0 (the | ||
4285 | 10 | * "License"); you may not use this file except in compliance | ||
4286 | 11 | * with the License. You may obtain a copy of the License at | ||
4287 | 12 | * | ||
4288 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
4289 | 14 | * | ||
4290 | 15 | * Unless required by applicable law or agreed to in writing, | ||
4291 | 16 | * software distributed under the License is distributed on an | ||
4292 | 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
4293 | 18 | * KIND, either express or implied. See the License for the | ||
4294 | 19 | * specific language governing permissions and limitations | ||
4295 | 20 | * under the License. | ||
4296 | 21 | * | ||
4297 | 22 | */ | ||
4298 | 23 | import QtQuick 2.0 | ||
4299 | 24 | import QtMultimedia 5.0 | ||
4300 | 25 | |||
4301 | 26 | Rectangle { | ||
4302 | 27 | property string recordOffImagePath: "record_off.png" | ||
4303 | 28 | property string recordOnImagePath: "record_on.png" | ||
4304 | 29 | property string shootImagePath: "shoot.png" | ||
4305 | 30 | function isSuffix(str, suffix) { | ||
4306 | 31 | return String(str).substr(String(str).length - suffix.length) == suffix | ||
4307 | 32 | } | ||
4308 | 33 | |||
4309 | 34 | id: ui | ||
4310 | 35 | color: "#252423" | ||
4311 | 36 | anchors.fill: parent | ||
4312 | 37 | state: "off" | ||
4313 | 38 | |||
4314 | 39 | Camera { | ||
4315 | 40 | objectName: "camera" | ||
4316 | 41 | id: camera | ||
4317 | 42 | cameraState: Camera.UnloadedState | ||
4318 | 43 | onError: { | ||
4319 | 44 | console.log(errorString); | ||
4320 | 45 | shootButton.source = recordOffImagePath | ||
4321 | 46 | } | ||
4322 | 47 | imageCapture { | ||
4323 | 48 | onImageSaved: { | ||
4324 | 49 | root.exec("Capture", "onImageSaved", [path]); | ||
4325 | 50 | ui.destroy(); | ||
4326 | 51 | } | ||
4327 | 52 | } | ||
4328 | 53 | videoRecorder { | ||
4329 | 54 | audioBitRate: 128000 | ||
4330 | 55 | mediaContainer: "mp4" | ||
4331 | 56 | outputLocation: ui.parent.plugin('Capture').generateLocation("mp4") | ||
4332 | 57 | onRecorderStateChanged: { | ||
4333 | 58 | if (videoRecorder.recorderState === CameraRecorder.StoppedState) { | ||
4334 | 59 | ui.parent.exec("Capture", "onVideoRecordEnd", [camera.videoRecorder.actualLocation]); | ||
4335 | 60 | shootButton.source = recordOffImagePath | ||
4336 | 61 | } | ||
4337 | 62 | } | ||
4338 | 63 | } | ||
4339 | 64 | } | ||
4340 | 65 | Image { | ||
4341 | 66 | id: microphoneImage | ||
4342 | 67 | source: "microphone.png" | ||
4343 | 68 | smooth: true | ||
4344 | 69 | visible: false | ||
4345 | 70 | width: parent.width | ||
4346 | 71 | height: parent.height | ||
4347 | 72 | } | ||
4348 | 73 | VideoOutput { | ||
4349 | 74 | id: output | ||
4350 | 75 | focus : visible | ||
4351 | 76 | source: camera | ||
4352 | 77 | width: parent.width | ||
4353 | 78 | height: parent.height | ||
4354 | 79 | } | ||
4355 | 80 | |||
4356 | 81 | Item { | ||
4357 | 82 | anchors.bottom: parent.bottom | ||
4358 | 83 | width: parent.width | ||
4359 | 84 | height: shootButton.height | ||
4360 | 85 | BorderImage { | ||
4361 | 86 | id: leftBackground | ||
4362 | 87 | anchors.left: parent.left | ||
4363 | 88 | anchors.top: parent.top | ||
4364 | 89 | anchors.bottom: parent.bottom | ||
4365 | 90 | anchors.right: middle.left | ||
4366 | 91 | anchors.topMargin: units.dp(2) | ||
4367 | 92 | anchors.bottomMargin: units.dp(2) | ||
4368 | 93 | source: "toolbar-left.png" | ||
4369 | 94 | Image { | ||
4370 | 95 | anchors.verticalCenter: parent.verticalCenter | ||
4371 | 96 | anchors.left: parent.left | ||
4372 | 97 | anchors.leftMargin: parent.iconSpacing | ||
4373 | 98 | source: "back.png" | ||
4374 | 99 | width: units.gu(6) | ||
4375 | 100 | height: units.gu(5) | ||
4376 | 101 | MouseArea { | ||
4377 | 102 | anchors.fill: parent | ||
4378 | 103 | onClicked: { | ||
4379 | 104 | root.exec("Capture", "cancel"); | ||
4380 | 105 | } | ||
4381 | 106 | } | ||
4382 | 107 | } | ||
4383 | 108 | } | ||
4384 | 109 | BorderImage { | ||
4385 | 110 | id: middle | ||
4386 | 111 | anchors.top: parent.top | ||
4387 | 112 | anchors.bottom: parent.bottom | ||
4388 | 113 | anchors.horizontalCenter: parent.horizontalCenter | ||
4389 | 114 | height: shootButton.height + units.gu(1) | ||
4390 | 115 | width: shootButton.width | ||
4391 | 116 | source: "toolbar-middle.png" | ||
4392 | 117 | Image { | ||
4393 | 118 | id: shootButton | ||
4394 | 119 | width: units.gu(8) | ||
4395 | 120 | height: width | ||
4396 | 121 | anchors.horizontalCenter: parent.horizontalCenter | ||
4397 | 122 | source: shootImagePath | ||
4398 | 123 | MouseArea { | ||
4399 | 124 | anchors.fill: parent | ||
4400 | 125 | onClicked: { | ||
4401 | 126 | if (ui.state === "camera") { | ||
4402 | 127 | camera.imageCapture.captureToLocation(ui.parent.plugin('Capture').generateLocation("jpg")); | ||
4403 | 128 | } else if (ui.state === "audio") { | ||
4404 | 129 | ui.parent.exec("Capture", "recordAudio"); | ||
4405 | 130 | if (isSuffix(shootButton.source, recordOffImagePath)) { | ||
4406 | 131 | shootButton.source = recordOnImagePath | ||
4407 | 132 | } else { | ||
4408 | 133 | shootButton.source = recordOffImagePath | ||
4409 | 134 | } | ||
4410 | 135 | } else if (ui.state === "videoRecording") { | ||
4411 | 136 | if (!camera.videoRecorder.recorderState) { | ||
4412 | 137 | shootButton.source = recordOnImagePath | ||
4413 | 138 | camera.videoRecorder.record(); | ||
4414 | 139 | } else { | ||
4415 | 140 | camera.videoRecorder.stop(); | ||
4416 | 141 | } | ||
4417 | 142 | } | ||
4418 | 143 | } | ||
4419 | 144 | } | ||
4420 | 145 | } | ||
4421 | 146 | } | ||
4422 | 147 | BorderImage { | ||
4423 | 148 | id: rightBackground | ||
4424 | 149 | anchors.right: parent.right | ||
4425 | 150 | anchors.top: parent.top | ||
4426 | 151 | anchors.bottom: parent.bottom | ||
4427 | 152 | anchors.left: middle.right | ||
4428 | 153 | anchors.topMargin: units.dp(2) | ||
4429 | 154 | anchors.bottomMargin: units.dp(2) | ||
4430 | 155 | source: "toolbar-right.png" | ||
4431 | 156 | } | ||
4432 | 157 | } | ||
4433 | 158 | states: [ | ||
4434 | 159 | State { | ||
4435 | 160 | name: "off" | ||
4436 | 161 | StateChangeScript { | ||
4437 | 162 | script:{ | ||
4438 | 163 | ui.visible = false; | ||
4439 | 164 | camera.stop(); | ||
4440 | 165 | camera.unlock(); | ||
4441 | 166 | } | ||
4442 | 167 | } | ||
4443 | 168 | }, | ||
4444 | 169 | State { | ||
4445 | 170 | name: "camera" | ||
4446 | 171 | StateChangeScript { | ||
4447 | 172 | script: { | ||
4448 | 173 | camera.start(); | ||
4449 | 174 | microphoneImage.visible = false | ||
4450 | 175 | output.visible = true | ||
4451 | 176 | shootButton.source = shootImagePath | ||
4452 | 177 | ui.visible = true | ||
4453 | 178 | } | ||
4454 | 179 | } | ||
4455 | 180 | }, | ||
4456 | 181 | State { | ||
4457 | 182 | name: "videoRecording" | ||
4458 | 183 | StateChangeScript { | ||
4459 | 184 | script: { | ||
4460 | 185 | shootButton.source = recordOffImagePath | ||
4461 | 186 | camera.start(); | ||
4462 | 187 | microphoneImage.visible = false | ||
4463 | 188 | output.visible = true | ||
4464 | 189 | ui.visible = true | ||
4465 | 190 | } | ||
4466 | 191 | } | ||
4467 | 192 | }, | ||
4468 | 193 | State { | ||
4469 | 194 | name: "audio" | ||
4470 | 195 | StateChangeScript { | ||
4471 | 196 | script:{ | ||
4472 | 197 | shootButton.source = recordOffImagePath | ||
4473 | 198 | camera.stop(); | ||
4474 | 199 | microphoneImage.visible = true | ||
4475 | 200 | camera.unlock(); | ||
4476 | 201 | output.visible = false | ||
4477 | 202 | ui.visible = true | ||
4478 | 203 | } | ||
4479 | 204 | } | ||
4480 | 205 | } | ||
4481 | 206 | ] | ||
4482 | 207 | } | ||
4483 | 0 | 208 | ||
4484 | === added file 'qml/back.png' | |||
4485 | 1 | Binary files qml/back.png 1970-01-01 00:00:00 +0000 and qml/back.png 2014-02-19 16:53:58 +0000 differ | 209 | Binary files qml/back.png 1970-01-01 00:00:00 +0000 and qml/back.png 2014-02-19 16:53:58 +0000 differ |
4486 | === added file 'qml/close.png' | |||
4487 | 2 | Binary files qml/close.png 1970-01-01 00:00:00 +0000 and qml/close.png 2014-02-19 16:53:58 +0000 differ | 210 | Binary files qml/close.png 1970-01-01 00:00:00 +0000 and qml/close.png 2014-02-19 16:53:58 +0000 differ |
4488 | === added file 'qml/microphone.png' | |||
4489 | 3 | Binary files qml/microphone.png 1970-01-01 00:00:00 +0000 and qml/microphone.png 2014-02-19 16:53:58 +0000 differ | 211 | Binary files qml/microphone.png 1970-01-01 00:00:00 +0000 and qml/microphone.png 2014-02-19 16:53:58 +0000 differ |
4490 | === added file 'qml/notification.qml' | |||
4491 | --- qml/notification.qml 1970-01-01 00:00:00 +0000 | |||
4492 | +++ qml/notification.qml 2014-02-19 16:53:58 +0000 | |||
4493 | @@ -0,0 +1,44 @@ | |||
4494 | 1 | import QtQuick 2.0 | ||
4495 | 2 | import Ubuntu.Components.Popups 0.1 | ||
4496 | 3 | import Ubuntu.Components 0.1 | ||
4497 | 4 | |||
4498 | 5 | Dialog { | ||
4499 | 6 | id: dialogue | ||
4500 | 7 | property string button1Text | ||
4501 | 8 | property string button2Text | ||
4502 | 9 | property string button3Text | ||
4503 | 10 | property bool promptVisible | ||
4504 | 11 | property string defaultPromptText | ||
4505 | 12 | TextInput {// FIXME: swith to TextField(TextField should support visible property) | ||
4506 | 13 | id: prompt | ||
4507 | 14 | color: "white" | ||
4508 | 15 | text: defaultPromptText | ||
4509 | 16 | visible: promptVisible | ||
4510 | 17 | focus: true | ||
4511 | 18 | } | ||
4512 | 19 | Button { | ||
4513 | 20 | text: button1Text | ||
4514 | 21 | color: "orange" | ||
4515 | 22 | onClicked: { | ||
4516 | 23 | root.exec("Notification", "notificationDialogButtonPressed", [1, prompt.text]); | ||
4517 | 24 | PopupUtils.close(dialogue) | ||
4518 | 25 | } | ||
4519 | 26 | } | ||
4520 | 27 | Button { | ||
4521 | 28 | text: button2Text | ||
4522 | 29 | visible: button2Text.length > 0 | ||
4523 | 30 | color: "orange" | ||
4524 | 31 | onClicked: { | ||
4525 | 32 | root.exec("Notification", "notificationDialogButtonPressed", [2, prompt.text]); | ||
4526 | 33 | PopupUtils.close(dialogue) | ||
4527 | 34 | } | ||
4528 | 35 | } | ||
4529 | 36 | Button { | ||
4530 | 37 | text: button3Text | ||
4531 | 38 | visible: button3Text.length > 0 | ||
4532 | 39 | onClicked: { | ||
4533 | 40 | root.exec("Notification", "notificationDialogButtonPressed", [3, prompt.text]); | ||
4534 | 41 | PopupUtils.close(dialogue) | ||
4535 | 42 | } | ||
4536 | 43 | } | ||
4537 | 44 | } | ||
4538 | 0 | 45 | ||
4539 | === added file 'qml/record_off.png' | |||
4540 | 1 | Binary files qml/record_off.png 1970-01-01 00:00:00 +0000 and qml/record_off.png 2014-02-19 16:53:58 +0000 differ | 46 | Binary files qml/record_off.png 1970-01-01 00:00:00 +0000 and qml/record_off.png 2014-02-19 16:53:58 +0000 differ |
4541 | === added file 'qml/record_on.png' | |||
4542 | 2 | Binary files qml/record_on.png 1970-01-01 00:00:00 +0000 and qml/record_on.png 2014-02-19 16:53:58 +0000 differ | 47 | Binary files qml/record_on.png 1970-01-01 00:00:00 +0000 and qml/record_on.png 2014-02-19 16:53:58 +0000 differ |
4543 | === added file 'qml/shoot.png' | |||
4544 | 3 | Binary files qml/shoot.png 1970-01-01 00:00:00 +0000 and qml/shoot.png 2014-02-19 16:53:58 +0000 differ | 48 | Binary files qml/shoot.png 1970-01-01 00:00:00 +0000 and qml/shoot.png 2014-02-19 16:53:58 +0000 differ |
4545 | === added file 'qml/toolbar-left.png' | |||
4546 | 4 | Binary files qml/toolbar-left.png 1970-01-01 00:00:00 +0000 and qml/toolbar-left.png 2014-02-19 16:53:58 +0000 differ | 49 | Binary files qml/toolbar-left.png 1970-01-01 00:00:00 +0000 and qml/toolbar-left.png 2014-02-19 16:53:58 +0000 differ |
4547 | === added file 'qml/toolbar-middle.png' | |||
4548 | 5 | Binary files qml/toolbar-middle.png 1970-01-01 00:00:00 +0000 and qml/toolbar-middle.png 2014-02-19 16:53:58 +0000 differ | 50 | Binary files qml/toolbar-middle.png 1970-01-01 00:00:00 +0000 and qml/toolbar-middle.png 2014-02-19 16:53:58 +0000 differ |
4549 | === added file 'qml/toolbar-right.png' | |||
4550 | 6 | Binary files qml/toolbar-right.png 1970-01-01 00:00:00 +0000 and qml/toolbar-right.png 2014-02-19 16:53:58 +0000 differ | 51 | Binary files qml/toolbar-right.png 1970-01-01 00:00:00 +0000 and qml/toolbar-right.png 2014-02-19 16:53:58 +0000 differ |
4551 | === modified file 'www/cordova_plugins.js' | |||
4552 | --- www/cordova_plugins.js 2014-02-05 23:42:31 +0000 | |||
4553 | +++ www/cordova_plugins.js 2014-02-19 16:53:58 +0000 | |||
4554 | @@ -1,7 +1,412 @@ | |||
4555 | 1 | cordova.define('cordova/plugin_list', function(require, exports, module) { | 1 | cordova.define('cordova/plugin_list', function(require, exports, module) { |
4557 | 2 | module.exports = []; | 2 | module.exports = [ |
4558 | 3 | { | ||
4559 | 4 | "file": "plugins/org.apache.cordova.battery-status/www/battery.js", | ||
4560 | 5 | "id": "org.apache.cordova.battery-status.battery", | ||
4561 | 6 | "clobbers": [ | ||
4562 | 7 | "navigator.battery" | ||
4563 | 8 | ] | ||
4564 | 9 | }, | ||
4565 | 10 | { | ||
4566 | 11 | "file": "plugins/org.apache.cordova.camera/www/CameraConstants.js", | ||
4567 | 12 | "id": "org.apache.cordova.camera.Camera", | ||
4568 | 13 | "clobbers": [ | ||
4569 | 14 | "Camera" | ||
4570 | 15 | ] | ||
4571 | 16 | }, | ||
4572 | 17 | { | ||
4573 | 18 | "file": "plugins/org.apache.cordova.camera/www/CameraPopoverOptions.js", | ||
4574 | 19 | "id": "org.apache.cordova.camera.CameraPopoverOptions", | ||
4575 | 20 | "clobbers": [ | ||
4576 | 21 | "CameraPopoverOptions" | ||
4577 | 22 | ] | ||
4578 | 23 | }, | ||
4579 | 24 | { | ||
4580 | 25 | "file": "plugins/org.apache.cordova.camera/www/Camera.js", | ||
4581 | 26 | "id": "org.apache.cordova.camera.camera", | ||
4582 | 27 | "clobbers": [ | ||
4583 | 28 | "navigator.camera" | ||
4584 | 29 | ] | ||
4585 | 30 | }, | ||
4586 | 31 | { | ||
4587 | 32 | "file": "plugins/org.apache.cordova.camera/www/CameraPopoverHandle.js", | ||
4588 | 33 | "id": "org.apache.cordova.camera.CameraPopoverHandle", | ||
4589 | 34 | "clobbers": [ | ||
4590 | 35 | "CameraPopoverHandle" | ||
4591 | 36 | ] | ||
4592 | 37 | }, | ||
4593 | 38 | { | ||
4594 | 39 | "file": "plugins/org.apache.cordova.console/www/console-via-logger.js", | ||
4595 | 40 | "id": "org.apache.cordova.console.console", | ||
4596 | 41 | "clobbers": [ | ||
4597 | 42 | "console" | ||
4598 | 43 | ] | ||
4599 | 44 | }, | ||
4600 | 45 | { | ||
4601 | 46 | "file": "plugins/org.apache.cordova.console/www/logger.js", | ||
4602 | 47 | "id": "org.apache.cordova.console.logger", | ||
4603 | 48 | "clobbers": [ | ||
4604 | 49 | "cordova.logger" | ||
4605 | 50 | ] | ||
4606 | 51 | }, | ||
4607 | 52 | { | ||
4608 | 53 | "file": "plugins/org.apache.cordova.device/www/device.js", | ||
4609 | 54 | "id": "org.apache.cordova.device.device", | ||
4610 | 55 | "clobbers": [ | ||
4611 | 56 | "device" | ||
4612 | 57 | ] | ||
4613 | 58 | }, | ||
4614 | 59 | { | ||
4615 | 60 | "file": "plugins/org.apache.cordova.device/src/ubuntu/device.js", | ||
4616 | 61 | "id": "org.apache.cordova.device.DeviceProxy", | ||
4617 | 62 | "merges": [ | ||
4618 | 63 | "device" | ||
4619 | 64 | ] | ||
4620 | 65 | }, | ||
4621 | 66 | { | ||
4622 | 67 | "file": "plugins/org.apache.cordova.device-motion/www/Acceleration.js", | ||
4623 | 68 | "id": "org.apache.cordova.device-motion.Acceleration", | ||
4624 | 69 | "clobbers": [ | ||
4625 | 70 | "Acceleration" | ||
4626 | 71 | ] | ||
4627 | 72 | }, | ||
4628 | 73 | { | ||
4629 | 74 | "file": "plugins/org.apache.cordova.device-motion/www/accelerometer.js", | ||
4630 | 75 | "id": "org.apache.cordova.device-motion.accelerometer", | ||
4631 | 76 | "clobbers": [ | ||
4632 | 77 | "navigator.accelerometer" | ||
4633 | 78 | ] | ||
4634 | 79 | }, | ||
4635 | 80 | { | ||
4636 | 81 | "file": "plugins/org.apache.cordova.device-orientation/www/CompassError.js", | ||
4637 | 82 | "id": "org.apache.cordova.device-orientation.CompassError", | ||
4638 | 83 | "clobbers": [ | ||
4639 | 84 | "CompassError" | ||
4640 | 85 | ] | ||
4641 | 86 | }, | ||
4642 | 87 | { | ||
4643 | 88 | "file": "plugins/org.apache.cordova.device-orientation/www/CompassHeading.js", | ||
4644 | 89 | "id": "org.apache.cordova.device-orientation.CompassHeading", | ||
4645 | 90 | "clobbers": [ | ||
4646 | 91 | "CompassHeading" | ||
4647 | 92 | ] | ||
4648 | 93 | }, | ||
4649 | 94 | { | ||
4650 | 95 | "file": "plugins/org.apache.cordova.device-orientation/www/compass.js", | ||
4651 | 96 | "id": "org.apache.cordova.device-orientation.compass", | ||
4652 | 97 | "clobbers": [ | ||
4653 | 98 | "navigator.compass" | ||
4654 | 99 | ] | ||
4655 | 100 | }, | ||
4656 | 101 | { | ||
4657 | 102 | "file": "plugins/org.apache.cordova.dialogs/www/notification.js", | ||
4658 | 103 | "id": "org.apache.cordova.dialogs.notification", | ||
4659 | 104 | "merges": [ | ||
4660 | 105 | "navigator.notification" | ||
4661 | 106 | ] | ||
4662 | 107 | }, | ||
4663 | 108 | { | ||
4664 | 109 | "file": "plugins/org.apache.cordova.file/www/DirectoryEntry.js", | ||
4665 | 110 | "id": "org.apache.cordova.file.DirectoryEntry", | ||
4666 | 111 | "clobbers": [ | ||
4667 | 112 | "window.DirectoryEntry" | ||
4668 | 113 | ] | ||
4669 | 114 | }, | ||
4670 | 115 | { | ||
4671 | 116 | "file": "plugins/org.apache.cordova.file/www/DirectoryReader.js", | ||
4672 | 117 | "id": "org.apache.cordova.file.DirectoryReader", | ||
4673 | 118 | "clobbers": [ | ||
4674 | 119 | "window.DirectoryReader" | ||
4675 | 120 | ] | ||
4676 | 121 | }, | ||
4677 | 122 | { | ||
4678 | 123 | "file": "plugins/org.apache.cordova.file/www/Entry.js", | ||
4679 | 124 | "id": "org.apache.cordova.file.Entry", | ||
4680 | 125 | "clobbers": [ | ||
4681 | 126 | "window.Entry" | ||
4682 | 127 | ] | ||
4683 | 128 | }, | ||
4684 | 129 | { | ||
4685 | 130 | "file": "plugins/org.apache.cordova.file/www/File.js", | ||
4686 | 131 | "id": "org.apache.cordova.file.File", | ||
4687 | 132 | "clobbers": [ | ||
4688 | 133 | "window.File" | ||
4689 | 134 | ] | ||
4690 | 135 | }, | ||
4691 | 136 | { | ||
4692 | 137 | "file": "plugins/org.apache.cordova.file/www/FileEntry.js", | ||
4693 | 138 | "id": "org.apache.cordova.file.FileEntry", | ||
4694 | 139 | "clobbers": [ | ||
4695 | 140 | "window.FileEntry" | ||
4696 | 141 | ] | ||
4697 | 142 | }, | ||
4698 | 143 | { | ||
4699 | 144 | "file": "plugins/org.apache.cordova.file/www/FileError.js", | ||
4700 | 145 | "id": "org.apache.cordova.file.FileError", | ||
4701 | 146 | "clobbers": [ | ||
4702 | 147 | "window.FileError" | ||
4703 | 148 | ] | ||
4704 | 149 | }, | ||
4705 | 150 | { | ||
4706 | 151 | "file": "plugins/org.apache.cordova.file/www/FileReader.js", | ||
4707 | 152 | "id": "org.apache.cordova.file.FileReader", | ||
4708 | 153 | "clobbers": [ | ||
4709 | 154 | "window.FileReader" | ||
4710 | 155 | ] | ||
4711 | 156 | }, | ||
4712 | 157 | { | ||
4713 | 158 | "file": "plugins/org.apache.cordova.file/www/FileSystem.js", | ||
4714 | 159 | "id": "org.apache.cordova.file.FileSystem", | ||
4715 | 160 | "clobbers": [ | ||
4716 | 161 | "window.FileSystem" | ||
4717 | 162 | ] | ||
4718 | 163 | }, | ||
4719 | 164 | { | ||
4720 | 165 | "file": "plugins/org.apache.cordova.file/www/FileUploadOptions.js", | ||
4721 | 166 | "id": "org.apache.cordova.file.FileUploadOptions", | ||
4722 | 167 | "clobbers": [ | ||
4723 | 168 | "window.FileUploadOptions" | ||
4724 | 169 | ] | ||
4725 | 170 | }, | ||
4726 | 171 | { | ||
4727 | 172 | "file": "plugins/org.apache.cordova.file/www/FileUploadResult.js", | ||
4728 | 173 | "id": "org.apache.cordova.file.FileUploadResult", | ||
4729 | 174 | "clobbers": [ | ||
4730 | 175 | "window.FileUploadResult" | ||
4731 | 176 | ] | ||
4732 | 177 | }, | ||
4733 | 178 | { | ||
4734 | 179 | "file": "plugins/org.apache.cordova.file/www/FileWriter.js", | ||
4735 | 180 | "id": "org.apache.cordova.file.FileWriter", | ||
4736 | 181 | "clobbers": [ | ||
4737 | 182 | "window.FileWriter" | ||
4738 | 183 | ] | ||
4739 | 184 | }, | ||
4740 | 185 | { | ||
4741 | 186 | "file": "plugins/org.apache.cordova.file/www/Flags.js", | ||
4742 | 187 | "id": "org.apache.cordova.file.Flags", | ||
4743 | 188 | "clobbers": [ | ||
4744 | 189 | "window.Flags" | ||
4745 | 190 | ] | ||
4746 | 191 | }, | ||
4747 | 192 | { | ||
4748 | 193 | "file": "plugins/org.apache.cordova.file/www/LocalFileSystem.js", | ||
4749 | 194 | "id": "org.apache.cordova.file.LocalFileSystem", | ||
4750 | 195 | "clobbers": [ | ||
4751 | 196 | "window.LocalFileSystem" | ||
4752 | 197 | ], | ||
4753 | 198 | "merges": [ | ||
4754 | 199 | "window" | ||
4755 | 200 | ] | ||
4756 | 201 | }, | ||
4757 | 202 | { | ||
4758 | 203 | "file": "plugins/org.apache.cordova.file/www/Metadata.js", | ||
4759 | 204 | "id": "org.apache.cordova.file.Metadata", | ||
4760 | 205 | "clobbers": [ | ||
4761 | 206 | "window.Metadata" | ||
4762 | 207 | ] | ||
4763 | 208 | }, | ||
4764 | 209 | { | ||
4765 | 210 | "file": "plugins/org.apache.cordova.file/www/ProgressEvent.js", | ||
4766 | 211 | "id": "org.apache.cordova.file.ProgressEvent", | ||
4767 | 212 | "clobbers": [ | ||
4768 | 213 | "window.ProgressEvent" | ||
4769 | 214 | ] | ||
4770 | 215 | }, | ||
4771 | 216 | { | ||
4772 | 217 | "file": "plugins/org.apache.cordova.file/www/requestFileSystem.js", | ||
4773 | 218 | "id": "org.apache.cordova.file.requestFileSystem", | ||
4774 | 219 | "clobbers": [ | ||
4775 | 220 | "window.requestFileSystem" | ||
4776 | 221 | ] | ||
4777 | 222 | }, | ||
4778 | 223 | { | ||
4779 | 224 | "file": "plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js", | ||
4780 | 225 | "id": "org.apache.cordova.file.resolveLocalFileSystemURI", | ||
4781 | 226 | "merges": [ | ||
4782 | 227 | "window" | ||
4783 | 228 | ] | ||
4784 | 229 | }, | ||
4785 | 230 | { | ||
4786 | 231 | "file": "plugins/org.apache.cordova.file/www/ubuntu/Entry.js", | ||
4787 | 232 | "id": "org.apache.cordova.file.Entry1", | ||
4788 | 233 | "merges": [ | ||
4789 | 234 | "window.Entry" | ||
4790 | 235 | ] | ||
4791 | 236 | }, | ||
4792 | 237 | { | ||
4793 | 238 | "file": "plugins/org.apache.cordova.file/www/ubuntu/DirectoryEntry.js", | ||
4794 | 239 | "id": "org.apache.cordova.file.DirectoryEntry1", | ||
4795 | 240 | "merges": [ | ||
4796 | 241 | "window.DirectoryEntry" | ||
4797 | 242 | ] | ||
4798 | 243 | }, | ||
4799 | 244 | { | ||
4800 | 245 | "file": "plugins/org.apache.cordova.file/www/ubuntu/FileWriter.js", | ||
4801 | 246 | "id": "org.apache.cordova.file.FileWriter1", | ||
4802 | 247 | "merges": [ | ||
4803 | 248 | "window.FileWriter" | ||
4804 | 249 | ] | ||
4805 | 250 | }, | ||
4806 | 251 | { | ||
4807 | 252 | "file": "plugins/org.apache.cordova.file-transfer/www/FileTransferError.js", | ||
4808 | 253 | "id": "org.apache.cordova.file-transfer.FileTransferError", | ||
4809 | 254 | "clobbers": [ | ||
4810 | 255 | "window.FileTransferError" | ||
4811 | 256 | ] | ||
4812 | 257 | }, | ||
4813 | 258 | { | ||
4814 | 259 | "file": "plugins/org.apache.cordova.file-transfer/www/FileTransfer.js", | ||
4815 | 260 | "id": "org.apache.cordova.file-transfer.FileTransfer", | ||
4816 | 261 | "clobbers": [ | ||
4817 | 262 | "window.FileTransfer" | ||
4818 | 263 | ] | ||
4819 | 264 | }, | ||
4820 | 265 | { | ||
4821 | 266 | "file": "plugins/org.apache.cordova.geolocation/www/Coordinates.js", | ||
4822 | 267 | "id": "org.apache.cordova.geolocation.Coordinates", | ||
4823 | 268 | "clobbers": [ | ||
4824 | 269 | "Coordinates" | ||
4825 | 270 | ] | ||
4826 | 271 | }, | ||
4827 | 272 | { | ||
4828 | 273 | "file": "plugins/org.apache.cordova.geolocation/www/PositionError.js", | ||
4829 | 274 | "id": "org.apache.cordova.geolocation.PositionError", | ||
4830 | 275 | "clobbers": [ | ||
4831 | 276 | "PositionError" | ||
4832 | 277 | ] | ||
4833 | 278 | }, | ||
4834 | 279 | { | ||
4835 | 280 | "file": "plugins/org.apache.cordova.geolocation/www/Position.js", | ||
4836 | 281 | "id": "org.apache.cordova.geolocation.Position", | ||
4837 | 282 | "clobbers": [ | ||
4838 | 283 | "Position" | ||
4839 | 284 | ] | ||
4840 | 285 | }, | ||
4841 | 286 | { | ||
4842 | 287 | "file": "plugins/org.apache.cordova.geolocation/www/geolocation.js", | ||
4843 | 288 | "id": "org.apache.cordova.geolocation.geolocation", | ||
4844 | 289 | "clobbers": [ | ||
4845 | 290 | "navigator.geolocation" | ||
4846 | 291 | ] | ||
4847 | 292 | }, | ||
4848 | 293 | { | ||
4849 | 294 | "file": "plugins/org.apache.cordova.globalization/www/GlobalizationError.js", | ||
4850 | 295 | "id": "org.apache.cordova.globalization.GlobalizationError", | ||
4851 | 296 | "clobbers": [ | ||
4852 | 297 | "window.GlobalizationError" | ||
4853 | 298 | ] | ||
4854 | 299 | }, | ||
4855 | 300 | { | ||
4856 | 301 | "file": "plugins/org.apache.cordova.globalization/www/globalization.js", | ||
4857 | 302 | "id": "org.apache.cordova.globalization.globalization", | ||
4858 | 303 | "clobbers": [ | ||
4859 | 304 | "navigator.globalization" | ||
4860 | 305 | ] | ||
4861 | 306 | }, | ||
4862 | 307 | { | ||
4863 | 308 | "file": "plugins/org.apache.cordova.globalization/www/ubuntu/globalization.js", | ||
4864 | 309 | "id": "org.apache.cordova.globalization.Globalization1", | ||
4865 | 310 | "merges": [ | ||
4866 | 311 | "navigator.globalization" | ||
4867 | 312 | ] | ||
4868 | 313 | }, | ||
4869 | 314 | { | ||
4870 | 315 | "file": "plugins/org.apache.cordova.inappbrowser/www/InAppBrowser.js", | ||
4871 | 316 | "id": "org.apache.cordova.inappbrowser.InAppBrowser", | ||
4872 | 317 | "clobbers": [ | ||
4873 | 318 | "window.open" | ||
4874 | 319 | ] | ||
4875 | 320 | }, | ||
4876 | 321 | { | ||
4877 | 322 | "file": "plugins/org.apache.cordova.media/www/MediaError.js", | ||
4878 | 323 | "id": "org.apache.cordova.media.MediaError", | ||
4879 | 324 | "clobbers": [ | ||
4880 | 325 | "window.MediaError" | ||
4881 | 326 | ] | ||
4882 | 327 | }, | ||
4883 | 328 | { | ||
4884 | 329 | "file": "plugins/org.apache.cordova.media/www/Media.js", | ||
4885 | 330 | "id": "org.apache.cordova.media.Media", | ||
4886 | 331 | "clobbers": [ | ||
4887 | 332 | "window.Media" | ||
4888 | 333 | ] | ||
4889 | 334 | }, | ||
4890 | 335 | { | ||
4891 | 336 | "file": "plugins/org.apache.cordova.media-capture/www/CaptureAudioOptions.js", | ||
4892 | 337 | "id": "org.apache.cordova.media-capture.CaptureAudioOptions", | ||
4893 | 338 | "clobbers": [ | ||
4894 | 339 | "CaptureAudioOptions" | ||
4895 | 340 | ] | ||
4896 | 341 | }, | ||
4897 | 342 | { | ||
4898 | 343 | "file": "plugins/org.apache.cordova.media-capture/www/CaptureImageOptions.js", | ||
4899 | 344 | "id": "org.apache.cordova.media-capture.CaptureImageOptions", | ||
4900 | 345 | "clobbers": [ | ||
4901 | 346 | "CaptureImageOptions" | ||
4902 | 347 | ] | ||
4903 | 348 | }, | ||
4904 | 349 | { | ||
4905 | 350 | "file": "plugins/org.apache.cordova.media-capture/www/CaptureVideoOptions.js", | ||
4906 | 351 | "id": "org.apache.cordova.media-capture.CaptureVideoOptions", | ||
4907 | 352 | "clobbers": [ | ||
4908 | 353 | "CaptureVideoOptions" | ||
4909 | 354 | ] | ||
4910 | 355 | }, | ||
4911 | 356 | { | ||
4912 | 357 | "file": "plugins/org.apache.cordova.media-capture/www/CaptureError.js", | ||
4913 | 358 | "id": "org.apache.cordova.media-capture.CaptureError", | ||
4914 | 359 | "clobbers": [ | ||
4915 | 360 | "CaptureError" | ||
4916 | 361 | ] | ||
4917 | 362 | }, | ||
4918 | 363 | { | ||
4919 | 364 | "file": "plugins/org.apache.cordova.media-capture/www/MediaFileData.js", | ||
4920 | 365 | "id": "org.apache.cordova.media-capture.MediaFileData", | ||
4921 | 366 | "clobbers": [ | ||
4922 | 367 | "MediaFileData" | ||
4923 | 368 | ] | ||
4924 | 369 | }, | ||
4925 | 370 | { | ||
4926 | 371 | "file": "plugins/org.apache.cordova.media-capture/www/MediaFile.js", | ||
4927 | 372 | "id": "org.apache.cordova.media-capture.MediaFile", | ||
4928 | 373 | "clobbers": [ | ||
4929 | 374 | "MediaFile" | ||
4930 | 375 | ] | ||
4931 | 376 | }, | ||
4932 | 377 | { | ||
4933 | 378 | "file": "plugins/org.apache.cordova.media-capture/www/capture.js", | ||
4934 | 379 | "id": "org.apache.cordova.media-capture.capture", | ||
4935 | 380 | "clobbers": [ | ||
4936 | 381 | "navigator.device.capture" | ||
4937 | 382 | ] | ||
4938 | 383 | }, | ||
4939 | 384 | { | ||
4940 | 385 | "file": "plugins/org.apache.cordova.vibration/www/vibration.js", | ||
4941 | 386 | "id": "org.apache.cordova.vibration.notification", | ||
4942 | 387 | "merges": [ | ||
4943 | 388 | "navigator.notification" | ||
4944 | 389 | ] | ||
4945 | 390 | } | ||
4946 | 391 | ]; | ||
4947 | 3 | module.exports.metadata = | 392 | module.exports.metadata = |
4948 | 4 | // TOP OF METADATA | 393 | // TOP OF METADATA |
4950 | 5 | {} | 394 | { |
4951 | 395 | "org.apache.cordova.battery-status": "0.2.7", | ||
4952 | 396 | "org.apache.cordova.camera": "0.2.7", | ||
4953 | 397 | "org.apache.cordova.console": "0.2.7", | ||
4954 | 398 | "org.apache.cordova.device": "0.2.8", | ||
4955 | 399 | "org.apache.cordova.device-motion": "0.2.6", | ||
4956 | 400 | "org.apache.cordova.device-orientation": "0.3.5", | ||
4957 | 401 | "org.apache.cordova.dialogs": "0.2.6", | ||
4958 | 402 | "org.apache.cordova.file": "1.0.0", | ||
4959 | 403 | "org.apache.cordova.file-transfer": "0.4.1", | ||
4960 | 404 | "org.apache.cordova.geolocation": "0.3.6", | ||
4961 | 405 | "org.apache.cordova.globalization": "0.2.6", | ||
4962 | 406 | "org.apache.cordova.inappbrowser": "0.3.1", | ||
4963 | 407 | "org.apache.cordova.media": "0.2.8", | ||
4964 | 408 | "org.apache.cordova.media-capture": "0.2.7", | ||
4965 | 409 | "org.apache.cordova.vibration": "0.3.7" | ||
4966 | 410 | } | ||
4967 | 6 | // BOTTOM OF METADATA | 411 | // BOTTOM OF METADATA |
4968 | 7 | }); | 412 | }); |
4969 | 8 | \ No newline at end of file | 413 | \ No newline at end of file |
4970 | 9 | 414 | ||
4971 | === added directory 'www/plugins' | |||
4972 | === added directory 'www/plugins/org.apache.cordova.battery-status' | |||
4973 | === added directory 'www/plugins/org.apache.cordova.battery-status/www' | |||
4974 | === added file 'www/plugins/org.apache.cordova.battery-status/www/battery.js' | |||
4975 | --- www/plugins/org.apache.cordova.battery-status/www/battery.js 1970-01-01 00:00:00 +0000 | |||
4976 | +++ www/plugins/org.apache.cordova.battery-status/www/battery.js 2014-02-19 16:53:58 +0000 | |||
4977 | @@ -0,0 +1,101 @@ | |||
4978 | 1 | cordova.define("org.apache.cordova.battery-status.battery", function(require, exports, module) { /* | ||
4979 | 2 | * | ||
4980 | 3 | * Licensed to the Apache Software Foundation (ASF) under one | ||
4981 | 4 | * or more contributor license agreements. See the NOTICE file | ||
4982 | 5 | * distributed with this work for additional information | ||
4983 | 6 | * regarding copyright ownership. The ASF licenses this file | ||
4984 | 7 | * to you under the Apache License, Version 2.0 (the | ||
4985 | 8 | * "License"); you may not use this file except in compliance | ||
4986 | 9 | * with the License. You may obtain a copy of the License at | ||
4987 | 10 | * | ||
4988 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
4989 | 12 | * | ||
4990 | 13 | * Unless required by applicable law or agreed to in writing, | ||
4991 | 14 | * software distributed under the License is distributed on an | ||
4992 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
4993 | 16 | * KIND, either express or implied. See the License for the | ||
4994 | 17 | * specific language governing permissions and limitations | ||
4995 | 18 | * under the License. | ||
4996 | 19 | * | ||
4997 | 20 | */ | ||
4998 | 21 | |||
4999 | 22 | /** | ||
5000 | 23 | * This class contains information about the current battery status. |
The diff has been truncated for viewing.
works fine for me