xref: /haiku/src/apps/serialconnect/SerialApp.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
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 "FileSender.h"
17 #include "XModem.h"
18 
19 
20 class BFile;
21 class SerialWindow;
22 
23 
24 class SerialApp: public BApplication
25 {
26 	public:
27 							SerialApp();
28 							~SerialApp();
29 				void		ReadyToRun();
30 				void		MessageReceived(BMessage* message);
31 				bool		QuitRequested();
32 
33 				status_t	GetSupportedSuites(BMessage* message);
34 				BHandler*	ResolveSpecifier(BMessage*, int32, BMessage*, int32,
35 								const char*);
36 
37 		const	BString&	GetPort();
38 
39 	private:
40 				void		LoadSettings();
41 				void		SaveSettings();
42 
43 	private:
44 						BSerialPort		fSerialPort;
45 						sem_id			fSerialLock;
46 						SerialWindow*	fWindow;
47 						BFile*			fLogFile;
48 						BString			fPortPath;
49 
50 						FileSender*		fFileSender;
51 
52 		static			status_t		PollSerial(void*);
53 
54 		static const	BPropertyInfo	kScriptingProperties;
55 		static const	char*			kApplicationSignature;
56 };
57 
58 
59 enum messageConstants {
60 	kMsgCustomBaudrate  = 'cust',
61 	kMsgDataRead        = 'dard',
62 	kMsgDataWrite       = 'dawr',
63 	kMsgLogfile         = 'logf',
64 	kMsgOpenPort        = 'open',
65 	kMsgProgress        = 'prog',
66 	kMsgSettings        = 'stty',
67 	kMsgSendFile        = 'sndf',
68 };
69 
70 #endif
71