示例#1
0
void *OSDPlugin::processEvent(Event *e)
{
    OSDRequest osd;
    Contact *contact;
    Message *msg;
    switch (e->type()){
    case EventContactOnline:
        contact = (Contact*)(e->param());
        if (contact->getIgnore()) break;
        osd.contact = contact->id();
        osd.type    = OSD_ALERT;
        queue.push_back(osd);
        processQueue();
        break;
    case EventMessageReceived:
        msg = (Message*)(e->param());
        if (msg->type() == MessageStatus)
            break;
        osd.contact = msg->contact();
        osd.type    = msg->type();
        osd.msg_id	= msg->id();
        osd.client	= msg->client();
        queue.push_back(osd);
        processQueue();
        break;
    }
    return NULL;
}
示例#2
0
void MainWindow::previewImage( int dummy )
{
  Q_UNUSED( dummy );

  // clear and abort if no preview
  if ( !ui->previewCheckBox->isChecked())
  {
    clearImage();
    return;
  }

  // cancel ongoing download
  cancelCurrentDownload();

  // get row to display
  QList<QTableWidgetItem*> selected = ui->pointTable->selectedItems();
  if ( selected.isEmpty())
  {
    clearImage();
    return;
  }

  mDnlQueue.clear();
  int i = selected[0]->row();
  DnlElement elem( i, true, false );
  mDnlQueue.append( elem );

  processQueue( true );
}
示例#3
0
void QProjector::processQueue()
{
    emit debug(tr("Projector processing queue of %1 pattern%2.")
               .arg(patternQueue.size())
               .arg(patternQueue.size()==1?"":"s"));
    if(patternQueue.size()>0) {
        Pattern *pattern = patternQueue.at(0);
        patternQueue.erase(patternQueue.begin());
        if(pattern==0) {
            processQueue();
            return;
        }
        emit debug(tr("Projector projects, and announces pattern has been projected."));

        GrayCodePattern *gray =
            dynamic_cast<GrayCodePattern*>(pattern);

        if(gray) {
            emit debug(tr("Projecting Gray code pattern,"
                          " bit %1, %2")
                       .arg(gray->getBit())
                       .arg(gray->isInverted()?
                            "inverted":
                            "not inverted"));
        }
        currentPattern = pattern;
        projectPattern(pattern);

        // handled by subclasses:
        // emit patternProjected
    }
    listenersWaitingFor = 0;
    listenersDenyingPermission = 0;
}
示例#4
0
void forestSample::add(double newW)
{
	short newP;
	node newOne;
	wsum += newW;

	newP = utils::discreteLog(newW);

	//update weight
	newOne.weight = newW;
	newOne.childNum = forest[1][newP].children.size();
	forest[0][N] = newOne;
	//forest[0].insert(std::pair<short,node>(N,newOne));
	forest[0].push_back(newOne);

	//Add new parent to processing queue for insertion
	temp1.task = 1;
	temp1.level = 1;
	temp1.pos = newP;
	temp1.addr = N;
	temp1.dw = forest[0][N].weight;
	Q1.push(temp1);

	++N;

	processQueue();
}
void LastFmImageFetcher::gotResponse(QNetworkReply* reply)
{

    if (reply->error() != QNetworkReply::NoError) {
        //qDebug() << reply->errorString();
        emit serviceUnavailable();
        return;
    }

    QDomDocument doc;
    doc.setContent(reply->readAll());

    const QDomElement firstElement = doc.firstChildElement().firstChildElement();
    const QString type = firstElement.tagName();

    const QString name = m_currentInfoDownloads.take(reply);
    const QDomNodeList imageList = firstElement.childNodes();

    for (int i=imageList.length(); i>0; i--) {
        const QDomElement element = imageList.at(i).toElement();
        if (element.tagName() == "image" &&
            (element.attribute("size") == "extralarge"
                || element.attribute("size") == "large")) {
            downloadImage(type, name, element.text());
            return;
        }
    }

//    qDebug() << "Webservice has no image for " << name;
    QTimer::singleShot(0, this, SLOT(processQueue()));

    reply->deleteLater();
}
示例#6
0
void forestSample::remove(short pos)
{
	short curP;
	node newOne;
	wsum -= forest[0][pos].weight;

	curP = utils::discreteLog(forest[0][pos].weight);

	//Add old parent to processing queue for deletion
	temp1.task = -1;
	temp1.level = 1;
	temp1.pos = curP;
	temp1.addr = forest[0][pos].childNum;
	temp1.dw = -forest[0][pos].weight;
	Q1.push(temp1);

	//update weight
	--N;
	curP = utils::discreteLog(forest[0][N].weight);
	forest[1][curP].children[forest[0][N].childNum] = pos;
	forest[0][pos] = forest[0][N];
	//forest[0].erase(N);
	forest[0].pop_back();

	processQueue();
}
示例#7
0
void SoundPlugin::childExited(int pid, int)
{
    if (pid == m_player){
        m_player = 0;
        m_current = "";
        processQueue();
    }
}
示例#8
0
bool SocketConnection::send( const std::string& msg )
{
  Locker l( m_mutex );

  m_sendQueue.push_back( msg );
  processQueue();
  signal();
  return true;
}
示例#9
0
void InputService::onTick(const TimeEvent* evt)
{
	// Send incoming (from outside tick loop) events of previous frame (ex. system event)
	processQueue(_eventQueue);

	++_frame;
	if (_frame < 0) _frame = 0;

	// Update devices of all users
	for (UserNameLookup::iterator itr = _users.begin(), end = _users.end(); itr != end; ++itr)
	{
		InputUser* user = itr->second;
		user->update(_frame);
	}

	// Send events which are queued during updating devices
	processQueue(_eventQueue);
}
示例#10
0
END_TEST

