Added GetDefaultSettings().

Fixed return correct error code in ConfigurePage().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1530 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer 2002-10-15 15:57:45 +00:00
parent a744b32df3
commit f2ee553c1b
2 changed files with 43 additions and 0 deletions

View File

@ -59,6 +59,7 @@
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);
typedef BMessage* (*default_settings_t)(BNode*);
// ---------------------------------------------------------------
BObjectList<Printer> Printer::sPrinters;
@ -227,6 +228,9 @@ status_t Printer::ConfigurePage(BMessage& settings)
BMessage* new_settings = (*func)(SpoolDir(), &settings);
if (new_settings != NULL && new_settings->what != 'baad')
settings = *new_settings;
else
rc = B_ERROR;
delete new_settings;
}
::unload_add_on(id);
@ -286,6 +290,44 @@ void Printer::HandleSpooledJob() {
}
}
// ---------------------------------------------------------------
// GetDefaultSettings
//
// Retrieve the default configuration message from printer add-on
//
// Parameters:
// settings, output paramter.
//
// Returns:
// B_OK if successful or errorcode otherwise.
// ---------------------------------------------------------------
status_t Printer::GetDefaultSettings(BMessage& settings) {
image_id id;
status_t rc;
if ((rc=LoadPrinterAddon(id)) == B_OK) {
// Addon was loaded, so try and get the default_settings symbol
default_settings_t func;
if ((rc=get_image_symbol(id, "default_settings", B_SYMBOL_TYPE_TEXT, (void**)&func)) == B_OK) {
// call the function and check its result
BMessage* new_settings = (*func)(SpoolDir());
if (new_settings) {
settings = *new_settings;
} else {
rc = B_ERROR;
}
delete new_settings;
}
::unload_add_on(id);
}
return rc;
}
void Printer::AbortPrintThread() {
fAbort = true;
}

View File

@ -80,6 +80,7 @@ public:
status_t ConfigurePrinter();
status_t ConfigureJob(BMessage& ioSettings);
status_t ConfigurePage(BMessage& ioSettings);
status_t GetDefaultSettings(BMessage& configuration);
// Try to start processing of next spooled job
void HandleSpooledJob();