-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathaccountmanager.js
97 lines (84 loc) · 2.74 KB
/
accountmanager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2013 Polychrom Pty Ltd
//
// This program is licensed under the 3-clause "Modified" BSD license,
// see LICENSE file for full definition.
var AccountManager = function() {};
AccountManager.prototype.getAccountsByType = function(type, callback)
{
return cordova.exec(
function(accounts) { callback(undefined, accounts) },
callback,
'AccountManager', 'getAccountsByType', [type]);
};
AccountManager.prototype.addAccountExplicitly = function(accountType, username, password, userdata, callback)
{
return cordova.exec(
function(account) { callback(undefined, account) },
callback,
'AccountManager', 'addAccountExplicitly', [accountType, username, password, userdata]);
};
AccountManager.prototype.clearPassword = function(account, callback)
{
return cordova.exec(
function() { callback(); },
callback,
'AccountManager', 'clearPassword', [account._index]);
};
AccountManager.prototype.removeAccount = function(account, callback)
{
return cordova.exec(
function() { callback(); },
callback,
'AccountManager', 'removeAccount', [account._index]);
};
AccountManager.prototype.setAuthToken = function(account, authTokenType, authToken, callback)
{
return cordova.exec(
function() { callback(); },
callback,
'AccountManager', 'setAuthToken', [account._index, authTokenType, authToken]);
};
AccountManager.prototype.peekAuthToken = function(account, authTokenType, callback)
{
return cordova.exec(
function(result) { callback(undefined, result.value); },
callback,
'AccountManager', 'peekAuthToken', [account._index, authTokenType]);
};
AccountManager.prototype.getAuthToken = function(account, authTokenType, callback)
{
return cordova.exec(
function(result) { callback(undefined, result.value); },
callback,
'AccountManager', 'getAuthToken', [account, authTokenType]);
};
AccountManager.prototype.setPassword = function(account, password, callback)
{
return cordova.exec(
function() { callback(); },
callback,
'AccountManager', 'setPassword', [account._index, password]);
};
AccountManager.prototype.getPassword = function(account, callback)
{
return cordova.exec(
function(result) { callback(undefined, result.value); },
callback,
'AccountManager', 'getPassword', [account._index]);
};
AccountManager.prototype.setUserData = function(account, key, value, callback)
{
return cordova.exec(
function() { callback(); },
callback,
'AccountManager', 'setUserData', [account._index, key, value]);
};
AccountManager.prototype.getUserData = function(account, key, callback)
{
return cordova.exec(
function(result) { callback(undefined, result.value); },
callback,
'AccountManager', 'getUserData', [account._index, key]);
};
if(!window.plugins) window.plugins = {};
window.plugins.accountmanager = new AccountManager();