From 3f4b183da1a9b652d7a389eab4ccca2df0ada631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Wed, 29 Jul 2009 08:39:38 +0000 Subject: [PATCH] Partial clean-up. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31896 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../tracker/zipomatic/GenericThread.cpp | 368 ++++++++++-------- src/add-ons/tracker/zipomatic/GenericThread.h | 130 ++++--- .../tracker/zipomatic/ZipperThread.cpp | 83 ++-- src/add-ons/tracker/zipomatic/ZipperThread.h | 71 ++-- 4 files changed, 340 insertions(+), 312 deletions(-) diff --git a/src/add-ons/tracker/zipomatic/GenericThread.cpp b/src/add-ons/tracker/zipomatic/GenericThread.cpp index ca4b975c31..c7dfeeb0a4 100644 --- a/src/add-ons/tracker/zipomatic/GenericThread.cpp +++ b/src/add-ons/tracker/zipomatic/GenericThread.cpp @@ -1,72 +1,79 @@ // license: public domain -// authors: jonas.sundstrom@kirilla.com +// authors: Jonas Sundström, jonas@kirilla.com + #include "GenericThread.h" #include -GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMessage * a_message) + +GenericThread::GenericThread(const char* thread_name, int32 priority, + BMessage* message) : - m_thread_data_store (a_message), - m_thread_id (spawn_thread (private_thread_function, a_thread_name, a_priority, this)), - m_execute_unit (create_sem(1, "m_execute_unit")), - m_quit_requested (false), - m_thread_is_paused (false) + fThreadDataStore(message), + fThreadId(spawn_thread (_ThreadFunction, thread_name, priority, this)), + fExecuteUnitSem(create_sem(1, "fExecuteUnitSem")), + fQuitRequested(false), + fThreadIsPaused(false) { - if (m_thread_data_store == NULL) - m_thread_data_store = new BMessage(); + if (fThreadDataStore == NULL) + fThreadDataStore = new BMessage(); } + GenericThread::~GenericThread() { - kill_thread(m_thread_id); + kill_thread(fThreadId); - delete_sem(m_execute_unit); + delete_sem(fExecuteUnitSem); } + status_t -GenericThread::ThreadFunction (void) +GenericThread::ThreadFunction() { - status_t status = B_OK; + status_t status = B_OK; - status = ThreadStartup(); // Subclass and override this function - if (status != B_OK) - { - ThreadStartupFailed (status); - return (status); + status = ThreadStartup(); + // Subclass and override this function + + if (status != B_OK) { + ThreadStartupFailed(status); + return status; // is this the right thing to do? } - while(1) - { - if (HasQuitBeenRequested()) - { - status = ThreadShutdown(); // Subclass and override this function - if (status != B_OK) - { - ThreadShutdownFailed (status); - return (status); - // what do we do? + while (1) { + if (HasQuitBeenRequested()) { + status = ThreadShutdown(); + // Subclass and override this function + + if (status != B_OK) { + ThreadShutdownFailed(status); + return status; } - delete this; // destructor + delete this; } BeginUnit(); - status = ExecuteUnit(); // Subclass and override + status = ExecuteUnit(); + // Subclass and override if (status != B_OK) - ExecuteUnitFailed (status); // Subclass and override + ExecuteUnitFailed (status); + // Subclass and override EndUnit(); } - return (B_OK); + return B_OK; } + status_t -GenericThread::ThreadStartup (void) +GenericThread::ThreadStartup() { // This function is virtual. // Subclass and override this function. @@ -76,7 +83,7 @@ GenericThread::ThreadStartup (void) status_t -GenericThread::ExecuteUnit (void) +GenericThread::ExecuteUnit() { // This function is virtual. @@ -87,8 +94,9 @@ GenericThread::ExecuteUnit (void) return B_OK; } + status_t -GenericThread::ThreadShutdown (void) +GenericThread::ThreadShutdown() { // This function is virtual. // Subclass and override this function. @@ -96,8 +104,9 @@ GenericThread::ThreadShutdown (void) return B_OK; } + void -GenericThread::ThreadStartupFailed (status_t a_status) +GenericThread::ThreadStartupFailed(status_t status) { // This function is virtual. // Subclass and override this function. @@ -105,8 +114,9 @@ GenericThread::ThreadStartupFailed (status_t a_status) Quit(); } + void -GenericThread::ExecuteUnitFailed (status_t a_status) +GenericThread::ExecuteUnitFailed(status_t status) { // This function is virtual. // Subclass and override this function. @@ -114,8 +124,9 @@ GenericThread::ExecuteUnitFailed (status_t a_status) Quit(); } + void -GenericThread::ThreadShutdownFailed (status_t a_status) +GenericThread::ThreadShutdownFailed(status_t status) { // This function is virtual. // Subclass and override this function. @@ -123,266 +134,303 @@ GenericThread::ThreadShutdownFailed (status_t a_status) // (is this good default behaviour?) } + status_t -GenericThread::Start (void) +GenericThread::Start() { - status_t status = B_OK; + status_t status = B_OK; - if (IsPaused()) - { - status = release_sem (m_execute_unit); + if (IsPaused()) { + status = release_sem(fExecuteUnitSem); if (status != B_OK) return status; - m_thread_is_paused = false; + fThreadIsPaused = false; } - status = resume_thread (m_thread_id); + status = resume_thread(fThreadId); return status; } + int32 -GenericThread::private_thread_function (void * a_simple_thread_ptr) +GenericThread::_ThreadFunction(void* simple_thread_ptr) { - status_t status = B_OK; + status_t status = B_OK; - status = ((GenericThread *) a_simple_thread_ptr)-> ThreadFunction(); + status = ((GenericThread*) simple_thread_ptr)->ThreadFunction(); - return (status); + return status; } -BMessage * -GenericThread::GetDataStore (void) + +BMessage* +GenericThread::GetDataStore() { - return (m_thread_data_store); + return fThreadDataStore; } + void -GenericThread::SetDataStore (BMessage * a_message) +GenericThread::SetDataStore(BMessage* message) { - m_thread_data_store = a_message; + fThreadDataStore = message; } + status_t -GenericThread::Pause (bool a_do_block, bigtime_t a_timeout) +GenericThread::Pause(bool doBlock, bigtime_t timeout) { - status_t status = B_OK; + status_t status = B_OK; - if (a_do_block) - status = acquire_sem(m_execute_unit); + if (doBlock) + status = acquire_sem(fExecuteUnitSem); // thread will wait on semaphore else - status = acquire_sem_etc(m_execute_unit, 1, B_RELATIVE_TIMEOUT, a_timeout); + status = acquire_sem_etc(fExecuteUnitSem, 1, B_RELATIVE_TIMEOUT, + timeout); // thread will timeout - if (status == B_OK) - { - m_thread_is_paused = true; - return (B_OK); + if (status == B_OK) { + fThreadIsPaused = true; + return B_OK; } return status; } + void -GenericThread::Quit (void) +GenericThread::Quit() { - m_quit_requested = true; + fQuitRequested = true; } + bool -GenericThread::HasQuitBeenRequested (void) +GenericThread::HasQuitBeenRequested() { - return (m_quit_requested); + return fQuitRequested; } + bool -GenericThread::IsPaused (void) +GenericThread::IsPaused() { - return (m_thread_is_paused); + return fThreadIsPaused; } -status_t -GenericThread::Suspend (void) -{ - return (suspend_thread(m_thread_id)); -} status_t -GenericThread::Resume (void) +GenericThread::Suspend() { - release_sem(m_execute_unit); // to counteract Pause() - m_thread_is_paused = false; + return suspend_thread(fThreadId); +} + + +status_t +GenericThread::Resume() +{ + release_sem(fExecuteUnitSem); + // to counteract Pause() + fThreadIsPaused = false; - return (resume_thread(m_thread_id)); // to counteract Suspend() + return resume_thread(fThreadId); + // to counteract Suspend() } + status_t -GenericThread::Kill (void) +GenericThread::Kill() { - return (kill_thread(m_thread_id)); + return kill_thread(fThreadId); } + void -GenericThread::ExitWithReturnValue (status_t a_return_value) +GenericThread::ExitWithReturnValue(status_t return_value) { - exit_thread(a_return_value); + exit_thread(return_value); } -status_t -GenericThread::SetExitCallback (void (*a_callback)(void*), void * a_data) -{ - return (on_exit_thread(a_callback, a_data)); -} status_t -GenericThread::WaitForThread (status_t * a_exit_value) +GenericThread::SetExitCallback(void (*callback)(void*), void* data) { - return (wait_for_thread(m_thread_id, a_exit_value)); + return on_exit_thread(callback, data); } -status_t -GenericThread::Rename (char * a_name) -{ - return (rename_thread(m_thread_id, a_name)); -} status_t -GenericThread::SendData (int32 a_code, void * a_buffer, size_t a_buffer_size) +GenericThread::WaitForThread(status_t* exitValue) { - return (send_data(m_thread_id, a_code, a_buffer, a_buffer_size)); + return wait_for_thread(fThreadId, exitValue); } + +status_t +GenericThread::Rename(char* name) +{ + return rename_thread(fThreadId, name); +} + + +status_t +GenericThread::SendData(int32 code, void* buffer, size_t buffer_size) +{ + return send_data(fThreadId, code, buffer, buffer_size); +} + + int32 -GenericThread::ReceiveData (thread_id * a_sender, void * a_buffer, size_t a_buffer_size) +GenericThread::ReceiveData(thread_id* sender, void* buffer, size_t buffer_size) { - return (receive_data(a_sender, a_buffer, a_buffer_size)); + return receive_data(sender, buffer, buffer_size); } - + + bool -GenericThread::HasData (void) +GenericThread::HasData() { - return (has_data(m_thread_id)); -} - -status_t -GenericThread::SetPriority (int32 a_new_priority) -{ - return (set_thread_priority(m_thread_id, a_new_priority)); + return has_data(fThreadId); } + +status_t +GenericThread::SetPriority(int32 newPriority) +{ + return set_thread_priority(fThreadId, newPriority); +} + + void -GenericThread::Snooze (bigtime_t a_microseconds) +GenericThread::Snooze(bigtime_t microseconds) { Suspend(); - snooze(a_microseconds); + snooze(microseconds); Resume(); } + void -GenericThread::SnoozeUntil (bigtime_t a_microseconds, int a_timebase) +GenericThread::SnoozeUntil(bigtime_t microseconds, int timebase) { Suspend(); - snooze_until(a_microseconds, a_timebase); + snooze_until(microseconds, timebase); Resume(); } + status_t -GenericThread::GetInfo (thread_info * a_thread_info) +GenericThread::GetInfo(thread_info* threadInfo) { - return (get_thread_info(m_thread_id, a_thread_info)); + return get_thread_info(fThreadId, threadInfo); } + thread_id -GenericThread::GetThread (void) +GenericThread::GetThread() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.thread); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.thread; } + team_id -GenericThread::GetTeam (void) +GenericThread::GetTeam() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.team); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.team; } -char * -GenericThread::GetName (void) + +char* +GenericThread::GetName() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return strdup(t_thread_info.name); + thread_info threadInfo; + GetInfo(&threadInfo); + return strdup(threadInfo.name); } + thread_state -GenericThread::GetState (void) +GenericThread::GetState() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.state); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.state; } + sem_id -GenericThread::GetSemaphore (void) +GenericThread::GetSemaphore() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.sem); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.sem; } + int32 -GenericThread::GetPriority (void) +GenericThread::GetPriority() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.priority); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.priority; } + bigtime_t -GenericThread::GetUserTime (void) +GenericThread::GetUserTime() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.user_time); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.user_time; } + bigtime_t -GenericThread::GetKernelTime (void) +GenericThread::GetKernelTime() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.kernel_time); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.kernel_time; } -void * -GenericThread::GetStackBase (void) + +void* +GenericThread::GetStackBase() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.stack_base); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.stack_base; } -void * -GenericThread::GetStackEnd (void) + +void* +GenericThread::GetStackEnd() { - thread_info t_thread_info; - GetInfo (& t_thread_info); - return (t_thread_info.stack_end); + thread_info threadInfo; + GetInfo(&threadInfo); + return threadInfo.stack_end; } + void -GenericThread::BeginUnit (void) +GenericThread::BeginUnit() { - acquire_sem(m_execute_unit); // thread can not be paused until it releases semaphore + acquire_sem(fExecuteUnitSem); + // thread can not be paused until it releases semaphore } + void -GenericThread::EndUnit (void) +GenericThread::EndUnit() { - release_sem(m_execute_unit); // thread can now be paused + release_sem(fExecuteUnitSem); + // thread can now be paused } diff --git a/src/add-ons/tracker/zipomatic/GenericThread.h b/src/add-ons/tracker/zipomatic/GenericThread.h index 3a2d8c698b..16742079b4 100644 --- a/src/add-ons/tracker/zipomatic/GenericThread.h +++ b/src/add-ons/tracker/zipomatic/GenericThread.h @@ -1,83 +1,87 @@ #ifndef __GENERIC_THREAD_H__ #define __GENERIC_THREAD_H__ -#include + #include + class GenericThread { - public: - GenericThread (const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL); - virtual ~GenericThread (void); +public: + GenericThread(const char* + thread_name = "generic_thread", + int32 priority = B_NORMAL_PRIORITY, + BMessage* message = NULL); + virtual ~GenericThread(); - BMessage * GetDataStore (void); - void SetDataStore (BMessage * a_message); + BMessage* GetDataStore(); + void SetDataStore(BMessage* message); - status_t Start (void); - status_t Pause (bool a_do_block = TRUE, bigtime_t a_timeout = 0); - void Quit (void); - bool IsPaused (void); - bool HasQuitBeenRequested (void); - - status_t Suspend (void); - status_t Resume (void); - status_t Kill (void); - - void ExitWithReturnValue (status_t a_return_value); - status_t SetExitCallback (void (* a_callback)(void *), void * a_data); - status_t WaitForThread (status_t * a_exit_value); - - status_t Rename (char * a_name); - - status_t SendData (int32 a_code, void * a_buffer, size_t a_buffer_size); - int32 ReceiveData (thread_id * a_sender, void * a_buffer, size_t a_buffer_size); - bool HasData (void); + status_t Start(); + status_t Pause(bool doBlock = TRUE, bigtime_t timeout = 0); + void Quit(); + bool IsPaused(); + bool HasQuitBeenRequested(); - status_t SetPriority (int32 a_new_priority); + status_t Suspend(); + status_t Resume(); + status_t Kill(); + + void ExitWithReturnValue(status_t returnValue); + status_t SetExitCallback(void (* callback)(void*), + void* data); + status_t WaitForThread(status_t* exitValue); + + status_t Rename(char* name); + + status_t SendData(int32 code, void* buffer, + size_t bufferSize); + int32 ReceiveData(thread_id* sender, void* buffer, + size_t bufferSize); + bool HasData(); + + status_t SetPriority(int32 newPriority); - void Snooze (bigtime_t a_microseconds); - void SnoozeUntil (bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE); - + void Snooze(bigtime_t microseconds); + void SnoozeUntil(bigtime_t microseconds, + int timebase = B_SYSTEM_TIMEBASE); - status_t GetInfo (thread_info * a_thread_info); - thread_id GetThread (void); - team_id GetTeam (void); - char * GetName (void); - thread_state GetState (void); - sem_id GetSemaphore (void); - int32 GetPriority (void); - bigtime_t GetUserTime (void); - bigtime_t GetKernelTime (void); - void * GetStackBase (void); - void * GetStackEnd (void); + status_t GetInfo(thread_info* threadInfo); + thread_id GetThread(); + team_id GetTeam(); + char* GetName(); + thread_state GetState(); + sem_id GetSemaphore(); + int32 GetPriority(); + bigtime_t GetUserTime(); + bigtime_t GetKernelTime(); + void* GetStackBase(); + void* GetStackEnd(); - protected: +protected: + virtual status_t ThreadFunction(); + virtual status_t ThreadStartup(); + virtual status_t ExecuteUnit(); + virtual status_t ThreadShutdown(); + + virtual void ThreadStartupFailed(status_t status); + virtual void ExecuteUnitFailed(status_t status); + virtual void ThreadShutdownFailed(status_t status); - virtual status_t ThreadFunction (void); - virtual status_t ThreadStartup (void); - virtual status_t ExecuteUnit (void); - virtual status_t ThreadShutdown (void); - - virtual void ThreadStartupFailed (status_t a_status); - virtual void ExecuteUnitFailed (status_t a_status); - virtual void ThreadShutdownFailed (status_t a_status); + void BeginUnit(); + void EndUnit(); - void BeginUnit (void); // acquire m_execute_cycle - void EndUnit (void); // release m_execute_cycle - - BMessage * m_thread_data_store; + BMessage* fThreadDataStore; - private: - - static status_t private_thread_function (void * a_simple_thread_ptr); +private: + static status_t _ThreadFunction(void* simpleThreadPtr); - thread_id m_thread_id; - - sem_id m_execute_unit; // acq./relase within tread_function.. For Pause() - - bool m_quit_requested; - bool m_thread_is_paused; + thread_id fThreadId; + sem_id fExecuteUnitSem; + bool fQuitRequested; + bool fThreadIsPaused; }; -#endif +#endif // __GENERIC_THREAD_H__ + diff --git a/src/add-ons/tracker/zipomatic/ZipperThread.cpp b/src/add-ons/tracker/zipomatic/ZipperThread.cpp index 4526e3567b..de17966a22 100644 --- a/src/add-ons/tracker/zipomatic/ZipperThread.cpp +++ b/src/add-ons/tracker/zipomatic/ZipperThread.cpp @@ -1,42 +1,39 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: - * Jonas Sundström, jonas.sundstrom@kirilla.com + * Jonas Sundström, jonas@kirilla.com + * Peter Folk */ #include "ZipperThread.h" -#include "ZipOMaticWindow.h" -#include "ZipOMaticMisc.h" -#include +#include +#include +#include + #include #include #include #include -#include -#include -#include - - -const char* kZipperThreadName = "ZipperThread"; +#include "ZipOMaticMisc.h" +#include "ZipOMaticWindow.h" ZipperThread::ZipperThread (BMessage* refsMessage, BWindow* window) - : GenericThread(kZipperThreadName, B_NORMAL_PRIORITY, refsMessage), + : + GenericThread("ZipperThread", B_NORMAL_PRIORITY, refsMessage), fWindowMessenger(window), fZipProcess(-1), - m_std_in(-1), - m_std_out(-1), - m_std_err(-1), + fStdIn(-1), + fStdOut(-1), + fStdErr(-1), fOutputFile(NULL) { - PRINT(("ZipperThread()\n")); - - m_thread_data_store = new BMessage(*refsMessage); + fThreadDataStore = new BMessage(*refsMessage); // leak? // prevents bug with B_SIMPLE_DATA // (drag&drop messages) @@ -51,8 +48,6 @@ ZipperThread::~ZipperThread() status_t ZipperThread::ThreadStartup() { - PRINT(("ZipperThread::ThreadStartup()\n")); - BString archiveName = "Archive.zip"; // do all refs have the same parent dir? @@ -62,12 +57,12 @@ ZipperThread::ThreadStartup() entry_ref lastRef; bool sameFolder = true; - status_t status = m_thread_data_store->GetInfo("refs", &type, &refCount); + status_t status = fThreadDataStore->GetInfo("refs", &type, &refCount); if (status != B_OK) return status; for (int index = 0; index < refCount; index++) { - m_thread_data_store->FindRef("refs", index, &ref); + fThreadDataStore->FindRef("refs", index, &ref); if (index > 0) { BEntry entry(&ref); @@ -114,8 +109,8 @@ ZipperThread::ThreadStartup() argv[2] = strdup(archiveName.String()); // files to zip - for (int index = 0; index < refCount ; index++) { - m_thread_data_store->FindRef("refs", index, &ref); + for (int index = 0; index < refCount; index++) { + fThreadDataStore->FindRef("refs", index, &ref); if (sameFolder) { // just the file name @@ -130,7 +125,7 @@ ZipperThread::ThreadStartup() argv[argc] = NULL; - fZipProcess = _PipeCommand(argc, argv, m_std_in, m_std_out, m_std_err); + fZipProcess = _PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr); delete [] argv; @@ -139,7 +134,7 @@ ZipperThread::ThreadStartup() resume_thread(fZipProcess); - fOutputFile = fdopen(m_std_out, "r"); + fOutputFile = fdopen(fStdOut, "r"); if (fOutputFile == NULL) return errno; @@ -148,8 +143,6 @@ ZipperThread::ThreadStartup() _SendMessageToWindow('strt', "archive_filename", archiveName.String()); _SendMessageToWindow('outp', "zip_output", "Preparing to archive"); - PRINT(("\n")); - return B_OK; } @@ -157,8 +150,6 @@ ZipperThread::ThreadStartup() status_t ZipperThread::ExecuteUnit() { - //PRINT(("ZipperThread::ExecuteUnit()\n")); - // read output from /bin/zip // send it to window char buffer[4096]; @@ -188,11 +179,9 @@ ZipperThread::ExecuteUnit() status_t ZipperThread::ThreadShutdown() { - PRINT(("ZipperThread::ThreadShutdown()\n")); - - close(m_std_in); - close(m_std_out); - close(m_std_err); + close(fStdIn); + close(fStdOut); + close(fStdErr); return B_OK; } @@ -239,13 +228,6 @@ ZipperThread::_MakeShellSafe(BString* string) } -status_t -ZipperThread::ProcessRefs(BMessage* msg) -{ - return B_OK; -} - - thread_id ZipperThread::_PipeCommand(int argc, const char** argv, int& in, int& out, int& err, const char** envp) @@ -288,10 +270,9 @@ ZipperThread::_PipeCommand(int argc, const char** argv, int& in, int& out, // execute command thread = load_image(argc, argv, envp); - - PRINT(("load_image() thread_id: %ld\n", ret)); - } else + } else { thread = errno; + } // Restore old FDs dup2(oldIn, STDIN_FILENO); @@ -317,7 +298,8 @@ err1: void -ZipperThread::_SendMessageToWindow(uint32 what, const char* name, const char* value) +ZipperThread::_SendMessageToWindow(uint32 what, const char* name, + const char* value) { BMessage msg(what); if (name != NULL && value != NULL) @@ -330,8 +312,6 @@ ZipperThread::_SendMessageToWindow(uint32 what, const char* name, const char* va status_t ZipperThread::SuspendExternalZip() { - PRINT(("ZipperThread::SuspendExternalZip()\n")); - thread_info info; status_t status = get_thread_info(fZipProcess, &info); @@ -345,8 +325,6 @@ ZipperThread::SuspendExternalZip() status_t ZipperThread::ResumeExternalZip() { - PRINT(("ZipperThread::ResumeExternalZip()\n")); - thread_info info; status_t status = get_thread_info(fZipProcess, &info); @@ -360,8 +338,6 @@ ZipperThread::ResumeExternalZip() status_t ZipperThread::InterruptExternalZip() { - PRINT(("ZipperThread::InterruptExternalZip()\n")); - thread_info info; status_t status = get_thread_info(fZipProcess, &info); @@ -379,8 +355,6 @@ ZipperThread::InterruptExternalZip() status_t ZipperThread::WaitOnExternalZip() { - PRINT(("ZipperThread::WaitOnExternalZip()\n")); - thread_info info; status_t status = get_thread_info(fZipProcess, &info); @@ -389,3 +363,4 @@ ZipperThread::WaitOnExternalZip() return status; } + diff --git a/src/add-ons/tracker/zipomatic/ZipperThread.h b/src/add-ons/tracker/zipomatic/ZipperThread.h index 2a8b4d2c3f..6871dd6640 100644 --- a/src/add-ons/tracker/zipomatic/ZipperThread.h +++ b/src/add-ons/tracker/zipomatic/ZipperThread.h @@ -1,60 +1,61 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: - * Jonas Sundström, jonas.sundstrom@kirilla.com + * Jonas Sundström, jonas@kirilla.com */ -#ifndef ZIPPER_THREAD_H -#define ZIPPER_THREAD_H +#ifndef _ZIPPER_THREAD_H +#define _ZIPPER_THREAD_H -#include "GenericThread.h" - -#include - #include -class BMessage; -class BWindow; +#include +#include +#include + +#include "GenericThread.h" class ZipperThread : public GenericThread { - public: - ZipperThread(BMessage* refsMessage, BWindow* window); +public: + ZipperThread(BMessage* refsMessage, + BWindow* window); ~ZipperThread(); - status_t SuspendExternalZip(); - status_t ResumeExternalZip(); - status_t InterruptExternalZip(); - status_t WaitOnExternalZip(); + status_t SuspendExternalZip(); + status_t ResumeExternalZip(); + status_t InterruptExternalZip(); + status_t WaitOnExternalZip(); - private: - virtual status_t ThreadStartup(); - virtual status_t ExecuteUnit(); - virtual status_t ThreadShutdown(); +protected: + virtual status_t ThreadStartup(); + virtual status_t ExecuteUnit(); + virtual status_t ThreadShutdown(); - virtual void ThreadStartupFailed(status_t a_status); - virtual void ExecuteUnitFailed(status_t a_status); - virtual void ThreadShutdownFailed(status_t a_status); + virtual void ThreadStartupFailed(status_t status); + virtual void ExecuteUnitFailed(status_t status); + virtual void ThreadShutdownFailed(status_t status); - status_t ProcessRefs(BMessage* msg); - void _MakeShellSafe(BString* string); +private: + void _MakeShellSafe(BString* string); - thread_id _PipeCommand(int argc, const char** argv, + thread_id _PipeCommand(int argc, const char** argv, int& in, int& out, int& err, const char** envp = (const char**)environ); - void _SendMessageToWindow(uint32 what, - const char* name = NULL, const char* value = NULL); + void _SendMessageToWindow(uint32 what, + const char* name = NULL, + const char* value = NULL); - BMessenger fWindowMessenger; - thread_id fZipProcess; - int m_std_in; - int m_std_out; - int m_std_err; - FILE* fOutputFile; + BMessenger fWindowMessenger; + thread_id fZipProcess; + int fStdIn; + int fStdOut; + int fStdErr; + FILE* fOutputFile; }; -#endif // ZIPPER_THREAD_H +#endif // _ZIPPER_THREAD_H