]>
Commit | Line | Data |
---|---|---|
dacd667c MW |
1 | /* |
2 | * Copyright (C) 2013 Martin Willi | |
19ef2aec TB |
3 | * |
4 | * Copyright (C) secunet Security Networks AG | |
dacd667c MW |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | * for more details. | |
15 | */ | |
16 | ||
17 | #import <Foundation/Foundation.h> | |
18 | ||
19 | /** | |
20 | * State of a connection during connect. | |
21 | */ | |
22 | typedef enum { | |
23 | /** The connection is currently down */ | |
24 | STATE_DOWN, | |
25 | /** The connection is getting established, the daemon is working */ | |
26 | STATE_WORKING, | |
27 | /** The connection has been established successfully */ | |
28 | STATE_UP, | |
29 | } connectionState; | |
30 | ||
31 | /** | |
32 | * This protocol defines callback functions to invoke during connect. | |
33 | */ | |
34 | @protocol ControlDelegate | |
35 | ||
36 | /** | |
37 | * The connection has changed its state | |
38 | * | |
39 | * @param state new connection state | |
40 | * @param conn connection that changed its state | |
41 | */ | |
42 | - (void)change:(connectionState)state withConnection:(NSDictionary*)conn; | |
43 | ||
44 | /** | |
45 | * A password is required for authentication | |
46 | * | |
47 | * @param conn connection a password is required for | |
48 | * @return a retained password string | |
49 | */ | |
50 | - (NSString*)createPasswordWithConnection:(NSDictionary*)conn; | |
51 | ||
52 | /** | |
53 | * Show an alert message to the user | |
54 | * | |
55 | * @param alert alert message string | |
56 | * @param conn connection an error has occurred | |
57 | */ | |
58 | - (void)raise:(NSString*)alert withConnection:(NSDictionary*)conn; | |
59 | ||
60 | /** | |
61 | * Log a line for a specific connection | |
62 | * | |
63 | * @param line log line string | |
64 | * @param conn connection the line is logged for | |
65 | */ | |
66 | - (void)log:(NSString*)line withConnection:(NSDictionary*)conn; | |
67 | @end | |
68 | ||
69 | /** | |
70 | * Implements connection connect/disconnect operations using a GUI delegate. | |
71 | */ | |
72 | @interface Control : NSObject | |
73 | ||
74 | /** | |
75 | * Try to establish a connection | |
76 | * | |
77 | * @param conn connection configuration to initiate | |
78 | */ | |
79 | - (void)connect:(NSDictionary*)conn; | |
80 | ||
81 | /** | |
82 | * Disconnect a previously established connection | |
83 | * | |
84 | * @param conn connection configuration to terminate | |
85 | */ | |
86 | - (void)disconnect:(NSDictionary*)conn; | |
87 | ||
88 | /** | |
89 | * Initiate the Control class using a delegate for GUI operations | |
90 | * | |
91 | * @param delegate delegate to invoke callbacks on during connect operation | |
92 | * @return class instance | |
93 | */ | |
94 | - (id)initWithDelegate:(id<ControlDelegate>)delegate; | |
95 | ||
96 | @end |