START_TEST (test_missing_callback)
{
    QUEUE_PUSH(uint8_t, &queue, (uint8_t) 128);
    processQueue(&queue, NULL);
    fail_if(called);
    fail_if(QUEUE_EMPTY(uint8_t, &queue));
}
示例#11
0
DWORD EventDispatcher::run() {
	exit = false;

	while(!exit) {
		WaitForSingleObject(eventSem, INFINITE);
		processQueue();
	}

	return 0;
}
示例#12
0
END_TEST

START_TEST (test_failure_preserves)
{
    callbackStatus = false;
    QUEUE_PUSH(uint8_t, &queue, (uint8_t) 128);
    processQueue(&queue, callback);
    fail_unless(called);
    fail_if(QUEUE_EMPTY(uint8_t, &queue));
}
示例#13
0
END_TEST

START_TEST (test_success_clears)
{
    callbackStatus = true;
    QUEUE_PUSH(uint8_t, &queue, (uint8_t) 128);
    processQueue(&queue, callback);
    fail_unless(called);
    fail_unless(QUEUE_EMPTY(uint8_t, &queue));
}
示例#14
0
void readFromSerial(SerialDevice* device, bool (*callback)(uint8_t*)) {
    if(device != NULL) {
        if(!QUEUE_EMPTY(uint8_t, &device->receiveQueue)) {
            processQueue(&device->receiveQueue, callback);
            if(!QUEUE_FULL(uint8_t, &device->receiveQueue)) {
                resumeReceive();
            }
        }
    }
}
示例#15
0
文件: upload.cpp 项目: snowy97/marble
void Upload::uploadAndDelete(const Region &region, const QFileInfo &file, const QString &transport)
{
    Package package;
    package.region = region;
    package.file = file;
    package.transport = transport;

    m_queue.removeAll(package);
    m_queue << package;
    processQueue();
}
void SplayPlayObject_impl::process_indata(Arts::DataPacket<Arts::mcopbyte> *inpacket) {
  arts_debug("receiving packet");


  packetQueue->enqueue((Frame*)inpacket);
  if (packetQueue->getFillgrade() == 1) {
    currentPos=0;
  }

  processQueue();
}
示例#17
0
END_TEST

