コード例 #1
0
ファイル: kremotemodel.cpp プロジェクト: tonton1728/Karte
void KRemoteModel::setState(ModelState st) {
	Kwery *kw;

	st_ = st;

	switch(st_) {
	case Getting:
		kw = new KweryModelGet(modelName_);
		connect(((KweryModelGet*)kw), SIGNAL(gotModel(int)), this, SLOT(gotModelId(int)));
		k_->sendKwery(kw);
		break;
	case Headers:
		kw = new KweryModelHeaders(mid_);
		connect(((KweryModelHeaders*)kw), SIGNAL(gotHeaders(QVariantList)), this, SLOT(gotHeaders(QVariantList)));
		k_->sendKwery(kw);
		break;
	case Fetching:
		kw = new KweryModelData(mid_);
		connect(((KweryModelData*)kw), SIGNAL(gotData(QVariantList)), this, SLOT(gotData(QVariantList)));
		k_->sendKwery(kw);
		break;
	case Complete:
		qDebug() << "Model" << modelName_ << "complete";
		qDebug() << hdrs_;
		qDebug() << data_;
	default:
		break;
	}

	emit stateChanged(st);
}
コード例 #2
0
CDReader::CDReader( CDInfo *info, CDEdit *edit, QWidget *parent )
: QWidget( parent )
, mpCDReaderThread( new CDReaderThread() )
, mpCDInfo( info )
, mpCDEdit( edit )
, mpProgressBar( new QProgressBar( this ) )
, mpRippingSpeed( new QLabel( this ) )
, mEncoders()
, mDevice()
{
   mpProgressBar->setRange( 0, 100 );
   mpProgressBar->setAlignment( Qt::AlignCenter );

   QGridLayout *mainLayout = new QGridLayout( this );
   mainLayout->setContentsMargins( 0, 0, 0, 0 );

   mainLayout->addWidget( mpRippingSpeed, 1, 0 );
   mainLayout->addWidget( mpProgressBar, 0, 0 );

   connect( mpCDReaderThread, SIGNAL(stateNoDisc()),
            this, SIGNAL(stateNoDisc()) );
   connect( mpCDReaderThread, SIGNAL(stateDisc()),
            this, SIGNAL(stateDisc()) );
   connect( mpCDReaderThread, SIGNAL(stateScan()),
            this, SIGNAL(stateScan()) );
   connect( mpCDReaderThread, SIGNAL(stateRip()),
            this, SIGNAL(stateRip()) );
   connect( mpCDReaderThread, SIGNAL(gotToc()),
            this, SIGNAL(gotToc()) );
   connect( mpCDReaderThread, SIGNAL(gotData()),
            this, SIGNAL(gotData()) );
   connect( mpCDReaderThread, SIGNAL(noEject()),
            this, SLOT(noEject()) );
   connect( mpCDReaderThread, SIGNAL(foundDevices(QStringList)),
            this, SIGNAL(foundDevices(QStringList)) );
   connect( mpCDReaderThread, SIGNAL(message(QString)),
            this, SIGNAL(message(QString)) );
   connect( mpCDReaderThread, SIGNAL(setTrackDisabled(int,bool)),
            this, SIGNAL(setTrackDisabled(int,bool)) );
   connect( mpCDReaderThread, SIGNAL(ensureVisible(int)),
            this, SIGNAL(ensureVisible(int)) );
   connect( mpCDReaderThread, SIGNAL(progress(int,int)),
            this, SLOT(updateProgress(int,int)) );
   connect( mpCDReaderThread, SIGNAL(errors(int,unsigned int,const unsigned long*)),
            this, SIGNAL(errors(int,unsigned int,const unsigned long*)) );

   updateProgress( 0, 0 );
   setLayout( mainLayout );
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: anates/TCP-controller
void MainWindow::on_client_clicked()
{
    ui->label_3->setText("Client selected");
    ui->Server->setDisabled(true);
    if(!ui->ip->text().isEmpty() && !ui->port->text().isEmpty())
        myClient = new Client();
    else
        return;
    myClient->connectToServer(ui->ip->text(), ui->port->text().toInt());
    connect(myClient, SIGNAL(gotData(QVariant)), this, SLOT(dataReceived(QVariant)));
    ui->client->setDisabled(true);

}
コード例 #4
0
ファイル: httpd.c プロジェクト: Carrotman42/cs4534
static
PT_THREAD(handle_emu_in(struct httpd_state *s, RoverAction last)) {
	static int c = 0;
	PSOCK_BEGIN(&s->sin);
	
	f(8, "Input______________ ", &c);
	PSOCK_READTO(&s->sin, 0xFF);
	f(8, "Input ", &c);
	//int len = PSOCK_DATALEN(&s->sin)-1;
	// Report the data we got
	gotData(last, s->inputbuf);
	s->state = STATE_WAITING;
	
	PSOCK_END(&s->sin);
}
コード例 #5
0
ファイル: enigmacache.cpp プロジェクト: GWARDAR/OpenPLi-1
void EnigmaCache::readOneChannelProgramData( bool partOfGlobal, eServiceReferenceDVB ref, time_t from, time_t to, bool includeDescriptionsFlag )
{
        timeMapPtr evmap = cacheP->getTimeMapPtr( ref, from, to );
        if ( !evmap )
		return;

	timeMap::const_iterator ibegin = evmap->lower_bound( from );
	if ((ibegin != evmap->end()) && (ibegin != evmap->begin())) {
		if ( ibegin->first != from )
                	--ibegin;
	}
        else
		ibegin=evmap->begin();

	timeMap::const_iterator iend = evmap->lower_bound( to );

	struct ProgramData p;
	p.channelName = getServiceName( ref );

	eServiceReferenceDVB &rref=(eServiceReferenceDVB&)ref;
        int tsidonid =
              (rref.getTransportStreamID().get()<<16)|rref.getOriginalNetworkID().get();

	for (timeMap::const_iterator event(ibegin); event != iend; ++event) {
		EITEvent *ev = new EITEvent(*event->second,tsidonid, event->second->type);

		// This will be done in receiveData, but doing
		// it also here prevents all the work in between
		if (((ev->start_time+ev->duration)>= from) && (ev-> start_time <= to)) {

			p.name = "";
			p.flags = 0;

			if ( parseProgramData( ev, p, includeDescriptionsFlag, true ) ) {
				p.flags |= programDataFlagFromCache;
				p.startTime = ev->start_time;
				p.duration = ev->duration;
				p.idxFic=-1;
				p.offset=-1;
				if ( partOfGlobal )
					/*emit*/ gotData( p );
				else
					/*emit*/ gotOneChannelData( p );
			}
		}
		delete ev;
	}
}
コード例 #6
0
bool
LastFmParser::parse_xml (const QByteArray &b, int id)
{
	LastFmHandler *x = dynamic_cast<LastFmHandler*> (m_xml.contentHandler ());
	QXmlInputSource s;
	s.setData (b);

	x->reset ();

	m_xml.parse (s);

	if (x->type () == LastFmHandler::SIMILARARTIST) {
		QList<LastFmArtist> l = x->artist_list ();
		m_cache[m_cache_map[id]] = l;
		emit gotData (m_cache_map[id]);
	}
	return true;
}
コード例 #7
0
	void FileTransferManager::handleRequest (int32_t friendNum,
			const QByteArray& pkey, uint8_t filenum, uint64_t size, const QString& name)
	{
		const auto toxThread = ToxThread_.lock ();
		if (!toxThread)
		{
			qWarning () << Q_FUNC_INFO
					<< "Tox thread is not available";
			return;
		}

		const auto entry = Acc_->GetByPubkey (pkey);
		if (!entry)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to find entry for pubkey"
					<< pkey;
			return;
		}

		const auto transfer = new FileTransferIn
		{
			entry->GetEntryID (),
			pkey,
			friendNum,
			filenum,
			static_cast<qint64> (size),
			name,
			toxThread
		};

		connect (this,
				SIGNAL (gotFileControl (qint32, qint8, qint8, QByteArray)),
				transfer,
				SLOT (handleFileControl (qint32, qint8, qint8, QByteArray)));
		connect (this,
				SIGNAL (gotData (qint32, qint8, QByteArray)),
				transfer,
				SLOT (handleData (qint32, qint8, QByteArray)));

		emit fileOffered (transfer);
	}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: hgarbeil/QuikServer
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    int i ;

    ui->setupUi(this);

    startPort = 8890 ;
    nServers = 4 ;
    for (i=0; i<nServers; i++) {

        server[i] = new MyTcpServer (this) ;
        connect(server[i], SIGNAL(newConnection()), server[i], SLOT(acceptConnection()));
        connect (server[i], SIGNAL (gotData(QString)), this, SLOT (addData(QString))) ;

        //connFlag [i] = false ;
    }
    for (i=0; i<nServers; i++)server[i]->listen (QHostAddress::Any, startPort+i) ;

}
コード例 #9
0
void ProjectLangstatsModel::populate(const QVariantMap &data)
{
    int length = data.count();

    beginInsertRows(QModelIndex(), 0, length-1);

    QMapIterator<QString, QVariant> i(data);
    while (i.hasNext())
    {
        i.next();

        QVariantMap map = i.value().toMap();

        LangstatObject *sobj = new LangstatObject(i.key(), map.value("translated").toDouble(), map.value("untranslated").toDouble(), map.value("reviewed").toDouble());

        m_stats.append(sobj);
    }

    endInsertRows();

    emit gotData();
}
コード例 #10
0
ファイル: InboundLedgers.cpp プロジェクト: Empresaria/rippled
    /** We received a TMLedgerData from a peer.
    */
    bool gotLedgerData (LedgerHash const& hash,
            std::shared_ptr<Peer> peer,
            std::shared_ptr<protocol::TMLedgerData> packet_ptr) override
    {
        protocol::TMLedgerData& packet = *packet_ptr;

        JLOG (j_.trace())
            << "Got data (" << packet.nodes ().size ()
            << ") for acquiring ledger: " << hash;

        auto ledger = find (hash);

        if (!ledger)
        {
            JLOG (j_.trace())
                << "Got data for ledger we're no longer acquiring";

            // If it's state node data, stash it because it still might be
            // useful.
            if (packet.type () == protocol::liAS_NODE)
            {
                app_.getJobQueue().addJob(
                    jtLEDGER_DATA, "gotStaleData",
                    [this, packet_ptr] (Job&) { gotStaleData(packet_ptr); });
            }

            return false;
        }

        // Stash the data for later processing and see if we need to dispatch
        if (ledger->gotData(std::weak_ptr<Peer>(peer), packet_ptr))
            app_.getJobQueue().addJob (
                jtLEDGER_DATA, "processLedgerData",
                [this, hash] (Job&) { doLedgerData(hash); });

        return true;
    }
