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> 1331a41b60SOliver Tappe #include <stdlib.h> 1473d4b58eSAxel Dörfler 15714236b8SJonas Sundström #include <Entry.h> 163f4b183dSJonas Sundström #include <Message.h> 173f4b183dSJonas Sundström #include <Messenger.h> 182680698bSJonas Sundström #include <String.h> 193f4b183dSJonas Sundström #include <Window.h> 203f4b183dSJonas Sundström 213f4b183dSJonas Sundström #include "GenericThread.h" 2273d4b58eSAxel Dörfler 2373d4b58eSAxel Dörfler 2473d4b58eSAxel Dörfler class ZipperThread : public GenericThread { 2573d4b58eSAxel Dörfler public: 263f4b183dSJonas Sundström ZipperThread(BMessage* refsMessage, 273f4b183dSJonas Sundström BWindow* window); 2873d4b58eSAxel Dörfler ~ZipperThread(); 2973d4b58eSAxel Dörfler 3073d4b58eSAxel Dörfler status_t SuspendExternalZip(); 3173d4b58eSAxel Dörfler status_t ResumeExternalZip(); 3273d4b58eSAxel Dörfler status_t InterruptExternalZip(); 3373d4b58eSAxel Dörfler status_t WaitOnExternalZip(); 3473d4b58eSAxel Dörfler 353f4b183dSJonas Sundström protected: 3673d4b58eSAxel Dörfler virtual status_t ThreadStartup(); 3773d4b58eSAxel Dörfler virtual status_t ExecuteUnit(); 3873d4b58eSAxel Dörfler virtual status_t ThreadShutdown(); 3973d4b58eSAxel Dörfler 403f4b183dSJonas Sundström virtual void ThreadStartupFailed(status_t status); 413f4b183dSJonas Sundström virtual void ExecuteUnitFailed(status_t status); 423f4b183dSJonas Sundström virtual void ThreadShutdownFailed(status_t status); 4373d4b58eSAxel Dörfler 443f4b183dSJonas Sundström private: 4573d4b58eSAxel Dörfler void _MakeShellSafe(BString* string); 4673d4b58eSAxel Dörfler 4773d4b58eSAxel Dörfler thread_id _PipeCommand(int argc, const char** argv, 4873d4b58eSAxel Dörfler int& in, int& out, int& err, 4973d4b58eSAxel Dörfler const char** envp = (const char**)environ); 5073d4b58eSAxel Dörfler 5173d4b58eSAxel Dörfler void _SendMessageToWindow(uint32 what, 523f4b183dSJonas Sundström const char* name = NULL, 533f4b183dSJonas Sundström const char* value = NULL); 5473d4b58eSAxel Dörfler 55*56241aabSAugustin Cavalier status_t _SelectInTracker(); 56714236b8SJonas Sundström 5773d4b58eSAxel Dörfler BMessenger fWindowMessenger; 5873d4b58eSAxel Dörfler thread_id fZipProcess; 593f4b183dSJonas Sundström int fStdIn; 603f4b183dSJonas Sundström int fStdOut; 613f4b183dSJonas Sundström int fStdErr; 6273d4b58eSAxel Dörfler FILE* fOutputFile; 63714236b8SJonas Sundström entry_ref fOutputEntryRef; 6473d4b58eSAxel Dörfler }; 6573d4b58eSAxel Dörfler 663f4b183dSJonas Sundström #endif // _ZIPPER_THREAD_H 6773d4b58eSAxel Dörfler 68