* Style changes. No functional changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36966 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -96,7 +96,8 @@ static struct PageFormat
|
||||
};
|
||||
|
||||
|
||||
static void GetPageFormat(float w, float h, BString& label)
|
||||
static void
|
||||
GetPageFormat(float w, float h, BString& label)
|
||||
{
|
||||
w = floor(w + 0.5); h = floor(h + 0.5);
|
||||
for (uint i = 0; i < sizeof(pageFormat) / sizeof(struct PageFormat); i ++) {
|
||||
@@ -240,6 +241,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
||||
UpdateSettings(true);
|
||||
}
|
||||
|
||||
|
||||
ConfigWindow::~ConfigWindow()
|
||||
{
|
||||
if (fCurrentPrinter)
|
||||
@@ -248,7 +250,8 @@ ConfigWindow::~ConfigWindow()
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::Go()
|
||||
void
|
||||
ConfigWindow::Go()
|
||||
{
|
||||
sem_id sid = create_sem(0, "finished");
|
||||
if (sid >= 0) {
|
||||
@@ -262,7 +265,8 @@ void ConfigWindow::Go()
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::MessageReceived(BMessage* m)
|
||||
void
|
||||
ConfigWindow::MessageReceived(BMessage* m)
|
||||
{
|
||||
switch (m->what) {
|
||||
case MSG_PAGE_SETUP:
|
||||
@@ -313,7 +317,8 @@ ConfigWindow::AboutRequested()
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::FrameMoved(BPoint p)
|
||||
void
|
||||
ConfigWindow::FrameMoved(BPoint p)
|
||||
{
|
||||
BRect frame = GetWindowFrame();
|
||||
frame.OffsetTo(p);
|
||||
@@ -321,7 +326,8 @@ void ConfigWindow::FrameMoved(BPoint p)
|
||||
}
|
||||
|
||||
|
||||
BRect ConfigWindow::GetWindowFrame()
|
||||
BRect
|
||||
ConfigWindow::GetWindowFrame()
|
||||
{
|
||||
BAutolock lock(gLock);
|
||||
if (lock.IsLocked())
|
||||
@@ -331,7 +337,8 @@ BRect ConfigWindow::GetWindowFrame()
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::SetWindowFrame(BRect r)
|
||||
void
|
||||
ConfigWindow::SetWindowFrame(BRect r)
|
||||
{
|
||||
BAutolock lock(gLock);
|
||||
if (lock.IsLocked())
|
||||
@@ -339,7 +346,8 @@ void ConfigWindow::SetWindowFrame(BRect r)
|
||||
}
|
||||
|
||||
|
||||
BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
||||
BPictureButton*
|
||||
ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
||||
const char* name, const char* on, const char* off, uint32 what)
|
||||
{
|
||||
BBitmap* onBM = LoadBitmap(on);
|
||||
@@ -379,7 +387,8 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::PrinterForMimeType()
|
||||
void
|
||||
ConfigWindow::PrinterForMimeType()
|
||||
{
|
||||
BAutolock lock(gLock);
|
||||
if (fCurrentPrinter) {
|
||||
@@ -402,7 +411,8 @@ void ConfigWindow::PrinterForMimeType()
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::SetupPrintersMenu(BMenu* menu)
|
||||
void
|
||||
ConfigWindow::SetupPrintersMenu(BMenu* menu)
|
||||
{
|
||||
// clear menu
|
||||
while (menu->CountItems() != 0)
|
||||
@@ -426,7 +436,8 @@ void ConfigWindow::SetupPrintersMenu(BMenu* menu)
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::UpdateAppSettings(const char* mime, const char* printer)
|
||||
void
|
||||
ConfigWindow::UpdateAppSettings(const char* mime, const char* printer)
|
||||
{
|
||||
BAutolock lock(gLock);
|
||||
if (lock.IsLocked()) {
|
||||
@@ -440,7 +451,8 @@ void ConfigWindow::UpdateAppSettings(const char* mime, const char* printer)
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::UpdateSettings(bool read)
|
||||
void
|
||||
ConfigWindow::UpdateSettings(bool read)
|
||||
{
|
||||
BAutolock lock(gLock);
|
||||
if (lock.IsLocked()) {
|
||||
@@ -463,7 +475,8 @@ void ConfigWindow::UpdateSettings(bool read)
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::UpdateUI()
|
||||
void
|
||||
ConfigWindow::UpdateUI()
|
||||
{
|
||||
if (fCurrentPrinter == NULL) {
|
||||
fPageSetup->SetEnabled(false);
|
||||
@@ -545,7 +558,8 @@ void ConfigWindow::UpdateUI()
|
||||
}
|
||||
|
||||
|
||||
void ConfigWindow::Setup(config_setup_kind kind)
|
||||
void
|
||||
ConfigWindow::Setup(config_setup_kind kind)
|
||||
{
|
||||
if (fCurrentPrinter) {
|
||||
Hide();
|
||||
|
||||
@@ -48,7 +48,9 @@ struct AsyncThreadParams {
|
||||
}
|
||||
};
|
||||
|
||||
status_t PrintServerApp::async_thread(void* data)
|
||||
|
||||
status_t
|
||||
PrintServerApp::async_thread(void* data)
|
||||
{
|
||||
AsyncThreadParams* p = (AsyncThreadParams*)data;
|
||||
|
||||
@@ -153,7 +155,8 @@ status_t PrintServerApp::async_thread(void* data)
|
||||
|
||||
|
||||
// Async. processing of received message
|
||||
void PrintServerApp::AsyncHandleMessage(BMessage* msg)
|
||||
void
|
||||
PrintServerApp::AsyncHandleMessage(BMessage* msg)
|
||||
{
|
||||
AsyncThreadParams* data = new AsyncThreadParams(this, fDefaultPrinter, msg);
|
||||
|
||||
@@ -167,7 +170,9 @@ void PrintServerApp::AsyncHandleMessage(BMessage* msg)
|
||||
}
|
||||
}
|
||||
|
||||
void PrintServerApp::Handle_BeOSR5_Message(BMessage* msg)
|
||||
|
||||
void
|
||||
PrintServerApp::Handle_BeOSR5_Message(BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
// Get currently selected printer
|
||||
@@ -218,3 +223,4 @@ void PrintServerApp::Handle_BeOSR5_Message(BMessage* msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ static property_info prop_list[] = {
|
||||
{ 0 } // terminate list
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
PrintServerApp::HandleScriptingCommand(BMessage* msg)
|
||||
{
|
||||
@@ -131,7 +132,9 @@ PrintServerApp::HandleScriptingCommand(BMessage* msg)
|
||||
}
|
||||
}
|
||||
|
||||
Printer* PrintServerApp::GetPrinterFromSpecifier(BMessage* msg)
|
||||
|
||||
Printer*
|
||||
PrintServerApp::GetPrinterFromSpecifier(BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case B_NAME_SPECIFIER: {
|
||||
@@ -162,7 +165,9 @@ Printer* PrintServerApp::GetPrinterFromSpecifier(BMessage* msg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Transport* PrintServerApp::GetTransportFromSpecifier(BMessage* msg)
|
||||
|
||||
Transport*
|
||||
PrintServerApp::GetTransportFromSpecifier(BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case B_NAME_SPECIFIER: {
|
||||
@@ -193,6 +198,7 @@ Transport* PrintServerApp::GetTransportFromSpecifier(BMessage* msg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
BHandler*
|
||||
PrintServerApp::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
int32 form, const char* prop)
|
||||
@@ -234,6 +240,7 @@ PrintServerApp::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PrintServerApp::GetSupportedSuites(BMessage* msg)
|
||||
{
|
||||
|
||||
@@ -41,17 +41,22 @@
|
||||
#define B_TRANSLATE_CONTEXT "PrintServerApp"
|
||||
|
||||
|
||||
BLocker *gLock = NULL;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
typedef struct _printer_data {
|
||||
char defaultPrinterName[256];
|
||||
} printer_data_t;
|
||||
|
||||
|
||||
typedef BMessage* (*config_func_t)(BNode*, const BMessage*);
|
||||
typedef BMessage* (*take_job_func_t)(BFile*, BNode*, const BMessage*);
|
||||
typedef char* (*add_printer_func_t)(const char* printer_name);
|
||||
|
||||
|
||||
static const char* kSettingsName = "print_server_settings";
|
||||
|
||||
|
||||
BLocker *gLock = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Main entry point of print_server.
|
||||
*
|
||||
@@ -71,6 +76,7 @@ main()
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for print_server's application class. Retrieves the
|
||||
* name of the default printer from storage, caches the icons for
|
||||
@@ -373,6 +379,7 @@ PrintServerApp::MessageReceived(BMessage* msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// CreatePrinter(const char* printerName, const char* driverName,
|
||||
// const char* connection, const char* transportName,
|
||||
@@ -504,6 +511,7 @@ error:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// SelectPrinter(const char* printerName)
|
||||
//
|
||||
@@ -555,6 +563,7 @@ PrintServerApp::SelectPrinter(const char* printerName)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// HandleSpooledJobs()
|
||||
//
|
||||
@@ -571,6 +580,7 @@ PrintServerApp::HandleSpooledJobs()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// RetrieveDefaultPrinter()
|
||||
//
|
||||
@@ -590,6 +600,7 @@ PrintServerApp::RetrieveDefaultPrinter()
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// StoreDefaultPrinter()
|
||||
//
|
||||
@@ -612,6 +623,7 @@ PrintServerApp::StoreDefaultPrinter()
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// FindPrinterNode(const char* name, BNode& node)
|
||||
//
|
||||
@@ -638,6 +650,7 @@ PrintServerApp::FindPrinterNode(const char* name, BNode& node)
|
||||
return node.SetTo(path.Path());
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// FindPrinterDriver(const char* name, BPath& outPath)
|
||||
//
|
||||
@@ -667,7 +680,8 @@ PrintServerApp::FindPrinterDriver(const char* name, BPath& outPath)
|
||||
}
|
||||
|
||||
|
||||
bool PrintServerApp::OpenSettings(BFile& file, const char* name,
|
||||
bool
|
||||
PrintServerApp::OpenSettings(BFile& file, const char* name,
|
||||
bool forReading)
|
||||
{
|
||||
BPath path;
|
||||
@@ -678,9 +692,9 @@ bool PrintServerApp::OpenSettings(BFile& file, const char* name,
|
||||
&& file.SetTo(path.Path(), openMode) == B_OK;
|
||||
}
|
||||
|
||||
static const char* kSettingsName = "print_server_settings";
|
||||
|
||||
void PrintServerApp::LoadSettings() {
|
||||
void
|
||||
PrintServerApp::LoadSettings() {
|
||||
BFile file;
|
||||
if (OpenSettings(file, kSettingsName, true)) {
|
||||
fSettings->Load(&file);
|
||||
@@ -688,7 +702,9 @@ void PrintServerApp::LoadSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
void PrintServerApp::SaveSettings() {
|
||||
|
||||
void
|
||||
PrintServerApp::SaveSettings() {
|
||||
BFile file;
|
||||
if (OpenSettings(file, kSettingsName, false)) {
|
||||
fSettings->SetUseConfigWindow(fUseConfigWindow);
|
||||
|
||||
@@ -37,7 +37,8 @@ static property_info prop_list[] = {
|
||||
};
|
||||
|
||||
|
||||
void Printer::HandleScriptingCommand(BMessage* msg)
|
||||
void
|
||||
Printer::HandleScriptingCommand(BMessage* msg)
|
||||
{
|
||||
status_t rc = B_ERROR;
|
||||
BString propName;
|
||||
@@ -82,7 +83,8 @@ void Printer::HandleScriptingCommand(BMessage* msg)
|
||||
}
|
||||
}
|
||||
|
||||
BHandler* Printer::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
BHandler*
|
||||
Printer::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
int32 form, const char* prop)
|
||||
{
|
||||
BPropertyInfo prop_info(prop_list);
|
||||
@@ -98,7 +100,8 @@ BHandler* Printer::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
return rc;
|
||||
}
|
||||
|
||||
status_t Printer::GetSupportedSuites(BMessage* msg)
|
||||
status_t
|
||||
Printer::GetSupportedSuites(BMessage* msg)
|
||||
{
|
||||
msg->AddString("suites", "application/x-vnd.OpenBeOS-printer");
|
||||
|
||||
|
||||
@@ -226,7 +226,8 @@ status_t Printer::ConfigurePrinter()
|
||||
// Returns:
|
||||
// B_OK if successful or errorcode otherwise.
|
||||
// ---------------------------------------------------------------
|
||||
status_t Printer::ConfigurePage(BMessage& settings)
|
||||
status_t
|
||||
Printer::ConfigurePage(BMessage& settings)
|
||||
{
|
||||
status_t rc;
|
||||
image_id id;
|
||||
@@ -267,7 +268,8 @@ status_t Printer::ConfigurePage(BMessage& settings)
|
||||
// Returns:
|
||||
// B_OK if successful or errorcode otherwise.
|
||||
// ---------------------------------------------------------------
|
||||
status_t Printer::ConfigureJob(BMessage& settings)
|
||||
status_t
|
||||
Printer::ConfigureJob(BMessage& settings)
|
||||
{
|
||||
status_t rc;
|
||||
image_id id;
|
||||
@@ -300,7 +302,8 @@ status_t Printer::ConfigureJob(BMessage& settings)
|
||||
//
|
||||
// Print spooled jobs in a new thread.
|
||||
// ---------------------------------------------------------------
|
||||
void Printer::HandleSpooledJob()
|
||||
void
|
||||
Printer::HandleSpooledJob()
|
||||
{
|
||||
BAutolock lock(gLock);
|
||||
if (lock.IsLocked()
|
||||
@@ -321,7 +324,8 @@ void Printer::HandleSpooledJob()
|
||||
// Returns:
|
||||
// B_OK if successful or errorcode otherwise.
|
||||
// ---------------------------------------------------------------
|
||||
status_t Printer::GetDefaultSettings(BMessage& settings)
|
||||
status_t
|
||||
Printer::GetDefaultSettings(BMessage& settings)
|
||||
{
|
||||
status_t rc;
|
||||
image_id id;
|
||||
@@ -348,7 +352,8 @@ status_t Printer::GetDefaultSettings(BMessage& settings)
|
||||
}
|
||||
|
||||
|
||||
void Printer::AbortPrintThread()
|
||||
void
|
||||
Printer::AbortPrintThread()
|
||||
{
|
||||
fAbort = true;
|
||||
}
|
||||
@@ -365,7 +370,8 @@ void Printer::AbortPrintThread()
|
||||
// Returns:
|
||||
// B_OK if successful or errorcode otherwise.
|
||||
// ---------------------------------------------------------------
|
||||
status_t Printer::LoadPrinterAddon(image_id& id)
|
||||
status_t
|
||||
Printer::LoadPrinterAddon(image_id& id)
|
||||
{
|
||||
status_t rc;
|
||||
BString drName;
|
||||
@@ -400,7 +406,8 @@ status_t Printer::LoadPrinterAddon(image_id& id)
|
||||
// Parameters:
|
||||
// msg - message.
|
||||
// ---------------------------------------------------------------
|
||||
void Printer::AddCurrentPrinter(BMessage& message)
|
||||
void
|
||||
Printer::AddCurrentPrinter(BMessage& message)
|
||||
{
|
||||
BString name;
|
||||
GetName(name);
|
||||
@@ -418,7 +425,8 @@ void Printer::AddCurrentPrinter(BMessage& message)
|
||||
// Parameters:
|
||||
// name - the name of the printer.
|
||||
// ---------------------------------------------------------------
|
||||
void Printer::GetName(BString& name)
|
||||
void
|
||||
Printer::GetName(BString& name)
|
||||
{
|
||||
if (SpoolDir()->ReadAttrString(PSRV_PRINTER_ATTR_PRT_NAME, &name) != B_OK)
|
||||
name = "Unknown Printer";
|
||||
@@ -430,7 +438,8 @@ void Printer::GetName(BString& name)
|
||||
//
|
||||
// Reset status of "processing" jobs to "waiting" at print_server start.
|
||||
// ---------------------------------------------------------------
|
||||
void Printer::ResetJobStatus()
|
||||
void
|
||||
Printer::ResetJobStatus()
|
||||
{
|
||||
if (fPrinter.Lock()) {
|
||||
const int32 n = fPrinter.CountJobs();
|
||||
@@ -455,7 +464,8 @@ void Printer::ResetJobStatus()
|
||||
// Returns:
|
||||
// true if successful.
|
||||
// ---------------------------------------------------------------
|
||||
bool Printer::HasCurrentPrinter(BString& name)
|
||||
bool
|
||||
Printer::HasCurrentPrinter(BString& name)
|
||||
{
|
||||
BMessage settings;
|
||||
// read settings from spool file and get printer name
|
||||
@@ -478,7 +488,8 @@ bool Printer::HasCurrentPrinter(BString& name)
|
||||
// Returns:
|
||||
// true if successful.
|
||||
// ---------------------------------------------------------------
|
||||
bool Printer::MoveJob(const BString& name)
|
||||
bool
|
||||
Printer::MoveJob(const BString& name)
|
||||
{
|
||||
BPath file(&fJob->EntryRef());
|
||||
BPath path;
|
||||
@@ -506,7 +517,8 @@ bool Printer::MoveJob(const BString& name)
|
||||
// Returns:
|
||||
// true if there is a job present in fJob.
|
||||
// ---------------------------------------------------------------
|
||||
bool Printer::FindSpooledJob()
|
||||
bool
|
||||
Printer::FindSpooledJob()
|
||||
{
|
||||
BString name2;
|
||||
GetName(name2);
|
||||
@@ -541,7 +553,8 @@ bool Printer::FindSpooledJob()
|
||||
// Returns:
|
||||
// B_OK if successful.
|
||||
// ---------------------------------------------------------------
|
||||
status_t Printer::PrintSpooledJob(BFile* spoolFile)
|
||||
status_t
|
||||
Printer::PrintSpooledJob(BFile* spoolFile)
|
||||
{
|
||||
status_t rc;
|
||||
image_id id;
|
||||
@@ -578,7 +591,8 @@ status_t Printer::PrintSpooledJob(BFile* spoolFile)
|
||||
// Parameters:
|
||||
// job - the spool job.
|
||||
// ---------------------------------------------------------------
|
||||
void Printer::PrintThread(Job* job)
|
||||
void
|
||||
Printer::PrintThread(Job* job)
|
||||
{
|
||||
// Wait until resource is available
|
||||
fResource->Lock();
|
||||
@@ -615,7 +629,8 @@ void Printer::PrintThread(Job* job)
|
||||
// Returns:
|
||||
// 0 always.
|
||||
// ---------------------------------------------------------------
|
||||
status_t Printer::print_thread(void* data)
|
||||
status_t
|
||||
Printer::print_thread(void* data)
|
||||
{
|
||||
Job* job = static_cast<Job*>(data);
|
||||
job->GetPrinter()->PrintThread(job);
|
||||
@@ -629,7 +644,8 @@ status_t Printer::print_thread(void* data)
|
||||
// Sets the status of the current spool job to "processing" and
|
||||
// starts the print_thread.
|
||||
// ---------------------------------------------------------------
|
||||
void Printer::StartPrintThread()
|
||||
void
|
||||
Printer::StartPrintThread()
|
||||
{
|
||||
Acquire();
|
||||
thread_id tid = spawn_thread(print_thread, "print", B_NORMAL_PRIORITY, (void*)fJob);
|
||||
|
||||
@@ -22,11 +22,14 @@ Resource::Resource(const char* transport, const char* address, const char* conne
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Resource::~Resource() {
|
||||
if (fResourceAvailable > 0) delete_sem(fResourceAvailable);
|
||||
}
|
||||
|
||||
bool Resource::NeedsLocking() {
|
||||
|
||||
bool
|
||||
Resource::NeedsLocking() {
|
||||
// TODO R2: Provide API to query that information
|
||||
// ATM: Print jobs are not processed sequentially
|
||||
// if the transport add-on is either "Print To File"
|
||||
@@ -38,30 +41,39 @@ bool Resource::NeedsLocking() {
|
||||
|| fTransport == "");
|
||||
}
|
||||
|
||||
bool Resource::Equals(const char* transport, const char* address, const char* connection) {
|
||||
|
||||
bool
|
||||
Resource::Equals(const char* transport, const char* address, const char* connection) {
|
||||
return fTransport == transport &&
|
||||
fTransportAddress == address &&
|
||||
fConnection == connection;
|
||||
}
|
||||
|
||||
bool Resource::Lock() {
|
||||
|
||||
bool
|
||||
Resource::Lock() {
|
||||
if (fResourceAvailable > 0) {
|
||||
return acquire_sem(fResourceAvailable) == B_NO_ERROR;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Resource::Unlock() {
|
||||
|
||||
void
|
||||
Resource::Unlock() {
|
||||
if (fResourceAvailable > 0) {
|
||||
release_sem(fResourceAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ResourceManager::~ResourceManager() {
|
||||
ASSERT(fResources.CountItems() == 0);
|
||||
}
|
||||
|
||||
Resource* ResourceManager::Find(const char* transport, const char* address, const char* connection) {
|
||||
|
||||
Resource*
|
||||
ResourceManager::Find(const char* transport, const char* address, const char* connection) {
|
||||
for (int i = 0; i < fResources.CountItems(); i ++) {
|
||||
Resource* r = fResources.ItemAt(i);
|
||||
if (r->Equals(transport, address, connection)) return r;
|
||||
@@ -69,7 +81,9 @@ Resource* ResourceManager::Find(const char* transport, const char* address, cons
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Resource* ResourceManager::Allocate(const char* transport, const char* address, const char* connection) {
|
||||
|
||||
Resource*
|
||||
ResourceManager::Allocate(const char* transport, const char* address, const char* connection) {
|
||||
Resource* r = Find(transport, address, connection);
|
||||
if (r == NULL) {
|
||||
r = new Resource(transport, address, connection);
|
||||
@@ -81,7 +95,8 @@ Resource* ResourceManager::Allocate(const char* transport, const char* address,
|
||||
}
|
||||
|
||||
|
||||
void ResourceManager::Free(Resource* r) {
|
||||
void
|
||||
ResourceManager::Free(Resource* r) {
|
||||
if (r->Release()) {
|
||||
fResources.RemoveItem(r);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <StorageKit.h>
|
||||
|
||||
|
||||
// Implementation of AppSettings
|
||||
|
||||
AppSettings::AppSettings(const char* mimetype, const char* printer)
|
||||
@@ -42,24 +43,33 @@ Settings::Settings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Settings::~Settings() {
|
||||
fSingleton = NULL;
|
||||
}
|
||||
|
||||
Settings* Settings::GetSettings() {
|
||||
|
||||
Settings*
|
||||
Settings::GetSettings() {
|
||||
if (fSingleton == NULL) fSingleton = new Settings();
|
||||
return fSingleton;
|
||||
}
|
||||
|
||||
void Settings::RemoveAppSettings(int i) {
|
||||
|
||||
void
|
||||
Settings::RemoveAppSettings(int i) {
|
||||
delete fApps.RemoveItemAt(i);
|
||||
}
|
||||
|
||||
void Settings::RemovePrinterSettings(int i) {
|
||||
|
||||
void
|
||||
Settings::RemovePrinterSettings(int i) {
|
||||
delete fPrinters.RemoveItemAt(i);
|
||||
}
|
||||
|
||||
AppSettings* Settings::FindAppSettings(const char* mimeType) {
|
||||
|
||||
AppSettings*
|
||||
Settings::FindAppSettings(const char* mimeType) {
|
||||
for (int i = AppSettingsCount()-1; i >= 0; i --) {
|
||||
if (strcmp(AppSettingsAt(i)->GetMimeType(), mimeType) == 0)
|
||||
return AppSettingsAt(i);
|
||||
@@ -67,7 +77,9 @@ AppSettings* Settings::FindAppSettings(const char* mimeType) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PrinterSettings* Settings::FindPrinterSettings(const char* printer) {
|
||||
|
||||
PrinterSettings*
|
||||
Settings::FindPrinterSettings(const char* printer) {
|
||||
for (int i = PrinterSettingsCount()-1; i >= 0; i --) {
|
||||
if (strcmp(PrinterSettingsAt(i)->GetPrinter(), printer) == 0)
|
||||
return PrinterSettingsAt(i);
|
||||
@@ -75,7 +87,9 @@ PrinterSettings* Settings::FindPrinterSettings(const char* printer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Settings::Save(BFile* file) {
|
||||
|
||||
void
|
||||
Settings::Save(BFile* file) {
|
||||
BMessage m;
|
||||
// store application settings
|
||||
for (int i = 0; i < AppSettingsCount(); i++) {
|
||||
@@ -97,7 +111,9 @@ void Settings::Save(BFile* file) {
|
||||
m.Flatten(file);
|
||||
}
|
||||
|
||||
void Settings::Load(BFile* file) {
|
||||
|
||||
void
|
||||
Settings::Load(BFile* file) {
|
||||
BMessage m;
|
||||
if (m.Unflatten(file) == B_OK) {
|
||||
// restore application settings
|
||||
|
||||
@@ -27,7 +27,9 @@ static property_info prop_list[] = {
|
||||
{ 0 } // terminate list
|
||||
};
|
||||
|
||||
void Transport::HandleScriptingCommand(BMessage* msg)
|
||||
|
||||
void
|
||||
Transport::HandleScriptingCommand(BMessage* msg)
|
||||
{
|
||||
status_t rc = B_ERROR;
|
||||
BString propName;
|
||||
@@ -72,7 +74,9 @@ void Transport::HandleScriptingCommand(BMessage* msg)
|
||||
}
|
||||
}
|
||||
|
||||
BHandler* Transport::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
|
||||
BHandler*
|
||||
Transport::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
||||
int32 form, const char* prop)
|
||||
{
|
||||
BPropertyInfo prop_info(prop_list);
|
||||
@@ -88,7 +92,9 @@ BHandler* Transport::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec
|
||||
return rc;
|
||||
}
|
||||
|
||||
status_t Transport::GetSupportedSuites(BMessage* msg)
|
||||
|
||||
status_t
|
||||
Transport::GetSupportedSuites(BMessage* msg)
|
||||
{
|
||||
msg->AddString("suites", "application/x-vnd.OpenBeOS-transport");
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
#include <image.h>
|
||||
#include <Entry.h>
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
BObjectList<Transport> Transport::sTransports;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Find [static]
|
||||
//
|
||||
@@ -29,7 +30,8 @@ BObjectList<Transport> Transport::sTransports;
|
||||
// Returns:
|
||||
// Pointer to Transport object, or NULL if not found.
|
||||
// ---------------------------------------------------------------
|
||||
Transport* Transport::Find(const BString& name)
|
||||
Transport*
|
||||
Transport::Find(const BString& name)
|
||||
{
|
||||
// Look in list to find printer definition
|
||||
for (int32 idx=0; idx < sTransports.CountItems(); idx++) {
|
||||
@@ -42,26 +44,30 @@ Transport* Transport::Find(const BString& name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
Transport* Transport::At(int32 idx)
|
||||
|
||||
Transport*
|
||||
Transport::At(int32 idx)
|
||||
{
|
||||
return sTransports.ItemAt(idx);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void Transport::Remove(Transport* transport)
|
||||
|
||||
void
|
||||
Transport::Remove(Transport* transport)
|
||||
{
|
||||
sTransports.RemoveItem(transport);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
int32 Transport::CountTransports()
|
||||
|
||||
int32
|
||||
Transport::CountTransports()
|
||||
{
|
||||
return sTransports.CountItems();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
status_t Transport::Scan(directory_which which)
|
||||
|
||||
status_t
|
||||
Transport::Scan(directory_which which)
|
||||
{
|
||||
BDirectory dir;
|
||||
status_t rc;
|
||||
@@ -98,6 +104,7 @@ status_t Transport::Scan(directory_which which)
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Transport [constructor]
|
||||
//
|
||||
@@ -141,14 +148,15 @@ Transport::Transport(const BPath& path)
|
||||
sTransports.AddItem(this);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
Transport::~Transport()
|
||||
{
|
||||
sTransports.RemoveItem(this);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
status_t Transport::ListAvailablePorts(BMessage* msg)
|
||||
|
||||
status_t
|
||||
Transport::ListAvailablePorts(BMessage* msg)
|
||||
{
|
||||
status_t (*list_ports)(BMessage*);
|
||||
image_id id = fImageID;
|
||||
@@ -174,6 +182,7 @@ done:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// MessageReceived
|
||||
//
|
||||
@@ -182,7 +191,8 @@ done:
|
||||
// Parameters:
|
||||
// msg - message.
|
||||
// ---------------------------------------------------------------
|
||||
void Transport::MessageReceived(BMessage* msg)
|
||||
void
|
||||
Transport::MessageReceived(BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case B_GET_PROPERTY:
|
||||
|
||||
Reference in New Issue
Block a user