1/*
2 * Copyright (C) 2009 Google Inc.  All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.polo.pairing;
18
19import com.google.polo.exception.PoloException;
20
21/**
22 * Listener interface for handling events within a pairing session.
23 */
24public interface PairingListener {
25
26  public static enum LogLevel {
27    LOG_DEBUG,
28    LOG_INFO,
29    LOG_ERROR
30  }
31
32  /**
33   * Called at the start of a new pairing session. The session object can be
34   * inspected to determine whether in client or server mode.
35   *
36   * @param session  the pairing session
37   */
38  void onSessionCreated(PairingSession session);
39
40  /**
41   * Called when the session calls for the local entity to act as the input
42   * device.
43   *
44   * @param session  the pairing session
45   * @throws PoloException  on error receiving the input
46   */
47  void onPerformInputDeviceRole(PairingSession session) throws PoloException;
48
49  /**
50   * Called when the session calls for the local entity to act as the display
51   * device.
52   *
53   * @param session         the pairing session
54   * @throws PoloException  on error displaying the secret
55   */
56  void onPerformOutputDeviceRole(PairingSession session, byte[] gamma)
57      throws PoloException;
58
59  /**
60   * Called at the end of a pairing session.  The session object can be
61   * inspected to determine success or failure.
62   *
63   * @param session  the pairing session
64   */
65  void onSessionEnded(PairingSession session);
66
67  /**
68   * Receives various log messages from the protocol.
69   *
70   * @param level    the severity of the message
71   * @param message  the message to log
72   */
73  void onLogMessage(LogLevel level, String message);
74
75}
76