cordova.plugins.diagnostic 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +6 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +123 -0
- package/.github/ISSUE_TEMPLATE/documentation-issue.md +36 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +41 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +37 -0
- package/.github/stale.yml +17 -0
- package/CHANGELOG.md +390 -0
- package/README.md +3709 -0
- package/cordova.plugins.diagnostic.d.ts +1113 -0
- package/package.json +54 -0
- package/plugin.xml +496 -0
- package/scripts/apply-modules.js +165 -0
- package/scripts/logger.js +94 -0
- package/src/android/Diagnostic.java +856 -0
- package/src/android/Diagnostic_Bluetooth.java +297 -0
- package/src/android/Diagnostic_Camera.java +134 -0
- package/src/android/Diagnostic_External_Storage.java +273 -0
- package/src/android/Diagnostic_Location.java +319 -0
- package/src/android/Diagnostic_NFC.java +270 -0
- package/src/android/Diagnostic_Notifications.java +157 -0
- package/src/android/Diagnostic_Wifi.java +155 -0
- package/src/ios/Diagnostic.h +56 -0
- package/src/ios/Diagnostic.m +282 -0
- package/src/ios/Diagnostic_Bluetooth.h +24 -0
- package/src/ios/Diagnostic_Bluetooth.m +170 -0
- package/src/ios/Diagnostic_Calendar.h +24 -0
- package/src/ios/Diagnostic_Calendar.m +94 -0
- package/src/ios/Diagnostic_Camera.h +27 -0
- package/src/ios/Diagnostic_Camera.m +194 -0
- package/src/ios/Diagnostic_Contacts.h +24 -0
- package/src/ios/Diagnostic_Contacts.m +93 -0
- package/src/ios/Diagnostic_Location.h +31 -0
- package/src/ios/Diagnostic_Location.m +284 -0
- package/src/ios/Diagnostic_Microphone.h +21 -0
- package/src/ios/Diagnostic_Microphone.m +97 -0
- package/src/ios/Diagnostic_Motion.h +27 -0
- package/src/ios/Diagnostic_Motion.m +143 -0
- package/src/ios/Diagnostic_Notifications.h +22 -0
- package/src/ios/Diagnostic_Notifications.m +235 -0
- package/src/ios/Diagnostic_Reminders.h +24 -0
- package/src/ios/Diagnostic_Reminders.m +93 -0
- package/src/ios/Diagnostic_Wifi.h +19 -0
- package/src/ios/Diagnostic_Wifi.m +108 -0
- package/src/windows/diagnosticProxy.bluetooth.js +23 -0
- package/src/windows/diagnosticProxy.camera.js +35 -0
- package/src/windows/diagnosticProxy.js +137 -0
- package/src/windows/diagnosticProxy.location.js +54 -0
- package/src/windows/diagnosticProxy.wifi.js +18 -0
- package/www/android/diagnostic.bluetooth.js +211 -0
- package/www/android/diagnostic.calendar.js +90 -0
- package/www/android/diagnostic.camera.js +203 -0
- package/www/android/diagnostic.contacts.js +91 -0
- package/www/android/diagnostic.external_storage.js +102 -0
- package/www/android/diagnostic.js +1309 -0
- package/www/android/diagnostic.location.js +282 -0
- package/www/android/diagnostic.microphone.js +89 -0
- package/www/android/diagnostic.nfc.js +127 -0
- package/www/android/diagnostic.notifications.js +74 -0
- package/www/android/diagnostic.wifi.js +90 -0
- package/www/ios/diagnostic.bluetooth.js +127 -0
- package/www/ios/diagnostic.calendar.js +97 -0
- package/www/ios/diagnostic.camera.js +212 -0
- package/www/ios/diagnostic.contacts.js +98 -0
- package/www/ios/diagnostic.js +990 -0
- package/www/ios/diagnostic.location.js +236 -0
- package/www/ios/diagnostic.microphone.js +99 -0
- package/www/ios/diagnostic.motion.js +160 -0
- package/www/ios/diagnostic.notifications.js +189 -0
- package/www/ios/diagnostic.reminders.js +97 -0
- package/www/ios/diagnostic.wifi.js +80 -0
- package/www/windows/diagnostic.bluetooth.js +51 -0
- package/www/windows/diagnostic.camera.js +41 -0
- package/www/windows/diagnostic.js +169 -0
- package/www/windows/diagnostic.location.js +35 -0
- package/www/windows/diagnostic.wifi.js +51 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**********
|
|
4
|
+
* Globals
|
|
5
|
+
**********/
|
|
6
|
+
|
|
7
|
+
const PLUGIN_NAME = "Diagnostic plugin";
|
|
8
|
+
const PLUGIN_ID = "cordova.plugins.diagnostic";
|
|
9
|
+
const PREFERENCE_NAME = PLUGIN_ID + ".modules";
|
|
10
|
+
|
|
11
|
+
const MODULES = [
|
|
12
|
+
"LOCATION",
|
|
13
|
+
"BLUETOOTH",
|
|
14
|
+
"WIFI",
|
|
15
|
+
"CAMERA",
|
|
16
|
+
"NOTIFICATIONS",
|
|
17
|
+
"MICROPHONE",
|
|
18
|
+
"CONTACTS",
|
|
19
|
+
"CALENDAR",
|
|
20
|
+
"REMINDERS",
|
|
21
|
+
"MOTION",
|
|
22
|
+
"NFC",
|
|
23
|
+
"EXTERNAL_STORAGE"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const COMMENT_START = "<!--";
|
|
27
|
+
const COMMENT_END = "-->";
|
|
28
|
+
|
|
29
|
+
// Node dependencies
|
|
30
|
+
var path, cwd, fs;
|
|
31
|
+
|
|
32
|
+
// External dependencies
|
|
33
|
+
var et;
|
|
34
|
+
|
|
35
|
+
// Internal dependencies
|
|
36
|
+
var logger;
|
|
37
|
+
|
|
38
|
+
var projectPath, modulesPath, pluginNodePath, pluginScriptsPath, configXmlPath, pluginXmlPath, configXmlData, pluginXmlText;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/*********************
|
|
42
|
+
* Internal functions
|
|
43
|
+
*********************/
|
|
44
|
+
|
|
45
|
+
var run = function (){
|
|
46
|
+
var configuredModules = getSelectedModules();
|
|
47
|
+
logger.verbose("Modules: " + configuredModules);
|
|
48
|
+
|
|
49
|
+
readPluginXml();
|
|
50
|
+
enableAllModules();
|
|
51
|
+
if(configuredModules){
|
|
52
|
+
MODULES.forEach(function(module){
|
|
53
|
+
if(configuredModules.indexOf(module) === -1){
|
|
54
|
+
disableModule(module);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
writePluginXml();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
var handleError = function (error) {
|
|
64
|
+
error = PLUGIN_NAME + " - ERROR: " + error;
|
|
65
|
+
if(logger){
|
|
66
|
+
logger.error(error);
|
|
67
|
+
}else{
|
|
68
|
+
console.log(error);
|
|
69
|
+
console.error(error)
|
|
70
|
+
}
|
|
71
|
+
return error;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Parses a given file into an elementtree object
|
|
75
|
+
var parseElementtreeSync = function(filename) {
|
|
76
|
+
var contents = fs.readFileSync(filename, 'utf-8');
|
|
77
|
+
if(contents) {
|
|
78
|
+
//Windows is the BOM. Skip the Byte Order Mark.
|
|
79
|
+
contents = contents.substring(contents.indexOf('<'));
|
|
80
|
+
}
|
|
81
|
+
return new et.ElementTree(et.XML(contents));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Parses the config.xml into an elementtree object and stores in the config object
|
|
85
|
+
var getConfigXml = function() {
|
|
86
|
+
if(!configXmlData) {
|
|
87
|
+
configXmlData = parseElementtreeSync(configXmlPath);
|
|
88
|
+
}
|
|
89
|
+
return configXmlData;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
var readPluginXml = function(){
|
|
93
|
+
pluginXmlText = fs.readFileSync(pluginXmlPath, 'utf-8');
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var writePluginXml = function(){
|
|
97
|
+
fs.writeFileSync(pluginXmlPath, pluginXmlText, 'utf-8');
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var getSelectedModules = function(){
|
|
101
|
+
var modules = null;
|
|
102
|
+
var preference = getConfigXml().findall("preference[@name='"+PREFERENCE_NAME+"']")[0];
|
|
103
|
+
if(preference){
|
|
104
|
+
modules = preference.attrib.value.split(' ');
|
|
105
|
+
}
|
|
106
|
+
return modules;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var enableAllModules = function(){
|
|
110
|
+
MODULES.forEach(function(module){
|
|
111
|
+
var commentedStartRegExp = new RegExp(getModuleStart(module)+COMMENT_START, "g");
|
|
112
|
+
var commentedEndRegExp = new RegExp(COMMENT_END+getModuleEnd(module), "g");
|
|
113
|
+
if(pluginXmlText.match(commentedStartRegExp)){
|
|
114
|
+
pluginXmlText = pluginXmlText.replace(commentedStartRegExp, getModuleStart(module));
|
|
115
|
+
pluginXmlText = pluginXmlText.replace(commentedEndRegExp, getModuleEnd(module));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var disableModule = function(module){
|
|
121
|
+
var commentedStart = getModuleStart(module)+COMMENT_START;
|
|
122
|
+
var commentedEnd = COMMENT_END+getModuleEnd(module);
|
|
123
|
+
pluginXmlText = pluginXmlText.replace(new RegExp(getModuleStart(module), "g"), commentedStart);
|
|
124
|
+
pluginXmlText = pluginXmlText.replace(new RegExp(getModuleEnd(module), "g"), commentedEnd);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var getModuleStart = function(module){
|
|
128
|
+
return "<!--BEGIN_MODULE "+module+"-->";
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var getModuleEnd = function(module){
|
|
132
|
+
return "<!--END_MODULE "+module+"-->";
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
/**********
|
|
137
|
+
* Main
|
|
138
|
+
**********/
|
|
139
|
+
var main = function() {
|
|
140
|
+
try{
|
|
141
|
+
fs = require('fs');
|
|
142
|
+
path = require('path');
|
|
143
|
+
cwd = path.resolve();
|
|
144
|
+
pluginNodePath = cwd;
|
|
145
|
+
|
|
146
|
+
modulesPath = path.resolve(pluginNodePath, "..");
|
|
147
|
+
projectPath = path.resolve(modulesPath, "..");
|
|
148
|
+
pluginScriptsPath = path.resolve(pluginNodePath, "scripts");
|
|
149
|
+
|
|
150
|
+
logger = require(path.resolve(pluginScriptsPath, "logger.js"))(modulesPath, PLUGIN_ID);
|
|
151
|
+
et = require(path.resolve(modulesPath, "elementtree"));
|
|
152
|
+
}catch(e){
|
|
153
|
+
handleError("Failed to load dependencies. If using cordova@6 CLI, ensure this plugin is installed with the --fetch option or run 'npm install "+PLUGIN_ID+"': " + e.message);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
try{
|
|
157
|
+
configXmlPath = path.join(projectPath, 'config.xml');
|
|
158
|
+
pluginXmlPath = path.join(pluginNodePath, "plugin.xml");
|
|
159
|
+
run();
|
|
160
|
+
}catch(e){
|
|
161
|
+
handleError(e.message);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
main();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var logger = (function(){
|
|
4
|
+
|
|
5
|
+
/**********************
|
|
6
|
+
* Internal properties
|
|
7
|
+
*********************/
|
|
8
|
+
var logger, path, minimist,
|
|
9
|
+
modulesPath, pluginId, hasColors = true, cliArgs;
|
|
10
|
+
|
|
11
|
+
function prefixMsg(msg){
|
|
12
|
+
return pluginId+": "+msg;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/************
|
|
16
|
+
* Public API
|
|
17
|
+
************/
|
|
18
|
+
logger = {
|
|
19
|
+
init: function(_modulesPath, _pluginId){
|
|
20
|
+
pluginId = _pluginId;
|
|
21
|
+
modulesPath = _modulesPath;
|
|
22
|
+
|
|
23
|
+
path = require('path');
|
|
24
|
+
|
|
25
|
+
try{
|
|
26
|
+
require(path.resolve(modulesPath, "colors"));
|
|
27
|
+
}catch(e){
|
|
28
|
+
hasColors = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
minimist = require(path.resolve(modulesPath, "minimist"));
|
|
32
|
+
cliArgs = minimist(process.argv.slice(2));
|
|
33
|
+
},
|
|
34
|
+
dump: function (obj){
|
|
35
|
+
if(cliArgs["--debug"] || cliArgs["--dump"]) {
|
|
36
|
+
console.log("DUMP: "+require('util').inspect(obj));
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
debug: function(msg){
|
|
40
|
+
if(cliArgs["--debug"]){
|
|
41
|
+
msg = "DEBUG: " + msg;
|
|
42
|
+
console.log(msg);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
verbose: function(msg){
|
|
46
|
+
if(cliArgs["--verbose"] || cliArgs["--debug"]){
|
|
47
|
+
msg = prefixMsg(msg);
|
|
48
|
+
if(hasColors){
|
|
49
|
+
console.log(msg.green);
|
|
50
|
+
}else{
|
|
51
|
+
console.log(msg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
log: function(msg){
|
|
56
|
+
msg = prefixMsg(msg);
|
|
57
|
+
if(hasColors){
|
|
58
|
+
console.log(msg.white);
|
|
59
|
+
}else{
|
|
60
|
+
console.log(msg);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
info: function(msg){
|
|
64
|
+
msg = prefixMsg(msg);
|
|
65
|
+
if(hasColors){
|
|
66
|
+
console.log(msg.blue);
|
|
67
|
+
}else{
|
|
68
|
+
console.info(msg);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
warn: function(msg){
|
|
72
|
+
msg = prefixMsg(msg);
|
|
73
|
+
if(hasColors){
|
|
74
|
+
console.log(msg.yellow);
|
|
75
|
+
}else{
|
|
76
|
+
console.warn(msg);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
error: function(msg){
|
|
80
|
+
msg = prefixMsg(msg);
|
|
81
|
+
if(hasColors){
|
|
82
|
+
console.log(msg.red);
|
|
83
|
+
}else{
|
|
84
|
+
console.error(msg);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return logger;
|
|
89
|
+
})();
|
|
90
|
+
|
|
91
|
+
module.exports = function(modulesPath, pluginId){
|
|
92
|
+
logger.init(modulesPath, pluginId);
|
|
93
|
+
return logger;
|
|
94
|
+
};
|