コード例 #11
0
ファイル: test.cpp プロジェクト: andrewchambers/serialtunnel
int testRecoverLost() {
    
    Protocol a;
    Protocol b;
    
    uint64_t t = 0;
    a.listen();
    std::vector<ProtocolPacket> fora = b._connect(t);
    std::vector<ProtocolPacket> forb;
    
    std::vector<ProtocolPacket> out;
    
    std::string arecieved;
    std::string brecieved;
    int asentCount = 0;
    int bsentCount = 0;
    int loopCounter = 0;
    while (loopCounter < 500000) {
        t += 10;
        if (asentCount < 500 && a.readyForData()) {
            out = a._sendData("foo",t);
            forb.insert(forb.end(),out.begin(),out.end());
            asentCount += 1;
        }
           
        if (bsentCount < 1000 && b.readyForData()) {
            out = b._sendData("bar",t);
            fora.insert(fora.end(),out.begin(),out.end());
            bsentCount += 1;
        }
        
        if (loopCounter > 10) { //start dropping packets after _connection is up
            if  (((loopCounter % 8) == 0) && fora.size() ) {
                fora.pop_back();
            }
            
            if (((loopCounter % 7) == 0) && forb.size()){
                forb.pop_back();
            }
        }
        
        // drop some more packets by not accepting data arbitrarily
        for (std::vector<ProtocolPacket>::iterator it = fora.begin() ; it != fora.end() ; it++ ) {
            std::pair<std::vector<ProtocolPacket>,std::vector<uint8_t> > eventResult;
            eventResult = a._packetEvent(*it,t,true);
            out = eventResult.first;
            std::string gotData(eventResult.second.begin(),eventResult.second.end());
            arecieved += gotData;
            forb.insert(forb.end(),out.begin(),out.end());
           
        }
        fora.clear();
        for (std::vector<ProtocolPacket>::iterator it = forb.begin() ; it != forb.end() ; it++ ) {
            std::pair<std::vector<ProtocolPacket>,std::vector<uint8_t> > eventResult;
            eventResult = b._packetEvent(*it,t,true);
            out = eventResult.first;
            std::string gotData(eventResult.second.begin(),eventResult.second.end());
            brecieved += gotData;
            fora.insert(fora.end(),out.begin(),out.end());
        }
        forb.clear();
        
        out = a._timerEvent(t);
        forb.insert(forb.end(),out.begin(),out.end());
        out = b._timerEvent(t);
        fora.insert(fora.end(),out.begin(),out.end());
        
        if (asentCount == 500 && bsentCount == 1000 && !a.outgoingDataPacket && !b.outgoingDataPacket) {
            break;
        }
        
        loopCounter += 1;
    }
    ASSERT(a.state == STATE_CONNECTED);
    ASSERT(b.state == STATE_CONNECTED);
    ASSERT(loopCounter != 500000);
    ASSERT(arecieved.size() == 1000*3);
    for(int i = 0 ; i < 1000; i++){
        ASSERT(arecieved.substr(i*3,3) == std::string("bar"));
    }
    for(int i = 0 ; i < 500; i++){
        ASSERT(brecieved.substr(i*3,3) == std::string("foo"));
    }    
    return 0;
}