Ejemplo n.º 1
0
/* Fonction appelée continuellement en cours de traitement */
int yield( void )
{
  int ret;
  long time, elapsed, remaining;
  evnt.timer = 0;
  if( preferences.pref_flags.multitask )
  {
    ret = FormWindDo( FORM_EVNT|MU_MESAG|MU_TIMER );
    if( !(ret & FORM_EVNT) )
    {
      if( ret == PB_CANCEL )
        progress_exitflag = 1;
    }
  } else
  {
    ret = EvntWindom( MU_KEYBD|MU_TIMER );
    if( (ret & MU_KEYBD) && evnt.keybd == 0x11b )
      progress_exitflag = 1;
  }
  if( progress_start_time )
  {
    time = timer();
    if( time > progress_next_refresh )
    {
      elapsed = (time - progress_start_time) / 200;
      remaining = progress_count
                  ? (progress_max * elapsed / progress_count - elapsed)
                  : 0;
      sprintf( ObjcString( progress_tree, PB_ELATIME, NULL ),
               "%02d:%02d", (int)(elapsed/60), (int)(elapsed%60) );
      if( remaining > 0 )
        sprintf( ObjcString( progress_tree, PB_REMTIME, NULL ),
                 "%02d:%02d", (int)(remaining/60), (int)(remaining%60) );
      progress_display_object( PB_ELATIME );
      progress_display_object( PB_REMTIME );
      progress_next_refresh = time + PROGRESS_REFRESH_RATE;
    }
  }
  return progress_exitflag;
}
Ejemplo n.º 2
0
bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n ,
	unsigned long num_certs )
{
	OBJECT *tree;
	WINDOW * form;

	bool bres = false;
	bool cont = true;
	int res = 0;
	dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n;
	dp.num_certs = num_certs;
	dp.scrollx = 0;
	dp.scrolly = 0;
	dp.current = 0;
	dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] );
	dp.rows = 8;
	dp.tree = tree;

	RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
	ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
	ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
	ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
	form = FormWindBegin( tree, (char*)"SSL Verify failed"  );
	EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT );
	/* this results in some extended objects which can not be freed: :( */
	/* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */
	ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
	/*
	ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
	ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
	*/
	while( cont ) {
		res = FormWindDo( MU_MESAG );
		cont = false;
		switch( res ){
			case VERIFY_BT_ACCEPT:
				bres = true;
				break;

			case VERIFY_BT_NEXT_CERT:
			/* select box clicked or dragged... */
				cont = true;
				break;

			case VERIFY_BT_REJECT:
				bres = false;
				break;

			case VERIFY_BT_SCROLL_D:
					cont = true;
					dp.scrolly += 1;
					ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
				break;

			case VERIFY_BT_SCROLL_U:
					cont = true;
					dp.scrolly -= 1;
					ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
				break;

			case VERIFY_BT_SCROLL_R:
					LOG(( "scroll r!" ));
					cont = true;
					dp.scrollx += 1;
					if( dp.scrollx > (dp.cols - (272 / 8 )) )
						dp.scrollx -= 1;
					ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG);
				break;

			case VERIFY_BT_SCROLL_L:
					cont = true;
					dp.scrollx -= 1;
					if( dp.scrollx < 0 )
						dp.scrollx = 0;
					ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
				break;

			default:
				break;
		}
	}
	FormWindEnd( );
  return( bres );
}