Merge branch 'master' into sam460ex
This commit is contained in:
+17
-17
@@ -135,7 +135,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Initialization was successful.
|
||||
\retval B_BAD_VALUE \c NULL \a ref.
|
||||
\retval B_BAD_VALUE \a ref was \c NULL.
|
||||
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
|
||||
*/
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Initialization was successful.
|
||||
\retval B_BAD_VALUE \c NULL \a ref.
|
||||
\retval B_BAD_VALUE \a ref was \c NULL.
|
||||
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
|
||||
*/
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Initialization was successful.
|
||||
\retval B_BAD_VALUE \c NULL \a ref.
|
||||
\retval B_BAD_VALUE \a ref was \c NULL.
|
||||
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
|
||||
*/
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Initialization was successful.
|
||||
\retval B_BAD_VALUE \c NULL \a ref.
|
||||
\retval B_BAD_VALUE \a ref was \c NULL.
|
||||
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
|
||||
*/
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Initialization was successful.
|
||||
\retval B_BAD_VALUE \c NULL \a ref.
|
||||
\retval B_BAD_VALUE \a ref was \c NULL.
|
||||
\retval B_NAME_TOO_LONG The pathname was longer than \c B_PATH_NAME_LENGTH.
|
||||
*/
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_BAD_VALUE \c NULL \a path.
|
||||
\retval B_BAD_VALUE \a path was \c NULL.
|
||||
\retval B_ENTRY_NOT_FOUND The BPath object represents the root path and
|
||||
thus has no parent.
|
||||
*/
|
||||
@@ -389,7 +389,7 @@
|
||||
|
||||
|
||||
/*!
|
||||
\name BFlattenable override methods
|
||||
\name BFlattenable method implementations
|
||||
*/
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@
|
||||
|
||||
/*!
|
||||
\fn bool BPath::IsFixedSize() const
|
||||
\brief Overrides BFlattenable::IsFixedSize(). Always returns \c false.
|
||||
\brief Implements BFlattenable::IsFixedSize(). Always returns \c false.
|
||||
|
||||
\return \c false
|
||||
*/
|
||||
@@ -406,7 +406,7 @@
|
||||
|
||||
/*!
|
||||
\fn type_code BPath::TypeCode() const
|
||||
\brief Overrides BFlattenable::TypeCode() Always returns \c B_REF_TYPE.
|
||||
\brief Implements BFlattenable::TypeCode(). Always returns \c B_REF_TYPE.
|
||||
|
||||
\return \c B_REF_TYPE
|
||||
*/
|
||||
@@ -414,7 +414,7 @@
|
||||
|
||||
/*!
|
||||
\fn ssize_t BPath::FlattenedSize() const
|
||||
\brief Overrides BFlattenable::FlattenedSize() Gets the size of the
|
||||
\brief Implements BFlattenable::FlattenedSize(). Gets the size of the
|
||||
flattened entry_ref struct that represents the path in bytes.
|
||||
|
||||
\return The size of the flattened entry_ref struct that represents the
|
||||
@@ -424,7 +424,7 @@
|
||||
|
||||
/*!
|
||||
\fn status_t BPath::Flatten(void* buffer, ssize_t size) const
|
||||
\brief Overrides BFlattenable::Flatten(). Converts the path of the object
|
||||
\brief Implements BFlattenable::Flatten(). Converts the path of the object
|
||||
to an entry_ref and writes it into <em>buffer</em>.
|
||||
|
||||
\param buffer The buffer that the data is to be stored in.
|
||||
@@ -432,13 +432,13 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_BAD_VALUE \c NULL buffer or the buffer is of insufficient size.
|
||||
\retval B_BAD_VALUE \a buffer was \c NULL or of insufficient size.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn bool BPath::AllowsTypeCode(type_code code) const
|
||||
\brief Overrides BFlattenable::AllowsTypeCode(). Checks if type code is
|
||||
\brief Implements BFlattenable::AllowsTypeCode(). Checks if type code is
|
||||
equal to \c B_REF_TYPE.
|
||||
|
||||
\param code The type code to test.
|
||||
@@ -450,7 +450,7 @@
|
||||
/*!
|
||||
\fn status_t BPath::Unflatten(type_code code, const void* buffer,
|
||||
ssize_t size)
|
||||
\brief Overrides BFlattenable::Unflatten(). Initializes the object with
|
||||
\brief Implements BFlattenable::Unflatten(). Initializes the object with
|
||||
the flattened entry_ref data from the passed in buffer.
|
||||
|
||||
The type code must be set to \c B_REF_TYPE.
|
||||
@@ -461,7 +461,7 @@
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_BAD_VALUE \a buffer is \c NULL or doesn't contain an entry_ref.
|
||||
\retval B_BAD_VALUE \a buffer was \c NULL or didn't contain an entry_ref.
|
||||
*/
|
||||
|
||||
|
||||
@@ -475,8 +475,8 @@
|
||||
status_t BPath::_SetPath(const char* path)
|
||||
\brief Sets the supplied path.
|
||||
|
||||
The path is copied. If \a path is \c NULL path of the object is set to
|
||||
\c NULL as well. The object's old path is deleted.
|
||||
The path is copied, if \a path is \c NULL the path of the object is set to
|
||||
\c NULL as well. The old path is deleted.
|
||||
|
||||
\param path the path to be set
|
||||
|
||||
|
||||
@@ -58,8 +58,6 @@ public:
|
||||
BUrlContext* Context() const;
|
||||
BUrlProtocolListener* Listener() const;
|
||||
const BString& Protocol() const;
|
||||
// TODO: Does not belong here.
|
||||
BHttpHeaders& Headers() { return fRequestHeaders; }
|
||||
|
||||
// URL protocol informations
|
||||
bool IsRunning() const;
|
||||
@@ -82,8 +80,6 @@ protected:
|
||||
|
||||
protected:
|
||||
BUrl fUrl;
|
||||
BHttpHeaders fRequestHeaders;
|
||||
// TODO: Does not belong here.
|
||||
BUrlResult* fResult;
|
||||
BUrlContext* fContext;
|
||||
BUrlProtocolListener* fListener;
|
||||
|
||||
@@ -22,10 +22,10 @@ enum {
|
||||
class BUrlRequest {
|
||||
public:
|
||||
BUrlRequest(const BUrl& url,
|
||||
BUrlProtocolListener* listener);
|
||||
BUrlRequest(const BUrl& url);
|
||||
BUrlProtocolListener* listener = NULL,
|
||||
BUrlContext* context = NULL);
|
||||
BUrlRequest(const BUrlRequest& other);
|
||||
virtual ~BUrlRequest() { };
|
||||
virtual ~BUrlRequest();
|
||||
|
||||
// Request parameters modification
|
||||
status_t SetUrl(const BUrl& url);
|
||||
@@ -40,15 +40,13 @@ public:
|
||||
const BUrl& Url();
|
||||
|
||||
// Request control
|
||||
status_t Identify();
|
||||
virtual status_t Perform();
|
||||
// TODO: Rename to Run() perhaps? "Perform" is used for FBC stuff.
|
||||
virtual status_t Start();
|
||||
virtual status_t Pause();
|
||||
virtual status_t Resume();
|
||||
virtual status_t Abort();
|
||||
|
||||
// Request informations
|
||||
virtual bool InitCheck() const;
|
||||
virtual status_t InitCheck() const;
|
||||
bool IsRunning() const;
|
||||
status_t Status() const;
|
||||
|
||||
@@ -62,7 +60,10 @@ protected:
|
||||
BUrlResult fResult;
|
||||
BUrlContext* fContext;
|
||||
BUrl fUrl;
|
||||
bool fReady;
|
||||
status_t fInitStatus;
|
||||
|
||||
private:
|
||||
status_t _SetupProtocol();
|
||||
};
|
||||
|
||||
#endif // _B_URL_REQUEST_H_
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
class AboutView;
|
||||
class BBitmap;
|
||||
class BPoint;
|
||||
class BHandler;
|
||||
|
||||
@@ -26,6 +27,7 @@ class BAboutWindow : public BWindow {
|
||||
virtual ~BAboutWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void Show();
|
||||
|
||||
BPoint AboutPosition(float width, float height);
|
||||
void AddDescription(const char* description);
|
||||
@@ -37,6 +39,15 @@ class BAboutWindow : public BWindow {
|
||||
void AddVersionHistory(const char** history);
|
||||
void AddExtraInfo(const char* extraInfo);
|
||||
|
||||
BBitmap* Icon();
|
||||
void SetIcon(BBitmap* icon);
|
||||
|
||||
const char* Name();
|
||||
void SetName(const char* name);
|
||||
|
||||
const char* Version();
|
||||
void SetVersion(const char* version);
|
||||
|
||||
private:
|
||||
AboutView* fAboutView;
|
||||
BHandler* fCaller;
|
||||
|
||||
@@ -133,7 +133,6 @@ TBarMenuTitle::DrawContent()
|
||||
rgb_color menuColor = menu->LowColor();
|
||||
rgb_color dark = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||
rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
||||
rgb_color black = {0, 0, 0, 255};
|
||||
|
||||
bool inExpandoMode = dynamic_cast<TExpandoMenuBar*>(menu) != NULL;
|
||||
|
||||
@@ -161,7 +160,10 @@ TBarMenuTitle::DrawContent()
|
||||
frame.InsetBy(1, 1);
|
||||
menu->SetHighColor(menuColor);
|
||||
menu->FillRect(frame);
|
||||
menu->SetHighColor(black);
|
||||
if (IsSelected())
|
||||
menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
frame.InsetBy(-1, -1);
|
||||
if (inExpandoMode)
|
||||
frame.top -= 1;
|
||||
@@ -177,7 +179,10 @@ TBarMenuTitle::DrawContent()
|
||||
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
|
||||
}
|
||||
|
||||
menu->SetHighColor(black);
|
||||
if (IsSelected())
|
||||
menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
}
|
||||
|
||||
menu->SetDrawingMode(B_OP_ALPHA);
|
||||
|
||||
@@ -283,6 +283,18 @@ PreferencesWindow::QuitRequested()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PreferencesWindow::Show()
|
||||
{
|
||||
if (IsHidden()) {
|
||||
// move to current workspace
|
||||
SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||
}
|
||||
|
||||
BWindow::Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PreferencesWindow::WindowActivated(bool active)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
virtual void Show();
|
||||
virtual void WindowActivated(bool active);
|
||||
|
||||
void UpdateRecentCounts();
|
||||
|
||||
@@ -395,9 +395,6 @@ TTeamMenuItem::DrawContent()
|
||||
menu->MovePenTo(drawLoc);
|
||||
}
|
||||
|
||||
// set the pen to black so that either method will draw in the same color
|
||||
// low color is set in inherited::DrawContent, override makes sure its
|
||||
// what we want
|
||||
if (fDrawLabel) {
|
||||
menu->SetDrawingMode(B_OP_OVER);
|
||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
@@ -513,6 +510,11 @@ TTeamMenuItem::DrawContentLabel()
|
||||
else
|
||||
menu->SetLowColor(menu->LowColor());
|
||||
|
||||
if (IsSelected())
|
||||
menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
|
||||
menu->DrawString(label);
|
||||
|
||||
free(truncLabel);
|
||||
|
||||
@@ -272,8 +272,11 @@ TWindowMenuItem::DrawContent()
|
||||
+ ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f;
|
||||
|
||||
menu->MovePenTo(contLoc);
|
||||
// Set the pen color so that the label is always visible.
|
||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
|
||||
if (IsSelected())
|
||||
menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
|
||||
BMenuItem::DrawContent();
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ PowerStatusView::PowerStatusView(BMessage* archive)
|
||||
|
||||
PowerStatusView::~PowerStatusView()
|
||||
{
|
||||
if (fAboutWindow != NULL)
|
||||
if (fAboutWindow != NULL && fAboutWindow->Lock())
|
||||
fAboutWindow->Quit();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <Catalog.h>
|
||||
#include <CheckBox.h>
|
||||
#include <Clipboard.h>
|
||||
#include <ControlLook.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
@@ -56,6 +57,7 @@
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <SeparatorView.h>
|
||||
#include <Size.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
#include <StatusBar.h>
|
||||
#include <StringView.h>
|
||||
@@ -424,6 +426,12 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
||||
const float kElementSpacing = 5;
|
||||
|
||||
// Find group
|
||||
fFindCloseButton = new BButton("\xc3\x97", // multiplication sign
|
||||
new BMessage(EDIT_HIDE_FIND_GROUP));
|
||||
fFindCloseButton->SetExplicitMinSize(
|
||||
BSize(be_control_look->DefaultItemSpacing() * 3, B_SIZE_UNSET));
|
||||
fFindCloseButton->SetExplicitMaxSize(
|
||||
BSize(be_control_look->DefaultItemSpacing() * 3, B_SIZE_UNSET));
|
||||
fFindTextControl = new BTextControl("find", B_TRANSLATE("Find:"), "",
|
||||
new BMessage(EDIT_FIND_NEXT));
|
||||
fFindTextControl->SetModificationMessage(new BMessage(FIND_TEXT_CHANGED));
|
||||
@@ -431,18 +439,15 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
||||
new BMessage(EDIT_FIND_PREVIOUS));
|
||||
fFindNextButton = new BButton(B_TRANSLATE("Next"),
|
||||
new BMessage(EDIT_FIND_NEXT));
|
||||
fFindCloseButton = new BButton(B_TRANSLATE("Close"),
|
||||
new BMessage(EDIT_HIDE_FIND_GROUP));
|
||||
fFindCaseSensitiveCheckBox = new BCheckBox(B_TRANSLATE("Match case"));
|
||||
BGroupLayout* findGroup = BLayoutBuilder::Group<>(B_VERTICAL, 0.0)
|
||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
|
||||
.Add(fFindCloseButton)
|
||||
.Add(fFindTextControl)
|
||||
.Add(fFindPreviousButton)
|
||||
.Add(fFindNextButton)
|
||||
.Add(fFindCaseSensitiveCheckBox)
|
||||
.Add(BSpaceLayoutItem::CreateGlue())
|
||||
.Add(fFindCloseButton)
|
||||
.SetInsets(kInsetSpacing, kInsetSpacing,
|
||||
kInsetSpacing, kInsetSpacing)
|
||||
)
|
||||
@@ -2332,5 +2337,3 @@ BrowserWindow::_HandlePageSourceResult(const BMessage* message)
|
||||
alert->Go(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+35
-1
@@ -222,9 +222,12 @@ struct MimeAttribute
|
||||
|
||||
MimeAttribute(BMessage& msg, int32 index);
|
||||
MimeAttribute(TUserArgs& args);
|
||||
MimeAttribute(const MimeAttribute& src);
|
||||
|
||||
status_t InitCheck() { return fStatus; }
|
||||
|
||||
MimeAttribute& operator=(const MimeAttribute& src);
|
||||
|
||||
void Dump();
|
||||
void SyncWith(TUserArgs& args) throw(Error);
|
||||
void StoreInto(BMessage* target);
|
||||
@@ -288,12 +291,43 @@ MimeAttribute::MimeAttribute(BMessage& msg, int32 index)
|
||||
|
||||
|
||||
MimeAttribute::MimeAttribute(TUserArgs& args)
|
||||
:
|
||||
fStatus(B_NO_INIT),
|
||||
fType('CSTR'),
|
||||
fViewable(true),
|
||||
fEditable(false),
|
||||
fExtra(false),
|
||||
fWidth(0),
|
||||
fAlignment(0)
|
||||
{
|
||||
SyncWith(args);
|
||||
fStatus = B_OK;
|
||||
}
|
||||
|
||||
|
||||
MimeAttribute::MimeAttribute(const MimeAttribute& src)
|
||||
{
|
||||
*this = src;
|
||||
}
|
||||
|
||||
|
||||
MimeAttribute&
|
||||
MimeAttribute::operator=(const MimeAttribute& src)
|
||||
{
|
||||
fStatus = src.fStatus;
|
||||
fName = src.fName;
|
||||
fPublicName = src.fPublicName;
|
||||
fType = src.fType;
|
||||
fViewable = src.fViewable;
|
||||
fEditable = src.fEditable;
|
||||
fExtra = src.fExtra;
|
||||
fWidth = src.fWidth;
|
||||
fAlignment = src.fAlignment;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MimeAttribute::SyncWith(TUserArgs& args) throw(Error)
|
||||
{
|
||||
@@ -609,7 +643,7 @@ MimeType::_Init(char** argv) throw (Error)
|
||||
throw Error("'%s' allowed only after the '%s' <name>",
|
||||
name, kAttribute);
|
||||
|
||||
if (!*++arg)
|
||||
if (!*++arg || **arg == '-')
|
||||
throw Error("'%s', argument should be specified", name);
|
||||
|
||||
TUserArgsI A = fUserAttributes.back().find(key);
|
||||
|
||||
@@ -32,8 +32,8 @@ static const char* kHttpProtocolThreadStrStatus[
|
||||
|
||||
|
||||
BUrlProtocolHttp::BUrlProtocolHttp(BUrl& url, bool ssl,
|
||||
const char *protocolName, BUrlProtocolListener* listener,
|
||||
BUrlContext* context, BUrlResult* result)
|
||||
const char* protocolName, BUrlProtocolListener* listener,
|
||||
BUrlContext* context, BUrlResult* result)
|
||||
:
|
||||
BUrlProtocol(url, listener, context, result, "BUrlProtocol.HTTP", protocolName),
|
||||
fSSL(ssl),
|
||||
@@ -45,7 +45,6 @@ BUrlProtocolHttp::BUrlProtocolHttp(BUrl& url, bool ssl,
|
||||
fSocket = new BSecureSocket();
|
||||
else
|
||||
fSocket = new BSocket();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -320,8 +319,7 @@ BUrlProtocolHttp::_ProtocolLoop()
|
||||
|
||||
_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT,
|
||||
"%ld headers and %ld bytes of data remaining",
|
||||
fHeaders.CountHeaders(),
|
||||
fInputBuffer.Size());
|
||||
fHeaders.CountHeaders(), fInputBuffer.Size());
|
||||
|
||||
if (fResult->StatusCode() == 404)
|
||||
return B_PROT_HTTP_NOT_FOUND;
|
||||
@@ -339,10 +337,7 @@ BUrlProtocolHttp::_ResolveHostName()
|
||||
if (fUrl.HasPort())
|
||||
fRemoteAddr = BNetworkAddress(fUrl.Host(), fUrl.Port());
|
||||
else {
|
||||
if (fSSL)
|
||||
fRemoteAddr = BNetworkAddress(fUrl.Host(), 443);
|
||||
else
|
||||
fRemoteAddr = BNetworkAddress(fUrl.Host(), 80);
|
||||
fRemoteAddr = BNetworkAddress(fUrl.Host(), fSSL ? 443 : 80);
|
||||
}
|
||||
|
||||
if (fRemoteAddr.InitCheck() != B_OK)
|
||||
@@ -350,11 +345,10 @@ BUrlProtocolHttp::_ResolveHostName()
|
||||
|
||||
//! ProtocolHook:HostnameResolved
|
||||
if (fListener != NULL)
|
||||
fListener->HostnameResolved(this,
|
||||
const_cast<const char*>(fRemoteAddr.ToString().String()));
|
||||
fListener->HostnameResolved(this, fRemoteAddr.ToString().String());
|
||||
|
||||
_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT, "Hostname resolved to: %s",
|
||||
fRemoteAddr.ToString().String());
|
||||
fRemoteAddr.ToString().String());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -582,7 +576,7 @@ BUrlProtocolHttp::_MakeRequest()
|
||||
if (readError)
|
||||
return B_PROT_READ_FAILED;
|
||||
|
||||
return fQuit?B_PROT_ABORTED:B_PROT_SUCCESS;
|
||||
return fQuit ? B_PROT_ABORTED : B_PROT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -763,12 +757,12 @@ BUrlProtocolHttp::_AddHeaders()
|
||||
|
||||
fOutputHeaders.AddHeader("Accept", "*/*");
|
||||
fOutputHeaders.AddHeader("Accept-Encoding", "chunked");
|
||||
// Allow the remote server to send dynamic content by chunks
|
||||
// Allow the remote server to send dynamic content by chunks
|
||||
// rather than waiting for the full content to be generated and
|
||||
// sending us data.
|
||||
|
||||
fOutputHeaders.AddHeader("Connection", "close");
|
||||
// Let the remote server close the connection after response since
|
||||
// Let the remote server close the connection after response since
|
||||
// we don't handle multiple request on a single connection
|
||||
}
|
||||
|
||||
@@ -823,30 +817,14 @@ BUrlProtocolHttp::_AddHeaders()
|
||||
&& (fRequestMethod == B_HTTP_POST || fRequestMethod == B_HTTP_PUT))
|
||||
fOutputHeaders.AddHeader("Transfer-Encoding", "chunked");
|
||||
|
||||
// Request headers
|
||||
for (int32 headerIndex = 0;
|
||||
headerIndex < fRequestHeaders.CountHeaders();
|
||||
headerIndex++) {
|
||||
BHttpHeader& optHeader = fRequestHeaders[headerIndex];
|
||||
int32 replaceIndex = fOutputHeaders.HasHeader(optHeader.Name());
|
||||
|
||||
// Add or replace the current option header to the
|
||||
// output header list
|
||||
if (replaceIndex == -1)
|
||||
fOutputHeaders.AddHeader(optHeader.Name(), optHeader.Value());
|
||||
else
|
||||
fOutputHeaders[replaceIndex].SetValue(optHeader.Value());
|
||||
}
|
||||
|
||||
// Optional headers specified by the user
|
||||
if (fOptHeaders != NULL) {
|
||||
for (int32 headerIndex = 0;
|
||||
headerIndex < fOptHeaders->CountHeaders();
|
||||
headerIndex++) {
|
||||
for (int32 headerIndex = 0; headerIndex < fOptHeaders->CountHeaders();
|
||||
headerIndex++) {
|
||||
BHttpHeader& optHeader = (*fOptHeaders)[headerIndex];
|
||||
int32 replaceIndex = fOutputHeaders.HasHeader(optHeader.Name());
|
||||
|
||||
// Add or replace the current option header to the
|
||||
// Add or replace the current option header to the
|
||||
// output header list
|
||||
if (replaceIndex == -1)
|
||||
fOutputHeaders.AddHeader(optHeader.Name(), optHeader.Value());
|
||||
@@ -859,17 +837,15 @@ BUrlProtocolHttp::_AddHeaders()
|
||||
if (fOptSetCookies && (fContext != NULL)) {
|
||||
BNetworkCookie* cookie;
|
||||
|
||||
for (BNetworkCookieJar::UrlIterator
|
||||
it(fContext->GetCookieJar().GetUrlIterator(fUrl));
|
||||
(cookie = it.Next()) != NULL;
|
||||
)
|
||||
fOutputHeaders.AddHeader("Cookie", cookie->RawCookie(false));
|
||||
for (BNetworkCookieJar::UrlIterator it
|
||||
= fContext->GetCookieJar().GetUrlIterator(fUrl);
|
||||
(cookie = it.Next()) != NULL;)
|
||||
fOutputHeaders.AddHeader("Cookie", cookie->RawCookie(false));
|
||||
}
|
||||
|
||||
// Write output headers to output stream
|
||||
for (int32 headerIndex = 0;
|
||||
headerIndex < fOutputHeaders.CountHeaders();
|
||||
headerIndex++)
|
||||
for (int32 headerIndex = 0; headerIndex < fOutputHeaders.CountHeaders();
|
||||
headerIndex++)
|
||||
_AddOutputBufferLine(fOutputHeaders.HeaderAt(headerIndex).Header());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,27 +13,15 @@
|
||||
#include <Debug.h>
|
||||
|
||||
|
||||
BUrlRequest::BUrlRequest(const BUrl& url, BUrlProtocolListener* listener)
|
||||
BUrlRequest::BUrlRequest(const BUrl& url, BUrlProtocolListener* listener,
|
||||
BUrlContext* context)
|
||||
:
|
||||
fListener(listener),
|
||||
fUrlProtocol(NULL),
|
||||
fResult(url),
|
||||
fContext(),
|
||||
fContext(context),
|
||||
fUrl(),
|
||||
fReady(false)
|
||||
{
|
||||
SetUrl(url);
|
||||
}
|
||||
|
||||
|
||||
BUrlRequest::BUrlRequest(const BUrl& url)
|
||||
:
|
||||
fListener(NULL),
|
||||
fUrlProtocol(NULL),
|
||||
fResult(url),
|
||||
fContext(),
|
||||
fUrl(),
|
||||
fReady(false)
|
||||
fInitStatus(B_ERROR)
|
||||
{
|
||||
SetUrl(url);
|
||||
}
|
||||
@@ -46,12 +34,18 @@ BUrlRequest::BUrlRequest(const BUrlRequest& other)
|
||||
fResult(other.fUrl),
|
||||
fContext(),
|
||||
fUrl(),
|
||||
fReady(false)
|
||||
fInitStatus(B_ERROR)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
||||
BUrlRequest::~BUrlRequest()
|
||||
{
|
||||
if (fUrlProtocol != NULL)
|
||||
delete fUrlProtocol;
|
||||
}
|
||||
|
||||
// #pragma mark Request parameters modification
|
||||
|
||||
|
||||
@@ -61,15 +55,13 @@ BUrlRequest::SetUrl(const BUrl& url)
|
||||
fUrl = url;
|
||||
fResult.SetUrl(url);
|
||||
|
||||
if (fUrlProtocol != NULL && url.Protocol() == fUrl.Protocol())
|
||||
if (fUrlProtocol != NULL && url.Protocol() == fUrl.Protocol()) {
|
||||
fUrlProtocol->SetUrl(url);
|
||||
else {
|
||||
status_t err = Identify();
|
||||
if (err != B_OK)
|
||||
return err;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
fInitStatus = _SetupProtocol();
|
||||
return fInitStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,33 +121,7 @@ BUrlRequest::Url()
|
||||
|
||||
|
||||
status_t
|
||||
BUrlRequest::Identify()
|
||||
{
|
||||
// TODO: instanciate the correct BUrlProtocol w/ the services roster
|
||||
delete fUrlProtocol;
|
||||
fUrlProtocol = NULL;
|
||||
|
||||
if (fUrl.Protocol() == "http") {
|
||||
fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, false, "HTTP",
|
||||
fListener, fContext,
|
||||
&fResult);
|
||||
fReady = true;
|
||||
return B_OK;
|
||||
} else if (fUrl.Protocol() == "https") {
|
||||
fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, true, "HTTPS",
|
||||
fListener, fContext,
|
||||
&fResult);
|
||||
fReady = true;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
fReady = false;
|
||||
return B_NO_HANDLER_FOR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BUrlRequest::Perform()
|
||||
BUrlRequest::Start()
|
||||
{
|
||||
if (fUrlProtocol == NULL) {
|
||||
PRINT(("BUrlRequest::Perform() : Oops, no BUrlProtocol defined!\n"));
|
||||
@@ -208,10 +174,10 @@ BUrlRequest::Abort()
|
||||
// #pragma mark Request informations
|
||||
|
||||
|
||||
bool
|
||||
status_t
|
||||
BUrlRequest::InitCheck() const
|
||||
{
|
||||
return fReady;
|
||||
return fInitStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -251,3 +217,26 @@ BUrlRequest::operator=(const BUrlRequest& other)
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BUrlRequest::_SetupProtocol()
|
||||
{
|
||||
// TODO: instanciate the correct BUrlProtocol w/ the services roster
|
||||
delete fUrlProtocol;
|
||||
fUrlProtocol = NULL;
|
||||
|
||||
if (fUrl.Protocol() == "http")
|
||||
fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, false, "HTTP",
|
||||
fListener, fContext, &fResult);
|
||||
else if (fUrl.Protocol() == "https")
|
||||
fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, true, "HTTPS",
|
||||
fListener, fContext, &fResult);
|
||||
else
|
||||
return B_NO_HANDLER_FOR_PROTOCOL;
|
||||
|
||||
if (fUrlProtocol == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ BUrlSynchronousRequest::Perform()
|
||||
SetProtocolListener(this);
|
||||
fRequestComplete = false;
|
||||
|
||||
return BUrlRequest::Perform();
|
||||
return Start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+206
-10
@@ -20,7 +20,10 @@
|
||||
#include <Font.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <GroupView.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Message.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <Point.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
@@ -42,6 +45,46 @@ using BPrivate::gSystemCatalog;
|
||||
#define B_TRANSLATION_CONTEXT "AboutWindow"
|
||||
|
||||
|
||||
class EscapeFilter : public BMessageFilter {
|
||||
public:
|
||||
EscapeFilter(BWindow* target)
|
||||
:
|
||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
fTarget(target)
|
||||
{
|
||||
}
|
||||
virtual ~EscapeFilter()
|
||||
{
|
||||
}
|
||||
virtual filter_result
|
||||
Filter(BMessage* message, BHandler** target)
|
||||
{
|
||||
filter_result result = B_DISPATCH_MESSAGE;
|
||||
switch (message->what) {
|
||||
case B_KEY_DOWN:
|
||||
case B_UNMAPPED_KEY_DOWN: {
|
||||
uint32 key;
|
||||
if (message->FindInt32("raw_char",
|
||||
(int32*)&key) >= B_OK) {
|
||||
if (key == B_ESCAPE) {
|
||||
result = B_SKIP_MESSAGE;
|
||||
fTarget->PostMessage(
|
||||
B_QUIT_REQUESTED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
BWindow* fTarget;
|
||||
};
|
||||
|
||||
|
||||
class StripeView : public BView {
|
||||
public:
|
||||
StripeView(BBitmap* icon);
|
||||
@@ -49,6 +92,9 @@ class StripeView : public BView {
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
BBitmap* Icon() const { return fIcon; };
|
||||
void SetIcon(BBitmap* icon);
|
||||
|
||||
private:
|
||||
BBitmap* fIcon;
|
||||
};
|
||||
@@ -62,14 +108,24 @@ class AboutView : public BGroupView {
|
||||
|
||||
BTextView* InfoView() const { return fInfoView; };
|
||||
|
||||
BBitmap* Icon();
|
||||
status_t SetIcon(BBitmap* icon);
|
||||
|
||||
const char* Name();
|
||||
status_t SetName(const char* name);
|
||||
|
||||
const char* Version();
|
||||
status_t SetVersion(const char* version);
|
||||
|
||||
protected:
|
||||
const char* AppVersion(const char* signature);
|
||||
BBitmap* AppIcon(const char* signature);
|
||||
const char* _GetVersionFromSignature(const char* signature);
|
||||
BBitmap* _GetIconFromSignature(const char* signature);
|
||||
|
||||
private:
|
||||
BStringView* fNameView;
|
||||
BStringView* fVersionView;
|
||||
BTextView* fInfoView;
|
||||
StripeView* fStripeView;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,13 +137,14 @@ StripeView::StripeView(BBitmap* icon)
|
||||
BView("StripeView", B_WILL_DRAW),
|
||||
fIcon(icon)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
float width = 0.0f;
|
||||
if (icon != NULL)
|
||||
width += icon->Bounds().Width() + 32.0f;
|
||||
|
||||
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +173,24 @@ StripeView::Draw(BRect updateRect)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
void
|
||||
StripeView::SetIcon(BBitmap* icon)
|
||||
{
|
||||
if (fIcon != NULL)
|
||||
delete fIcon;
|
||||
|
||||
fIcon = icon;
|
||||
|
||||
float width = 0.0f;
|
||||
if (icon != NULL)
|
||||
width += icon->Bounds().Width() + 32.0f;
|
||||
|
||||
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - AboutView
|
||||
|
||||
|
||||
AboutView::AboutView(const char* appName, const char* signature)
|
||||
@@ -131,7 +205,8 @@ AboutView::AboutView(const char* appName, const char* signature)
|
||||
fNameView->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE
|
||||
| B_FONT_FLAGS);
|
||||
|
||||
fVersionView = new BStringView("version", AppVersion(signature));
|
||||
fVersionView = new BStringView("version",
|
||||
_GetVersionFromSignature(signature));
|
||||
|
||||
fInfoView = new BTextView("info", B_WILL_DRAW);
|
||||
fInfoView->SetExplicitMinSize(BSize(210.0, 160.0));
|
||||
@@ -145,10 +220,12 @@ AboutView::AboutView(const char* appName, const char* signature)
|
||||
"infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS,
|
||||
false, true, B_PLAIN_BORDER);
|
||||
|
||||
fStripeView = new StripeView(_GetIconFromSignature(signature));
|
||||
|
||||
GroupLayout()->SetSpacing(0);
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.AddGroup(B_HORIZONTAL, 0)
|
||||
.Add(new StripeView(AppIcon(signature)))
|
||||
.Add(fStripeView)
|
||||
.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
|
||||
.SetInsets(0, B_USE_DEFAULT_SPACING,
|
||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||
@@ -166,8 +243,11 @@ AboutView::~AboutView()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - AboutView protected methods
|
||||
|
||||
|
||||
const char*
|
||||
AboutView::AppVersion(const char* signature)
|
||||
AboutView::_GetVersionFromSignature(const char* signature)
|
||||
{
|
||||
if (signature == NULL)
|
||||
return NULL;
|
||||
@@ -228,7 +308,7 @@ AboutView::AppVersion(const char* signature)
|
||||
|
||||
|
||||
BBitmap*
|
||||
AboutView::AppIcon(const char* signature)
|
||||
AboutView::_GetIconFromSignature(const char* signature)
|
||||
{
|
||||
if (signature == NULL)
|
||||
return NULL;
|
||||
@@ -251,7 +331,64 @@ AboutView::AppIcon(const char* signature)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
// #pragma mark - AboutView public methods
|
||||
|
||||
|
||||
const char*
|
||||
AboutView::Name()
|
||||
{
|
||||
return fNameView->Text();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AboutView::SetName(const char* name)
|
||||
{
|
||||
fNameView->SetText(name);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
AboutView::Version()
|
||||
{
|
||||
return fVersionView->Text();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AboutView::SetVersion(const char* version)
|
||||
{
|
||||
fVersionView->SetText(version);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
AboutView::Icon()
|
||||
{
|
||||
if (fStripeView == NULL)
|
||||
return NULL;
|
||||
|
||||
return fStripeView->Icon();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AboutView::SetIcon(BBitmap* icon)
|
||||
{
|
||||
if (fStripeView == NULL)
|
||||
return B_NO_INIT;
|
||||
|
||||
fStripeView->SetIcon(icon);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BAboutWindow
|
||||
|
||||
|
||||
BAboutWindow::BAboutWindow(const char* appName, const char* signature)
|
||||
@@ -272,6 +409,8 @@ BAboutWindow::BAboutWindow(const char* appName, const char* signature)
|
||||
AddChild(fAboutView);
|
||||
|
||||
MoveTo(AboutPosition(Frame().Width(), Frame().Height()));
|
||||
|
||||
AddCommonFilter(new EscapeFilter(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +422,9 @@ BAboutWindow::~BAboutWindow()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BAboutWindow virtual methods
|
||||
|
||||
|
||||
bool
|
||||
BAboutWindow::QuitRequested()
|
||||
{
|
||||
@@ -292,7 +434,19 @@ BAboutWindow::QuitRequested()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
void
|
||||
BAboutWindow::Show()
|
||||
{
|
||||
if (IsHidden()) {
|
||||
// move to current workspace
|
||||
SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||
}
|
||||
|
||||
BWindow::Show();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BAboutWindow public methods
|
||||
|
||||
|
||||
BPoint
|
||||
@@ -463,3 +617,45 @@ BAboutWindow::AddExtraInfo(const char* extraInfo)
|
||||
|
||||
fAboutView->InfoView()->Insert(extra.String());
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BAboutWindow::Name()
|
||||
{
|
||||
return fAboutView->Name();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAboutWindow::SetName(const char* name)
|
||||
{
|
||||
fAboutView->SetName(name);
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BAboutWindow::Version()
|
||||
{
|
||||
return fAboutView->Version();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAboutWindow::SetVersion(const char* version)
|
||||
{
|
||||
fAboutView->SetVersion(version);
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
BAboutWindow::Icon()
|
||||
{
|
||||
return fAboutView->Icon();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BAboutWindow::SetIcon(BBitmap* icon)
|
||||
{
|
||||
fAboutView->SetIcon(icon);
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ const uint32 kRevertButtonPressed = 'Rebp';
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "TrackerSettingsWindow"
|
||||
|
||||
|
||||
TrackerSettingsWindow::TrackerSettingsWindow()
|
||||
:
|
||||
BWindow(BRect(80, 80, 450, 350), B_TRANSLATE("Tracker preferences"),
|
||||
B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
|
||||
| B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE
|
||||
| B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
@@ -184,6 +184,12 @@ TrackerSettingsWindow::Show()
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
if (IsHidden()) {
|
||||
// move to current workspace
|
||||
SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||
}
|
||||
|
||||
_inherited::Show();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user