1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00
OpenSTF/lib/roles/device/plugins/account.js
2014-07-02 18:37:39 +09:00

57 lines
1.5 KiB
JavaScript

var syrup = require('syrup')
var logger = require('../../../util/logger')
var wire = require('../../../wire')
var wireutil = require('../../../wire/util')
module.exports = syrup.serial()
.dependency(require('./service'))
.dependency(require('../support/router'))
.dependency(require('../support/push'))
.define(function(options, service, router, push) {
var log = logger.createLogger('device:plugins:account')
router.on(wire.AccountRemoveMessage, function(channel) {
var reply = wireutil.reply(options.serial)
log.info('Removing current Google account(s)')
service.removeAccount()
.timeout(30000)
.then(function() {
push.send([
channel
, reply.okay()
])
})
.error(function(err) {
log.error('Account removal failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
router.on(wire.AccountAddMenuMessage, function(channel) {
var reply = wireutil.reply(options.serial)
log.info('Showing add account menu for Google Account')
service.addAccountMenu()
.timeout(30000)
.then(function() {
push.send([
channel
, reply.okay()
])
})
.error(function(err) {
log.error('Add account menu failed', err.stack)
push.send([
channel
, reply.fail(err.message)
])
})
})
})