Пример #1
0
WebTabPanel::WebTabPanel(BirdBox *t,ImageCache *c,QWidget *parent) : TabPanel(parent),statusUser(0) {
	type=1;
	tweets=t;
	cache=c;
	layout=new QVBoxLayout();
	widget()->setLayout(layout);
	state=0;
	web=new QWebView(this);
	QObject::connect(web,SIGNAL(loadFinished(bool)),this,SLOT(handleLoadFinished(bool)));
	QObject::connect(web,SIGNAL(loadStarted()),this,SLOT(handleLoadStarted()));
	QObject::connect(web,SIGNAL(urlChanged(const QUrl&)),this,SLOT(handleUrlChanged(const QUrl&)));
	QObject::connect(web,SIGNAL(linkClicked(const QUrl&)),this,SLOT(handleLinkClicked(const QUrl&)));
	QObject::connect(this,SIGNAL(followUserByScreenName(QString)),t,SIGNAL(followUserByScreenName(QString)));
	QObject::connect(t,SIGNAL(haveUpdatedUser(TweetUser*)),this,SLOT(handleUpdatedUser(TweetUser*)));
	QObject::connect(c,SIGNAL(update(QString)),this,SLOT(updateImage(QString)));
	QObject::connect(&timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
	statusArea = new QWidget(this);
	statusArea->setLayout(new QHBoxLayout());
	statusIcon = new QLabel(this);
	statusIcon->setMaximumSize(32,32);
	statusIcon->setScaledContents(true);
	message = new QLabel(this);
	message->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
	statusArea->layout()->setAlignment(Qt::AlignLeft);
	statusArea->layout()->addWidget(statusIcon);
	statusArea->layout()->addWidget(message);
	statusArea->layout()->setMargin(0);
	statusArea->layout()->setSpacing(1);
	infoArea = new QWidget(this);
	loadingText = new QLabel(this);
	loadingText->setText("Please wait, connecting to twitter...");
	progress = new QProgressBar(this);
	progress->setRange(0,0);
	progress->setMaximumHeight(15);
	progress->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
	loadingText->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Maximum);
	infoArea->setLayout(new QHBoxLayout());
	infoArea->layout()->addWidget(loadingText);
	infoArea->layout()->addWidget(progress);
	infoArea->layout()->setMargin(0);
	infoArea->layout()->setSpacing(1);
	layout->setAlignment(Qt::AlignTop);
	layout->addWidget(statusArea);
	layout->addWidget(infoArea);
	layout->addWidget(web);
	//web->hide();
	web->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled,false);
	web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
	web->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

	setWidgetResizable(true);
	resetPage();
	handleTimeout();
}
Пример #2
0
void SshConnectionPrivate::connectToHost()
{
    QSSH_ASSERT_AND_RETURN(m_state == SocketUnconnected);

    m_incomingData.clear();
    m_incomingPacket.reset();
    m_sendFacility.reset();
    m_error = SshNoError;
    m_ignoreNextPacket = false;
    m_errorString.clear();
    m_serverId.clear();
    m_serverHasSentDataBeforeId = false;

    try {
        if (m_connParams.authenticationType == SshConnectionParameters::AuthenticationTypePublicKey)
            createPrivateKey();
    } catch (const SshClientException &ex) {
        m_error = ex.error;
        m_errorString = ex.errorString;
        emit error(m_error);
        return;
    }

    connect(m_socket, SIGNAL(connected()), this, SLOT(handleSocketConnected()));
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(handleIncomingData()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
        SLOT(handleSocketError()));
    connect(m_socket, SIGNAL(disconnected()), this,
        SLOT(handleSocketDisconnected()));
    connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
    m_state = SocketConnecting;
    m_keyExchangeState = NoKeyExchange;
    m_timeoutTimer.start();
    m_socket->connectToHost(m_connParams.host, m_connParams.port);
}
void
PipelineInterests::handleNack(const Interest& interest, const lp::Nack& nack)
{
  if (m_options.isVerbose)
    std::cerr << "Received Nack with reason " << nack.getReason()
              << " for Interest " << interest << std::endl;

  switch (nack.getReason()) {
  case lp::NackReason::DUPLICATE: {
    break; // ignore duplicates
  }
  case lp::NackReason::CONGESTION: { // treated the same as timeout for now
    uint64_t segno = interest.getName()[-1].toSegment();
    m_segmentInfoMap[segno]->state = inRetxQueue; // update state
    handleTimeout(1);
    break;
  }
  default: {
    m_hasError = true;
    fail("Could not retrieve data for " + interest.getName().toUri() +
         ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
    break;
  }
  }
}
void
PipelineInterests::checkRto()
{
  uint64_t timeout_count = 0;
  bool timeout_found = false;

  for (auto it = m_segmentInfoMap.begin(); it != m_segmentInfoMap.end(); ++it) {
    shared_ptr<SegmentInfo> seg_info = it->second;
    if (seg_info->state != inRetxQueue && // donot check segments currently in the retx queue
        seg_info->state != retransmitReceived) { // or already-received retransmitted segments
      duration_in_ms time_elapsed = time::steady_clock::now() - seg_info->timeSent;
      if (time_elapsed.count() > seg_info->rto) { // timer expired?
        uint64_t timedout_seg = it->first;
        m_retxQueue.push(timedout_seg); // put on retx queue
        seg_info->state = inRetxQueue; // update status
        timeout_found = true;
        timeout_count++;
      }
    }
  }

  if (timeout_found) {
    handleTimeout(timeout_count);
  }

  // schedule the next event after predefined interval
  m_scheduler.scheduleEvent(time::milliseconds(m_options.rtoCheckInterval),
                            bind(&PipelineInterests::checkRto, this));
}
Пример #5
0
void BaseConnection::onConnectTimeout()
{
    std::ostringstream os;
    os << "Connect to " << _host << ':' << _port << " timed out";
    handleTimeout(os.str());
    hardDisconnect(true);
}
void
PipelineInterests::handleLifeTimeExpiration(const Interest& interest)
{
  uint64_t segno = interest.getName()[-1].toSegment();
  m_retxQueue.push(segno); // put on retx queue
  m_segmentInfoMap[segno]->state = inRetxQueue; // update state
  handleTimeout(1);
}
Пример #7
0
MyTimer::MyTimer(
	  void* aUserdata,
	  ut_TimerCallback* aCb
	  ) : userdata(aUserdata), cb(aCb) 
{
  setSingleShot(true);
  connect(this, SIGNAL(timeout()), 
	  this, SLOT(handleTimeout()));
}
Пример #8
0
void CanvasTimer::createTimer(QObject *parent, const QScriptValue &val, long timeout, bool singleshot)
{

    CanvasTimer *timer = new CanvasTimer(parent, val);
    timer->setInterval(timeout);
    timer->setSingleShot(singleshot);
    connect(timer, SIGNAL(timeout()), timer, SLOT(handleTimeout()));
    activeTimers()->append(timer);
    timer->start();
}
Android::Internal::AndroidSignalOperation::AndroidSignalOperation()
    : m_adbPath(AndroidConfigurations::currentConfig().adbToolPath().toString())
    , m_adbProcess(new QProcess(this))
    , m_timeout(new QTimer(this))
    , m_state(Idle)
    , m_pid(0)
    , m_signal(0)
{
    m_timeout->setInterval(5000);
    connect(m_timeout, SIGNAL(timeout()), this, SLOT(handleTimeout()));
}
Пример #10
0
MiniHttpServerConnection::MiniHttpServerConnection(QTcpSocket *socket)
    : QObject(socket), socket(socket), source(0)
{
    connect(socket, SIGNAL(readyRead()), SLOT(handleReadyRead()));
    connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(handleBytesWritten()));
    connect(socket, SIGNAL(disconnected()), SLOT(handleDisconnected()));

    timeout.setInterval(30000);
    timeout.setSingleShot(true);
    connect(&timeout, SIGNAL(timeout()), SLOT(handleTimeout()));
    timeout.start();
}
QT_USE_NAMESPACE

