173d4b58eSAxel Dörfler /* 23f4b183dSJonas Sundström * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. 373d4b58eSAxel Dörfler * Distributed under the terms of the MIT License. 473d4b58eSAxel Dörfler * 573d4b58eSAxel Dörfler * Authors: 63f4b183dSJonas Sundström * Jonas Sundström, jonas@kirilla.com 773d4b58eSAxel Dörfler */ 83f4b183dSJonas Sundström #ifndef _ZIPPER_THREAD_H 93f4b183dSJonas Sundström #define _ZIPPER_THREAD_H 1073d4b58eSAxel Dörfler 1173d4b58eSAxel Dörfler 1273d4b58eSAxel Dörfler #include <stdio.h> 13*31a41b60SOliver Tappe #include <stdlib.h> 1473d4b58eSAxel Dörfler 153f4b183dSJonas Sundström #include <Message.h> 163f4b183dSJonas Sundström #include <Messenger.h> 173f4b183dSJonas Sundström #include <Window.h> 183f4b183dSJonas Sundström 193f4b183dSJonas Sundström #include "GenericThread.h" 2073d4b58eSAxel Dörfler 2173d4b58eSAxel Dörfler 2273d4b58eSAxel Dörfler class ZipperThread : public GenericThread { 2373d4b58eSAxel Dörfler public: 243f4b183dSJonas Sundström ZipperThread(BMessage* refsMessage, 253f4b183dSJonas Sundström BWindow* window); 2673d4b58eSAxel Dörfler ~ZipperThread(); 2773d4b58eSAxel Dörfler 2873d4b58eSAxel Dörfler status_t SuspendExternalZip(); 2973d4b58eSAxel Dörfler status_t ResumeExternalZip(); 3073d4b58eSAxel Dörfler status_t InterruptExternalZip(); 3173d4b58eSAxel Dörfler status_t WaitOnExternalZip(); 3273d4b58eSAxel Dörfler 333f4b183dSJonas Sundström protected: 3473d4b58eSAxel Dörfler virtual status_t ThreadStartup(); 3573d4b58eSAxel Dörfler virtual status_t ExecuteUnit(); 3673d4b58eSAxel Dörfler virtual status_t ThreadShutdown(); 3773d4b58eSAxel Dörfler 383f4b183dSJonas Sundström virtual void ThreadStartupFailed(status_t status); 393f4b183dSJonas Sundström virtual void ExecuteUnitFailed(status_t status); 403f4b183dSJonas Sundström virtual void ThreadShutdownFailed(status_t status); 4173d4b58eSAxel Dörfler 423f4b183dSJonas Sundström private: 4373d4b58eSAxel Dörfler void _MakeShellSafe(BString* string); 4473d4b58eSAxel Dörfler 4573d4b58eSAxel Dörfler thread_id _PipeCommand(int argc, const char** argv, 4673d4b58eSAxel Dörfler int& in, int& out, int& err, 4773d4b58eSAxel Dörfler const char** envp = (const char**)environ); 4873d4b58eSAxel Dörfler 4973d4b58eSAxel Dörfler void _SendMessageToWindow(uint32 what, 503f4b183dSJonas Sundström const char* name = NULL, 513f4b183dSJonas Sundström const char* value = NULL); 5273d4b58eSAxel Dörfler 5373d4b58eSAxel Dörfler BMessenger fWindowMessenger; 5473d4b58eSAxel Dörfler thread_id fZipProcess; 553f4b183dSJonas Sundström int fStdIn; 563f4b183dSJonas Sundström int fStdOut; 573f4b183dSJonas Sundström int fStdErr; 5873d4b58eSAxel Dörfler FILE* fOutputFile; 5973d4b58eSAxel Dörfler }; 6073d4b58eSAxel Dörfler 613f4b183dSJonas Sundström #endif // _ZIPPER_THREAD_H 6273d4b58eSAxel Dörfler 63