nsAString* os2PrintQ::PrinterTitle() { if (mPrinterTitle.IsEmpty()) { nsAutoCString cName(mpPQI3->pszComment); if (cName.IsEmpty()) cName.Assign(mpPQI3->pszName); cName.ReplaceChar('\r', ' '); cName.StripChars("\n"); if (cName.Length() > 64) cName.Truncate(64); nsAutoChar16Buffer uName; int32_t uNameLength = 123; MultiByteToWideChar(0, cName.get(), cName.Length(), uName, uNameLength); mPrinterTitle.Assign(nsDependentString(uName.Elements())); // store printer description in prefs for the print dialog nsresult rv; nsCOMPtr<nsIPrefBranch> pPrefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { char desc[DRIV_DEVICENAME_SIZE + DRIV_NAME_SIZE + 8]; char pref[128]; sprintf(desc, "%s (%s)", DriverData()->szDeviceName, mDriverName); sprintf(pref, "print.printer_%s.printer_description", cName.get()); pPrefs->SetCharPref(pref, desc); } } return &mPrinterTitle; }
status_t device_node::Rescan() { status_t status = InitDriver(); if (status < B_OK) return status; MethodDeleter<device_node, bool> uninit(this, &device_node::UninitDriver); if (DriverModule()->rescan_child_devices != NULL) { status = DriverModule()->rescan_child_devices(DriverData()); if (status != B_OK) return status; } NodeList::Iterator iterator = fChildren.GetIterator(); while (iterator.HasNext()) { device_node* child = iterator.Next(); status = child->Rescan(); if (status != B_OK) return status; } return B_OK; }
void device_node::Dump(int32 level) { put_level(level); kprintf("(%" B_PRId32 ") @%p \"%s\" (ref %" B_PRId32 ", init %" B_PRId32 ", module %p, data %p)\n", level, this, ModuleName(), fRefCount, fInitialized, DriverModule(), DriverData()); AttributeList::Iterator attribute = Attributes().GetIterator(); while (attribute.HasNext()) { dump_attribute(attribute.Next(), level); } DeviceList::Iterator deviceIterator = fDevices.GetIterator(); while (deviceIterator.HasNext()) { Device* device = deviceIterator.Next(); put_level(level); kprintf("device: %s, %p\n", device->ModuleName(), device->Data()); } NodeList::ConstIterator iterator = Children().GetIterator(); while (iterator.HasNext()) { iterator.Next()->Dump(level + 1); } }
HDC os2PrintQ::OpenHDC() { DEVOPENSTRUC dop; memset(&dop, 0, sizeof(dop)); dop.pszDriverName = (char*)mDriverName; dop.pdriv = DriverData(); return DevOpenDC(0, OD_INFO, "*", 9, (PDEVOPENDATA)&dop, 0); }
/*! Registers this node, and all of its children that have to be registered. Also initializes the driver and keeps it that way on return in case it returns successfully. */ status_t device_node::Register(device_node* parent) { // make it public if (parent != NULL) parent->AddChild(this); else sRootNode = this; status_t status = InitDriver(); if (status != B_OK) return status; if ((fFlags & B_KEEP_DRIVER_LOADED) != 0) { // We keep this driver loaded by having it always initialized InitDriver(); } fFlags |= NODE_FLAG_REGISTER_INITIALIZED; // We don't uninitialize the driver - this is done by the caller // in order to save reinitializing during driver loading. uint32 registeredFixedCount; status = _RegisterFixed(registeredFixedCount); if (status != B_OK) { UninitUnusedDriver(); return status; } // Register the children the driver wants if (DriverModule()->register_child_devices != NULL) { status = DriverModule()->register_child_devices(DriverData()); if (status != B_OK) { UninitUnusedDriver(); return status; } if (!fChildren.IsEmpty()) { fRegistered = true; return B_OK; } } if (registeredFixedCount > 0) { // Nodes with fixed children cannot have any dynamic children, so bail // out here fRegistered = true; return B_OK; } // Register all possible child device nodes status = _RegisterDynamic(); if (status == B_OK) fRegistered = true; else UninitUnusedDriver(); return status; }