Debian Codegraph @

bus/greeter/greeter.go

raw
1 /*
2 Copyright 2014 Canonical Ltd.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License version 3, as published
6 by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranties of
10 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 // Package greeter retrieves information about the Lomiri Greeter
18 // using Lomiri's dbus interface
19 package greeter
20
21 import (
22 "gitlab.com/ubports/development/core/lomiri-push-service/bus"
23 "gitlab.com/ubports/development/core/lomiri-push-service/logger"
24 )
25
26 // Well known address for the Greeter API
27 var BusAddress bus.Address = bus.Address{
28 Interface: "com.lomiri.LomiriGreeter",
29 Path: "/com/lomiri/LomiriGreeter",
30 Name: "com.lomiri.LomiriGreeter",
31 }
32
33 // Greeter encapsulates info needed to call out to the Greeter API
34 type Greeter struct {
35 bus bus.Endpoint
36 log logger.Logger
37 }
38
39 // New returns a new Greeter that'll use the provided bus.Endpoint
40 func New(endp bus.Endpoint, log logger.Logger) *Greeter {
41 return &Greeter{endp, log}
42 }
43
44 // GetGreeter returns the window stack state
45 func (greeter *Greeter) IsActive() bool {
46 result, err := greeter.bus.GetProperty("IsActive")
47 if err != nil {
48 greeter.log.Errorf("GetGreeter call returned %v", err)
49 return false
50 }
51 return result.(bool)
52 }