// --------------------------------------------------------------- // 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) { status_t rc; image_id id; 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; settings.what = 'okok'; AddCurrentPrinter(settings); } else { rc = B_ERROR; } delete new_settings; } ::unload_add_on(id); } return rc; }
// --------------------------------------------------------------- // ConfigureJob // // Handles calling the printer addon's config_job function. // // Parameters: // settings - Job settings to display. The contents of this // message will be replaced with the new settings // if the function returns success. // // Returns: // B_OK if successful or errorcode otherwise. // --------------------------------------------------------------- status_t Printer::ConfigureJob(BMessage& settings) { status_t rc; image_id id; if ((rc = LoadPrinterAddon(id)) == B_OK) { // Addon was loaded, so try and get the config_job symbol config_func_t func; if ((rc = get_image_symbol(id, "config_job", B_SYMBOL_TYPE_TEXT, (void**)&func)) == B_OK) { // call the function and check its result BMessage* new_settings = (*func)(SpoolDir(), &settings); if ((new_settings != NULL) && (new_settings->what != 'baad')) { settings = *new_settings; settings.what = 'okok'; AddCurrentPrinter(settings); } else { rc = B_ERROR; } delete new_settings; } ::unload_add_on(id); } return rc; }
// --------------------------------------------------------------- // 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) { BString driver; status_t result = GetDriverName(&driver); if (result != B_OK) return result; PrintAddOnServer addOn(driver.String()); result = addOn.DefaultSettings(SpoolDir(), &settings); if (result == B_OK) AddCurrentPrinter(settings); return result; }
// --------------------------------------------------------------- // ConfigurePage // // Handles calling the printer addon's config_page function. // // Parameters: // settings - Page settings to display. The contents of this // message will be replaced with the new settings // if the function returns success. // // Returns: // B_OK if successful or errorcode otherwise. // --------------------------------------------------------------- status_t Printer::ConfigurePage(BMessage& settings) { BString driver; status_t result = GetDriverName(&driver); if (result != B_OK) return result; PrintAddOnServer addOn(driver.String()); result = addOn.ConfigPage(SpoolDir(), &settings); if (result == B_OK) { AddCurrentPrinter(settings); } return result; }