1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

Merge branch 'feature/check-account' into develop

This commit is contained in:
Valverde Antonio 2014-07-30 19:32:44 +09:00
commit e6465fe8cc
4 changed files with 52 additions and 1 deletions

View file

@ -14,7 +14,35 @@ module.exports = syrup.serial()
.define(function(options, service, identity, touch, router, push, adb) {
var log = logger.createLogger('device:plugins:account')
router.on(wire.AccountGetMessage, function(channel, message){
router.on(wire.AccountCheckMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)
log.info('Checking if account "%s" is added',message.account)
service.getAccounts(message.type)
.timeout(30000)
.then(function(accounts) {
if(accounts.indexOf(message.account) >= 0) {
push.send([
channel
, reply.okay()
])
}
else {
throw new Error('The account is not added')
}
})
.catch(function(err){
log.error('Account check failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
router.on(wire.AccountGetMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)
log.info('Getting account(s) of type "%s"', message.type)

View file

@ -332,6 +332,16 @@ module.exports = function(options) {
)
])
})
.on('account.check', function(channel, responseChannel, data){
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.AccountCheckMessage(data)
)
])
})
.on('account.remove', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([

View file

@ -59,6 +59,7 @@ enum MessageType {
WifiGetStatusMessage = 58;
AccountAddMenuMessage = 59;
AccountAddMessage = 60;
AccountCheckMessage = 63;
AccountGetMessage = 62;
AccountRemoveMessage = 55;
SdStatusMessage = 61;
@ -399,6 +400,11 @@ message AccountAddMessage {
required string password = 2;
}
message AccountCheckMessage {
required string type = 1;
required string account = 2;
}
message AccountGetMessage {
required string type = 1;
}

View file

@ -218,6 +218,13 @@ module.exports = function ControlServiceFactory(
return sendTwoWay('screen.capture')
}
this.checkAccount = function(type, account) {
return sendTwoWay('account.check', {
type: type
, account: account
})
}
this.removeAccount = function(type, account) {
return sendTwoWay('account.remove', {
type: type