示例#1
0
void PcapFilesReader::schedulePacket(unsigned index, const struct timeval *at) {
    scheduledIndex = index;

    int compare = timercmp(at, &zero, <=);
    if (compare) {
        // packet should already have been sent
        timerFired();
    } else {
        auto duration = std::chrono::seconds(at->tv_sec) +
                        std::chrono::microseconds(at->tv_usec);
        BMLOG_DEBUG("Pcap reader: sleep for {}", duration.count());
        std::this_thread::sleep_for(duration);
        timerFired();
    }
}
MixingWithTimersHelper::MixingWithTimersHelper(QTimer *timer, QTcpServer *server)
{
    timerActivated = false;
    socketActivated = false;

    connect(timer, SIGNAL(timeout()), SLOT(timerFired()));
    connect(server, SIGNAL(newConnection()), SLOT(socketFired()));
}
示例#3
0
void PcapFilesReader::schedulePacket(unsigned index, const struct timeval* at) {
  scheduledIndex = index;

  int compare = timercmp(at, &zero, <=);
  if (compare) {
    // packet should already have been sent
    timerFired();
  } else {
    auto duration = std::chrono::seconds(at->tv_sec) +
      std::chrono::microseconds(at->tv_usec);
#if DEBUG_TIMING
    std::cout << "Sleeping for " << duration.count() << std::endl;
#endif
    std::this_thread::sleep_for(duration);
    timerFired();
  }
}
示例#4
0
bool Statistics::start()
{
    if (!m_timer->IsRunning()) {
        timerFired();
        m_timer->Start(m_interval);
        return true;
    } else
        return false;
}
void TrainDialog::beginTraining() {
  progressBar = new QProgressBar();
  progressBar->setMaximum(TRAIN_TIME_S);
  trainButton->setVisible(false);
  layout->removeWidget(trainButton);
  layout->addWidget(progressBar);
  timer = new QTimer(this);
  connect(timer, SIGNAL(timeout()), this, SLOT(timerFired()));
  timer->start(1000);
  watcher = new QFutureWatcher<void>();
  connect(watcher, SIGNAL(finished()), this, SLOT(handleFinished()));
  QFuture<void> future = QtConcurrent::run(train);
  watcher->setFuture(future);
}
void makegif::draw(void)
{
    timerFired();
    straightMotion(3);
    int number=timeCounter%12;
    unsigned char *dat1;
    dat1=new unsigned char[4*picWidth*picHeight];
    for(int y=0; y<picHeight; ++y)
    {
        for(int x=0; x<picWidth; ++x)
        {
            unsigned char *pix=dat+(picWidth*y+x)*4+4*picWidth*picHeight*number;
            dat1[(picWidth*y+x)*4]=pix[0];
            dat1[(picWidth*y+x)*4+1]=pix[1];
            dat1[(picWidth*y+x)*4+2]=pix[2];
            dat1[(picWidth*y+x)*4+3]=pix[3];
        }
    }

    glRasterPos2d(double(startX),double(startY));

    glDrawPixels(picWidth,picHeight,GL_RGBA,GL_UNSIGNED_BYTE,dat1);
    delete [] dat1;
}
NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationClient* client)
    : ActiveDOMObject(context)
    , m_client(client)
    , m_timer([this]() { timerFired(); })
{
}
void makegif::copyRGBA(YsRawPngDecoder &image1,YsRawPngDecoder &image2,TextString &str)
{
    dat=new unsigned char[48*picHeight*picWidth];
    unsigned char *dat2;
    dat2=new unsigned char[4*image1.wid*image1.hei];

    int position1[4];
    int position2[4];
    position1[0]=image1HeadLTx;
    position1[1]=image1HeadLTy;
    position1[2]=image1HeadRBx;
    position1[3]=image1HeadRBy;

    position2[0]=headLTx;
    position2[1]=headLTy;
    position2[2]=headRBx;
    position2[3]=headRBy;

    for(int y=0; y<image1.hei; ++y)
    {
        for(int x=0; x<image1.wid; ++x)
        {
            unsigned char *pix1=image1.rgba+(image1.wid*y+x)*4;
            dat2[(image1.wid*y+x)*4]=pix1[0];
            dat2[(image1.wid*y+x)*4+1]=pix1[1];
            dat2[(image1.wid*y+x)*4+2]=pix1[2];
            dat2[(image1.wid*y+x)*4+3]=pix1[3];
            pix1=NULL;
            delete pix1;
        }
    }

    for(int i=0; i<12; i++)
    {
        choose(image2,str);
        warpImage(image1,image2,position1,position2,0.0);
        image2.Flip();
        for(int y=0; y<picHeight; ++y)
        {
            for(int x=0; x<picWidth; ++x)
            {
                unsigned char *pix=image2.rgba+(picWidth*y+x)*4;
                dat[4*picWidth*picHeight*timeCounter+(picWidth*y+x)*4]=pix[0];
                dat[4*picWidth*picHeight*timeCounter+(picWidth*y+x)*4+1]=pix[1];
                dat[4*picWidth*picHeight*timeCounter+(picWidth*y+x)*4+2]=pix[2];
                dat[4*picWidth*picHeight*timeCounter+(picWidth*y+x)*4+3]=pix[3];
            }
        }

        for(int y=0; y<image1.hei; ++y)
        {
            for(int x=0; x<image1.wid; ++x)
            {
                unsigned char *pix3=dat2+(image1.wid*y+x)*4;
                image1.rgba[(image1.wid*y+x)*4]=pix3[0];
                image1.rgba[(image1.wid*y+x)*4+1]=pix3[1];
                image1.rgba[(image1.wid*y+x)*4+2]=pix3[2];
                image1.rgba[(image1.wid*y+x)*4+3]=pix3[3];
                pix3=NULL;
                delete pix3;
            }
        }

        image2.Flip();
        timerFired();
    }
    delete [] dat2;
}
示例#9
0
NicksOnline::NicksOnline(QWidget* parent): ChatWindow(parent)
{
    setName(i18n("Watched Nicks Online"));
    setType(ChatWindow::NicksOnline);

    m_nickListView=new KListView(this);

    // Set to false every 8 seconds to permit a whois on watched nicks lacking information.
    // Remove when server or addressbook does this automatically.
    m_whoisRequested = true;

    m_nickListView->addColumn(i18n("Network/Nickname/Channel"));
    m_kabcIconSet = KGlobal::iconLoader()->loadIconSet("kaddressbook",KIcon::Small);
    m_nickListView->addColumn(i18n("Additional Information"));
    m_nickListView->setFullWidth(true);
    m_nickListView->setRootIsDecorated(true);
    m_nickListView->setShowToolTips(false);
    m_nickListView->setShadeSortColumn(true);
    m_nickListView->setShowSortIndicator(true);

    QString nickListViewWT = i18n(
                                 "<p>These are all the nicknames on your Nickname Watch list, listed under the "
                                 "server network they are connected to.  The list also includes the nicknames "
                                 "in KAddressBook associated with the server network.</p>"
                                 "<p>The <b>Additional Information</b> column shows the information known "
                                 "for each nickname.</p>"
                                 "<p>The channels the nickname has joined are listed underneath each nickname.</p>"
                                 "<p>Nicknames appearing under <b>Offline</b> are not connected to any of the "
                                 "servers in the network.</p>"
                                 "<p>Right-click with the mouse on a nickname to perform additional functions.</p>");
    QWhatsThis::add(m_nickListView, nickListViewWT);

    m_tooltip = new Konversation::KonversationNicksOnlineToolTip(m_nickListView->viewport(), this);

    setMargin(margin());
    setSpacing(spacing());

    QHBox* buttonBox=new QHBox(this);
    buttonBox->setSpacing(spacing());
    QPushButton* editButton=new QPushButton(i18n("&Edit Watch List..."),
                                            buttonBox,"edit_notify_button");
    QString editButtonWT = i18n(
                               "Click to edit the list of nicknames that appear on this screen.");
    QWhatsThis::add(editButton, editButtonWT);

    connect(editButton, SIGNAL(clicked()), SIGNAL(editClicked()) );
    connect(m_nickListView, SIGNAL(doubleClicked(QListViewItem*)),
            this,SLOT(processDoubleClick(QListViewItem*)));

    QLabel* addressbookLabel = new QLabel(i18n("Address book:"),
                                          buttonBox, "nicksonline_addressbook_label");
    QString addressbookLabelWT = i18n(
                                     "When you select a nickname in the list above, the buttons here are used "
                                     "to associate the nickname with an entry in KAddressBook.");
    QWhatsThis::add(addressbookLabel, addressbookLabelWT);
    addressbookLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    m_editContactButton = new QPushButton(i18n("Edit C&ontact..."),
                                          buttonBox, "nicksonline_editcontact_button");
    QString editContactButtonWT = i18n(
                                      "Click to create, view, or edit the KAddressBook entry associated with the nickname "
                                      "selected above.");
    QWhatsThis::add(m_editContactButton, editContactButtonWT);
    m_editContactButton->setIconSet(m_kabcIconSet);
    m_changeAssociationButton = new QPushButton(i18n("&Change Association..."),
            buttonBox, "nicksonline_changeassociation_button");
    QString changeAssociationButtonWT = i18n(
                                            "Click to associate the nickname selected above with an entry in KAddressBook.");
    QWhatsThis::add(m_changeAssociationButton, changeAssociationButtonWT);
    m_changeAssociationButton->setIconSet(m_kabcIconSet);
    m_deleteAssociationButton = new QPushButton(i18n("&Delete Association"),
            buttonBox, "nicksonline_deleteassociation_button");
    QString deleteAssociationButtonWT = i18n(
                                            "Click to remove the association between the nickname selected above and a "
                                            "KAddressBook entry.");
    QWhatsThis::add(m_deleteAssociationButton, deleteAssociationButtonWT);
    m_deleteAssociationButton->setIconSet(m_kabcIconSet);

    connect(m_editContactButton, SIGNAL(clicked()),
            this, SLOT(slotEditContactButton_Clicked()));
    connect(m_changeAssociationButton, SIGNAL(clicked()),
            this, SLOT(slotChangeAssociationButton_Clicked()));
    connect(m_deleteAssociationButton, SIGNAL(clicked()),
            this, SLOT(slotDeleteAssociationButton_Clicked()));
    connect(m_nickListView, SIGNAL(selectionChanged()),
            this, SLOT(slotNickListView_SelectionChanged()));

    setupAddressbookButtons(nsNotANick);

    // Create context menu.  Individual menu entries are created in rightButtonClicked slot.
    m_popupMenu = new QPopupMenu(this,"nicksonline_context_menu");
    connect(m_nickListView, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int )),
            this, SLOT(slotNickListView_RightButtonClicked(QListViewItem*, const QPoint &)));
    connect(m_popupMenu, SIGNAL(activated(int)),
            this, SLOT(slotPopupMenu_Activated(int)));

    // Display info for all currently-connected servers.
    refreshAllServerOnlineLists();

    // Connect and start refresh timer.
    m_timer = new QTimer(this, "nicksOnlineTimer");
    connect(m_timer, SIGNAL (timeout()), this, SLOT(timerFired()));
    // TODO: User preference for refresh interval.
    m_timer->start(8000);
}