-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from 3h3c/master
add support for windows10 platform
- Loading branch information
Showing
4 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
examples/ | ||
.idea/ | ||
node_modules/ | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
<description> | ||
A demo application for the NativeStorage plugin | ||
</description> | ||
<author email="[email protected]" href="http://example.com/"> | ||
Example Company | ||
</author> | ||
<content src="index.html" /> | ||
<plugin name="cordova-plugin-whitelist" spec="1" /> | ||
<access origin="*" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/** | ||
* Created by Christian on 30.08.2016. | ||
* [email protected] | ||
*/ | ||
|
||
var package = Windows.ApplicationModel.Package.current; | ||
var service = package.id.name | ||
|
||
var NativeStorageProxy = { | ||
getItem: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var passwordCredential = vault.retrieve(service, key); | ||
win(passwordCredential.password); | ||
} catch (e) { | ||
fail(2); | ||
} | ||
}, | ||
setItem: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var value = args[1]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
vault.add(new Windows.Security.Credentials.PasswordCredential(service, key, value)); | ||
win(value); | ||
} catch (e) { | ||
fail(1); | ||
} | ||
}, | ||
clear: function (win, fail, args) { | ||
//todo: Clear all values in NativeStorage | ||
try { | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var iVectorView = vault.retrieveAll(); | ||
if (iVectorView == null) | ||
win(); | ||
for (var i = 0; i < iVectorView.size; i++) { | ||
vault.remove(iVectorView[i]); | ||
} | ||
win(); | ||
} catch (e) { | ||
fail(); | ||
} | ||
}, | ||
putString: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var value = args[1]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
vault.add(new Windows.Security.Credentials.PasswordCredential(service, key, value)); | ||
win(value); | ||
} catch (e) { | ||
fail(1); | ||
} | ||
}, | ||
getString: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var passwordCredential = vault.retrieve(service, key); | ||
win(passwordCredential.password); | ||
} catch (e) { | ||
fail(2); | ||
} | ||
}, | ||
putBoolean: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var value = args[1]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
vault.add(new Windows.Security.Credentials.PasswordCredential(service, key, value)); | ||
win(value); | ||
} catch (e) { | ||
fail(1); | ||
} | ||
}, | ||
getBoolean: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var passwordCredential = vault.retrieve(service, key); | ||
win(passwordCredential.password); | ||
} catch (e) { | ||
fail(2); | ||
} | ||
}, | ||
putInt: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var value = args[1]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
vault.add(new Windows.Security.Credentials.PasswordCredential(service, key, value)); | ||
win(value); | ||
} catch (e) { | ||
fail(1); | ||
} | ||
}, | ||
getInt: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var passwordCredential = vault.retrieve(service, key); | ||
win(parseInt(passwordCredential.password)); | ||
} catch (e) { | ||
fail(2); | ||
} | ||
}, | ||
putDouble: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var value = args[1]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
vault.add(new Windows.Security.Credentials.PasswordCredential(service, key, value)); | ||
win(value); | ||
} catch (e) { | ||
fail(1); | ||
} | ||
}, | ||
getDouble: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var passwordCredential = vault.retrieve(service, key); | ||
win(passwordCredential.password); | ||
} catch (e) { | ||
fail(2); | ||
} | ||
}, | ||
remove: function (win, fail, args) { | ||
try { | ||
var key = args[0]; | ||
var vault = new Windows.Security.Credentials.PasswordVault(); | ||
var passwordCredential = vault.retrieve(service, key); | ||
if (passwordCredential) { | ||
vault.remove(passwordCredential); | ||
} | ||
win(key); | ||
} catch (e) { | ||
fail(2); | ||
} | ||
}, | ||
}; | ||
|
||
require("cordova/exec/proxy").add("NativeStorage", NativeStorageProxy); |