From 9e22843851a61507cbc491e1e81564e0bae6971f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 22 Aug 2006 21:37:22 +0000 Subject: [PATCH] * Fixed the most annoying style violations of the files I had to look at - there are still plenty of them left, though. Hey Jonas, we do have a coding style guideline! * Removed an extra copy of the message passed in to the settings constructor. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18571 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../tracker/zipomatic/ZipOMaticSettings.cpp | 154 +++--- .../tracker/zipomatic/ZipOMaticSettings.h | 58 ++- .../tracker/zipomatic/ZipOMaticZipper.cpp | 469 +++++++++--------- .../tracker/zipomatic/ZipOMaticZipper.h | 95 ++-- 4 files changed, 378 insertions(+), 398 deletions(-) diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticSettings.cpp b/src/add-ons/tracker/zipomatic/ZipOMaticSettings.cpp index b24fe3c768..62595f765c 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticSettings.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMaticSettings.cpp @@ -1,140 +1,120 @@ -// license: public domain -// authors: jonas.sundstrom@kirilla.com +/* + * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jonas Sundström, jonas.sundstrom@kirilla.com + */ -// // TODO: proper locking <<--------- -// + +#include "ZipOMaticMisc.h" +#include "ZipOMaticSettings.h" #include - #include #include #include #include #include -#include "ZipOMaticMisc.h" -#include "ZipOMaticSettings.h" ZippoSettings::ZippoSettings() -: BMessage (), - m_volume (), - m_base_dir (B_USER_SETTINGS_DIRECTORY), - m_relative_path (), - m_settings_filename () + : + fBaseDir(B_USER_SETTINGS_DIRECTORY) { PRINT(("ZippoSettings()\n")); } -ZippoSettings::ZippoSettings(BMessage a_message) -: BMessage (a_message), - m_volume (), - m_base_dir (B_USER_SETTINGS_DIRECTORY), - m_relative_path (), - m_settings_filename () + +ZippoSettings::ZippoSettings(BMessage& message) + : BMessage(message), + fBaseDir(B_USER_SETTINGS_DIRECTORY) { PRINT(("ZippoSettings(a_message)\n")); } + ZippoSettings::~ZippoSettings() { - m_volume.Unset(); } + status_t -ZippoSettings::SetTo (const char * a_settings_filename, - BVolume * a_volume, - directory_which a_base_dir, - const char * a_relative_path) +ZippoSettings::SetTo(const char* filename, BVolume* volume, + directory_which baseDir, const char* relativePath) { - status_t status = B_OK; + status_t status = B_OK; // copy to members - m_base_dir = a_base_dir; - m_relative_path = a_relative_path; - m_settings_filename = a_settings_filename; - + fBaseDir = baseDir; + fRelativePath = relativePath; + fFilename = filename; + // sanity check - if (a_volume == NULL) - { - BVolumeRoster volume_roster; - volume_roster.GetBootVolume(& m_volume); - } - else - m_volume = *(a_volume); - - status = m_volume.InitCheck(); + if (volume == NULL) { + BVolumeRoster volumeRoster; + volumeRoster.GetBootVolume(&fVolume); + } else + fVolume = *volume; + + status = fVolume.InitCheck(); if (status != B_OK) return status; - - // InitCheck + return InitCheck(); } -status_t -ZippoSettings::InitCheck (void) -{ - BFile settings_file; - - return GetSettingsFile (& settings_file, B_READ_ONLY | B_CREATE_FILE); -} - -status_t -ZippoSettings::GetSettingsFile (BFile * a_settings_file, uint32 a_openmode) -{ - status_t status = B_OK; - BPath settings_path; - - status = find_and_create_directory(m_base_dir, & m_volume, m_relative_path.String(), & settings_path); - if (status != B_OK) - return status; - - status = settings_path.Append (m_settings_filename.String()); - if (status != B_OK) - return status; - - status = a_settings_file->SetTo (settings_path.Path(), a_openmode); - if (status != B_OK) - return status; - - return B_OK; -} status_t -ZippoSettings::ReadSettings (void) +ZippoSettings::InitCheck() +{ + BFile file; + return _GetSettingsFile(&file, B_READ_ONLY | B_CREATE_FILE); +} + + +status_t +ZippoSettings::ReadSettings() { PRINT(("ZippoSettings::ReadSettings()\n")); - status_t status = B_OK; - BFile settings_file; - - status = GetSettingsFile (& settings_file, B_READ_ONLY); - if (status != B_OK) - return status; - - status = Unflatten(& settings_file); + BFile file; + status_t status = _GetSettingsFile(&file, B_READ_ONLY); if (status != B_OK) return status; - return B_OK; + return Unflatten(&file); } + status_t -ZippoSettings::WriteSettings (void) +ZippoSettings::WriteSettings() { PRINT(("ZippoSettings::WriteSettings()\n")); - status_t status = B_OK; - BFile settings_file; - - status = GetSettingsFile (& settings_file, B_WRITE_ONLY | B_ERASE_FILE); - if (status != B_OK) - return status; - - status = Flatten(& settings_file); + BFile file; + status_t status = _GetSettingsFile(&file, B_WRITE_ONLY | B_ERASE_FILE); if (status != B_OK) return status; - return B_OK; + return Flatten(&file); +} + + +status_t +ZippoSettings::_GetSettingsFile(BFile* file, uint32 openMode) +{ + BPath path; + status_t status = find_and_create_directory(fBaseDir, &fVolume, + fRelativePath.String(), &path); + if (status != B_OK) + return status; + + status = path.Append(fFilename.String()); + if (status != B_OK) + return status; + + return file->SetTo(path.Path(), openMode); } diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticSettings.h b/src/add-ons/tracker/zipomatic/ZipOMaticSettings.h index d1574bd9e6..16c99f9878 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticSettings.h +++ b/src/add-ons/tracker/zipomatic/ZipOMaticSettings.h @@ -1,36 +1,42 @@ -#ifndef __ZIPPO_SETTINGS_H__ -#define __ZIPPO_SETTINGS_H__ +/* + * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jonas Sundström, jonas.sundstrom@kirilla.com + */ +#ifndef ZIPOMATIC_SETTINGS_H +#define ZIPOMATIC_SETTINGS_H + +#include #include -#include #include +#include -class ZippoSettings : public BMessage -{ -public: - ZippoSettings (); - ZippoSettings (BMessage a_message); - ~ZippoSettings (); - - status_t SetTo (const char * a_settings_filename, - BVolume * a_volume = NULL, - directory_which a_base_dir = B_USER_SETTINGS_DIRECTORY, - const char * a_relative_path = NULL); - status_t InitCheck (void); - - status_t ReadSettings (); - status_t WriteSettings (); - -private: +class ZippoSettings : public BMessage { + public: + ZippoSettings(); + ZippoSettings(BMessage& message); + ~ZippoSettings(); - status_t GetSettingsFile (BFile * a_settings_file, uint32 a_openmode); + status_t SetTo(const char* filename, BVolume* volume = NULL, + directory_which baseDir = B_USER_SETTINGS_DIRECTORY, + const char* relativePath = NULL); - BVolume m_volume; - directory_which m_base_dir; - BString m_relative_path; - BString m_settings_filename; + status_t InitCheck(); + status_t ReadSettings(); + status_t WriteSettings(); + + private: + status_t _GetSettingsFile(BFile* file, uint32 openMode); + + BVolume fVolume; + directory_which fBaseDir; + BString fRelativePath; + BString fFilename; }; -#endif // __ZIPPO_SETTINGS_H__ +#endif // ZIPOMATIC_SETTINGS_H diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticZipper.cpp b/src/add-ons/tracker/zipomatic/ZipOMaticZipper.cpp index 7ceb622c38..4020d08ce5 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticZipper.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMaticZipper.cpp @@ -1,162 +1,153 @@ -// license: public domain -// authors: jonas.sundstrom@kirilla.com -// -// exception: ZipperThread::PipeCommand() -// written by Peter Folk, published in the BeDevTalk mailinglist FAQ -// License unknown, most likely public domain +/* + * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jonas Sundström, jonas.sundstrom@kirilla.com + */ -#include - -#include #include "ZipOMaticZipper.h" #include "ZipOMaticWindow.h" #include "ZipOMaticMisc.h" +#include +#include +#include +#include +#include + +#include +#include +#include + #include #include #include -const char * ZipperThreadName = "ZipperThread"; + +const char* kZipperThreadName = "ZipperThread"; -ZipperThread::ZipperThread (BMessage * a_refs_message, BWindow * a_window) -: GenericThread(ZipperThreadName, B_NORMAL_PRIORITY, a_refs_message), - m_window (a_window), - m_window_messenger (new BMessenger(NULL, a_window)), - m_zip_process_thread_id (-1), - m_std_in (-1), - m_std_out (-1), - m_std_err (-1), - m_zip_output (NULL), - m_zip_output_string (), - m_zip_output_buffer (new char [4096]) +ZipperThread::ZipperThread (BMessage* refsMessage, BWindow* window) + : GenericThread(kZipperThreadName, B_NORMAL_PRIORITY, refsMessage), + fWindowMessenger(window), + m_zip_process_thread_id(-1), + m_std_in(-1), + m_std_out(-1), + m_std_err(-1), + fOutputFile(NULL) { PRINT(("ZipperThread()\n")); - - m_thread_data_store = new BMessage (* a_refs_message); // leak? - // prevents bug with B_SIMPLE_DATA - // (drag&drop messages) + + m_thread_data_store = new BMessage(*refsMessage); + // leak? + // prevents bug with B_SIMPLE_DATA + // (drag&drop messages) } + ZipperThread::~ZipperThread() { - delete m_window_messenger; - delete [] m_zip_output_buffer; } + status_t -ZipperThread::ThreadStartup (void) +ZipperThread::ThreadStartup() { PRINT(("ZipperThread::ThreadStartup()\n")); - // init - status_t status = B_OK; - entry_ref ref; - entry_ref last_ref; - bool same_folder = true; + // init + status_t status = B_OK; + entry_ref ref; + entry_ref last_ref; + bool same_folder = true; + + BString zip_archive_filename = "Archive.zip"; - BString zip_archive_filename = "Archive.zip"; - // do all refs have the same parent dir? - type_code ref_type = B_REF_TYPE; - int32 ref_count = 0; - - status = m_thread_data_store->GetInfo("refs", & ref_type, & ref_count); + type_code ref_type = B_REF_TYPE; + int32 ref_count = 0; + + status = m_thread_data_store->GetInfo("refs", &ref_type, &ref_count); if (status != B_OK) return status; - - for (int index = 0; index < ref_count ; index++) - { + + for (int index = 0; index < ref_count ; index++) { m_thread_data_store->FindRef("refs", index, & ref); - if (index > 0) - { - BEntry entry (& ref); - if (entry.IsSymLink()) - { + if (index > 0) { + BEntry entry(&ref); + if (entry.IsSymLink()) { entry.SetTo(& ref, true); entry_ref target; entry.GetRef(& target); - if (last_ref.directory != target.directory) - { - same_folder = false; + if (last_ref.directory != target.directory) { + same_folder = false; break; } - } - else - if (last_ref.directory != ref.directory) - { - same_folder = false; + } else if (last_ref.directory != ref.directory) { + same_folder = false; break; } } - last_ref = ref; + last_ref = ref; } // change active dir - if (same_folder) - { - BEntry entry (& last_ref); + if (same_folder) { + BEntry entry(&last_ref); BPath path; - entry.GetParent(& entry); - entry.GetPath(& path); + entry.GetParent(&entry); + entry.GetPath(&path); chdir(path.Path()); - } - else - { + } else { BPath path; - if (find_directory(B_DESKTOP_DIRECTORY, & path) == B_OK) - chdir (path.Path()); + if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) + chdir(path.Path()); } // archive filename - if (ref_count == 1) - { - zip_archive_filename = last_ref.name; - zip_archive_filename += ".zip"; + if (ref_count == 1) { + zip_archive_filename = last_ref.name; + zip_archive_filename += ".zip"; } - - int32 argc = ref_count + 3; - const char ** argv = new const char * [argc + 1]; - - argv[0] = strdup("/bin/zip"); - argv[1] = strdup("-ry"); - argv[2] = strdup(zip_archive_filename.String()); - - - // files to zip - for (int ref_index = 0; ref_index < ref_count ; ref_index++) - { - m_thread_data_store->FindRef("refs", ref_index, & ref); - - if (same_folder) - { - argv[3 + ref_index] = strdup(ref.name); // just the file name - } - else - { - BPath path (& ref); - BString file = path.Path(); - argv[3 + ref_index] = strdup(path.Path()); // full path - } - } - - argv[argc] = NULL; - m_zip_process_thread_id = PipeCommand (argc, argv, m_std_in, m_std_out, m_std_err); + int32 argc = ref_count + 3; + const char** argv = new const char* [argc + 1]; + + argv[0] = strdup("/bin/zip"); + argv[1] = strdup("-ry"); + argv[2] = strdup(zip_archive_filename.String()); + + // files to zip + for (int ref_index = 0; ref_index < ref_count ; ref_index++) { + m_thread_data_store->FindRef("refs", ref_index, &ref); + + if (same_folder) { + argv[3 + ref_index] = strdup(ref.name); // just the file name + } else { + BPath path(&ref); + BString file = path.Path(); + argv[3 + ref_index] = strdup(path.Path()); // full path + } + } + + argv[argc] = NULL; + + m_zip_process_thread_id = PipeCommand(argc, argv, m_std_in, m_std_out, m_std_err); delete [] argv; if (m_zip_process_thread_id < 0) - return (m_zip_process_thread_id); - - resume_thread (m_zip_process_thread_id); - - m_zip_output = fdopen (m_std_out, "r"); + return m_zip_process_thread_id; + + resume_thread(m_zip_process_thread_id); + + fOutputFile = fdopen(m_std_out, "r"); zip_archive_filename.Prepend("Creating archive: "); - + SendMessageToWindow ('strt', "archive_filename", zip_archive_filename.String()); SendMessageToWindow ('outp', "zip_output", "Preparing to archive"); @@ -165,48 +156,40 @@ ZipperThread::ThreadStartup (void) return B_OK; } + status_t -ZipperThread::ExecuteUnit (void) +ZipperThread::ExecuteUnit() { //PRINT(("ZipperThread::ExecuteUnit()\n")); // read output from /bin/zip // send it to window - - char * output_string; - output_string = fgets(m_zip_output_buffer , 4096-1, m_zip_output); + char buffer[4096]; - if (output_string == NULL) - { + char* output = fgets(buffer, sizeof(buffer) - 1, fOutputFile); + if (output == NULL) return EOF; - } - else - { - char * new_line_ptr = strrchr(output_string, '\n'); - if (new_line_ptr != NULL) - *new_line_ptr = '\0'; - - if (! strncmp(" a", m_zip_output_buffer, 3)) - { - m_zip_output_buffer[2] = 'A'; - SendMessageToWindow ('outp', "zip_output", output_string + 2); - } - else if (! strncmp("up", m_zip_output_buffer, 2)) - { - m_zip_output_buffer[0] = 'U'; - SendMessageToWindow ('outp', "zip_output", output_string); - } - else - { - SendMessageToWindow ('outp', "zip_output", output_string); - } + + char* newLine = strrchr(output, '\n'); + if (newLine != NULL) + *newLine = '\0'; + + if (!strncmp(" a", output, 3)) { + output[2] = 'A'; + SendMessageToWindow('outp', "zip_output", output + 2); + } else if (!strncmp("up", output, 2)) { + output[0] = 'U'; + SendMessageToWindow('outp', "zip_output", output); + } else { + SendMessageToWindow('outp', "zip_output", output); } return B_OK; } + status_t -ZipperThread::ThreadShutdown (void) +ZipperThread::ThreadShutdown() { PRINT(("ZipperThread::ThreadShutdown()\n")); @@ -217,172 +200,184 @@ ZipperThread::ThreadShutdown (void) return B_OK; } -void -ZipperThread::ThreadStartupFailed (status_t a_status) -{ - error_message("ZipperThread::ThreadStartupFailed() \n", a_status); +void +ZipperThread::ThreadStartupFailed(status_t status) +{ + error_message("ZipperThread::ThreadStartupFailed() \n", status); Quit(); } + void -ZipperThread::ExecuteUnitFailed (status_t a_status) +ZipperThread::ExecuteUnitFailed(status_t status) { - error_message("ZipperThread::ExecuteUnitFailed() \n", a_status); - - - if (a_status == EOF) - { + error_message("ZipperThread::ExecuteUnitFailed() \n", status); + + if (status == EOF) { // thread has finished, been quit or killed, we don't know - SendMessageToWindow ('exit'); - } - else - { + SendMessageToWindow('exit'); + } else { // explicit error - communicate error to Window - SendMessageToWindow ('exrr'); + SendMessageToWindow('exrr'); } - + Quit(); } + void -ZipperThread::ThreadShutdownFailed (status_t a_status) +ZipperThread::ThreadShutdownFailed(status_t status) { - error_message("ZipperThread::ThreadShutdownFailed() \n", a_status); + error_message("ZipperThread::ThreadShutdownFailed() \n", status); } void -ZipperThread::MakeShellSafe (BString * a_string) +ZipperThread::MakeShellSafe(BString* string) { - a_string->CharacterEscape("\"$`", '\\'); - a_string->Prepend("\""); - a_string->Append("\""); + string->CharacterEscape("\"$`", '\\'); + string->Prepend("\""); + string->Append("\""); } + status_t -ZipperThread::ProcessRefs (BMessage * msg) +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) -{ +ZipperThread::PipeCommand(int argc, const char** argv, int& in, int& out, + int& err, const char** envp) +{ // This function written by Peter Folk // and published in the BeDevTalk FAQ // http://www.abisoft.com/faq/BeDevTalk_FAQ.html#FAQ-209 - // Save current FDs - int old_in = dup(0); - int old_out = dup(1); - int old_err = dup(2); - - int filedes[2]; - - /* Create new pipe FDs as stdin, stdout, stderr */ - pipe(filedes); dup2(filedes[0],0); close(filedes[0]); - in=filedes[1]; // Write to in, appears on cmd's stdin - pipe(filedes); dup2(filedes[1],1); close(filedes[1]); - out=filedes[0]; // Read from out, taken from cmd's stdout - pipe(filedes); dup2(filedes[1],2); close(filedes[1]); - err=filedes[0]; // Read from err, taken from cmd's stderr - - // "load" command. - thread_id ret = load_image(argc, argv, envp); - // thread ret is now suspended. + // Save current FDs + int old_in = dup(0); + int old_out = dup(1); + int old_err = dup(2); + + int filedes[2]; + + /* Create new pipe FDs as stdin, stdout, stderr */ + pipe(filedes); + dup2(filedes[0], 0); + close(filedes[0]); + in = filedes[1]; // Write to in, appears on cmd's stdin + pipe(filedes); + dup2(filedes[1], 1); + close(filedes[1]); + out = filedes[0]; // Read from out, taken from cmd's stdout + pipe(filedes); + dup2(filedes[1], 2); + close(filedes[1]); + err = filedes[0]; // Read from err, taken from cmd's stderr + + // "load" command. + thread_id ret = load_image(argc, argv, envp); + // thread ret is now suspended. PRINT(("load_image() thread_id: %ld\n", ret)); - // Restore old FDs - close(0); dup(old_in); close(old_in); - close(1); dup(old_out); close(old_out); - close(2); dup(old_err); close(old_err); - - /* Theoretically I should do loads of error checking, but - the calls aren't very likely to fail, and that would - muddy up the example quite a bit. YMMV. */ + // Restore old FDs + close(0); dup(old_in); close(old_in); + close(1); dup(old_out); close(old_out); + close(2); dup(old_err); close(old_err); + + // TODO: + /* + Theoretically I should do loads of error checking, but + the calls aren't very likely to fail, and that would + muddy up the example quite a bit. YMMV. + */ + + return ret; +} - return ret; -} void -ZipperThread::SendMessageToWindow (uint32 a_msg_what, const char * a_string_name, const char * a_string_value) -{ - BMessage msg (a_msg_what); - - if (! (a_string_name == NULL || a_string_value == NULL)) - msg.AddString(a_string_name, a_string_value); - - m_window_messenger->SendMessage(& msg); +ZipperThread::SendMessageToWindow(uint32 what, const char* name, const char* value) +{ + BMessage msg(what); + if (name != NULL && value != NULL) + msg.AddString(name, value); + + fWindowMessenger.SendMessage(&msg); } + status_t -ZipperThread::SuspendExternalZip (void) -{ +ZipperThread::SuspendExternalZip() +{ PRINT(("ZipperThread::SuspendExternalZip()\n")); - status_t status = B_OK; - thread_info zip_thread_info; - status = get_thread_info (m_zip_process_thread_id, & zip_thread_info); - BString thread_name = zip_thread_info.name; - + status_t status = B_OK; + thread_info zip_thread_info; + status = get_thread_info(m_zip_process_thread_id, &zip_thread_info); + BString thread_name = zip_thread_info.name; + if (status == B_OK && thread_name == "zip") return suspend_thread (m_zip_process_thread_id); - else - return status; + + return status; } + status_t -ZipperThread::ResumeExternalZip (void) -{ +ZipperThread::ResumeExternalZip() +{ PRINT(("ZipperThread::ResumeExternalZip()\n")); - status_t status = B_OK; - thread_info zip_thread_info; - status = get_thread_info (m_zip_process_thread_id, & zip_thread_info); - BString thread_name = zip_thread_info.name; - + status_t status = B_OK; + thread_info zip_thread_info; + status = get_thread_info(m_zip_process_thread_id, &zip_thread_info); + BString thread_name = zip_thread_info.name; + if (status == B_OK && thread_name == "zip") - return resume_thread (m_zip_process_thread_id); - else - return status; + return resume_thread(m_zip_process_thread_id); + + return status; } + status_t -ZipperThread::InterruptExternalZip (void) -{ +ZipperThread::InterruptExternalZip() +{ PRINT(("ZipperThread::InterruptExternalZip()\n")); - status_t status = B_OK; - thread_info zip_thread_info; - status = get_thread_info (m_zip_process_thread_id, & zip_thread_info); - BString thread_name = zip_thread_info.name; - - if (status == B_OK && thread_name == "zip") - { - status = B_OK; - status = send_signal (m_zip_process_thread_id, SIGINT); + status_t status = B_OK; + thread_info zip_thread_info; + status = get_thread_info(m_zip_process_thread_id, &zip_thread_info); + BString thread_name = zip_thread_info.name; + + if (status == B_OK && thread_name == "zip") { + status = B_OK; + status = send_signal(m_zip_process_thread_id, SIGINT); WaitOnExternalZip(); return status; } - else - return status; + + return status; } + status_t -ZipperThread::WaitOnExternalZip (void) -{ +ZipperThread::WaitOnExternalZip() +{ PRINT(("ZipperThread::WaitOnExternalZip()\n")); - - status_t status = B_OK; - thread_info zip_thread_info; - status = get_thread_info (m_zip_process_thread_id, & zip_thread_info); - BString thread_name = zip_thread_info.name; - + + status_t status = B_OK; + thread_info zip_thread_info; + status = get_thread_info(m_zip_process_thread_id, &zip_thread_info); + BString thread_name = zip_thread_info.name; + if (status == B_OK && thread_name == "zip") - return wait_for_thread (m_zip_process_thread_id, & status); - else - return status; + return wait_for_thread(m_zip_process_thread_id, &status); + + return status; } diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticZipper.h b/src/add-ons/tracker/zipomatic/ZipOMaticZipper.h index 181e95f6f1..2fefb9f588 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticZipper.h +++ b/src/add-ons/tracker/zipomatic/ZipOMaticZipper.h @@ -1,61 +1,60 @@ -#ifndef __ZIPOMATIC_ZIPPER_H__ -#define __ZIPOMATIC_ZIPPER_H__ +/* + * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jonas Sundström, jonas.sundstrom@kirilla.com + */ +#ifndef ZIPPER_THREAD_H +#define ZIPPER_THREAD_H -#include -#include -#include -#include -#include -#include #include "GenericThread.h" -#include -extern const char * ZipperThreadName; +#include -class ZipperThread : public GenericThread -{ -public: - ZipperThread (BMessage * a_refs_message, BWindow * a_window); - ~ZipperThread (); +#include - status_t SuspendExternalZip (void); - status_t ResumeExternalZip (void); - status_t InterruptExternalZip (void); - status_t WaitOnExternalZip (void); +class BMessage; +class BWindow; -private: - 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); +class ZipperThread : public GenericThread { + public: + ZipperThread(BMessage* refsMessage, BWindow* window); + ~ZipperThread(); - status_t ProcessRefs (BMessage * msg); - void MakeShellSafe (BString * a_string); - - thread_id PipeCommand (int argc, const char **argv, - int & in, int & out, int & err, - const char **envp = (const char **) environ); - - void SendMessageToWindow (uint32 a_msg_what, - const char * a_string_name = NULL, - const char * a_string_value = NULL); - - BWindow * m_window; - BMessenger * m_window_messenger; + status_t SuspendExternalZip(); + status_t ResumeExternalZip(); + status_t InterruptExternalZip(); + status_t WaitOnExternalZip(); - int32 m_zip_process_thread_id; - int m_std_in; - int m_std_out; - int m_std_err; - FILE * m_zip_output; - BString m_zip_output_string; - char * m_zip_output_buffer; + private: + 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); + + status_t ProcessRefs(BMessage* msg); + void MakeShellSafe(BString* string); + + 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); + + BMessenger fWindowMessenger; + int32 m_zip_process_thread_id; + int m_std_in; + int m_std_out; + int m_std_err; + FILE* fOutputFile; }; -#endif // __ZIPOMATIC_ZIPPER_H__ +#endif // ZIPPER_THREAD_H