xref: /haiku/src/apps/codycam/SpawningUploadClient.h (revision 6a739773fceb43d72a2314eafb465d301ae36310)
1 /*
2  * Copyright 1998-1999 Be, Inc. All Rights Reserved.
3  * Copyright 2003-2019 Haiku, Inc. All rights reserved.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef SPAWNING_UPLOAD_CLIENT_H
7 #define SPAWNING_UPLOAD_CLIENT_H
8 
9 #include "FileUploadClient.h"
10 
11 #include <stdio.h>
12 #include <string.h>
13 
14 #include <OS.h>
15 #include <String.h>
16 
17 
18 class SpawningUploadClient : public FileUploadClient {
19 public:
20 								SpawningUploadClient();
21 	virtual						~SpawningUploadClient();
22 
23 	virtual bool				Connect(const string& server,
24 									const string& login,
25 									const string& passwd);
26 
27 	virtual bool				PutFile(const string& local,
28 									const string& remote,
29 									ftp_mode mode = binary_mode);
30 
31 	virtual bool				GetFile(const string& remote,
32 									const string& local,
33 									ftp_mode mode = binary_mode);
34 
35 	virtual bool				MoveFile(const string& oldPath,
36 									const string& newPath);
37 	virtual bool				ChangeDir(const string& dir);
38 	virtual bool				PrintWorkingDir(string& dir);
39 	virtual bool				ListDirContents(string& listing);
40 	virtual bool				Chmod(const string& path, const string& mod);
41 
42 	virtual void				SetPassive(bool on);
43 
44 protected:
45 			status_t			SetCommandLine(const char* command);
46 			ssize_t				SendCommand(const char* cmd);
47 			ssize_t				ReadReply(BString* to);
48 	virtual status_t			ParseReply();
49 			int					getpty(char* pty, char* tty);
50 
InputPipe()51 			int					InputPipe() const { return fPty; };
OutputPipe()52 			int					OutputPipe() const { return fPty; };
53 
54 private:
55 			bool				SpawnCommand();
56 
57 private:
58 			string				fCommand;
59 			pid_t				fCommandPid;
60 			int					fPty;
61 };
62 
63 #endif	// SPAWNING_UPLOAD_CLIENT_H
64