Example #1
0
File: Init.c Project: aosm/X11
/*
 * XpClientIsBitmapClient is called by the font code to find out if
 * a particular client should be granted access to bitmap fonts.
 * This function works by
 * calling XpContextOfClient (in Xserver/Xext/xprint.c) to determine
 * the context associated with the client, and then queries the context's
 * attributes to determine whether the bitmap fonts should be visible.
 * It looks at the value of the xp-listfonts-mode document/page attribute to 
 * see if xp-list-glyph-fonts has been left out of the mode list. Only
 * if the xp-listfonts-mode attribute exists, and it does not contain
 * xp-list-glyph-fonts does this function return FALSE. In any other
 * case the funtion returns TRUE, indicating that the bitmap fonts 
 * should be visible to the client.
 */
Bool
XpClientIsBitmapClient(
    ClientPtr client)
{
    XpContextPtr pContext;
    char *mode;

    if(!(pContext = XpContextOfClient(client)))
	return TRUE;

    /*
     * Check the page attributes, and if it's not defined there, then
     * check the document attributes.
     */
    mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-mode");
    if(!mode || !strlen(mode))
    {
        mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-mode");
        if(!mode || !strlen(mode))
	    return TRUE;
    }
    
    if(!strstr(mode, "xp-list-glyph-fonts"))
	return FALSE;

    return TRUE;
}
Example #2
0
/* static utility function to get document/page attributes */
static void
S_GetPageAttributes(XpContextPtr pCon,int *iorient,int *icount, int *iplex,
                  int *ires, unsigned short *iwd, unsigned short *iht)
{
    char               *count;
    XpOid              orient, plex;
    /*
     *  Get the orientation
     */
    orient = XpGetContentOrientation(pCon);
    switch (orient) {
    case xpoid_val_content_orientation_landscape:
      *iorient = 1;
      break;
    case xpoid_val_content_orientation_reverse_portrait:
      *iorient = 2;
      break;
    case xpoid_val_content_orientation_reverse_landscape:
      *iorient = 3;
      break;
    case xpoid_val_content_orientation_portrait:
    default:
      *iorient = 0;
      break;
    }

    /*
     *  Get the count
     */
    count = XpGetOneAttribute(pCon, XPDocAttr, "copy-count");
    if( count )
    {
      int ii = sscanf(count, "%d", icount);
      if( ii!=1 ) *icount = 1;
    }
    else *icount = 1;

    /*
     * Get the plex
     */
    plex = XpGetPlex(pCon);
    switch(plex)
    {
    case xpoid_val_plex_duplex:
      *iplex = 1;
      break;
    case xpoid_val_plex_tumble:
      *iplex = 2;
      break;
    default:
      *iplex = 0;
      break;
    }

  /*
   *  Get the resolution and media size
   */
    *ires = XpGetResolution(pCon);
    XpGetMediumDimensions(pCon, iwd, iht);
}
Example #3
0
static void 
ResourcesUpdate(Widget w, XPContext pcontext,
		Dimension * pwidth, Dimension * pheight)
{
    XmPrintShellWidget print_shell = (XmPrintShellWidget) w ;
    String string_resolution ;
    XRectangle imageable_area ;

    /*** Get the resolution so that unit Type conversion works */
    string_resolution =  
	XpGetOneAttribute(XtDisplay(w), pcontext,
			  XPDocAttr, "default-printer-resolution") ;
    print_shell->print.print_resolution = atoi(string_resolution);
    XFree(string_resolution);

    if (!print_shell->print.print_resolution)
	/* compute from the X screen resolution */
	print_shell->print.print_resolution = 
	    (254 * WidthOfScreen(XtScreen(w)) +
	     5 * WidthMMOfScreen(XtScreen(w))) /
	    (10 * WidthMMOfScreen(XtScreen(w))) ;

    /* get our size from the print server now */
    XpGetPageDimensions(XtDisplay(w), pcontext,
			pwidth, pheight, 
			&imageable_area);
    print_shell->print.min_x = imageable_area.x ;    
    print_shell->print.min_y = imageable_area.y ;    
    print_shell->print.max_x = imageable_area.x + imageable_area.width ;    
    print_shell->print.max_y = imageable_area.y + imageable_area.height ;
}
static
void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext )
{
    char *scr;

    scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results");
    if( scr )
    {
      if( strlen(scr) > 0 )
      {
        const char *msg = XpuCompoundTextToXmb(pdpy, scr);
        if( msg )
        {
          Msg(("Spooler command returned '%s'.\n", msg));
          XpuFreeXmbString(msg);
        }
        else
        {
          Msg(("Spooler command returned '%s' (unconverted).\n", scr));
        }
      }

      XFree((void *)scr);
    }
}
Example #5
0
char *
PclGetOneAttribute(
     XpContextPtr pCon,
     XPAttributes pool,
     char *attr )
{
    return XpGetOneAttribute( pCon, pool, attr );
}
Example #6
0
/* StartPage 
 */