START_TEST (test_clear_corrupted)
{
    callbackStatus = false;
    QUEUE_PUSH(uint8_t, &queue, (uint8_t) 128);
    QUEUE_PUSH(uint8_t, &queue, (uint8_t) '\0');
    processQueue(&queue, callback);
    fail_unless(called);
    fail_unless(QUEUE_EMPTY(uint8_t, &queue));
}
示例#18
0
void TestRegressionWindow::testerExited(int /* exitCode */, QProcess::ExitStatus exitStatus)
{
	assert(m_activeProcess != 0);
	assert(m_activeTreeItem != 0);

	if(exitStatus == QProcess::CrashExit) // Special case: crash!
	{
		QTreeWidgetItem *useItem = m_activeTreeItem;

		if(m_testCounter >= 0 || m_runCounter > 0) // Single-tests mode invoked on a directory OR All-test-mode
		{
			QTreeWidgetItem *parent = useItem->parent();
			assert(parent != 0);

			useItem = parent->child(parent->indexOfChild(useItem) + 1);
			assert(useItem != 0);
		}

		// Reflect crashed test...
		updateItemStatus(Crash, useItem, QString());
	}

	if(m_testCounter >= 0) // All-tests mode
		m_ui.progressBar->setValue(m_ui.progressBar->maximum());

	// Eventually save log output...
	if(!m_saveLogUrl.isEmpty())
	{
		// We should close our written log with </body></html>.
		m_processingQueue.enqueue(QString::fromLatin1("\n</body>\n</html>"));

		if(!m_justProcessingQueue)
		{
			m_justProcessingQueue = true;
			QTimer::singleShot(50, this, SLOT(processQueue()));
		}
	}

	// Cleanup gui...
	m_ui.saveLogButton->setEnabled(true);
	m_ui.actionRun_tests->setEnabled(true);
	m_ui.pauseContinueButton->setEnabled(false);

	// Check if there is already an output/index.html present...
	loadOutputHTML();

	// Cleanup data..
	delete m_activeProcess;
	m_activeProcess = 0;

	m_runCounter = 0;
	m_testCounter = 0;
	m_activeTreeItem = 0;
}
示例#19
0
void QProjector::requestAdvance()
{
    emit debug(tr("Someone requests that the projector advance."));
    if(hasDependencies()) {
        emit debug(QString("Projector announces intention to advance."));
        listenersWaitingFor = countDependencies();
        listenersDenyingPermission = 0;
        emit aboutToAdvance();
    } else {
        emit debug(QString("Projector directly processes pattern queue, as it has no listeners."));
        processQueue();
    }
}
示例#20
0
// TODO see if we can do this with interrupts on the chipKIT
// http://www.chipkit.org/forum/viewtopic.php?f=7&t=1088
void readFromSerial(SerialDevice* device, bool (*callback)(uint8_t*)) {
    if(device != NULL) {
        int bytesAvailable = ((HardwareSerial*)device->controller)->available();
        if(bytesAvailable > 0) {
            for(int i = 0; i < bytesAvailable &&
                    !QUEUE_FULL(uint8_t, &device->receiveQueue); i++) {
                char byte = ((HardwareSerial*)device->controller)->read();
                QUEUE_PUSH(uint8_t, &device->receiveQueue, (uint8_t) byte);
            }
            processQueue(&device->receiveQueue, callback);
        }
    }
}
示例#21
0
void
doRun(IOHIDDeviceInterface **hidDeviceInterface, cookie_struct_t cookies)
{
    IOReturn ioReturnValue;

    ioReturnValue = (*hidDeviceInterface)->open(hidDeviceInterface, 0);

    processQueue(hidDeviceInterface, cookies);

    if (ioReturnValue == KERN_SUCCESS)
        ioReturnValue = (*hidDeviceInterface)->close(hidDeviceInterface);
    (*hidDeviceInterface)->Release(hidDeviceInterface);
}
示例#22
0
int
asyncExecuteAlarmCallback (AsyncAlarmData *ad, long int *timeout) {
  if (ad) {
    Queue *alarms = ad->alarmQueue;

    if (alarms) {
      Element *element = processQueue(alarms, testInactiveAlarm, NULL);

      if (element) {
        AlarmEntry *alarm = getElementItem(element);
        TimeValue now;
        long int milliseconds;

        getMonotonicTime(&now);
        milliseconds = millisecondsBetween(&now, &alarm->time);

        if (milliseconds <= 0) {
          AsyncAlarmCallback *callback = alarm->callback;
          const AsyncAlarmCallbackParameters parameters = {
            .now = &now,
            .data = alarm->data
          };

          logSymbol(LOG_CATEGORY(ASYNC_EVENTS), callback, "alarm starting");
          alarm->active = 1;
          if (callback) callback(&parameters);
          alarm->active = 0;

          if (alarm->reschedule) {
            adjustTimeValue(&alarm->time, alarm->interval);
            getMonotonicTime(&now);
            if (compareTimeValues(&alarm->time, &now) < 0) alarm->time = now;
            requeueElement(element);
          } else {
            alarm->cancel = 1;
          }

          if (alarm->cancel) deleteElement(element);
          return 1;
        }

        if (milliseconds < *timeout) {
          *timeout = milliseconds;
          logSymbol(LOG_CATEGORY(ASYNC_EVENTS), alarm->callback, "next alarm: %ld", *timeout);
        }
      }
    }
  }

  return 0;
}
示例#23
0
END_TEST

