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