fixing indenting style issues

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20314 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-03-03 15:26:57 +00:00
parent 5cb9bf4bbb
commit 96303159b3
16 changed files with 548 additions and 548 deletions
+3 -3
View File
@@ -34,10 +34,10 @@
#include "ExpanderWindow.h" #include "ExpanderWindow.h"
class ExpanderApp : public BApplication { class ExpanderApp : public BApplication {
public: public:
ExpanderApp(); ExpanderApp();
public: public:
virtual void AboutRequested(); virtual void AboutRequested();
virtual void ArgvReceived(int32 argc, char **argv); virtual void ArgvReceived(int32 argc, char **argv);
virtual void ReadyToRun(); virtual void ReadyToRun();
@@ -45,7 +45,7 @@ public:
ExpanderSettings fSettings; ExpanderSettings fSettings;
void UpdateSettingsFrom(BMessage *message); void UpdateSettingsFrom(BMessage *message);
private: private:
ExpanderWindow *fWindow; ExpanderWindow *fWindow;
}; };
+18 -18
View File
@@ -29,7 +29,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
AddChild(background); AddChild(background);
rect.OffsetBy(11,9); rect.OffsetBy(11, 9);
rect.bottom -= 64; rect.bottom -= 64;
rect.right -= 22; rect.right -= 22;
BBox *box = new BBox(rect, "background", B_FOLLOW_NONE, BBox *box = new BBox(rect, "background", B_FOLLOW_NONE,
@@ -37,15 +37,15 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
box->SetLabel("Expander Preferences"); box->SetLabel("Expander Preferences");
background->AddChild(box); background->AddChild(box);
float maxWidth=box->Bounds().right; float maxWidth = box->Bounds().right;
BRect frameRect = box->Bounds(); BRect frameRect = box->Bounds();
frameRect.OffsetBy(15,23); frameRect.OffsetBy(15, 23);
frameRect.right = frameRect.left + 200; frameRect.right = frameRect.left + 200;
frameRect.bottom = frameRect.top + 20; frameRect.bottom = frameRect.top + 20;
BRect textRect(frameRect); BRect textRect(frameRect);
textRect.OffsetTo(B_ORIGIN); textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(1,1); textRect.InsetBy(1, 1);
BStringView *stringView = new BStringView(frameRect, "expansion", "Expansion:", BStringView *stringView = new BStringView(frameRect, "expansion", "Expansion:",
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred(); stringView->ResizeToPreferred();
@@ -100,7 +100,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
frameRect = fSameDest->Frame(); frameRect = fSameDest->Frame();
frameRect.top = frameRect.bottom + 1; frameRect.top = frameRect.bottom + 1;
fDestUse = new BRadioButton(frameRect, "destUse", "Use:",new BMessage(MSG_DESTUSE)); fDestUse = new BRadioButton(frameRect, "destUse", "Use:", new BMessage(MSG_DESTUSE));
fDestUse->ResizeToPreferred(); fDestUse->ResizeToPreferred();
if (fDestUse->Frame().right > maxWidth) if (fDestUse->Frame().right > maxWidth)
maxWidth = fDestUse->Frame().right; maxWidth = fDestUse->Frame().right;
@@ -116,7 +116,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
fDestText->ResizeToPreferred(); fDestText->ResizeToPreferred();
fDestText->SetDivider(0); fDestText->SetDivider(0);
fDestText->TextView()->MakeEditable(false); fDestText->TextView()->MakeEditable(false);
fDestText->ResizeTo(158,fDestText->Frame().Height()); fDestText->ResizeTo(158, fDestText->Frame().Height());
fDestText->SetEnabled(false); fDestText->SetEnabled(false);
@@ -129,13 +129,13 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
box->AddChild(fSelect); box->AddChild(fSelect);
fSelect->SetEnabled(false); fSelect->SetEnabled(false);
fDestText->MoveBy(0,(fSelect->Frame().Height() - fDestText->Frame().Height())/2.0); fDestText->MoveBy(0, (fSelect->Frame().Height() - fDestText->Frame().Height()) / 2.0);
fDestText->ResizeTo(158,fDestText->Frame().Height()); fDestText->ResizeTo(158, fDestText->Frame().Height());
frameRect = stringView->Frame(); frameRect = stringView->Frame();
frameRect.top = fDestUse->Frame().bottom + 10; frameRect.top = fDestUse->Frame().bottom + 10;
stringView = new BStringView(frameRect, "other", "Other:",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); stringView = new BStringView(frameRect, "other", "Other:", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred(); stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth) if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right; maxWidth = stringView->Frame().right;
@@ -158,28 +158,28 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
maxWidth = fAutoShow->Frame().right; maxWidth = fAutoShow->Frame().right;
box->AddChild(fAutoShow); box->AddChild(fAutoShow);
box->ResizeTo(maxWidth + 15,fAutoShow->Frame().bottom + 10); box->ResizeTo(maxWidth + 15, fAutoShow->Frame().bottom + 10);
rect = BRect(Bounds().right-89, Bounds().bottom-40, Bounds().right-14, Bounds().bottom-16); rect = BRect(Bounds().right - 89, Bounds().bottom - 40, Bounds().right - 14, Bounds().bottom - 16);
rect = Bounds(); rect = Bounds();
BButton *button = new BButton(rect, "OKButton", "OK",new BMessage(MSG_OK)); BButton *button = new BButton(rect, "OKButton", "OK", new BMessage(MSG_OK));
button->MakeDefault(true); button->MakeDefault(true);
button->ResizeToPreferred(); button->ResizeToPreferred();
button->MoveTo(box->Frame().right - button->Frame().Width(),box->Frame().bottom + 10 ); button->MoveTo(box->Frame().right - button->Frame().Width(), box->Frame().bottom + 10);
background->AddChild(button); background->AddChild(button);
rect = button->Frame(); rect = button->Frame();
BButton *cancel = new BButton(rect, "CancelButton", "Cancel", new BMessage(MSG_CANCEL)); BButton *cancel = new BButton(rect, "CancelButton", "Cancel", new BMessage(MSG_CANCEL));
cancel->ResizeToPreferred(); cancel->ResizeToPreferred();
cancel->MoveBy(-cancel->Frame().Width() - 10, (button->Frame().Height() - cancel->Frame().Height()) /2.0); cancel->MoveBy(-cancel->Frame().Width() - 10, (button->Frame().Height() - cancel->Frame().Height()) / 2.0);
background->AddChild(cancel); background->AddChild(cancel);
ResizeTo(box->Frame().right + 11 ,button->Frame().bottom + 11); ResizeTo(box->Frame().right + 11 , button->Frame().bottom + 11);
BScreen screen(this); BScreen screen(this);
MoveBy((screen.Frame().Width()-Bounds().Width())/2, MoveBy((screen.Frame().Width() - Bounds().Width()) / 2,
(screen.Frame().Height()-Bounds().Height())/2); (screen.Frame().Height() - Bounds().Height()) / 2);
bool automatically_expand_files; bool automatically_expand_files;
bool close_when_done; bool close_when_done;
@@ -279,7 +279,7 @@ ExpanderPreferences::MessageReceived(BMessage *msg)
fSettings->ReplaceBool("automatically_expand_files", fAutoExpand->Value() == B_CONTROL_ON); fSettings->ReplaceBool("automatically_expand_files", fAutoExpand->Value() == B_CONTROL_ON);
fSettings->ReplaceBool("close_when_done", fCloseWindow->Value() == B_CONTROL_ON); fSettings->ReplaceBool("close_when_done", fCloseWindow->Value() == B_CONTROL_ON);
fSettings->ReplaceInt8("destination_folder", (fSameDest->Value() == B_CONTROL_ON) ? 0x63 fSettings->ReplaceInt8("destination_folder", (fSameDest->Value() == B_CONTROL_ON) ? 0x63
: ( (fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65) ); : ((fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65));
fSettings->ReplaceRef("destination_folder_use", &fRef); fSettings->ReplaceRef("destination_folder_use", &fRef);
fSettings->ReplaceBool("open_destination_folder", fOpenDest->Value() == B_CONTROL_ON); fSettings->ReplaceBool("open_destination_folder", fOpenDest->Value() == B_CONTROL_ON);
fSettings->ReplaceBool("show_contents_listing", fAutoShow->Value() == B_CONTROL_ON); fSettings->ReplaceBool("show_contents_listing", fAutoShow->Value() == B_CONTROL_ON);
+2 -2
View File
@@ -39,12 +39,12 @@
#include <RadioButton.h> #include <RadioButton.h>
class ExpanderPreferences : public BWindow { class ExpanderPreferences : public BWindow {
public: public:
ExpanderPreferences(BMessage *settings); ExpanderPreferences(BMessage *settings);
virtual ~ExpanderPreferences(); virtual ~ExpanderPreferences();
virtual void MessageReceived(BMessage *msg); virtual void MessageReceived(BMessage *msg);
private: private:
BMessage *fSettings; BMessage *fSettings;
BCheckBox *fAutoExpand, *fCloseWindow, *fAutoShow, *fOpenDest; BCheckBox *fAutoExpand, *fCloseWindow, *fAutoShow, *fOpenDest;
BRadioButton *fDestUse, *fSameDest, *fLeaveDest; BRadioButton *fDestUse, *fSameDest, *fLeaveDest;
+4 -4
View File
@@ -58,20 +58,20 @@ ExpanderRules::ExpanderRules()
char buffer[1024]; char buffer[1024];
BString strings[4]; BString strings[4];
while (fgets(buffer, 1024-1, f)!=NULL) { while (fgets(buffer, 1024 - 1, f) != NULL) {
int32 i = 0, j = 0; int32 i = 0, j = 0;
int32 firstQuote = -1; int32 firstQuote = -1;
while (buffer[i] != '#' && buffer[i] != '\n' && j < 4) { while (buffer[i] != '#' && buffer[i] != '\n' && j < 4) {
if ((j == 0 || j > 1) && buffer[i] == '"') { if ((j == 0 || j > 1) && buffer[i] == '"') {
if (firstQuote >= 0) { if (firstQuote >= 0) {
strings[j++].SetTo(&buffer[firstQuote+1], i-firstQuote-1); strings[j++].SetTo(&buffer[firstQuote+1], i - firstQuote - 1);
firstQuote = -1; firstQuote = -1;
} else } else
firstQuote = i; firstQuote = i;
} else if (j == 1 && (buffer[i] == ' ' || buffer[i] == '\t')) { } else if (j == 1 && (buffer[i] == ' ' || buffer[i] == '\t')) {
if (firstQuote >= 0) { if (firstQuote >= 0) {
if (firstQuote + 1 != i) { if (firstQuote + 1 != i) {
strings[j++].SetTo(&buffer[firstQuote+1], i-firstQuote-1); strings[j++].SetTo(&buffer[firstQuote+1], i - firstQuote - 1);
firstQuote = -1; firstQuote = -1;
} else } else
firstQuote = i; firstQuote = i;
@@ -122,7 +122,7 @@ ExpanderRules::MatchingRule(BString &fileName, const char *filetype)
{ {
int32 count = fList.CountItems(); int32 count = fList.CountItems();
int32 length = fileName.Length(); int32 length = fileName.Length();
for (int32 i=0; i<count; i++) { for (int32 i = 0; i < count; i++) {
ExpanderRule *rule = (ExpanderRule *)fList.ItemAt(i); ExpanderRule *rule = (ExpanderRule *)fList.ItemAt(i);
if ((rule->MimeType().IsValid() && rule->MimeType() == filetype) if ((rule->MimeType().IsValid() && rule->MimeType() == filetype)
|| (fileName.FindLast(rule->FilenameExtension()) == (length - rule->FilenameExtension().Length()))) || (fileName.FindLast(rule->FilenameExtension()) == (length - rule->FilenameExtension().Length())))
+5 -5
View File
@@ -91,7 +91,7 @@ ExpanderSettings::ExpanderSettings()
&& (file.Read(&ref.device, sizeof(ref.device)) == sizeof(ref.device)) && (file.Read(&ref.device, sizeof(ref.device)) == sizeof(ref.device))
&& (file.Read(&ref.directory, sizeof(ref.directory)) == sizeof(ref.directory)) && (file.Read(&ref.directory, sizeof(ref.directory)) == sizeof(ref.directory))
&& (file.Read(&name_size, sizeof(name_size)) == sizeof(name_size)) && (file.Read(&name_size, sizeof(name_size)) == sizeof(name_size))
&& ((name_size <= 0) || (ref.name = (char*)malloc(name_size+1))) && ((name_size <= 0) || (ref.name = (char*)malloc(name_size + 1)))
&& (file.Read(ref.name, name_size) == name_size) && (file.Read(ref.name, name_size) == name_size)
&& (file.Read(&open_destination_folder, sizeof(open_destination_folder)) == sizeof(open_destination_folder)) && (file.Read(&open_destination_folder, sizeof(open_destination_folder)) == sizeof(open_destination_folder))
&& (file.Read(&show_contents_listing, sizeof(show_contents_listing)) == sizeof(show_contents_listing)) && (file.Read(&show_contents_listing, sizeof(show_contents_listing)) == sizeof(show_contents_listing))
@@ -105,12 +105,12 @@ ExpanderSettings::ExpanderSettings()
fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files); fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files);
fMessage.ReplaceBool("close_when_done", close_when_done); fMessage.ReplaceBool("close_when_done", close_when_done);
if(destination_folder == 0x66 || destination_folder == 0x63 || destination_folder == 0x65) if (destination_folder == 0x66 || destination_folder == 0x63 || destination_folder == 0x65)
fMessage.ReplaceInt8("destination_folder", destination_folder); fMessage.ReplaceInt8("destination_folder", destination_folder);
if (name_size > 0) if (name_size > 0)
ref.name[name_size] = '\0'; ref.name[name_size] = '\0';
BEntry entry(&ref); BEntry entry(&ref);
if(entry.Exists()) if (entry.Exists())
fMessage.ReplaceRef("destination_folder_use", &ref); fMessage.ReplaceRef("destination_folder_use", &ref);
fMessage.ReplaceBool("open_destination_folder", open_destination_folder); fMessage.ReplaceBool("open_destination_folder", open_destination_folder);
fMessage.ReplaceBool("show_contents_listing", show_contents_listing); fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
@@ -143,7 +143,7 @@ ExpanderSettings::~ExpanderSettings()
&& (fMessage.FindInt8("destination_folder", &destination_folder) == B_OK) && (fMessage.FindInt8("destination_folder", &destination_folder) == B_OK)
&& (fMessage.FindRef("destination_folder_use", &ref) == B_OK) && (fMessage.FindRef("destination_folder_use", &ref) == B_OK)
&& (fMessage.FindBool("open_destination_folder", &open_destination_folder) == B_OK) && (fMessage.FindBool("open_destination_folder", &open_destination_folder) == B_OK)
&& (fMessage.FindBool("show_contents_listing", &show_contents_listing) == B_OK) ) { && (fMessage.FindBool("show_contents_listing", &show_contents_listing) == B_OK)) {
file.Write(&unknown, sizeof(unknown)); file.Write(&unknown, sizeof(unknown));
file.Write(&automatically_expand_files, sizeof(automatically_expand_files)); file.Write(&automatically_expand_files, sizeof(automatically_expand_files));
@@ -154,7 +154,7 @@ ExpanderSettings::~ExpanderSettings()
file.Write(&ref.device, sizeof(ref.device)); file.Write(&ref.device, sizeof(ref.device));
file.Write(&ref.directory, sizeof(ref.directory)); file.Write(&ref.directory, sizeof(ref.directory));
int32 name_size = 0; int32 name_size = 0;
if(ref.name) if (ref.name)
name_size = strlen(ref.name); name_size = strlen(ref.name);
file.Write(&name_size, sizeof(name_size)); file.Write(&name_size, sizeof(name_size));
file.Write(ref.name, name_size); file.Write(ref.name, name_size);
+18 -18
View File
@@ -13,8 +13,8 @@
const char * ExpanderThreadName = "ExpanderThread"; const char * ExpanderThreadName = "ExpanderThread";
ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger) ExpanderThread::ExpanderThread(BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message), : GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
fWindowMessenger(messenger), fWindowMessenger(messenger),
fThreadId(-1), fThreadId(-1),
fStdIn(-1), fStdIn(-1),
@@ -24,7 +24,7 @@ ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
fExpanderOutputString(), fExpanderOutputString(),
fExpanderOutputBuffer(new char [4096]) fExpanderOutputBuffer(new char [4096])
{ {
SetDataStore(new BMessage (* refs_message)); // leak? SetDataStore(new BMessage(* refs_message)); // leak?
// prevents bug with B_SIMPLE_DATA // prevents bug with B_SIMPLE_DATA
// (drag&drop messages) // (drag&drop messages)
} }
@@ -42,13 +42,13 @@ ExpanderThread::ThreadStartup()
entry_ref srcRef, destRef; entry_ref srcRef, destRef;
BString cmd; BString cmd;
if ((status = GetDataStore()->FindRef("srcRef", &srcRef))!=B_OK) if ((status = GetDataStore()->FindRef("srcRef", &srcRef)) != B_OK)
return status; return status;
if ((status = GetDataStore()->FindRef("destRef", &destRef))==B_OK) { if ((status = GetDataStore()->FindRef("destRef", &destRef)) == B_OK) {
BPath path(&destRef); BPath path(&destRef);
chdir(path.Path()); chdir(path.Path());
} }
if ((status = GetDataStore()->FindString("cmd", &cmd))!=B_OK) if ((status = GetDataStore()->FindString("cmd", &cmd)) != B_OK)
return status; return status;
BPath path(&srcRef); BPath path(&srcRef);
@@ -81,21 +81,21 @@ ExpanderThread::ThreadStartup()
} }
status_t status_t
ExpanderThread::ExecuteUnit (void) ExpanderThread::ExecuteUnit(void)
{ {
// read output from command // read output from command
// send it to window // send it to window
char *output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput); char *output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (output_string == NULL) if (output_string == NULL)
return EOF; return EOF;
BMessage message('outp'); BMessage message('outp');
message.AddString("output", output_string); message.AddString("output", output_string);
for (int32 i=0; i<5; i++) { for (int32 i = 0; i < 5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput); output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if(!output_string) if (!output_string)
break; break;
message.AddString("output", output_string); message.AddString("output", output_string);
} }
@@ -164,12 +164,12 @@ ExpanderThread::PipeCommand(int argc, const char **argv, int &in, int &out, int
int filedes[2]; int filedes[2];
/* Create new pipe FDs as stdin, stdout, stderr */ /* Create new pipe FDs as stdin, stdout, stderr */
pipe(filedes); dup2(filedes[0],0); close(filedes[0]); pipe(filedes); dup2(filedes[0], 0); close(filedes[0]);
in=filedes[1]; // Write to in, appears on cmd's stdin in = filedes[1]; // Write to in, appears on cmd's stdin
pipe(filedes); dup2(filedes[1],1); close(filedes[1]); pipe(filedes); dup2(filedes[1], 1); close(filedes[1]);
out=filedes[0]; // Read from out, taken from cmd's stdout out = filedes[0]; // Read from out, taken from cmd's stdout
pipe(filedes); dup2(filedes[1],2); close(filedes[1]); pipe(filedes); dup2(filedes[1], 2); close(filedes[1]);
err=filedes[0]; // Read from err, taken from cmd's stderr err = filedes[0]; // Read from err, taken from cmd's stderr
// "load" command. // "load" command.
thread_id ret = load_image(argc, argv, envp); thread_id ret = load_image(argc, argv, envp);
@@ -222,7 +222,7 @@ status_t
ExpanderThread::InterruptExternalExpander() ExpanderThread::InterruptExternalExpander()
{ {
thread_info thread_info; thread_info thread_info;
status_t status = get_thread_info (fThreadId, &thread_info); status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK) { if (status == B_OK) {
status = send_signal(-fThreadId, SIGINT); status = send_signal(-fThreadId, SIGINT);
+2 -2
View File
@@ -42,7 +42,7 @@ extern const char * ExpanderThreadName;
class ExpanderThread : public GenericThread class ExpanderThread : public GenericThread
{ {
public: public:
ExpanderThread(BMessage *refs_message, BMessenger *messenger); ExpanderThread(BMessage *refs_message, BMessenger *messenger);
~ExpanderThread(); ~ExpanderThread();
@@ -51,7 +51,7 @@ public:
status_t InterruptExternalExpander(); status_t InterruptExternalExpander();
status_t WaitOnExternalExpander(); status_t WaitOnExternalExpander();
private: private:
virtual status_t ThreadStartup(); virtual status_t ThreadStartup();
virtual status_t ExecuteUnit(); virtual status_t ExecuteUnit();
+7 -7
View File
@@ -234,7 +234,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n" BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n"
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL, "archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go()==0) { if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander(); fExpandingThread->ResumeExternalExpander();
StopExpanding(); StopExpanding();
} else } else
@@ -319,8 +319,8 @@ ExpanderWindow::MessageReceived(BMessage *msg)
case 'outp': case 'outp':
if (!fExpandingStarted && fListingStarted) { if (!fExpandingStarted && fListingStarted) {
BString string; BString string;
int32 i=0; int32 i = 0;
while (msg->FindString("output", i++, &string)==B_OK) while (msg->FindString("output", i++, &string) == B_OK)
fListingText->Insert(string.String()); fListingText->Insert(string.String());
fListingText->ScrollToSelection(); fListingText->ScrollToSelection();
} }
@@ -364,7 +364,7 @@ ExpanderWindow::CanQuit()
BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n" BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n"
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL, "archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go()==0) { if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander(); fExpandingThread->ResumeExternalExpander();
StopExpanding(); StopExpanding();
} else { } else {
@@ -409,12 +409,12 @@ ExpanderWindow::RefsReceived(BMessage *msg)
fSourceChanged = true; fSourceChanged = true;
fSourceRef = ref; fSourceRef = ref;
fSourceText->SetText(path.Path()); fSourceText->SetText(path.Path());
if (destination_folder==0x63) { if (destination_folder == 0x63) {
BPath parent; BPath parent;
path.GetParent(&parent); path.GetParent(&parent);
fDestText->SetText(parent.Path()); fDestText->SetText(parent.Path());
get_ref_for_path(parent.Path(), &fDestRef); get_ref_for_path(parent.Path(), &fDestRef);
} else if (destination_folder==0x65) { } else if (destination_folder == 0x65) {
fSettings.FindRef("destination_folder_use", &fDestRef); fSettings.FindRef("destination_folder_use", &fDestRef);
BEntry dEntry(&fDestRef, true); BEntry dEntry(&fDestRef, true);
BPath dPath(&dEntry); BPath dPath(&dEntry);
@@ -440,7 +440,7 @@ ExpanderWindow::RefsReceived(BMessage *msg)
AutoExpand(); AutoExpand();
} else } else
AutoListing(); AutoListing();
} else if(node.IsDirectory()) { } else if (node.IsDirectory()) {
fDestRef = ref; fDestRef = ref;
fDestText->SetText(path.Path()); fDestText->SetText(path.Path());
} }
+62 -62
View File
@@ -5,11 +5,11 @@
GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMessage * a_message) GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMessage * a_message)
: :
m_thread_data_store (a_message), m_thread_data_store(a_message),
m_thread_id (spawn_thread (private_thread_function, a_thread_name, a_priority, this)), m_thread_id(spawn_thread(private_thread_function, a_thread_name, a_priority, this)),
m_execute_unit (create_sem(1, "m_execute_unit")), m_execute_unit(create_sem(1, "m_execute_unit")),
m_quit_requested (false), m_quit_requested(false),
m_thread_is_paused (false) m_thread_is_paused(false)
{ {
if (m_thread_data_store == NULL) if (m_thread_data_store == NULL)
m_thread_data_store = new BMessage(); m_thread_data_store = new BMessage();
@@ -23,26 +23,26 @@ GenericThread::~GenericThread()
} }
status_t status_t
GenericThread::ThreadFunction (void) GenericThread::ThreadFunction(void)
{ {
status_t status = B_OK; status_t status = B_OK;
status = ThreadStartup(); // Subclass and override this function status = ThreadStartup(); // Subclass and override this function
if (status != B_OK) if (status != B_OK)
{ {
ThreadStartupFailed (status); ThreadStartupFailed(status);
return (status); return (status);
// is this the right thing to do? // is this the right thing to do?
} }
while(1) while (1)
{ {
if (HasQuitBeenRequested()) if (HasQuitBeenRequested())
{ {
status = ThreadShutdown(); // Subclass and override this function status = ThreadShutdown(); // Subclass and override this function
if (status != B_OK) if (status != B_OK)
{ {
ThreadShutdownFailed (status); ThreadShutdownFailed(status);
return (status); return (status);
// what do we do? // what do we do?
} }
@@ -55,7 +55,7 @@ GenericThread::ThreadFunction (void)
status = ExecuteUnit(); // Subclass and override status = ExecuteUnit(); // Subclass and override
if (status != B_OK) if (status != B_OK)
ExecuteUnitFailed (status); // Subclass and override ExecuteUnitFailed(status); // Subclass and override
EndUnit(); EndUnit();
} }
@@ -64,7 +64,7 @@ GenericThread::ThreadFunction (void)
} }
status_t status_t
GenericThread::ThreadStartup (void) GenericThread::ThreadStartup(void)
{ {
// This function is virtual. // This function is virtual.
// Subclass and override this function. // Subclass and override this function.
@@ -74,7 +74,7 @@ GenericThread::ThreadStartup (void)
status_t status_t
GenericThread::ExecuteUnit (void) GenericThread::ExecuteUnit(void)
{ {
// This function is virtual. // This function is virtual.
@@ -86,7 +86,7 @@ GenericThread::ExecuteUnit (void)
} }
status_t status_t
GenericThread::ThreadShutdown (void) GenericThread::ThreadShutdown(void)
{ {
// This function is virtual. // This function is virtual.
// Subclass and override this function. // Subclass and override this function.
@@ -95,7 +95,7 @@ GenericThread::ThreadShutdown (void)
} }
void void
GenericThread::ThreadStartupFailed (status_t a_status) GenericThread::ThreadStartupFailed(status_t a_status)
{ {
// This function is virtual. // This function is virtual.
// Subclass and override this function. // Subclass and override this function.
@@ -104,7 +104,7 @@ GenericThread::ThreadStartupFailed (status_t a_status)
} }
void void
GenericThread::ExecuteUnitFailed (status_t a_status) GenericThread::ExecuteUnitFailed(status_t a_status)
{ {
// This function is virtual. // This function is virtual.
// Subclass and override this function. // Subclass and override this function.
@@ -113,7 +113,7 @@ GenericThread::ExecuteUnitFailed (status_t a_status)
} }
void void
GenericThread::ThreadShutdownFailed (status_t a_status) GenericThread::ThreadShutdownFailed(status_t a_status)
{ {
// This function is virtual. // This function is virtual.
// Subclass and override this function. // Subclass and override this function.
@@ -122,26 +122,26 @@ GenericThread::ThreadShutdownFailed (status_t a_status)
} }
status_t status_t
GenericThread::Start (void) GenericThread::Start(void)
{ {
status_t status = B_OK; status_t status = B_OK;
if (IsPaused()) if (IsPaused())
{ {
status = release_sem (m_execute_unit); status = release_sem(m_execute_unit);
if (status != B_OK) if (status != B_OK)
return status; return status;
m_thread_is_paused = false; m_thread_is_paused = false;
} }
status = resume_thread (m_thread_id); status = resume_thread(m_thread_id);
return status; return status;
} }
int32 int32
GenericThread::private_thread_function (void * a_simple_thread_ptr) GenericThread::private_thread_function(void * a_simple_thread_ptr)
{ {
status_t status = B_OK; status_t status = B_OK;
@@ -151,19 +151,19 @@ GenericThread::private_thread_function (void * a_simple_thread_ptr)
} }
BMessage * BMessage *
GenericThread::GetDataStore (void) GenericThread::GetDataStore(void)
{ {
return (m_thread_data_store); return (m_thread_data_store);
} }
void void
GenericThread::SetDataStore (BMessage * a_message) GenericThread::SetDataStore(BMessage * a_message)
{ {
m_thread_data_store = a_message; m_thread_data_store = a_message;
} }
status_t status_t
GenericThread::Pause (bool a_do_block, bigtime_t a_timeout) GenericThread::Pause(bool a_do_block, bigtime_t a_timeout)
{ {
status_t status = B_OK; status_t status = B_OK;
@@ -184,31 +184,31 @@ GenericThread::Pause (bool a_do_block, bigtime_t a_timeout)
} }
void void
GenericThread::Quit (void) GenericThread::Quit(void)
{ {
m_quit_requested = true; m_quit_requested = true;
} }
bool bool
GenericThread::HasQuitBeenRequested (void) GenericThread::HasQuitBeenRequested(void)
{ {
return (m_quit_requested); return (m_quit_requested);
} }
bool bool
GenericThread::IsPaused (void) GenericThread::IsPaused(void)
{ {
return (m_thread_is_paused); return (m_thread_is_paused);
} }
status_t status_t
GenericThread::Suspend (void) GenericThread::Suspend(void)
{ {
return (suspend_thread(m_thread_id)); return (suspend_thread(m_thread_id));
} }
status_t status_t
GenericThread::Resume (void) GenericThread::Resume(void)
{ {
release_sem(m_execute_unit); // to counteract Pause() release_sem(m_execute_unit); // to counteract Pause()
m_thread_is_paused = false; m_thread_is_paused = false;
@@ -217,61 +217,61 @@ GenericThread::Resume (void)
} }
status_t status_t
GenericThread::Kill (void) GenericThread::Kill(void)
{ {
return (kill_thread(m_thread_id)); return (kill_thread(m_thread_id));
} }
void void
GenericThread::ExitWithReturnValue (status_t a_return_value) GenericThread::ExitWithReturnValue(status_t a_return_value)
{ {
exit_thread(a_return_value); exit_thread(a_return_value);
} }
status_t status_t
GenericThread::SetExitCallback (void (*a_callback)(void*), void * a_data) GenericThread::SetExitCallback(void(*a_callback)(void*), void * a_data)
{ {
return (on_exit_thread(a_callback, a_data)); return (on_exit_thread(a_callback, a_data));
} }
status_t status_t
GenericThread::WaitForThread (status_t * a_exit_value) GenericThread::WaitForThread(status_t * a_exit_value)
{ {
return (wait_for_thread(m_thread_id, a_exit_value)); return (wait_for_thread(m_thread_id, a_exit_value));
} }
status_t status_t
GenericThread::Rename (char * a_name) GenericThread::Rename(char * a_name)
{ {
return (rename_thread(m_thread_id, a_name)); return (rename_thread(m_thread_id, a_name));
} }
status_t status_t
GenericThread::SendData (int32 a_code, void * a_buffer, size_t a_buffer_size) GenericThread::SendData(int32 a_code, void * a_buffer, size_t a_buffer_size)
{ {
return (send_data(m_thread_id, a_code, a_buffer, a_buffer_size)); return (send_data(m_thread_id, a_code, a_buffer, a_buffer_size));
} }
int32 int32
GenericThread::ReceiveData (thread_id * a_sender, void * a_buffer, size_t a_buffer_size) GenericThread::ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size)
{ {
return (receive_data(a_sender, a_buffer, a_buffer_size)); return (receive_data(a_sender, a_buffer, a_buffer_size));
} }
bool bool
GenericThread::HasData (void) GenericThread::HasData(void)
{ {
return (has_data(m_thread_id)); return (has_data(m_thread_id));
} }
status_t status_t
GenericThread::SetPriority (int32 a_new_priority) GenericThread::SetPriority(int32 a_new_priority)
{ {
return (set_thread_priority(m_thread_id, a_new_priority)); return (set_thread_priority(m_thread_id, a_new_priority));
} }
void void
GenericThread::Snooze (bigtime_t a_microseconds) GenericThread::Snooze(bigtime_t a_microseconds)
{ {
Suspend(); Suspend();
snooze(a_microseconds); snooze(a_microseconds);
@@ -279,7 +279,7 @@ GenericThread::Snooze (bigtime_t a_microseconds)
} }
void void
GenericThread::SnoozeUntil (bigtime_t a_microseconds, int a_timebase) GenericThread::SnoozeUntil(bigtime_t a_microseconds, int a_timebase)
{ {
Suspend(); Suspend();
snooze_until(a_microseconds, a_timebase); snooze_until(a_microseconds, a_timebase);
@@ -287,99 +287,99 @@ GenericThread::SnoozeUntil (bigtime_t a_microseconds, int a_timebase)
} }
status_t status_t
GenericThread::GetInfo (thread_info * a_thread_info) GenericThread::GetInfo(thread_info * a_thread_info)
{ {
return (get_thread_info(m_thread_id, a_thread_info)); return (get_thread_info(m_thread_id, a_thread_info));
} }
thread_id thread_id
GenericThread::GetThread (void) GenericThread::GetThread(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.thread); return (t_thread_info.thread);
} }
team_id team_id
GenericThread::GetTeam (void) GenericThread::GetTeam(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.team); return (t_thread_info.team);
} }
char * char *
GenericThread::GetName (void) GenericThread::GetName(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.name); return (t_thread_info.name);
} }
thread_state thread_state
GenericThread::GetState (void) GenericThread::GetState(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.state); return (t_thread_info.state);
} }
sem_id sem_id
GenericThread::GetSemaphore (void) GenericThread::GetSemaphore(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.sem); return (t_thread_info.sem);
} }
int32 int32
GenericThread::GetPriority (void) GenericThread::GetPriority(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.priority); return (t_thread_info.priority);
} }
bigtime_t bigtime_t
GenericThread::GetUserTime (void) GenericThread::GetUserTime(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.user_time); return (t_thread_info.user_time);
} }
bigtime_t bigtime_t
GenericThread::GetKernelTime (void) GenericThread::GetKernelTime(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.kernel_time); return (t_thread_info.kernel_time);
} }
void * void *
GenericThread::GetStackBase (void) GenericThread::GetStackBase(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.stack_base); return (t_thread_info.stack_base);
} }
void * void *
GenericThread::GetStackEnd (void) GenericThread::GetStackEnd(void)
{ {
thread_info t_thread_info; thread_info t_thread_info;
GetInfo (& t_thread_info); GetInfo(& t_thread_info);
return (t_thread_info.stack_end); return (t_thread_info.stack_end);
} }
void void
GenericThread::BeginUnit (void) GenericThread::BeginUnit(void)
{ {
acquire_sem(m_execute_unit); // thread can not be paused until it releases semaphore acquire_sem(m_execute_unit); // thread can not be paused until it releases semaphore
} }
void void
GenericThread::EndUnit (void) GenericThread::EndUnit(void)
{ {
release_sem(m_execute_unit); // thread can now be paused release_sem(m_execute_unit); // thread can now be paused
} }
+43 -43
View File
@@ -7,69 +7,69 @@
class GenericThread class GenericThread
{ {
public: public:
GenericThread (const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL); GenericThread(const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL);
virtual ~GenericThread (void); virtual ~GenericThread(void);
BMessage * GetDataStore (void); BMessage * GetDataStore(void);
void SetDataStore (BMessage * a_message); void SetDataStore(BMessage * a_message);
status_t Start (void); status_t Start(void);
status_t Pause (bool a_do_block = TRUE, bigtime_t a_timeout = 0); status_t Pause(bool a_do_block = TRUE, bigtime_t a_timeout = 0);
void Quit (void); void Quit(void);
bool IsPaused (void); bool IsPaused(void);
bool HasQuitBeenRequested (void); bool HasQuitBeenRequested(void);
status_t Suspend (void); status_t Suspend(void);
status_t Resume (void); status_t Resume(void);
status_t Kill (void); status_t Kill(void);
void ExitWithReturnValue (status_t a_return_value); void ExitWithReturnValue(status_t a_return_value);
status_t SetExitCallback (void (* a_callback)(void *), void * a_data); status_t SetExitCallback(void(* a_callback)(void *), void * a_data);
status_t WaitForThread (status_t * a_exit_value); status_t WaitForThread(status_t * a_exit_value);
status_t Rename (char * a_name); status_t Rename(char * a_name);
status_t SendData (int32 a_code, void * a_buffer, size_t a_buffer_size); 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); int32 ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size);
bool HasData (void); bool HasData(void);
status_t SetPriority (int32 a_new_priority); status_t SetPriority(int32 a_new_priority);
void Snooze (bigtime_t a_microseconds); void Snooze(bigtime_t a_microseconds);
void SnoozeUntil (bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE); void SnoozeUntil(bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE);
status_t GetInfo (thread_info * a_thread_info); status_t GetInfo(thread_info * a_thread_info);
thread_id GetThread (void); thread_id GetThread(void);
team_id GetTeam (void); team_id GetTeam(void);
char * GetName (void); char * GetName(void);
thread_state GetState (void); thread_state GetState(void);
sem_id GetSemaphore (void); sem_id GetSemaphore(void);
int32 GetPriority (void); int32 GetPriority(void);
bigtime_t GetUserTime (void); bigtime_t GetUserTime(void);
bigtime_t GetKernelTime (void); bigtime_t GetKernelTime(void);
void * GetStackBase (void); void * GetStackBase(void);
void * GetStackEnd (void); void * GetStackEnd(void);
protected: protected:
virtual status_t ThreadFunction (void); virtual status_t ThreadFunction(void);
virtual status_t ThreadStartup (void); virtual status_t ThreadStartup(void);
virtual status_t ExecuteUnit (void); virtual status_t ExecuteUnit(void);
virtual status_t ThreadShutdown (void); virtual status_t ThreadShutdown(void);
virtual void ThreadStartupFailed (status_t a_status); virtual void ThreadStartupFailed(status_t a_status);
virtual void ExecuteUnitFailed (status_t a_status); virtual void ExecuteUnitFailed(status_t a_status);
virtual void ThreadShutdownFailed (status_t a_status); virtual void ThreadShutdownFailed(status_t a_status);
void BeginUnit (void); // acquire m_execute_cycle void BeginUnit(void); // acquire m_execute_cycle
void EndUnit (void); // release m_execute_cycle void EndUnit(void); // release m_execute_cycle
BMessage * m_thread_data_store; BMessage * m_thread_data_store;
private: private:
static status_t private_thread_function (void * a_simple_thread_ptr); static status_t private_thread_function(void * a_simple_thread_ptr);
thread_id m_thread_id; thread_id m_thread_id;