START_TEST (test_full_clears)
{
    for(int i = 0; i < 512; i++) {
        QUEUE_PUSH(uint8_t, &queue, (uint8_t) 128);
    }
    fail_unless(QUEUE_FULL(uint8_t, &queue));

    callbackStatus = false;
    processQueue(&queue, callback);
    fail_unless(called);
    fail_unless(QUEUE_EMPTY(uint8_t, &queue));
}
void BatchingUIManager::dispatchFunction(std::function<void()> func)
{
  // If the queue is full then dispatch all items in the queue first
  if (this->m_queue->isFull())
  {
#ifdef TRACK_QUEUE
  OutputDebugStringA("BatchingUIManager: Processing Full Queue ...");
#endif

    processQueue();
  }

  m_queue->write(func);
}
示例#25
0
void readFromHost(UsbDevice* usbDevice, bool (*callback)(uint8_t*)) {
    if(!usbDevice->device.HandleBusy(usbDevice->hostToDeviceHandle)) {
        if(usbDevice->receiveBuffer[0] != NULL) {
            for(int i = 0; i < usbDevice->outEndpointSize; i++) {
                if(!QUEUE_PUSH(uint8_t, &usbDevice->receiveQueue,
                            usbDevice->receiveBuffer[i])) {
                    debug("Dropped write from host -- queue is full\r\n");
                }
            }
            processQueue(&usbDevice->receiveQueue, callback);
        }
        armForRead(usbDevice, usbDevice->receiveBuffer);
    }
}
示例#26
0
void MainWindow::run()
{
  freezeGui();
  int nPoints = mPoints.size();
  ui->globalProgressBar->setValue(0);
  ui->globalProgressBar->setMaximum(nPoints);
  ui->globalProgressBar->show();

  mDnlQueue.clear();
  for ( int i=0; i < mPoints.size(); i++ )
    mDnlQueue.append( DnlElement( i, true, true ) );

  processQueue( true );
}
示例#27
0
//*************************************************************************************************
// Update function for the manager
//*************************************************************************************************
void PhysicsManager::update()
{
	// Broad phase collision culling, update AABBs and compute overlapping pairs
	queryForCollisionPairs();
	processQueue();

	// Remove overlapping pairs using BV test

	// Compute contact points, resolve interpenetrations

	// Resolve constraints

	// Solve equations of motion
}
示例#28
0
文件: report.c 项目: plundblad/brltty
void
report (ReportIdentifier identifier, const void *data) {
  ReportEntry *report = getReportEntry(identifier, 0);

  if (report) {
    if (report->listeners) {
      ReportListenerParameters parameters = {
        .reportIdentifier = identifier,
        .reportData = data,
        .listenerData = NULL
      };

      processQueue(report->listeners, tellListener, &parameters);
    }
  }
示例#29
0
文件: upload.cpp 项目: snowy97/marble
void Upload::processQueue()
{
    if (m_queue.isEmpty()) {
        return;
    }

    Package const package = m_queue.takeFirst();

    if (upload(package)) {
        QString const message = QString("File %1 (%2) successfully created and uploaded").arg(package.file.fileName()).arg(Region::fileSize(package.file));
        Logger::instance().setStatus(package.region.id(), package.region.name(), "finished", message);
    }
    deleteFile(package.file);
    processQueue();
}
void LastFmImageFetcher::gotImage(QNetworkReply* reply)
{
    const QPair<QString,QString> thisDownload = m_currentImageDownloads.take(reply);
    const QString type = thisDownload.first;
    const QString namePrefix = type + ':';
    const QString name = thisDownload.second;
    const QByteArray data = reply->readAll();

    QImage image = QImage::fromData(data);
    // qDebug() << "Adding image " << image.size() << " for " << name;
    SingletonFactory::instanceFor<PmcImageCache>()->addImage(QString(name).prepend(namePrefix), image);

    m_busy = false;
    QTimer::singleShot(0, this, SLOT(processQueue()));
    emit SingletonFactory::instanceFor<MediaLibrary>()->imageFetched(m_identifiers.take(name), name);
}