SerialPortWriter::SerialPortWriter(QSerialPort *serialPort, QObject *parent)
    : QObject(parent)
    , m_serialPort(serialPort)
    , m_standardOutput(stdout)
    , m_bytesWritten(0)
{
    m_timer.setSingleShot(true);
    connect(m_serialPort, SIGNAL(bytesWritten(qint64)), SLOT(handleBytesWritten(qint64)));
    connect(m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), SLOT(handleError(QSerialPort::SerialPortError)));
    connect(&m_timer, SIGNAL(timeout()), SLOT(handleTimeout()));
}
Пример #12
0
QT_USE_NAMESPACE

SerialPortReader::SerialPortReader(QSerialPort *serialPort, QObject *parent)
    : QObject(parent)
    , m_serialPort(serialPort)
    , m_standardOutput(stdout)
{
    connect(m_serialPort, SIGNAL(readyRead()), SLOT(handleReadyRead()));
    connect(m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), SLOT(handleError(QSerialPort::SerialPortError)));
    connect(&m_timer, SIGNAL(timeout()), SLOT(handleTimeout()));

    m_timer.start(5000);
}
Пример #13
0
QT_USE_NAMESPACE

SerialPortReader::SerialPortReader(QSerialPort *serialPort, QApplication *app, QQmlApplicationEngine *engine, QObject *parent)
    : QObject(parent)
    , m_serialPort(serialPort)
    , m_app(app),
      m_engine(engine)
{
    connect(m_serialPort, SIGNAL(readyRead()), SLOT(handleReadyRead()));
    connect(m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), SLOT(handleError(QSerialPort::SerialPortError)));
    connect(&m_timer, SIGNAL(timeout()), SLOT(handleTimeout()));

    m_timer.start(5000);
}
Пример #14
0
CSerialPortReader::CSerialPortReader(const CSerialPortConfig& config)
    : mSerial(this) //TODO: test it
    , mConfig(config)
    , mAlertConfig("serial_port", mConfig.mAlertCoef)
{
    mSerial.setPortName(config.mSerialPort);
    mSerial.setBaudRate(config.mBaudRate);
    const int TIMER_DEFAULT_INTERVAL = 5000;
    mTimer.setInterval(TIMER_DEFAULT_INTERVAL);
    openSerial();

    connect(&mTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
    mTimer.start();
}
Пример #15
0
DataGatherDialog::DataGatherDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DataGatherDialog),
    patient(NULL),
    clipRect(145,68,600,470)
{
    ui->setupUi(this);
    ui->screenshotListview->setModel(&model);
    connect(this, SIGNAL(idScanned(QString)), SLOT(handleIdScanned(QString)));
    setFocus();
    timer.setInterval(30);
    timer.start();
    connect(&timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
}
Пример #16
0
SshConnectionPrivate::SshConnectionPrivate(SshConnection *conn,
    const SshConnectionParameters &serverInfo)
    : m_socket(new QTcpSocket(this)), m_state(SocketUnconnected),
      m_sendFacility(m_socket),
      m_channelManager(new SshChannelManager(m_sendFacility, this)),
      m_connParams(serverInfo), m_error(SshNoError), m_ignoreNextPacket(false),
      m_conn(conn)
{
    setupPacketHandlers();
    m_socket->setProxy((m_connParams.options & SshIgnoreDefaultProxy)
            ? QNetworkProxy::NoProxy : QNetworkProxy::DefaultProxy);
    m_timeoutTimer.setSingleShot(true);
    m_timeoutTimer.setInterval(m_connParams.timeout * 1000);
    m_keepAliveTimer.setSingleShot(true);
    m_keepAliveTimer.setInterval(10000);
    connect(m_channelManager, SIGNAL(timeout()), this, SLOT(handleTimeout()));
}
Пример #17
0
bool ZDvidBufferReader::isReadable(const QString &url)
{
  QTimer::singleShot(5000, this, SLOT(handleTimeout()));

  startReading();

  qDebug() << url;

  m_networkReply = m_networkManager->get(QNetworkRequest(url));

  //return m_networkReply->error() == QNetworkReply::NoError;
  connect(m_networkReply, SIGNAL(readyRead()), this, SLOT(finishReading()));
  connect(m_networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
          this, SLOT(handleError(QNetworkReply::NetworkError)));

  waitForReading();

  return m_status == READ_OK;
}
Пример #18
0
QT_USE_NAMESPACE

CREAD_SERIAL_PORT::CREAD_SERIAL_PORT(const QString &port, const QString &baud, const QString &data, const QString &parity, const QString &stop, const QString &flow,  QObject *parent)
    : QObject(parent)
{
    serial = new QSerialPort();

    connect(serial, SIGNAL(readyRead()), this, SLOT(readData()));
    connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
    m_timer.start(5000);

    currentSettings.name = port;
    currentSettings.baudRate = static_cast<QSerialPort::BaudRate>(baud.toInt());
    currentSettings.dataBits = static_cast<QSerialPort::DataBits>(data.toInt());
    currentSettings.parity = static_cast<QSerialPort::Parity>(parity.toInt());
    currentSettings.stopBits = static_cast<QSerialPort::StopBits>(stop.toInt());
    currentSettings.flowControl = static_cast<QSerialPort::FlowControl>(flow.toInt());

    connectPort();
}
Пример #19
0
void newConnThread::run()
{
    //this is where the thread actually starts.
    socket = new QTcpSocket;
    if(!socket->setSocketDescriptor(this->socketDescriptor))
    {
        exit(1);
    }
    //cool. we've got a connection.
    //setup timer
    timer = new QTimer;
    timer->start(500);

    //time to connect some signals and slots.
    connect(socket,SIGNAL(readyRead()),this,SLOT(handleReadyRead()));
    connect(socket,SIGNAL(disconnected()),this,SLOT(handleDisconnected()));
    connect(timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
    connect(this,SIGNAL(timeSig()),this,SLOT(handleWrite()));
    //make the thread run even when this run function goes out of scope.
    exec();
}
Пример #20
0
void WebTabPanel::handleLoadFinished(bool) {
	QWebFrame *frame = web->page()->mainFrame();
	QString url=frame->url().toString();
	//QMessageBox::information (0,"assdf",tr("Handle load finished, state: ")+QString::number(state)+tr(", url: ")+frame->url().toString());
	infoArea->hide();
	progress->hide();
	loadingText->hide();
	if (url=="http://twitter.com/login") {
		if (!tweets->getAuthenticatingFetcher()) {
			state=-1;
			return;
		}
		QString user = tweets->getAuthenticatingFetcher()->getUsername();
		QString pass = tweets->getAuthenticatingFetcher()->getPassword();

		// Homepage login
		//frame->evaluateJavaScript(tr("var f=document.getElementById('signin');document.getElementById('username').value=\"")+user+tr("\";document.getElementById('password').value=\"")+pass+tr("\";f.submit();"));
		// redirect page login
		loadingText->setText("Please wait, signing in to twitter...");
		frame->evaluateJavaScript(tr("var f=document.forms[1];f['username_or_email'].value=\"")+user+tr("\";f['session[password]'].value=\"")+pass+tr("\";f.submit();"));
		state=1;//loggin in

	} else if (url=="http://twitter.com/invitations/find_on_twitter") {
		// Now at being passed to twitter state
		state=2;//Searching
		web->show();
		frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
		frame->setScrollPosition(QPoint(0,0));
		//QTimer::singleShot(1000,this,SLOT(resetScroll()));
		web->setEnabled(true);
		handleTimeout();
	} else if (url.startsWith(tr("http://twitter.com/"))) {
		state=3;//Search results or user info.
		frame->evaluateJavaScript(tr("function $(s){return document.getElementById(s);}function __yasstlinks() {var i=['home_link','profile_link','settings_link','help_link','sign_out_link'];for (var b in i) {b=$(i[b]);b.style.display='none';}i=$('footer').firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;while(i.nextSibling){i.parentNode.removeChild(i.nextSibling);}}__yasstlinks();"));
		frame->evaluateJavaScript(tr("function __yasst() {i=$('timeline');i.innerHTML='<style>.follow-actions input{display:none;} a.__yasst-followsingle {text-decoration:none; visibility:visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: inline-block; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: 23px; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 48px; word-spacing: 0px;} a:hover.__yasst-follow,a:hover.__yasst-followsingle{background-color: rgb(204, 204, 204);} a.__yasst-follow{visibility: visible !important; -webkit-appearance: none; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-box-align: center; -webkit-box-sizing: border-box; -webkit-rtl-ordering: logical; -webkit-user-select: text; background-color: rgb(230, 230, 230); border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; color: black; cursor: pointer; display: none; font-family: \\'Lucida Grande\\'; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; height: auto; letter-spacing: normal; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; padding-top: 4px; text-align: center; text-indent: 0px; text-shadow: none; text-transform: none; vertical-align: top; white-space: pre; width: 80px; word-spacing: 0px;}</style>'+$('timeline').innerHTML;var e=document.getElementById('follow_control');if (e!=null) {var u=e.parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+1);var l=document.createElement('div');l.innerHTML='<a class=\\\"__yasst-followsingle\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';e.parentNode.parentNode.insertBefore(l,e.parentNode);} else {		e=i.getElementsByClassName('follow-actions');for(b=0;b<e.length;b++) {var u=e[b].parentNode.parentNode.className;u=u.substr(u.lastIndexOf(' ')+6);var l=document.createElement('div');var c=e[b].childNodes;for(var x=0;x<c.length;x++) {if (c[x].nodeName=='FORM') {var d=c[x].action.substr(c[x].action.lastIndexOf('/')+1);var f=c[x].firstChild.childNodes;l.innerHTML='<a class=\\\"__yasst-follow\\\" href=\\\"twitter:/follow/'+u+'\\\">Follow</a>';for(var y=0;y<f.length;y++) {if(f[y].nodeName=='INPUT'&&f[y].type=='submit') {f[y].parentNode.insertBefore(l,f[y]);}}}}}}}__yasst();"));
		web->setEnabled(true);
		//frame->setScrollPosition(QPoint(0,0));
		//QTimer::singleShot(1000,this,SLOT(resetScroll()));
	}
}
Пример #21
0
int32_t SearcherWorker::run() {
    const char *pureString = NULL;
    uint32_t pureSize = 0;
    char *resData = NULL;
    uint32_t resSize = 0;
    char *resDetailData = NULL;
    int32_t resDetailSize = 0;
    int32_t ret = 0;
    MemPool *memPool = NULL;
    int64_t *pNid = NULL;
    commdef::ClusterResult *pClusterResult = NULL;
    queryparser::QueryRewriterResult *pQRWResult = NULL;
    queryparser::QPResult *pQueryResult = NULL;
    SearchResult *pSearchResult = NULL;
    statistic::StatisticResult *pStatisticResult = NULL;
    sort_framework::SortResult *pSortResult = NULL;
    ResultSerializer resultSerial;
    FRAMEWORK::Context context;
    FILE *pOutput = NULL;
    //check session status
    FRAMEWORK::session_status_t status = _session.getStatus();
    if (status == FRAMEWORK::ss_timeout) {
        handleTimeout();
        return KS_SUCCESS;
    }
    //get query infomation
    FRAMEWORK::Query &query = _session.getQuery();
    pureSize = query.getPureQuerySize();
    pureString = query.getPureQueryData();
    if (!pureString || pureSize == 0) {
        _session.setStatus(FRAMEWORK::ss_error);
        _session.response();
        return KS_EFAILED;
    }
    //set LogInfo level
    _session._logInfo._eRole = FRAMEWORK::sr_simple;
    //get MemPool from factory
    memPool = _memFactory.make((uint64_t)(getOwner()));
    if (memPool == NULL) {
        TWARN("Make mem pool failed!");
        return KS_EFAILED;
    }
    //create memory pool monitor
    MemMonitor memMonitor(memPool, _memLimit);
    memPool->setMonitor(&memMonitor);
    memMonitor.enableException();
    //initialize context class
    context.setMemPool(memPool);
	//initialize format processor
    _formatProcessor.init(memPool);
    //Deal with search proccess
    do{  
        if(_session.isHttp()){
            pQRWResult = NEW(memPool, queryparser::QueryRewriterResult)();
            if (pQRWResult == NULL) {
                TWARN("SEARCHER: new Result no mem");
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
        }
        pQueryResult = NEW(memPool, queryparser::QPResult)(memPool);
        pSearchResult = NEW(memPool, SearchResult);
        pStatisticResult = NEW(memPool, statistic::StatisticResult); 
        pSortResult = NEW(memPool, sort_framework::SortResult)(memPool);
        if(unlikely(!pQueryResult || !pSearchResult || !pStatisticResult
                    || !pSortResult)) {
            TWARN("SEARCHER: new Result no mem");
            _session.setStatus(FRAMEWORK::ss_error);
            break;
        }
        //add queryrewrite process
        if(_session.isHttp()){     
            ret = _qrewriter.doRewrite(&context, pureString, pureSize, pQRWResult);
            if (timeoutCheck && (_timeout > 0) && (_session.getLatencyTime() > _timeout)) {
                _session.setStatus(FRAMEWORK::ss_timeout);
                TWARN("SEARCHER: qrewriter.doRewrite function over time. query is %s", pureString);
                break;
            }
            if (unlikely(ret != KS_SUCCESS)) {
                _session.setStatus(FRAMEWORK::ss_error);
                TWARN("qrewriter.doRewrite function error. query is %s", pureString);                
                break;
            }
            pureString = pQRWResult->getRewriteQuery();
        }
        //end add
        ret = _qp.doParse(&context, pQueryResult, pureString);
        if (timeoutCheck && (_timeout > 0) && 
                (_session.getLatencyTime() > _timeout)) 
        {
            _session.setStatus(FRAMEWORK::ss_timeout);
            TWARN("SEARCHER: qp.doParse function over time. query is %s", pureString);
            break;
        }
        if (unlikely(ret != KS_SUCCESS)){
            TWARN("SEARCHER: queryparser doParse function error. query is %s", pureString);
            _session.setStatus(FRAMEWORK::ss_error);
            break;
        }

        // cache命中情况下, mempool reset时调用CacheResult析构函数,释放命中的节点,
        // 否则sortResult对节点内存的引用失效,变为野指针(bug#118631)
        {
            ret = _is.doQuery(&context, pQueryResult, &_sort, pSearchResult);
            if (timeoutCheck && (_timeout > 0) &&
                    (_session.getLatencyTime() > _timeout)) 
            {
                _session.setStatus(FRAMEWORK::ss_timeout);
                TWARN("SEARCHER: is.doQuery function over time. query is %s", pureString);
                break;
            }
            if (unlikely(ret != KS_SUCCESS)){
                TWARN("SEARCHER: search doQuery function error. query is %s", pureString);
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
            ret = _stat.doStatisticOnSearcher(&context, 
                    *(pQueryResult->getParam()),
                    pSearchResult, pStatisticResult);
            if (timeoutCheck && (_timeout > 0) &&
                    (_session.getLatencyTime() > _timeout)) 
            {
                _session.setStatus(FRAMEWORK::ss_timeout);
                TWARN("SEARCHER: doStatisticOnSearcher function over time. query is %s", pureString);
                break;
            }
            if (unlikely(ret != KS_SUCCESS)){
                TWARN("SEARCHER: statistic doStatisticOnSearcher function error. query is %s", pureString);
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
            ret = _sort.doProcess(context, *(pQueryResult->getParam()), 
                    *pSearchResult, *pSortResult);
            if (timeoutCheck && (_timeout > 0) &&
                    (_session.getLatencyTime() > _timeout))
            {
                _session.setStatus(FRAMEWORK::ss_timeout);
                TWARN("SEARCHER: sort.doProcess function over time. query is %s", pureString);
                break;
            }
            if (unlikely(ret)) {
                TWARN("SEARCHER: sort doProcess function error. query is %s", pureString);
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
        }


        pNid = NULL;
        //get docs return number
        int32_t num = pSortResult->getNidList(pNid);
        pClusterResult = NEW(memPool, commdef::ClusterResult)();

        if ( NULL == pClusterResult ){
            TWARN("SEARCHER: malloc from memPool failed ");
            _session.setStatus(FRAMEWORK::ss_error);
            break;            
        }

        memset(pClusterResult, 0x0, sizeof(commdef::ClusterResult));
        pClusterResult->_nDocsFound = pSortResult->getDocsFound();//pSearchResult->nDocFound;
        pClusterResult->_nEstimateDocsFound = pSortResult->getEstimateDocsFound();//pSearchResult->nEstimateDocFound;
        pClusterResult->_nDocsSearch = pSearchResult->nDocSearch;
        pClusterResult->_nDocsReturn = num;
        pClusterResult->_nDocsRestrict = pSearchResult->nEstimateDocFound;//pSearchResult->nDocFound;
        pClusterResult->_pStatisticResult = pStatisticResult;
        pClusterResult->_pSortResult = pSortResult;
        pClusterResult->_pQPResult = pQueryResult;
        pClusterResult->_ppDocuments = NULL;

        if(_session.isHttp() && _detail){

            if(!pClusterResult->_nDocsReturn){
                break;
            }  
            char* pid = NULL;
            uint32_t pid_size = 0;
            ret = get_nid_str(pNid, num, memPool, &pid, &pid_size);
            if(KS_SUCCESS != ret){
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }            
            ret = getDetailInfo(pid, pid_size, pureString, &resDetailData, &resDetailSize);
            if(KS_SUCCESS != ret){
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
            if(timeoutCheck && _timeout>0 && _session.getLatencyTime()>_timeout){
        		_session.setStatus(FRAMEWORK::ss_timeout); 
                break;
        	} 

            if (!translateV3(resDetailData, pClusterResult->_ppDocuments, (uint32_t &)pClusterResult->_nDocsReturn, memPool)) {
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
        }
    } while (0);

    if(resDetailData)std::free(resDetailData);

    if(_session.isHttp() && _detail){
        //fromat result
        get_outfmt_type(pureString, pureSize);
        result_container_t container;
        container.pClusterResult = pClusterResult;
        container.cost = _session.getLatencyTime();
        if(_formatProcessor.frmt(_ofmt_type, container, &resData , &resSize) < 0){
            TERR("FORMATRESULT: format_processor process error!"); 
            _session.setStatus(FRAMEWORK::ss_error);
        }
    }
    else{     
        //serialize search result
        ret = resultSerial.serialClusterResult(pClusterResult,
                resData, resSize, "Z");
        if (ret != KS_SUCCESS) {
            _session.setStatus(FRAMEWORK::ss_error);
        }
    }
    //recycle mem pool
    context.getMemPool()->reset();
    _session.setResponseData(resData, resSize);
    _session.response();
    return KS_SUCCESS;
}
Пример #22
0
void BaseConnection::onNegotiateTimeout()
{
    handleTimeout("Atlas negotiation timed out");
    hardDisconnect(true);
}
Пример #23
0
void Connection::onDisconnectTimeout()
{
    handleTimeout("timed out waiting for disconnection");
    hardDisconnect(true);
}
Пример #24
0
/* Takes the inital event.
 * If we were configured, recalculate the opacify-windows if
 * it was our window.
 * If a window was entered: call upon handle_timeout after od->timeout
 * micro seconds, or directly if od->timeout is 0 (no delay).
 *
 */
static void
opacifyHandleEvent (XEvent      *event)
{
	CompScreen *s;

	OPACIFY_DISPLAY (&display);

	UNWRAP (od, &display, handleEvent);
	(display.handleEvent) (event);
	WRAP (od, &display, handleEvent, opacifyHandleEvent);

	switch (event->type) {
	case EnterNotify:
		if (!od->toggle)
			return;

		s = findScreenAtDisplay (event->xcrossing.root);

		if (s)
		{
			Window id;

			OPACIFY_SCREEN (s);

			id = event->xcrossing.window;
			os->newActive = findTopLevelWindowAtScreen (s, id);

			if (od->timeoutHandle)
				compRemoveTimeout (od->timeoutHandle);

			const BananaValue *
			option_timeout = bananaGetOption (bananaIndex,
			                                  "timeout",
			                                  -1);

			if (checkDelay (s))
				handleTimeout (s);
			else
				od->timeoutHandle = compAddTimeout (option_timeout->i,
				                                    (float)
				                                    option_timeout->i * 1.2,
				                                    handleTimeout, s);
		}
		break;
	case ConfigureNotify:
		if (!od->toggle)
			return;

		s = findScreenAtDisplay (event->xconfigure.event);
		if (s)
		{
			OPACIFY_SCREEN (s);

			if (os->active != event->xconfigure.window)
				break;

			clearPassive (s);
			if (os->active)
			{
				CompWindow *w;

				w = findWindowAtScreen (s, os->active);
				if (w)
					passiveWindows (s, w->region);
			}
		}
	case KeyPress:
		if (isKeyPressEvent (event, &od->toggle_key))
			opacifyToggle ();

		break;
	default:
		break;
	}
}
Пример #25
0
QTPcapReplay::QTPcapReplay(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	/* Connects  */
	m_jobReplay = new JobReplay;
	m_jobReplay->SetPcapReplay(this);
	m_jobReplay->SetUI(&ui);

	//BUTTONACT(ui.removeFileButton, removeFile());
	connect(ui.removeFileButton, SIGNAL(pressed()), this, SLOT(removeFile()));
	connect(ui.exitAppButton, SIGNAL(pressed()), this, SLOT(onFileExit()));
	connect(ui.actionFiles, SIGNAL(triggered()), this, SLOT(onFileOpen()));
	connect(ui.actionFrom_Folder, SIGNAL(triggered()), this, SLOT(onFolderOpen()));
	connect(ui.actionClose, SIGNAL(triggered()), this, SLOT(onFileExit()));
	connect(ui.actionNew_Window, SIGNAL(triggered()), this, SLOT(onNewWindow()));
	connect(ui.actionNew_Window_Dynamic, SIGNAL(triggered()), this, SLOT(onNewWindowDynamic()));
	connect(ui.actionScheduler, SIGNAL(triggered()), this, SLOT(onSchedulerDynamic()));
	connect(ui.startReplayButton, SIGNAL(pressed()), m_jobReplay, SLOT(StartReplay()));
	connect(ui.pauseReplayButton, SIGNAL(pressed()), this, SLOT(onPause()));
	connect(ui.stopReplayButton, SIGNAL(pressed()), this, SLOT(StopPlaying()));
	connect(m_jobReplay, SIGNAL(updateProgress(const int&)), this, SLOT(getProgress(int)));
	connect(m_jobReplay, SIGNAL(updateNextPacketNumber(const QString&)), this, SLOT(getNextPacketNumber(QString)));
	connect(m_jobReplay, SIGNAL(updateCurrentPlayingFile(const QString&)), this, SLOT(getCurStatus(QString)));
	connect(m_jobReplay, SIGNAL(updatePlayingStatus(const bool&)), this, SLOT(updatePlayingStatus(bool)));
	connect(&(m_SchedulerTimer.m_timer), SIGNAL(timeout()), this, SLOT(handleTimeout()));
	connect(&(m_NetSpeedMeasure), SIGNAL(UpdateNetSpeed(double)), this, SLOT(updateNetSpeedMeasure(double)));
	connect(&(m_PacketTimeReportor), SIGNAL(UpdateTimeReport(QString)), this, SLOT(PrintTimeReport(QString)));
	connect(m_jobReplay, SIGNAL(sendMessageBox(const QString&)), this, SLOT(showMessageBox(const QString&)));
	connect(ui.regularReplayButton, SIGNAL(pressed()), m_jobReplay, SLOT(startRegularReplay()));
	connect(m_jobReplay, SIGNAL(updateRegularReplayingStatus(const bool&)), this, SLOT(updateRegularReplayingStatus(bool)));
	connect(m_jobReplay, SIGNAL(sendUpdateRegularButtonText(const QString&)), this, SLOT(updateRegularButtonText(const QString&)));
	connect(ui.actionSave_Config, SIGNAL(triggered()), this, SLOT(save_config_setting()));
	connect(ui.actionLoad_Config, SIGNAL(triggered()), this, SLOT(load_config_setting()));

	ui.progressBar->setValue(0);

	if (InitAdapterName() == 1)
		exit(0);

	m_playerTimer = new PlayerTimer;
	m_threadPool = new threadPool(2);
	m_threadPool->submit(m_playerTimer);

	// Modify display
	ui.curPcapPackage->setText(QString(""));
	ui.StatusReportLabel->setText(QString(""));
	ui.schedulerStatus->setText(QString("Scheduler Stop"));
	ui.schedulerStatus->setStyleSheet("QLabel { background-color : red; color : black; }");
	ui.pauseReplayButton->setDisabled(true);
	ui.stopReplayButton->setDisabled(true);
	ui.offSet_lineEdit->setText("0");
	ui.speed_LineEdit->setText("1");
	ui.netSpeedMon->setText("");
	ui.packetTimeLabel->setText("");

	// Status
	m_bPlaying = false;
	m_bBeforePlay = true;

	
	m_openFilePath = QDir::currentPath();

	// net speed measurement

	// icon
	//m_icon.addFile("C:\NGN2\NGN2011\App\QTPcapReplay\QTPcapReplay\test.bmp");
	//this->setWindowIcon(m_icon);
}