Fixed bug #1232. Report "Add new printer" cancellation correctly.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21184 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2007-05-20 20:31:37 +00:00
parent a637368987
commit f1bbbce435
+31 -20
View File
@@ -393,29 +393,40 @@ PrintServerApp::CreatePrinter(const char* printerName, const char* driverName,
// Notify printer driver that a new printer definition node // Notify printer driver that a new printer definition node
// has been created. // has been created.
// TODO check why we keep the printer definition node image_id id = -1;
// although printer driver cannot be found or loaded
if (FindPrinterDriver(driverName, path) != B_OK)
return B_OK;
image_id id = ::load_add_on(path.Path());
if (id <= 0)
return B_OK;
add_printer_func_t func; add_printer_func_t func;
if (get_image_symbol(id, "add_printer", B_SYMBOL_TYPE_TEXT, (void**)&func) == B_OK) {
// call the function and check its result rc = FindPrinterDriver(driverName, path);
if ((*func)(printerName) == NULL) { if (rc != B_OK)
BEntry entry; goto error;
if (printer.GetEntry(&entry) == B_OK)
entry.Remove(); id = ::load_add_on(path.Path());
if (id <= 0) {
} else rc = B_ERROR;
printer.WriteAttr(PSRV_PRINTER_ATTR_STATE, B_STRING_TYPE, 0, "free", ::strlen("free")+1); goto error;
} }
::unload_add_on(id); rc = get_image_symbol(id, "add_printer", B_SYMBOL_TYPE_TEXT, (void**)&func);
return B_OK; if (rc != B_OK)
goto error;
// call the function and check its result
if ((*func)(printerName) == NULL)
rc = B_ERROR;
else
printer.WriteAttr(PSRV_PRINTER_ATTR_STATE, B_STRING_TYPE, 0, "free", ::strlen("free")+1);
error:
if (rc != B_OK) {
BEntry entry;
if (printer.GetEntry(&entry) == B_OK)
entry.Remove();
}
if (id > 0)
::unload_add_on(id);
return rc;
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------