int
PsStartPage(
  XpContextPtr pCon,
  WindowPtr    pWin)
{
  int                iorient, iplex, icount, ires;
  unsigned short     iwd, iht;
  register WindowPtr pChild;
  PsContextPrivPtr   pConPriv =
     (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
  PsWindowPrivPtr    pWinPriv =
     (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
  char               s[80];
  xEvent event;

/*
 * Put a pointer to the context in the window private structure
 */
  pWinPriv->validContext = 1;
  pWinPriv->context      = pCon;

  /* get page level attributes */
  S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht);
  /*
   *  Start the page
   */
  if (pConPriv->pPsOut == NULL) {
    char *title;
    
    /* get job level attributes */ 
    title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");

    pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
                                       title, iorient, icount, iplex, ires,
                                       (int)iwd, (int)iht, False);
    pConPriv->fontInfoRecords     = NULL;
    pConPriv->fontTypeInfoRecords = NULL;
  }
  PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires,
		  (int)iwd, (int)iht);

  return Success;
}
Example #7
0
int
PsStartDoc(XpContextPtr pCon, XPDocumentType type)
{
  int                iorient, iplex, icount, ires;
  unsigned short     iwd, iht;
  char              *title;
  PsContextPrivPtr   pConPriv = 
      (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;

  /* get job level attributes */ 
  title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
 
  /* get document level attributes */
  S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht);

  pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
                                     title, iorient, icount, iplex, ires,
                                     (int)iwd, (int)iht, (Bool)(type == XPDocRaw));

  pConPriv->fontInfoRecords     = NULL;
  pConPriv->fontTypeInfoRecords = NULL;

  return Success;
}
Example #8
0
File: Init.c Project: aosm/X11
/*
 * XpClientIsPrintClient is called by the font code to find out if
 * a particular client has set a context which references a printer
 * which utilizes a particular font path.  This function works by
 * calling XpContextOfClient (in Xserver/Xext/xprint.c) to determine
 * the context associated with the client, and then looks up the
 * font directory for the context.  The font directory is then compared
 * with the directory specified in the FontPathElement which is passed in.
 */
Bool
XpClientIsPrintClient(
    ClientPtr client,
    FontPathElementPtr fpe)
{
    XpContextPtr pContext;
    char *modelID, *fontDir;

    if(!(pContext = XpContextOfClient(client)))
	return FALSE;

    if (!fpe)
	return TRUE;

    modelID = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-model-identifier");
    if(!modelID || !strlen(modelID))
	return FALSE;
    
    if(!(fontDir = FindFontDir(modelID)))
	return FALSE;

    /*
     * The grunge here is to ignore the PATH_PREFIX at the front of the
     * fpe->name.
     */
    if(fpe->name_length < PATH_PREFIX_LEN || 
       (strlen(fontDir) != (unsigned)(fpe->name_length - PATH_PREFIX_LEN)) ||
       strncmp(fontDir, fpe->name + PATH_PREFIX_LEN, 
	       fpe->name_length - PATH_PREFIX_LEN))
    {
	xfree(fontDir);
	return FALSE;
    }
    xfree(fontDir);
    return TRUE;
}
Example #9
0
/********************************************************************
 *
 * Figure out which pdm executable to later fork/exec.
 */
