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:
@@ -22,7 +22,7 @@ DirectoryRefFilter::DirectoryRefFilter()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
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)
|
const char *filetype)
|
||||||
{
|
{
|
||||||
return node->IsDirectory();
|
return node->IsDirectory();
|
||||||
@@ -32,13 +32,13 @@ DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node, struct stat *st,
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode, BMessenger *target,
|
DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode, BMessenger *target,
|
||||||
const entry_ref *startDirectory, uint32 nodeFlavors,
|
const entry_ref *startDirectory, uint32 nodeFlavors,
|
||||||
bool allowMultipleSelection, BMessage *message, BRefFilter *filter,
|
bool allowMultipleSelection, BMessage *message, BRefFilter *filter,
|
||||||
bool modal, bool hideWhenDone)
|
bool modal, bool hideWhenDone)
|
||||||
: BFilePanel(mode, target, startDirectory, nodeFlavors,
|
: BFilePanel(mode, target, startDirectory, nodeFlavors,
|
||||||
allowMultipleSelection, message, filter, modal, hideWhenDone),
|
allowMultipleSelection, message, filter, modal, hideWhenDone),
|
||||||
fCurrentButton(NULL)
|
fCurrentButton(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ DirectoryFilePanel::Show()
|
|||||||
{
|
{
|
||||||
if (fCurrentButton == NULL) {
|
if (fCurrentButton == NULL) {
|
||||||
Window()->Lock();
|
Window()->Lock();
|
||||||
BView* background = Window()->ChildAt(0);
|
BView* background = Window()->ChildAt(0);
|
||||||
BView* cancel = background->FindView("cancel button");
|
BView* cancel = background->FindView("cancel button");
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
|
|||||||
@@ -9,18 +9,18 @@
|
|||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// 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.
|
// in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// 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
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -37,7 +37,7 @@ const uint32 MSG_DIRECTORY = 'mDIR';
|
|||||||
class DirectoryRefFilter : public BRefFilter {
|
class DirectoryRefFilter : public BRefFilter {
|
||||||
public:
|
public:
|
||||||
DirectoryRefFilter();
|
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);
|
const char *filetype);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class DirectoryFilePanel : public BFilePanel {
|
|||||||
bool modal = false, bool hide_when_done = true);
|
bool modal = false, bool hide_when_done = true);
|
||||||
virtual void SelectionChanged(void);
|
virtual void SelectionChanged(void);
|
||||||
virtual void Show();
|
virtual void Show();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BButton *fCurrentButton;
|
BButton *fCurrentButton;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ ExpanderApp::AboutRequested()
|
|||||||
|
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
font.SetSize(18);
|
font.SetSize(18);
|
||||||
font.SetFace(B_BOLD_FACE);
|
font.SetFace(B_BOLD_FACE);
|
||||||
view->SetFontAndColor(0, 14, &font);
|
view->SetFontAndColor(0, 14, &font);
|
||||||
|
|
||||||
alert->Go();
|
alert->Go();
|
||||||
@@ -72,14 +72,14 @@ ExpanderApp::ArgvReceived(int32 argc, char **argv)
|
|||||||
|
|
||||||
void
|
void
|
||||||
ExpanderApp::RefsReceived(BMessage *msg)
|
ExpanderApp::RefsReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
BMessenger messenger(fWindow);
|
BMessenger messenger(fWindow);
|
||||||
msg->AddBool("fromApp", true);
|
msg->AddBool("fromApp", true);
|
||||||
messenger.SendMessage(msg);
|
messenger.SendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpanderApp::UpdateSettingsFrom(BMessage *message)
|
ExpanderApp::UpdateSettingsFrom(BMessage *message)
|
||||||
{
|
{
|
||||||
fSettings.UpdateFrom(message);
|
fSettings.UpdateFrom(message);
|
||||||
|
|||||||
@@ -10,18 +10,18 @@
|
|||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// 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.
|
// in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// 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
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -34,19 +34,19 @@
|
|||||||
#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();
|
||||||
virtual void RefsReceived(BMessage *msg);
|
virtual void RefsReceived(BMessage *msg);
|
||||||
|
|
||||||
ExpanderSettings fSettings;
|
ExpanderSettings fSettings;
|
||||||
void UpdateSettingsFrom(BMessage *message);
|
void UpdateSettingsFrom(BMessage *message);
|
||||||
private:
|
private:
|
||||||
ExpanderWindow *fWindow;
|
ExpanderWindow *fWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ExpanderApp_h */
|
#endif /* _ExpanderApp_h */
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Copyright 2004-2006, Jérôme DUVAL. All rights reserved.
|
* Copyright 2004-2006, Jérôme DUVAL. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ExpanderPreferences.h"
|
#include "ExpanderPreferences.h"
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
@@ -18,169 +18,169 @@ const uint32 MSG_DESTTEXT = 'mDet';
|
|||||||
const uint32 MSG_DESTSELECT = 'mDes';
|
const uint32 MSG_DESTSELECT = 'mDes';
|
||||||
|
|
||||||
ExpanderPreferences::ExpanderPreferences(BMessage *settings)
|
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),
|
B_NOT_CLOSABLE | B_NOT_RESIZABLE),
|
||||||
fSettings(settings),
|
fSettings(settings),
|
||||||
fUsePanel(NULL)
|
fUsePanel(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
BRect rect = Bounds();
|
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);
|
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,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
||||||
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();
|
||||||
if (stringView->Frame().right > maxWidth)
|
if (stringView->Frame().right > maxWidth)
|
||||||
maxWidth = stringView->Frame().right;
|
maxWidth = stringView->Frame().right;
|
||||||
box->AddChild(stringView);
|
box->AddChild(stringView);
|
||||||
|
|
||||||
frameRect.top = stringView->Frame().bottom + 5;
|
frameRect.top = stringView->Frame().bottom + 5;
|
||||||
frameRect.left += 10;
|
frameRect.left += 10;
|
||||||
|
|
||||||
fAutoExpand = new BCheckBox(frameRect, "autoExpand", "Automatically expand files", NULL);
|
fAutoExpand = new BCheckBox(frameRect, "autoExpand", "Automatically expand files", NULL);
|
||||||
fAutoExpand->ResizeToPreferred();
|
fAutoExpand->ResizeToPreferred();
|
||||||
if (fAutoExpand->Frame().right > maxWidth)
|
if (fAutoExpand->Frame().right > maxWidth)
|
||||||
maxWidth = fAutoExpand->Frame().right;
|
maxWidth = fAutoExpand->Frame().right;
|
||||||
box->AddChild(fAutoExpand);
|
box->AddChild(fAutoExpand);
|
||||||
|
|
||||||
frameRect = fAutoExpand->Frame();
|
frameRect = fAutoExpand->Frame();
|
||||||
frameRect.top = fAutoExpand->Frame().bottom + 1;
|
frameRect.top = fAutoExpand->Frame().bottom + 1;
|
||||||
fCloseWindow = new BCheckBox(frameRect, "closeWindowWhenDone", "Close window when done expanding", NULL);
|
fCloseWindow = new BCheckBox(frameRect, "closeWindowWhenDone", "Close window when done expanding", NULL);
|
||||||
fCloseWindow->ResizeToPreferred();
|
fCloseWindow->ResizeToPreferred();
|
||||||
if (fCloseWindow->Frame().right > maxWidth)
|
if (fCloseWindow->Frame().right > maxWidth)
|
||||||
maxWidth = fCloseWindow->Frame().right;
|
maxWidth = fCloseWindow->Frame().right;
|
||||||
box->AddChild(fCloseWindow);
|
box->AddChild(fCloseWindow);
|
||||||
|
|
||||||
frameRect = stringView->Frame();
|
frameRect = stringView->Frame();
|
||||||
frameRect.top = fCloseWindow->Frame().bottom + 10;
|
frameRect.top = fCloseWindow->Frame().bottom + 10;
|
||||||
stringView = new BStringView(frameRect, "destinationFolder", "Destination Folder:",
|
stringView = new BStringView(frameRect, "destinationFolder", "Destination Folder:",
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
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;
|
||||||
box->AddChild(stringView);
|
box->AddChild(stringView);
|
||||||
|
|
||||||
frameRect.top = stringView->Frame().bottom + 5;
|
frameRect.top = stringView->Frame().bottom + 5;
|
||||||
frameRect.left += 10;
|
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));
|
new BMessage(MSG_LEAVEDEST));
|
||||||
fLeaveDest->ResizeToPreferred();
|
fLeaveDest->ResizeToPreferred();
|
||||||
if (fLeaveDest->Frame().right > maxWidth)
|
if (fLeaveDest->Frame().right > maxWidth)
|
||||||
maxWidth = fLeaveDest->Frame().right;
|
maxWidth = fLeaveDest->Frame().right;
|
||||||
box->AddChild(fLeaveDest);
|
box->AddChild(fLeaveDest);
|
||||||
|
|
||||||
frameRect = fLeaveDest->Frame();
|
frameRect = fLeaveDest->Frame();
|
||||||
frameRect.top = fLeaveDest->Frame().bottom + 1;
|
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));
|
new BMessage(MSG_SAMEDIR));
|
||||||
fSameDest->ResizeToPreferred();
|
fSameDest->ResizeToPreferred();
|
||||||
if (fSameDest->Frame().right > maxWidth)
|
if (fSameDest->Frame().right > maxWidth)
|
||||||
maxWidth = fSameDest->Frame().right;
|
maxWidth = fSameDest->Frame().right;
|
||||||
box->AddChild(fSameDest);
|
box->AddChild(fSameDest);
|
||||||
|
|
||||||
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;
|
||||||
box->AddChild(fDestUse);
|
box->AddChild(fDestUse);
|
||||||
|
|
||||||
frameRect = fDestUse->Frame();
|
frameRect = fDestUse->Frame();
|
||||||
frameRect.left = fDestUse->Frame().right + 1;
|
frameRect.left = fDestUse->Frame().right + 1;
|
||||||
frameRect.right = frameRect.left + 58;
|
frameRect.right = frameRect.left + 58;
|
||||||
frameRect.bottom = frameRect.top + 38;
|
frameRect.bottom = frameRect.top + 38;
|
||||||
|
|
||||||
fDestText = new BTextControl(frameRect, "destText", "", "", new BMessage(MSG_DESTTEXT));
|
fDestText = new BTextControl(frameRect, "destText", "", "", new BMessage(MSG_DESTTEXT));
|
||||||
box->AddChild(fDestText);
|
box->AddChild(fDestText);
|
||||||
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);
|
||||||
|
|
||||||
frameRect = fDestText->Frame();
|
frameRect = fDestText->Frame();
|
||||||
frameRect.left = frameRect.right + 5;
|
frameRect.left = frameRect.right + 5;
|
||||||
fSelect = new BButton(frameRect, "selectButton", "Select", new BMessage(MSG_DESTSELECT));
|
fSelect = new BButton(frameRect, "selectButton", "Select", new BMessage(MSG_DESTSELECT));
|
||||||
fSelect->ResizeToPreferred();
|
fSelect->ResizeToPreferred();
|
||||||
if (fSelect->Frame().right > maxWidth)
|
if (fSelect->Frame().right > maxWidth)
|
||||||
maxWidth = fSelect->Frame().right;
|
maxWidth = fSelect->Frame().right;
|
||||||
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;
|
||||||
box->AddChild(stringView);
|
box->AddChild(stringView);
|
||||||
|
|
||||||
frameRect.top = stringView->Frame().bottom + 5;
|
frameRect.top = stringView->Frame().bottom + 5;
|
||||||
frameRect.left += 10;
|
frameRect.left += 10;
|
||||||
|
|
||||||
fOpenDest = new BCheckBox(frameRect, "openDestination", "Open destination folder after extraction", NULL);
|
fOpenDest = new BCheckBox(frameRect, "openDestination", "Open destination folder after extraction", NULL);
|
||||||
fOpenDest->ResizeToPreferred();
|
fOpenDest->ResizeToPreferred();
|
||||||
if (fOpenDest->Frame().right > maxWidth)
|
if (fOpenDest->Frame().right > maxWidth)
|
||||||
maxWidth = fOpenDest->Frame().right;
|
maxWidth = fOpenDest->Frame().right;
|
||||||
box->AddChild(fOpenDest);
|
box->AddChild(fOpenDest);
|
||||||
|
|
||||||
frameRect = fOpenDest->Frame();
|
frameRect = fOpenDest->Frame();
|
||||||
frameRect.top = frameRect.bottom + 1;
|
frameRect.top = frameRect.bottom + 1;
|
||||||
fAutoShow = new BCheckBox(frameRect, "autoShow", "Automatically show contents listing", NULL);
|
fAutoShow = new BCheckBox(frameRect, "autoShow", "Automatically show contents listing", NULL);
|
||||||
fAutoShow->ResizeToPreferred();
|
fAutoShow->ResizeToPreferred();
|
||||||
if (fAutoShow->Frame().right > maxWidth)
|
if (fAutoShow->Frame().right > maxWidth)
|
||||||
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;
|
||||||
int8 destination_folder;
|
int8 destination_folder;
|
||||||
@@ -190,11 +190,11 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
|
|||||||
if ((settings->FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
|
if ((settings->FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
|
||||||
&& automatically_expand_files)
|
&& automatically_expand_files)
|
||||||
fAutoExpand->SetValue(B_CONTROL_ON);
|
fAutoExpand->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
if ((settings->FindBool("close_when_done", &close_when_done) == B_OK)
|
if ((settings->FindBool("close_when_done", &close_when_done) == B_OK)
|
||||||
&& close_when_done)
|
&& close_when_done)
|
||||||
fCloseWindow->SetValue(B_CONTROL_ON);
|
fCloseWindow->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
if (settings->FindInt8("destination_folder", &destination_folder) == B_OK) {
|
if (settings->FindInt8("destination_folder", &destination_folder) == B_OK) {
|
||||||
switch (destination_folder) {
|
switch (destination_folder) {
|
||||||
case 0x63:
|
case 0x63:
|
||||||
@@ -210,21 +210,21 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->FindRef("destination_folder_use", &fRef) == B_OK) {
|
if (settings->FindRef("destination_folder_use", &fRef) == B_OK) {
|
||||||
BEntry entry(&fRef);
|
BEntry entry(&fRef);
|
||||||
if (entry.Exists()) {
|
if (entry.Exists()) {
|
||||||
BPath path(&entry);
|
BPath path(&entry);
|
||||||
fDestText->SetText(path.Path());
|
fDestText->SetText(path.Path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((settings->FindBool("open_destination_folder", &open_destination_folder) == B_OK)
|
if ((settings->FindBool("open_destination_folder", &open_destination_folder) == B_OK)
|
||||||
&& open_destination_folder)
|
&& open_destination_folder)
|
||||||
fOpenDest->SetValue(B_CONTROL_ON);
|
fOpenDest->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
if ((settings->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
|
if ((settings->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
|
||||||
&& show_contents_listing)
|
&& show_contents_listing)
|
||||||
fAutoShow->SetValue(B_CONTROL_ON);
|
fAutoShow->SetValue(B_CONTROL_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,21 +240,21 @@ ExpanderPreferences::MessageReceived(BMessage *msg)
|
|||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case MSG_DESTSELECT:
|
case MSG_DESTSELECT:
|
||||||
if (!fUsePanel)
|
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);
|
B_DIRECTORY_NODE, false, NULL, new DirectoryRefFilter(), true);
|
||||||
fUsePanel->Show();
|
fUsePanel->Show();
|
||||||
break;
|
break;
|
||||||
case MSG_DIRECTORY:
|
case MSG_DIRECTORY:
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
fUsePanel->GetPanelDirectory(&ref);
|
fUsePanel->GetPanelDirectory(&ref);
|
||||||
fRef = ref;
|
fRef = ref;
|
||||||
BEntry entry(&ref);
|
BEntry entry(&ref);
|
||||||
BPath path(&entry);
|
BPath path(&entry);
|
||||||
fDestText->SetText(path.Path());
|
fDestText->SetText(path.Path());
|
||||||
fUsePanel->Hide();
|
fUsePanel->Hide();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
if (msg->FindRef("refs", 0, &fRef) == B_OK) {
|
if (msg->FindRef("refs", 0, &fRef) == B_OK) {
|
||||||
BEntry entry(&fRef, true);
|
BEntry entry(&fRef, true);
|
||||||
@@ -278,8 +278,8 @@ ExpanderPreferences::MessageReceived(BMessage *msg)
|
|||||||
case MSG_OK:
|
case MSG_OK:
|
||||||
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);
|
||||||
|
|||||||
@@ -10,18 +10,18 @@
|
|||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// 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.
|
// in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// 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
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -39,19 +39,19 @@
|
|||||||
#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;
|
||||||
BButton *fSelect;
|
BButton *fSelect;
|
||||||
BTextControl *fDestText;
|
BTextControl *fDestText;
|
||||||
entry_ref fRef;
|
entry_ref fRef;
|
||||||
DirectoryFilePanel *fUsePanel;
|
DirectoryFilePanel *fUsePanel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ExpanderPreferences_h */
|
#endif /* _ExpanderPreferences_h */
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
ExpanderRule::ExpanderRule(BString mimetype, BString filenameExtension,
|
ExpanderRule::ExpanderRule(BString mimetype, BString filenameExtension,
|
||||||
BString listingCmd, BString expandCmd)
|
BString listingCmd, BString expandCmd)
|
||||||
:
|
:
|
||||||
fMimeType(mimetype.String()),
|
fMimeType(mimetype.String()),
|
||||||
fFilenameExtension(filenameExtension),
|
fFilenameExtension(filenameExtension),
|
||||||
@@ -26,7 +26,7 @@ ExpanderRule::ExpanderRule(BString mimetype, BString filenameExtension,
|
|||||||
|
|
||||||
|
|
||||||
ExpanderRule::ExpanderRule(const char* mimetype, const char* filenameExtension,
|
ExpanderRule::ExpanderRule(const char* mimetype, const char* filenameExtension,
|
||||||
const char* listingCmd, const char* expandCmd)
|
const char* listingCmd, const char* expandCmd)
|
||||||
:
|
:
|
||||||
fMimeType(mimetype),
|
fMimeType(mimetype),
|
||||||
fFilenameExtension(filenameExtension),
|
fFilenameExtension(filenameExtension),
|
||||||
@@ -58,31 +58,31 @@ 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;
|
||||||
} else
|
} else
|
||||||
firstQuote = i;
|
firstQuote = i;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (j == 4) {
|
if (j == 4) {
|
||||||
fList.AddItem(new ExpanderRule(strings[0], strings[1], strings[2], strings[3]));
|
fList.AddItem(new ExpanderRule(strings[0], strings[1], strings[2], strings[3]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
close(fd);
|
close(fd);
|
||||||
@@ -97,7 +97,7 @@ ExpanderRules::~ExpanderRules()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ExpanderRules::Open(BFile *file)
|
ExpanderRules::Open(BFile *file)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
@@ -107,13 +107,13 @@ ExpanderRules::Open(BFile *file)
|
|||||||
path.Append("etc/expander.rules");
|
path.Append("etc/expander.rules");
|
||||||
if (file->SetTo(path.Path(), B_READ_ONLY) == B_OK)
|
if (file->SetTo(path.Path(), B_READ_ONLY) == B_OK)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
if (find_directory(B_COMMON_ETC_DIRECTORY, &path) != B_OK)
|
if (find_directory(B_COMMON_ETC_DIRECTORY, &path) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
path.Append("expander.rules");
|
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 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())))
|
||||||
@@ -141,7 +141,7 @@ ExpanderRules::MatchingRule(const entry_ref *ref)
|
|||||||
char type[B_MIME_TYPE_LENGTH];
|
char type[B_MIME_TYPE_LENGTH];
|
||||||
nodeInfo.GetType(type);
|
nodeInfo.GetType(type);
|
||||||
BString fileName(ref->name);
|
BString fileName(ref->name);
|
||||||
return MatchingRule(fileName, type);
|
return MatchingRule(fileName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ RuleRefFilter::RuleRefFilter(ExpanderRules &rules)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
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)
|
const char *filetype)
|
||||||
{
|
{
|
||||||
if (node->IsDirectory() || node->IsSymLink())
|
if (node->IsDirectory() || node->IsSymLink())
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
class ExpanderRule {
|
class ExpanderRule {
|
||||||
public:
|
public:
|
||||||
ExpanderRule(BString mimetype, BString filenameExtension,
|
ExpanderRule(BString mimetype, BString filenameExtension,
|
||||||
BString listingCmd, BString expandCmd);
|
BString listingCmd, BString expandCmd);
|
||||||
ExpanderRule(const char* mimetype, const char* filenameExtension,
|
ExpanderRule(const char* mimetype, const char* filenameExtension,
|
||||||
const char* listingCmd, const char* expandCmd);
|
const char* listingCmd, const char* expandCmd);
|
||||||
BMimeType &MimeType() { return fMimeType;}
|
BMimeType &MimeType() { return fMimeType;}
|
||||||
BString &FilenameExtension() { return fFilenameExtension;}
|
BString &FilenameExtension() { return fFilenameExtension;}
|
||||||
@@ -46,7 +46,7 @@ class ExpanderRules {
|
|||||||
class RuleRefFilter : public BRefFilter {
|
class RuleRefFilter : public BRefFilter {
|
||||||
public:
|
public:
|
||||||
RuleRefFilter(ExpanderRules &rules);
|
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);
|
const char *filetype);
|
||||||
protected:
|
protected:
|
||||||
ExpanderRules &fRules;
|
ExpanderRules &fRules;
|
||||||
|
|||||||
@@ -11,18 +11,18 @@
|
|||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// 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.
|
// in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// 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
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
// 1st byte : unknown (0x1)
|
// 1st byte : unknown (0x1)
|
||||||
// 2nd byte : Automatically expand files (default : 0x0)
|
// 2nd byte : Automatically expand files (default : 0x0)
|
||||||
// 3rd byte : Close when done (default : 0x0)
|
// 3rd byte : Close when done (default : 0x0)
|
||||||
// 4th byte : 0x66
|
// 4th byte : 0x66
|
||||||
// 0x63 (default)
|
// 0x63 (default)
|
||||||
// 0x65
|
// 0x65
|
||||||
// 5th byte : unknown (0x0)
|
// 5th byte : unknown (0x0)
|
||||||
@@ -91,13 +91,13 @@ 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))
|
||||||
&& (file.Read(&position, sizeof(position)) == sizeof(position))
|
&& (file.Read(&position, sizeof(position)) == sizeof(position))
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// check if the window position is on screen at all
|
// check if the window position is on screen at all
|
||||||
BScreen screen;
|
BScreen screen;
|
||||||
if (screen.Frame().Contains(position))
|
if (screen.Frame().Contains(position))
|
||||||
@@ -105,16 +105,16 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ ExpanderSettings::~ExpanderSettings()
|
|||||||
BFile file;
|
BFile file;
|
||||||
if (Open(&file, B_CREATE_FILE | B_WRITE_ONLY) != B_OK)
|
if (Open(&file, B_CREATE_FILE | B_WRITE_ONLY) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool automatically_expand_files;
|
bool automatically_expand_files;
|
||||||
bool close_when_done;
|
bool close_when_done;
|
||||||
int8 destination_folder;
|
int8 destination_folder;
|
||||||
@@ -136,15 +136,15 @@ ExpanderSettings::~ExpanderSettings()
|
|||||||
bool show_contents_listing;
|
bool show_contents_listing;
|
||||||
BPoint position;
|
BPoint position;
|
||||||
bool unknown = 1;
|
bool unknown = 1;
|
||||||
|
|
||||||
if ((fMessage.FindPoint("window_position", &position) == B_OK)
|
if ((fMessage.FindPoint("window_position", &position) == B_OK)
|
||||||
&& (fMessage.FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
|
&& (fMessage.FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
|
||||||
&& (fMessage.FindBool("close_when_done", &close_when_done) == B_OK)
|
&& (fMessage.FindBool("close_when_done", &close_when_done) == B_OK)
|
||||||
&& (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));
|
||||||
file.Write(&close_when_done, sizeof(close_when_done));
|
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.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);
|
||||||
@@ -166,7 +166,7 @@ ExpanderSettings::~ExpanderSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ExpanderSettings::Open(BFile *file, int32 mode)
|
ExpanderSettings::Open(BFile *file, int32 mode)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
@@ -179,7 +179,7 @@ ExpanderSettings::Open(BFile *file, int32 mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpanderSettings::UpdateFrom(BMessage *message)
|
ExpanderSettings::UpdateFrom(BMessage *message)
|
||||||
{
|
{
|
||||||
bool automatically_expand_files;
|
bool automatically_expand_files;
|
||||||
@@ -189,27 +189,27 @@ ExpanderSettings::UpdateFrom(BMessage *message)
|
|||||||
bool open_destination_folder;
|
bool open_destination_folder;
|
||||||
bool show_contents_listing;
|
bool show_contents_listing;
|
||||||
BPoint position;
|
BPoint position;
|
||||||
|
|
||||||
if (message->FindPoint("window_position", &position) == B_OK)
|
if (message->FindPoint("window_position", &position) == B_OK)
|
||||||
fMessage.ReplacePoint("window_position", position);
|
fMessage.ReplacePoint("window_position", position);
|
||||||
|
|
||||||
if (message->FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
|
if (message->FindBool("automatically_expand_files", &automatically_expand_files) == B_OK)
|
||||||
fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files);
|
fMessage.ReplaceBool("automatically_expand_files", automatically_expand_files);
|
||||||
|
|
||||||
if (message->FindBool("close_when_done", &close_when_done) == B_OK)
|
if (message->FindBool("close_when_done", &close_when_done) == B_OK)
|
||||||
fMessage.ReplaceBool("close_when_done", close_when_done);
|
fMessage.ReplaceBool("close_when_done", close_when_done);
|
||||||
|
|
||||||
if (message->FindInt8("destination_folder", &destination_folder) == B_OK)
|
if (message->FindInt8("destination_folder", &destination_folder) == B_OK)
|
||||||
fMessage.ReplaceInt8("destination_folder", destination_folder);
|
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);
|
fMessage.ReplaceRef("destination_folder_use", &ref);
|
||||||
|
|
||||||
if (message->FindBool("open_destination_folder", &open_destination_folder) == B_OK)
|
if (message->FindBool("open_destination_folder", &open_destination_folder) == B_OK)
|
||||||
fMessage.ReplaceBool("open_destination_folder", open_destination_folder);
|
fMessage.ReplaceBool("open_destination_folder", open_destination_folder);
|
||||||
|
|
||||||
if (message->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
|
if (message->FindBool("show_contents_listing", &show_contents_listing) == B_OK)
|
||||||
fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
|
fMessage.ReplaceBool("show_contents_listing", show_contents_listing);
|
||||||
|
|
||||||
fUpdated = true;
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,18 +10,18 @@
|
|||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// 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.
|
// in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// 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
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
@@ -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,12 +24,12 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpanderThread::~ExpanderThread()
|
ExpanderThread::~ExpanderThread()
|
||||||
{
|
{
|
||||||
delete fWindowMessenger;
|
delete fWindowMessenger;
|
||||||
delete [] fExpanderOutputBuffer;
|
delete [] fExpanderOutputBuffer;
|
||||||
@@ -41,64 +41,64 @@ ExpanderThread::ThreadStartup()
|
|||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
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);
|
||||||
BString pathString(path.Path());
|
BString pathString(path.Path());
|
||||||
pathString.CharacterEscape("\"$`", '\\');
|
pathString.CharacterEscape("\"$`", '\\');
|
||||||
pathString.Prepend("\"");
|
pathString.Prepend("\"");
|
||||||
pathString.Append("\"");
|
pathString.Append("\"");
|
||||||
cmd.ReplaceAll("%s", pathString.String());
|
cmd.ReplaceAll("%s", pathString.String());
|
||||||
|
|
||||||
int32 argc = 3;
|
int32 argc = 3;
|
||||||
const char ** argv = new const char * [argc + 1];
|
const char ** argv = new const char * [argc + 1];
|
||||||
|
|
||||||
argv[0] = strdup("/bin/sh");
|
argv[0] = strdup("/bin/sh");
|
||||||
argv[1] = strdup("-c");
|
argv[1] = strdup("-c");
|
||||||
argv[2] = strdup(cmd.String());
|
argv[2] = strdup(cmd.String());
|
||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
|
|
||||||
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);
|
fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);
|
||||||
|
|
||||||
delete [] argv;
|
delete [] argv;
|
||||||
|
|
||||||
if (fThreadId < 0)
|
if (fThreadId < 0)
|
||||||
return fThreadId;
|
return fThreadId;
|
||||||
|
|
||||||
resume_thread(fThreadId);
|
resume_thread(fThreadId);
|
||||||
|
|
||||||
fExpanderOutput = fdopen(fStdOut, "r");
|
fExpanderOutput = fdopen(fStdOut, "r");
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
fWindowMessenger->SendMessage(&message);
|
fWindowMessenger->SendMessage(&message);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -108,8 +108,8 @@ status_t
|
|||||||
ExpanderThread::ThreadShutdown(void)
|
ExpanderThread::ThreadShutdown(void)
|
||||||
{
|
{
|
||||||
close(fStdIn);
|
close(fStdIn);
|
||||||
close(fStdOut);
|
close(fStdOut);
|
||||||
close(fStdErr);
|
close(fStdErr);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ ExpanderThread::ExecuteUnitFailed(status_t status)
|
|||||||
// explicit error - communicate error to Window
|
// explicit error - communicate error to Window
|
||||||
fWindowMessenger->SendMessage(new BMessage('exrr'));
|
fWindowMessenger->SendMessage(new BMessage('exrr'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,56 +150,56 @@ ExpanderThread::ProcessRefs(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
thread_id
|
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]>
|
// 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
|
// http://www.abisoft.com/faq/BeDevTalk_FAQ.html#FAQ-209
|
||||||
|
|
||||||
// Save current FDs
|
// Save current FDs
|
||||||
int old_in = dup(0);
|
int old_in = dup(0);
|
||||||
int old_out = dup(1);
|
int old_out = dup(1);
|
||||||
int old_err = dup(2);
|
int old_err = dup(2);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (ret < B_OK)
|
if (ret < B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
// thread ret is now suspended.
|
// thread ret is now suspended.
|
||||||
|
|
||||||
setpgid(ret, ret);
|
setpgid(ret, ret);
|
||||||
|
|
||||||
// Restore old FDs
|
// Restore old FDs
|
||||||
close(0); dup(old_in); close(old_in);
|
close(0); dup(old_in); close(old_in);
|
||||||
close(1); dup(old_out); close(old_out);
|
close(1); dup(old_out); close(old_out);
|
||||||
close(2); dup(old_err); close(old_err);
|
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. */
|
|
||||||
|
|
||||||
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
|
status_t
|
||||||
ExpanderThread::SuspendExternalExpander()
|
ExpanderThread::SuspendExternalExpander()
|
||||||
{
|
{
|
||||||
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)
|
||||||
return send_signal(-fThreadId, SIGSTOP);
|
return send_signal(-fThreadId, SIGSTOP);
|
||||||
else
|
else
|
||||||
@@ -207,11 +207,11 @@ ExpanderThread::SuspendExternalExpander()
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ExpanderThread::ResumeExternalExpander()
|
ExpanderThread::ResumeExternalExpander()
|
||||||
{
|
{
|
||||||
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)
|
||||||
return send_signal(-fThreadId, SIGCONT);
|
return send_signal(-fThreadId, SIGCONT);
|
||||||
else
|
else
|
||||||
@@ -219,11 +219,11 @@ ExpanderThread::ResumeExternalExpander()
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
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);
|
||||||
WaitOnExternalExpander();
|
WaitOnExternalExpander();
|
||||||
@@ -232,11 +232,11 @@ ExpanderThread::InterruptExternalExpander()
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ExpanderThread::WaitOnExternalExpander()
|
ExpanderThread::WaitOnExternalExpander()
|
||||||
{
|
{
|
||||||
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)
|
||||||
return wait_for_thread(fThreadId, &status);
|
return wait_for_thread(fThreadId, &status);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -9,18 +9,18 @@
|
|||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
// 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:
|
// 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.
|
// in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// 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
|
// 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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
|
||||||
#include "GenericThread.h"
|
#include "GenericThread.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -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,22 +51,22 @@ 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();
|
||||||
virtual status_t ThreadShutdown();
|
virtual status_t ThreadShutdown();
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
status_t ProcessRefs(BMessage * msg);
|
status_t ProcessRefs(BMessage * msg);
|
||||||
|
|
||||||
thread_id PipeCommand(int argc, const char **argv,
|
thread_id PipeCommand(int argc, const char **argv,
|
||||||
int & in, int & out, int & err,
|
int & in, int & out, int & err,
|
||||||
const char **envp = (const char **) environ);
|
const char **envp = (const char **) environ);
|
||||||
|
|
||||||
BMessenger * fWindowMessenger;
|
BMessenger * fWindowMessenger;
|
||||||
|
|
||||||
thread_id fThreadId;
|
thread_id fThreadId;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
|
|||||||
fSourcePanel = NULL;
|
fSourcePanel = NULL;
|
||||||
fDestPanel = NULL;
|
fDestPanel = NULL;
|
||||||
|
|
||||||
// create menu bar
|
// create menu bar
|
||||||
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
|
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
|
||||||
BMenu *menu = new BMenu("File");
|
BMenu *menu = new BMenu("File");
|
||||||
BMenuItem *item;
|
BMenuItem *item;
|
||||||
@@ -84,7 +84,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
|
|||||||
// Buttons
|
// Buttons
|
||||||
|
|
||||||
rect = topView->Bounds().InsetByCopy(8, 8);
|
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);
|
new BMessage(MSG_DEST), B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
||||||
fDestButton->ResizeToPreferred();
|
fDestButton->ResizeToPreferred();
|
||||||
topView->AddChild(fDestButton);
|
topView->AddChild(fDestButton);
|
||||||
@@ -92,13 +92,13 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
|
|||||||
rect = fDestButton->Frame();
|
rect = fDestButton->Frame();
|
||||||
fDestButton->MoveBy(0, rect.Height() + 4);
|
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);
|
new BMessage(MSG_SOURCE), B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
||||||
topView->AddChild(fSourceButton);
|
topView->AddChild(fSourceButton);
|
||||||
|
|
||||||
rect = fDestButton->Frame();
|
rect = fDestButton->Frame();
|
||||||
rect.OffsetBy(0, rect.Height() + 4);
|
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);
|
new BMessage(MSG_EXPAND), B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
||||||
topView->AddChild(fExpandButton);
|
topView->AddChild(fExpandButton);
|
||||||
fExpandButton->SetEnabled(false);
|
fExpandButton->SetEnabled(false);
|
||||||
@@ -108,7 +108,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
|
|||||||
rect = fSourceButton->Frame();
|
rect = fSourceButton->Frame();
|
||||||
rect.left = rect.right + 8;
|
rect.left = rect.right + 8;
|
||||||
rect.right = frame.Width() - 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);
|
new BMessage(MSG_SOURCETEXT), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
fSourceText->SetDivider(0);
|
fSourceText->SetDivider(0);
|
||||||
float width, height;
|
float width, height;
|
||||||
@@ -120,13 +120,13 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
|
|||||||
|
|
||||||
rect = fSourceText->Frame();
|
rect = fSourceText->Frame();
|
||||||
rect.OffsetBy(0, fSourceButton->Bounds().Height() + 4);
|
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);
|
new BMessage(MSG_DESTTEXT), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
fDestText->SetDivider(0);
|
fDestText->SetDivider(0);
|
||||||
topView->AddChild(fDestText);
|
topView->AddChild(fDestText);
|
||||||
|
|
||||||
rect.OffsetBy(0, fSourceButton->Bounds().Height() + 4 + offset);
|
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);
|
new BMessage(MSG_SHOWCONTENTS), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
fShowContents->ResizeToPreferred();
|
fShowContents->ResizeToPreferred();
|
||||||
fShowContents->MoveTo(Bounds().right - 8 - fShowContents->Bounds().Width(),
|
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);
|
be_fixed_font, NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
fListingText->SetText("");
|
fListingText->SetText("");
|
||||||
fListingText->MakeEditable(false);
|
fListingText->MakeEditable(false);
|
||||||
fListingScroll = new BScrollView("listingScroll", fListingText,
|
fListingScroll = new BScrollView("listingScroll", fListingText,
|
||||||
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
||||||
topView->AddChild(fListingScroll);
|
topView->AddChild(fListingScroll);
|
||||||
fListingScroll->Hide();
|
fListingScroll->Hide();
|
||||||
@@ -191,7 +191,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case MSG_SOURCE:
|
case MSG_SOURCE:
|
||||||
if (!fSourcePanel) {
|
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);
|
B_FILE_NODE, false, NULL, new RuleRefFilter(fRules), true);
|
||||||
}
|
}
|
||||||
fSourcePanel->Show();
|
fSourcePanel->Show();
|
||||||
@@ -199,7 +199,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
case MSG_DEST:
|
case MSG_DEST:
|
||||||
if (!fDestPanel) {
|
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);
|
B_DIRECTORY_NODE, false, NULL, new DirectoryRefFilter(), true);
|
||||||
}
|
}
|
||||||
fDestPanel->Show();
|
fDestPanel->Show();
|
||||||
@@ -225,16 +225,16 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
case MSG_EXPAND:
|
case MSG_EXPAND:
|
||||||
if (!fExpandingStarted) {
|
if (!fExpandingStarted) {
|
||||||
StartExpanding();
|
StartExpanding();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// supposed to fall through
|
// supposed to fall through
|
||||||
case MSG_STOP:
|
case MSG_STOP:
|
||||||
if (fExpandingStarted) {
|
if (fExpandingStarted) {
|
||||||
fExpandingThread->SuspendExternalExpander();
|
fExpandingThread->SuspendExternalExpander();
|
||||||
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
|
||||||
@@ -250,67 +250,67 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
// change menu item label
|
// change menu item label
|
||||||
fShowItem->SetLabel(fShowContents->Value() == B_CONTROL_OFF
|
fShowItem->SetLabel(fShowContents->Value() == B_CONTROL_OFF
|
||||||
? "Show Contents" : "Hide Contents");
|
? "Show Contents" : "Hide Contents");
|
||||||
|
|
||||||
if (fShowContents->Value() == B_CONTROL_OFF) {
|
if (fShowContents->Value() == B_CONTROL_OFF) {
|
||||||
if (fListingStarted)
|
if (fListingStarted)
|
||||||
StopListing();
|
StopListing();
|
||||||
|
|
||||||
_UpdateWindowSize(false);
|
_UpdateWindowSize(false);
|
||||||
} else
|
} else
|
||||||
StartListing();
|
StartListing();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_SOURCETEXT:
|
case MSG_SOURCETEXT:
|
||||||
{
|
{
|
||||||
BEntry entry(fSourceText->Text(), true);
|
BEntry entry(fSourceText->Text(), true);
|
||||||
if (!entry.Exists()) {
|
if (!entry.Exists()) {
|
||||||
BAlert *alert = new BAlert("srcAlert", "The file doesn't exist",
|
BAlert *alert = new BAlert("srcAlert", "The file doesn't exist",
|
||||||
"Cancel", NULL, NULL,
|
"Cancel", NULL, NULL,
|
||||||
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
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();
|
alert->Go();
|
||||||
|
break;
|
||||||
fShowContents->SetEnabled(false);
|
|
||||||
fExpandButton->SetEnabled(false);
|
|
||||||
fExpandItem->SetEnabled(false);
|
|
||||||
fShowItem->SetEnabled(false);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case MSG_DESTTEXT:
|
entry_ref ref;
|
||||||
{
|
entry.GetRef(&ref);
|
||||||
BEntry entry(fDestText->Text(), true);
|
ExpanderRule *rule = fRules.MatchingRule(&ref);
|
||||||
if (!entry.Exists()) {
|
if (rule) {
|
||||||
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
|
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.",
|
"supported.",
|
||||||
"Cancel", NULL, NULL,
|
"Cancel", NULL, NULL,
|
||||||
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
entry.GetRef(&fDestRef);
|
|
||||||
}
|
}
|
||||||
break;
|
entry.GetRef(&fDestRef);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MSG_PREFERENCES:
|
case MSG_PREFERENCES:
|
||||||
if (!fPreferences)
|
if (!fPreferences)
|
||||||
fPreferences = new ExpanderPreferences(&fSettings);
|
fPreferences = new ExpanderPreferences(&fSettings);
|
||||||
@@ -319,12 +319,12 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'exit': // thread has finished (finished, quit, killed, we don't know)
|
case 'exit': // thread has finished (finished, quit, killed, we don't know)
|
||||||
// reset window state
|
// reset window state
|
||||||
@@ -362,9 +362,9 @@ ExpanderWindow::CanQuit()
|
|||||||
if (fExpandingStarted) {
|
if (fExpandingStarted) {
|
||||||
fExpandingThread->SuspendExternalExpander();
|
fExpandingThread->SuspendExternalExpander();
|
||||||
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);
|
||||||
@@ -428,7 +428,7 @@ ExpanderWindow::RefsReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fShowContents->Value() == B_CONTROL_ON) {
|
if (fShowContents->Value() == B_CONTROL_ON) {
|
||||||
StopListing();
|
StopListing();
|
||||||
StartListing();
|
StartListing();
|
||||||
} else {
|
} else {
|
||||||
fShowContents->SetEnabled(true);
|
fShowContents->SetEnabled(true);
|
||||||
@@ -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());
|
||||||
}
|
}
|
||||||
@@ -458,9 +458,9 @@ ExpanderWindow::StartExpanding()
|
|||||||
BEntry destEntry(fDestText->Text(), true);
|
BEntry destEntry(fDestText->Text(), true);
|
||||||
if (!destEntry.Exists()) {
|
if (!destEntry.Exists()) {
|
||||||
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
|
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
|
||||||
"supported.",
|
"supported.",
|
||||||
"Cancel", NULL, NULL,
|
"Cancel", NULL, NULL,
|
||||||
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -606,7 +606,7 @@ ExpanderWindow::StopListing(void)
|
|||||||
fShowItem->SetEnabled(true);
|
fShowItem->SetEnabled(true);
|
||||||
fStopItem->SetEnabled(false);
|
fStopItem->SetEnabled(false);
|
||||||
fPreferencesItem->SetEnabled(true);
|
fPreferencesItem->SetEnabled(true);
|
||||||
|
|
||||||
fSourceButton->SetEnabled(true);
|
fSourceButton->SetEnabled(true);
|
||||||
fDestButton->SetEnabled(true);
|
fDestButton->SetEnabled(true);
|
||||||
fExpandButton->SetEnabled(true);
|
fExpandButton->SetEnabled(true);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class ExpanderWindow : public BWindow {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool CanQuit();
|
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 CloseWindowOrKeepOpen();
|
||||||
void OpenDestFolder();
|
void OpenDestFolder();
|
||||||
void AutoListing();
|
void AutoListing();
|
||||||
@@ -57,22 +57,22 @@ class ExpanderWindow : public BWindow {
|
|||||||
entry_ref fSourceRef;
|
entry_ref fSourceRef;
|
||||||
entry_ref fDestRef;
|
entry_ref fDestRef;
|
||||||
bool fSourceChanged;
|
bool fSourceChanged;
|
||||||
|
|
||||||
BButton *fSourceButton, *fDestButton, *fExpandButton;
|
BButton *fSourceButton, *fDestButton, *fExpandButton;
|
||||||
BMenuItem *fExpandItem, *fShowItem, *fStopItem,
|
BMenuItem *fExpandItem, *fShowItem, *fStopItem,
|
||||||
*fSourceItem, *fDestItem, *fPreferencesItem;
|
*fSourceItem, *fDestItem, *fPreferencesItem;
|
||||||
BCheckBox *fShowContents;
|
BCheckBox *fShowContents;
|
||||||
BTextControl *fSourceText, *fDestText;
|
BTextControl *fSourceText, *fDestText;
|
||||||
BStringView* fStatusView;
|
BStringView* fStatusView;
|
||||||
BTextView *fListingText;
|
BTextView *fListingText;
|
||||||
BScrollView *fListingScroll;
|
BScrollView *fListingScroll;
|
||||||
|
|
||||||
ExpanderThread *fListingThread;
|
ExpanderThread *fListingThread;
|
||||||
bool fListingStarted;
|
bool fListingStarted;
|
||||||
|
|
||||||
ExpanderThread *fExpandingThread;
|
ExpanderThread *fExpandingThread;
|
||||||
bool fExpandingStarted;
|
bool fExpandingStarted;
|
||||||
|
|
||||||
BMessage fSettings;
|
BMessage fSettings;
|
||||||
ExpanderPreferences *fPreferences;
|
ExpanderPreferences *fPreferences;
|
||||||
ExpanderRules fRules;
|
ExpanderRules fRules;
|
||||||
|
|||||||
+124
-124
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
#include "GenericThread.h"
|
#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_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();
|
||||||
@@ -18,35 +18,35 @@ GenericThread::GenericThread(const char * a_thread_name, int32 a_priority, BMess
|
|||||||
GenericThread::~GenericThread()
|
GenericThread::~GenericThread()
|
||||||
{
|
{
|
||||||
kill_thread(m_thread_id);
|
kill_thread(m_thread_id);
|
||||||
|
|
||||||
delete_sem(m_execute_unit);
|
delete_sem(m_execute_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
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?
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this; // destructor
|
delete this; // destructor
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,16 +55,16 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (B_OK);
|
return (B_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
@@ -73,8 +73,8 @@ GenericThread::ThreadStartup (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GenericThread::ExecuteUnit (void)
|
GenericThread::ExecuteUnit(void)
|
||||||
{
|
{
|
||||||
// This function is virtual.
|
// This function is virtual.
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@ GenericThread::ExecuteUnit (void)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
@@ -94,54 +94,54 @@ GenericThread::ThreadShutdown (void)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
// (is this good default behaviour?)
|
// (is this good default behaviour?)
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -150,236 +150,236 @@ GenericThread::private_thread_function (void * a_simple_thread_ptr)
|
|||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
if (a_do_block)
|
if (a_do_block)
|
||||||
status = acquire_sem(m_execute_unit);
|
status = acquire_sem(m_execute_unit);
|
||||||
// thread will wait on semaphore
|
// thread will wait on semaphore
|
||||||
else
|
else
|
||||||
status = acquire_sem_etc(m_execute_unit, 1, B_RELATIVE_TIMEOUT, a_timeout);
|
status = acquire_sem_etc(m_execute_unit, 1, B_RELATIVE_TIMEOUT, a_timeout);
|
||||||
// thread will timeout
|
// thread will timeout
|
||||||
|
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
{
|
{
|
||||||
m_thread_is_paused = true;
|
m_thread_is_paused = true;
|
||||||
return (B_OK);
|
return (B_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
return (resume_thread(m_thread_id)); // to counteract Suspend()
|
return (resume_thread(m_thread_id)); // to counteract Suspend()
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
Resume();
|
Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
Resume();
|
Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,72 +7,72 @@
|
|||||||
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 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);
|
status_t Suspend(void);
|
||||||
void SnoozeUntil (bigtime_t a_microseconds, int a_timebase = B_SYSTEM_TIMEBASE);
|
status_t Resume(void);
|
||||||
|
status_t Kill(void);
|
||||||
|
|
||||||
status_t GetInfo (thread_info * a_thread_info);
|
void ExitWithReturnValue(status_t a_return_value);
|
||||||
thread_id GetThread (void);
|
status_t SetExitCallback(void(* a_callback)(void *), void * a_data);
|
||||||
team_id GetTeam (void);
|
status_t WaitForThread(status_t * a_exit_value);
|
||||||
char * GetName (void);
|
|
||||||
thread_state GetState (void);
|
status_t Rename(char * a_name);
|
||||||
sem_id GetSemaphore (void);
|
|
||||||
int32 GetPriority (void);
|
status_t SendData(int32 a_code, void * a_buffer, size_t a_buffer_size);
|
||||||
bigtime_t GetUserTime (void);
|
int32 ReceiveData(thread_id * a_sender, void * a_buffer, size_t a_buffer_size);
|
||||||
bigtime_t GetKernelTime (void);
|
bool HasData(void);
|
||||||
void * GetStackBase (void);
|
|
||||||
void * GetStackEnd (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:
|
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 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;
|
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;
|
||||||
|
|
||||||
sem_id m_execute_unit; // acq./relase within tread_function.. For Pause()
|
sem_id m_execute_unit; // acq./relase within tread_function.. For Pause()
|
||||||
|
|
||||||
bool m_quit_requested;
|
bool m_quit_requested;
|
||||||
|
|||||||
Reference in New Issue
Block a user