Merge lp:~dbarth/cordova-ubuntu/3.4-core-platform-plugins into lp:cordova-ubuntu/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
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
Review via email: mp+206982@code.launchpad.net

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\!

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

works fine for me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'apparmor.json'
--- apparmor.json 2014-02-06 00:00:42 +0000
+++ apparmor.json 2014-02-19 16:53:58 +0000
@@ -1,1 +1,1 @@
1{"policy_groups":["networking","audio"],"policy_version":1}
2\ No newline at end of file1\ No newline at end of file
2{"policy_groups":["networking","audio","camera","sensors","location","microphone","video","audio","camera","microphone"],"policy_version":1}
3\ No newline at end of file3\ No newline at end of file
44
=== modified file 'build/src/coreplugins.cpp'
--- build/src/coreplugins.cpp 2014-02-05 23:42:31 +0000
+++ build/src/coreplugins.cpp 2014-02-19 16:53:58 +0000
@@ -19,6 +19,22 @@
19#include <QtCore>19#include <QtCore>
20#include "cplugin.h"20#include "cplugin.h"
21#include "coreplugins.h"21#include "coreplugins.h"
22#include "plugins/org.apache.cordova.camera/camera.h"
23#include "plugins/org.apache.cordova.console/console.h"
24#include "plugins/org.apache.cordova.device/device.h"
25#include "plugins/org.apache.cordova.device-motion/accelerometer.h"
26#include "plugins/org.apache.cordova.device-orientation/compass.h"
27#include "plugins/org.apache.cordova.file/file.h"
28#include "plugins/org.apache.cordova.media-capture/capture.h"
29#include "plugins/org.apache.cordova.media/media.h"
30#include "plugins/org.apache.cordova.inappbrowser/inappbrowser.h"
31#include "plugins/org.apache.cordova.splashscreen/splashscreen.h"
32#include "plugins/org.apache.cordova.vibration/vibration.h"
33#include "plugins/org.apache.cordova.geolocation/geolocation.h"
34#include "plugins/org.apache.cordova.globalization/globalization.h"
35#include "plugins/org.apache.cordova.battery-status/battery.h"
36#include "plugins/org.apache.cordova.file-transfer/file-transfer.h"
37#include "plugins/org.apache.cordova.dialogs/notification.h"
22INSERT_HEADER_HERE38INSERT_HEADER_HERE
2339
24#define INIT_PLUGIN(class) \40#define INIT_PLUGIN(class) \
@@ -29,7 +45,7 @@
29Q_DECL_EXPORT QList<QSharedPointer<CPlugin>> cordovaGetPluginInstances(Cordova *cordova) {45Q_DECL_EXPORT QList<QSharedPointer<CPlugin>> cordovaGetPluginInstances(Cordova *cordova) {
30 QList<QSharedPointer<CPlugin>> res;46 QList<QSharedPointer<CPlugin>> res;
3147
32 INSERT_PLUGIN_HERE48 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
3349
34 return res;50 return res;
35}51}
3652
=== added directory 'build/src/plugins/org.apache.cordova.battery-status'
=== added file 'build/src/plugins/org.apache.cordova.battery-status/battery.cpp'
--- build/src/plugins/org.apache.cordova.battery-status/battery.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.battery-status/battery.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,78 @@
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19*/
20
21#include <QtCore>
22
23#include "battery.h"
24
25BatteryStatus::BatteryStatus(Cordova *cordova) : CPlugin(cordova) {
26 _scId = 0;
27
28 connect(&_batteryInfo, SIGNAL(remainingCapacityChanged(int,int)), this, SLOT(remainingCapacityChanged(int,int)));
29 connect(&_batteryInfo, SIGNAL(chargerTypeChanged(QBatteryInfo::ChargerType)), this, SLOT(chargerTypeChanged(QBatteryInfo::ChargerType)));
30}
31
32void BatteryStatus::remainingCapacityChanged(int battery, int capacity) {
33 Q_UNUSED(battery);
34 Q_UNUSED(capacity);
35
36 fireEvents();
37}
38
39void BatteryStatus::chargerTypeChanged(QBatteryInfo::ChargerType type) {
40 Q_UNUSED(type);
41
42 fireEvents();
43}
44
45void BatteryStatus::fireEvents() {
46 int fullCount = 0;
47 bool isPlugged = false;
48
49 int remaining = 0, total = 0;
50 for (int i = 0; i < _batteryInfo.batteryCount(); i++) {
51 isPlugged = (_batteryInfo.chargingState(i) == QBatteryInfo::Charging) || isPlugged;
52 fullCount += _batteryInfo.chargingState(i) == QBatteryInfo::Full;
53
54 remaining += _batteryInfo.remainingCapacity(i);
55 total += _batteryInfo.maximumCapacity(i);
56 }
57
58 isPlugged = isPlugged || (_batteryInfo.batteryCount() == fullCount);
59
60 if (_scId) {
61 QVariantMap obj;
62 obj.insert("isPlugged", (int)isPlugged);
63 if (total != 0)
64 obj.insert("level", remaining * 100 / total);
65 else
66 obj.insert("level", 100);
67
68 this->callbackWithoutRemove(_scId, CordovaInternal::format(obj));
69 }
70}
71
72void BatteryStatus::start(int scId, int) {
73 _scId = scId;
74}
75
76void BatteryStatus::stop(int, int) {
77 _scId = 0;
78}
079
=== added file 'build/src/plugins/org.apache.cordova.battery-status/battery.h'
--- build/src/plugins/org.apache.cordova.battery-status/battery.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.battery-status/battery.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,62 @@
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19*/
20
21#ifndef BATTERY_H_AAAAAAAA
22#define BATTERY_H_AAAAAAAA
23
24#include <QBatteryInfo>
25
26#include <cplugin.h>
27
28class BatteryStatus: public CPlugin {
29 Q_OBJECT
30public:
31 explicit BatteryStatus(Cordova *cordova);
32
33 virtual const QString fullName() override {
34 return BatteryStatus::fullID();
35 }
36
37 virtual const QString shortName() override {
38 return "Battery";
39 }
40
41 static const QString fullID() {
42 return "Battery";
43 }
44
45public slots:
46 void start(int scId, int ecId);
47 void stop(int scId, int ecId);
48
49private slots:
50 void remainingCapacityChanged(int battery, int capacity);
51 void chargerTypeChanged(QBatteryInfo::ChargerType type);
52 void onlineStatusChanged(bool isOnline);
53
54private:
55 void fireEvents();
56
57 QBatteryInfo _batteryInfo;
58
59 int _scId;
60};
61
62#endif
063
=== added directory 'build/src/plugins/org.apache.cordova.camera'
=== added file 'build/src/plugins/org.apache.cordova.camera/camera.cpp'
--- build/src/plugins/org.apache.cordova.camera/camera.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.camera/camera.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,143 @@
1/*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22#include "camera.h"
23#include <cordova.h>
24
25#include <QCameraViewfinder>
26#include <QCameraImageCapture>
27#include <QGraphicsObject>
28#include <QCloseEvent>
29#include <QQuickItem>
30
31const char code[] = "\
32var component, object; \
33function createObject() { \
34 component = Qt.createComponent(%1); \
35 if (component.status == Component.Ready) \
36 finishCreation(); \
37 else \
38 component.statusChanged.connect(finishCreation); \
39} \
40function finishCreation() { \
41 CordovaWrapper.object = component.createObject(root, \
42 {root: root, cordova: cordova}); \
43} \
44createObject()";
45
46
47Camera::Camera(Cordova *cordova):
48 CPlugin(cordova),
49 _lastScId(0),
50 _lastEcId(0) {
51}
52
53bool Camera::preprocessImage(QString &path) {
54 bool convertToPNG = (*_options.find("encodingType")).toInt() == Camera::PNG;
55 int quality = (*_options.find("quality")).toInt();
56 int width = (*_options.find("targetWidth")).toInt();
57 int height = (*_options.find("targetHeight")).toInt();
58
59 QImage image(path);
60 if (width <= 0)
61 width = image.width();
62 if (height <= 0)
63 height = image.height();
64 image = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
65
66 QFile oldImage(path);
67 QTemporaryFile newImage;
68
69 const char *type;
70 if (convertToPNG) {
71 newImage.setFileTemplate("imgXXXXXX.png");
72 type = "png";
73 } else {
74 newImage.setFileTemplate("imgXXXXXX.jpg");
75 type = "jpg";
76 }
77
78 newImage.open();
79 newImage.setAutoRemove(false);
80 image.save(newImage.fileName(), type, quality);
81
82 path = newImage.fileName();
83 oldImage.remove();
84
85 return true;
86}
87
88void Camera::onImageSaved(QString path) {
89 bool dataURL = _options.find("destinationType")->toInt() == Camera::DATA_URL;
90
91 QString cbParams;
92 if (preprocessImage(path)) {
93 QString absolutePath = QFileInfo(path).absoluteFilePath();
94 if (dataURL) {
95 QFile image(absolutePath);
96 image.open(QIODevice::ReadOnly);
97 QByteArray content = image.readAll().toBase64();
98 cbParams = QString("\"%1\"").arg(content.data());
99 image.remove();
100 } else {
101 cbParams = CordovaInternal::format(QUrl::fromLocalFile(absolutePath).toString());
102 }
103 }
104
105 this->callback(_lastScId, cbParams);
106
107 _lastEcId = _lastScId = 0;
108}
109
110void Camera::takePicture(int scId, int ecId, int quality, int destinationType, int/*sourceType*/, int targetWidth, int targetHeight, int encodingType,
111 int/*mediaType*/, bool/*allowEdit*/, bool/*correctOrientation*/, bool/*saveToPhotoAlbum*/, const QVariantMap &/*popoverOptions*/, int/*cameraDirection*/) {
112 if (_camera.isNull()) {
113 _camera = QSharedPointer<QCamera>(new QCamera());
114 }
115
116 if (((_lastScId || _lastEcId) && (_lastScId != scId && _lastEcId != ecId)) || !_camera->isAvailable() || _camera->lockStatus() != QCamera::Unlocked) {
117 this->cb(_lastEcId, "Device is busy");
118 return;
119 }
120
121 _options.clear();
122 _options.insert("quality", quality);
123 _options.insert("destinationType", destinationType);
124 _options.insert("targetWidth", targetWidth);
125 _options.insert("targetHeight", targetHeight);
126 _options.insert("encodingType", encodingType);
127
128 _lastScId = scId;
129 _lastEcId = ecId;
130
131 QString path = m_cordova->get_app_dir() + "/../qml/CaptureWidget.qml";
132
133 // TODO: relative url
134 QString qml = QString(code).arg(CordovaInternal::format(path));
135 m_cordova->execQML(qml);
136}
137
138void Camera::cancel() {
139 m_cordova->execQML("CordovaWrapper.object.destroy()");
140 this->cb(_lastEcId, "canceled");
141
142 _lastEcId = _lastScId = 0;
143}
0144
=== added file 'build/src/plugins/org.apache.cordova.camera/camera.h'
--- build/src/plugins/org.apache.cordova.camera/camera.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.camera/camera.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,76 @@
1/*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22#ifndef CAMERA_H
23#define CAMERA_H
24
25#include <cplugin.h>
26
27#include <QtCore>
28#include <QQuickView>
29#include <QCamera>
30#include <QtMultimediaWidgets/QCameraViewfinder>
31#include <QCameraImageCapture>
32
33class Camera: public CPlugin {
34 Q_OBJECT
35public:
36 explicit Camera(Cordova *cordova);
37
38 virtual const QString fullName() override {
39 return Camera::fullID();
40 }
41
42 virtual const QString shortName() override {
43 return "Camera";
44 }
45
46 static const QString fullID() {
47 return "Camera";
48 }
49
50public slots:
51 void takePicture(int scId, int ecId, int quality, int destinationType, int/*sourceType*/, int targetWidth, int targetHeight, int encodingType,
52 int/*mediaType*/, bool/*allowEdit*/, bool/*correctOrientation*/, bool/*saveToPhotoAlbum*/, const QVariantMap &popoverOptions, int cameraDirection);
53 void cancel();
54
55 void onImageSaved(QString path);
56
57private:
58 bool preprocessImage(QString &path);
59
60 int _lastScId;
61 int _lastEcId;
62 QSharedPointer<QCamera> _camera;
63
64 QVariantMap _options;
65protected:
66 enum DestinationType {
67 DATA_URL = 0,
68 FILE_URI = 1
69 };
70 enum EncodingType {
71 JPEG = 0,
72 PNG = 1
73 };
74};
75
76#endif // CAMERA_H
077
=== added directory 'build/src/plugins/org.apache.cordova.console'
=== added file 'build/src/plugins/org.apache.cordova.console/console.cpp'
--- build/src/plugins/org.apache.cordova.console/console.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.console/console.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,29 @@
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15#include "console.h"
16
17#include <iostream>
18
19Console::Console(Cordova *cordova) : CPlugin(cordova) {
20}
21
22void Console::logLevel(int scId, int ecId, QString level, QString message) {
23 Q_UNUSED(scId)
24 Q_UNUSED(ecId)
25
26 if (level != "LOG")
27 std::cout << "[" << level.toStdString() << "] ";
28 std::cout << message.toStdString() << std::endl;
29}
030
=== added file 'build/src/plugins/org.apache.cordova.console/console.h'
--- build/src/plugins/org.apache.cordova.console/console.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.console/console.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,43 @@
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15#ifndef CONSOLE_H_FDSVCXGFRS
16#define CONSOLE_H_FDSVCXGFRS
17
18#include <cplugin.h>
19
20#include <QtCore>
21
22class Console : public CPlugin {
23 Q_OBJECT
24public:
25 explicit Console(Cordova *cordova);
26
27 virtual const QString fullName() override {
28 return Console::fullID();
29 }
30
31 virtual const QString shortName() override {
32 return "Console";
33 }
34
35 static const QString fullID() {
36 return "Console";
37 }
38
39public slots:
40 void logLevel(int scId, int ecId, QString level, QString message);
41};
42
43#endif
044
=== added directory 'build/src/plugins/org.apache.cordova.device'
=== added directory 'build/src/plugins/org.apache.cordova.device-motion'
=== added file 'build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp'
--- build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.device-motion/accelerometer.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,58 @@
1/*
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing,
10 * software distributed under the License is distributed on an
11 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 * KIND, either express or implied. See the License for the
13 * specific language governing permissions and limitations
14 * under the License.
15 *
16*/
17
18#include <cassert>
19#include "accelerometer.h"
20
21DeviceMotion::DeviceMotion(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) {
22 _accelerometerSource = QSharedPointer<QAccelerometer>(new QAccelerometer());
23 _sensorAvaliable = _accelerometerSource->start();
24 connect(_accelerometerSource.data(), SIGNAL(readingChanged()), SLOT(updateSensor()));
25}
26
27void DeviceMotion::start(int scId, int ecId) {
28 assert(_ecId == 0);
29 assert(_scId == 0);
30
31 _ecId = ecId;
32 _scId = scId;
33
34 if (!_sensorAvaliable) {
35 this->cb(ecId);
36 return;
37 }
38}
39
40void DeviceMotion::stop(int, int) {
41 _scId = 0;
42 _ecId = 0;
43}
44
45void DeviceMotion::updateSensor() {
46 QAccelerometerReading *accelerometer = _accelerometerSource->reading();
47
48 QVariantMap obj;
49 obj.insert("x", accelerometer->x());
50 obj.insert("y", accelerometer->y());
51 obj.insert("z", accelerometer->z());
52 // accelerometer->timestamp() is not sutiable.
53 // Timestamps values are microseconds since _a_ fixed point(depend on backend).
54 obj.insert("timestamp", QDateTime::currentDateTime().toMSecsSinceEpoch());
55
56 if (_scId)
57 this->cb(_scId, obj);
58}
059
=== added file 'build/src/plugins/org.apache.cordova.device-motion/accelerometer.h'
--- build/src/plugins/org.apache.cordova.device-motion/accelerometer.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.device-motion/accelerometer.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,55 @@
1/*
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing,
10 * software distributed under the License is distributed on an
11 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 * KIND, either express or implied. See the License for the
13 * specific language governing permissions and limitations
14 * under the License.
15 *
16*/
17
18#ifndef ACCELEROMETER_H
19#define ACCELEROMETER_H
20
21#include <cplugin.h>
22#include <QAccelerometer>
23#include <QtCore>
24
25class DeviceMotion: public CPlugin {
26 Q_OBJECT
27public:
28 explicit DeviceMotion(Cordova *cordova);
29
30 virtual const QString fullName() override {
31 return DeviceMotion::fullID();
32 }
33
34 virtual const QString shortName() override {
35 return "Accelerometer";
36 }
37
38 static const QString fullID() {
39 return "Accelerometer";
40 }
41
42public slots:
43 void start(int scId, int ecId);
44 void stop(int scId, int ecId);
45
46protected slots:
47 void updateSensor();
48
49private:
50 int _scId, _ecId;
51 bool _sensorAvaliable;
52 QSharedPointer<QAccelerometer> _accelerometerSource;
53};
54
55#endif
056
=== added directory 'build/src/plugins/org.apache.cordova.device-orientation'
=== added file 'build/src/plugins/org.apache.cordova.device-orientation/compass.cpp'
--- build/src/plugins/org.apache.cordova.device-orientation/compass.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.device-orientation/compass.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,75 @@
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15#include "compass.h"
16
17DeviceOrientation::DeviceOrientation(Cordova *cordova): CPlugin(cordova), _validData(false) {
18 _compass.connectToBackend();
19 connect(&_compass, SIGNAL(readingChanged()), SLOT(updateSensor()));
20 connect(&_compass, SIGNAL(sensorError(int)), SLOT(sensorError(int)));
21}
22
23void DeviceOrientation::getHeading(int scId, int ecId, QVariantMap options) {
24 Q_UNUSED(options);
25 if (_compass.isConnectedToBackend() || !_compass.start()) {
26 this->callback(ecId, "CompassError.COMPASS_NOT_SUPPORTED");
27 return;
28 }
29
30 _successCallbacks << scId;
31 _errorCallbacks << ecId;
32
33 if (_validData) {
34 reportResult();
35 return;
36 }
37}
38
39void DeviceOrientation::sensorError(int error) {
40 Q_UNUSED(error);
41
42 for (int ecId: _errorCallbacks) {
43 this->callback(ecId, "CompassError.COMPASS_INTERNAL_ERR");
44 }
45
46 _errorCallbacks.clear();
47 _successCallbacks.clear();
48 _validData = false;
49}
50
51void DeviceOrientation::reportResult() {
52 QVariantMap obj;
53
54 obj.insert("magneticHeading", _azymuth);
55 obj.insert("trueHeading", _azymuth);
56 obj.insert("headingAccuracy", _accuracy);
57 obj.insert("timestamp", _timestamp);
58
59 for (int scId: _successCallbacks) {
60 this->cb(scId, obj);
61 }
62
63 _errorCallbacks.clear();
64 _successCallbacks.clear();
65}
66
67void DeviceOrientation::updateSensor(){
68 QCompassReading *heading = _compass.reading();
69 _azymuth = heading->azimuth();
70 _accuracy = heading->calibrationLevel();
71 _timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
72
73 _validData = true;
74 reportResult();
75}
076
=== added file 'build/src/plugins/org.apache.cordova.device-orientation/compass.h'
--- build/src/plugins/org.apache.cordova.device-orientation/compass.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.device-orientation/compass.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,58 @@
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15#ifndef COMPASS_H_HKFSAHKDFAS
16#define COMPASS_H_HKFSAHKDFAS
17
18#include <cplugin.h>
19#include <QCompass>
20#include <QtCore>
21
22class DeviceOrientation: public CPlugin {
23 Q_OBJECT
24public:
25 explicit DeviceOrientation(Cordova *cordova);
26
27 virtual const QString fullName() override {
28 return DeviceOrientation::fullID();
29 }
30
31 virtual const QString shortName() override {
32 return "Compass";
33 }
34
35 static const QString fullID() {
36 return "Compass";
37 }
38
39public slots:
40 void getHeading(int scId, int ecId, QVariantMap options);
41
42protected slots:
43 void updateSensor();
44 void sensorError(int error);
45
46private:
47 void reportResult();
48 QCompass _compass;
49 QList<int> _successCallbacks;
50 QList<int> _errorCallbacks;
51
52 double _azymuth;
53 double _accuracy;
54 qtimestamp _timestamp;
55 bool _validData;
56};
57
58#endif
059
=== added file 'build/src/plugins/org.apache.cordova.device/device.cpp'
--- build/src/plugins/org.apache.cordova.device/device.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.device/device.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2011 Wolfgang Koller - http://www.gofg.at/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <QDeviceInfo>
18#include <QtSystemInfo>
19
20#include"device.h"
21
22#define CORDOVA "3.0.0"
23
24Device::Device(Cordova *cordova) : CPlugin(cordova) {
25}
26
27static QString getOSName() {
28#ifdef Q_OS_SYMBIAN
29 QString platform = "Symbian";
30#endif
31#ifdef Q_OS_WIN
32 QString platform = "Windows";
33#endif
34#ifdef Q_OS_WINCE
35 QString platform = "Windows CE";
36#endif
37#ifdef Q_OS_LINUX
38 QString platform = "Linux";
39#endif
40 return platform;
41}
42
43void Device::getInfo(int scId, int ecId) {
44 Q_UNUSED(ecId)
45
46 QDeviceInfo systemDeviceInfo;
47 QDeviceInfo systemInfo;
48
49 QString platform = getOSName();
50
51 QString uuid = systemDeviceInfo.uniqueDeviceID();
52 if (uuid.isEmpty()) {
53 QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform;
54 QString user = qgetenv("USER");
55 if (user.isEmpty()) {
56 user = qgetenv("USERNAME");
57 if (user.isEmpty())
58 user = QDir::homePath();
59 }
60 uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex());
61 }
62
63 this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os));
64}
065
=== added file 'build/src/plugins/org.apache.cordova.device/device.h'
--- build/src/plugins/org.apache.cordova.device/device.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.device/device.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2011 Wolfgang Koller - http://www.gofg.at/
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef DEVICE_H_FDSAFAS
18#define DEVICE_H_FDSAFAS
19
20#include <QtCore>
21
22#include <cplugin.h>
23
24class Device: public CPlugin {
25 Q_OBJECT
26public:
27 explicit Device(Cordova *cordova);
28
29 virtual const QString fullName() override {
30 return Device::fullID();
31 }
32
33 virtual const QString shortName() override {
34 return "Device";
35 }
36
37 static const QString fullID() {
38 return "com.cordova.Device";
39 }
40
41signals:
42
43public slots:
44 void getInfo(int scId, int ecId);
45};
46
47#endif
048
=== added directory 'build/src/plugins/org.apache.cordova.dialogs'
=== added file 'build/src/plugins/org.apache.cordova.dialogs/notification.cpp'
--- build/src/plugins/org.apache.cordova.dialogs/notification.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.dialogs/notification.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,81 @@
1/*
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "notification.h"
17
18#include <QApplication>
19
20#include <QMediaPlayer>
21#include <QMessageBox>
22
23void Dialogs::beep(int scId, int ecId, int times) {
24 Q_UNUSED(scId)
25 Q_UNUSED(ecId)
26 Q_UNUSED(times)
27 QMediaPlayer* player = new QMediaPlayer;
28 player->setVolume(100);
29 player->setMedia(QUrl::fromLocalFile("/usr/share/sounds/ubuntu/stereo/bell.ogg"));
30 player->play();
31}
32
33void Dialogs::alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel) {
34 QStringList list;
35 list.append(buttonLabel);
36
37 confirm(scId, ecId, message, title, list);
38}
39
40void Dialogs::confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels) {
41 Q_UNUSED(ecId);
42
43 //FIXME:
44 assert(!_alertCallback);
45 _alertCallback = scId;
46
47 QString s1, s2, s3;
48 if (buttonLabels.size() > 0)
49 s1 = buttonLabels[0];
50 if (buttonLabels.size() > 1)
51 s2 = buttonLabels[1];
52 if (buttonLabels.size() > 2)
53 s3 = buttonLabels[2];
54
55 QString path = m_cordova->get_app_dir() + "/../qml/notification.qml";
56 //FIXME:
57 QString qml = QString("PopupUtils.open(\"%1\", root, { root: root, cordova: cordova, title: \"%2\", text: \"%3\", promptVisible: false, button1Text: \"%4\", button2Text: \"%5\", button3Text: \"%6\" })")
58 .arg(path).arg(title).arg(message).arg(s1).arg(s2).arg(s3);
59 m_cordova->execQML(qml);
60}
61
62void Dialogs::prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText) {
63 Q_UNUSED(ecId)
64
65 assert(!_alertCallback);
66 _alertCallback = scId;
67
68 QString s1, s2, s3;
69 if (buttonLabels.size() > 0)
70 s1 = buttonLabels[0];
71 if (buttonLabels.size() > 1)
72 s2 = buttonLabels[1];
73 if (buttonLabels.size() > 2)
74 s3 = buttonLabels[2];
75 QString path = m_cordova->get_app_dir() + "/../qml/notification.qml";
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\" })")
77 .arg(path).arg(title).arg(message).arg(s1).arg(s2).arg(s3).arg(defaultText);
78
79 qDebug() << qml;
80 m_cordova->execQML(qml);
81}
082
=== added file 'build/src/plugins/org.apache.cordova.dialogs/notification.h'
--- build/src/plugins/org.apache.cordova.dialogs/notification.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.dialogs/notification.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,63 @@
1/*
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef NOTIFICATION_H
17#define NOTIFICATION_H
18
19#include <QtQuick>
20#include <cplugin.h>
21#include <cordova.h>
22
23class Dialogs: public CPlugin {
24 Q_OBJECT
25public:
26 explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) {
27 }
28
29 virtual const QString fullName() override {
30 return Dialogs::fullID();
31 }
32
33 virtual const QString shortName() override {
34 return "Notification";
35 }
36
37 static const QString fullID() {
38 return "Notification";
39 }
40public slots:
41 void beep(int scId, int ecId, int times);
42 void alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel);
43 void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels);
44 void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText);
45
46 void notificationDialogButtonPressed(int buttonId, const QString &text) {
47 if (text.size()) {
48 QVariantMap res;
49 res.insert("buttonIndex", buttonId);
50 res.insert("input1", text);
51 this->cb(_alertCallback, res);
52 } else {
53 this->cb(_alertCallback, buttonId);
54 }
55 _alertCallback = 0;
56 }
57
58private:
59 QQmlComponent *_component;
60 int _alertCallback;
61};
62
63#endif
064
=== added directory 'build/src/plugins/org.apache.cordova.file'
=== added directory 'build/src/plugins/org.apache.cordova.file-transfer'
=== added file 'build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp'
--- build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.file-transfer/file-transfer.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,247 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#include "file-transfer.h"
21#include <cassert>
22
23void FileTransfer::download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &/*headers*/) {
24 QSharedPointer<FileTransferRequest> request(new FileTransferRequest(_manager, scId, ecId, id, this));
25
26 assert(_id2request.find(id) == _id2request.end());
27
28 _id2request.insert(id, request);
29
30 request->connect(request.data(), &FileTransferRequest::done, [&]() {
31 auto it = _id2request.find(id);
32 while (it != _id2request.end() && it.key() == id) {
33 if (it.value().data() == request.data()) {
34 _id2request.erase(it);
35 break;
36 }
37 it++;
38 }
39 });
40 request->download(url, target);
41}
42
43void FileTransfer::upload(int scId, int ecId, const QString &filePath, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType,
44 const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &httpMethod) {
45 QSharedPointer<FileTransferRequest> request(new FileTransferRequest(_manager, scId, ecId, id, this));
46
47 assert(_id2request.find(id) == _id2request.end());
48
49 _id2request.insert(id, request);
50
51 request->connect(request.data(), &FileTransferRequest::done, [&]() {
52 auto it = _id2request.find(id);
53 while (it != _id2request.end() && it.key() == id) {
54 if (it.value().data() == request.data()) {
55 _id2request.erase(it);
56 break;
57 }
58 it++;
59 }
60 });
61 request->upload(url, filePath, fileKey, fileName, mimeType, params, headers);
62}
63
64void FileTransfer::abort(int scId, int ecId, int id) {
65 Q_UNUSED(scId)
66 Q_UNUSED(ecId)
67
68 auto it = _id2request.find(id);
69 while (it != _id2request.end() && it.key() == id) {
70 (*it)->abort();
71 it++;
72 }
73}
74
75void FileTransferRequest::download(const QString& uri, const QString &target) {
76 QUrl url(uri);
77 QNetworkRequest request;
78
79 if (!url.isValid()) {
80 QVariantMap map;
81 map.insert("code", INVALID_URL_ERR);
82 map.insert("source", uri);
83 map.insert("target", target);
84 _plugin->cb(_ecId, map);
85 emit done();
86 return;
87 }
88
89 request.setUrl(url);
90 if (url.password().size() || url.userName().size()) {
91 QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64();
92 request.setRawHeader("Authorization", headerData.toLocal8Bit());
93 }
94 _reply = QSharedPointer<QNetworkReply>(_manager.get(request));
95
96 _reply->connect(_reply.data(), &QNetworkReply::finished, [this, target, uri]() {
97 if (!_scId || _reply->error() != QNetworkReply::NoError)
98 return;
99
100 QFile res(target);
101 qCritical() << target;
102 if (target[0] != '/' || !res.open(QIODevice::WriteOnly)) {
103 QVariantMap map;
104 map.insert("code", INVALID_URL_ERR);
105 map.insert("source", uri);
106 map.insert("target", target);
107 _plugin->cb(_ecId, map);
108 emit done();
109 return;
110 }
111 res.write(_reply->readAll());
112
113 QFileInfo info(target);
114 QVariantMap map;
115 map.insert("isFile", true);
116 map.insert("isDirectory", false);
117 map.insert("name", info.fileName());
118 map.insert("fullPath", info.absoluteFilePath());
119
120 _plugin->cb(_scId, map);
121
122 emit done();
123 });
124 _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
125 _reply->connect(_reply.data(), SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64)));
126}
127
128void FileTransferRequest::upload(const QString& _url, const QString& filePath, QString fileKey, QString fileName, QString mimeType, const QVariantMap &params, const QVariantMap &headers) {
129 QUrl url(_url);
130 QNetworkRequest request;
131
132 if (!url.isValid()) {
133 QVariantMap map;
134 map.insert("code", INVALID_URL_ERR);
135 map.insert("source", filePath);
136 map.insert("target", _url);
137 _plugin->cb(_ecId, map);
138 emit done();
139 return;
140 }
141
142 QFile file(filePath);
143 if (filePath[0] != '/' || !file.open(QIODevice::ReadOnly)) {
144 QVariantMap map;
145 map.insert("code", FILE_NOT_FOUND_ERR);
146 map.insert("source", filePath);
147 map.insert("target", _url);
148 _plugin->cb(_ecId, map);
149 emit done();
150 return;
151 }
152 QString content{file.readAll()};
153
154 request.setUrl(url);
155 if (url.password().size() || url.userName().size()) {
156 QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64();
157 request.setRawHeader("Authorization", headerData.toLocal8Bit());
158 }
159
160 for (const QString &key: headers.keys()) {
161 const QString &value = headers.find(key)->toString();
162 request.setRawHeader(key.toUtf8(), value.toUtf8());
163 }
164
165 QString boundary = QString("CORDOVA-QT-%1A").arg(qrand());
166 while (content.contains(boundary)) {
167 boundary += QString("B%1A").arg(qrand());
168 }
169
170 request.setHeader(QNetworkRequest::ContentTypeHeader, QString("multipart/form-data; boundary=") + boundary);
171
172 fileKey.replace("\"", "");
173 fileName.replace("\"", "");
174 mimeType.replace("\"", "");
175 QString part = "--" + boundary + "\r\n";
176
177 part += "Content-Disposition: form-data; name=\"" + fileKey +"\"; filename=\"" + fileName + "\"\r\n";
178 part += "Content-Type: " + mimeType + "\r\n\r\n";
179 part += content + "\r\n";
180
181 for (QString key: params.keys()) {
182 part += "--" + boundary + "\r\n";
183 part += "Content-Disposition: form-data; name=\"" + key + "\";\r\n\r\n";
184 part += params.find(key)->toString();
185 part += "\r\n";
186 }
187
188 part += QString("--") + boundary + "--" + "\r\n";
189
190 _reply = QSharedPointer<QNetworkReply>(_manager.post(request, QByteArray(part.toUtf8())));
191
192 _reply->connect(_reply.data(), &QNetworkReply::finished, [this, content]() {
193 if (_reply->error() != QNetworkReply::NoError)
194 return;
195 int status = 200;
196 QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
197
198 if (statusCode.isValid()) {
199 status = statusCode.toInt();
200 }
201
202 QVariantMap map;
203 map.insert("responseCode", status);
204 map.insert("response", QString(_reply->readAll()));
205 map.insert("bytesSent", content.size());
206 _plugin->cb(_scId, map);
207 emit done();
208 });
209 _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
210 _reply->connect(_reply.data(), SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64)));
211}
212
213void FileTransferRequest::abort() {
214 QVariantMap map;
215 map.insert("code", ABORT_ERR);
216 _plugin->cb(_ecId, map);
217 _scId = 0;
218 emit done();
219}
220
221void FileTransferRequest::error(QNetworkReply::NetworkError code) {
222 Q_UNUSED(code);
223
224 int status = 404;
225 QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
226
227 if (statusCode.isValid()) {
228 status = statusCode.toInt();
229 }
230
231 QVariantMap map;
232 map.insert("http_status", status);
233 map.insert("body", QString(_reply->readAll()));
234 map.insert("code", CONNECTION_ERR);
235 _plugin->cb(_ecId, map);
236 emit done();
237}
238
239void FileTransferRequest::progress(qint64 bytesReceived, qint64 bytesTotal) {
240 QVariantMap map;
241 map.insert("lengthComputable", true);
242 map.insert("total", bytesTotal);
243 map.insert("loaded", bytesReceived);
244
245 if (bytesReceived && bytesTotal && _scId)
246 _plugin->callbackWithoutRemove(_scId, CordovaInternal::format(map));
247}
0248
=== added file 'build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h'
--- build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.file-transfer/file-transfer.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,97 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#ifndef FILE_TRANSFER_H_SDASDASDAS
21#define FILE_TRANSFER_H_SDASDASDAS
22
23#include <QtCore>
24#include <QtNetwork>
25
26#include <cplugin.h>
27
28class FileTransferRequest: public QObject {
29 Q_OBJECT
30
31 QNetworkAccessManager &_manager;
32 int _scId, _ecId;
33 int _id;
34 QSharedPointer<QNetworkReply> _reply;
35
36 enum FileTransferError {
37 FILE_NOT_FOUND_ERR = 1,
38 INVALID_URL_ERR = 2,
39 CONNECTION_ERR = 3,
40 ABORT_ERR = 4
41 };
42
43public:
44 FileTransferRequest(QNetworkAccessManager &manager, int scId, int ecId, int id, CPlugin *plugin):
45 _manager(manager),
46 _scId(scId),
47 _ecId(ecId),
48 _id(id),
49 _plugin(plugin) {
50 }
51
52 void download(const QString& url, const QString &target);
53 void upload(const QString& _url, const QString& filePath, QString fileKey, QString fileName, QString mimeType, const QVariantMap &params, const QVariantMap &headers);
54 void abort();
55
56signals:
57 void done();
58
59private slots:
60 void progress(qint64 bytesReceived, qint64 bytesTotal);
61 void error(QNetworkReply::NetworkError code);
62private:
63 CPlugin *_plugin;
64 Q_DISABLE_COPY(FileTransferRequest);
65};
66
67class FileTransfer : public CPlugin {
68 Q_OBJECT
69public:
70 explicit FileTransfer(Cordova *cordova): CPlugin(cordova) {
71 }
72
73 virtual const QString fullName() override {
74 return FileTransfer::fullID();
75 }
76
77 virtual const QString shortName() override {
78 return "FileTransfer";
79 }
80
81 static const QString fullID() {
82 return "FileTransfer";
83 }
84
85public slots:
86 void abort(int scId, int ecId, int id);
87 void download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &/*headers*/);
88 void upload(int scId, int ecId, const QString &filePath, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType,
89 const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &httpMethod);
90
91private:
92 QNetworkAccessManager _manager;
93 QMultiMap<int, QSharedPointer<FileTransferRequest> > _id2request;
94 int lastRequestId;
95};
96
97#endif
098
=== added file 'build/src/plugins/org.apache.cordova.file/file.cpp'
--- build/src/plugins/org.apache.cordova.file/file.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.file/file.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,773 @@
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15#include "file.h"
16
17#include <QApplication>
18
19namespace {
20 class FileError {
21 public:
22 static const QString kEncodingErr;
23 static const QString kTypeMismatchErr;
24 static const QString kNotFoundErr;
25 static const QString kSecurityErr;
26 static const QString kAbortErr;
27 static const QString kNotReadableErr;
28 static const QString kNoModificationAllowedErr;
29 static const QString kInvalidStateErr;
30 static const QString kSyntaxErr;
31 static const QString kInvalidModificationErr;
32 static const QString kQuotaExceededErr;
33 static const QString kPathExistsErr;
34 };
35
36 QVariantMap file2map(const QFileInfo &fileInfo) {
37 QVariantMap res;
38
39 res.insert("name", fileInfo.fileName());
40 res.insert("fullPath", fileInfo.isDir() ? QDir::cleanPath(fileInfo.absoluteFilePath()) : fileInfo.absoluteFilePath());
41 res.insert("isDirectory", (int)fileInfo.isDir());
42 res.insert("isFile", (int)fileInfo.isFile());
43
44 return res;
45 }
46 QVariantMap dir2map(const QDir &dir) {
47 return file2map(QFileInfo(dir.absolutePath()));
48 }
49};
50
51const QString FileError::kEncodingErr("FileError.ENCODING_ERR");
52const QString FileError::kTypeMismatchErr("FileError.TYPE_MISMATCH_ERR");
53const QString FileError::kNotFoundErr("FileError.NOT_FOUND_ERR");
54const QString FileError::kSecurityErr("FileError.SECURITY_ERR");
55const QString FileError::kAbortErr("FileError.ABORT_ERR");
56const QString FileError::kNotReadableErr("FileError.NOT_READABLE_ERR");
57const QString FileError::kNoModificationAllowedErr("FileError.NO_MODIFICATION_ALLOWED_ERR");
58const QString FileError::kInvalidStateErr("FileError.INVALID_STATE_ERR");
59const QString FileError::kSyntaxErr("FileError.SYNTAX_ERR");
60const QString FileError::kInvalidModificationErr("FileError.INVALID_MODIFICATION_ERR");
61const QString FileError::kQuotaExceededErr("FileError.QUOTA_EXCEEDED_ERR");
62const QString FileError::kPathExistsErr("FileError.PATH_EXISTS_ERR");
63
64File::File(Cordova *cordova) :
65 CPlugin(cordova),
66 _persistentDir(QString("%1/.local/share/%2/persistent").arg(QDir::homePath()).arg(QCoreApplication::applicationName())) {
67 QDir::root().mkpath(QDir(_persistentDir).absolutePath());
68}
69
70void File::requestFileSystem(int scId, int ecId, unsigned short type, unsigned long long size) {
71 QDir dir;
72
73 //FIXEME,what is quota value
74 if (size >= 10000){
75 this->callback(ecId, FileError::kQuotaExceededErr);
76 return;
77 }
78
79 if (type == 0)
80 dir = QDir::temp();
81 else
82 dir = QDir(_persistentDir);
83
84 if (type > 1) {
85 this->callback(ecId, FileError::kSyntaxErr);
86 return;
87 } else {
88 QVariantMap res;
89 res.insert("root", dir2map(dir));
90 if (type == 0)
91 res.insert("name", "temporary");
92 else
93 res.insert("name", "persistent");
94
95 this->cb(scId, res);
96 }
97}
98
99void File::resolveLocalFileSystemURI(int scId, int ecId, QString uri) {
100 QUrl url = QUrl::fromUserInput(uri);
101
102 if (!url.isValid() || uri[0] == '/' || uri[0] == '.') {
103 this->callback(ecId, FileError::kEncodingErr);
104 return;
105 }
106
107 if (url.scheme() != "file") {
108 this->callback(ecId, FileError::kTypeMismatchErr);
109 return;
110 }
111
112 QFileInfo fileInfo(url.path());
113
114 if (!fileInfo.exists()) {
115 this->callback(ecId, FileError::kNotFoundErr);
116 return;
117 }
118
119 this->cb(scId, file2map(fileInfo));
120}
121
122void File::getFile(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options) {
123 QString path(rpath);
124
125 if (rpath[0] != '/') {
126 if (!parentPath.size() || !QFileInfo(parentPath).isDir())
127 path = _persistentDir + "/" + rpath;
128 else
129 path = parentPath + "/" + rpath;
130 }
131
132 //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here.
133 if (path.contains(":")){
134 this->callback(ecId, FileError::kEncodingErr);
135 return;
136 }
137
138 QUrl url = QUrl::fromUserInput(path);
139 if (!url.isValid()) {
140 this->callback(ecId, FileError::kEncodingErr);
141 return;
142 }
143
144 if (url.scheme() != "file") {
145 this->callback(ecId, FileError::kTypeMismatchErr);
146 return;
147 }
148
149 bool create = options.value("create").toBool();
150 bool exclusive = options.value("exclusive").toBool();
151 QFile file(path);
152
153 // if create is false and the path represents a directory, return error
154 QFileInfo fileInfo(url.path());
155 if ((!create) && fileInfo.isDir()) {
156 this->callback(ecId, FileError::kTypeMismatchErr);
157 return;
158 }
159
160 // if file does exist, and create is true and exclusive is true, return error
161 if (file.exists()) {
162 if (create && exclusive) {
163 this->callback(ecId, FileError::kPathExistsErr);
164 return;
165 }
166 }
167 else {
168 // if file does not exist and create is false, return error
169 if (!create) {
170 this->callback(ecId, FileError::kNotFoundErr);
171 return;
172 }
173
174 file.open(QIODevice::WriteOnly);
175 file.close();
176
177 // Check if creation was successfull
178 if (!file.exists()) {
179 this->callback(ecId, FileError::kNoModificationAllowedErr);
180 return;
181 }
182 }
183
184 this->cb(scId, file2map(QFileInfo(file)));
185}
186
187void File::getDirectory(int scId, int ecId, QString parentPath, QString rpath, QVariantMap options) {
188 QString path(rpath);
189 if (rpath[0] != '/') {
190 path = parentPath + "/" + rpath;
191 }
192
193 //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here.
194 if (path.contains(":")){
195 this->callback(ecId, FileError::kEncodingErr);
196 return;
197 }
198
199 QUrl url = QUrl::fromUserInput(path);
200 if (!url.isValid()) {
201 this->callback(ecId, FileError::kEncodingErr);
202 return;
203 }
204
205 if (url.scheme() != "file") {
206 this->callback(ecId, FileError::kTypeMismatchErr);
207 return;
208 }
209
210 bool create = options.value("create").toBool();
211 bool exclusive = options.value("exclusive").toBool();
212 QDir dir(path);
213
214 // if create is false and the path represents a file, return error
215 QFileInfo fileInfo(url.path());
216 if ((!create) && fileInfo.isFile()) {
217 this->callback(ecId, FileError::kTypeMismatchErr);
218 return;
219 }
220
221 // if directory does exist and create is true and exclusive is true, return error
222 if (dir.exists()) {
223 if (create && exclusive) {
224 this->callback(ecId, FileError::kPathExistsErr);
225 return;
226 }
227 }
228 else {
229 // if directory does not exist and create is false and directory does not exist, return error
230 if (!create) {
231 this->callback(ecId, FileError::kNotFoundErr);
232 return;
233 }
234
235 // if directory does not exist and create is false and directory does not exist, return error
236 QString folderName = dir.dirName();
237 dir.cdUp();
238 dir.mkdir(folderName);
239 dir.cd(folderName);
240
241 if (!dir.exists()) {
242 this->callback(ecId, FileError::kNoModificationAllowedErr);
243 return;
244 }
245 }
246
247 QVariantMap res;
248 res.insert("name", dir.dirName());
249 res.insert("fullPath", dir.absolutePath());
250 this->cb(scId, res);
251}
252
253void File::removeRecursively(int scId, int ecId, QString path) {
254 QDir dir(path);
255 if (File::rmDir(dir))
256 this->cb(scId);
257 else
258 this->callback(ecId, FileError::kNoModificationAllowedErr);
259}
260
261void File::write(int scId, int ecId, const QString &path, const QString &_data, unsigned long long position, bool binary) {
262 QFile file(path);
263
264 file.open(QIODevice::WriteOnly);
265 file.close();
266
267 if (!file.exists()) {
268 this->callback(ecId, FileError::kNotFoundErr);
269 return;
270 }
271
272 QFileInfo fileInfo(file);
273 if (!file.open(QIODevice::ReadWrite)) {
274 this->callback(ecId, FileError::kNoModificationAllowedErr);
275 return;
276 }
277
278 if (!binary) {
279 QTextStream textStream(&file);
280 textStream.setCodec("UTF-8");
281 textStream.setAutoDetectUnicode(true);
282
283 if (!textStream.seek(position)) {
284 file.close();
285 fileInfo.refresh();
286
287 this->callback(ecId, FileError::kInvalidModificationErr);
288 return;
289 }
290
291 textStream << _data;
292 textStream.flush();
293 } else {
294 QByteArray data(_data.toUtf8());
295 if (!file.seek(position)) {
296 file.close();
297 fileInfo.refresh();
298
299 this->callback(ecId, FileError::kInvalidModificationErr);
300 return;
301 }
302
303 file.write(data.data(), data.length());
304 }
305
306 file.flush();
307 file.close();
308 fileInfo.refresh();
309
310 this->cb(scId, fileInfo.size() - position);
311}
312
313void File::truncate(int scId, int ecId, const QString &path, unsigned long long size) {
314 QFile file(path);
315
316 if (!file.exists()) {
317 this->callback(ecId, FileError::kNotFoundErr);
318 return;
319 }
320
321 if (!file.resize(size)) {
322 this->callback(ecId, FileError::kNoModificationAllowedErr);
323 return;
324 }
325
326 this->cb(scId, size);
327}
328
329void File::getParent(int scId, int ecId, QString path) {
330 QDir dir(path);
331
332 //can't cdup more than app's root
333 // Try to change into upper directory
334 if (path != _persistentDir){
335 if (!dir.cdUp()) {
336 this->callback(ecId, FileError::kNotFoundErr);
337 return;
338 }
339
340 }
341 this->cb(scId, dir2map(dir));
342}
343
344void File::remove(int scId, int ecId, QString path) {
345 QFileInfo fileInfo(path);
346 if (!fileInfo.exists() || (path == _persistentDir)) {
347 this->callback(ecId, FileError::kNoModificationAllowedErr);
348 return;
349 }
350
351 if (fileInfo.isDir()) {
352 QDir dir(path);
353 if (dir.rmdir(dir.absolutePath())) {
354 this->cb(scId);
355 return;
356 }
357 } else {
358 QFile file(path);
359 if (file.remove()) {
360 this->cb(scId);
361 return;
362 }
363 }
364
365 this->callback(ecId, FileError::kInvalidModificationErr);
366}
367
368void File::getFileMetadata(int scId, int ecId, const QString &path) {
369 QFileInfo fileInfo(path);
370
371 if (!fileInfo.exists()) {
372 this->callback(ecId, FileError::kNotFoundErr);
373 } else {
374 QMimeType mime = _db.mimeTypeForFile(fileInfo.fileName());
375
376 QString args = QString("{name: %1, fullPath: %2, type: %3, lastModifiedDate: new Date(%4), size: %5}")
377 .arg(CordovaInternal::format(fileInfo.fileName())).arg(CordovaInternal::format(fileInfo.absoluteFilePath()))
378 .arg(CordovaInternal::format(mime.name())).arg(fileInfo.lastModified().toMSecsSinceEpoch())
379 .arg(fileInfo.size());
380
381 this->callback(scId, args);
382 }
383}
384
385void File::getMetadata(int scId, int ecId, const QString &path) {
386 QFileInfo fileInfo(path);
387
388 if (!fileInfo.exists())
389 this->callback(ecId, FileError::kNotFoundErr);
390 else
391 this->cb(scId, fileInfo.lastModified().toMSecsSinceEpoch());
392}
393
394void File::readEntries(int scId, int ecId, QString path) {
395 QDir dir(path);
396 QString entriesList;
397
398 if (!dir.exists()) {
399 this->callback(ecId, FileError::kNotFoundErr);
400 return;
401 }
402
403 for (const QFileInfo &fileInfo: dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
404 entriesList += CordovaInternal::format(file2map(fileInfo)) + ",";
405 }
406
407 // Remove trailing comma
408 if (entriesList.size() > 0)
409 entriesList.remove(entriesList.size()-1, 1);
410 entriesList = "new Array(" + entriesList + ")";
411
412 this->callback(scId, entriesList);
413}
414
415void File::readAsText(int scId, int ecId, const QString &path, const QString &encoding, int sliceStart, int sliceEnd) {
416 QFile file(path);
417
418 if (!file.exists()) {
419 this->callback(ecId, FileError::kNotFoundErr);
420 return;
421 }
422
423 if (!file.open(QIODevice::ReadOnly)) {
424 this->callback(ecId, FileError::kNotReadableErr);
425 return;
426 }
427
428 QByteArray content = file.readAll();
429
430 if (sliceEnd == -1)
431 sliceEnd = content.size();
432 if (sliceEnd < 0) {
433 sliceEnd++;
434 sliceEnd = std::max(0, content.size() + sliceEnd);
435 }
436 if (sliceEnd > content.size())
437 sliceEnd = content.size();
438
439 if (sliceStart < 0)
440 sliceStart = std::max(0, content.size() + sliceStart);
441 if (sliceStart > content.size())
442 sliceStart = content.size();
443
444 if (sliceStart > sliceEnd)
445 sliceEnd = sliceStart;
446
447 //FIXME: encoding
448 content = content.mid(sliceStart, sliceEnd - sliceStart);
449
450 this->cb(scId, content);
451}
452
453void File::readAsArrayBuffer(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd) {
454 const QString str2array("\
455 (function strToArray(str) { \
456 var res = new Uint8Array(str.length); \
457 for (var i = 0; i < str.length; i++) { \
458 res[i] = str.charCodeAt(i); \
459 } \
460 return res; \
461 })(\"%1\")");
462 QFile file(path);
463
464 if (!file.exists()) {
465 this->callback(ecId, FileError::kNotFoundErr);
466 return;
467 }
468
469 if (!file.open(QIODevice::ReadOnly)) {
470 this->callback(ecId, FileError::kNotReadableErr);
471 return;
472 }
473 QString res;
474 QByteArray content = file.readAll();
475
476 if (sliceEnd == -1)
477 sliceEnd = content.size();
478 if (sliceEnd < 0) {
479 sliceEnd++;
480 sliceEnd = std::max(0, content.size() + sliceEnd);
481 }
482 if (sliceEnd > content.size())
483 sliceEnd = content.size();
484
485 if (sliceStart < 0)
486 sliceStart = std::max(0, content.size() + sliceStart);
487 if (sliceStart > content.size())
488 sliceStart = content.size();
489
490 if (sliceStart > sliceEnd)
491 sliceEnd = sliceStart;
492
493 content = content.mid(sliceStart, sliceEnd - sliceStart);
494
495 res.reserve(content.length() * 6);
496 for (uchar c: content) {
497 res += "\\x";
498 res += QString::number(c, 16).rightJustified(2, '0').toUpper();
499 }
500
501 this->callback(scId, str2array.arg(res));
502}
503
504void File::readAsBinaryString(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd) {
505 QFile file(path);
506
507 if (!file.exists()) {
508 this->callback(ecId, FileError::kNotFoundErr);
509 return;
510 }
511
512 if (!file.open(QIODevice::ReadOnly)) {
513 this->callback(ecId, FileError::kNotReadableErr);
514 return;
515 }
516 QString res;
517 QByteArray content = file.readAll();
518
519 if (sliceEnd == -1)
520 sliceEnd = content.size();
521 if (sliceEnd < 0) {
522 sliceEnd++;
523 sliceEnd = std::max(0, content.size() + sliceEnd);
524 }
525 if (sliceEnd > content.size())
526 sliceEnd = content.size();
527
528 if (sliceStart < 0)
529 sliceStart = std::max(0, content.size() + sliceStart);
530 if (sliceStart > content.size())
531 sliceStart = content.size();
532
533 if (sliceStart > sliceEnd)
534 sliceEnd = sliceStart;
535
536 content = content.mid(sliceStart, sliceEnd - sliceStart);
537
538 res.reserve(content.length() * 6);
539 for (uchar c: content) {
540 res += "\\x";
541 res += QString::number(c, 16).rightJustified(2, '0').toUpper();
542 }
543 this->callback(scId, "\"" + res + "\"");
544}
545
546void File::readAsDataURL(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd) {
547 QFile file(path);
548 QFileInfo fileInfo(path);
549
550 if (path.startsWith("content:")){
551 this->callback(ecId, FileError::kNotReadableErr);
552 return;
553 }
554
555 if (!file.exists()) {
556 this->callback(ecId, FileError::kNotReadableErr);
557 return;
558 }
559 // Try to open file for reading
560 if (!file.open(QIODevice::ReadOnly)) {
561 this->callback(ecId, FileError::kNotReadableErr);
562 return;
563 }
564 // Read the file content
565 QByteArray content = file.readAll();
566 QString contentType(_db.mimeTypeForFile(fileInfo.fileName()).name());
567
568 if (sliceEnd == -1)
569 sliceEnd = content.size();
570 if (sliceEnd < 0) {
571 sliceEnd++;
572 sliceEnd = std::max(0, content.size() + sliceEnd);
573 }
574 if (sliceEnd > content.size())
575 sliceEnd = content.size();
576
577 if (sliceStart < 0)
578 sliceStart = std::max(0, content.size() + sliceStart);
579 if (sliceStart > content.size())
580 sliceStart = content.size();
581
582 if (sliceStart > sliceEnd)
583 sliceEnd = sliceStart;
584
585 content = content.mid(sliceStart, sliceEnd - sliceStart);
586
587 this->cb(scId, QString("data:%1;base64,").arg(contentType) + content.toBase64());
588}
589
590bool File::rmDir(QDir dir) {
591 if (dir == _persistentDir) {//can't remove root dir
592 return false;
593 }
594 bool result = true;
595 if (dir.exists()) {
596 // Iterate over entries and remove them
597 Q_FOREACH(const QFileInfo &fileInfo, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
598 if (fileInfo.isDir()) {
599 result = rmDir(fileInfo.absoluteFilePath());
600 }
601 else {
602 result = QFile::remove(fileInfo.absoluteFilePath());
603 }
604
605 if (!result) {
606 return result;
607 }
608 }
609
610 // Finally remove the current dir
611 return dir.rmdir(dir.absolutePath());
612 }
613 return result;
614}
615
616bool File::copyFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName) {
617 if (!QDir(destinationParentDir).exists()){
618 this->callback(ecId, FileError::kNotFoundErr);
619 return false;
620 }
621
622 QFileInfo fileInfo(sourceFile);
623 QString fileName = ((newName.isEmpty()) ? fileInfo.fileName() : newName);
624 QString destinationFile(destinationParentDir + "/" + fileName);
625
626 //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here.
627 if (!QUrl::fromUserInput(destinationFile).isValid() || destinationFile.contains(":")){
628 this->callback(ecId, FileError::kEncodingErr);
629 return false;
630 }
631
632 if (QFile::copy(sourceFile, destinationFile)){
633 this->cb(scId, file2map(QFileInfo(destinationFile)));
634 return true;
635 } else {
636 this->callback(ecId, FileError::kInvalidModificationErr);
637 return false;
638 }
639}
640
641void File::copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destinationParentDir, const QString& newName) {
642 QDir sourceDir(sourceFolder);
643 QString dirName = ((newName.isEmpty()) ? sourceDir.dirName() : newName);
644 QString destFolder(destinationParentDir + "/" + dirName);
645
646 if (QFileInfo(destFolder).isFile()){
647 this->callback(ecId, FileError::kInvalidModificationErr);
648 return;
649 }
650 QDir destDir(destFolder);
651
652 if ((sourceFolder == destFolder) || (sourceFolder == destinationParentDir)){
653 this->callback(ecId, FileError::kInvalidModificationErr);
654 return;
655 }
656
657 if (!destDir.exists()){
658 destDir.mkdir(destFolder);;
659 } else{
660 this->callback(ecId, FileError::kInvalidModificationErr);
661 return;
662 }
663
664 if (copyFolder(sourceFolder, destFolder)){
665 this->cb(scId, dir2map(destDir));
666 return;
667 } else {
668 this->callback(ecId, FileError::kInvalidModificationErr);
669 return;
670 }
671}
672
673void File::copyTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName) {
674 if (QFileInfo(source).isDir())
675 copyDir(scId, ecId, source, destinationDir, newName);
676 else
677 copyFile(scId, ecId, source, destinationDir, newName);
678}
679
680void File::moveFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName) {
681 QString fileName = ((newName.isEmpty()) ? QFileInfo(sourceFile).fileName() : newName);
682 QString destinationFile(destinationParentDir + "/" + fileName);
683
684 if (QFileInfo(sourceFile) == QFileInfo(destinationFile)) {
685 this->callback(ecId, FileError::kInvalidModificationErr);
686 return;
687 }
688
689 if (!QFileInfo(destinationParentDir).exists()) {
690 this->callback(ecId, FileError::kNotFoundErr);
691 return;
692 }
693
694 if (QFileInfo(destinationFile).exists()) {
695 if (!QFile::remove(QFileInfo(destinationFile).absoluteFilePath())) {
696 this->callback(ecId, FileError::kInvalidModificationErr);
697 return;
698 }
699 }
700
701 QFile::rename(sourceFile, destinationFile);
702 this->cb(scId, file2map(QFileInfo(destinationFile)));
703}
704
705void File::moveDir(int scId, int ecId,const QString& sourceDir, const QString& destinationParentDir, const QString& newName){
706 QString dirName = ((newName.isEmpty()) ? QDir(sourceDir).dirName() : newName);
707 QString destFolder(destinationParentDir + "/" + dirName);
708 QDir destDir(destFolder);
709
710 if (!QFileInfo(destinationParentDir).exists()){
711 this->callback(ecId, FileError::kNotFoundErr);
712 return;
713 }
714
715 if (QFileInfo(destFolder).isFile()){
716 this->callback(ecId, FileError::kInvalidModificationErr);
717 return;
718 }
719
720 if ((QFileInfo(sourceDir) == QFileInfo(destFolder)) || (QFileInfo(sourceDir) == QFileInfo(destinationParentDir))) {
721 this->callback(ecId, FileError::kInvalidModificationErr);
722 return;
723 }
724
725 if (destDir.exists() && !QDir(destinationParentDir).rmdir(dirName)) {
726 this->callback(ecId, FileError::kInvalidModificationErr);
727 return;
728 }
729
730 if (copyFolder(sourceDir, destFolder)) {
731 rmDir(sourceDir);
732 this->cb(scId, file2map(QFileInfo(destFolder)));
733 } else {
734 this->callback(ecId, FileError::kNoModificationAllowedErr);
735 }
736}
737
738void File::moveTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName) {
739 if (newName.contains(":")) {
740 this->callback(ecId, FileError::kEncodingErr);
741 return;
742 }
743 if (QFileInfo(source).isDir())
744 moveDir(scId, ecId, source, destinationDir, newName);
745 else
746 moveFile(scId, ecId, source, destinationDir, newName);
747}
748
749bool File::copyFolder(const QString& sourceFolder, const QString& destFolder) {
750 QDir sourceDir(sourceFolder);
751 if (!sourceDir.exists())
752 return false;
753 QDir destDir(destFolder);
754 if (!destDir.exists()){
755 destDir.mkdir(destFolder);
756 }
757 QStringList files = sourceDir.entryList(QDir::Files);
758 for (int i = 0; i< files.count(); i++)
759 {
760 QString srcName = sourceFolder + "/" + files[i];
761 QString destName = destFolder + "/" + files[i];
762 QFile::copy(srcName, destName);
763 }
764 files.clear();
765 files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
766 for (int i = 0; i< files.count(); i++)
767 {
768 QString srcName = sourceFolder + "/" + files[i];
769 QString destName = destFolder + "/" + files[i];
770 copyFolder(srcName, destName);
771 }
772 return true;
773}
0774
=== added file 'build/src/plugins/org.apache.cordova.file/file.h'
--- build/src/plugins/org.apache.cordova.file/file.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.file/file.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,73 @@
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15#ifndef FILEAPI_H_SDASDASDAS
16#define FILEAPI_H_SDASDASDAS
17
18#include <QNetworkReply>
19#include <QtCore>
20
21#include <cplugin.h>
22#include <cordova.h>
23
24class File: public CPlugin {
25 Q_OBJECT
26public:
27 explicit File(Cordova *cordova);
28
29 virtual const QString fullName() override {
30 return File::fullID();
31 }
32
33 virtual const QString shortName() override {
34 return "File";
35 }
36
37 static const QString fullID() {
38 return "File";
39 }
40
41public slots:
42 void requestFileSystem(int scId, int ecId, unsigned short type, unsigned long long size);
43 void resolveLocalFileSystemURI(int scId, int ecId, QString uri);
44 void getDirectory(int scId, int ecId, QString parentPath, QString path, QVariantMap options);
45 void getFile(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options);
46 void readEntries(int scId, int ecId, QString path);
47 void getParent(int scId, int ecId, QString path);
48 void copyTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName);
49 void moveTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName);
50 void getFileMetadata(int scId, int ecId, const QString &path);
51 void getMetadata(int scId, int ecId, const QString &path);
52 void remove(int scId, int ecId, QString path);
53 void removeRecursively(int scId, int ecId, QString path);
54 void readAsText(int scId, int ecId, const QString &path, const QString &encoding, int sliceStart, int sliceEnd);
55 void write(int scId, int ecId, const QString &path, const QString &_data, unsigned long long position, bool binary);
56 void readAsDataURL(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd);
57 void readAsArrayBuffer(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd);
58 void readAsBinaryString(int scId, int ecId, const QString &path, int sliceStart, int sliceEnd);
59 void truncate(int scId, int ecId, const QString &path, unsigned long long size);
60private:
61 void moveFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName);
62 void moveDir(int scId, int ecId,const QString& sourceFolder, const QString& destFolder, const QString& newName);
63 bool copyFile(int scId, int ecId, const QString& sourceFile, const QString& destinationParentDir, const QString& newName);
64 void copyDir(int scId, int ecId, const QString& sourceFolder, const QString& destFolder, const QString& newName);
65 bool rmDir(QDir dir);
66 bool copyFolder(const QString& sourceFolder, const QString& destFolder);
67
68 QMimeDatabase _db;
69 const QString _persistentDir;
70 QNetworkAccessManager _manager;
71};
72
73#endif
074
=== added directory 'build/src/plugins/org.apache.cordova.geolocation'
=== added file 'build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp'
--- build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.geolocation/geolocation.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,119 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#include <QUuid>
21
22#include "geolocation.h"
23
24Geolocation::Geolocation(Cordova *cordova): CPlugin(cordova),
25 _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) {
26 if (_geoPositionInfoSource.data() != 0) {
27 QObject::connect(_geoPositionInfoSource.data(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
28 QObject::connect(_geoPositionInfoSource.data(), SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
29 }
30}
31
32void Geolocation::addWatch(int scId, int ecId, const QString &id, bool enableHighAccuracy) {
33 Q_UNUSED(enableHighAccuracy);
34
35 assert(_id2sc.find(id) == _id2sc.end());
36
37 if (!_geoPositionInfoSource.data()) {
38 QVariantMap err;
39 err.insert("code", POSITION_UNAVAILABLE);
40 err.insert("message", "unavailable");
41
42 this->cb(ecId, err);
43 return;
44 }
45
46 _id2sc[id] = scId;
47 _id2ec[id] = ecId;
48}
49
50void Geolocation::clearWatch(int scId, int ecId, const QString &id) {
51 _id2sc.remove(id);
52 _id2ec.remove(id);
53}
54
55void Geolocation::getLocation(int scId, int ecId, bool enableHighAccuracy, qint64 maximumAge) {
56 Q_UNUSED(maximumAge);
57 Q_UNUSED(enableHighAccuracy);
58
59 if (!_geoPositionInfoSource.data()) {
60 QVariantMap err;
61 err.insert("code", POSITION_UNAVAILABLE);
62 err.insert("message", "unavailable");
63
64 this->cb(ecId, err);
65 return;
66 }
67
68 _geoPositionInfoSource->requestUpdate();
69
70 QString id = QString("_INTERNAL_") + QUuid::createUuid().toString();
71
72 _id2sc[id] = scId;
73 _id2ec[id] = ecId;
74 _singleUpdate.insert(id);
75}
76
77void Geolocation::positionUpdated(const QGeoPositionInfo &update) {
78 QGeoCoordinate coordinate = update.coordinate();
79
80 QVariantMap p;
81
82 p.insert("latitude", coordinate.latitude());
83 p.insert("longitude", coordinate.longitude());
84 p.insert("altitude", coordinate.altitude());
85
86 if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
87 p.insert("accuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy));
88 if (update.hasAttribute(QGeoPositionInfo::Direction))
89 p.insert("heading", update.attribute(QGeoPositionInfo::Direction));
90 if (update.hasAttribute(QGeoPositionInfo::GroundSpeed))
91 p.insert("velocity", update.attribute(QGeoPositionInfo::GroundSpeed));
92 if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
93 p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy));
94 p.insert("timestamp", update.timestamp().toMSecsSinceEpoch());
95
96 for (const QString &id: _id2sc.keys()) {
97 int scId = _id2sc[id];
98 this->cb(scId, p);
99 if (_singleUpdate.contains(id)) {
100 _singleUpdate.remove(id);
101 _id2sc.remove(id);
102 _id2ec.remove(id);
103 }
104 }
105}
106
107void Geolocation::updateTimeout() {
108 QVariantMap err;
109 err.insert("code", TIMEOUT);
110 err.insert("message", "timeout");
111
112 for (int ecId: _id2ec) {
113 this->cb(ecId, err);
114 }
115
116 _id2ec.clear();
117 _id2sc.clear();
118 _singleUpdate.clear();
119}
0120
=== added file 'build/src/plugins/org.apache.cordova.geolocation/geolocation.h'
--- build/src/plugins/org.apache.cordova.geolocation/geolocation.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.geolocation/geolocation.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,69 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#ifndef GEOLOCATION_H_SVO2013
21#define GEOLOCATION_H_SVO2013
22
23#include <QGeoPositionInfoSource>
24#include <QGeoPositionInfo>
25#include <QtCore>
26#include <cassert>
27
28#include <cplugin.h>
29
30class Geolocation: public CPlugin {
31 Q_OBJECT
32public:
33 explicit Geolocation(Cordova *cordova);
34
35 virtual const QString fullName() override {
36 return Geolocation::fullID();
37 }
38
39 virtual const QString shortName() override {
40 return "Geolocation";
41 }
42
43 static const QString fullID() {
44 return "Geolocation";
45 }
46
47public slots:
48 void getLocation(int scId, int ecId, bool enableHighAccuracy, qint64 maximumAge);
49 void addWatch(int scId, int ecId, const QString &id, bool enableHighAccuracy);
50 void clearWatch(int scId, int ecId, const QString &id);
51
52protected slots:
53 void positionUpdated(const QGeoPositionInfo &update);
54 void updateTimeout();
55
56private:
57 QMap<QString, int> _id2sc;
58 QMap<QString, int> _id2ec;
59 QSet<QString> _singleUpdate;
60 QSharedPointer<QGeoPositionInfoSource> _geoPositionInfoSource;
61
62 enum PositionError {
63 PERMISSION_DENIED = 1,
64 POSITION_UNAVAILABLE = 2,
65 TIMEOUT = 3
66 };
67};
68
69#endif
070
=== added directory 'build/src/plugins/org.apache.cordova.globalization'
=== added file 'build/src/plugins/org.apache.cordova.globalization/globalization.cpp'
--- build/src/plugins/org.apache.cordova.globalization/globalization.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.globalization/globalization.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,342 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#include <ctime> //TODO: switch to QTimeZone (QT 5.1)
21#include <unicode/decimfmt.h>
22#include <unicode/timezone.h>
23
24#include "globalization.h"
25
26Globalization::Globalization(Cordova *cordova):
27 CPlugin(cordova) {
28}
29
30void Globalization::getPreferredLanguage(int scId, int ecId) {
31 Q_UNUSED(ecId)
32
33 QLocale locale;
34 QString lang = QLocale::languageToString(locale.language());
35 QVariantMap obj;
36 obj.insert("value", lang);
37 this->cb(scId, obj);
38}
39
40void Globalization::getLocaleName(int scId, int ecId) {
41 Q_UNUSED(ecId)
42
43 QVariantMap obj;
44 obj.insert("value", QLocale().name());
45 this->cb(scId, obj);
46}
47
48void Globalization::getFirstDayOfWeek(int scId, int ecId) {
49 Q_UNUSED(ecId)
50
51 QLocale locale;
52
53 int res;
54 if (locale.firstDayOfWeek() == Qt::Sunday) {
55 res = 1;
56 } else {
57 res = (2 - Qt::Monday) + locale.firstDayOfWeek();
58 }
59
60 QVariantMap obj;
61 obj.insert("value", res);
62 this->cb(scId, obj);
63}
64
65void Globalization::isDayLightSavingsTime(int scId, int ecId, const QVariantMap &options) {
66 time_t time = options.find("time_t")->toLongLong() / 1000;
67 const tm *desc = std::localtime(&time);
68 if (desc->tm_isdst < 0) {
69 this->callback(ecId, QString("new GlobalizationError(%1, 'information is not available');").arg(Globalization::UNKNOWN_ERROR));
70 return;
71 }
72 this->callback(scId, QString("{dst:%1}").arg(desc->tm_isdst > 0 ? "true" : "false"));
73}
74
75QLocale::FormatType translateFormat(Globalization::Format formatLength) {
76 QLocale::FormatType format = QLocale::ShortFormat;
77 switch (formatLength) {
78 case Globalization::FORMAT_FULL:
79 case Globalization::FORMAT_LONG:
80 format = QLocale::ShortFormat; // TODO: Qt cant parse string produced with QLocale::LongFormat;
81 break;
82 case Globalization::FORMAT_MEDIUM:
83 format = QLocale::ShortFormat;
84 break;
85 case Globalization::FORMAT_SHORT:
86 format = QLocale::NarrowFormat;
87 break;
88 }
89 return format;
90}
91
92void Globalization::dateToString(int scId, int ecId, const QVariantMap &options) {
93 time_t time = options.find("time_t")->toLongLong() / 1000;
94
95 Globalization::Format formatLength = static_cast<Globalization::Format>(options.find("formatLength")->toInt());
96 Globalization::Selector selector = static_cast<Globalization::Selector>(options.find("selector")->toInt());
97
98 QLocale::FormatType format = translateFormat(formatLength);
99 if (time < 0) {
100 this->callback(ecId, QString("new GlobalizationError(%1, 'unsupported operation');").arg(Globalization::FORMATTING_ERROR));
101 return;
102 }
103
104 QLocale locale;
105 QString res;
106 QDateTime dateTime = QDateTime::fromTime_t((uint)time);
107 switch (selector) {
108 case SELECTOR_ALL:
109 res = locale.toString(dateTime,format);
110 break;
111 case SELECTOR_TIME:
112 res = locale.toString(dateTime.time(), format);
113 break;
114 case SELECTOR_DATE:
115 res = locale.toString(dateTime.date(), format);
116 break;
117 }
118 QVariantMap obj;
119 obj.insert("value", res);
120 this->cb(scId, obj);
121}
122
123void Globalization::stringToDate(int scId, int ecId, const QVariantMap &options) {
124 QString dateString = options.find("dateString")->toString();
125 Globalization::Format formatLength = static_cast<Globalization::Format>(options.find("formatLength")->toInt());
126 Globalization::Selector selector = static_cast<Globalization::Selector>(options.find("selector")->toInt());
127
128 QLocale::FormatType format = translateFormat(formatLength);
129 QLocale locale;
130 bool valid(true);
131 int year(0), month(0), day(0), hour(0), minute(0), second(0), millisecond(0);
132 switch (selector) {
133 case SELECTOR_ALL:
134 {
135 QDateTime dateTime = locale.toDateTime(dateString, format);
136 valid = dateTime.isValid();
137 QTime time = dateTime.time();
138 hour = time.hour(); minute = time.minute(); second = time.second(); millisecond = time.msec();
139 QDate date = dateTime.date();
140 year = date.year(); month = date.month(); day = date.day();
141 }
142 break;
143 case SELECTOR_TIME:
144 {
145 QTime time = locale.toTime(dateString, format);
146 valid = time.isValid();
147 hour = time.hour(); minute = time.minute(); second = time.second(); millisecond = time.msec();
148 }
149 break;
150 case SELECTOR_DATE:
151 {
152 QDate date = locale.toDate(dateString, format);
153 valid = date.isValid();
154 year = date.year(); month = date.month(); day = date.day();
155 }
156 break;
157 }
158 if ((format == QLocale::NarrowFormat || format == QLocale::ShortFormat) && year < 2000 && year > 1900) {
159 year += 100;
160 }
161 if (!valid) {
162 this->callback(ecId, QString("new GlobalizationError(%1, 'parsing error')").arg(Globalization::PARSING_ERROR));
163 } else {
164 QVariantMap obj;
165 obj.insert("year", year);
166 obj.insert("month", month - 1);
167 obj.insert("day", day);
168 obj.insert("hour", hour);
169 obj.insert("minute", minute);
170 obj.insert("second", second);
171 obj.insert("millisecond", millisecond);
172 this->cb(scId, obj);
173 }
174}
175
176void Globalization::getDateNames(int scId, int ecId, const QVariantMap &options) {
177 Q_UNUSED(ecId)
178
179 int type = options.find("type")->toInt();
180 int item = options.find("item")->toInt();
181
182 QLocale::FormatType format;
183 if (type == FORMAT_SHORT)
184 format = QLocale::ShortFormat;
185 else
186 format = QLocale::LongFormat;
187 QLocale locale;
188 QList<QString> res;
189 if (item == REQUEST_DAY_NAMES) {
190 for (int i = 1; i <= 7; i++) {
191 res.append(locale.dayName(i, format));
192 }
193 } else { //REQUEST_MONTH_NAMES
194 for (int i = 1; i <= 12; i++) {
195 res.append(locale.monthName(i, format));
196 }
197 }
198
199 QString result;
200 for (QList<QString>::iterator it = res.begin(); it != res.end(); it++) {
201 result += QString("'%1',").arg(*it);
202 }
203 this->callback(scId, QString("{ value: [ %1 ]}").arg(result));
204}
205
206template<class T>
207static QString format(T number, Globalization::NumberType type) {
208 QString res;
209 QLocale locale;
210 switch (type) {
211 case Globalization::DECIMAL:
212 res = locale.toString(number);
213 break;
214 case Globalization::PERCENT:
215 res = locale.toString(number) + locale.percent();
216 break;
217 case Globalization::CURRENCY:
218 res = locale.toCurrencyString(number);
219 break;
220 };
221 return res;
222}
223
224void Globalization::numberToString(int scId, int ecId, const QVariantMap &options) {
225 Q_UNUSED(ecId)
226
227 bool isInt = options.find("isInt")->toBool();
228 NumberType type = static_cast<NumberType>(options.find("type")->toBool());
229
230 QString res;
231 if (isInt) {
232 long long number = options.find("number")->toLongLong();
233 res = format(number, type);
234 } else {
235 double number = options.find("number")->toDouble();
236 res = format(number, type);
237 }
238 this->callback(scId, QString("{ value: '%1' }").arg(res));
239}
240
241void Globalization::stringToNumber(int scId, int ecId, int type, QString string) {
242 switch ((NumberType)type) {
243 case Globalization::DECIMAL:
244 string = string.remove(QLocale().groupSeparator());
245 break;
246 case Globalization::PERCENT:
247 string = string.remove(QLocale().percent()).remove(QLocale().groupSeparator());
248 break;
249 case Globalization::CURRENCY:
250 string = string.remove(QLocale().currencySymbol()).remove(QLocale().groupSeparator());
251 break;
252 };
253 bool ok;
254 double res = QLocale().toDouble(string, &ok);
255 if (ok)
256 this->callback(scId, QString("{ value: %1 }").arg(res));
257 else
258 this->callback(ecId, QString("new GlobalizationError(%1, 'parsing error')").arg(Globalization::PARSING_ERROR));
259}
260
261static QString ustr2qstr(UnicodeString &ustr) {
262 std::string res;
263 ustr.toUTF8String(res);
264
265 return QString(res.c_str());
266}
267
268void Globalization::getNumberPattern(int scId, int ecId, int type) {
269 Q_UNUSED(ecId);
270 UErrorCode status = U_ZERO_ERROR;
271 icu::DecimalFormat icu(status);
272
273 icu::UnicodeString pattern;
274 icu.toPattern(pattern);
275
276 QLocale locale;
277 QVariantMap obj;
278
279 obj.insert("pattern", ustr2qstr(pattern));
280
281 switch ((NumberType)type) {
282 case Globalization::DECIMAL:
283 obj.insert("symbol", "");
284 break;
285 case Globalization::PERCENT:
286 obj.insert("symbol", QString(locale.percent()));
287 break;
288 case Globalization::CURRENCY:
289 obj.insert("symbol", QString(locale.currencySymbol()));
290 break;
291 };
292
293 obj.insert("fraction", icu.getMaximumFractionDigits());
294 obj.insert("rounding", icu.getRoundingIncrement());
295 obj.insert("positive", QString(locale.positiveSign()));
296 obj.insert("negative", QString(locale.negativeSign()));
297 obj.insert("decimal", QString(locale.decimalPoint()));
298 obj.insert("grouping", QString(locale.groupSeparator()));
299
300 this->cb(scId, obj);
301}
302
303static bool inDayLightSavingsTime() {
304 time_t now;
305
306 time(&now);
307
308 const tm *desc = std::localtime(&now);
309
310 return desc->tm_isdst > 0;
311}
312
313void Globalization::getDatePattern(int scId, int ecId, int formatLength, int selector) {
314 Q_UNUSED(ecId);
315
316 QLocale locale;
317 QVariantMap res;
318 QLocale::FormatType format = translateFormat((Format)formatLength);
319
320 switch ((Selector)selector) {
321 case Selector::SELECTOR_TIME:
322 res.insert("pattern", locale.timeFormat(format));
323 break;
324 case Selector::SELECTOR_DATE:
325 res.insert("pattern", locale.dateFormat(format));
326 break;
327 case Selector::SELECTOR_ALL:
328 res.insert("pattern", locale.dateTimeFormat(format));
329 break;
330 };
331
332 UnicodeString result;
333 QSharedPointer<TimeZone> timezone = QSharedPointer<TimeZone>(TimeZone::createDefault());
334 timezone->getDisplayName(inDayLightSavingsTime(), TimeZone::SHORT, result);
335
336 res.insert("timezone", ustr2qstr(result));
337 res.insert("utc_offset", timezone->getRawOffset() / 1000 + timezone->getDSTSavings() / 1000);
338 res.insert("dst_offset", timezone->getDSTSavings() / 1000);
339
340 this->cb(scId, res);
341}
342
0343
=== added file 'build/src/plugins/org.apache.cordova.globalization/globalization.h'
--- build/src/plugins/org.apache.cordova.globalization/globalization.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.globalization/globalization.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,93 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19#ifndef GLOBALIZATION_H_SVO2013
20#define GLOBALIZATION_H_SVO2013
21
22#include <QtCore>
23#include <QLocale>
24
25#include <cplugin.h>
26
27class Globalization: public CPlugin {
28 Q_OBJECT
29 enum GlobalizationError {
30 UNKNOWN_ERROR = 0,
31 FORMATTING_ERROR = 1,
32 PARSING_ERROR = 2,
33 PATTERN_ERROR = 3
34 };
35
36 enum Selector {
37 SELECTOR_DATE = 0,
38 SELECTOR_TIME = 1,
39 SELECTOR_ALL = 2
40 };
41
42 enum Format {
43 FORMAT_SHORT = 0,
44 FORMAT_MEDIUM = 1,
45 FORMAT_LONG = 2,
46 FORMAT_FULL = 3
47 };
48
49 enum {
50 REQUEST_DAY_NAMES = 0,
51 REQUEST_MONTH_NAMES = 1
52 };
53
54 enum NumberType {
55 DECIMAL,
56 PERCENT,
57 CURRENCY
58 };
59
60public:
61 explicit Globalization(Cordova *cordova);
62
63 virtual const QString fullName() override {
64 return Globalization::fullID();
65 }
66
67 virtual const QString shortName() override {
68 return "Globalization";
69 }
70
71 static const QString fullID() {
72 return "Globalization";
73 }
74
75public slots:
76 void getPreferredLanguage(int scId, int ecId);
77 void getLocaleName(int scId, int ecId);
78 void getFirstDayOfWeek(int scId, int ecId);
79 void isDayLightSavingsTime(int scId, int ecId, const QVariantMap &options);
80 void dateToString(int scId, int ecId, const QVariantMap &options);
81 void stringToDate(int scId, int ecId, const QVariantMap &options);
82
83 void getDateNames(int scId, int ecId, const QVariantMap &options);
84 void numberToString(int scId, int ecId, const QVariantMap &options);
85 void stringToNumber(int scId, int ecId, int type, QString string);
86 void getNumberPattern(int scId, int ecId, int type);
87 void getDatePattern(int scId, int ecId, int formatLength, int selector);
88private:
89 friend QLocale::FormatType translateFormat(Globalization::Format formatLength);
90 template<class T> friend QString format(T number, Globalization::NumberType type);
91};
92
93#endif
094
=== added directory 'build/src/plugins/org.apache.cordova.inappbrowser'
=== added file 'build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp'
--- build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,106 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23
24#include <QQuickView>
25#include <QQuickItem>
26
27#include "inappbrowser.h"
28#include <cordova.h>
29
30Inappbrowser::Inappbrowser(Cordova *cordova): CPlugin(cordova), _eventCb(0) {
31}
32
33const char code[] = "\
34var component, object; \
35function createObject() { \
36 component = Qt.createComponent(%1); \
37 if (component.status == Component.Ready) \
38 finishCreation(); \
39 else \
40 component.statusChanged.connect(finishCreation); \
41} \
42function finishCreation() { \
43 CordovaWrapper.object = component.createObject(root, \
44 {root: root, cordova: cordova, url1: %2}); \
45} \
46createObject()";
47
48const char EXIT_EVENT[] = "'exit'";
49const char LOADSTART_EVENT[] = "'loadstart'";
50const char LOADSTOP_EVENT[] = "'loadstop'";
51const char LOADERROR_EVENT[] = "'loaderror'";
52
53void Inappbrowser::open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures) {
54 assert(_eventCb == 0);
55
56 _eventCb = cb;
57
58 QString path = m_cordova->get_app_dir() + "/../qml/InAppBrowser.qml";
59
60 // TODO: relative url
61 QString qml = QString(code)
62 .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(url));
63 m_cordova->execQML(qml);
64}
65
66void Inappbrowser::show(int, int) {
67 m_cordova->execQML("CordovaWrapper.object.visible = true");
68}
69
70void Inappbrowser::close(int, int) {
71 m_cordova->execQML("CordovaWrapper.object.destroy()");
72 this->callbackWithoutRemove(_eventCb, EXIT_EVENT);
73 _eventCb = 0;
74}
75
76void Inappbrowser::injectStyleFile(int cb, int, const QString&, bool) {
77 // TODO:
78 qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
79}
80
81void Inappbrowser::injectStyleCode(int cb, int, const QString&, bool) {
82 // TODO:
83 qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
84}
85
86void Inappbrowser::injectScriptFile(int cb, int, const QString&, bool) {
87 // TODO:
88 qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
89}
90
91void Inappbrowser::injectScriptCode(int cb, int, const QString&, bool) {
92 // TODO:
93 qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
94}
95
96void Inappbrowser::loadFinished(int status) {
97 if (status == 2) {
98 this->callbackWithoutRemove(_eventCb, LOADERROR_EVENT);
99 }
100 if (status == 0) {
101 this->callbackWithoutRemove(_eventCb, LOADSTART_EVENT);
102 }
103 if (status == 3) {
104 this->callbackWithoutRemove(_eventCb, LOADSTOP_EVENT);
105 }
106}
0107
=== added file 'build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h'
--- build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.inappbrowser/inappbrowser.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,61 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23#ifndef INAPPBROWSER_H
24#define INAPPBROWSER_H
25
26#include <QtCore>
27#include <cplugin.h>
28
29class Inappbrowser: public CPlugin {
30 Q_OBJECT
31public:
32 Inappbrowser(Cordova *cordova);
33
34 virtual const QString fullName() override {
35 return Inappbrowser::fullID();
36 }
37
38 virtual const QString shortName() override {
39 return "InAppBrowser";
40 }
41
42 static const QString fullID() {
43 return "InAppBrowser";
44 }
45
46public slots:
47 void open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures);
48 void show(int, int);
49 void close(int, int);
50 void injectStyleFile(int cb, int, const QString&, bool);
51 void injectStyleCode(int cb, int, const QString&, bool);
52 void injectScriptFile(int cb, int, const QString&, bool);
53 void injectScriptCode(int cb, int, const QString&, bool);
54
55 void loadFinished(int status);
56
57private:
58 int _eventCb;
59};
60
61#endif
062
=== added directory 'build/src/plugins/org.apache.cordova.media'
=== added directory 'build/src/plugins/org.apache.cordova.media-capture'
=== added file 'build/src/plugins/org.apache.cordova.media-capture/capture.cpp'
--- build/src/plugins/org.apache.cordova.media-capture/capture.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.media-capture/capture.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,167 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19#include "capture.h"
20
21const char code[] = "\
22var component, object; \
23function createObject() { \
24 component = Qt.createComponent(%1); \
25 if (component.status == Component.Ready) \
26 finishCreation(); \
27 else \
28 component.statusChanged.connect(finishCreation); \
29} \
30function finishCreation() { \
31 CordovaWrapper.captureObject = component.createObject(root, \
32 {root: root, cordova: cordova, state: \"%2\"}); \
33} \
34createObject()";
35
36static QString formatFile(const QMimeDatabase &db, const QString &path) {
37 QFileInfo info(path);
38 QMimeType mime = db.mimeTypeForFile(info.fileName());
39
40 QVariantMap file;
41 file.insert("name", info.fileName());
42 file.insert("fullPath", info.absoluteFilePath());
43 file.insert("lastModifiedDate", info.lastModified().toMSecsSinceEpoch());
44 file.insert("size", info.size());
45 file.insert("type", mime.name());
46
47 return CordovaInternal::format(file);
48}
49
50MediaCapture::MediaCapture(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) {
51}
52
53void MediaCapture::captureAudio(int scId, int ecId, QVariantMap options) {
54 if (_scId || _ecId) {
55 this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
56 return;
57 }
58
59 QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
60
61 // TODO: relative url
62 QString qml = QString(code).arg(CordovaInternal::format(path)).arg("audio");
63 m_cordova->execQML(qml);
64
65 _scId = scId;
66 _ecId = ecId;
67}
68
69void MediaCapture::onAudioRecordError(QMediaRecorder::Error) {
70 if (!_ecId)
71 return;
72 this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_INTERNAL_ERR));
73 _ecId = _scId = 0;
74
75 _recorder.clear();
76 _files.clear();
77
78 m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
79}
80
81void MediaCapture::recordAudio() {
82 if (_recorder.data()) {
83 QUrl url = _recorder->outputLocation();
84
85 QString path = url.toString();
86 _recorder->stop();
87
88 _recorder.clear();
89
90 this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
91 _ecId = _scId = 0;
92
93 m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
94 } else {
95 _recorder = QSharedPointer<QAudioRecorder>(new QAudioRecorder);
96 QObject::connect(_recorder.data(), SIGNAL(error(QMediaRecorder::Error)), this, SLOT(onAudioRecordError(QMediaRecorder::Error)));
97
98 if (_options.find("mode")->toString() == "audio/amr") {
99 _recorder->setContainerFormat("amr");
100 _recorder->setOutputLocation(generateLocation("amr"));
101 } else {
102 _recorder->setContainerFormat("wav");
103 _recorder->setOutputLocation(generateLocation("wav"));
104 }
105 _recorder->record();
106 }
107}
108
109void MediaCapture::cancel() {
110 if (!_ecId)
111 return;
112
113 m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
114
115 _recorder.clear();
116 this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_NO_MEDIA_FILES));
117 _ecId = _scId = 0;
118
119 _recorder.clear();
120}
121
122void MediaCapture::captureVideo(int scId, int ecId, QVariantMap options) {
123 if (_scId || _ecId) {
124 this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
125 return;
126 }
127
128 QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
129
130 // TODO: relative url
131 QString qml = QString(code).arg(CordovaInternal::format(path)).arg("videoRecording");
132 m_cordova->execQML(qml);
133
134 _scId = scId;
135 _ecId = ecId;
136}
137
138void MediaCapture::onVideoRecordEnd(QString path) {
139 assert(path.startsWith("file:"));
140 path = path.mid(5);
141
142 this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
143 _ecId = _scId = 0;
144
145 m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
146}
147
148void MediaCapture::captureImage(int scId, int ecId, QVariantMap options) {
149 if (_scId || _ecId) {
150 this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
151 return;
152 }
153
154 QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
155
156 // TODO: relative url
157 QString qml = QString(code).arg(CordovaInternal::format(path)).arg("camera");
158 m_cordova->execQML(qml);
159
160 _scId = scId;
161 _ecId = ecId;
162}
163
164void MediaCapture::onImageSaved(const QString &path) {
165 this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
166 _ecId = _scId = 0;
167}
0168
=== added file 'build/src/plugins/org.apache.cordova.media-capture/capture.h'
--- build/src/plugins/org.apache.cordova.media-capture/capture.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.media-capture/capture.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,84 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19#ifndef CAPTURE_H_ASCXZFG975
20#define CAPTURE_H_ASCXZFG975
21
22#include <cordova.h>
23#include <cplugin.h>
24#include <QtMultimedia>
25#include <QtCore>
26#include <QtQuick>
27
28class MediaCapture: public CPlugin {
29 Q_OBJECT
30public:
31 explicit MediaCapture(Cordova *cordova);
32
33 virtual const QString fullName() override {
34 return MediaCapture::fullID();
35 }
36
37 virtual const QString shortName() override {
38 return "Capture";
39 }
40
41 static const QString fullID() {
42 return "Capture";
43 }
44
45public slots:
46 void captureAudio(int scId, int ecId, QVariantMap options);
47 void captureImage(int scId, int ecId, QVariantMap options);
48 void captureVideo(int scId, int ecId, QVariantMap options);
49
50 void recordAudio();
51 void cancel();
52 void onVideoRecordEnd(QString path);
53 void onImageSaved(const QString &path);
54
55 QString generateLocation(const QString &extension) {
56 int i = 1;
57 for (;;++i) {
58 QString path = QString("%1/.local/share/%2/persistent/%3.%4").arg(QDir::homePath())
59 .arg(QCoreApplication::applicationName()).arg(i).arg(extension);
60
61 if (!QFileInfo(path).exists())
62 return path;
63 }
64 }
65private slots:
66 void onAudioRecordError(QMediaRecorder::Error);
67private:
68 QSharedPointer<QAudioRecorder> _recorder;
69
70 int _scId, _ecId;
71 QList<QString> _files;
72 QVariantMap _options;
73 QMimeDatabase _db;
74
75 enum CaptureError {
76 CAPTURE_INTERNAL_ERR = 0,
77 CAPTURE_APPLICATION_BUSY = 1,
78 CAPTURE_INVALID_ARGUMENT = 2,
79 CAPTURE_NO_MEDIA_FILES = 3,
80 CAPTURE_NOT_SUPPORTED = 20
81 };
82};
83
84#endif
085
=== added file 'build/src/plugins/org.apache.cordova.media/media.cpp'
--- build/src/plugins/org.apache.cordova.media/media.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.media/media.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,128 @@
1/*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22#include "media.h"
23
24void Media::create(int scId, int ecId, const QString &id, const QString &src) {
25 Q_UNUSED(scId);
26 Q_UNUSED(ecId);
27
28 if (_id2Player.find(id) != _id2Player.end()) {
29 _id2Player[id]->stop();
30 _id2Player.remove(id);
31 }
32
33 _id2Player[id] = QSharedPointer<Player>(new Player(id, src, this));
34}
35
36void Media::relase(int scId, int ecId, const QString &id) {
37 Q_UNUSED(scId);
38 Q_UNUSED(ecId);
39
40 if (_id2Player.find(id) == _id2Player.end())
41 return;
42 _id2Player.remove(id);
43}
44
45void Media::startPlayingAudio(int scId, int ecId, const QString &id, const QString &src, QVariantMap options) {
46 Q_UNUSED(scId);
47 Q_UNUSED(ecId);
48 Q_UNUSED(src);
49 Q_UNUSED(options);
50
51 if (_id2Player.find(id) == _id2Player.end())
52 return;
53 QSharedPointer<Player> player = _id2Player[id];
54 player->play();
55}
56
57void Media::pausePlayingAudio(int scId, int ecId, const QString &id) {
58 Q_UNUSED(scId);
59 Q_UNUSED(ecId);
60
61 if (_id2Player.find(id) == _id2Player.end())
62 return;
63 QSharedPointer<Player> player = _id2Player[id];
64 player->pause();
65}
66
67void Media::stopPlayingAudio(int scId, int ecId, const QString &id) {
68 Q_UNUSED(scId);
69 Q_UNUSED(ecId);
70
71 if (_id2Player.find(id) == _id2Player.end())
72 return;
73 QSharedPointer<Player> player = _id2Player[id];
74 player->stop();
75}
76
77void Media::startRecordingAudio(int scId, int ecId, const QString &id, const QString &src) {
78 Q_UNUSED(scId);
79 Q_UNUSED(ecId);
80 Q_UNUSED(src);
81
82 if (_id2Player.find(id) == _id2Player.end())
83 return;
84 QSharedPointer<Player> player = _id2Player[id];
85 player->startRecording();
86}
87
88void Media::stopRecordingAudio(int scId, int ecId, const QString &id) {
89 Q_UNUSED(scId);
90 Q_UNUSED(ecId);
91
92 if (_id2Player.find(id) == _id2Player.end())
93 return;
94 QSharedPointer<Player> player = _id2Player[id];
95 player->stopRecording();
96}
97
98void Media::getCurrentPositionAudio(int scId, int ecId, const QString &id) {
99 Q_UNUSED(ecId);
100
101 if (_id2Player.find(id) == _id2Player.end())
102 return;
103
104 QSharedPointer<Player> player = _id2Player[id];
105 double position = player->getPosition();
106 this->cb(scId, position);
107}
108
109void Media::seekToAudio(int scId, int ecId, const QString &id, qint64 position) {
110 Q_UNUSED(scId);
111 Q_UNUSED(ecId);
112
113 if (_id2Player.find(id) == _id2Player.end())
114 return;
115
116 QSharedPointer<Player> player = _id2Player[id];
117 player->seekTo(position);
118}
119
120void Media::setVolume(int scId, int ecId, const QString &id, int volume) {
121 Q_UNUSED(scId);
122 Q_UNUSED(ecId);
123
124 if (_id2Player.find(id) == _id2Player.end())
125 return;
126 QSharedPointer<Player> player = _id2Player[id];
127 player->setVolume(volume);
128}
0129
=== added file 'build/src/plugins/org.apache.cordova.media/media.h'
--- build/src/plugins/org.apache.cordova.media/media.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.media/media.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,267 @@
1/*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22#ifndef MEDIA_H_789768978
23#define MEDIA_H_789768978
24
25#include <QtMultimedia/QMediaPlayer>
26#include <QtCore>
27#include <QAudioRecorder>
28#include <QtMultimedia/QAudioEncoderSettings>
29
30#include <cplugin.h>
31#include <cordova.h>
32
33class Player;
34
35class Media: public CPlugin {
36 Q_OBJECT
37public:
38 explicit Media(Cordova *cordova): CPlugin(cordova) {
39 }
40
41 virtual const QString fullName() override {
42 return Media::fullID();
43 }
44
45 virtual const QString shortName() override {
46 return "Media";
47 }
48
49 static const QString fullID() {
50 return "Media";
51 }
52
53 enum State {
54 MEDIA_NONE = 0,
55 MEDIA_STARTING = 1,
56 MEDIA_RUNNING = 2,
57 MEDIA_PAUSED = 3,
58 MEDIA_STOPPED = 4
59 };
60 enum ErrorCode {
61 MEDIA_ERR_NONE_ACTIVE = 0,
62 MEDIA_ERR_ABORTED = 1,
63 MEDIA_ERR_NETWORK = 2,
64 MEDIA_ERR_DECODE = 3,
65 MEDIA_ERR_NONE_SUPPORTED = 4
66 };
67
68 void execJS(const QString &js) {
69 m_cordova->execJS(js);
70 }
71public slots:
72 void create(int scId, int ecId, const QString &id, const QString &src);
73 void relase(int scId, int ecId, const QString &id);
74
75 void startRecordingAudio(int scId, int ecId, const QString &id, const QString &src);
76 void stopRecordingAudio(int scId, int ecId, const QString &id);
77
78 void startPlayingAudio(int scId, int ecId, const QString &id, const QString &src, QVariantMap options);
79 void pausePlayingAudio(int scId, int ecId, const QString &id);
80 void stopPlayingAudio(int scId, int ecId, const QString &id);
81 void getCurrentPositionAudio(int scId, int ecId, const QString &id);
82 void seekToAudio(int scId, int ecId, const QString &id, qint64 position);
83 void setVolume(int scId, int ecId, const QString &id, int volume);
84
85private:
86 QMap<QString, QSharedPointer<Player> > _id2Player;
87};
88
89class Player: public QObject {
90 Q_OBJECT
91public:
92 Player(const QString &id, QString src, Media *plugin):
93 _state(Media::MEDIA_NONE),
94 _src(src),
95 _mode(MODE_NONE),
96 _plugin(plugin),
97 _id(id),
98 _stateChanged(false) {
99 QUrl url(src, QUrl::TolerantMode);
100
101 if (url.scheme().isEmpty()) {
102 QAudioEncoderSettings audioSettings;
103
104 _recorder.setEncodingSettings(audioSettings);
105 _recorder.setOutputLocation(QFileInfo(src).absoluteFilePath());
106
107 _player.setMedia(QUrl::fromLocalFile(QFileInfo(src).absoluteFilePath()));
108 } else {
109 _player.setMedia(url);
110 }
111 QObject::connect(&_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(onMediaStatusChanged(QMediaPlayer::MediaStatus)));
112 QObject::connect(&_recorder, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(onError(QMediaRecorder::Error)));
113
114 connect(&_timer, SIGNAL(timeout()), this, SLOT(reportPosition()));
115 }
116
117 void startRecording() {
118 if (recordMode() && _state != Media::MEDIA_RUNNING) {
119 _recorder.record();
120 setState(Media::MEDIA_RUNNING);
121 }
122 }
123 void stopRecording() {
124 if (recordMode() && _state == Media::MEDIA_RUNNING) {
125 _recorder.stop();
126 setState(Media::MEDIA_STOPPED);
127 }
128 }
129
130 void setVolume(int volume) {
131 _player.setVolume(volume);
132 }
133
134 void play() {
135 if (playMode() && _state != Media::MEDIA_RUNNING) {
136 _player.play();
137 setState(Media::MEDIA_RUNNING);
138 }
139 }
140 void pause() {
141 if (playMode() && _state == Media::MEDIA_RUNNING) {
142 _player.pause();
143 setState(Media::MEDIA_PAUSED);
144 }
145 }
146 void stop() {
147 if (playMode() && (_state == Media::MEDIA_RUNNING || _state == Media::MEDIA_PAUSED)) {
148 _player.stop();
149 setState(Media::MEDIA_STOPPED);
150 }
151 }
152 double getDuration() {
153 if (_mode == MODE_NONE || _player.duration() == -1)
154 return -1;
155 if (_mode != MODE_PLAY)
156 return -2;
157 return static_cast<double>(_player.duration()) / 1000.0;
158 }
159 double getPosition() {
160 if (_mode != MODE_PLAY)
161 return -1;
162 return static_cast<double>(_player.position()) / 1000.0;
163 }
164 bool seekTo(qint64 position) {
165 if (!_player.isSeekable())
166 return false;
167 _player.setPosition(position * 1000);
168 return true;
169 }
170private slots:
171 void reportPosition() {
172 double position = getPosition();
173 _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_POSITION, %2)")
174 .arg(_id).arg(position));
175 double duration = getDuration();
176 _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_DURATION, %2)")
177 .arg(_id).arg(duration));
178
179 if (_stateChanged && !(_state == Media::MEDIA_RUNNING && (duration == -1 || position == 0))) {
180 qCritical() << _id << "POSITION" << position << ":" << duration;
181 _stateChanged = false;
182 _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_STATE, %2)").arg(_id).arg(_state));
183 }
184 }
185
186 void onMediaStatusChanged(QMediaPlayer::MediaStatus status) {
187 if (status == QMediaPlayer::InvalidMedia) {
188 reportError(Media::MEDIA_ERR_ABORTED, "AudioPlayer Error: The current media cannot be played.");
189 setState(Media::MEDIA_STOPPED);
190 }
191 if (status == QMediaPlayer::EndOfMedia) {
192 setState(Media::MEDIA_STOPPED);
193 seekTo(0);
194 }
195 }
196 void onError(QMediaRecorder::Error) {
197 reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: Device is not ready or not available.");
198 setState(Media::MEDIA_STOPPED);
199 }
200
201private:
202 void reportError(int code, const QString &descr) {
203 Q_UNUSED(descr);
204 _plugin->execJS(QString("Media.onStatus('%1', Media.MEDIA_ERROR, {code: %2})")
205 .arg(_id).arg(code));
206 }
207
208 bool playMode() {
209 switch (_mode) {
210 case Player::MODE_NONE:
211 _mode = MODE_PLAY;
212 break;
213 case Player::MODE_PLAY:
214 break;
215 case Player::MODE_RECORD:
216 reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: Can't play in record mode.");
217 return false;
218 break;
219 }
220 return true;
221 }
222
223 bool recordMode() {
224 switch (_mode) {
225 case Player::MODE_NONE:
226 if (_recorder.outputLocation().isEmpty()) {
227 reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: unsupported output location.");
228 return false;
229 }
230 _mode = MODE_RECORD;
231 break;
232 case Player::MODE_PLAY:
233 reportError(Media::MEDIA_ERR_NONE_SUPPORTED, "AudioPlayer Error: Can't play in play mode.");
234 return false;
235 break;
236 case Player::MODE_RECORD:
237 break;
238 }
239 return true;
240 }
241
242 void setState(Media::State state) {
243 _state = state;
244 _stateChanged = true;
245 _timer.start(250);
246 }
247
248 QMediaPlayer _player;
249
250 QAudioRecorder _recorder;
251 QTimer _timer;
252
253 Media::State _state;
254 QString _src;
255 enum Mode {
256 MODE_NONE,
257 MODE_PLAY,
258 MODE_RECORD
259 };
260 Mode _mode;
261 Media *_plugin;
262 QString _id;
263
264 bool _stateChanged;
265};
266
267#endif
0268
=== added directory 'build/src/plugins/org.apache.cordova.splashscreen'
=== added file 'build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp'
--- build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.splashscreen/splashscreen.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,42 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23
24#include <QQuickItem>
25
26#include "splashscreen.h"
27#include <cordova.h>
28
29#define SPLASHSCREEN_STATE_NAME "splashscreen"
30
31Splashscreen::Splashscreen(Cordova *cordova): CPlugin(cordova) {
32}
33
34void Splashscreen::show(int, int) {
35 m_cordova->rootObject()->setProperty("splashscreenPath", m_cordova->getSplashscreenPath());
36
37 m_cordova->pushViewState(SPLASHSCREEN_STATE_NAME);
38}
39
40void Splashscreen::hide(int, int) {
41 m_cordova->popViewState(SPLASHSCREEN_STATE_NAME);
42}
043
=== added file 'build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h'
--- build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.splashscreen/splashscreen.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,52 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23
24#ifndef SPLASHSCREEN_H
25#define SPLASHSCREEN_H
26
27#include <QtCore>
28#include <cplugin.h>
29
30class Splashscreen: public CPlugin {
31 Q_OBJECT
32public:
33 explicit Splashscreen(Cordova *cordova);
34
35 virtual const QString fullName() override {
36 return Splashscreen::fullID();
37 }
38
39 virtual const QString shortName() override {
40 return "SplashScreen";
41 }
42
43 static const QString fullID() {
44 return "SplashScreen";
45 }
46
47public slots:
48 void show(int, int);
49 void hide(int, int);
50};
51
52#endif // SPLASHSCREEN_H
053
=== added directory 'build/src/plugins/org.apache.cordova.vibration'
=== added file 'build/src/plugins/org.apache.cordova.vibration/vibration.cpp'
--- build/src/plugins/org.apache.cordova.vibration/vibration.cpp 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.vibration/vibration.cpp 2014-02-19 16:53:58 +0000
@@ -0,0 +1,38 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#include <QFeedbackHapticsEffect>
21#include "vibration.h"
22
23void Vibration::vibrate(int, int, int mills) {
24 QFeedbackHapticsEffect *vibrate = new QFeedbackHapticsEffect;
25 vibrate->setIntensity(1.0);
26 vibrate->setDuration(mills);
27
28 connect(vibrate, &QFeedbackHapticsEffect::stateChanged, [&]() {
29 QFeedbackEffect *effect = qobject_cast<QFeedbackEffect *>(sender());
30 if (!effect)
31 return;
32 if (effect->state() == QFeedbackEffect::Stopped)
33 effect->deleteLater();
34 });
35
36 vibrate->start();
37}
38
039
=== added file 'build/src/plugins/org.apache.cordova.vibration/vibration.h'
--- build/src/plugins/org.apache.cordova.vibration/vibration.h 1970-01-01 00:00:00 +0000
+++ build/src/plugins/org.apache.cordova.vibration/vibration.h 2014-02-19 16:53:58 +0000
@@ -0,0 +1,47 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 *
18*/
19
20#ifndef _VIBRATION_H_SFAFKNVX3456
21#define _VIBRATION_H_SFAFKNVX3456
22
23#include <QtQuick>
24#include <cplugin.h>
25
26class Vibration: public CPlugin {
27 Q_OBJECT
28public:
29 explicit Vibration(Cordova *cordova): CPlugin(cordova) {
30 }
31
32 virtual const QString fullName() override {
33 return Vibration::fullID();
34 }
35
36 virtual const QString shortName() override {
37 return "Vibration";
38 }
39
40 static const QString fullID() {
41 return "Vibration";
42 }
43public slots:
44 void vibrate(int, int, int mills);
45};
46
47#endif
048
=== modified file 'config.xml'
--- config.xml 2014-02-05 23:42:31 +0000
+++ config.xml 2014-02-19 16:53:58 +0000
@@ -1,5 +1,24 @@
1<?xml version='1.0' encoding='utf-8'?>1<?xml version='1.0' encoding='utf-8'?>
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">
3 <preference name="loglevel" value="DEBUG" />
4 <feature name="Camera">
5 <param policy_group="camera" policy_version="1" />
6 </feature>
7 <feature name="DeviceOrientation">
8 <param policy_group="sensors" policy_version="1" />
9 </feature>
10 <feature name="Geolocation">
11 <param policy_group="location" policy_version="1" />
12 </feature>
13 <feature name="Media">
14 <param policy_group="microphone" policy_version="1" />
15 <param policy_group="video" policy_version="1" />
16 </feature>
17 <feature name="Capture">
18 <param policy_group="audio" policy_version="1" />
19 <param policy_group="camera" policy_version="1" />
20 <param policy_group="microphone" policy_version="1" />
21 </feature>
3 <name>HelloCordova</name>22 <name>HelloCordova</name>
4 <description>23 <description>
5 A sample Apache Cordova application that responds to the deviceready event.24 A sample Apache Cordova application that responds to the deviceready event.
625
=== modified file 'debian/changelog'
--- debian/changelog 2014-02-18 10:03:39 +0000
+++ debian/changelog 2014-02-19 16:53:58 +0000
@@ -1,3 +1,9 @@
1cordova-ubuntu-3.4 (3.4~pre3.r17ubuntu2) trusty; urgency=low
2
3 * Test build with additional plugins
4
5 -- David Barth <david.barth@canonical.com> Wed, 19 Feb 2014 17:48:58 +0100
6
1cordova-ubuntu-3.4 (3.4~pre3.r17) trusty; urgency=medium7cordova-ubuntu-3.4 (3.4~pre3.r17) trusty; urgency=medium
28
3 [ Alexandre Abreu ]9 [ Alexandre Abreu ]
@@ -11,6 +17,12 @@
1117
12 -- Daniel Holbach <daniel.holbach@ubuntu.com> Fri, 14 Feb 2014 10:21:43 +010018 -- Daniel Holbach <daniel.holbach@ubuntu.com> Fri, 14 Feb 2014 10:21:43 +0100
1319
20cordova-ubuntu-3.4 (3.4~pre3ubuntu1) UNRELEASED; urgency=low
21
22 * Add the full set of platform plugins
23
24 -- David Barth <david.barth@canonical.com> Fri, 14 Feb 2014 16:17:05 +0100
25
14cordova-ubuntu-3.4 (3.4~pre3) trusty; urgency=low26cordova-ubuntu-3.4 (3.4~pre3) trusty; urgency=low
1527
16 * Trusty build28 * Trusty build
1729
=== modified file 'debian/control'
--- debian/control 2014-02-17 16:24:58 +0000
+++ debian/control 2014-02-19 16:53:58 +0000
@@ -28,8 +28,10 @@
28Architecture: any28Architecture: any
29Depends: ${misc:Depends},29Depends: ${misc:Depends},
30 ${shlibs:Depends},30 ${shlibs:Depends},
31Description: Ubuntu HTML5 Framework for building mobile web apps - development files31Description: Cordova Framework for building mobile web apps - development files
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
33 apps using standardized web APIs for the platforms you care about.
33 .34 .
34 They are not meant to be used locally, but are embedded in the resulting35 This package contains library files that are needed to build applications.
35 click packages.36 The libraries are not meant to be installed on the system, but should be
37 embedded in a click package.
3638
=== modified file 'debian/rules'
--- debian/rules 2014-02-17 16:24:58 +0000
+++ debian/rules 2014-02-19 16:53:58 +0000
@@ -1,12 +1,33 @@
1#!/usr/bin/make -f1#!/usr/bin/make -f
2# -*- makefile -*-2# -*- makefile -*-
33
4# to update the source tree:
5# create a temporary directory to construct the runtime with the cordova CLI tool
6# cordova create runtime
7# cd runtime
8# cordova platform add ubuntu
9# cordova plugin add org.apache.cordova.camera
10# cordova plugin add <other plugins>
11# ...
12# cordova prepare
13# then copy back files from the platforms/ubuntu directory
14
4DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)15DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
16INSTALL_PREFIX="/usr/share/ubuntu-html5-platform-3.4/${DEB_HOST_MULTIARCH}"
17PACKAGE_NAME=ubuntu-html5-platform-3.4-dev
518
6override_dh_auto_configure:19override_dh_auto_configure:
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} \
8 -DCMAKE_VERBOSE_MAKEFILE=ON \21 -DCMAKE_VERBOSE_MAKEFILE=ON \
9 -DCMAKE_BUILD_TYPE=RelWithDebInfo22 -DCMAKE_BUILD_TYPE=RelWithDebInfo
1023
24override_dh_install:
25 dh_install
26 cp -R www debian/${PACKAGE_NAME}/${INSTALL_PREFIX}/; \
27 cp -R qml debian/${PACKAGE_NAME}/${INSTALL_PREFIX}/; \
28 rm -f debian/${PACKAGE_NAME}/${INSTALL_PREFIX}/cordova-ubuntu
29
30override_dh_strip:
31
11%:32%:
12 dh $@ --sourcedirectory=build --fail-missing33 dh $@ --sourcedirectory=build --fail-missing
1334
=== added directory 'qml'
=== added file 'qml/CaptureWidget.qml'
--- qml/CaptureWidget.qml 1970-01-01 00:00:00 +0000
+++ qml/CaptureWidget.qml 2014-02-19 16:53:58 +0000
@@ -0,0 +1,119 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23import QtQuick 2.0
24import QtMultimedia 5.0
25
26Rectangle {
27 property string shootImagePath: "shoot.png"
28 function isSuffix(str, suffix) {
29 return String(str).substr(String(str).length - suffix.length) == suffix
30 }
31
32 id: ui
33 color: "#252423"
34 anchors.fill: parent
35
36 Camera {
37 objectName: "camera"
38 id: camera
39 onError: {
40 console.log(errorString);
41 }
42 videoRecorder.audioBitRate: 128000
43 videoRecorder.mediaContainer: "mp4"
44 imageCapture {
45 onImageSaved: {
46 root.exec("Camera", "onImageSaved", [path]);
47 ui.destroy();
48 }
49 }
50 }
51 VideoOutput {
52 id: output
53 source: camera
54 width: parent.width
55 height: parent.height
56 }
57
58 Item {
59 anchors.bottom: parent.bottom
60 width: parent.width
61 height: shootButton.height
62 BorderImage {
63 id: leftBackground
64 anchors.left: parent.left
65 anchors.top: parent.top
66 anchors.bottom: parent.bottom
67 anchors.right: middle.left
68 anchors.topMargin: units.dp(2)
69 anchors.bottomMargin: units.dp(2)
70 source: "toolbar-left.png"
71 Image {
72 anchors.verticalCenter: parent.verticalCenter
73 anchors.left: parent.left
74 anchors.leftMargin: parent.iconSpacing
75 source: "back.png"
76 width: units.gu(6)
77 height: units.gu(5)
78 MouseArea {
79 anchors.fill: parent
80 onClicked: {
81 root.exec("Camera", "cancel");
82 }
83 }
84 }
85 }
86 BorderImage {
87 id: middle
88 anchors.top: parent.top
89 anchors.bottom: parent.bottom
90 anchors.horizontalCenter: parent.horizontalCenter
91 height: shootButton.height + units.gu(1)
92 width: shootButton.width
93 source: "toolbar-middle.png"
94 Image {
95 id: shootButton
96 width: units.gu(8)
97 height: width
98 anchors.horizontalCenter: parent.horizontalCenter
99 source: shootImagePath
100 MouseArea {
101 anchors.fill: parent
102 onClicked: {
103 camera.imageCapture.capture();
104 }
105 }
106 }
107 }
108 BorderImage {
109 id: rightBackground
110 anchors.right: parent.right
111 anchors.top: parent.top
112 anchors.bottom: parent.bottom
113 anchors.left: middle.right
114 anchors.topMargin: units.dp(2)
115 anchors.bottomMargin: units.dp(2)
116 source: "toolbar-right.png"
117 }
118 }
119}
0120
=== added file 'qml/InAppBrowser.qml'
--- qml/InAppBrowser.qml 1970-01-01 00:00:00 +0000
+++ qml/InAppBrowser.qml 2014-02-19 16:53:58 +0000
@@ -0,0 +1,69 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23import QtQuick 2.0
24import QtWebKit 3.0
25import Ubuntu.Components.Popups 0.1
26import Ubuntu.Components 0.1
27
28Rectangle {
29 anchors.fill: parent
30 id: inappbrowser
31 property string url1
32 Rectangle {
33 border.color: "black"
34 width: parent.width
35 height: urlEntry.height
36 color: "gray"
37 TextInput {
38 id: urlEntry
39 width: parent.width - closeButton.width
40 text: url1
41 activeFocusOnPress: false
42 }
43 Image {
44 id: closeButton
45 width: height
46 x: parent.width - width
47 height: parent.height
48 source: "close.png"
49 MouseArea {
50 anchors.fill: parent
51 onClicked: {
52 root.exec("InAppBrowser", "close", [0, 0])
53 }
54 }
55 }
56 }
57
58 WebView {
59 width: parent.width
60 y: urlEntry.height
61 height: parent.height - y
62 url: url1
63 onLoadingChanged: {
64 if (loadRequest.status) {
65 root.exec("InAppBrowser", "loadFinished", [loadRequest.status])
66 }
67 }
68 }
69}
070
=== added file 'qml/MediaCaptureWidget.qml'
--- qml/MediaCaptureWidget.qml 1970-01-01 00:00:00 +0000
+++ qml/MediaCaptureWidget.qml 2014-02-19 16:53:58 +0000
@@ -0,0 +1,207 @@
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23import QtQuick 2.0
24import QtMultimedia 5.0
25
26Rectangle {
27 property string recordOffImagePath: "record_off.png"
28 property string recordOnImagePath: "record_on.png"
29 property string shootImagePath: "shoot.png"
30 function isSuffix(str, suffix) {
31 return String(str).substr(String(str).length - suffix.length) == suffix
32 }
33
34 id: ui
35 color: "#252423"
36 anchors.fill: parent
37 state: "off"
38
39 Camera {
40 objectName: "camera"
41 id: camera
42 cameraState: Camera.UnloadedState
43 onError: {
44 console.log(errorString);
45 shootButton.source = recordOffImagePath
46 }
47 imageCapture {
48 onImageSaved: {
49 root.exec("Capture", "onImageSaved", [path]);
50 ui.destroy();
51 }
52 }
53 videoRecorder {
54 audioBitRate: 128000
55 mediaContainer: "mp4"
56 outputLocation: ui.parent.plugin('Capture').generateLocation("mp4")
57 onRecorderStateChanged: {
58 if (videoRecorder.recorderState === CameraRecorder.StoppedState) {
59 ui.parent.exec("Capture", "onVideoRecordEnd", [camera.videoRecorder.actualLocation]);
60 shootButton.source = recordOffImagePath
61 }
62 }
63 }
64 }
65 Image {
66 id: microphoneImage
67 source: "microphone.png"
68 smooth: true
69 visible: false
70 width: parent.width
71 height: parent.height
72 }
73 VideoOutput {
74 id: output
75 focus : visible
76 source: camera
77 width: parent.width
78 height: parent.height
79 }
80
81 Item {
82 anchors.bottom: parent.bottom
83 width: parent.width
84 height: shootButton.height
85 BorderImage {
86 id: leftBackground
87 anchors.left: parent.left
88 anchors.top: parent.top
89 anchors.bottom: parent.bottom
90 anchors.right: middle.left
91 anchors.topMargin: units.dp(2)
92 anchors.bottomMargin: units.dp(2)
93 source: "toolbar-left.png"
94 Image {
95 anchors.verticalCenter: parent.verticalCenter
96 anchors.left: parent.left
97 anchors.leftMargin: parent.iconSpacing
98 source: "back.png"
99 width: units.gu(6)
100 height: units.gu(5)
101 MouseArea {
102 anchors.fill: parent
103 onClicked: {
104 root.exec("Capture", "cancel");
105 }
106 }
107 }
108 }
109 BorderImage {
110 id: middle
111 anchors.top: parent.top
112 anchors.bottom: parent.bottom
113 anchors.horizontalCenter: parent.horizontalCenter
114 height: shootButton.height + units.gu(1)
115 width: shootButton.width
116 source: "toolbar-middle.png"
117 Image {
118 id: shootButton
119 width: units.gu(8)
120 height: width
121 anchors.horizontalCenter: parent.horizontalCenter
122 source: shootImagePath
123 MouseArea {
124 anchors.fill: parent
125 onClicked: {
126 if (ui.state === "camera") {
127 camera.imageCapture.captureToLocation(ui.parent.plugin('Capture').generateLocation("jpg"));
128 } else if (ui.state === "audio") {
129 ui.parent.exec("Capture", "recordAudio");
130 if (isSuffix(shootButton.source, recordOffImagePath)) {
131 shootButton.source = recordOnImagePath
132 } else {
133 shootButton.source = recordOffImagePath
134 }
135 } else if (ui.state === "videoRecording") {
136 if (!camera.videoRecorder.recorderState) {
137 shootButton.source = recordOnImagePath
138 camera.videoRecorder.record();
139 } else {
140 camera.videoRecorder.stop();
141 }
142 }
143 }
144 }
145 }
146 }
147 BorderImage {
148 id: rightBackground
149 anchors.right: parent.right
150 anchors.top: parent.top
151 anchors.bottom: parent.bottom
152 anchors.left: middle.right
153 anchors.topMargin: units.dp(2)
154 anchors.bottomMargin: units.dp(2)
155 source: "toolbar-right.png"
156 }
157 }
158 states: [
159 State {
160 name: "off"
161 StateChangeScript {
162 script:{
163 ui.visible = false;
164 camera.stop();
165 camera.unlock();
166 }
167 }
168 },
169 State {
170 name: "camera"
171 StateChangeScript {
172 script: {
173 camera.start();
174 microphoneImage.visible = false
175 output.visible = true
176 shootButton.source = shootImagePath
177 ui.visible = true
178 }
179 }
180 },
181 State {
182 name: "videoRecording"
183 StateChangeScript {
184 script: {
185 shootButton.source = recordOffImagePath
186 camera.start();
187 microphoneImage.visible = false
188 output.visible = true
189 ui.visible = true
190 }
191 }
192 },
193 State {
194 name: "audio"
195 StateChangeScript {
196 script:{
197 shootButton.source = recordOffImagePath
198 camera.stop();
199 microphoneImage.visible = true
200 camera.unlock();
201 output.visible = false
202 ui.visible = true
203 }
204 }
205 }
206 ]
207}
0208
=== added file 'qml/back.png'
1Binary files qml/back.png 1970-01-01 00:00:00 +0000 and qml/back.png 2014-02-19 16:53:58 +0000 differ209Binary files qml/back.png 1970-01-01 00:00:00 +0000 and qml/back.png 2014-02-19 16:53:58 +0000 differ
=== added file 'qml/close.png'
2Binary files qml/close.png 1970-01-01 00:00:00 +0000 and qml/close.png 2014-02-19 16:53:58 +0000 differ210Binary files qml/close.png 1970-01-01 00:00:00 +0000 and qml/close.png 2014-02-19 16:53:58 +0000 differ
=== added file 'qml/microphone.png'
3Binary files qml/microphone.png 1970-01-01 00:00:00 +0000 and qml/microphone.png 2014-02-19 16:53:58 +0000 differ211Binary files qml/microphone.png 1970-01-01 00:00:00 +0000 and qml/microphone.png 2014-02-19 16:53:58 +0000 differ
=== added file 'qml/notification.qml'
--- qml/notification.qml 1970-01-01 00:00:00 +0000
+++ qml/notification.qml 2014-02-19 16:53:58 +0000
@@ -0,0 +1,44 @@
1import QtQuick 2.0
2import Ubuntu.Components.Popups 0.1
3import Ubuntu.Components 0.1
4
5Dialog {
6 id: dialogue
7 property string button1Text
8 property string button2Text
9 property string button3Text
10 property bool promptVisible
11 property string defaultPromptText
12 TextInput {// FIXME: swith to TextField(TextField should support visible property)
13 id: prompt
14 color: "white"
15 text: defaultPromptText
16 visible: promptVisible
17 focus: true
18 }
19 Button {
20 text: button1Text
21 color: "orange"
22 onClicked: {
23 root.exec("Notification", "notificationDialogButtonPressed", [1, prompt.text]);
24 PopupUtils.close(dialogue)
25 }
26 }
27 Button {
28 text: button2Text
29 visible: button2Text.length > 0
30 color: "orange"
31 onClicked: {
32 root.exec("Notification", "notificationDialogButtonPressed", [2, prompt.text]);
33 PopupUtils.close(dialogue)
34 }
35 }
36 Button {
37 text: button3Text
38 visible: button3Text.length > 0
39 onClicked: {
40 root.exec("Notification", "notificationDialogButtonPressed", [3, prompt.text]);
41 PopupUtils.close(dialogue)
42 }
43 }
44}
045
=== added file 'qml/record_off.png'
1Binary files qml/record_off.png 1970-01-01 00:00:00 +0000 and qml/record_off.png 2014-02-19 16:53:58 +0000 differ46Binary 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
=== added file 'qml/record_on.png'
2Binary files qml/record_on.png 1970-01-01 00:00:00 +0000 and qml/record_on.png 2014-02-19 16:53:58 +0000 differ47Binary 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
=== added file 'qml/shoot.png'
3Binary files qml/shoot.png 1970-01-01 00:00:00 +0000 and qml/shoot.png 2014-02-19 16:53:58 +0000 differ48Binary files qml/shoot.png 1970-01-01 00:00:00 +0000 and qml/shoot.png 2014-02-19 16:53:58 +0000 differ
=== added file 'qml/toolbar-left.png'
4Binary files qml/toolbar-left.png 1970-01-01 00:00:00 +0000 and qml/toolbar-left.png 2014-02-19 16:53:58 +0000 differ49Binary 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
=== added file 'qml/toolbar-middle.png'
5Binary files qml/toolbar-middle.png 1970-01-01 00:00:00 +0000 and qml/toolbar-middle.png 2014-02-19 16:53:58 +0000 differ50Binary 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
=== added file 'qml/toolbar-right.png'
6Binary files qml/toolbar-right.png 1970-01-01 00:00:00 +0000 and qml/toolbar-right.png 2014-02-19 16:53:58 +0000 differ51Binary 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
=== modified file 'www/cordova_plugins.js'
--- www/cordova_plugins.js 2014-02-05 23:42:31 +0000
+++ www/cordova_plugins.js 2014-02-19 16:53:58 +0000
@@ -1,7 +1,412 @@
1cordova.define('cordova/plugin_list', function(require, exports, module) {1cordova.define('cordova/plugin_list', function(require, exports, module) {
2module.exports = [];2module.exports = [
3 {
4 "file": "plugins/org.apache.cordova.battery-status/www/battery.js",
5 "id": "org.apache.cordova.battery-status.battery",
6 "clobbers": [
7 "navigator.battery"
8 ]
9 },
10 {
11 "file": "plugins/org.apache.cordova.camera/www/CameraConstants.js",
12 "id": "org.apache.cordova.camera.Camera",
13 "clobbers": [
14 "Camera"
15 ]
16 },
17 {
18 "file": "plugins/org.apache.cordova.camera/www/CameraPopoverOptions.js",
19 "id": "org.apache.cordova.camera.CameraPopoverOptions",
20 "clobbers": [
21 "CameraPopoverOptions"
22 ]
23 },
24 {
25 "file": "plugins/org.apache.cordova.camera/www/Camera.js",
26 "id": "org.apache.cordova.camera.camera",
27 "clobbers": [
28 "navigator.camera"
29 ]
30 },
31 {
32 "file": "plugins/org.apache.cordova.camera/www/CameraPopoverHandle.js",
33 "id": "org.apache.cordova.camera.CameraPopoverHandle",
34 "clobbers": [
35 "CameraPopoverHandle"
36 ]
37 },
38 {
39 "file": "plugins/org.apache.cordova.console/www/console-via-logger.js",
40 "id": "org.apache.cordova.console.console",
41 "clobbers": [
42 "console"
43 ]
44 },
45 {
46 "file": "plugins/org.apache.cordova.console/www/logger.js",
47 "id": "org.apache.cordova.console.logger",
48 "clobbers": [
49 "cordova.logger"
50 ]
51 },
52 {
53 "file": "plugins/org.apache.cordova.device/www/device.js",
54 "id": "org.apache.cordova.device.device",
55 "clobbers": [
56 "device"
57 ]
58 },
59 {
60 "file": "plugins/org.apache.cordova.device/src/ubuntu/device.js",
61 "id": "org.apache.cordova.device.DeviceProxy",
62 "merges": [
63 "device"
64 ]
65 },
66 {
67 "file": "plugins/org.apache.cordova.device-motion/www/Acceleration.js",
68 "id": "org.apache.cordova.device-motion.Acceleration",
69 "clobbers": [
70 "Acceleration"
71 ]
72 },
73 {
74 "file": "plugins/org.apache.cordova.device-motion/www/accelerometer.js",
75 "id": "org.apache.cordova.device-motion.accelerometer",
76 "clobbers": [
77 "navigator.accelerometer"
78 ]
79 },
80 {
81 "file": "plugins/org.apache.cordova.device-orientation/www/CompassError.js",
82 "id": "org.apache.cordova.device-orientation.CompassError",
83 "clobbers": [
84 "CompassError"
85 ]
86 },
87 {
88 "file": "plugins/org.apache.cordova.device-orientation/www/CompassHeading.js",
89 "id": "org.apache.cordova.device-orientation.CompassHeading",
90 "clobbers": [
91 "CompassHeading"
92 ]
93 },
94 {
95 "file": "plugins/org.apache.cordova.device-orientation/www/compass.js",
96 "id": "org.apache.cordova.device-orientation.compass",
97 "clobbers": [
98 "navigator.compass"
99 ]
100 },
101 {
102 "file": "plugins/org.apache.cordova.dialogs/www/notification.js",
103 "id": "org.apache.cordova.dialogs.notification",
104 "merges": [
105 "navigator.notification"
106 ]
107 },
108 {
109 "file": "plugins/org.apache.cordova.file/www/DirectoryEntry.js",
110 "id": "org.apache.cordova.file.DirectoryEntry",
111 "clobbers": [
112 "window.DirectoryEntry"
113 ]
114 },
115 {
116 "file": "plugins/org.apache.cordova.file/www/DirectoryReader.js",
117 "id": "org.apache.cordova.file.DirectoryReader",
118 "clobbers": [
119 "window.DirectoryReader"
120 ]
121 },
122 {
123 "file": "plugins/org.apache.cordova.file/www/Entry.js",
124 "id": "org.apache.cordova.file.Entry",
125 "clobbers": [
126 "window.Entry"
127 ]
128 },
129 {
130 "file": "plugins/org.apache.cordova.file/www/File.js",
131 "id": "org.apache.cordova.file.File",
132 "clobbers": [
133 "window.File"
134 ]
135 },
136 {
137 "file": "plugins/org.apache.cordova.file/www/FileEntry.js",
138 "id": "org.apache.cordova.file.FileEntry",
139 "clobbers": [
140 "window.FileEntry"
141 ]
142 },
143 {
144 "file": "plugins/org.apache.cordova.file/www/FileError.js",
145 "id": "org.apache.cordova.file.FileError",
146 "clobbers": [
147 "window.FileError"
148 ]
149 },
150 {
151 "file": "plugins/org.apache.cordova.file/www/FileReader.js",
152 "id": "org.apache.cordova.file.FileReader",
153 "clobbers": [
154 "window.FileReader"
155 ]
156 },
157 {
158 "file": "plugins/org.apache.cordova.file/www/FileSystem.js",
159 "id": "org.apache.cordova.file.FileSystem",
160 "clobbers": [
161 "window.FileSystem"
162 ]
163 },
164 {
165 "file": "plugins/org.apache.cordova.file/www/FileUploadOptions.js",
166 "id": "org.apache.cordova.file.FileUploadOptions",
167 "clobbers": [
168 "window.FileUploadOptions"
169 ]
170 },
171 {
172 "file": "plugins/org.apache.cordova.file/www/FileUploadResult.js",
173 "id": "org.apache.cordova.file.FileUploadResult",
174 "clobbers": [
175 "window.FileUploadResult"
176 ]
177 },
178 {
179 "file": "plugins/org.apache.cordova.file/www/FileWriter.js",
180 "id": "org.apache.cordova.file.FileWriter",
181 "clobbers": [
182 "window.FileWriter"
183 ]
184 },
185 {
186 "file": "plugins/org.apache.cordova.file/www/Flags.js",
187 "id": "org.apache.cordova.file.Flags",
188 "clobbers": [
189 "window.Flags"
190 ]
191 },
192 {
193 "file": "plugins/org.apache.cordova.file/www/LocalFileSystem.js",
194 "id": "org.apache.cordova.file.LocalFileSystem",
195 "clobbers": [
196 "window.LocalFileSystem"
197 ],
198 "merges": [
199 "window"
200 ]
201 },
202 {
203 "file": "plugins/org.apache.cordova.file/www/Metadata.js",
204 "id": "org.apache.cordova.file.Metadata",
205 "clobbers": [
206 "window.Metadata"
207 ]
208 },
209 {
210 "file": "plugins/org.apache.cordova.file/www/ProgressEvent.js",
211 "id": "org.apache.cordova.file.ProgressEvent",
212 "clobbers": [
213 "window.ProgressEvent"
214 ]
215 },
216 {
217 "file": "plugins/org.apache.cordova.file/www/requestFileSystem.js",
218 "id": "org.apache.cordova.file.requestFileSystem",
219 "clobbers": [
220 "window.requestFileSystem"
221 ]
222 },
223 {
224 "file": "plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js",
225 "id": "org.apache.cordova.file.resolveLocalFileSystemURI",
226 "merges": [
227 "window"
228 ]
229 },
230 {
231 "file": "plugins/org.apache.cordova.file/www/ubuntu/Entry.js",
232 "id": "org.apache.cordova.file.Entry1",
233 "merges": [
234 "window.Entry"
235 ]
236 },
237 {
238 "file": "plugins/org.apache.cordova.file/www/ubuntu/DirectoryEntry.js",
239 "id": "org.apache.cordova.file.DirectoryEntry1",
240 "merges": [
241 "window.DirectoryEntry"
242 ]
243 },
244 {
245 "file": "plugins/org.apache.cordova.file/www/ubuntu/FileWriter.js",
246 "id": "org.apache.cordova.file.FileWriter1",
247 "merges": [
248 "window.FileWriter"
249 ]
250 },
251 {
252 "file": "plugins/org.apache.cordova.file-transfer/www/FileTransferError.js",
253 "id": "org.apache.cordova.file-transfer.FileTransferError",
254 "clobbers": [
255 "window.FileTransferError"
256 ]
257 },
258 {
259 "file": "plugins/org.apache.cordova.file-transfer/www/FileTransfer.js",
260 "id": "org.apache.cordova.file-transfer.FileTransfer",
261 "clobbers": [
262 "window.FileTransfer"
263 ]
264 },
265 {
266 "file": "plugins/org.apache.cordova.geolocation/www/Coordinates.js",
267 "id": "org.apache.cordova.geolocation.Coordinates",
268 "clobbers": [
269 "Coordinates"
270 ]
271 },
272 {
273 "file": "plugins/org.apache.cordova.geolocation/www/PositionError.js",
274 "id": "org.apache.cordova.geolocation.PositionError",
275 "clobbers": [
276 "PositionError"
277 ]
278 },
279 {
280 "file": "plugins/org.apache.cordova.geolocation/www/Position.js",
281 "id": "org.apache.cordova.geolocation.Position",
282 "clobbers": [
283 "Position"
284 ]
285 },
286 {
287 "file": "plugins/org.apache.cordova.geolocation/www/geolocation.js",
288 "id": "org.apache.cordova.geolocation.geolocation",
289 "clobbers": [
290 "navigator.geolocation"
291 ]
292 },
293 {
294 "file": "plugins/org.apache.cordova.globalization/www/GlobalizationError.js",
295 "id": "org.apache.cordova.globalization.GlobalizationError",
296 "clobbers": [
297 "window.GlobalizationError"
298 ]
299 },
300 {
301 "file": "plugins/org.apache.cordova.globalization/www/globalization.js",
302 "id": "org.apache.cordova.globalization.globalization",
303 "clobbers": [
304 "navigator.globalization"
305 ]
306 },
307 {
308 "file": "plugins/org.apache.cordova.globalization/www/ubuntu/globalization.js",
309 "id": "org.apache.cordova.globalization.Globalization1",
310 "merges": [
311 "navigator.globalization"
312 ]
313 },
314 {
315 "file": "plugins/org.apache.cordova.inappbrowser/www/InAppBrowser.js",
316 "id": "org.apache.cordova.inappbrowser.InAppBrowser",
317 "clobbers": [
318 "window.open"
319 ]
320 },
321 {
322 "file": "plugins/org.apache.cordova.media/www/MediaError.js",
323 "id": "org.apache.cordova.media.MediaError",
324 "clobbers": [
325 "window.MediaError"
326 ]
327 },
328 {
329 "file": "plugins/org.apache.cordova.media/www/Media.js",
330 "id": "org.apache.cordova.media.Media",
331 "clobbers": [
332 "window.Media"
333 ]
334 },
335 {
336 "file": "plugins/org.apache.cordova.media-capture/www/CaptureAudioOptions.js",
337 "id": "org.apache.cordova.media-capture.CaptureAudioOptions",
338 "clobbers": [
339 "CaptureAudioOptions"
340 ]
341 },
342 {
343 "file": "plugins/org.apache.cordova.media-capture/www/CaptureImageOptions.js",
344 "id": "org.apache.cordova.media-capture.CaptureImageOptions",
345 "clobbers": [
346 "CaptureImageOptions"
347 ]
348 },
349 {
350 "file": "plugins/org.apache.cordova.media-capture/www/CaptureVideoOptions.js",
351 "id": "org.apache.cordova.media-capture.CaptureVideoOptions",
352 "clobbers": [
353 "CaptureVideoOptions"
354 ]
355 },
356 {
357 "file": "plugins/org.apache.cordova.media-capture/www/CaptureError.js",
358 "id": "org.apache.cordova.media-capture.CaptureError",
359 "clobbers": [
360 "CaptureError"
361 ]
362 },
363 {
364 "file": "plugins/org.apache.cordova.media-capture/www/MediaFileData.js",
365 "id": "org.apache.cordova.media-capture.MediaFileData",
366 "clobbers": [
367 "MediaFileData"
368 ]
369 },
370 {
371 "file": "plugins/org.apache.cordova.media-capture/www/MediaFile.js",
372 "id": "org.apache.cordova.media-capture.MediaFile",
373 "clobbers": [
374 "MediaFile"
375 ]
376 },
377 {
378 "file": "plugins/org.apache.cordova.media-capture/www/capture.js",
379 "id": "org.apache.cordova.media-capture.capture",
380 "clobbers": [
381 "navigator.device.capture"
382 ]
383 },
384 {
385 "file": "plugins/org.apache.cordova.vibration/www/vibration.js",
386 "id": "org.apache.cordova.vibration.notification",
387 "merges": [
388 "navigator.notification"
389 ]
390 }
391];
3module.exports.metadata = 392module.exports.metadata =
4// TOP OF METADATA393// TOP OF METADATA
5{}394{
395 "org.apache.cordova.battery-status": "0.2.7",
396 "org.apache.cordova.camera": "0.2.7",
397 "org.apache.cordova.console": "0.2.7",
398 "org.apache.cordova.device": "0.2.8",
399 "org.apache.cordova.device-motion": "0.2.6",
400 "org.apache.cordova.device-orientation": "0.3.5",
401 "org.apache.cordova.dialogs": "0.2.6",
402 "org.apache.cordova.file": "1.0.0",
403 "org.apache.cordova.file-transfer": "0.4.1",
404 "org.apache.cordova.geolocation": "0.3.6",
405 "org.apache.cordova.globalization": "0.2.6",
406 "org.apache.cordova.inappbrowser": "0.3.1",
407 "org.apache.cordova.media": "0.2.8",
408 "org.apache.cordova.media-capture": "0.2.7",
409 "org.apache.cordova.vibration": "0.3.7"
410}
6// BOTTOM OF METADATA411// BOTTOM OF METADATA
7});412});
8\ No newline at end of file413\ No newline at end of file
9414
=== added directory 'www/plugins'
=== added directory 'www/plugins/org.apache.cordova.battery-status'
=== added directory 'www/plugins/org.apache.cordova.battery-status/www'
=== added file 'www/plugins/org.apache.cordova.battery-status/www/battery.js'
--- www/plugins/org.apache.cordova.battery-status/www/battery.js 1970-01-01 00:00:00 +0000
+++ www/plugins/org.apache.cordova.battery-status/www/battery.js 2014-02-19 16:53:58 +0000
@@ -0,0 +1,101 @@
1cordova.define("org.apache.cordova.battery-status.battery", function(require, exports, module) { /*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22/**
23 * This class contains information about the current battery status.
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches