1/* 2 * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Jonas Sundstr��m, jonas@kirilla.com 7 */ 8#ifndef _ZIPPER_THREAD_H 9#define _ZIPPER_THREAD_H 10 11 12#include <stdio.h> 13#include <stdlib.h> 14 15#include <Entry.h> 16#include <Message.h> 17#include <Messenger.h> 18#include <String.h> 19#include <Window.h> 20 21#include "GenericThread.h" 22 23 24class ZipperThread : public GenericThread { 25public: 26 ZipperThread(BMessage* refsMessage, 27 BWindow* window); 28 ~ZipperThread(); 29 30 status_t SuspendExternalZip(); 31 status_t ResumeExternalZip(); 32 status_t InterruptExternalZip(); 33 status_t WaitOnExternalZip(); 34 35protected: 36 virtual status_t ThreadStartup(); 37 virtual status_t ExecuteUnit(); 38 virtual status_t ThreadShutdown(); 39 40 virtual void ThreadStartupFailed(status_t status); 41 virtual void ExecuteUnitFailed(status_t status); 42 virtual void ThreadShutdownFailed(status_t status); 43 44private: 45 void _MakeShellSafe(BString* string); 46 47 thread_id _PipeCommand(int argc, const char** argv, 48 int& in, int& out, int& err, 49 const char** envp = (const char**)environ); 50 51 void _SendMessageToWindow(uint32 what, 52 const char* name = NULL, 53 const char* value = NULL); 54 55 status_t _SelectInTracker(); 56 57 BMessenger fWindowMessenger; 58 thread_id fZipProcess; 59 int fStdIn; 60 int fStdOut; 61 int fStdErr; 62 FILE* fOutputFile; 63 entry_ref fOutputEntryRef; 64}; 65 66#endif // _ZIPPER_THREAD_H 67 68