Codestyle fixes, patch created by Freemann2430 during GCI2012

This commit is contained in:
barrett 2013-01-04 13:52:14 +00:00
parent 101006a459
commit 6572adb23b
18 changed files with 237 additions and 138 deletions

View File

@ -170,18 +170,21 @@ ActionDownload::Perform(BMessage* errors)
return status;
}
BString
ActionDownload::GetDescription()
{
return "HTTP File download";
}
BString
ActionDownload::GetLocalPath()
{
return BPath(&fDest).Path();
}
void
ActionDownload::fillMessage(ActionDownload* ad, BMessage* msg)
{
@ -196,7 +199,6 @@ ActionDownload::fillMessage(ActionDownload* ad, BMessage* msg)
}
void
ActionDownload::sendProgressX(ActionDownload* ad, double max, double current)
{
@ -253,6 +255,7 @@ ActionDownload::sendError(BLooper* looper,uint32 amsg,Status st,BString descr){
*/
//
int
ActionDownload::callback(void* data,
double dltotal,
@ -267,6 +270,7 @@ ActionDownload::callback(void* data,
return 0;
}
size_t
ActionDownload::save_file( void* ptr, size_t size, size_t nmemb, void* data)
{
@ -280,6 +284,7 @@ ActionDownload::save_file( void* ptr, size_t size, size_t nmemb, void* data)
}
}
BFile* file = ad->file;
if (ad->ShouldStop()) return 0;
if (ad->ShouldStop())
return 0;
return file->Write(ptr, size * nmemb);
}

View File

@ -35,47 +35,69 @@ public:
BString GetDescription();
BString GetLocalPath();
void SetLooper(BLooper* loop, uint32 msg) {
void
SetLooper(BLooper* loop, uint32 msg)
{
fTarget = loop;
fMsg = msg;
};
BLooper* Looper() {
};
BLooper*
Looper()
{
return fTarget;
}
uint32 MessageWhat() {
}
uint32
MessageWhat()
{
return fMsg;
}
}
// For compatibility:
void SetExtraData(BString extra) {
void
SetExtraData(BString extra)
{
extraInfo.AddString("extra", extra);
}
}
void SetKey(BString key, BString data) {
void
SetKey(BString key, BString data)
{
extraInfo.AddString(key.String(), data);
}
}
void SetRef(BString key, entry_ref* ref) {
void
SetRef(BString key, entry_ref* ref)
{
extraInfo.AddRef(key.String(), ref);
}
}
status_t GetRef(BString key, entry_ref* ref) {
status_t
GetRef(BString key, entry_ref* ref)
{
return extraInfo.FindRef(key.String(), ref);
}
}
BString GetKey(BString key) {
BString GetKey(BString key)
{
BString data;
extraInfo.FindString(key.String(), &data);
return data;
}
}
void SetShouldStop(bool stop) {
void
SetShouldStop(bool stop)
{
fShouldStop = stop;
}
bool ShouldStop() {
}
bool
ShouldStop()
{
return fShouldStop;
}
}
void SetDownloadManager(DownloadManager* downloadManager);
@ -87,7 +109,8 @@ private:
//curl callbacks:
static size_t save_file ( void* ptr, size_t size, size_t nmemb, void* stream);
static int callback (void* clientp, double dltotal, double dlnow, double , double);
static int callback (void* clientp, double dltotal,
double dlnow, double , double);
CURL* curl;
BString fUrl;

View File

@ -13,20 +13,25 @@
#define DEFAULT_ITEMS_DOWNLOAD 1
DownloadManager::DownloadManager(BLooper* target): fTarget(target)
DownloadManager::DownloadManager(BLooper* target)
:
fTarget(target)
{
}
void
DownloadManager::Enqueue(QueueType type, ActionDownload* ad)
{
if (!fQueue[type]) {
fQueue[type] = new QueueFileDownload("queue_downloads", DEFAULT_ITEMS_DOWNLOAD, fTarget, DOWNLOAD_INFO);
fQueue[type] = new QueueFileDownload("queue_downloads",
DEFAULT_ITEMS_DOWNLOAD, fTarget, DOWNLOAD_INFO);
}
ad->SetDownloadManager(this);
fQueue[type]->AddAction(ad);
}
void
DownloadManager::TryStopCurrentAction(QueueType type, BString key, BString value)
{
@ -46,6 +51,7 @@ DownloadManager::TryStopCurrentAction(QueueType type, BString key, BString value
}
}
bool
DownloadManager::RemoveFromQueue(QueueType type , BString key, BString value)
{
@ -78,6 +84,7 @@ DownloadManager::RemoveFromQueue(QueueType type , BString key, BString value)
return false;
}
void
DownloadManager::RemoveQueue(QueueType type, BList* removed)
{
@ -103,6 +110,7 @@ DownloadManager::RemoveQueue(QueueType type, BList* removed)
}
}
void
DownloadManager::LoadProxySetting(BMessage* data)
{
@ -158,6 +166,7 @@ DownloadManager::FinishCurl(CURL* curl)
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD , fUserpwd.String() );
}
thread_id
DownloadManager::SingleThreadAction(ActionDownload* action)
{
@ -165,11 +174,13 @@ DownloadManager::SingleThreadAction(ActionDownload* action)
if (action->Looper() == NULL) {
action->SetLooper(fTarget, DOWNLOAD_INFO);
}
thread_id id = spawn_thread(DownloadManager::SingleThreadPerform, "single_action_thread", B_NORMAL_PRIORITY, (void*)action);
thread_id id = spawn_thread(DownloadManager::SingleThreadPerform,
"single_action_thread", B_NORMAL_PRIORITY, (void*)action);
resume_thread(id);
return id;
}
int32
DownloadManager::SingleThreadPerform(void* a)
{

View File

@ -19,9 +19,7 @@ class ActionDownload;
class DownloadManager
{
public:
enum QueueType {
DOWNLOADS_QUEUE = 0
};
enum QueueType {DOWNLOADS_QUEUE = 0};
DownloadManager(BLooper* target);

View File

@ -14,18 +14,21 @@ void
QueueFileDownload::ActionReadyToPerform(Action* action)
{
ActionDownload* ad = dynamic_cast<ActionDownload*>(action);
if (!ad) return;
if (!ad)
return;
ad->SetLooper(fLooper, fMsg);
}
void
QueueFileDownload::ActionPerformed(Action* action, status_t state, BMessage* msg)
{
ActionDownload* ad = dynamic_cast<ActionDownload*>(action);
if (!ad) return;
if (!ad)
return;
BMessage notify(*msg);
notify.what = fMsg;
@ -36,11 +39,13 @@ QueueFileDownload::ActionPerformed(Action* action, status_t state, BMessage* msg
return;
}
void
QueueFileDownload::SuppressAction(Action* action)
{
ActionDownload* ad = dynamic_cast<ActionDownload*>(action);
if (!ad) return;
if (!ad)
return;
ad->SetShouldStop(true);
}

View File

@ -69,6 +69,7 @@ QueueMultiActions::Lock()
return (value == B_NO_ERROR);
}
void
QueueMultiActions::Unlock()
{
@ -76,6 +77,7 @@ QueueMultiActions::Unlock()
release_sem(fLock);
}
void
QueueMultiActions::SetDownloadCount(int fProposedCount)
{
@ -138,6 +140,7 @@ QueueMultiActions::AddAction(Action* a)
}
}
Action*
QueueMultiActions::CurrentAction(int index)
{
@ -145,6 +148,7 @@ QueueMultiActions::CurrentAction(int index)
return fCurrentAction[index];
}
void
QueueMultiActions::SetCurrentAction(Action* action, int index)
{
@ -152,6 +156,7 @@ QueueMultiActions::SetCurrentAction(Action* action, int index)
fCurrentAction[index] = action;
}
int32
QueueMultiActions::CountActions()
{
@ -159,6 +164,7 @@ QueueMultiActions::CountActions()
return fList.CountItems();
}
Action*
QueueMultiActions::ActionAt(int32 pos)
{
@ -166,6 +172,7 @@ QueueMultiActions::ActionAt(int32 pos)
return fList.ItemAt(pos);
}
void
QueueMultiActions::RemoveActionAt(int32 pos)
{
@ -173,18 +180,21 @@ QueueMultiActions::RemoveActionAt(int32 pos)
fList.RemoveItemAt(pos);
}
bool
QueueMultiActions::IsLocked()
{
return fLocked;
}
void
QueueMultiActions::KIllThread(int id)
{
fID[id] = 0;
}
int32
QueueMultiActions::ManageTheQueue(void* data)
{

View File

@ -28,6 +28,8 @@ public:
Action* CurrentAction(int index);
int32 CountActions();
int CountThreads() {
return fCount;
}
@ -45,9 +47,9 @@ public:
protected:
static int32 ManageTheQueue(void*);
static int32 ManageTheQueue(void*);
virtual void ActionReadyToPerform(Action*) = 0;
virtual void ActionReadyToPerform(Action*) = 0;
virtual void ActionPerformed(Action*, status_t, BMessage*) = 0;
virtual void SuppressAction(Action*) = 0;

View File

@ -16,30 +16,45 @@ enum {
RTV_HIDE_TOOLTIP
};
ReflowingTextView::ReflowingTextView(BRect frame, const char* name, BRect textRect, uint32 resizeMask, uint32 flags) : BTextView(frame, name, textRect, resizeMask, flags), _showTipRunner(NULL), _canShow(false), _urlTip(NULL), _currentLinkStart(-1)
ReflowingTextView::ReflowingTextView(BRect frame, const char* name,
BRect textRect, uint32 resizeMask, uint32 flags)
:
BTextView(frame, name, textRect, resizeMask, flags),
_showTipRunner(NULL),
_canShow(false),
_urlTip(NULL),
_currentLinkStart(-1)
{
// empty
}
ReflowingTextView::~ReflowingTextView()
{
if ((_urlTip) && (_urlTip->Lock())) _urlTip->Quit();
delete _showTipRunner;
}
void ReflowingTextView::AttachedToWindow()
void
ReflowingTextView::AttachedToWindow()
{
BTextView::AttachedToWindow();
// FixTextRect();
}
void ReflowingTextView::FrameResized(float w, float h)
void
ReflowingTextView::FrameResized(float w, float h)
{
BTextView::FrameResized(w, h);
// FixTextRect();
}
void ReflowingTextView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
void
ReflowingTextView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
{
const URLLink* link = NULL;
if (code == B_INSIDE_VIEW) {
@ -89,7 +104,9 @@ void ReflowingTextView::MouseMoved(BPoint where, uint32 code, const BMessage* ms
BTextView::MouseMoved(where, code, msg);
}
void ReflowingTextView::MessageReceived(BMessage* msg)
void
ReflowingTextView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case RTV_SHOW_TOOLTIP:
@ -112,12 +129,18 @@ void ReflowingTextView::MessageReceived(BMessage* msg)
}
}
void ReflowingTextView::UpdateToolTip()
void
ReflowingTextView::UpdateToolTip()
{
if ((_canShow) && (_currentLinkStart >= 0)) {
if (_urlTip == NULL) {
_urlTip = new BWindow(BRect(0, 0, 5, 5), NULL, B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AVOID_FOCUS);
BView* blackBorder = new BView(_urlTip->Bounds(), NULL, B_FOLLOW_ALL_SIDES, 0);
_urlTip = new BWindow(BRect(0, 0, 5, 5), NULL,
B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE |
B_AVOID_FOCUS);
BView* blackBorder = new BView(_urlTip->Bounds(), NULL,
B_FOLLOW_ALL_SIDES, 0);
const rgb_color black = {0, 0, 0, 255};
blackBorder->SetViewColor(black);
_urlTip->AddChild(blackBorder);
@ -130,7 +153,8 @@ void ReflowingTextView::UpdateToolTip()
yellowInterior->SetViewColor(hiliteYellow);
blackBorder->AddChild(yellowInterior);
_urlStringView = new BStringView(yellowInterior->Bounds(), NULL, "", B_FOLLOW_ALL_SIDES);
_urlStringView = new BStringView(yellowInterior->Bounds(), NULL, "",
B_FOLLOW_ALL_SIDES);
_urlStringView->SetLowColor(hiliteYellow);
_urlStringView->SetViewColor(hiliteYellow);
yellowInterior->AddChild(_urlStringView);
@ -140,9 +164,11 @@ void ReflowingTextView::UpdateToolTip()
_urlStringView->GetFontHeight(&ttfh);
float urlHeight = 20.0f;
BPoint pt = PointAt(_currentLinkStart, &urlHeight);
_urlTip->MoveTo(ConvertToScreen(pt) + BPoint(15.0f, -(ttfh.ascent + ttfh.descent + 3.0f)));
_urlTip->MoveTo(ConvertToScreen(pt) + BPoint(15.0f,
-(ttfh.ascent + ttfh.descent + 3.0f)));
_urlTip->ResizeTo(muscleMin(_urlStringView->StringWidth(_currentURLString.String()) + 4.0f, 400.0f), ttfh.ascent + ttfh.descent + 2.0f);
_urlTip->ResizeTo(muscleMin(_urlStringView->StringWidth(_currentURLString.String())
+ 4.0f, 400.0f), ttfh.ascent + ttfh.descent + 2.0f);
_urlStringView->SetText(_currentURLString.String());
_urlTip->SetWorkspaces(B_CURRENT_WORKSPACE);
if (_urlTip->IsHidden()) _urlTip->Show();
@ -156,9 +182,12 @@ void ReflowingTextView::UpdateToolTip()
}
}
void ReflowingTextView::MouseDown(BPoint where)
void
ReflowingTextView::MouseDown(BPoint where)
{
if (IsFocus() == false) MakeFocus();
if (IsFocus() == false)
MakeFocus();
const URLLink* url = GetURLAt(where);
if (url) {
char* allocBuf = NULL;
@ -197,36 +226,47 @@ void ReflowingTextView::MouseDown(BPoint where)
BTextView::MouseDown(where);
}
void ReflowingTextView::FixTextRect()
void
ReflowingTextView::FixTextRect()
{
BRect t(Frame());
SetTextRect(t);
}
void ReflowingTextView::Clear()
void
ReflowingTextView::Clear()
{
Delete(0, TextLength() - 1);
_urls.Clear();
}
void ReflowingTextView::AddURLRegion(uint32 start, uint32 len, const BString& optHiddenURL)
void
ReflowingTextView::AddURLRegion(uint32 start, uint32 len, const BString& optHiddenURL)
{
_urls.AddTail(URLLink(start, len, optHiddenURL));
}
void ReflowingTextView::SetCommandURLTarget(const BMessenger& target, const BMessage& queryMsg, const BMessage& privMsg)
void
ReflowingTextView::SetCommandURLTarget(const BMessenger& target, const BMessage& queryMsg, const BMessage& privMsg)
{
_commandTarget = target;
_queryMessage = queryMsg;
_privMessage = privMsg;
}
const ReflowingTextView::URLLink* ReflowingTextView::GetURLAt(BPoint pt) const
const
ReflowingTextView::URLLink* ReflowingTextView::GetURLAt(BPoint pt) const
{
uint32 offset = (uint32) OffsetAt(pt);
for (int i = _urls.GetNumItems() - 1; i >= 0; i--) {
const URLLink& url = _urls[i];
if ((offset >= url.GetStart()) && (offset < url.GetStart() + url.GetLength())) return &url;
if ((offset >= url.GetStart()) && (offset < url.GetStart() + url.GetLength()))
return &url;
}
return NULL;
}

View File

@ -9,14 +9,16 @@
BitmapMenuItem::BitmapMenuItem(const char *label, BMessage *msg,
BBitmap *bitmap, char shortcut,
uint32 modifiers)
: BMenuItem(label,msg,shortcut,modifiers),
:
BMenuItem(label,msg,shortcut,modifiers),
fBitmap(bitmap)
{
}
BitmapMenuItem::BitmapMenuItem(BMessage *data)
: BMenuItem(data)
:
BMenuItem(data)
{
fBitmap = (BBitmap*) BBitmap::Instantiate(data);
}
@ -73,6 +75,7 @@ BitmapMenuItem::DrawContent(void)
drawrect.bottom--;
drawrect.top++;
drawrect.left = ContentLocation().x;
if (fBitmap) {
// Scale the fBitmap down to completely fit within the field's height
if (fBitmap->Bounds().Height() > drawrect.Height()) {

View File

@ -16,8 +16,7 @@
BitmapMenuItems -- the bitmap does not obscure the checkmark.
*/
class BitmapMenuItem : public BMenuItem
{
class BitmapMenuItem : public BMenuItem {
public:
BitmapMenuItem(const char *label, BMessage *msg,
BBitmap *bitmap, char shortcut = 0,
@ -30,7 +29,7 @@ public:
virtual void DrawContent(void);
virtual void SetBitmap(BBitmap *bitmap);
BBitmap * Bitmap(void) const;
BBitmap* Bitmap(void) const;
private:
BBitmap *fBitmap;

View File

@ -11,8 +11,8 @@ class BBitmap;
class BitmapView : public BView {
public:
BitmapView(const char* name = NULL, uint32 flags
= B_WILL_DRAW);
BitmapView(const char* name = NULL,
uint32 flags = B_WILL_DRAW);
~BitmapView();
virtual void AttachedToWindow();

View File

@ -12,7 +12,8 @@ class BMessenger;
class Divider : public BView {
public:
Divider(const char* name, uint32 flags = B_FRAME_EVENTS | B_WILL_DRAW);
Divider(const char* name, uint32 flags =
B_FRAME_EVENTS | B_WILL_DRAW);
virtual ~Divider();
Divider(BMessage* archive);

View File

@ -51,8 +51,8 @@ NotifyingTextView::SetMessage(BMessage* msg)
void
NotifyingTextView::InsertText(const char* text, int32 length, int32 offset,
const text_run_array* runs)
NotifyingTextView::InsertText(const char* text, int32 length,
int32 offset, const text_run_array* runs)
{
if ((fMessenger != NULL) && fMessenger->IsValid()) {
BMessage msg(*fMessage);

View File

@ -24,8 +24,8 @@ public:
void SetMessage(BMessage* msg);
protected:
virtual void InsertText(const char* text, int32 length, int32 offset,
const text_run_array* runs = NULL);
virtual void InsertText(const char* text, int32 length,
int32 offset, const text_run_array* runs = NULL);
virtual void DeleteText(int32 start, int32 finish);
private:

View File

@ -28,8 +28,8 @@ const uint32 kToolbarIconSize = 16;
// this should go on BControlLook
ToolButton::ToolButton(const char* name, const char* label, BMessage* message,
uint32 flags)
ToolButton::ToolButton(const char* name, const char* label,
BMessage* message, uint32 flags)
:
BControl(name, label, message,
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
@ -42,7 +42,8 @@ ToolButton::ToolButton(const char* name, const char* label, BMessage* message,
ToolButton::ToolButton(const char* label, BMessage* message)
: BControl(NULL, label, message,
:
BControl(NULL, label, message,
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
fBitmap(NULL),
fMenu(NULL),
@ -53,7 +54,8 @@ ToolButton::ToolButton(const char* label, BMessage* message)
ToolButton::ToolButton(BMessage* archive)
: BControl(archive),
:
BControl(archive),
fBitmap(NULL),
fMenu(NULL),
fPreferredSize(-1, -1)