* Adjusted thread priorities of several system services based on a mail from
Mikhail Panasyuk: since worker threads often end up with B_NORMAL_PRIORITY, it might be a good idea to give system threads a higher priority. * Minor cleanup (mostly automatic whitespace). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33961 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2008, Haiku, Inc. All Rights Reserved.
|
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -164,6 +164,9 @@ InputServer::InputServer()
|
|||||||
CALLED();
|
CALLED();
|
||||||
gInputServer = this;
|
gInputServer = this;
|
||||||
|
|
||||||
|
set_thread_priority(find_thread(NULL), B_URGENT_DISPLAY_PRIORITY);
|
||||||
|
// elevate priority for client interaction
|
||||||
|
|
||||||
_StartEventLoop();
|
_StartEventLoop();
|
||||||
|
|
||||||
char parameter[32];
|
char parameter[32];
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public:
|
|||||||
|
|
||||||
if (message.FindInt32("uid", &intValue) == B_OK)
|
if (message.FindInt32("uid", &intValue) == B_OK)
|
||||||
fUID = intValue;
|
fUID = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("gid", &intValue) == B_OK)
|
if (message.FindInt32("gid", &intValue) == B_OK)
|
||||||
fGID = intValue;
|
fGID = intValue;
|
||||||
|
|
||||||
@@ -207,22 +207,22 @@ public:
|
|||||||
|
|
||||||
if (message.FindInt32("last changed", &intValue) == B_OK)
|
if (message.FindInt32("last changed", &intValue) == B_OK)
|
||||||
fLastChanged = intValue;
|
fLastChanged = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("min", &intValue) == B_OK)
|
if (message.FindInt32("min", &intValue) == B_OK)
|
||||||
fMin = intValue;
|
fMin = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("max", &intValue) == B_OK)
|
if (message.FindInt32("max", &intValue) == B_OK)
|
||||||
fMax = intValue;
|
fMax = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("warn", &intValue) == B_OK)
|
if (message.FindInt32("warn", &intValue) == B_OK)
|
||||||
fWarn = intValue;
|
fWarn = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("inactive", &intValue) == B_OK)
|
if (message.FindInt32("inactive", &intValue) == B_OK)
|
||||||
fInactive = intValue;
|
fInactive = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("expiration", &intValue) == B_OK)
|
if (message.FindInt32("expiration", &intValue) == B_OK)
|
||||||
fExpiration = intValue;
|
fExpiration = intValue;
|
||||||
|
|
||||||
if (message.FindInt32("flags", &intValue) == B_OK)
|
if (message.FindInt32("flags", &intValue) == B_OK)
|
||||||
fFlags = intValue;
|
fFlags = intValue;
|
||||||
}
|
}
|
||||||
@@ -654,7 +654,7 @@ AuthenticationManager::Init()
|
|||||||
return fRequestPort;
|
return fRequestPort;
|
||||||
|
|
||||||
fRequestThread = spawn_thread(&_RequestThreadEntry,
|
fRequestThread = spawn_thread(&_RequestThreadEntry,
|
||||||
"authentication manager", B_NORMAL_PRIORITY, this);
|
"authentication manager", B_NORMAL_PRIORITY + 1, this);
|
||||||
if (fRequestThread < 0)
|
if (fRequestThread < 0)
|
||||||
return fRequestThread;
|
return fRequestThread;
|
||||||
|
|
||||||
@@ -947,7 +947,7 @@ AuthenticationManager::_RequestThread()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace the old user and write DBs to disk
|
// replace the old user and write DBs to disk
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
fUserDB->AddUser(user);
|
fUserDB->AddUser(user);
|
||||||
fUserDB->WriteToDisk();
|
fUserDB->WriteToDisk();
|
||||||
|
|||||||
@@ -1,42 +1,25 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2002, OpenBeOS
|
* Copyright 2001-2009, Haiku Inc.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* Ingo Weinhold (bonefish@users.sf.net)
|
||||||
// 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:
|
|
||||||
//
|
#include "EventQueue.h"
|
||||||
// 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: EventQueue.cpp
|
|
||||||
// Author: Ingo Weinhold ([email protected])
|
|
||||||
// YellowBites (http://www.yellowbites.com)
|
|
||||||
// Description: A class providing a mechanism for executing events at
|
|
||||||
// specified times.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "EventQueue.h"
|
|
||||||
|
|
||||||
static const char *kDefaultEventQueueName = "event looper";
|
static const char *kDefaultEventQueueName = "event looper";
|
||||||
|
|
||||||
/*!
|
|
||||||
\class EventQueue
|
/*! \class EventQueue
|
||||||
\brief A class providing a mechanism for executing events at specified
|
\brief A class providing a mechanism for executing events at specified
|
||||||
times.
|
times.
|
||||||
|
|
||||||
@@ -51,7 +34,7 @@ static const char *kDefaultEventQueueName = "event looper";
|
|||||||
method return \c true, the event object is deleted after execution. In
|
method return \c true, the event object is deleted after execution. In
|
||||||
any case the event is removed from the list before it is executed. The
|
any case the event is removed from the list before it is executed. The
|
||||||
queue is not locked while an event is executed.
|
queue is not locked while an event is executed.
|
||||||
|
|
||||||
The event list (\a fEvents) is ordered ascendingly by time. The thread
|
The event list (\a fEvents) is ordered ascendingly by time. The thread
|
||||||
uses a semaphore (\a fLooperControl) to wait (time out) for the next
|
uses a semaphore (\a fLooperControl) to wait (time out) for the next
|
||||||
event. This semaphore is released to indicate changes to the event list.
|
event. This semaphore is released to indicate changes to the event list.
|
||||||
@@ -88,7 +71,6 @@ static const char *kDefaultEventQueueName = "event looper";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
/*! \brief Creates a new event queue.
|
/*! \brief Creates a new event queue.
|
||||||
|
|
||||||
The status of the initialization can and should be check with InitCheck().
|
The status of the initialization can and should be check with InitCheck().
|
||||||
@@ -97,12 +79,13 @@ static const char *kDefaultEventQueueName = "event looper";
|
|||||||
a default name is used.
|
a default name is used.
|
||||||
*/
|
*/
|
||||||
EventQueue::EventQueue(const char *name)
|
EventQueue::EventQueue(const char *name)
|
||||||
: fEvents(100),
|
:
|
||||||
fEventLooper(-1),
|
fEvents(100),
|
||||||
fLooperControl(-1),
|
fEventLooper(-1),
|
||||||
fNextEventTime(0),
|
fLooperControl(-1),
|
||||||
fStatus(B_ERROR),
|
fNextEventTime(0),
|
||||||
fTerminating(false)
|
fStatus(B_ERROR),
|
||||||
|
fTerminating(false)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
name = kDefaultEventQueueName;
|
name = kDefaultEventQueueName;
|
||||||
@@ -112,8 +95,8 @@ EventQueue::EventQueue(const char *name)
|
|||||||
else
|
else
|
||||||
fStatus = fLooperControl;
|
fStatus = fLooperControl;
|
||||||
if (fStatus == B_OK) {
|
if (fStatus == B_OK) {
|
||||||
fEventLooper = spawn_thread(_EventLooperEntry, name, B_NORMAL_PRIORITY,
|
fEventLooper = spawn_thread(_EventLooperEntry, name,
|
||||||
this);
|
B_DISPLAY_PRIORITY + 1, this);
|
||||||
if (fEventLooper >= B_OK) {
|
if (fEventLooper >= B_OK) {
|
||||||
fStatus = B_OK;
|
fStatus = B_OK;
|
||||||
resume_thread(fEventLooper);
|
resume_thread(fEventLooper);
|
||||||
@@ -122,7 +105,7 @@ EventQueue::EventQueue(const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
/*! \brief Frees all resources associated by this object.
|
/*! \brief Frees all resources associated by this object.
|
||||||
|
|
||||||
Die() is called to terminate the queue's thread and all events whose
|
Die() is called to terminate the queue's thread and all events whose
|
||||||
@@ -137,7 +120,7 @@ EventQueue::~EventQueue()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitCheck
|
|
||||||
/*! \brief Returns the initialization status of the event queue.
|
/*! \brief Returns the initialization status of the event queue.
|
||||||
\return \c B_OK, if everything went fine, an error code otherwise.
|
\return \c B_OK, if everything went fine, an error code otherwise.
|
||||||
*/
|
*/
|
||||||
@@ -147,7 +130,7 @@ EventQueue::InitCheck()
|
|||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die
|
|
||||||
/*! \brief Terminates the queue's thread.
|
/*! \brief Terminates the queue's thread.
|
||||||
|
|
||||||
If an event is currently executed, it is allowed to finish its task
|
If an event is currently executed, it is allowed to finish its task
|
||||||
@@ -165,7 +148,7 @@ EventQueue::Die()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddEvent
|
|
||||||
/*! \brief Adds a new event to the queue.
|
/*! \brief Adds a new event to the queue.
|
||||||
|
|
||||||
The event's time must be set, before adding it. Afterwards ModifyEvent()
|
The event's time must be set, before adding it. Afterwards ModifyEvent()
|
||||||
@@ -188,7 +171,7 @@ EventQueue::AddEvent(Event *event)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveEvent
|
|
||||||
/*! \brief Removes an event from the queue.
|
/*! \brief Removes an event from the queue.
|
||||||
\param event The event to be removed.
|
\param event The event to be removed.
|
||||||
\return \c true, if the event has been removed successfully, \c false, if
|
\return \c true, if the event has been removed successfully, \c false, if
|
||||||
@@ -205,7 +188,7 @@ EventQueue::RemoveEvent(Event *event)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModifyEvent
|
|
||||||
/*! \brief Modifies an event's time.
|
/*! \brief Modifies an event's time.
|
||||||
|
|
||||||
The event must be in the queue.
|
The event must be in the queue.
|
||||||
@@ -228,7 +211,7 @@ EventQueue::ModifyEvent(Event *event, bigtime_t newTime)
|
|||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// _AddEvent
|
|
||||||
/*! \brief Adds an event to the event list.
|
/*! \brief Adds an event to the event list.
|
||||||
|
|
||||||
\note The object must be locked when this method is invoked.
|
\note The object must be locked when this method is invoked.
|
||||||
@@ -244,7 +227,7 @@ EventQueue::_AddEvent(Event *event)
|
|||||||
return fEvents.AddItem(event, index);
|
return fEvents.AddItem(event, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _RemoveEvent
|
|
||||||
/*! \brief Removes an event from the event list.
|
/*! \brief Removes an event from the event list.
|
||||||
|
|
||||||
\note The object must be locked when this method is invoked.
|
\note The object must be locked when this method is invoked.
|
||||||
@@ -260,7 +243,7 @@ EventQueue::_RemoveEvent(Event *event)
|
|||||||
return (index >= 0 && fEvents.RemoveItem(index));
|
return (index >= 0 && fEvents.RemoveItem(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
// _EventAt
|
|
||||||
/*! \brief Returns an event from the event list.
|
/*! \brief Returns an event from the event list.
|
||||||
|
|
||||||
\note The object must be locked when this method is invoked.
|
\note The object must be locked when this method is invoked.
|
||||||
@@ -274,7 +257,7 @@ EventQueue::_EventAt(int32 index) const
|
|||||||
return (Event*)fEvents.ItemAt(index);
|
return (Event*)fEvents.ItemAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _IndexOfEvent
|
|
||||||
/*! \brief Returns the event list index of the supplied event.
|
/*! \brief Returns the event list index of the supplied event.
|
||||||
|
|
||||||
\note The object must be locked when this method is invoked.
|
\note The object must be locked when this method is invoked.
|
||||||
@@ -299,7 +282,7 @@ EventQueue::_IndexOfEvent(Event *event) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _FindInsertionIndex
|
|
||||||
/*! \brief Finds the event list index at which an event with the supplied
|
/*! \brief Finds the event list index at which an event with the supplied
|
||||||
has to be added.
|
has to be added.
|
||||||
|
|
||||||
@@ -330,7 +313,7 @@ EventQueue::_FindInsertionIndex(bigtime_t time) const
|
|||||||
return lower;
|
return lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _EventLooperEntry
|
|
||||||
/*! \brief Entry point from the queue's thread.
|
/*! \brief Entry point from the queue's thread.
|
||||||
\param data The queue's \c this pointer.
|
\param data The queue's \c this pointer.
|
||||||
\return The thread's result. Of no relevance in this case.
|
\return The thread's result. Of no relevance in this case.
|
||||||
@@ -341,7 +324,7 @@ EventQueue::_EventLooperEntry(void *data)
|
|||||||
return ((EventQueue*)data)->_EventLooper();
|
return ((EventQueue*)data)->_EventLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
// _EventLooper
|
|
||||||
/*! \brief Method with the main loop of the queue's thread.
|
/*! \brief Method with the main loop of the queue's thread.
|
||||||
\return The thread's result. Of no relevance in this case.
|
\return The thread's result. Of no relevance in this case.
|
||||||
*/
|
*/
|
||||||
@@ -385,7 +368,7 @@ EventQueue::_EventLooper()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _Reschedule
|
|
||||||
/*! \brief To be called, when an event has been added or removed.
|
/*! \brief To be called, when an event has been added or removed.
|
||||||
|
|
||||||
Checks whether the queue's thread has to recalculate the time when it
|
Checks whether the queue's thread has to recalculate the time when it
|
||||||
@@ -402,4 +385,3 @@ EventQueue::_Reschedule()
|
|||||||
release_sem(fLooperControl);
|
release_sem(fLooperControl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
// MIMEManager.cpp
|
/*
|
||||||
|
* Copyright 2002-2009, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Ingo Weinhold (bonefish@users.sf.net)
|
||||||
|
* Tyler Dauwalder
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "MIMEManager.h"
|
#include "MIMEManager.h"
|
||||||
|
|
||||||
@@ -19,23 +27,25 @@
|
|||||||
#include "TextSnifferAddon.h"
|
#include "TextSnifferAddon.h"
|
||||||
#include "UpdateMimeInfoThread.h"
|
#include "UpdateMimeInfoThread.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
/*!
|
|
||||||
\class MIMEManager
|
/*! \class MIMEManager
|
||||||
\brief MIMEManager handles communication between BMimeType and the system-wide
|
\brief MIMEManager handles communication between BMimeType and the system-wide
|
||||||
MimeDatabase object for BMimeType's write and non-atomic read functions.
|
MimeDatabase object for BMimeType's write and non-atomic read functions.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// constructor
|
|
||||||
/*! \brief Creates and initializes a MIMEManager.
|
/*! \brief Creates and initializes a MIMEManager.
|
||||||
*/
|
*/
|
||||||
MIMEManager::MIMEManager()
|
MIMEManager::MIMEManager()
|
||||||
: BLooper("main_mime")
|
:
|
||||||
, fDatabase()
|
BLooper("main_mime"),
|
||||||
, fThreadManager()
|
fDatabase(),
|
||||||
|
fThreadManager()
|
||||||
{
|
{
|
||||||
AddHandler(&fThreadManager);
|
AddHandler(&fThreadManager);
|
||||||
|
|
||||||
@@ -48,14 +58,14 @@ MIMEManager::MIMEManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
/*! \brief Frees all resources associate with this object.
|
/*! \brief Frees all resources associate with this object.
|
||||||
*/
|
*/
|
||||||
MIMEManager::~MIMEManager()
|
MIMEManager::~MIMEManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageReceived
|
|
||||||
/*! \brief Overrides the super class version to handle the MIME specific
|
/*! \brief Overrides the super class version to handle the MIME specific
|
||||||
messages.
|
messages.
|
||||||
\param message The message to be handled
|
\param message The message to be handled
|
||||||
@@ -70,66 +80,65 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
case B_REG_MIME_SET_PARAM:
|
case B_REG_MIME_SET_PARAM:
|
||||||
HandleSetParam(message);
|
HandleSetParam(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_REG_MIME_DELETE_PARAM:
|
case B_REG_MIME_DELETE_PARAM:
|
||||||
HandleDeleteParam(message);
|
HandleDeleteParam(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_REG_MIME_START_WATCHING:
|
case B_REG_MIME_START_WATCHING:
|
||||||
case B_REG_MIME_STOP_WATCHING:
|
case B_REG_MIME_STOP_WATCHING:
|
||||||
{
|
{
|
||||||
BMessenger messenger;
|
BMessenger messenger;
|
||||||
err = message->FindMessenger("target", &messenger);
|
err = message->FindMessenger("target", &messenger);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
err = message->what == B_REG_MIME_START_WATCHING
|
err = message->what == B_REG_MIME_START_WATCHING
|
||||||
? fDatabase.StartWatching(messenger)
|
? fDatabase.StartWatching(messenger)
|
||||||
: fDatabase.StopWatching(messenger);
|
: fDatabase.StopWatching(messenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_INSTALL:
|
case B_REG_MIME_INSTALL:
|
||||||
case B_REG_MIME_DELETE:
|
case B_REG_MIME_DELETE:
|
||||||
{
|
{
|
||||||
const char *type;
|
const char *type;
|
||||||
err = message->FindString("type", &type);
|
err = message->FindString("type", &type);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->what == B_REG_MIME_INSTALL
|
err = message->what == B_REG_MIME_INSTALL
|
||||||
? fDatabase.Install(type)
|
? fDatabase.Install(type) : fDatabase.Delete(type);
|
||||||
: fDatabase.Delete(type);
|
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_GET_INSTALLED_TYPES:
|
case B_REG_MIME_GET_INSTALLED_TYPES:
|
||||||
{
|
{
|
||||||
const char *supertype;
|
const char *supertype;
|
||||||
err = message->FindString("supertype", &supertype);
|
err = message->FindString("supertype", &supertype);
|
||||||
if (err == B_NAME_NOT_FOUND)
|
if (err == B_NAME_NOT_FOUND)
|
||||||
err = fDatabase.GetInstalledTypes(&reply);
|
err = fDatabase.GetInstalledTypes(&reply);
|
||||||
else if (!err)
|
else if (!err)
|
||||||
err = fDatabase.GetInstalledTypes(supertype, &reply);
|
err = fDatabase.GetInstalledTypes(supertype, &reply);
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_GET_INSTALLED_SUPERTYPES:
|
case B_REG_MIME_GET_INSTALLED_SUPERTYPES:
|
||||||
{
|
{
|
||||||
err = fDatabase.GetInstalledSupertypes(&reply);
|
err = fDatabase.GetInstalledSupertypes(&reply);
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,28 +146,28 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
const char *type;
|
const char *type;
|
||||||
err = message->FindString("type", &type);
|
err = message->FindString("type", &type);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = fDatabase.GetSupportingApps(type, &reply);
|
err = fDatabase.GetSupportingApps(type, &reply);
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_GET_ASSOCIATED_TYPES:
|
case B_REG_MIME_GET_ASSOCIATED_TYPES:
|
||||||
{
|
{
|
||||||
const char *extension;
|
const char *extension;
|
||||||
err = message->FindString("extension", &extension);
|
err = message->FindString("extension", &extension);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = fDatabase.GetAssociatedTypes(extension, &reply);
|
err = fDatabase.GetAssociatedTypes(extension, &reply);
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_SNIFF:
|
case B_REG_MIME_SNIFF:
|
||||||
{
|
{
|
||||||
BString str;
|
BString str;
|
||||||
@@ -182,31 +191,31 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.AddString("mime type", str);
|
err = reply.AddString("mime type", str);
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_CREATE_APP_META_MIME:
|
case B_REG_MIME_CREATE_APP_META_MIME:
|
||||||
case B_REG_MIME_UPDATE_MIME_INFO:
|
case B_REG_MIME_UPDATE_MIME_INFO:
|
||||||
{
|
{
|
||||||
using BPrivate::Storage::Mime::MimeUpdateThread;
|
using BPrivate::Storage::Mime::MimeUpdateThread;
|
||||||
using BPrivate::Storage::Mime::CreateAppMetaMimeThread;
|
using BPrivate::Storage::Mime::CreateAppMetaMimeThread;
|
||||||
using BPrivate::Storage::Mime::UpdateMimeInfoThread;
|
using BPrivate::Storage::Mime::UpdateMimeInfoThread;
|
||||||
|
|
||||||
entry_ref root;
|
entry_ref root;
|
||||||
bool recursive;
|
bool recursive;
|
||||||
bool synchronous = false;
|
bool synchronous = false;
|
||||||
int32 force;
|
int32 force;
|
||||||
|
|
||||||
MimeUpdateThread *thread = NULL;
|
MimeUpdateThread *thread = NULL;
|
||||||
|
|
||||||
status_t threadStatus = B_NO_INIT;
|
status_t threadStatus = B_NO_INIT;
|
||||||
bool messageIsDetached = false;
|
bool messageIsDetached = false;
|
||||||
bool stillOwnsThread = true;
|
bool stillOwnsThread = true;
|
||||||
|
|
||||||
// Gather our arguments
|
// Gather our arguments
|
||||||
err = message->FindRef("entry", &root);
|
err = message->FindRef("entry", &root);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -215,13 +224,13 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
err = message->FindBool("synchronous", &synchronous);
|
err = message->FindBool("synchronous", &synchronous);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindInt32("force", &force);
|
err = message->FindInt32("force", &force);
|
||||||
|
|
||||||
// Detach the message for synchronous calls
|
// Detach the message for synchronous calls
|
||||||
if (!err && synchronous) {
|
if (!err && synchronous) {
|
||||||
DetachCurrentMessage();
|
DetachCurrentMessage();
|
||||||
messageIsDetached = true;
|
messageIsDetached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the appropriate flavor of mime update thread
|
// Create the appropriate flavor of mime update thread
|
||||||
if (!err) {
|
if (!err) {
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -229,30 +238,30 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
thread = new(nothrow) CreateAppMetaMimeThread(
|
thread = new(nothrow) CreateAppMetaMimeThread(
|
||||||
synchronous ? "create_app_meta_mime (s)"
|
synchronous ? "create_app_meta_mime (s)"
|
||||||
: "create_app_meta_mime (a)",
|
: "create_app_meta_mime (a)",
|
||||||
B_NORMAL_PRIORITY, &fDatabase,
|
B_NORMAL_PRIORITY + 1, &fDatabase,
|
||||||
BMessenger(&fThreadManager), &root, recursive,
|
BMessenger(&fThreadManager), &root, recursive,
|
||||||
force, synchronous ? message : NULL);
|
force, synchronous ? message : NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_REG_MIME_UPDATE_MIME_INFO:
|
case B_REG_MIME_UPDATE_MIME_INFO:
|
||||||
thread = new(nothrow) UpdateMimeInfoThread(synchronous
|
thread = new(nothrow) UpdateMimeInfoThread(synchronous
|
||||||
? "update_mime_info (s)"
|
? "update_mime_info (s)"
|
||||||
: "update_mime_info (a)",
|
: "update_mime_info (a)",
|
||||||
B_NORMAL_PRIORITY, &fDatabase,
|
B_NORMAL_PRIORITY + 1, &fDatabase,
|
||||||
BMessenger(&fThreadManager), &root, recursive,
|
BMessenger(&fThreadManager), &root, recursive,
|
||||||
force, synchronous ? message : NULL);
|
force, synchronous ? message : NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = B_BAD_VALUE;
|
err = B_BAD_VALUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
err = thread ? B_OK : B_NO_MEMORY;
|
err = thread ? B_OK : B_NO_MEMORY;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = threadStatus = thread->InitCheck();
|
err = threadStatus = thread->InitCheck();
|
||||||
|
|
||||||
// Launch the thread
|
// Launch the thread
|
||||||
if (!err) {
|
if (!err) {
|
||||||
err = fThreadManager.LaunchThread(thread);
|
err = fThreadManager.LaunchThread(thread);
|
||||||
@@ -260,7 +269,7 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
stillOwnsThread = false;
|
stillOwnsThread = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If something went wrong, we need to notify the sender regardless. However,
|
// If something went wrong, we need to notify the sender regardless. However,
|
||||||
// if this is a synchronous call, we've already detached the message, and must
|
// if this is a synchronous call, we've already detached the message, and must
|
||||||
// be careful that it gets deleted once and only once. Thus, if the MimeUpdateThread
|
// be careful that it gets deleted once and only once. Thus, if the MimeUpdateThread
|
||||||
@@ -280,7 +289,7 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
delete thread;
|
delete thread;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("MIMEMan: msg->what == %lx (%.4s)\n", message->what,
|
printf("MIMEMan: msg->what == %lx (%.4s)\n", message->what,
|
||||||
(char*)&(message->what));
|
(char*)&(message->what));
|
||||||
@@ -289,7 +298,7 @@ MIMEManager::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleSetParam
|
|
||||||
//! Handles all B_REG_MIME_SET_PARAM messages
|
//! Handles all B_REG_MIME_SET_PARAM messages
|
||||||
void
|
void
|
||||||
MIMEManager::HandleSetParam(BMessage *message)
|
MIMEManager::HandleSetParam(BMessage *message)
|
||||||
@@ -297,7 +306,7 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
status_t err;
|
status_t err;
|
||||||
int32 which;
|
int32 which;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
err = message->FindString("type", &type);
|
err = message->FindString("type", &type);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindInt32("which", &which);
|
err = message->FindInt32("which", &which);
|
||||||
@@ -311,7 +320,7 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = fDatabase.SetAppHint(type, &ref);
|
err = fDatabase.SetAppHint(type, &ref);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_ATTR_INFO:
|
case B_REG_MIME_ATTR_INFO:
|
||||||
{
|
{
|
||||||
BMessage info;
|
BMessage info;
|
||||||
@@ -320,7 +329,7 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = fDatabase.SetAttrInfo(type, &info);
|
err = fDatabase.SetAttrInfo(type, &info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_DESCRIPTION:
|
case B_REG_MIME_DESCRIPTION:
|
||||||
{
|
{
|
||||||
bool isLong;
|
bool isLong;
|
||||||
@@ -328,13 +337,14 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = message->FindBool("long", &isLong);
|
err = message->FindBool("long", &isLong);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindString("description", &description);
|
err = message->FindString("description", &description);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = (isLong
|
err = isLong
|
||||||
? fDatabase.SetLongDescription(type, description)
|
? fDatabase.SetLongDescription(type, description)
|
||||||
: fDatabase.SetShortDescription(type, description));
|
: fDatabase.SetShortDescription(type, description);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_FILE_EXTENSIONS:
|
case B_REG_MIME_FILE_EXTENSIONS:
|
||||||
{
|
{
|
||||||
BMessage extensions;
|
BMessage extensions;
|
||||||
@@ -343,32 +353,35 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = fDatabase.SetFileExtensions(type, &extensions);
|
err = fDatabase.SetFileExtensions(type, &extensions);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_ICON:
|
case B_REG_MIME_ICON:
|
||||||
case B_REG_MIME_ICON_FOR_TYPE:
|
case B_REG_MIME_ICON_FOR_TYPE:
|
||||||
{
|
{
|
||||||
const void *data;
|
const void *data;
|
||||||
ssize_t dataSize;
|
ssize_t dataSize;
|
||||||
int32 size;
|
int32 size;
|
||||||
err = message->FindData("icon data", B_RAW_TYPE, &data, &dataSize);
|
err = message->FindData("icon data", B_RAW_TYPE, &data,
|
||||||
|
&dataSize);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindInt32("icon size", &size);
|
err = message->FindInt32("icon size", &size);
|
||||||
if (which == B_REG_MIME_ICON_FOR_TYPE) {
|
if (which == B_REG_MIME_ICON_FOR_TYPE) {
|
||||||
const char *fileType;
|
const char *fileType;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindString("file type", &fileType);
|
err = message->FindString("file type", &fileType);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = size == -1 ?
|
err = size == -1
|
||||||
fDatabase.SetIconForType(type, fileType, data,
|
? fDatabase.SetIconForType(type, fileType, data,
|
||||||
dataSize) :
|
dataSize)
|
||||||
fDatabase.SetIconForType(type, fileType, data,
|
: fDatabase.SetIconForType(type, fileType, data,
|
||||||
dataSize, (icon_size)size);
|
dataSize, (icon_size)size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = size == -1 ?
|
err = size == -1
|
||||||
fDatabase.SetIcon(type, data, dataSize) :
|
? fDatabase.SetIcon(type, data, dataSize)
|
||||||
fDatabase.SetIcon(type, data, dataSize,
|
: fDatabase.SetIcon(type, data, dataSize,
|
||||||
(icon_size)size);
|
(icon_size)size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// End temporary fix code
|
// End temporary fix code
|
||||||
@@ -381,11 +394,13 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = message->FindString("signature", &signature);
|
err = message->FindString("signature", &signature);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindInt32("app verb", &verb);
|
err = message->FindInt32("app verb", &verb);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = fDatabase.SetPreferredApp(type, signature, (app_verb)verb);
|
err = fDatabase.SetPreferredApp(type, signature,
|
||||||
|
(app_verb)verb);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_SNIFFER_RULE:
|
case B_REG_MIME_SNIFFER_RULE:
|
||||||
{
|
{
|
||||||
const char *rule;
|
const char *rule;
|
||||||
@@ -394,7 +409,7 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = fDatabase.SetSnifferRule(type, rule);
|
err = fDatabase.SetSnifferRule(type, rule);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_SUPPORTED_TYPES:
|
case B_REG_MIME_SUPPORTED_TYPES:
|
||||||
{
|
{
|
||||||
BMessage types;
|
BMessage types;
|
||||||
@@ -406,29 +421,27 @@ MIMEManager::HandleSetParam(BMessage *message)
|
|||||||
err = fDatabase.SetSupportedTypes(type, &types, fullSync);
|
err = fDatabase.SetSupportedTypes(type, &types, fullSync);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = B_BAD_VALUE;
|
err = B_BAD_VALUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage reply(B_REG_RESULT);
|
BMessage reply(B_REG_RESULT);
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleSetParam
|
|
||||||
//! Handles all B_REG_MIME_SET_PARAM messages
|
//! Handles all B_REG_MIME_SET_PARAM messages
|
||||||
void
|
void
|
||||||
MIMEManager::HandleDeleteParam(BMessage *message)
|
MIMEManager::HandleDeleteParam(BMessage *message)
|
||||||
{
|
{
|
||||||
// using BPrivate::MimeDatabase;
|
|
||||||
|
|
||||||
status_t err;
|
status_t err;
|
||||||
int32 which;
|
int32 which;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
err = message->FindString("type", &type);
|
err = message->FindString("type", &type);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindInt32("which", &which);
|
err = message->FindInt32("which", &which);
|
||||||
@@ -441,21 +454,22 @@ MIMEManager::HandleDeleteParam(BMessage *message)
|
|||||||
case B_REG_MIME_ATTR_INFO:
|
case B_REG_MIME_ATTR_INFO:
|
||||||
err = fDatabase.DeleteAttrInfo(type);
|
err = fDatabase.DeleteAttrInfo(type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_REG_MIME_DESCRIPTION:
|
case B_REG_MIME_DESCRIPTION:
|
||||||
{
|
{
|
||||||
bool isLong;
|
bool isLong;
|
||||||
err = message->FindBool("long", &isLong);
|
err = message->FindBool("long", &isLong);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = isLong
|
err = isLong
|
||||||
? fDatabase.DeleteLongDescription(type)
|
? fDatabase.DeleteLongDescription(type)
|
||||||
: fDatabase.DeleteShortDescription(type);
|
: fDatabase.DeleteShortDescription(type);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_FILE_EXTENSIONS:
|
case B_REG_MIME_FILE_EXTENSIONS:
|
||||||
err = fDatabase.DeleteFileExtensions(type);
|
err = fDatabase.DeleteFileExtensions(type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_REG_MIME_ICON:
|
case B_REG_MIME_ICON:
|
||||||
case B_REG_MIME_ICON_FOR_TYPE:
|
case B_REG_MIME_ICON_FOR_TYPE:
|
||||||
@@ -466,19 +480,22 @@ MIMEManager::HandleDeleteParam(BMessage *message)
|
|||||||
const char *fileType;
|
const char *fileType;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = message->FindString("file type", &fileType);
|
err = message->FindString("file type", &fileType);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = (size == -1) ?
|
err = size == -1
|
||||||
fDatabase.DeleteIconForType(type, fileType) :
|
? fDatabase.DeleteIconForType(type, fileType)
|
||||||
fDatabase.DeleteIconForType(type, fileType, (icon_size)size);
|
: fDatabase.DeleteIconForType(type, fileType,
|
||||||
|
(icon_size)size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = (size == -1) ?
|
err = size == -1
|
||||||
fDatabase.DeleteIcon(type) :
|
? fDatabase.DeleteIcon(type)
|
||||||
fDatabase.DeleteIcon(type, (icon_size)size);
|
: fDatabase.DeleteIcon(type, (icon_size)size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_PREFERRED_APP:
|
case B_REG_MIME_PREFERRED_APP:
|
||||||
{
|
{
|
||||||
int32 verb;
|
int32 verb;
|
||||||
@@ -487,10 +504,10 @@ MIMEManager::HandleDeleteParam(BMessage *message)
|
|||||||
err = fDatabase.DeletePreferredApp(type, (app_verb)verb);
|
err = fDatabase.DeletePreferredApp(type, (app_verb)verb);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_MIME_SNIFFER_RULE:
|
case B_REG_MIME_SNIFFER_RULE:
|
||||||
err = fDatabase.DeleteSnifferRule(type);
|
err = fDatabase.DeleteSnifferRule(type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_REG_MIME_SUPPORTED_TYPES:
|
case B_REG_MIME_SUPPORTED_TYPES:
|
||||||
{
|
{
|
||||||
@@ -499,16 +516,16 @@ MIMEManager::HandleDeleteParam(BMessage *message)
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = fDatabase.DeleteSupportedTypes(type, fullSync);
|
err = fDatabase.DeleteSupportedTypes(type, fullSync);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = B_BAD_VALUE;
|
err = B_BAD_VALUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage reply(B_REG_RESULT);
|
BMessage reply(B_REG_RESULT);
|
||||||
reply.AddInt32("result", err);
|
reply.AddInt32("result", err);
|
||||||
message->SendReply(&reply, this);
|
message->SendReply(&reply, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
|
* Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -298,12 +298,12 @@ public:
|
|||||||
fMessage = other.fMessage;
|
fMessage = other.fMessage;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const TargetMessageHandle &other) const
|
bool operator==(const TargetMessageHandle &other) const
|
||||||
{
|
{
|
||||||
return (fMessage == other.fMessage);
|
return (fMessage == other.fMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const TargetMessageHandle &other) const
|
bool operator!=(const TargetMessageHandle &other) const
|
||||||
{
|
{
|
||||||
return (fMessage != other.fMessage);
|
return (fMessage != other.fMessage);
|
||||||
@@ -321,7 +321,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TargetMessage *fMessage;
|
TargetMessage *fMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TargetPort
|
// TargetPort
|
||||||
@@ -509,7 +509,7 @@ MessageDeliverer::Init()
|
|||||||
|
|
||||||
// spawn the deliverer thread
|
// spawn the deliverer thread
|
||||||
fDelivererThread = spawn_thread(MessageDeliverer::_DelivererThreadEntry,
|
fDelivererThread = spawn_thread(MessageDeliverer::_DelivererThreadEntry,
|
||||||
"message deliverer", B_NORMAL_PRIORITY, this);
|
"message deliverer", B_NORMAL_PRIORITY + 1, this);
|
||||||
if (fDelivererThread < 0)
|
if (fDelivererThread < 0)
|
||||||
return fDelivererThread;
|
return fDelivererThread;
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ MessageDeliverer::Default()
|
|||||||
\return
|
\return
|
||||||
- \c B_OK, if sending the message succeeded or if the target port was
|
- \c B_OK, if sending the message succeeded or if the target port was
|
||||||
full and the message has been queued,
|
full and the message has been queued,
|
||||||
- another error code otherwise.
|
- another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
MessageDeliverer::DeliverMessage(BMessage *message, BMessenger target,
|
MessageDeliverer::DeliverMessage(BMessage *message, BMessenger target,
|
||||||
@@ -597,7 +597,7 @@ MessageDeliverer::DeliverMessage(BMessage *message, BMessenger target,
|
|||||||
\return
|
\return
|
||||||
- \c B_OK, if for each of the given targets sending the message succeeded
|
- \c B_OK, if for each of the given targets sending the message succeeded
|
||||||
or if the target port was full and the message has been queued,
|
or if the target port was full and the message has been queued,
|
||||||
- another error code otherwise.
|
- another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
MessageDeliverer::DeliverMessage(BMessage *message, MessagingTargetSet &targets,
|
MessageDeliverer::DeliverMessage(BMessage *message, MessagingTargetSet &targets,
|
||||||
@@ -632,7 +632,7 @@ MessageDeliverer::DeliverMessage(BMessage *message, MessagingTargetSet &targets,
|
|||||||
\return
|
\return
|
||||||
- \c B_OK, if for each of the given targets sending the message succeeded
|
- \c B_OK, if for each of the given targets sending the message succeeded
|
||||||
or if the target port was full and the message has been queued,
|
or if the target port was full and the message has been queued,
|
||||||
- another error code otherwise.
|
- another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
MessageDeliverer::DeliverMessage(const void *messageData, int32 messageSize,
|
MessageDeliverer::DeliverMessage(const void *messageData, int32 messageSize,
|
||||||
@@ -706,7 +706,7 @@ MessageDeliverer::_GetTargetPort(port_id portID, bool create)
|
|||||||
|
|
||||||
if (!create)
|
if (!create)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// create a port
|
// create a port
|
||||||
TargetPort *port = new(nothrow) TargetPort(portID);
|
TargetPort *port = new(nothrow) TargetPort(portID);
|
||||||
if (!port)
|
if (!port)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2001-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -54,7 +54,8 @@ static const bigtime_t kRosterSanityEventInterval = 1000000LL;
|
|||||||
error code.
|
error code.
|
||||||
*/
|
*/
|
||||||
Registrar::Registrar(status_t *error)
|
Registrar::Registrar(status_t *error)
|
||||||
: BServer(kRegistrarSignature, false, error),
|
:
|
||||||
|
BServer(kRegistrarSignature, false, error),
|
||||||
fRoster(NULL),
|
fRoster(NULL),
|
||||||
fClipboardHandler(NULL),
|
fClipboardHandler(NULL),
|
||||||
fMIMEManager(NULL),
|
fMIMEManager(NULL),
|
||||||
@@ -65,9 +66,11 @@ Registrar::Registrar(status_t *error)
|
|||||||
fAuthenticationManager(NULL)
|
fAuthenticationManager(NULL)
|
||||||
{
|
{
|
||||||
FUNCTION_START();
|
FUNCTION_START();
|
||||||
|
|
||||||
|
set_thread_priority(find_thread(NULL), B_NORMAL_PRIORITY + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
/*! \brief Frees all resources associated with the registrar.
|
/*! \brief Frees all resources associated with the registrar.
|
||||||
|
|
||||||
All registrar services, that haven't been shut down earlier, are
|
All registrar services, that haven't been shut down earlier, are
|
||||||
@@ -93,7 +96,7 @@ Registrar::~Registrar()
|
|||||||
FUNCTION_END();
|
FUNCTION_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageReceived
|
|
||||||
/*! \brief Overrides the super class version to dispatch roster specific
|
/*! \brief Overrides the super class version to dispatch roster specific
|
||||||
messages.
|
messages.
|
||||||
\param message The message to be handled
|
\param message The message to be handled
|
||||||
@@ -114,7 +117,7 @@ Registrar::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadyToRun
|
|
||||||
/*! \brief Overrides the super class version to initialize the registrar
|
/*! \brief Overrides the super class version to initialize the registrar
|
||||||
services.
|
services.
|
||||||
*/
|
*/
|
||||||
@@ -164,14 +167,14 @@ Registrar::ReadyToRun()
|
|||||||
|
|
||||||
// create and schedule the sanity message event
|
// create and schedule the sanity message event
|
||||||
fSanityEvent = new MessageEvent(system_time() + kRosterSanityEventInterval,
|
fSanityEvent = new MessageEvent(system_time() + kRosterSanityEventInterval,
|
||||||
this, B_REG_ROSTER_SANITY_EVENT);
|
this, B_REG_ROSTER_SANITY_EVENT);
|
||||||
fSanityEvent->SetAutoDelete(false);
|
fSanityEvent->SetAutoDelete(false);
|
||||||
fEventQueue->AddEvent(fSanityEvent);
|
fEventQueue->AddEvent(fSanityEvent);
|
||||||
|
|
||||||
FUNCTION_END();
|
FUNCTION_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
// QuitRequested
|
|
||||||
/*! \brief Overrides the super class version to avoid termination of the
|
/*! \brief Overrides the super class version to avoid termination of the
|
||||||
registrar until the system shutdown.
|
registrar until the system shutdown.
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +186,7 @@ Registrar::QuitRequested()
|
|||||||
return BApplication::QuitRequested();
|
return BApplication::QuitRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEventQueue
|
|
||||||
/*! \brief Returns the registrar's event queue.
|
/*! \brief Returns the registrar's event queue.
|
||||||
\return The registrar's event queue.
|
\return The registrar's event queue.
|
||||||
*/
|
*/
|
||||||
@@ -193,7 +196,7 @@ Registrar::GetEventQueue() const
|
|||||||
return fEventQueue;
|
return fEventQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// App
|
|
||||||
/*! \brief Returns the Registrar application object.
|
/*! \brief Returns the Registrar application object.
|
||||||
\return The Registrar application object.
|
\return The Registrar application object.
|
||||||
*/
|
*/
|
||||||
@@ -203,7 +206,7 @@ Registrar::App()
|
|||||||
return dynamic_cast<Registrar*>(be_app);
|
return dynamic_cast<Registrar*>(be_app);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _MessageReceived
|
|
||||||
void
|
void
|
||||||
Registrar::_MessageReceived(BMessage *message)
|
Registrar::_MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
@@ -283,7 +286,7 @@ Registrar::_MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
case B_REG_STOP_WATCHING:
|
case B_REG_STOP_WATCHING:
|
||||||
fRoster->HandleStopWatching(message);
|
fRoster->HandleStopWatching(message);
|
||||||
break;
|
break;
|
||||||
case B_REG_GET_RECENT_DOCUMENTS:
|
case B_REG_GET_RECENT_DOCUMENTS:
|
||||||
fRoster->HandleGetRecentDocuments(message);
|
fRoster->HandleGetRecentDocuments(message);
|
||||||
break;
|
break;
|
||||||
@@ -352,7 +355,7 @@ Registrar::_MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _HandleShutDown
|
|
||||||
/*! \brief Handle a shut down request message.
|
/*! \brief Handle a shut down request message.
|
||||||
\param request The request to be handled.
|
\param request The request to be handled.
|
||||||
*/
|
*/
|
||||||
@@ -414,7 +417,7 @@ main()
|
|||||||
// rename the main thread
|
// rename the main thread
|
||||||
rename_thread(find_thread(NULL), kRosterThreadName);
|
rename_thread(find_thread(NULL), kRosterThreadName);
|
||||||
|
|
||||||
PRINT(("app->Run()...\n"));
|
PRINT(("app->Run()...\n"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
app->Run();
|
app->Run();
|
||||||
@@ -427,7 +430,7 @@ PRINT(("app->Run()...\n"));
|
|||||||
debugger("registrar main() caught unknown exception");
|
debugger("registrar main() caught unknown exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT(("delete app...\n"));
|
PRINT(("delete app...\n"));
|
||||||
delete app;
|
delete app;
|
||||||
|
|
||||||
FUNCTION_END();
|
FUNCTION_END();
|
||||||
|
|||||||
@@ -695,8 +695,8 @@ ShutdownProcess::Init(BMessage* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start the worker thread
|
// start the worker thread
|
||||||
fWorker = spawn_thread(_WorkerEntry, "shutdown worker", B_NORMAL_PRIORITY,
|
fWorker = spawn_thread(_WorkerEntry, "shutdown worker",
|
||||||
this);
|
B_NORMAL_PRIORITY + 1, this);
|
||||||
if (fWorker < 0) {
|
if (fWorker < 0) {
|
||||||
fRoster->RemoveWatcher(this);
|
fRoster->RemoveWatcher(this);
|
||||||
fRoster->SetShuttingDown(false);
|
fRoster->SetShuttingDown(false);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -182,14 +182,14 @@ IOScheduler::Init(const char* name)
|
|||||||
strlcpy(buffer, name, sizeof(buffer));
|
strlcpy(buffer, name, sizeof(buffer));
|
||||||
strlcat(buffer, " scheduler", sizeof(buffer));
|
strlcat(buffer, " scheduler", sizeof(buffer));
|
||||||
fSchedulerThread = spawn_kernel_thread(&_SchedulerThread, buffer,
|
fSchedulerThread = spawn_kernel_thread(&_SchedulerThread, buffer,
|
||||||
B_NORMAL_PRIORITY, (void *)this);
|
B_NORMAL_PRIORITY + 2, (void *)this);
|
||||||
if (fSchedulerThread < B_OK)
|
if (fSchedulerThread < B_OK)
|
||||||
return fSchedulerThread;
|
return fSchedulerThread;
|
||||||
|
|
||||||
strlcpy(buffer, name, sizeof(buffer));
|
strlcpy(buffer, name, sizeof(buffer));
|
||||||
strlcat(buffer, " notifier", sizeof(buffer));
|
strlcat(buffer, " notifier", sizeof(buffer));
|
||||||
fRequestNotifierThread = spawn_kernel_thread(&_RequestNotifierThread,
|
fRequestNotifierThread = spawn_kernel_thread(&_RequestNotifierThread,
|
||||||
buffer, B_NORMAL_PRIORITY, (void *)this);
|
buffer, B_NORMAL_PRIORITY + 2, (void *)this);
|
||||||
if (fRequestNotifierThread < B_OK)
|
if (fRequestNotifierThread < B_OK)
|
||||||
return fRequestNotifierThread;
|
return fRequestNotifierThread;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user