xref: /haiku/src/add-ons/tracker/zipomatic/ZipperThread.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
1 /*
2  * Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Jonas Sundström, jonas.sundstrom@kirilla.com
7  */
8 #ifndef ZIPPER_THREAD_H
9 #define ZIPPER_THREAD_H
10 
11 
12 #include "GenericThread.h"
13 
14 #include <Messenger.h>
15 
16 #include <stdio.h>
17 
18 class BMessage;
19 class BWindow;
20 
21 
22 class ZipperThread : public GenericThread {
23 	public:
24 							ZipperThread(BMessage* refsMessage, BWindow* window);
25 							~ZipperThread();
26 
27 				status_t	SuspendExternalZip();
28 				status_t	ResumeExternalZip();
29 				status_t	InterruptExternalZip();
30 				status_t	WaitOnExternalZip();
31 
32 	private:
33 		virtual status_t	ThreadStartup();
34 		virtual status_t	ExecuteUnit();
35 		virtual status_t	ThreadShutdown();
36 
37 		virtual void		ThreadStartupFailed(status_t a_status);
38 		virtual void		ExecuteUnitFailed(status_t a_status);
39 		virtual void		ThreadShutdownFailed(status_t a_status);
40 
41 				status_t	ProcessRefs(BMessage* msg);
42 				void		_MakeShellSafe(BString* string);
43 
44 				thread_id	_PipeCommand(int argc, const char** argv,
45 								int& in, int& out, int& err,
46 								const char** envp = (const char**)environ);
47 
48 				void		_SendMessageToWindow(uint32 what,
49 								const char* name  =  NULL, const char* value = NULL);
50 
51 				BMessenger	fWindowMessenger;
52 				thread_id	fZipProcess;
53 				int			m_std_in;
54 				int			m_std_out;
55 				int			m_std_err;
56 				FILE*		fOutputFile;
57 };
58 
59 #endif	// ZIPPER_THREAD_H
60 
61