Debian Codegraph @

bus/networkmanager/state.go

raw
1 /*
2 Copyright 2013-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 networkmanager
18
19 type State uint32
20
21 // the NetworkManager states, as per
22 // https://wiki.gnome.org/Projects/NetworkManager/DBusInterface/LatestDBusAPI
23 const (
24 Unknown State = iota * 10
25 Asleep
26 Disconnected
27 Disconnecting
28 Connecting
29 ConnectedLocal
30 ConnectedSite
31 ConnectedGlobal
32 _max_state
33 )
34
35 var names = map[State]string{
36 Unknown: "Unknown",
37 Asleep: "Asleep",
38 Disconnected: "Disconnected",
39 Disconnecting: "Disconnecting",
40 Connecting: "Connecting",
41 ConnectedLocal: "Connected Local",
42 ConnectedSite: "Connected Site",
43 ConnectedGlobal: "Connected Global",
44 }
45
46 // give its state a descriptive stringification
47 func (state State) String() string {
48 if s, ok := names[state]; ok {
49 return s
50 }
51 return names[Unknown]
52 }