void mgr_fetch_pdm( XpPdmServiceRec *rec )
{
    char tstr[1024], *tptr1, *tptr2, *tptr3;
    int  firstTime;
    long now;
    Display *tdpy;
    int lxerrno;

    if ( g.override_pdm ) {
	/*
	 * Override all defaults and other possible settings.
	 */
	tptr1 = xpstrdup(g.override_pdm);
    }
    else {
	/*
	 * See if the print context says which pdm to run.
	 */
	g.xerrno = 0;		/* Error Handler */
	lxerrno = 0;		/* XIO Error Handler */

	if ( setjmp( xio_quickie_jmp_buf ) == 0 ) {
	    XSetIOErrorHandler( xio_quickie_handler );

#if 0 && defined(PRINTING_SUPPORTED)
	    if ( rec->seldpy_as_printdpy ) {
		tptr1 = XpGetOneAttribute( rec->selection_display,
				   rec->print_context,
				   XPPrinterAttr, "dt-pdm-command" );
	    }
	    else {
		tdpy = XOpenDisplay( rec->print_display_str );
		if (tdpy) {
		    tptr1 = XpGetOneAttribute( tdpy,
                                   rec->print_context,
                                   XPPrinterAttr, "dt-pdm-command" );
		    XCloseDisplay( tdpy );
		}
	    }
#endif /* PRINTING_SUPPORTED */

	    XSetIOErrorHandler( NULL );
	}
	else {
	    lxerrno = 1;

	    XSetIOErrorHandler( NULL );
	}

	/*
	 * See if we got a useful pdm exec string.  Use
	 * default if not.
	 */
	if ( g.xerrno || lxerrno ) {
	    rec->pdm_exec_errorcode = g.pdm_start_error;
	    return;
	}
	else if (!tptr1) {
	    tptr1 = xpstrdup(g.default_pdm);
	}
	else if (!tptr1[0]) {
	    tptr1 = xpstrdup(g.default_pdm);
	}
    }
    
    /*
     * Convert pdm-command into argv[] style array.
     *
     * Note: this parsing code does NOT respect shell
     * quotes and other items.   --tomg
     */
    rec->pdm_exec_argvs = (char **) NULL;

    tptr2 = tptr1;	/* retain orig pointer for freeing */
    firstTime = 1;

    while (1) {
	if (firstTime) {
	    tptr3 = xpstrtok( tptr2, " \n\t" );
	    firstTime = 0;

	    if (!tptr3) {
		/*
		 * There were NO useful tokens to begin with, so
		 * we'll have to fall back on the default.
		 */
		xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup( g.default_pdm ));
		break;
	    }
	}
	else {
	    tptr3 = xpstrtok( (char *) NULL, " \n\t" );
	}

	if (tptr3) {
	    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup( tptr3 ) );
	}
	else {
	    break;
	}
    }
    Xfree(tptr1);

    /*
     * Add standard command line parameters.
     */
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup("-display") );
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup(rec->video_display_str) );

    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup("-window") );
    sprintf( tstr, "0x%lx", rec->video_window );
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup(tstr) );

    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup("-pdisplay") );
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup(rec->print_display_str) );

    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup("-pwindow") );
    sprintf( tstr, "0x%lx", rec->print_window );
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup(tstr) );

#if 0 && defined(PRINTING_SUPPORTED)
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup("-pcontext") );
    sprintf( tstr, "0x%lx", rec->print_context );
    xp_add_argv( &(rec->pdm_exec_argvs), xpstrdup(tstr) );
#endif /* PRINTING_SUPPORTED */
}