/* * StoreDriverNames - queries the attribute store for the ddx-identifier. * if the ddx-identifier is not in the attribute database, then a default * ddx-identifier is store in both the attribute store for the printer, * and in the printerDb. * The ddx-identifier is stored in the printerDb for use in initializing * the screens. */ static void StoreDriverNames(void) { PrinterDbPtr pEntry; for(pEntry = printerDb; pEntry != (PrinterDbPtr)NULL; pEntry = pEntry->next) { pEntry->driverName = (char*)XpGetPrinterAttribute(pEntry->name, "xp-ddx-identifier"); if(pEntry->driverName == (char *)NULL || strlen(pEntry->driverName) == 0 || GetInitFunc(pEntry->driverName) == 0) { if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) { ErrorF("Xp Extension: Can't load driver %s\n", pEntry->driverName); ErrorF(" init function missing\n"); } pEntry->driverName = defaultDriver; XpAddPrinterAttribute(pEntry->name, (pEntry->qualifier != (char *)NULL)? pEntry->qualifier : pEntry->name, "*xp-ddx-identifier", pEntry->driverName); } } }
/* * FillPrinterListEntry fills in a single XpDiListEntry element with data * derived from the supplied PrinterDbPtr element. * * XXX A smarter (i.e. future) version of this routine might inspect the * XXX "locale" parameter and attempt to match the "description" and * XXX "localeName" elements of the XpDiListEntry to the specified locale. */ static void FillPrinterListEntry( XpDiListEntry *pEntry, PrinterDbPtr pDb, int localeLen, char *locale) { static char *localeStr = (char *)NULL; if(localeStr == (char *)NULL) localeStr = strdup(setlocale(LC_ALL, (const char *)NULL)); pEntry->name = pDb->name; pEntry->description = (char*)XpGetPrinterAttribute(pDb->name, "descriptor"); pEntry->localeName = localeStr; pEntry->rootWinId = WindowTable[pDb->screenNum]->drawable.id; }
/* * AugmentFontPath adds printer-model-specific font path elements to * the front of the font path global variable "defaultFontPath" (dix/globals.c). * We can't call SetFontPath() because the font code has not yet been * initialized when InitOutput is called (from whence this routine is called). * * This utilizes the static variables origFontPath and * freeDefaultFontPath to track the original contents of defaultFontPath, * and to properly free the modified version upon server recycle. */ static void AugmentFontPath(void) { char *modelID, **allIDs = (char **)NULL; PrinterDbPtr pDbEntry; int numModels, i; if(!origFontPath) origFontPath = defaultFontPath; if(freeDefaultFontPath) { xfree(defaultFontPath); defaultFontPath = origFontPath; freeDefaultFontPath = FALSE; } /* * Build a list of printer models to check for internal fonts. */ for(pDbEntry = printerDb, numModels = 0; pDbEntry != (PrinterDbPtr)NULL; pDbEntry = pDbEntry->next) { modelID = (char*)XpGetPrinterAttribute(pDbEntry->name, "xp-model-identifier"); if(modelID && strlen(modelID) != 0) { /* look for current model in the list of allIDs */ for(i = 0; i < numModels; i++) { if(!strcmp(modelID, allIDs[i])) { modelID = (char *)NULL; break; } } } /* * If this printer's model-identifier isn't in the allIDs list, * then add it to allIDs. */ if(modelID && strlen(modelID) != 0) { allIDs = (char **)xrealloc(allIDs, (numModels+2) * sizeof(char *)); if(allIDs == (char **)NULL) return; allIDs[numModels] = modelID; allIDs[numModels + 1] = (char *)NULL; numModels++; } } /* for each model, check for a valid font directory, and add it to * the front of defaultFontPath. */ for(i = 0; allIDs != (char **)NULL && allIDs[i] != (char *)NULL; i ++) { char *fontDir; if ((fontDir = FindFontDir(allIDs[i])) != 0) { AddToFontPath(fontDir); xfree(fontDir); freeDefaultFontPath = TRUE; } } if(allIDs) xfree(allIDs); return; }
/* * XpGetMaxWidthHeightRes returns into the supplied width and height * unsigned short pointers the dimensions in millimeters of the largest * supported media for a specific printer. It looks at the * medium-source-sizes-supported attribute (if it exists) to determine * the list of possible media, and calls XpGetMediumMillimeters to get the * dimensions for each medium. If the m-s-s-s attribute is not defined, * then the dimensions for the na-letter medium is returned. * * This function also returns the largest resolution in DPI defined in * printer-resolutions-supported. If printer-resolutions-supported is not * specified, the default is obtained from the passed XpValidatePoolsRec. * * The passed XpValidatePoolsRec is also used to determine valid values * when parsing attribute values. */ void XpGetMaxWidthHeightRes( const char *printer_name, const XpValidatePoolsRec* vpr, float *width, float *height, int* resolution) { const char* value; const char* attr_str; XpOidMediumSS* pool_msss; const XpOidMediumSS* msss; int i_mss, i_ds; XpOidMediumDiscreteSizeList* ds_list; float w, h; XpOidCardList* pool_resolutions_supported; const XpOidCardList* resolutions_supported; int i; int res; /* * get the max medium width and height */ attr_str = XpOidString(xpoid_att_medium_source_sizes_supported); value = XpGetPrinterAttribute(printer_name, attr_str); pool_msss = XpOidMediumSSNew(value, vpr->valid_input_trays, vpr->valid_medium_sizes); if(0 == XpOidMediumSSCount(pool_msss)) msss = XpGetDefaultMediumSS(); else msss = pool_msss; *width = *height = 0; for(i_mss = 0; i_mss < XpOidMediumSSCount(msss); i_mss++) { if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag && xpoid_none != (msss->mss)[i_mss].input_tray) { ds_list = (msss->mss)[i_mss].ms.discrete; for(i_ds = 0; i_ds < ds_list->count; i_ds++) { if(xpoid_none != (ds_list->list)[i_ds].page_size) { XpGetMediumMillimeters((ds_list->list)[i_ds].page_size, &w, &h); if(w > *width) *width = w; if(h > *height) *height = h; } } } } XpOidMediumSSDelete(pool_msss); /* * get the maximum resolution */ attr_str = XpOidString(xpoid_att_printer_resolutions_supported); value = XpGetPrinterAttribute(printer_name, attr_str); pool_resolutions_supported = XpOidCardListNew(value, vpr->valid_printer_resolutions_supported); if(0 == XpOidCardListCount(pool_resolutions_supported)) resolutions_supported = vpr->default_printer_resolutions_supported; else resolutions_supported = pool_resolutions_supported; *resolution = 0; for(i = 0; i < XpOidCardListCount(resolutions_supported); i++) { res = XpOidCardListGetCard(resolutions_supported, i); if(res > *resolution) *resolution = res; } XpOidCardListDelete(pool_resolutions_supported); }