xref: /haiku/src/apps/serialconnect/SerialApp.h (revision 7c86c4573f697c129540e52d6b926937f3b00e16)
1 /*
2  * Copyright 2012-2017, Adrien Destugues, pulkomandy@gmail.com
3  * Distributed under the terms of the MIT licence.
4  */
5 
6 
7 #ifndef _SERIALAPP_H_
8 #define _SERIALAPP_H_
9 
10 
11 #include <Application.h>
12 #include <PropertyInfo.h>
13 #include <SerialPort.h>
14 #include <String.h>
15 
16 #include "XModem.h"
17 
18 
19 class BFile;
20 class SerialWindow;
21 
22 
23 class SerialApp: public BApplication
24 {
25 	public:
26 							SerialApp();
27 							~SerialApp();
28 				void		ReadyToRun();
29 				void		MessageReceived(BMessage* message);
30 				bool		QuitRequested();
31 
32 				status_t	GetSupportedSuites(BMessage* message);
33 				BHandler*	ResolveSpecifier(BMessage*, int32, BMessage*, int32,
34 								const char*);
35 
36 		const	BString&	GetPort();
37 
38 	private:
39 				void		LoadSettings();
40 				void		SaveSettings();
41 
42 	private:
43 						BSerialPort		fSerialPort;
44 						sem_id			fSerialLock;
45 						SerialWindow*	fWindow;
46 						BFile*			fLogFile;
47 						BString			fPortPath;
48 
49 						XModemSender*	fFileSender;
50 
51 		static			status_t		PollSerial(void*);
52 
53 		static const	BPropertyInfo	kScriptingProperties;
54 		static const	char*			kApplicationSignature;
55 };
56 
57 
58 enum messageConstants {
59 	kMsgCustomBaudrate  = 'cust',
60 	kMsgDataRead        = 'dard',
61 	kMsgDataWrite       = 'dawr',
62 	kMsgLogfile         = 'logf',
63 	kMsgOpenPort        = 'open',
64 	kMsgProgress        = 'prog',
65 	kMsgSettings        = 'stty',
66 	kMsgSendXmodem      = 'xmtx',
67 };
68 
69 #endif
70