Exemple #1
0
void p_http_fd_activate(struct url *u, fd_set *readfds, fd_set *writefds, fd_set *exceptfds) {
  struct http_data *hd = (struct http_data *) u->extra;
  size_t n_available;
  size_t n_read;

  if (FD_ISSET(hd->fd,readfds)) {

    /* Check how much data is actually available */
    ioctl(hd->fd, FIONREAD, &n_available);
    if (n_available <= 0) {
      /* Done */
      
      url_deactivate(u);
      u->data = pgFromMemory(hd->buffer, u->bytes_received);
      url_setstatus(u, URL_STATUS_DONE);
      return;
    }

    /* Will we need more space to read this? */
    if (u->bytes_received + n_available > hd->buffer_size) {
      hd->buffer_size = u->bytes_received + n_available + GROW_PAGE_BUFFER;
      hd->buffer = realloc(hd->buffer, hd->buffer_size);
      if (!hd->buffer) {
	browserwin_errormsg(u->browser,"Can't increase page buffer size");
	url_setstatus(u,URL_STATUS_ERROR);
	url_deactivate(u);
      }
      DBG("resized page buffer to %d\n",hd->buffer_size);
    }

    n_read = read(hd->fd,hd->buffer + u->bytes_received, n_available);
    if (!n_read) {
      browserwin_errormsg(u->browser,"Error reading from web server");
      url_setstatus(u,URL_STATUS_ERROR);
      url_deactivate(u);
    }
    if (n_read > 0)
      u->bytes_received += n_read;

    url_progress(u);
  }
}
Exemple #2
0
/*
 * Send a command to the virtual keyboard.
 * A virtual keyboard process is started if none is running.
 *
 * force       : 0 --> the command is ignored if a physical keyboard is present
 *               1 --> the command is always sent to the virtual keyboard
 */
void send_command (struct keyboard_command * cmd, int force)
{
  if ( cmd && (!physical_keyboard_available () || force) )
    {
      pghandle kb;

      DPRINTF ("sending command: %d\n", cmd->type);
      cmd->type = htons (cmd->type);

      while ( !(kb = pgFindWidget (PG_KEYBOARD_APPNAME)) )
	{
	  DPRINTF ("'pgboard' not running, please start it ...\n");

	  sleep (2);
	}

      /* Send the user command */
      pgAppMessage (kb, pgFromMemory (cmd, sizeof (struct keyboard_command)));

      /* Flush PG_APPMSG requests */
      pgFlushRequests ();
    }
}
Exemple #3
0
/* Create our toolbar */
void init_call_info(void) {
  pghandle bArrowMask,bArrow;
    
  /* Set up a bitmap/bitmask for the keypad button up arrow.
   * We have the mask stored in PNM format, and we paint
   * the arrow bitmap itself solid black. If we wanted another
   * color for the arrow, we could paint it that other color,
   * then apply the bitmask to it with the PG_LGOP_INVERT_AND
   * logical operation to mask out only the arrow part.
   */
  bArrowMask = pgNewBitmap(pgFromMemory(arrow_bits,arrow_len));
  bArrow = pgCreateBitmap(11,6);
  pgRender(bArrow,PG_GROP_SETCOLOR,0x000000);
  pgRender(bArrow,PG_GROP_RECT,0,0,15,8);

  /* Create a toolbar that starts out hidden */
  wInfoBar = pgRegisterApp(PG_APP_TOOLBAR,"pgtuxphone/call_info",
			   PG_APPSPEC_SIDE, PG_S_BOTTOM,
			   0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIZE,0,
	      0);
  
  /* Create widgets within the toolbar */
  
  wKeypadBtn = pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_BITMAP, bArrow,
	      PG_WP_BITMASK, bArrowMask,
	      PG_WP_EXTDEVENTS, PG_EXEV_TOGGLE,
	      PG_WP_TEXT,pgNewString("Keypad"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnKeypad,NULL);
  
  pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_TEXT,pgNewString("Redial"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnRedial,NULL);

  /* Make the connect time opaque and fixed-width to minimize the
   * amount of redrawing necessary to update it */
  wConnectTime = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TRANSPARENT,0,
	      PG_WP_SIDE,PG_S_RIGHT,
	      PG_WP_FONT,pgNewFont(NULL,0,PG_FSTYLE_FIXED),
	      0);
  wCallStatus = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);

  wName = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_FONT,pgNewFont(NULL,12,0),
	      0);

  wPhoneNumber = pgNewWidget(PG_WIDGET_CANVAS,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_ALL,
	      0);
  new_vfd_label(wPhoneNumber);

}