1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.support.model;
17
18 import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
19
20
21
22
23 public class Connection {
24
25 static public class StatusInfo {
26
27 private Status status;
28 private long uptimeSeconds;
29 private Error lastError;
30
31 public StatusInfo(Status status, UnsignedIntegerFourBytes uptime, Error lastError) {
32 this(status, uptime.getValue(), lastError);
33 }
34
35 public StatusInfo(Status status, long uptimeSeconds, Error lastError) {
36 this.status = status;
37 this.uptimeSeconds = uptimeSeconds;
38 this.lastError = lastError;
39 }
40
41 public Status getStatus() {
42 return status;
43 }
44
45 public long getUptimeSeconds() {
46 return uptimeSeconds;
47 }
48
49 public UnsignedIntegerFourBytes getUptime() {
50 return new UnsignedIntegerFourBytes(getUptimeSeconds());
51 }
52
53 public Error getLastError() {
54 return lastError;
55 }
56
57 @Override
58 public boolean equals(Object o) {
59 if (this == o) return true;
60 if (o == null || getClass() != o.getClass()) return false;
61
62 StatusInfo that = (StatusInfo) o;
63
64 if (uptimeSeconds != that.uptimeSeconds) return false;
65 if (lastError != that.lastError) return false;
66 if (status != that.status) return false;
67
68 return true;
69 }
70
71 @Override
72 public int hashCode() {
73 int result = status.hashCode();
74 result = 31 * result + (int) (uptimeSeconds ^ (uptimeSeconds >>> 32));
75 result = 31 * result + lastError.hashCode();
76 return result;
77 }
78
79 @Override
80 public String toString() {
81 return "(" + getClass().getSimpleName() + ") " + getStatus();
82 }
83 }
84
85 public enum Type {
86
87
88
89 Unconfigured,
90
91
92
93
94 IP_Routed,
95
96
97
98
99 IP_Bridged
100 }
101
102 public enum Status {
103
104
105
106
107 Unconfigured,
108
109
110
111
112
113 Connecting,
114
115
116
117
118
119 Connected,
120
121
122
123
124
125 PendingDisconnect,
126
127
128
129
130
131 Disconnecting,
132
133
134
135
136
137 Disconnected
138 }
139
140 public enum Error {
141 ERROR_NONE,
142 ERROR_COMMAND_ABORTED,
143 ERROR_NOT_ENABLED_FOR_INTERNET,
144 ERROR_USER_DISCONNECT,
145 ERROR_ISP_DISCONNECT,
146 ERROR_IDLE_DISCONNECT,
147 ERROR_FORCED_DISCONNECT,
148 ERROR_NO_CARRIER,
149 ERROR_IP_CONFIGURATION,
150 ERROR_UNKNOWN
151 }
152 }