Removed PortQueue since it's not used. Small style (old) changes here
and there. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25468 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
036cf4dd20
commit
e2fe7e2fe0
@ -1,58 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: PortQueue.h
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: Facilitation class for reading and queueing messages from ports
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef PORTQUEUE_H_
|
||||
#define PORTQUEUE_H_
|
||||
|
||||
#include <OS.h>
|
||||
#include <queue>
|
||||
|
||||
class PortMessage;
|
||||
|
||||
class PortQueue
|
||||
{
|
||||
public:
|
||||
PortQueue(const port_id &port);
|
||||
~PortQueue(void);
|
||||
bool IsInitialized(void) { return _init; }
|
||||
|
||||
bool SetPort(const port_id &port);
|
||||
port_id GetPort(void) { return _port; }
|
||||
|
||||
bool MessagesWaiting(void) { return !_q.empty(); }
|
||||
|
||||
void GetMessagesFromPort(bool wait_for_messages=false);
|
||||
PortMessage *GetMessageFromQueue(void);
|
||||
|
||||
void MakeEmpty(void);
|
||||
|
||||
private:
|
||||
std::queue<PortMessage*> _q;
|
||||
bool _init;
|
||||
port_id _port;
|
||||
};
|
||||
|
||||
#endif
|
@ -208,7 +208,6 @@ BApplication::BApplication(BMessage *data)
|
||||
bigtime_t pulseRate;
|
||||
if (data->FindInt64("_pulse", &pulseRate) == B_OK)
|
||||
SetPulseRate(pulseRate);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -861,6 +860,8 @@ BApplication::IsLaunching() const
|
||||
status_t
|
||||
BApplication::GetAppInfo(app_info *info) const
|
||||
{
|
||||
if (be_app == NULL || be_roster == NULL)
|
||||
return B_NO_INIT;
|
||||
return be_roster->GetRunningAppInfo(be_app->Team(), info);
|
||||
}
|
||||
|
||||
@ -879,9 +880,9 @@ BApplication::AppResources()
|
||||
bool found = false;
|
||||
|
||||
// App is already running. Get its entry ref with
|
||||
// GetRunningAppInfo()
|
||||
// GetAppInfo()
|
||||
app_info appInfo;
|
||||
if (be_app && be_roster->GetRunningAppInfo(be_app->Team(), &appInfo) == B_OK) {
|
||||
if (be_app && be_app->GetAppInfo(&appInfo) == B_OK) {
|
||||
ref = appInfo.ref;
|
||||
found = true;
|
||||
} else {
|
||||
@ -889,14 +890,16 @@ BApplication::AppResources()
|
||||
found = BPrivate::get_app_ref(&ref) == B_OK;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
BResources *resources = new BResources();
|
||||
if (resources->SetTo(&file, false) < B_OK)
|
||||
delete resources;
|
||||
else
|
||||
sAppResources = resources;
|
||||
if (!found)
|
||||
return NULL;
|
||||
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
sAppResources = new (nothrow) BResources(&file, false);
|
||||
if (sAppResources != NULL
|
||||
&& sAppResources->InitCheck() != B_OK) {
|
||||
delete sAppResources;
|
||||
sAppResources = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,9 @@ LinkReceiver::SetPort(port_id port)
|
||||
status_t
|
||||
LinkReceiver::GetNextMessage(int32 &code, bigtime_t timeout)
|
||||
{
|
||||
int32 remaining;
|
||||
|
||||
fReadError = B_OK;
|
||||
|
||||
remaining = fDataSize - (fRecvStart + fReplySize);
|
||||
int32 remaining = fDataSize - (fRecvStart + fReplySize);
|
||||
STRACE(("info: LinkReceiver GetNextReply() reports %ld bytes remaining in buffer.\n", remaining));
|
||||
|
||||
// find the position of the next message header in the buffer
|
||||
@ -277,14 +275,12 @@ status_t
|
||||
LinkReceiver::ReadString(char** _string, size_t* _length)
|
||||
{
|
||||
int32 length = 0;
|
||||
status_t status;
|
||||
status_t status = Read<int32>(&length);
|
||||
|
||||
status = Read<int32>(&length);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
char *string;
|
||||
|
||||
if (length < 0) {
|
||||
status = B_ERROR;
|
||||
goto err;
|
||||
@ -309,6 +305,7 @@ LinkReceiver::ReadString(char** _string, size_t* _length)
|
||||
|
||||
if (_length)
|
||||
*_length = length;
|
||||
|
||||
*_string = string;
|
||||
|
||||
return B_OK;
|
||||
@ -324,9 +321,8 @@ status_t
|
||||
LinkReceiver::ReadString(BString &string, size_t* _length)
|
||||
{
|
||||
int32 length = 0;
|
||||
status_t status;
|
||||
status_t status = Read<int32>(&length);
|
||||
|
||||
status = Read<int32>(&length);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
@ -370,9 +366,8 @@ status_t
|
||||
LinkReceiver::ReadString(char *buffer, size_t bufferLength)
|
||||
{
|
||||
int32 length = 0;
|
||||
status_t status;
|
||||
status_t status = Read<int32>(&length);
|
||||
|
||||
status = Read<int32>(&length);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
|
@ -195,8 +195,7 @@ LinkSender::AdjustBuffer(size_t newSize, char **_oldBuffer)
|
||||
return B_BUFFER_OVERFLOW;
|
||||
else if (newSize > kInitialBufferSize)
|
||||
newSize = (newSize + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
|
||||
|
||||
char *buffer = NULL;
|
||||
|
||||
if (newSize == fBufferSize) {
|
||||
// keep existing buffer
|
||||
if (_oldBuffer)
|
||||
@ -205,7 +204,7 @@ LinkSender::AdjustBuffer(size_t newSize, char **_oldBuffer)
|
||||
}
|
||||
|
||||
// create new larger buffer
|
||||
buffer = (char *)malloc(newSize);
|
||||
char *buffer = (char *)malloc(newSize);
|
||||
if (buffer == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
|
@ -1,105 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: PortQueue.cpp
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: Facilitation class for reading and queueing messages from ports
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "PortQueue.h"
|
||||
#include "PortMessage.h"
|
||||
|
||||
PortQueue::PortQueue(const port_id &port)
|
||||
{
|
||||
port_info pi;
|
||||
_init=(get_port_info(port,&pi)==B_OK)?true:false;
|
||||
_port=port;
|
||||
}
|
||||
|
||||
PortQueue::~PortQueue(void)
|
||||
{
|
||||
MakeEmpty();
|
||||
}
|
||||
|
||||
bool PortQueue::SetPort(const port_id &port)
|
||||
{
|
||||
port_info pi;
|
||||
_init=(get_port_info(port,&pi)==B_OK)?true:false;
|
||||
_port=port;
|
||||
|
||||
return _init;
|
||||
}
|
||||
|
||||
void PortQueue::GetMessagesFromPort(bool wait_for_messages)
|
||||
{
|
||||
if(_init)
|
||||
{
|
||||
PortMessage *msg;
|
||||
ssize_t size;
|
||||
port_info pi;
|
||||
get_port_info(_port, &pi);
|
||||
status_t stat;
|
||||
|
||||
if(pi.queue_count==0 && wait_for_messages)
|
||||
{
|
||||
size=port_buffer_size(_port);
|
||||
// now that there is a message, we'll just fall through to the
|
||||
// port-emptying loop
|
||||
get_port_info(_port, &pi);
|
||||
}
|
||||
|
||||
for(int32 i=0; i<pi.queue_count; i++)
|
||||
{
|
||||
msg=new PortMessage();
|
||||
stat=msg->ReadFromPort(_port,0);
|
||||
|
||||
if(stat!=B_OK)
|
||||
{
|
||||
delete msg;
|
||||
break;
|
||||
}
|
||||
_q.push(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
PortMessage *PortQueue::GetMessageFromQueue(void)
|
||||
{
|
||||
if(_q.empty())
|
||||
return NULL;
|
||||
|
||||
PortMessage *msg=_q.front();
|
||||
_q.pop();
|
||||
return msg;
|
||||
}
|
||||
|
||||
void PortQueue::MakeEmpty(void)
|
||||
{
|
||||
PortMessage *msg;
|
||||
while(!_q.empty())
|
||||
{
|
||||
msg=_q.front();
|
||||
_q.pop();
|
||||
delete msg;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user