Report stream errors from MessageQueue.
[macgdbp.git] / Source / NetworkConnection.h
1 /*
2 * MacGDBp
3 * Copyright (c) 2007 - 2011, Blue Static <http://www.bluestatic.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17 #import <Cocoa/Cocoa.h>
18
19 #import "ProtocolClient.h"
20
21 @protocol NetworkConnectionDelegate;
22 @class LoggingController;
23
24 // This class is the lowest level component to the network. It deals with all
25 // the intricacies of network and stream programming. Almost all the work this
26 // class does is on a background thread, which is created when the connection is
27 // asked to connect and shutdown when asked to close.
28 @interface NetworkConnection : ProtocolClient<ProtocolClientDelegate>
29 {
30 // The port to connect on.
31 NSUInteger port_;
32
33 ProtocolClient* _ideClient;
34
35 // If the connection to the debugger engine is currently active.
36 BOOL connected_;
37
38 // The delegate. All methods are executed on the main thread.
39 NSObject<NetworkConnectionDelegate>* delegate_;
40 }
41
42 @property (readonly) NSUInteger port;
43 @property (readonly) BOOL connected;
44 @property (assign) id <NetworkConnectionDelegate> delegate;
45
46 - (id)initWithPort:(NSUInteger)aPort;
47
48 - (void)connect;
49 - (void)close;
50
51 - (NSString*)escapedURIPath:(NSString*)path;
52
53 @end
54
55 // Delegate ////////////////////////////////////////////////////////////////////
56
57 @protocol NetworkConnectionDelegate <NSObject>
58
59 @optional
60
61 - (void)connectionDidAccept:(NetworkConnection*)cx;
62 - (void)connectionDidClose:(NetworkConnection*)cx;
63
64 - (void)handleInitialResponse:(NSXMLDocument*)response;
65
66 - (void)handleResponse:(NSXMLDocument*)response;
67
68 - (void)errorEncountered:(NSString*)error;
69
70 @end