]> git.basschouten.com Git - openhab-addons.git/blob
042f1972ef20f878daab6787132928cbf70e0b1b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.digitalstrom.internal.lib.listener;
14
15 /**
16  * The {@link ConnectionListener} is notified if the connection state of digitalSTROM-Server has changed.
17  *
18  * @author Michael Ochel - Initial contribution
19  * @author Matthias Siegele - Initial contribution
20  *
21  */
22 public interface ConnectionListener {
23
24     /* Connection-States */
25     /**
26      * State, if you're not authenticated on the digitalSTROM-Server.
27      */
28     final String NOT_AUTHENTICATED = "notAuth";
29     /**
30      * State, if the connection to the digitalSTROM-Server is lost.
31      */
32     final String CONNECTION_LOST = "connLost";
33     /**
34      * State, if a ssl handshake problem occured while communicating with the digitalSTROM-Server.
35      */
36     final String SSL_HANDSHAKE_ERROR = "sslHandshakeError";
37     /**
38      * State, if the connection to the digitalSTROM-Server is resumed.
39      */
40     final String CONNECTION_RESUMED = "connResumed";
41     /**
42      * State, if the Application-Token is generated.
43      */
44     final String APPLICATION_TOKEN_GENERATED = "appGen";
45
46     /* Not authentication reasons */
47     /**
48      * State, if the given Application-Token cannot be used.
49      */
50     final String WRONG_APP_TOKEN = "wrongAppT";
51     /**
52      * State, if the given username or password cannot be used.
53      */
54     final String WRONG_USER_OR_PASSWORD = "wrongUserOrPasswd";
55     /**
56      * State, if no username or password is set and the given application-token cannot be used or is null.
57      */
58     final String NO_USER_PASSWORD = "noUserPasswd";
59
60     /**
61      * State, if the connection timed out.
62      */
63     final String CONNECTON_TIMEOUT = "connTimeout";
64
65     /**
66      * State, if the host address cannot be found.
67      */
68     final String HOST_NOT_FOUND = "hostNotFound";
69
70     /**
71      * State, if the host address is unknown.
72      */
73     final String UNKNOWN_HOST = "unknownHost";
74
75     /**
76      * State, if the the URL is invalid.
77      */
78     final String INVALID_URL = "invalideURL";
79
80     /**
81      * This method is called whenever the connection state has changed from {@link #CONNECTION_LOST}
82      * to {@link #CONNECTION_RESUMED} and vice versa. It also will be called if the application-token is generated over
83      * {@link #APPLICATION_TOKEN_GENERATED}.
84      *
85      * @param newConnectionState of the connection
86      */
87     void onConnectionStateChange(String newConnectionState);
88
89     /**
90      * This method is called whenever the connection state has changed to {@link #NOT_AUTHENTICATED} or
91      * {@link #CONNECTION_LOST}
92      * and also passes the reason why. Reason can be:
93      * <ul>
94      * <li>{@link #WRONG_APP_TOKEN} if the given application-token can't be used.</li>
95      * <li>{@link #WRONG_USER_OR_PASSWORD} if the given user name or password can't be used.</li>
96      * <li>{@link #NO_USER_PASSWORD} if no user name or password is set and the given application-token can't be
97      * used.</li>
98      * <li>{@link #HOST_NOT_FOUND} if the host can't be found.</li>
99      * <li>{@link #INVALID_URL} if the the URL is invalid.</li>
100      * </ul>
101      *
102      * @param newConnectionState of the connection
103      * @param reason why the connection is failed
104      */
105     void onConnectionStateChange(String newConnectionState, String reason);
106 }