Fixes compiler warnings and coding style. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37283 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7656ad6be1
commit
cc507fa3f3
|
@ -6,30 +6,28 @@
|
|||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#include "pr_server.h"
|
||||
#include "Printer.h"
|
||||
#include "PrintServerApp.h"
|
||||
#include "ConfigWindow.h"
|
||||
#include "PrintUtils.h"
|
||||
|
||||
// posix
|
||||
#include "ConfigWindow.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// BeOS
|
||||
#include <Application.h>
|
||||
#include <Autolock.h>
|
||||
#include <Debug.h>
|
||||
#include <Window.h>
|
||||
|
||||
// Haiku
|
||||
#include <Catalog.h>
|
||||
#include <Layout.h>
|
||||
#include <Locale.h>
|
||||
#include <Debug.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Layout.h>
|
||||
#include <Locale.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "pr_server.h"
|
||||
#include "Printer.h"
|
||||
#include "PrintServerApp.h"
|
||||
#include "PrintUtils.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
|
@ -102,8 +100,8 @@ 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 ++) {
|
||||
struct PageFormat& pf = pageFormat[i];
|
||||
if (pf.width == w && pf.height == h || pf.width == h
|
||||
&& pf.height == w) {
|
||||
if ((pf.width == w && pf.height == h) || (pf.width == h
|
||||
&& pf.height == w)) {
|
||||
label = be_catalog->GetString(pf.label, B_TRANSLATE_CONTEXT);
|
||||
return;
|
||||
}
|
||||
|
@ -125,16 +123,17 @@ LeftAlign(BView* view)
|
|||
|
||||
ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
||||
BMessage* settings, AutoReply* sender)
|
||||
: BWindow(ConfigWindow::GetWindowFrame(), B_TRANSLATE("Page setup"),
|
||||
:
|
||||
BWindow(ConfigWindow::GetWindowFrame(), B_TRANSLATE("Page setup"),
|
||||
B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
, fKind(kind)
|
||||
, fDefaultPrinter(defaultPrinter)
|
||||
, fSettings(settings)
|
||||
, fSender(sender)
|
||||
, fCurrentPrinter(NULL)
|
||||
, fPageFormatText(NULL)
|
||||
, fJobSetupText(NULL)
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||
fKind(kind),
|
||||
fDefaultPrinter(defaultPrinter),
|
||||
fSettings(settings),
|
||||
fSender(sender),
|
||||
fCurrentPrinter(NULL),
|
||||
fPageFormatText(NULL),
|
||||
fJobSetupText(NULL)
|
||||
{
|
||||
MimeTypeForSender(settings, fSenderMimeType);
|
||||
PrinterForMimeType();
|
||||
|
@ -275,16 +274,16 @@ ConfigWindow::MessageReceived(BMessage* m)
|
|||
case MSG_JOB_SETUP:
|
||||
Setup(kJobSetup);
|
||||
break;
|
||||
case MSG_PRINTER_SELECTED: {
|
||||
BString printer;
|
||||
if (m->FindString("name", &printer) == B_OK) {
|
||||
UpdateAppSettings(fSenderMimeType.String(),
|
||||
printer.String());
|
||||
PrinterForMimeType();
|
||||
UpdateSettings(true);
|
||||
}
|
||||
case MSG_PRINTER_SELECTED:
|
||||
{
|
||||
BString printer;
|
||||
if (m->FindString("name", &printer) == B_OK) {
|
||||
UpdateAppSettings(fSenderMimeType.String(), printer.String());
|
||||
PrinterForMimeType();
|
||||
UpdateSettings(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_OK:
|
||||
UpdateSettings(false);
|
||||
if (fKind == kPageSetup)
|
||||
|
@ -399,11 +398,10 @@ ConfigWindow::PrinterForMimeType()
|
|||
if (lock.IsLocked()) {
|
||||
Settings* s = Settings::GetSettings();
|
||||
AppSettings* app = s->FindAppSettings(fSenderMimeType.String());
|
||||
if (app) {
|
||||
if (app)
|
||||
fPrinterName = app->GetPrinter();
|
||||
} else {
|
||||
else
|
||||
fPrinterName = fDefaultPrinter ? fDefaultPrinter->Name() : "";
|
||||
}
|
||||
fCurrentPrinter = Printer::Find(fPrinterName);
|
||||
if (fCurrentPrinter)
|
||||
fCurrentPrinter->Acquire();
|
||||
|
@ -493,8 +491,8 @@ ConfigWindow::UpdateUI()
|
|||
fJobSetup->SetEnabled(fKind == kJobSetup
|
||||
&& !fPageSettings.IsEmpty());
|
||||
|
||||
fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() ||
|
||||
fKind == kPageSetup && !fPageSettings.IsEmpty());
|
||||
fOk->SetEnabled((fKind == kJobSetup && !fJobSettings.IsEmpty())
|
||||
|| (fKind == kPageSetup && !fPageSettings.IsEmpty()));
|
||||
|
||||
// display information about page format
|
||||
BRect paperRect;
|
||||
|
@ -508,17 +506,18 @@ ConfigWindow::UpdateUI()
|
|||
pageFormat << ", " << B_TRANSLATE("Portrait");
|
||||
else
|
||||
pageFormat << ", " << B_TRANSLATE("Landscape");
|
||||
} else {
|
||||
} else
|
||||
pageFormat << B_TRANSLATE("Undefined");
|
||||
}
|
||||
|
||||
fPageFormatText->SetText(pageFormat.String());
|
||||
|
||||
// display information about job
|
||||
if (fKind == kJobSetup) {
|
||||
BString job;
|
||||
int32 first, last, copies;
|
||||
if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK &&
|
||||
fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) == B_OK) {
|
||||
if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK
|
||||
&& fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) ==
|
||||
B_OK) {
|
||||
|
||||
bool printRange = first >= 1 && first <= last && last != INT_MAX;
|
||||
char number[12];
|
||||
|
@ -544,13 +543,11 @@ ConfigWindow::UpdateUI()
|
|||
job.ReplaceFirst("%1", number);
|
||||
sprintf(number, "%d", (int)last);
|
||||
job.ReplaceFirst("%2", number);
|
||||
} else {
|
||||
} else
|
||||
job = B_TRANSLATE("All pages");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
job << B_TRANSLATE("Undefined");
|
||||
}
|
||||
|
||||
fJobSetupText->SetText(job.String());
|
||||
}
|
||||
|
|
|
@ -5,20 +5,24 @@
|
|||
* Authors:
|
||||
* Michael Pfeiffer
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_WINDOW_H
|
||||
#define _CONFIG_WINDOW_H
|
||||
|
||||
#include "BeUtils.h"
|
||||
#include "ObjectList.h"
|
||||
|
||||
#include <InterfaceKit.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "BeUtils.h"
|
||||
#include "ObjectList.h"
|
||||
#include "Printer.h"
|
||||
|
||||
|
||||
enum config_setup_kind {
|
||||
kPageSetup,
|
||||
kJobSetup,
|
||||
};
|
||||
|
||||
|
||||
class ConfigWindow : public BWindow {
|
||||
enum {
|
||||
MSG_PAGE_SETUP = 'cwps',
|
||||
|
@ -29,47 +33,50 @@ class ConfigWindow : public BWindow {
|
|||
};
|
||||
|
||||
public:
|
||||
ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
||||
BMessage* settings, AutoReply* sender);
|
||||
~ConfigWindow();
|
||||
void Go();
|
||||
ConfigWindow(config_setup_kind kind,
|
||||
Printer* defaultPrinter, BMessage* settings,
|
||||
AutoReply* sender);
|
||||
~ConfigWindow();
|
||||
void Go();
|
||||
|
||||
void MessageReceived(BMessage* m);
|
||||
void AboutRequested();
|
||||
void FrameMoved(BPoint p);
|
||||
void MessageReceived(BMessage* m);
|
||||
void AboutRequested();
|
||||
void FrameMoved(BPoint p);
|
||||
|
||||
static BRect GetWindowFrame();
|
||||
static void SetWindowFrame(BRect frame);
|
||||
static BRect GetWindowFrame();
|
||||
static void SetWindowFrame(BRect frame);
|
||||
|
||||
private:
|
||||
BPictureButton* AddPictureButton(BView* panel, BRect frame, const char* name,
|
||||
const char* on, const char* off, uint32 what);
|
||||
void PrinterForMimeType();
|
||||
void SetupPrintersMenu(BMenu* menu);
|
||||
void UpdateAppSettings(const char* mime, const char* printer);
|
||||
void UpdateSettings(bool read);
|
||||
void UpdateUI();
|
||||
void Setup(config_setup_kind);
|
||||
BPictureButton* AddPictureButton(BView* panel, BRect frame,
|
||||
const char* name, const char* on,
|
||||
const char* off, uint32 what);
|
||||
void PrinterForMimeType();
|
||||
void SetupPrintersMenu(BMenu* menu);
|
||||
void UpdateAppSettings(const char* mime, const char* printer);
|
||||
void UpdateSettings(bool read);
|
||||
void UpdateUI();
|
||||
void Setup(config_setup_kind);
|
||||
|
||||
config_setup_kind fKind;
|
||||
Printer* fDefaultPrinter;
|
||||
BMessage* fSettings;
|
||||
AutoReply* fSender;
|
||||
BString fSenderMimeType;
|
||||
config_setup_kind fKind;
|
||||
Printer* fDefaultPrinter;
|
||||
BMessage* fSettings;
|
||||
AutoReply* fSender;
|
||||
BString fSenderMimeType;
|
||||
|
||||
BString fPrinterName;
|
||||
Printer* fCurrentPrinter;
|
||||
BMessage fPageSettings;
|
||||
BMessage fJobSettings;
|
||||
BString fPrinterName;
|
||||
Printer* fCurrentPrinter;
|
||||
BMessage fPageSettings;
|
||||
BMessage fJobSettings;
|
||||
|
||||
sem_id fFinished;
|
||||
sem_id fFinished;
|
||||
|
||||
BMenuField* fPrinters;
|
||||
BPictureButton* fPageSetup;
|
||||
BPictureButton* fJobSetup;
|
||||
BButton* fOk;
|
||||
BStringView* fPageFormatText;
|
||||
BStringView* fJobSetupText;
|
||||
BMenuField* fPrinters;
|
||||
BPictureButton* fPageSetup;
|
||||
BPictureButton* fJobSetup;
|
||||
BButton* fOk;
|
||||
BStringView* fPageFormatText;
|
||||
BStringView* fJobSetupText;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,38 +5,45 @@
|
|||
* Authors:
|
||||
* Ithamar R. Adema
|
||||
*/
|
||||
|
||||
|
||||
#include "PrintServerApp.h"
|
||||
|
||||
#include "Transport.h"
|
||||
#include "Printer.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// BeOS API
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <PropertyInfo.h>
|
||||
|
||||
// ANSI C
|
||||
#include <stdio.h>
|
||||
#include "Transport.h"
|
||||
#include "Printer.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "PrintServerApp Scripting"
|
||||
|
||||
|
||||
static property_info prop_list[] = {
|
||||
{ "ActivePrinter", { B_GET_PROPERTY, B_SET_PROPERTY }, { B_DIRECT_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Retrieve or select the active printer") },
|
||||
{ "Printer", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER },
|
||||
{ "ActivePrinter", { B_GET_PROPERTY, B_SET_PROPERTY },
|
||||
{ B_DIRECT_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Retrieve or select the active printer") },
|
||||
{ "Printer", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER,
|
||||
B_REVERSE_INDEX_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Retrieve a specific printer") },
|
||||
{ "Printer", { B_CREATE_PROPERTY }, { B_DIRECT_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Create a new printer") },
|
||||
{ "Printer", { B_DELETE_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER },
|
||||
{ "Printer", { B_DELETE_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER,
|
||||
B_REVERSE_INDEX_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Delete a specific printer") },
|
||||
{ "Printers", { B_COUNT_PROPERTIES }, { B_DIRECT_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Return the number of available printers") },
|
||||
{ "Transport", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER },
|
||||
{ "Transport", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER,
|
||||
B_REVERSE_INDEX_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Retrieve a specific transport") },
|
||||
{ "Transports", { B_COUNT_PROPERTIES }, { B_DIRECT_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Return the number of available transports") },
|
||||
{ "UseConfigWindow", { B_GET_PROPERTY, B_SET_PROPERTY }, { B_DIRECT_SPECIFIER },
|
||||
{ "UseConfigWindow", { B_GET_PROPERTY, B_SET_PROPERTY },
|
||||
{ B_DIRECT_SPECIFIER },
|
||||
B_TRANSLATE_MARK("Show configuration window") },
|
||||
{ 0 } // terminate list
|
||||
};
|
||||
|
@ -55,12 +62,14 @@ PrintServerApp::HandleScriptingCommand(BMessage* msg)
|
|||
case B_GET_PROPERTY:
|
||||
if (propName == "ActivePrinter") {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddString("result", fDefaultPrinter ? fDefaultPrinter->Name() : "");
|
||||
reply.AddString("result", fDefaultPrinter
|
||||
? fDefaultPrinter->Name() : "");
|
||||
reply.AddInt32("error", B_OK);
|
||||
msg->SendReply(&reply);
|
||||
} else if (propName == "UseConfigWindow") {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddString("result", fUseConfigWindow ? "true" : "false");
|
||||
reply.AddString("result", fUseConfigWindow
|
||||
? "true" : "false");
|
||||
reply.AddInt32("error", B_OK);
|
||||
msg->SendReply(&reply);
|
||||
}
|
||||
|
@ -71,7 +80,8 @@ PrintServerApp::HandleScriptingCommand(BMessage* msg)
|
|||
BString newActivePrinter;
|
||||
if (msg->FindString("data", &newActivePrinter) == B_OK) {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddInt32("error", SelectPrinter(newActivePrinter.String()));
|
||||
reply.AddInt32("error",
|
||||
SelectPrinter(newActivePrinter.String()));
|
||||
msg->SendReply(&reply);
|
||||
}
|
||||
} else if (propName == "UseConfigWindow") {
|
||||
|
@ -89,13 +99,14 @@ PrintServerApp::HandleScriptingCommand(BMessage* msg)
|
|||
if (propName == "Printer") {
|
||||
BString name, driver, transport, config;
|
||||
|
||||
if (msg->FindString("name", &name) == B_OK &&
|
||||
msg->FindString("driver", &driver) == B_OK &&
|
||||
msg->FindString("transport", &transport) == B_OK &&
|
||||
msg->FindString("config", &config) == B_OK) {
|
||||
if (msg->FindString("name", &name) == B_OK
|
||||
&& msg->FindString("driver", &driver) == B_OK
|
||||
&& msg->FindString("transport", &transport) == B_OK
|
||||
&& msg->FindString("config", &config) == B_OK) {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddInt32("error", CreatePrinter(name.String(), driver.String(),
|
||||
"Local", transport.String(), config.String()));
|
||||
reply.AddInt32("error", CreatePrinter(name.String(),
|
||||
driver.String(), "Local", transport.String(),
|
||||
config.String()));
|
||||
msg->SendReply(&reply);
|
||||
}
|
||||
}
|
||||
|
@ -105,9 +116,8 @@ PrintServerApp::HandleScriptingCommand(BMessage* msg)
|
|||
Printer* printer = GetPrinterFromSpecifier(&spec);
|
||||
status_t rc = B_BAD_VALUE;
|
||||
|
||||
if (printer != NULL) {
|
||||
if (printer != NULL)
|
||||
rc=printer->Remove();
|
||||
}
|
||||
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddInt32("error", rc);
|
||||
|
@ -137,27 +147,27 @@ Printer*
|
|||
PrintServerApp::GetPrinterFromSpecifier(BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case B_NAME_SPECIFIER: {
|
||||
case B_NAME_SPECIFIER:
|
||||
{
|
||||
BString name;
|
||||
if (msg->FindString("name", &name) == B_OK) {
|
||||
if (msg->FindString("name", &name) == B_OK)
|
||||
return Printer::Find(name.String());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_INDEX_SPECIFIER: {
|
||||
case B_INDEX_SPECIFIER:
|
||||
{
|
||||
int32 idx;
|
||||
if (msg->FindInt32("index", &idx) == B_OK) {
|
||||
if (msg->FindInt32("index", &idx) == B_OK)
|
||||
return Printer::At(idx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_REVERSE_INDEX_SPECIFIER: {
|
||||
case B_REVERSE_INDEX_SPECIFIER:
|
||||
{
|
||||
int32 idx;
|
||||
if (msg->FindInt32("index", &idx) == B_OK) {
|
||||
if (msg->FindInt32("index", &idx) == B_OK)
|
||||
return Printer::At(Printer::CountPrinters() - idx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -170,27 +180,27 @@ Transport*
|
|||
PrintServerApp::GetTransportFromSpecifier(BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case B_NAME_SPECIFIER: {
|
||||
case B_NAME_SPECIFIER:
|
||||
{
|
||||
BString name;
|
||||
if (msg->FindString("name", &name) == B_OK) {
|
||||
if (msg->FindString("name", &name) == B_OK)
|
||||
return Transport::Find(name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_INDEX_SPECIFIER: {
|
||||
case B_INDEX_SPECIFIER:
|
||||
{
|
||||
int32 idx;
|
||||
if (msg->FindInt32("index", &idx) == B_OK) {
|
||||
if (msg->FindInt32("index", &idx) == B_OK)
|
||||
return Transport::At(idx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_REVERSE_INDEX_SPECIFIER: {
|
||||
case B_REVERSE_INDEX_SPECIFIER:
|
||||
{
|
||||
int32 idx;
|
||||
if (msg->FindInt32("index", &idx) == B_OK) {
|
||||
if (msg->FindInt32("index", &idx) == B_OK)
|
||||
return Transport::At(Transport::CountTransports() - idx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -211,8 +221,8 @@ PrintServerApp::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
|||
case B_ERROR:
|
||||
rc = Inherited::ResolveSpecifier(msg,index,spec,form,prop);
|
||||
|
||||
// GET Printer [arg]
|
||||
case 1:
|
||||
// GET Printer [arg]
|
||||
if ((rc=GetPrinterFromSpecifier(spec)) == NULL) {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddInt32("error", B_BAD_INDEX);
|
||||
|
@ -222,8 +232,8 @@ PrintServerApp::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
|||
msg->PopSpecifier();
|
||||
break;
|
||||
|
||||
// GET Transport [arg]
|
||||
case 5:
|
||||
// GET Transport [arg]
|
||||
if ((rc=GetTransportFromSpecifier(spec)) == NULL) {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddInt32("error", B_BAD_INDEX);
|
||||
|
@ -250,7 +260,7 @@ PrintServerApp::GetSupportedSuites(BMessage* msg)
|
|||
if (!localized) {
|
||||
localized = true;
|
||||
for (int i = 0; prop_list[i].name != NULL; i ++)
|
||||
prop_list[i].usage = be_catalog->GetString(prop_list[i].usage,
|
||||
prop_list[i].usage = be_catalog->GetString(prop_list[i].usage,
|
||||
B_TRANSLATE_CONTEXT);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <PropertyInfo.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "Printer Scripting"
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* Ithamar R. Adema
|
||||
*/
|
||||
|
||||
|
||||
#include "Transport.h"
|
||||
|
||||
#include <AppDefs.h>
|
||||
|
@ -16,6 +17,7 @@
|
|||
#include <PropertyInfo.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "Transport Scripting"
|
||||
|
||||
|
||||
|
@ -37,21 +39,22 @@ Transport::HandleScriptingCommand(BMessage* msg)
|
|||
BMessage spec;
|
||||
int32 idx;
|
||||
|
||||
if ((rc=msg->GetCurrentSpecifier(&idx,&spec)) == B_OK &&
|
||||
(rc=spec.FindString("property",&propName)) == B_OK) {
|
||||
if ((rc=msg->GetCurrentSpecifier(&idx,&spec)) == B_OK
|
||||
&& (rc=spec.FindString("property",&propName)) == B_OK) {
|
||||
switch(msg->what) {
|
||||
case B_GET_PROPERTY:
|
||||
if (propName == "Name")
|
||||
result = Name();
|
||||
else if (propName == "Ports") {
|
||||
// Need to duplicate messaging code, as our result is a complex
|
||||
// bmessage, not a string :(
|
||||
// Need to duplicate messaging code, as our result is a
|
||||
// complex bmessage, not a string :(
|
||||
BMessage reply(B_REPLY);
|
||||
rc = ListAvailablePorts(&reply);
|
||||
reply.AddInt32("error", rc);
|
||||
msg->SendReply(&reply);
|
||||
break;
|
||||
} else { // If unknown scripting request, let superclas handle it
|
||||
} else {
|
||||
// If unknown scripting request, let superclas handle it
|
||||
Inherited::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
|
@ -62,9 +65,8 @@ Transport::HandleScriptingCommand(BMessage* msg)
|
|||
msg->SendReply(&reply);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If GetSpecifier failed
|
||||
} else {
|
||||
// If GetSpecifier failed
|
||||
if (idx == -1) {
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddMessenger("result", BMessenger(this));
|
||||
|
@ -83,7 +85,7 @@ Transport::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec,
|
|||
BHandler* rc = this;
|
||||
|
||||
int32 idx;
|
||||
switch( idx=prop_info.FindMatch(msg,0,spec,form,prop) ) {
|
||||
switch (idx=prop_info.FindMatch(msg,0,spec,form,prop)) {
|
||||
case B_ERROR:
|
||||
rc = Inherited::ResolveSpecifier(msg,index,spec,form,prop);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue