Exemple #1
0
int
ScanTimers(int doRun, int maxMs)
{
    int dt = maxMs;
    Timer *scan;

    while ((scan = TimerBase.ti_Next) != &TimerBase) {
	if (scan->ti_Tv.tv_sec < CurTime.tv_sec ||
	    (scan->ti_Tv.tv_sec == CurTime.tv_sec &&
	    scan->ti_Tv.tv_usec <= CurTime.tv_usec)
	) {
	    if (doRun) {
		int fd;

		if ((fd = scan->ti_Desc->d_Fd) >= 0) {
		    if (scan->ti_Flags & TIF_READ)
			FD_SET(fd, &RFds);
		    if (scan->ti_Flags & TIF_WRITE)
			FD_SET(fd, &WFds);
		}
		DelTimer(scan);
		continue;
	    }
	    dt = 0;
	} else {
	    dt = (scan->ti_Tv.tv_sec - 1 - CurTime.tv_sec) * 1000 +
		(scan->ti_Tv.tv_usec + 1000000 - CurTime.tv_usec) / 1000;
	}
	break;
    }
    return(dt);
}
Exemple #2
0
void
ResetThreads(void)
{
    int i;

    for (i = 0; i < MaxFds; ++i) {
	ForkDesc *desc;
	if ((desc = FDes[i]) != NULL) {
	    if (desc->d_Timer) {
		DelTimer(desc->d_Timer);
		desc->d_Timer = NULL;
	    }
	    if (desc->d_Fd >= 0) {
		close(desc->d_Fd);
		desc->d_Fd = -1;
	    }
	    if (desc->d_FdPend >= 0) {
		close(desc->d_FdPend);
		desc->d_FdPend = -1;
	    }
	}
    }
    FD_ZERO(&SFds);
    FD_ZERO(&RFds);
    FD_ZERO(&WFds);
    bzero(FDes, sizeof(FDes));
    freePool(&TMemPool);
    MaxFds = 0;
}
CharacterWidget::CharacterWidget():m_bSecond(false),lastKeyId(65535)
{
    QPalette palette;
    if(m_bSecond)
    {
        palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/images/charactersubBackground.png")));
    }
    else
    {
        palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/images/characterBackground.png")));
    }

    this->setPalette (palette);

    QPixmap tmp_pixmap = QPixmap(":/images/characterBackground.png");
    this->setGeometry(0,125, tmp_pixmap.width(), tmp_pixmap.height());
    this->setFocusPolicy(Qt::ClickFocus);

    BottonPress = new QLabel(this);
    //ttonPressLarge = new QLabel(0);
    BottonPress->hide();
    //ttonPressLarge->hide();
    //ttonPressLarge->setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint|Qt::Tool);

    BottonPressLarge=BottonPressLarge1;

    PressLargeLabelText= new QLabel(BottonPressLarge);
    PressLargeLabelText->hide();
    PressLargeLabelText->setAlignment(Qt::AlignHCenter);

    DelTimeOutTime = 1;
    m_DelTimer = new QTimer(this);

    connect(m_DelTimer, SIGNAL(timeout()), this, SLOT(DelTimer()));
}
Exemple #4
0
void
DelThread(ForkDesc *desc)
{
    int fd = desc->d_Fd;

    if (desc->d_Timer) {
	DelTimer(desc->d_Timer);
	desc->d_Timer = NULL;	/* XXX not necessary */
    }

    if (fd >= 0) {
	FDes[fd] = NULL;
	close(fd);
	desc->d_Fd = -1;

	FD_CLR(fd, &SFds);
	FD_CLR(fd, &RFds);
	FD_CLR(fd, &WFds);

	if (fd + 1 == MaxFds) {
	    while (fd >= 0) {
		if (FDes[fd] != NULL)
		    break;
		--fd;
	    }
	    MaxFds = fd + 1;
	}
    }
    zfreeStr(&TMemPool, &desc->d_Id);
    zfree(&TMemPool, desc, sizeof(ForkDesc));
}
Exemple #5
0
EditWidget::EditWidget()
{	
	QPalette palette;
	selectStart = false;
	if(!selectStart)
	{
    	palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/images/editbackground.png")));
	}
	else
	{
    	palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/images/editbackgroundend.png")));
	}
	this->setPalette (palette);

	QPixmap tmp_pixmap = QPixmap(":/images/editbackground.png");
	this->setGeometry(123, 254, tmp_pixmap.width(), tmp_pixmap.height());
	this->setFocusPolicy(Qt::ClickFocus);	
	
    BottonPress = new QLabel(this);
	BottonPress->hide();

	DelTimeOutTime = 1;
	m_DelTimer = new QTimer(this);

	connect(m_DelTimer, SIGNAL(timeout()), this, SLOT(DelTimer()));
	
}         
Exemple #6
0
void stopwar(void)
{
	int i;
	if (currentwargamestatus == WS_GAME_STARTING) {
		DelTimer ("startwar");
	}
	for (wpln = 0; wpln < 10; wpln++) {
		strlcpy (wplayernick[wpln], " ", MAXNICK);
		wplayercardstotal[wpln]= 0;
		wplayercardplayed[wpln]= 0;
		wplayeratwar[wpln]= 0;
		for (i = 0; i < 52; i++) {
			wplayercardsinhand[wpln][i]= 0;
		}
		for (i = 0; i < 3; i++) {
			wplayerwarcardsplayed[wpln][i]= 0;
		}
	}
	for (wpln = 0; wpln < 52; wpln++) {
		wstackcards[wpln]= 0;
	}
	warinprogress= 0;
	wstackcardscurrent= 0;
	currentwarplayercount = 0;
	currentwargamestatus = WS_GAME_STOPPED;
	currentplayer= 0;
	return;
}
Exemple #7
0
void
AddTimer(ForkDesc *desc, int ms, int flags)
{
    Timer *ti = zalloc(&TMemPool, sizeof(Timer));
    Timer *scan;

    if (desc->d_Timer) {
	DelTimer(desc->d_Timer);
    }

    ti->ti_To.tv_sec = ms / 1000;
    ti->ti_To.tv_usec = (ms - (ti->ti_To.tv_sec * 1000)) * 1000;
    ti->ti_Tv.tv_usec = CurTime.tv_usec + ti->ti_To.tv_usec;
    ti->ti_Tv.tv_sec = CurTime.tv_sec + ti->ti_To.tv_sec;
    if (ti->ti_Tv.tv_usec >= 1000000) {
	ti->ti_Tv.tv_usec -= 1000000;
	++ti->ti_Tv.tv_sec;
    }

    /*
     * Attach to descriptor, clear select bits
     * on descriptor for timer function.
     */

    desc->d_Timer = ti;
    ti->ti_Desc = desc;
    ti->ti_Flags = flags;

    if (desc->d_Fd >= 0) {
	if (flags & TIF_READ)
	    FD_CLR(desc->d_Fd, &RFds);
	if (flags & TIF_WRITE)
	    FD_CLR(desc->d_Fd, &WFds);
    }

    /*
     * find insert-before point
     */
    for (scan = TimerBase.ti_Next; scan != &TimerBase; scan = scan->ti_Next) {
	if (ti->ti_Tv.tv_sec < scan->ti_Tv.tv_sec ||
	    (ti->ti_Tv.tv_sec == scan->ti_Tv.tv_sec &&
	    ti->ti_Tv.tv_usec < scan->ti_Tv.tv_usec)
	) {
	    break;
	}
    }
    ti->ti_Next = scan;
    ti->ti_Prev = scan->ti_Prev;
    ti->ti_Prev->ti_Next = ti;
    ti->ti_Next->ti_Prev = ti;
}
Exemple #8
0
void FiniTimers( void )
{
	lnode_t *tn;
	Timer *timer;
	
	evtimer_del( evtimers );
	os_free( evtimers );
	DelTimer("PingServers");
	DelTimer("FlushLogs");
	if (nsconfig.setservertimes > 0) 
		DelTimer("SetServersTime");
	DelTimer("ResetLogs");

	if (list_count(timerlist) > 0) {
		tn = list_first(timerlist);
		while( tn != NULL )
		{
			timer = lnode_get( tn );
			dlog( DEBUG3, "FiniTimers() BUG: Timer %s not deleted for module %s", timer->name, timer->moduleptr->info->name );
			tn = list_next(timerlist, tn);
		}
	}
	list_destroy( timerlist );
}
void cSearchTimerThread::RemoveTimer(cTimer* t, const cEvent* e)
{
   if (!t) return;
   if (EPGSearchConfig.sendMailOnSearchtimers)
      mailNotifier.AddRemoveTimerNotification(t,e);
   if (!EPGSearchConfig.TimerProgRepeat)
   {
      cTimerDone * TimerDone = TimersDone.InList(t->StartTime(), t->StopTime(), e, -1);
      if (TimerDone)
      {
         cMutexLock TimersDoneLock(&TimersDone);
         TimersDone.Del(TimerDone);
         TimersDone.Save();
      }
   }
   DelTimer(t->Index()+1);
}
Exemple #10
0
static int ss_set_html_cb( const CmdParams *cmdparams, SET_REASON reason )
{
	if( reason == SET_CHANGE )
	{
		if( StatServ.html && StatServ.htmlpath[0] == 0 )
		{
			irc_prefmsg ( statbot, cmdparams->source, 
				"You need to SET HTMLPATH. HTML output disabled." );
			StatServ.html = 0;
			return NS_SUCCESS;
		}
		if( StatServ.html )
			AddTimer( TIMER_TYPE_INTERVAL, HTMLOutputTimer, "HTMLOutputTimer", StatServ.htmltime, NULL );
		else
			DelTimer( "HTMLOutputTimer" );
	}
	return NS_SUCCESS;
}
Exemple #11
0
DigitWidget::DigitWidget()
{
    QPalette palette;
    palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/images/digitalbackground.png")));

    this->setPalette (palette);

    QPixmap tmp_pixmap = QPixmap(":/images/digitalbackground.png");
    this->setGeometry(0, 125, tmp_pixmap.width(), tmp_pixmap.height());
    this->setFocusPolicy(Qt::ClickFocus);

    BottonPress = new QLabel(this);
    BottonPress->hide();

    DelTimeOutTime = 1;
    m_DelTimer = new QTimer(this);

    connect(m_DelTimer, SIGNAL(timeout()), this, SLOT(DelTimer()));
}