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
+7 -7
View File
@@ -22,7 +22,7 @@ DirectoryRefFilter::DirectoryRefFilter()
bool
DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
const char *filetype)
{
return node->IsDirectory();
@@ -32,13 +32,13 @@ DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
// #pragma mark -
DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode, BMessenger *target,
const entry_ref *startDirectory, uint32 nodeFlavors,
bool allowMultipleSelection, BMessage *message, BRefFilter *filter,
DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode, BMessenger *target,
const entry_ref *startDirectory, uint32 nodeFlavors,
bool allowMultipleSelection, BMessage *message, BRefFilter *filter,
bool modal, bool hideWhenDone)
: BFilePanel(mode, target, startDirectory, nodeFlavors,
: BFilePanel(mode, target, startDirectory, nodeFlavors,
allowMultipleSelection, message, filter, modal, hideWhenDone),
fCurrentButton(NULL)
fCurrentButton(NULL)
{
}
@@ -48,7 +48,7 @@ DirectoryFilePanel::Show()
{
if (fCurrentButton == NULL) {
Window()->Lock();
BView* background = Window()->ChildAt(0);
BView* background = Window()->ChildAt(0);
BView* cancel = background->FindView("cancel button");
BRect rect;
+7 -7
View File
@@ -9,18 +9,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
@@ -37,7 +37,7 @@ const uint32 MSG_DIRECTORY = 'mDIR';
class DirectoryRefFilter : public BRefFilter {
public:
DirectoryRefFilter();
bool Filter(const entry_ref *ref, BNode* node, struct stat *st,
bool Filter(const entry_ref *ref, BNode* node, struct stat *st,
const char *filetype);
};
@@ -51,7 +51,7 @@ class DirectoryFilePanel : public BFilePanel {
bool modal = false, bool hide_when_done = true);
virtual void SelectionChanged(void);
virtual void Show();
protected:
BButton *fCurrentButton;
};
+6 -6
View File
@@ -37,7 +37,7 @@ ExpanderApp::AboutRequested()
view->GetFont(&font);
font.SetSize(18);
font.SetFace(B_BOLD_FACE);
font.SetFace(B_BOLD_FACE);
view->SetFontAndColor(0, 14, &font);
alert->Go();
@@ -72,14 +72,14 @@ ExpanderApp::ArgvReceived(int32 argc, char **argv)
void
ExpanderApp::RefsReceived(BMessage *msg)
{
BMessenger messenger(fWindow);
msg->AddBool("fromApp", true);
messenger.SendMessage(msg);
{
BMessenger messenger(fWindow);
msg->AddBool("fromApp", true);
messenger.SendMessage(msg);
}
void
void
ExpanderApp::UpdateSettingsFrom(BMessage *message)
{
fSettings.UpdateFrom(message);
+17 -17
View File
@@ -10,18 +10,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
@@ -34,19 +34,19 @@
#include "ExpanderWindow.h"
class ExpanderApp : public BApplication {
public:
ExpanderApp();
public:
ExpanderApp();
public:
virtual void AboutRequested();
virtual void ArgvReceived(int32 argc, char **argv);
virtual void ReadyToRun();
virtual void RefsReceived(BMessage *msg);
ExpanderSettings fSettings;
void UpdateSettingsFrom(BMessage *message);
private:
ExpanderWindow *fWindow;
public:
virtual void AboutRequested();
virtual void ArgvReceived(int32 argc, char **argv);
virtual void ReadyToRun();
virtual void RefsReceived(BMessage *msg);
ExpanderSettings fSettings;
void UpdateSettingsFrom(BMessage *message);
private:
ExpanderWindow *fWindow;
};
#endif /* _ExpanderApp_h */
+84 -84
View File
@@ -2,7 +2,7 @@
* Copyright 2004-2006, Jérôme DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "ExpanderPreferences.h"
#include <Box.h>
#include <Path.h>
@@ -18,169 +18,169 @@ const uint32 MSG_DESTTEXT = 'mDet';
const uint32 MSG_DESTSELECT = 'mDes';
ExpanderPreferences::ExpanderPreferences(BMessage *settings)
: BWindow(BRect(0, 0, 325, 305), "Expand-O-Matic", B_MODAL_WINDOW,
: BWindow(BRect(0, 0, 325, 305), "Expand-O-Matic", B_MODAL_WINDOW,
B_NOT_CLOSABLE | B_NOT_RESIZABLE),
fSettings(settings),
fUsePanel(NULL)
{
BRect rect = Bounds();
BBox *background = new BBox(rect, "background", B_FOLLOW_ALL,
BBox *background = new BBox(rect, "background", B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
AddChild(background);
rect.OffsetBy(11,9);
rect.OffsetBy(11, 9);
rect.bottom -= 64;
rect.right -= 22;
BBox *box = new BBox(rect, "background", B_FOLLOW_NONE,
BBox *box = new BBox(rect, "background", B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
box->SetLabel("Expander Preferences");
background->AddChild(box);
float maxWidth=box->Bounds().right;
float maxWidth = box->Bounds().right;
BRect frameRect = box->Bounds();
frameRect.OffsetBy(15,23);
frameRect.OffsetBy(15, 23);
frameRect.right = frameRect.left + 200;
frameRect.bottom = frameRect.top + 20;
BRect textRect(frameRect);
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(1,1);
textRect.InsetBy(1, 1);
BStringView *stringView = new BStringView(frameRect, "expansion", "Expansion:",
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
maxWidth = stringView->Frame().right;
box->AddChild(stringView);
frameRect.top = stringView->Frame().bottom + 5;
frameRect.top = stringView->Frame().bottom + 5;
frameRect.left += 10;
fAutoExpand = new BCheckBox(frameRect, "autoExpand", "Automatically expand files", NULL);
fAutoExpand->ResizeToPreferred();
if (fAutoExpand->Frame().right > maxWidth)
maxWidth = fAutoExpand->Frame().right;
maxWidth = fAutoExpand->Frame().right;
box->AddChild(fAutoExpand);
frameRect = fAutoExpand->Frame();
frameRect.top = fAutoExpand->Frame().bottom + 1;
fCloseWindow = new BCheckBox(frameRect, "closeWindowWhenDone", "Close window when done expanding", NULL);
fCloseWindow->ResizeToPreferred();
if (fCloseWindow->Frame().right > maxWidth)
maxWidth = fCloseWindow->Frame().right;
maxWidth = fCloseWindow->Frame().right;
box->AddChild(fCloseWindow);
frameRect = stringView->Frame();
frameRect.top = fCloseWindow->Frame().bottom + 10;
stringView = new BStringView(frameRect, "destinationFolder", "Destination Folder:",
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred();
stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
maxWidth = stringView->Frame().right;
box->AddChild(stringView);
frameRect.top = stringView->Frame().bottom + 5;
frameRect.top = stringView->Frame().bottom + 5;
frameRect.left += 10;
fLeaveDest = new BRadioButton(frameRect, "leaveDest", "Leave destination folder path empty",
fLeaveDest = new BRadioButton(frameRect, "leaveDest", "Leave destination folder path empty",
new BMessage(MSG_LEAVEDEST));
fLeaveDest->ResizeToPreferred();
if (fLeaveDest->Frame().right > maxWidth)
maxWidth = fLeaveDest->Frame().right;
maxWidth = fLeaveDest->Frame().right;
box->AddChild(fLeaveDest);
frameRect = fLeaveDest->Frame();
frameRect.top = fLeaveDest->Frame().bottom + 1;
fSameDest = new BRadioButton(frameRect, "sameDir", "Same directory as source (archive) file",
fSameDest = new BRadioButton(frameRect, "sameDir", "Same directory as source (archive) file",
new BMessage(MSG_SAMEDIR));
fSameDest->ResizeToPreferred();
if (fSameDest->Frame().right > maxWidth)
maxWidth = fSameDest->Frame().right;
maxWidth = fSameDest->Frame().right;
box->AddChild(fSameDest);
frameRect = fSameDest->Frame();
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();
if (fDestUse->Frame().right > maxWidth)
maxWidth = fDestUse->Frame().right;
maxWidth = fDestUse->Frame().right;
box->AddChild(fDestUse);
frameRect = fDestUse->Frame();
frameRect.left = fDestUse->Frame().right + 1;
frameRect.right = frameRect.left + 58;
frameRect.bottom = frameRect.top + 38;
fDestText = new BTextControl(frameRect, "destText", "", "", new BMessage(MSG_DESTTEXT));
box->AddChild(fDestText);
fDestText->ResizeToPreferred();
fDestText->SetDivider(0);
fDestText->TextView()->MakeEditable(false);
fDestText->ResizeTo(158,fDestText->Frame().Height());
fDestText->ResizeTo(158, fDestText->Frame().Height());
fDestText->SetEnabled(false);
frameRect = fDestText->Frame();
frameRect.left = frameRect.right + 5;
fSelect = new BButton(frameRect, "selectButton", "Select", new BMessage(MSG_DESTSELECT));
fSelect->ResizeToPreferred();
if (fSelect->Frame().right > maxWidth)
maxWidth = fSelect->Frame().right;
maxWidth = fSelect->Frame().right;
box->AddChild(fSelect);
fSelect->SetEnabled(false);
fDestText->MoveBy(0,(fSelect->Frame().Height() - fDestText->Frame().Height())/2.0);
fDestText->ResizeTo(158,fDestText->Frame().Height());
fDestText->MoveBy(0, (fSelect->Frame().Height() - fDestText->Frame().Height()) / 2.0);
fDestText->ResizeTo(158, fDestText->Frame().Height());
frameRect = stringView->Frame();
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();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
maxWidth = stringView->Frame().right;
box->AddChild(stringView);
frameRect.top = stringView->Frame().bottom + 5;
frameRect.top = stringView->Frame().bottom + 5;
frameRect.left += 10;
fOpenDest = new BCheckBox(frameRect, "openDestination", "Open destination folder after extraction", NULL);
fOpenDest->ResizeToPreferred();
if (fOpenDest->Frame().right > maxWidth)
maxWidth = fOpenDest->Frame().right;
maxWidth = fOpenDest->Frame().right;
box->AddChild(fOpenDest);
frameRect = fOpenDest->Frame();
frameRect.top = frameRect.bottom + 1;
frameRect.top = frameRect.bottom + 1;
fAutoShow = new BCheckBox(frameRect, "autoShow", "Automatically show contents listing", NULL);
fAutoShow->ResizeToPreferred();
if (fAutoShow->Frame().right > maxWidth)
maxWidth = fAutoShow->Frame().right;
maxWidth = fAutoShow->Frame().right;
box->AddChild(fAutoShow);
box->ResizeTo(maxWidth + 15,fAutoShow->Frame().bottom + 10);
rect = BRect(Bounds().right-89, Bounds().bottom-40, Bounds().right-14, Bounds().bottom-16);
box->ResizeTo(maxWidth + 15, fAutoShow->Frame().bottom + 10);
rect = BRect(Bounds().right - 89, Bounds().bottom - 40, Bounds().right - 14, Bounds().bottom - 16);
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->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);
rect = button->Frame();
BButton *cancel = new BButton(rect, "CancelButton", "Cancel", new BMessage(MSG_CANCEL));
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);
ResizeTo(box->Frame().right + 11 ,button->Frame().bottom + 11);
ResizeTo(box->Frame().right + 11 , button->Frame().bottom + 11);
BScreen screen(this);
MoveBy((screen.Frame().Width()-Bounds().Width())/2,
(screen.Frame().Height()-Bounds().Height())/2);
MoveBy((screen.Frame().Width() - Bounds().Width()) / 2,
(screen.Frame().Height() - Bounds().Height()) / 2);
bool automatically_expand_files;
bool close_when_done;
int8 destination_folder;
@@ -190,11 +190,11 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
if ((settings->FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
&& automatically_expand_files)
fAutoExpand->SetValue(B_CONTROL_ON);
if ((settings->FindBool("close_when_done", &close_when_done) == B_OK)
&& close_when_done)
fCloseWindow->SetValue(B_CONTROL_ON);
if (settings->FindInt8("destination_folder", &destination_folder) == B_OK) {
switch (destination_folder) {
case 0x63:
@@ -210,21 +210,21 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
break;
}
}
if (settings->FindRef("destination_folder_use", &fRef) == B_OK) {
BEntry entry(&fRef);
if (entry.Exists()) {
BPath path(&entry);
fDestText->SetText(path.Path());
}
}
}
if ((settings->FindBool("open_destination_folder", &open_destination_folder) == B_OK)
&& open_destination_folder)
fOpenDest->SetValue(B_CONTROL_ON);
if ((settings->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
&& show_contents_listing)
&& show_contents_listing)
fAutoShow->SetValue(B_CONTROL_ON);
}
@@ -240,21 +240,21 @@ ExpanderPreferences::MessageReceived(BMessage *msg)
switch (msg->what) {
case MSG_DESTSELECT:
if (!fUsePanel)
fUsePanel = new DirectoryFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL,
fUsePanel = new DirectoryFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL,
B_DIRECTORY_NODE, false, NULL, new DirectoryRefFilter(), true);
fUsePanel->Show();
break;
case MSG_DIRECTORY:
{
entry_ref ref;
fUsePanel->GetPanelDirectory(&ref);
fRef = ref;
BEntry entry(&ref);
BPath path(&entry);
fDestText->SetText(path.Path());
fUsePanel->Hide();
}
break;
{
entry_ref ref;
fUsePanel->GetPanelDirectory(&ref);
fRef = ref;
BEntry entry(&ref);
BPath path(&entry);
fDestText->SetText(path.Path());
fUsePanel->Hide();
}
break;
case B_REFS_RECEIVED:
if (msg->FindRef("refs", 0, &fRef) == B_OK) {
BEntry entry(&fRef, true);
@@ -278,8 +278,8 @@ ExpanderPreferences::MessageReceived(BMessage *msg)
case MSG_OK:
fSettings->ReplaceBool("automatically_expand_files", fAutoExpand->Value() == B_CONTROL_ON);
fSettings->ReplaceBool("close_when_done", fCloseWindow->Value() == B_CONTROL_ON);
fSettings->ReplaceInt8("destination_folder", (fSameDest->Value() == B_CONTROL_ON) ? 0x63
: ( (fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65) );
fSettings->ReplaceInt8("destination_folder", (fSameDest->Value() == B_CONTROL_ON) ? 0x63
: ((fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65));
fSettings->ReplaceRef("destination_folder_use", &fRef);
fSettings->ReplaceBool("open_destination_folder", fOpenDest->Value() == B_CONTROL_ON);
fSettings->ReplaceBool("show_contents_listing", fAutoShow->Value() == B_CONTROL_ON);
+17 -17
View File
@@ -10,18 +10,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
@@ -39,19 +39,19 @@
#include <RadioButton.h>
class ExpanderPreferences : public BWindow {
public:
ExpanderPreferences(BMessage *settings);
virtual ~ExpanderPreferences();
virtual void MessageReceived(BMessage *msg);
public:
ExpanderPreferences(BMessage *settings);
virtual ~ExpanderPreferences();
virtual void MessageReceived(BMessage *msg);
private:
BMessage *fSettings;
BCheckBox *fAutoExpand, *fCloseWindow, *fAutoShow, *fOpenDest;
BRadioButton *fDestUse, *fSameDest, *fLeaveDest;
BButton *fSelect;
BTextControl *fDestText;
entry_ref fRef;
DirectoryFilePanel *fUsePanel;
private:
BMessage *fSettings;
BCheckBox *fAutoExpand, *fCloseWindow, *fAutoShow, *fOpenDest;
BRadioButton *fDestUse, *fSameDest, *fLeaveDest;
BButton *fSelect;
BTextControl *fDestText;
entry_ref fRef;
DirectoryFilePanel *fUsePanel;
};
#endif /* _ExpanderPreferences_h */
+14 -14
View File
@@ -14,8 +14,8 @@
#include <unistd.h>
ExpanderRule::ExpanderRule(BString mimetype, BString filenameExtension,
BString listingCmd, BString expandCmd)
ExpanderRule::ExpanderRule(BString mimetype, BString filenameExtension,
BString listingCmd, BString expandCmd)
:
fMimeType(mimetype.String()),
fFilenameExtension(filenameExtension),
@@ -26,7 +26,7 @@ ExpanderRule::ExpanderRule(BString mimetype, BString filenameExtension,
ExpanderRule::ExpanderRule(const char* mimetype, const char* filenameExtension,
const char* listingCmd, const char* expandCmd)
const char* listingCmd, const char* expandCmd)
:
fMimeType(mimetype),
fFilenameExtension(filenameExtension),
@@ -58,31 +58,31 @@ ExpanderRules::ExpanderRules()
char buffer[1024];
BString strings[4];
while (fgets(buffer, 1024-1, f)!=NULL) {
while (fgets(buffer, 1024 - 1, f) != NULL) {
int32 i = 0, j = 0;
int32 firstQuote = -1;
while (buffer[i] != '#' && buffer[i] != '\n' && j < 4) {
if ((j == 0 || j > 1) && buffer[i] == '"') {
if (firstQuote >= 0) {
strings[j++].SetTo(&buffer[firstQuote+1], i-firstQuote-1);
strings[j++].SetTo(&buffer[firstQuote+1], i - firstQuote - 1);
firstQuote = -1;
} else
firstQuote = i;
} else if (j == 1 && (buffer[i] == ' ' || buffer[i] == '\t')) {
if (firstQuote >= 0) {
if (firstQuote + 1 != i) {
strings[j++].SetTo(&buffer[firstQuote+1], i-firstQuote-1);
strings[j++].SetTo(&buffer[firstQuote+1], i - firstQuote - 1);
firstQuote = -1;
} else
firstQuote = i;
} else
firstQuote = i;
}
}
i++;
}
if (j == 4) {
fList.AddItem(new ExpanderRule(strings[0], strings[1], strings[2], strings[3]));
}
}
}
fclose(f);
close(fd);
@@ -97,7 +97,7 @@ ExpanderRules::~ExpanderRules()
}
status_t
status_t
ExpanderRules::Open(BFile *file)
{
BPath path;
@@ -107,13 +107,13 @@ ExpanderRules::Open(BFile *file)
path.Append("etc/expander.rules");
if (file->SetTo(path.Path(), B_READ_ONLY) == B_OK)
return B_OK;
if (find_directory(B_COMMON_ETC_DIRECTORY, &path) != B_OK)
return B_ERROR;
path.Append("expander.rules");
return file->SetTo(path.Path(), B_READ_ONLY);
return file->SetTo(path.Path(), B_READ_ONLY);
}
@@ -122,7 +122,7 @@ ExpanderRules::MatchingRule(BString &fileName, const char *filetype)
{
int32 count = fList.CountItems();
int32 length = fileName.Length();
for (int32 i=0; i<count; i++) {
for (int32 i = 0; i < count; i++) {
ExpanderRule *rule = (ExpanderRule *)fList.ItemAt(i);
if ((rule->MimeType().IsValid() && rule->MimeType() == filetype)
|| (fileName.FindLast(rule->FilenameExtension()) == (length - rule->FilenameExtension().Length())))
@@ -141,7 +141,7 @@ ExpanderRules::MatchingRule(const entry_ref *ref)
char type[B_MIME_TYPE_LENGTH];
nodeInfo.GetType(type);
BString fileName(ref->name);
return MatchingRule(fileName, type);
return MatchingRule(fileName, type);
}
@@ -153,7 +153,7 @@ RuleRefFilter::RuleRefFilter(ExpanderRules &rules)
bool
RuleRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
RuleRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
const char *filetype)
{
if (node->IsDirectory() || node->IsSymLink())
+3 -3
View File
@@ -14,9 +14,9 @@
class ExpanderRule {
public:
ExpanderRule(BString mimetype, BString filenameExtension,
ExpanderRule(BString mimetype, BString filenameExtension,
BString listingCmd, BString expandCmd);
ExpanderRule(const char* mimetype, const char* filenameExtension,
ExpanderRule(const char* mimetype, const char* filenameExtension,
const char* listingCmd, const char* expandCmd);
BMimeType &MimeType() { return fMimeType;}
BString &FilenameExtension() { return fFilenameExtension;}
@@ -46,7 +46,7 @@ class ExpanderRules {
class RuleRefFilter : public BRefFilter {
public:
RuleRefFilter(ExpanderRules &rules);
bool Filter(const entry_ref *ref, BNode* node, struct stat *st,
bool Filter(const entry_ref *ref, BNode* node, struct stat *st,
const char *filetype);
protected:
ExpanderRules &fRules;
+31 -31
View File
@@ -11,18 +11,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
@@ -40,7 +40,7 @@
// 1st byte : unknown (0x1)
// 2nd byte : Automatically expand files (default : 0x0)
// 3rd byte : Close when done (default : 0x0)
// 4th byte : 0x66
// 4th byte : 0x66
// 0x63 (default)
// 0x65
// 5th byte : unknown (0x0)
@@ -91,13 +91,13 @@ ExpanderSettings::ExpanderSettings()
&& (file.Read(&ref.device, sizeof(ref.device)) == sizeof(ref.device))
&& (file.Read(&ref.directory, sizeof(ref.directory)) == sizeof(ref.directory))
&& (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(&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(&position, sizeof(position)) == sizeof(position))
) {
) {
// check if the window position is on screen at all
BScreen screen;
if (screen.Frame().Contains(position))
@@ -105,16 +105,16 @@ ExpanderSettings::ExpanderSettings()
fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files);
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);
if (name_size > 0)
ref.name[name_size] = '\0';
BEntry entry(&ref);
if(entry.Exists())
if (entry.Exists())
fMessage.ReplaceRef("destination_folder_use", &ref);
fMessage.ReplaceBool("open_destination_folder", open_destination_folder);
fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
}
}
}
@@ -127,7 +127,7 @@ ExpanderSettings::~ExpanderSettings()
BFile file;
if (Open(&file, B_CREATE_FILE | B_WRITE_ONLY) != B_OK)
return;
bool automatically_expand_files;
bool close_when_done;
int8 destination_folder;
@@ -136,15 +136,15 @@ ExpanderSettings::~ExpanderSettings()
bool show_contents_listing;
BPoint position;
bool unknown = 1;
if ((fMessage.FindPoint("window_position", &position) == B_OK)
&& (fMessage.FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
&& (fMessage.FindBool("close_when_done", &close_when_done) == 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("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(&automatically_expand_files, sizeof(automatically_expand_files));
file.Write(&close_when_done, sizeof(close_when_done));
@@ -154,7 +154,7 @@ ExpanderSettings::~ExpanderSettings()
file.Write(&ref.device, sizeof(ref.device));
file.Write(&ref.directory, sizeof(ref.directory));
int32 name_size = 0;
if(ref.name)
if (ref.name)
name_size = strlen(ref.name);
file.Write(&name_size, sizeof(name_size));
file.Write(ref.name, name_size);
@@ -166,7 +166,7 @@ ExpanderSettings::~ExpanderSettings()
}
status_t
status_t
ExpanderSettings::Open(BFile *file, int32 mode)
{
BPath path;
@@ -179,7 +179,7 @@ ExpanderSettings::Open(BFile *file, int32 mode)
}
void
void
ExpanderSettings::UpdateFrom(BMessage *message)
{
bool automatically_expand_files;
@@ -189,27 +189,27 @@ ExpanderSettings::UpdateFrom(BMessage *message)
bool open_destination_folder;
bool show_contents_listing;
BPoint position;
if (message->FindPoint("window_position", &position) == B_OK)
fMessage.ReplacePoint("window_position", position);
if (message->FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files);
if (message->FindBool("close_when_done", &close_when_done) == B_OK)
fMessage.ReplaceBool("close_when_done", close_when_done);
if (message->FindInt8("destination_folder", &destination_folder) == B_OK)
fMessage.ReplaceInt8("destination_folder", destination_folder);
if (message->FindRef("destination_folder_use", &ref) == B_OK)
if (message->FindRef("destination_folder_use", &ref) == B_OK)
fMessage.ReplaceRef("destination_folder_use", &ref);
if (message->FindBool("open_destination_folder", &open_destination_folder) == B_OK)
fMessage.ReplaceBool("open_destination_folder", open_destination_folder);
if (message->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
if (message->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
fUpdated = true;
}
+5 -5
View File
@@ -10,18 +10,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
+82 -82
View File
@@ -13,8 +13,8 @@
const char * ExpanderThreadName = "ExpanderThread";
ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
ExpanderThread::ExpanderThread(BMessage * refs_message, BMessenger * messenger)
: GenericThread(ExpanderThreadName, B_NORMAL_PRIORITY, refs_message),
fWindowMessenger(messenger),
fThreadId(-1),
fStdIn(-1),
@@ -24,12 +24,12 @@ ExpanderThread::ExpanderThread (BMessage * refs_message, BMessenger * messenger)
fExpanderOutputString(),
fExpanderOutputBuffer(new char [4096])
{
SetDataStore(new BMessage (* refs_message)); // leak?
// prevents bug with B_SIMPLE_DATA
// (drag&drop messages)
SetDataStore(new BMessage(* refs_message)); // leak?
// prevents bug with B_SIMPLE_DATA
// (drag&drop messages)
}
ExpanderThread::~ExpanderThread()
ExpanderThread::~ExpanderThread()
{
delete fWindowMessenger;
delete [] fExpanderOutputBuffer;
@@ -41,64 +41,64 @@ ExpanderThread::ThreadStartup()
status_t status = B_OK;
entry_ref srcRef, destRef;
BString cmd;
if ((status = GetDataStore()->FindRef("srcRef", &srcRef))!=B_OK)
if ((status = GetDataStore()->FindRef("srcRef", &srcRef)) != B_OK)
return status;
if ((status = GetDataStore()->FindRef("destRef", &destRef))==B_OK) {
if ((status = GetDataStore()->FindRef("destRef", &destRef)) == B_OK) {
BPath path(&destRef);
chdir(path.Path());
}
if ((status = GetDataStore()->FindString("cmd", &cmd))!=B_OK)
if ((status = GetDataStore()->FindString("cmd", &cmd)) != B_OK)
return status;
BPath path(&srcRef);
BString pathString(path.Path());
pathString.CharacterEscape("\"$`", '\\');
pathString.Prepend("\"");
pathString.Append("\"");
pathString.Prepend("\"");
pathString.Append("\"");
cmd.ReplaceAll("%s", pathString.String());
int32 argc = 3;
const char ** argv = new const char * [argc + 1];
argv[0] = strdup("/bin/sh");
argv[1] = strdup("-c");
argv[2] = strdup(cmd.String());
argv[argc] = NULL;
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);
delete [] argv;
if (fThreadId < 0)
return fThreadId;
resume_thread(fThreadId);
fExpanderOutput = fdopen(fStdOut, "r");
return fThreadId;
resume_thread(fThreadId);
fExpanderOutput = fdopen(fStdOut, "r");
return B_OK;
}
status_t
ExpanderThread::ExecuteUnit (void)
ExpanderThread::ExecuteUnit(void)
{
// read output from command
// send it to window
char *output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput);
char *output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (output_string == NULL)
return EOF;
BMessage message('outp');
message.AddString("output", output_string);
for (int32 i=0; i<5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096-1, fExpanderOutput);
if(!output_string)
for (int32 i = 0; i < 5; i++) {
output_string = fgets(fExpanderOutputBuffer , 4096 - 1, fExpanderOutput);
if (!output_string)
break;
message.AddString("output", output_string);
}
}
fWindowMessenger->SendMessage(&message);
return B_OK;
@@ -108,8 +108,8 @@ status_t
ExpanderThread::ThreadShutdown(void)
{
close(fStdIn);
close(fStdOut);
close(fStdErr);
close(fStdOut);
close(fStdErr);
return B_OK;
}
@@ -132,7 +132,7 @@ ExpanderThread::ExecuteUnitFailed(status_t status)
// explicit error - communicate error to Window
fWindowMessenger->SendMessage(new BMessage('exrr'));
}
Quit();
}
@@ -150,56 +150,56 @@ ExpanderThread::ProcessRefs(BMessage *msg)
}
thread_id
ExpanderThread::PipeCommand(int argc, const char **argv, int &in, int &out, int &err, const char **envp)
{
ExpanderThread::PipeCommand(int argc, const char **argv, int &in, int &out, int &err, const char **envp)
{
// This function written by Peter Folk <[email protected]>
// and published in the BeDevTalk FAQ
// 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);
if (ret < B_OK)
return ret;
// 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);
if (ret < B_OK)
return ret;
// thread ret is now suspended.
setpgid(ret, 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);
return ret;
}
/* 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;
}
status_t
ExpanderThread::SuspendExternalExpander()
ExpanderThread::SuspendExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK)
return send_signal(-fThreadId, SIGSTOP);
else
@@ -207,11 +207,11 @@ ExpanderThread::SuspendExternalExpander()
}
status_t
ExpanderThread::ResumeExternalExpander()
{
ExpanderThread::ResumeExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK)
return send_signal(-fThreadId, SIGCONT);
else
@@ -219,11 +219,11 @@ ExpanderThread::ResumeExternalExpander()
}
status_t
ExpanderThread::InterruptExternalExpander()
{
ExpanderThread::InterruptExternalExpander()
{
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) {
status = send_signal(-fThreadId, SIGINT);
WaitOnExternalExpander();
@@ -232,11 +232,11 @@ ExpanderThread::InterruptExternalExpander()
}
status_t
ExpanderThread::WaitOnExternalExpander()
{
ExpanderThread::WaitOnExternalExpander()
{
thread_info thread_info;
status_t status = get_thread_info(fThreadId, &thread_info);
if (status == B_OK)
return wait_for_thread(fThreadId, &status);
else
+15 -15
View File
@@ -9,18 +9,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
@@ -31,8 +31,8 @@
#include <Message.h>
#include <Volume.h>
#include <String.h>
#include <OS.h>
#include <FindDirectory.h>
#include <OS.h>
#include <FindDirectory.h>
#include "GenericThread.h"
#include <stdio.h>
@@ -42,7 +42,7 @@ extern const char * ExpanderThreadName;
class ExpanderThread : public GenericThread
{
public:
public:
ExpanderThread(BMessage *refs_message, BMessenger *messenger);
~ExpanderThread();
@@ -51,22 +51,22 @@ public:
status_t InterruptExternalExpander();
status_t WaitOnExternalExpander();
private:
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);
thread_id PipeCommand(int argc, const char **argv,
int & in, int & out, int & err,
const char **envp = (const char **) environ);
thread_id PipeCommand(int argc, const char **argv,
int & in, int & out, int & err,
const char **envp = (const char **) environ);
BMessenger * fWindowMessenger;
thread_id fThreadId;
+74 -74
View File
@@ -48,7 +48,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
fSourcePanel = NULL;
fDestPanel = NULL;
// create menu bar
// create menu bar
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
BMenu *menu = new BMenu("File");
BMenuItem *item;
@@ -84,7 +84,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
// Buttons
rect = topView->Bounds().InsetByCopy(8, 8);
fDestButton = new BButton(rect, "destButton", "Destination",
fDestButton = new BButton(rect, "destButton", "Destination",
new BMessage(MSG_DEST), B_FOLLOW_LEFT | B_FOLLOW_TOP);
fDestButton->ResizeToPreferred();
topView->AddChild(fDestButton);
@@ -92,13 +92,13 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
rect = fDestButton->Frame();
fDestButton->MoveBy(0, rect.Height() + 4);
fSourceButton = new BButton(rect, "sourceButton", "Source",
fSourceButton = new BButton(rect, "sourceButton", "Source",
new BMessage(MSG_SOURCE), B_FOLLOW_LEFT | B_FOLLOW_TOP);
topView->AddChild(fSourceButton);
rect = fDestButton->Frame();
rect.OffsetBy(0, rect.Height() + 4);
fExpandButton = new BButton(rect, "expandButton", "Expand",
fExpandButton = new BButton(rect, "expandButton", "Expand",
new BMessage(MSG_EXPAND), B_FOLLOW_LEFT | B_FOLLOW_TOP);
topView->AddChild(fExpandButton);
fExpandButton->SetEnabled(false);
@@ -108,7 +108,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
rect = fSourceButton->Frame();
rect.left = rect.right + 8;
rect.right = frame.Width() - 8;
fSourceText = new BTextControl(rect, "sourceText", "", NULL,
fSourceText = new BTextControl(rect, "sourceText", "", NULL,
new BMessage(MSG_SOURCETEXT), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fSourceText->SetDivider(0);
float width, height;
@@ -120,13 +120,13 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
rect = fSourceText->Frame();
rect.OffsetBy(0, fSourceButton->Bounds().Height() + 4);
fDestText = new BTextControl(rect, "destText", "", NULL,
fDestText = new BTextControl(rect, "destText", "", NULL,
new BMessage(MSG_DESTTEXT), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fDestText->SetDivider(0);
topView->AddChild(fDestText);
rect.OffsetBy(0, fSourceButton->Bounds().Height() + 4 + offset);
fShowContents = new BCheckBox(rect, "showContents", "Show Contents",
fShowContents = new BCheckBox(rect, "showContents", "Show Contents",
new BMessage(MSG_SHOWCONTENTS), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
fShowContents->ResizeToPreferred();
fShowContents->MoveTo(Bounds().right - 8 - fShowContents->Bounds().Width(),
@@ -157,7 +157,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
be_fixed_font, NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
fListingText->SetText("");
fListingText->MakeEditable(false);
fListingScroll = new BScrollView("listingScroll", fListingText,
fListingScroll = new BScrollView("listingScroll", fListingText,
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
topView->AddChild(fListingScroll);
fListingScroll->Hide();
@@ -191,7 +191,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
switch (msg->what) {
case MSG_SOURCE:
if (!fSourcePanel) {
fSourcePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL,
fSourcePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL,
B_FILE_NODE, false, NULL, new RuleRefFilter(fRules), true);
}
fSourcePanel->Show();
@@ -199,7 +199,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
case MSG_DEST:
if (!fDestPanel) {
fDestPanel = new DirectoryFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL,
fDestPanel = new DirectoryFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL,
B_DIRECTORY_NODE, false, NULL, new DirectoryRefFilter(), true);
}
fDestPanel->Show();
@@ -225,16 +225,16 @@ ExpanderWindow::MessageReceived(BMessage *msg)
case MSG_EXPAND:
if (!fExpandingStarted) {
StartExpanding();
break;
break;
}
// supposed to fall through
case MSG_STOP:
if (fExpandingStarted) {
fExpandingThread->SuspendExternalExpander();
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,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go()==0) {
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander();
StopExpanding();
} else
@@ -250,67 +250,67 @@ ExpanderWindow::MessageReceived(BMessage *msg)
// change menu item label
fShowItem->SetLabel(fShowContents->Value() == B_CONTROL_OFF
? "Show Contents" : "Hide Contents");
if (fShowContents->Value() == B_CONTROL_OFF) {
if (fListingStarted)
StopListing();
_UpdateWindowSize(false);
} else
StartListing();
break;
case MSG_SOURCETEXT:
{
BEntry entry(fSourceText->Text(), true);
if (!entry.Exists()) {
BAlert *alert = new BAlert("srcAlert", "The file doesn't exist",
"Cancel", NULL, NULL,
{
BEntry entry(fSourceText->Text(), true);
if (!entry.Exists()) {
BAlert *alert = new BAlert("srcAlert", "The file doesn't exist",
"Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go();
break;
}
entry_ref ref;
entry.GetRef(&ref);
ExpanderRule *rule = fRules.MatchingRule(&ref);
if (rule) {
fSourceChanged = true;
fSourceRef = ref;
fShowContents->SetEnabled(true);
fExpandButton->SetEnabled(true);
fExpandItem->SetEnabled(true);
fShowItem->SetEnabled(true);
break;
}
BString string = "The file : ";
string += fSourceText->Text();
string += " is not supported";
BAlert *alert = new BAlert("srcAlert", string.String(),
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT);
alert->Go();
fShowContents->SetEnabled(false);
fExpandButton->SetEnabled(false);
fExpandItem->SetEnabled(false);
fShowItem->SetEnabled(false);
break;
}
break;
case MSG_DESTTEXT:
{
BEntry entry(fDestText->Text(), true);
if (!entry.Exists()) {
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
entry_ref ref;
entry.GetRef(&ref);
ExpanderRule *rule = fRules.MatchingRule(&ref);
if (rule) {
fSourceChanged = true;
fSourceRef = ref;
fShowContents->SetEnabled(true);
fExpandButton->SetEnabled(true);
fExpandItem->SetEnabled(true);
fShowItem->SetEnabled(true);
break;
}
BString string = "The file : ";
string += fSourceText->Text();
string += " is not supported";
BAlert *alert = new BAlert("srcAlert", string.String(),
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT);
alert->Go();
fShowContents->SetEnabled(false);
fExpandButton->SetEnabled(false);
fExpandItem->SetEnabled(false);
fShowItem->SetEnabled(false);
}
break;
case MSG_DESTTEXT:
{
BEntry entry(fDestText->Text(), true);
if (!entry.Exists()) {
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
"supported.",
"Cancel", NULL, NULL,
"Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go();
break;
}
entry.GetRef(&fDestRef);
alert->Go();
break;
}
break;
entry.GetRef(&fDestRef);
}
break;
case MSG_PREFERENCES:
if (!fPreferences)
fPreferences = new ExpanderPreferences(&fSettings);
@@ -319,12 +319,12 @@ ExpanderWindow::MessageReceived(BMessage *msg)
case 'outp':
if (!fExpandingStarted && fListingStarted) {
BString string;
int32 i=0;
while (msg->FindString("output", i++, &string)==B_OK)
int32 i = 0;
while (msg->FindString("output", i++, &string) == B_OK)
fListingText->Insert(string.String());
fListingText->ScrollToSelection();
}
break;
case 'exit': // thread has finished (finished, quit, killed, we don't know)
// reset window state
@@ -362,9 +362,9 @@ ExpanderWindow::CanQuit()
if (fExpandingStarted) {
fExpandingThread->SuspendExternalExpander();
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,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go()==0) {
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander();
StopExpanding();
} else {
@@ -409,12 +409,12 @@ ExpanderWindow::RefsReceived(BMessage *msg)
fSourceChanged = true;
fSourceRef = ref;
fSourceText->SetText(path.Path());
if (destination_folder==0x63) {
if (destination_folder == 0x63) {
BPath parent;
path.GetParent(&parent);
fDestText->SetText(parent.Path());
get_ref_for_path(parent.Path(), &fDestRef);
} else if (destination_folder==0x65) {
} else if (destination_folder == 0x65) {
fSettings.FindRef("destination_folder_use", &fDestRef);
BEntry dEntry(&fDestRef, true);
BPath dPath(&dEntry);
@@ -428,7 +428,7 @@ ExpanderWindow::RefsReceived(BMessage *msg)
}
if (fShowContents->Value() == B_CONTROL_ON) {
StopListing();
StopListing();
StartListing();
} else {
fShowContents->SetEnabled(true);
@@ -440,7 +440,7 @@ ExpanderWindow::RefsReceived(BMessage *msg)
AutoExpand();
} else
AutoListing();
} else if(node.IsDirectory()) {
} else if (node.IsDirectory()) {
fDestRef = ref;
fDestText->SetText(path.Path());
}
@@ -458,9 +458,9 @@ ExpanderWindow::StartExpanding()
BEntry destEntry(fDestText->Text(), true);
if (!destEntry.Exists()) {
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
"supported.",
"Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
"supported.",
"Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go();
return;
}
@@ -606,7 +606,7 @@ ExpanderWindow::StopListing(void)
fShowItem->SetEnabled(true);
fStopItem->SetEnabled(false);
fPreferencesItem->SetEnabled(true);
fSourceButton->SetEnabled(true);
fDestButton->SetEnabled(true);
fExpandButton->SetEnabled(true);
+6 -6
View File
@@ -39,7 +39,7 @@ class ExpanderWindow : public BWindow {
private:
bool CanQuit();
// returns true if the window can be closed safely, false if not
// returns true if the window can be closed safely, false if not
void CloseWindowOrKeepOpen();
void OpenDestFolder();
void AutoListing();
@@ -57,22 +57,22 @@ class ExpanderWindow : public BWindow {
entry_ref fSourceRef;
entry_ref fDestRef;
bool fSourceChanged;
BButton *fSourceButton, *fDestButton, *fExpandButton;
BMenuItem *fExpandItem, *fShowItem, *fStopItem,
BMenuItem *fExpandItem, *fShowItem, *fStopItem,
*fSourceItem, *fDestItem, *fPreferencesItem;
BCheckBox *fShowContents;
BTextControl *fSourceText, *fDestText;
BStringView* fStatusView;
BTextView *fListingText;
BScrollView *fListingScroll;
ExpanderThread *fListingThread;
bool fListingStarted;
ExpanderThread *fExpandingThread;
bool fExpandingStarted;
BMessage fSettings;
ExpanderPreferences *fPreferences;
ExpanderRules fRules;
+124 -124
View File
@@ -3,13 +3,13 @@
#include "GenericThread.h"
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_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)
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)
{
if (m_thread_data_store == NULL)
m_thread_data_store = new BMessage();
@@ -18,35 +18,35 @@ GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMess
GenericThread::~GenericThread()
{
kill_thread(m_thread_id);
delete_sem(m_execute_unit);
}
status_t
GenericThread::ThreadFunction (void)
status_t
GenericThread::ThreadFunction(void)
{
status_t status = B_OK;
status = ThreadStartup(); // Subclass and override this function
if (status != B_OK)
{
ThreadStartupFailed (status);
ThreadStartupFailed(status);
return (status);
// is this the right thing to do?
}
while(1)
while (1)
{
if (HasQuitBeenRequested())
{
status = ThreadShutdown(); // Subclass and override this function
if (status != B_OK)
{
ThreadShutdownFailed (status);
ThreadShutdownFailed(status);
return (status);
// what do we do?
}
delete this; // destructor
}
@@ -55,16 +55,16 @@ GenericThread::ThreadFunction (void)
status = ExecuteUnit(); // Subclass and override
if (status != B_OK)
ExecuteUnitFailed (status); // Subclass and override
EndUnit();
ExecuteUnitFailed(status); // Subclass and override
EndUnit();
}
return (B_OK);
}
status_t
GenericThread::ThreadStartup (void)
status_t
GenericThread::ThreadStartup(void)
{
// This function is virtual.
// Subclass and override this function.
@@ -73,8 +73,8 @@ GenericThread::ThreadStartup (void)
}
status_t
GenericThread::ExecuteUnit (void)
status_t
GenericThread::ExecuteUnit(void)
{
// This function is virtual.
@@ -85,8 +85,8 @@ GenericThread::ExecuteUnit (void)
return B_OK;
}
status_t
GenericThread::ThreadShutdown (void)
status_t
GenericThread::ThreadShutdown(void)
{
// This function is virtual.
// Subclass and override this function.
@@ -94,54 +94,54 @@ GenericThread::ThreadShutdown (void)
return B_OK;
}
void
GenericThread::ThreadStartupFailed (status_t a_status)
void
GenericThread::ThreadStartupFailed(status_t a_status)
{
// This function is virtual.
// Subclass and override this function.
Quit();
}
void
GenericThread::ExecuteUnitFailed (status_t a_status)
void
GenericThread::ExecuteUnitFailed(status_t a_status)
{
// This function is virtual.
// Subclass and override this function.
Quit();
}
void
GenericThread::ThreadShutdownFailed (status_t a_status)
void
GenericThread::ThreadShutdownFailed(status_t a_status)
{
// This function is virtual.
// Subclass and override this function.
// (is this good default behaviour?)
}
status_t
GenericThread::Start (void)
status_t
GenericThread::Start(void)
{
status_t status = B_OK;
if (IsPaused())
{
status = release_sem (m_execute_unit);
status = release_sem(m_execute_unit);
if (status != B_OK)
return status;
m_thread_is_paused = false;
}
status = resume_thread (m_thread_id);
status = resume_thread(m_thread_id);
return status;
}
int32
GenericThread::private_thread_function (void * a_simple_thread_ptr)
int32
GenericThread::private_thread_function(void * a_simple_thread_ptr)
{
status_t status = B_OK;
@@ -150,236 +150,236 @@ GenericThread::private_thread_function (void * a_simple_thread_ptr)
return (status);
}
BMessage *
GenericThread::GetDataStore (void)
BMessage *
GenericThread::GetDataStore(void)
{
return (m_thread_data_store);
}
void
GenericThread::SetDataStore (BMessage * a_message)
GenericThread::SetDataStore(BMessage * a_message)
{
m_thread_data_store = a_message;
}
status_t
GenericThread::Pause (bool a_do_block, bigtime_t a_timeout)
status_t
GenericThread::Pause(bool a_do_block, bigtime_t a_timeout)
{
status_t status = B_OK;
if (a_do_block)
status = acquire_sem(m_execute_unit);
// thread will wait on semaphore
status = acquire_sem(m_execute_unit);
// thread will wait on semaphore
else
status = acquire_sem_etc(m_execute_unit, 1, B_RELATIVE_TIMEOUT, a_timeout);
// thread will timeout
status = acquire_sem_etc(m_execute_unit, 1, B_RELATIVE_TIMEOUT, a_timeout);
// thread will timeout
if (status == B_OK)
{
m_thread_is_paused = true;
return (B_OK);
}
return status;
}
void
GenericThread::Quit (void)
void
GenericThread::Quit(void)
{
m_quit_requested = true;
}
bool
GenericThread::HasQuitBeenRequested (void)
bool
GenericThread::HasQuitBeenRequested(void)
{
return (m_quit_requested);
}
bool
GenericThread::IsPaused (void)
bool
GenericThread::IsPaused(void)
{
return (m_thread_is_paused);
}
status_t
GenericThread::Suspend (void)
status_t
GenericThread::Suspend(void)
{
return (suspend_thread(m_thread_id));
}
status_t
GenericThread::Resume (void)
status_t
GenericThread::Resume(void)
{
release_sem(m_execute_unit); // to counteract Pause()
m_thread_is_paused = false;
return (resume_thread(m_thread_id)); // to counteract Suspend()
}
status_t
GenericThread::Kill (void)
status_t
GenericThread::Kill(void)
{
return (kill_thread(m_thread_id));
}
void
GenericThread::ExitWithReturnValue (status_t a_return_value)
void
GenericThread::ExitWithReturnValue(status_t a_return_value)
{
exit_thread(a_return_value);
}
status_t
GenericThread::SetExitCallback (void (*a_callback)(void*), void * a_data)
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)
status_t
GenericThread::WaitForThread(status_t * a_exit_value)
{
return (wait_for_thread(m_thread_id, a_exit_value));
}
status_t
GenericThread::Rename (char * a_name)
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)
status_t
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));
}
int32
GenericThread::ReceiveData (thread_id * a_sender, void * a_buffer, size_t a_buffer_size)
int32
GenericThread::ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size)
{
return (receive_data(a_sender, a_buffer, a_buffer_size));
}
bool
GenericThread::HasData (void)
bool
GenericThread::HasData(void)
{
return (has_data(m_thread_id));
}
status_t
GenericThread::SetPriority (int32 a_new_priority)
status_t
GenericThread::SetPriority(int32 a_new_priority)
{
return (set_thread_priority(m_thread_id, a_new_priority));
}
void
GenericThread::Snooze (bigtime_t a_microseconds)
void
GenericThread::Snooze(bigtime_t a_microseconds)
{
Suspend();
snooze(a_microseconds);
Resume();
}
void
GenericThread::SnoozeUntil (bigtime_t a_microseconds, int a_timebase)
void
GenericThread::SnoozeUntil(bigtime_t a_microseconds, int a_timebase)
{
Suspend();
snooze_until(a_microseconds, a_timebase);
Resume();
}
status_t
GenericThread::GetInfo (thread_info * a_thread_info)
status_t
GenericThread::GetInfo(thread_info * a_thread_info)
{
return (get_thread_info(m_thread_id, a_thread_info));
}
thread_id
GenericThread::GetThread (void)
thread_id
GenericThread::GetThread(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.thread);
}
team_id
GenericThread::GetTeam (void)
team_id
GenericThread::GetTeam(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.team);
}
char *
GenericThread::GetName (void)
char *
GenericThread::GetName(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.name);
}
thread_state
GenericThread::GetState (void)
thread_state
GenericThread::GetState(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.state);
}
sem_id
GenericThread::GetSemaphore (void)
sem_id
GenericThread::GetSemaphore(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.sem);
}
int32
GenericThread::GetPriority (void)
int32
GenericThread::GetPriority(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.priority);
}
bigtime_t
GenericThread::GetUserTime (void)
bigtime_t
GenericThread::GetUserTime(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.user_time);
}
bigtime_t
GenericThread::GetKernelTime (void)
bigtime_t
GenericThread::GetKernelTime(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.kernel_time);
}
void *
GenericThread::GetStackBase (void)
void *
GenericThread::GetStackBase(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.stack_base);
}
void *
GenericThread::GetStackEnd (void)
void *
GenericThread::GetStackEnd(void)
{
thread_info t_thread_info;
GetInfo (& t_thread_info);
GetInfo(& t_thread_info);
return (t_thread_info.stack_end);
}
void
GenericThread::BeginUnit (void)
void
GenericThread::BeginUnit(void)
{
acquire_sem(m_execute_unit); // thread can not be paused until it releases semaphore
}
void
GenericThread::EndUnit (void)
void
GenericThread::EndUnit(void)
{
release_sem(m_execute_unit); // thread can now be paused
}
+56 -56
View File
@@ -7,72 +7,72 @@
class GenericThread
{
public:
GenericThread (const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL);
virtual ~GenericThread (void);
GenericThread(const char * a_thread_name = "generic_thread", int32 a_priority = B_NORMAL_PRIORITY, BMessage * a_message = NULL);
virtual ~GenericThread(void);
BMessage * GetDataStore (void);
void SetDataStore (BMessage * a_message);
BMessage * GetDataStore(void);
void SetDataStore(BMessage * a_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 SetPriority (int32 a_new_priority);
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);
void Snooze (bigtime_t a_microseconds);
void SnoozeUntil (bigtime_t a_microseconds, int a_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 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 SetPriority(int32 a_new_priority);
void Snooze(bigtime_t a_microseconds);
void SnoozeUntil(bigtime_t a_microseconds, int a_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);
protected:
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);
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); // acquire m_execute_cycle
void EndUnit(void); // release m_execute_cycle
void BeginUnit (void); // acquire m_execute_cycle
void EndUnit (void); // release m_execute_cycle
BMessage * m_thread_data_store;
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;
sem_id m_execute_unit; // acq./relase within tread_function.. For Pause()
bool m_quit_requested;