bool RedisClient::SshTransporter::openTcpSocket()
{
    auto config = m_connection->getConfig();
    m_socket = m_sshClient->openTcpSocket(config.host(), config.port());

    if (!m_socket) {
        emit errorOccurred("SSH connection established, but socket failed");
        return false;
    }

    SignalWaiter socketWaiter(config.connectionTimeout());
    socketWaiter.addAbortSignal(m_socket, &QxtSshTcpSocket::destroyed);
    socketWaiter.addSuccessSignal(m_socket, &QxtSshTcpSocket::readyRead);

    connect(m_socket, &QxtSshTcpSocket::readyRead, this, &RedisClient::AbstractTransporter::readyRead);
    connect(m_socket, &QxtSshTcpSocket::destroyed, this, &RedisClient::SshTransporter::OnSshSocketDestroyed);

    if (!m_socket->isOpen() && !socketWaiter.wait()) {
        emit errorOccurred(QString("SSH connection established, but redis connection failed"));
        return false;
    }

    emit connected();
    emit logEvent(QString("%1 > reconnected").arg(m_connection->getConfig().name()));

    return true;
}
Exemple #2
0
void OvenManager::sigio_handler(int sig)
{
	QTime timestamp = QTime::currentTime();
	struct oven_state state;
	int ret;
	(void)sig;

	if (_connected) {
		ret = ioctl(_ioctlFd, PCBOVEN_GET_STATE, &state);
		if (ret == 0) {
			emit readingsRead(state, timestamp);
		} else if (ret == -1) {
			if (errno == ENODEV) {
				_connected = false;
				emit disconnected();
			} else {
				emit errorOccurred(errno);
			}
		} else {
			emit errorOccurred(ret);
		}
	} else {
		ret = ioctl(_ioctlFd, PCBOVEN_IS_CONNECTED, &state);
		if (ret < 0) {
			emit errorOccurred(ret);
		} else if (ret) {
			_connected = true;
			emit connected();
		}
	}
}
bool RedisConnection::connect()
{
    init();

    socket->connectToHost(config.host, config.port);

    if (socket->waitForConnected(config.connectionTimeout)) 
    {        
        if (config.useAuth()) {
            execute(QString("AUTH %1").arg(config.auth));
        }

        connected = (execute("PING") == "PONG");

        if (!connected)
            emit errorOccurred("Redis server require password or password invalid");

    } else {
        connected = false;
        emit errorOccurred("Connection timeout");
    }    

    if (connected) {
        emit log(QString("%1 > connected").arg(config.name));
    } else {
        emit log(QString("%1 > connection failed").arg(config.name));
        disconnect();
    } 

    return connected;
}
Exemple #4
0
void OvenManager::start()
{
	_ioctlFd = open("/dev/pcboven", O_RDWR, O_NONBLOCK);
	if (_ioctlFd < 0) {
		emit errorOccurred(errno);
		return;
	}

	register_sigio_receiver(this);

	if (fcntl(_ioctlFd, F_SETOWN, getpid())) {
		emit errorOccurred(errno);
		return;
	}

	if (fcntl(_ioctlFd, F_SETFL, (fcntl(_ioctlFd, F_GETFL) | FASYNC))) {
		emit errorOccurred(errno);
		return;
	}

	int ret = ioctl(_ioctlFd, PCBOVEN_IS_CONNECTED);
	if (ret < 0) {
		emit errorOccurred(ret);
	} else if (ret) {
		_connected = true;
		emit connected();
	}
}
void SearchWorker::startSearch(QString profilename, QString searchTerm)
{
    if (isRunning()) {
        emit errorOccurred(tr("Search already in progress"), "");
        return;
    }
    if (profilename.isEmpty() || searchTerm.isEmpty()) {
        emit errorOccurred(tr("Bad search parameters"), "");
        return;
    }

    m_profile.setName(profilename);

    if (!m_profile.isWhiteList()) {
        emit errorOccurred(tr("Profile configuration error!"), tr("Check profile whitelist..."));
        return;
    }

    m_searchTerm = searchTerm;
    //m_currentDirectory = directory;
    m_cancelled.storeRelease(NotCancelled);
    m_alreadySearchedNotes = false;

    start();
}
void GuiPreferences::changePasswd(void)
{
  QString userPasswd;
  QString passwd;
  QString newPasswd;
  QString renewPasswd;
  QString key;

  if (m_userRole == ngrt4n::AdmUserRole) {
    key = Settings::ADM_PASSWD_KEY;
    userPasswd = value(key, QString::fromStdString(ngrt4n::AdmUser));
  } else {
    key = Settings::OP_PASSWD_KEY;
    userPasswd = value(key, QString::fromStdString(ngrt4n::OpUser));
  }
  passwd = QCryptographicHash::hash(ngrt4n::toByteArray(m_oldPwdField->text()), QCryptographicHash::Md5);
  newPasswd = QCryptographicHash::hash(ngrt4n::toByteArray(m_pwdField->text()), QCryptographicHash::Md5);
  renewPasswd = QCryptographicHash::hash(ngrt4n::toByteArray(m_rePwdField->text()), QCryptographicHash::Md5);

  if (userPasswd == passwd) {
    if(newPasswd == renewPasswd) {
      setKeyValue(key, newPasswd);
      QMessageBox::information(m_dialog,
                               APP_NAME,
                               tr("Password updated"),
                               QMessageBox::Ok);
      m_dialog->done(0);
    } else {
      Q_EMIT errorOccurred(tr("Sorry the passwords do not match"));
    }
  } else {
    Q_EMIT errorOccurred(tr("Authentication failed"));
  }
}
void stylesheetParser::parseSelector(){
  int closingParenthesisPos = findParanthesis(m_styleSheet, '}');
   if(closingParenthesisPos==-1) {
    m_stopProcessing = true;
    emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg1);      
    return;
  }
    
   QString temp(m_styleSheet.left(closingParenthesisPos+1));    
  
  if(numberOfParenthesisInAParenthesisBlock(closed,temp) < numberOfParenthesisInAParenthesisBlock(opened,temp)){
    m_stopProcessing = true;
    emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg1);      
    return;
  }  
  
  if(numberOfParenthesisInAParenthesisBlock(closed,temp) > numberOfParenthesisInAParenthesisBlock(opened,temp)){
    m_stopProcessing = true;
    emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg2);      
    return;
  }    
 
   int closingParentheses = 1,
        openingParentheses = 0;
  while(true){ 
    openingParentheses = numberOfParenthesisInAParenthesisBlock(closed,m_styleSheet.left(closingParenthesisPos+1)); //m_styleSheet.left(closingParenthesisPos+1).contains("{");
        
    if(openingParentheses==closingParentheses){
      QString selectorName=m_styleSheet.left(findParanthesis(m_styleSheet, '{')/*m_styleSheet.find("{")*/).stripWhiteSpace(),
                   selectorValue=m_styleSheet.mid(findParanthesis(m_styleSheet, '{')/*m_styleSheet.find("{")*/+1, closingParenthesisPos - m_styleSheet.find("{") -1);    
        
      selectorName.remove("\n").remove("\t");
      selectorValue.remove("\n").remove("\t");
      QPair<QString,unsigned int> tmp(selectorValue,++m_orderNumber);
            
      if (m_stylesheetStructure.contains(selectorName))
      {
        uint i = 2;
        QString s = selectorName + QString("-v%1").arg(i);
        while (m_stylesheetStructure.contains(s))
        {          
         i++;
         s = selectorName + QString("-v%1").arg(i);
        }
        selectorName = s;
      }
      m_stylesheetStructure[selectorName]=tmp; 
      break;
    } 
    else {
      closingParenthesisPos = findParanthesis(m_styleSheet, '{',closingParenthesisPos+1)/*m_styleSheet.find("}",closingParenthesisPos+1)*/;
      closingParentheses++;
    } 
  }

  int ws=whiteSpaces(closingParenthesisPos+1);
  m_styleSheet=m_styleSheet.right(m_styleSheet.length()-closingParenthesisPos-1-ws);
  parse(); 
}
void Resource::finish()
{
    ASSERT(m_revalidatingRequest.isNull());
    ASSERT(!errorOccurred());
    finishOnePart();
    markClientsFinished();
    if (!errorOccurred())
        m_status = Cached;
}
Exemple #9
0
void errorService()
{
    static uint8 lastRxLowTime;

    if (uart1RxBufferFullOccurred)
    {
        uart1RxBufferFullOccurred = 0;
        errorOccurred();
    }

    if (uart1RxFramingErrorOccurred)
    {
        uart1RxFramingErrorOccurred = 0;

        // A framing error occurred.
        framingErrorActive = 1;
        errorOccurred();

        if (param_framing_error_ms > 0)
        {
            // Disable the UART's receiver.
            U1CSR &= ~0x40;    // U1CSR.RE = 0.  Disables reception of bytes on the UART.
            uartRxDisabled = 1;
            lastRxLowTime = (uint8)getMs();  // Initialize lastRxLowTime even if the line isn't low right now.
        }
    }

    if (framingErrorActive)
    {
        if (!isPinHigh(17))
        {
            errorOccurred();
        }
        else
        {
            framingErrorActive = 0;
        }
    }

    if (uartRxDisabled)
    {
        if (!isPinHigh(17))
        {
            // The line is low.
            lastRxLowTime = (uint8)getMs();
        }
        else if ((uint8)(getMs() - lastRxLowTime) > param_framing_error_ms)
        {
            // The line has been high for long enough, so re-enable the receiver.
            U1CSR |= 0x40;
            uartRxDisabled = 0;
        }
    }
}
Exemple #10
0
void CSteganoExecutor::connectSignalsAndSlotsToMethod()
{
    qRegisterMetaType<PArgsList>("PArgsList");
    qRegisterMetaType<PImage>("PImage");

    connect(m_pSteganoMethod.data(),SIGNAL(proposeFinished(PArgsList)),this,SLOT(onProposed(PArgsList)),Qt::QueuedConnection);
    connect(m_pSteganoMethod.data(),SIGNAL(encryptFinished(bool)),this,SLOT(onEncryptFinished(bool)),Qt::QueuedConnection);
    connect(m_pSteganoMethod.data(),SIGNAL(decryptFinished(bool)),this,SLOT(onDecryptFinished(bool)),Qt::QueuedConnection);
    connect(m_pSteganoMethod.data(),SIGNAL(previewFinished(PImage)), this,SIGNAL(previewFinished(PImage)),Qt::QueuedConnection);
    connect(m_pSteganoMethod.data(),SIGNAL(progressChanged(int)), this,SIGNAL(progressChanged(int)));
    connect(m_pSteganoMethod.data(),SIGNAL(errorOccurred(QString)), this,SIGNAL(errorOccurred(QString)));
}
Exemple #11
0
//------------------------------------------------------------------------------
bool ofxLua::doScript(const string& script) {

	if(L == NULL) {
		ofLogError("ofxLua") << "Cannot do script, lua state not inited!";
		return false;
	}
	
	string fullpath = ofFilePath::getAbsolutePath(ofToDataPath(script));
	string file = ofFilePath::getFileName(fullpath);
	string folder = ofFilePath::getEnclosingDirectory(fullpath);
	
	// trim the trailing slash Poco::Path always adds ... blarg
	if(folder.size() > 0 && folder.at(folder.size()-1) == '/') {
		folder.erase(folder.end()-1);
	}
	
	ofLogVerbose("ofxLua") << "Doing script: \"" << file << "\" path: \"" << folder << "\"";

	// load the script
	int ret = luaL_loadfile(L, fullpath.c_str());
	if(ret != 0) {
		switch(ret) {
			case LUA_ERRFILE:
			{
				string msg = (string)"Script \""+file+"\" not found or unreadable";
				errorOccurred(msg);
				break;
			}
			case LUA_ERRSYNTAX:
			{
				string msg = (string) lua_tostring(L, -1);
				errorOccurred(msg);
				break;
			}
			case LUA_ERRMEM:
			{
				string msg = "Memory error for script \""+file+"\"";
				errorOccurred(msg);
				break;
			}
		}
		return false;
	}
	
	// run the script
	if(lua_pcall(L, 0, LUA_MULTRET, 0) != 0) {
		string msg = (string) lua_tostring(L, -1);
		errorOccurred(msg);
		return false;
	}
	
	return true;
}
bool RedisClient::SshTransporter::connectToHost()
{
    ConnectionConfig config = m_connection->getConfig();

    if (config.isSshPasswordUsed())
        m_sshClient->setPassphrase(config.sshPassword());

    QString privateKey = config.getSshPrivateKey();

    if (!privateKey.isEmpty()) {
        m_sshClient->setKeyFiles("", privateKey);
    }    

    //connect to ssh server
    SignalWaiter waiter(config.connectionTimeout());
    waiter.addAbortSignal(this, &RedisClient::SshTransporter::errorOccurred);
    waiter.addSuccessSignal(m_sshClient.data(), &QxtSshClient::connected);

    emit logEvent("Connecting to SSH host...");

    m_sshClient->connectToHost(config.sshUser(), config.sshHost(), config.sshPort());

    if (!waiter.wait()) {
        emit errorOccurred("Cannot connect to SSH host");
        return false;
    }

    emit logEvent("SSH tunnel established. Connecting to redis-server...");    

    return openTcpSocket();
}
Exemple #13
0
void LauncherSocket::handleError(const QString &error)
{
    m_socket->disconnect();
    m_socket->deleteLater();
    m_socket = nullptr;
    emit errorOccurred(error);
}
Exemple #14
0
void CachedImage::addIncrementalDataBuffer(SharedBuffer& data)
{
    m_data = &data;

    createImage();

    // Have the image update its data from its internal buffer.
    // It will not do anything now, but will delay decoding until
    // queried for info (like size or specific image frames).
    bool sizeAvailable = m_image->setData(&data, false);
    if (!sizeAvailable)
        return;

    if (m_image->isNull()) {
        // Image decoding failed. Either we need more image data or the image data is malformed.
        error(errorOccurred() ? status() : DecodeError);
        if (inCache())
            MemoryCache::singleton().remove(*this);
        return;
    }

    // Tell our observers to try to draw.
    // Each chunk from the network causes observers to repaint, which will force that chunk to decode.
    // It would be nice to only redraw the decoded band of the image, but with the current design
    // (decoding delayed until painting) that seems hard.
    notifyObservers();

    setEncodedSize(m_image->data() ? m_image->data()->size() : 0);
}
Exemple #15
0
int oLaucher::GetTempGpu()
{



	if(procPyrit->processId()==0)
	{		
		return -1;
	}		

     oPrograms dats;

    GetPathUtils(6, &dats);
	GetParamAtiConfig(&dats.args);

    connect(procAtiConfig, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(launchErrorCrunch(QProcess::ProcessError)));
//  connect(procAtiConfig, SIGNAL(finished(int)), this, SLOT(CrunchFinish(int)));
 	connect(procAtiConfig, SIGNAL(readyReadStandardOutput()), this, SLOT(ReadStdOutAtiConfig()));
    connect(procAtiConfig, SIGNAL(readyReadStandardError()), this, SLOT(ReadStdErrAtiConfig()));
    connect(procAtiConfig, SIGNAL(error(QProcess::ProcessError)), this, SLOT(launchingError(QProcess::ProcessError)));

    //qDebug() << "[+] Get Temp GPU [aticonfig]" << dats.pathExec << dats.args;
    procAtiConfig->start(dats.pathExec, dats.args);
    procAtiConfig->waitForFinished(-1);

    return 0;
}
void GeolocationServiceAndroid::newErrorAvailable(PassRefPtr<PositionError> error)
{
    ASSERT(error);
    // We leave the last position
    m_lastError = error;
    errorOccurred();
}
void ConnectionData::runScript(const QString &type)
{
    QString scriptToStart (this->getScript(type));
    if (!scriptToStart.isEmpty()) {

        ServiceLogData::instance()->append(this->id, "Starting script: " + type + "\n");
        //
        if (g_bPortable) {
            // Replace placeholder with path
            scriptToStart = scriptToStart.replace("$appDir", qApp->applicationDirPath());

            ServiceLogData::instance()->append(this->id, "Script path: " + scriptToStart + "\n");
        }

        auto procScripts = new QProcess(this);
        QObject::connect(procScripts, SIGNAL(error(QProcess::ProcessError)), this, SLOT(showProcessScriptError(QProcess::ProcessError)));
        QObject::connect(procScripts, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(scriptFinished(int,QProcess::ExitStatus)));
        QObject::connect(procScripts, SIGNAL(finished(int,QProcess::ExitStatus)), procScripts, SLOT(deleteLater()));
        QObject::connect(procScripts, SIGNAL(error(QProcess::ProcessError)), this, SLOT(scriptErrorOccurred(QProcess::ProcessError)));
        QObject::connect(procScripts, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(scriptErrorOccurred(QProcess::ProcessError)));

        QObject::connect(procScripts, SIGNAL(started()), this, SLOT(scriptStartet()));

        //
        ServiceLogData::instance()->append(this->id, "Script call: " + scriptToStart + "\n");
        //
        procScripts->start(scriptToStart);
        qApp->processEvents() ;
    }
void stylesheetParser::parseComment(){ 
  bool stopProcessingComment=false;
  unsigned int k;
  for(k=2;k<m_styleSheet.length()-1;k++){
    QString temp;
    temp.append(m_styleSheet[k]).append(m_styleSheet[k+1]);
    if(temp=="*/")  {
      k+=2;
      stopProcessingComment=true;
      break;
    }    
  }
  
  if(stopProcessingComment){
    int ws=whiteSpaces(k);
    QPair<QString,unsigned int> tmp(m_styleSheet.left(k+ws),++m_orderNumber);
    m_stylesheetStructure["/*"+QString::number(m_orderNumber,10)]=tmp;
    m_styleSheet=m_styleSheet.right(m_styleSheet.length()-k-ws);
    parse(); 
  }
  
   else {
      m_stopProcessing = true;
      emit errorOccurred(i18n("The comment") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg1);      
      return;
    }
}
Exemple #19
0
bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI)
{
    if (!externalSVG)
        return CachedFont::ensureCustomFontData(externalSVG, remoteURI);

    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
#if !ENABLE(SVG_OTF_CONVERTER)
        if (decoder->sawError())
            m_externalSVGDocument = nullptr;
#else
        if (decoder->sawError())
            m_externalSVGDocument = nullptr;
        else
            maybeInitializeExternalSVGFontElement(remoteURI);
        if (!m_externalSVGFontElement)
            return false;
        Vector<char> convertedFont = convertSVGToOTFFont(*m_externalSVGFontElement);
        m_convertedFont = SharedBuffer::adoptVector(convertedFont);
#endif
    }

#if !ENABLE(SVG_OTF_CONVERTER)
    return m_externalSVGDocument;
#else
    return m_externalSVGDocument && CachedFont::ensureCustomFontData(m_convertedFont.get());
#endif
}
void CachedFont::error(CachedResource::Status status)
{
    setStatus(status);
    ASSERT(errorOccurred());
    setLoading(false);
    checkNotify();
}
Exemple #21
0
bool CachedFont::ensureCustomFontData()
{
    if (!m_fontData && !errorOccurred() && !isLoading() && m_data) {
        SharedBuffer* buffer = m_data.get()->sharedBuffer();
        ASSERT(buffer);

        RefPtr<SharedBuffer> sfntBuffer;

        bool fontIsWOFF = isWOFF(buffer);
        if (fontIsWOFF) {
            Vector<char> sfnt;
            if (convertWOFFToSfnt(buffer, sfnt)) {
                sfntBuffer = SharedBuffer::adoptVector(sfnt);
                buffer = sfntBuffer.get();
            } else
                buffer = nullptr;
        }

        m_fontData = buffer ? createFontCustomPlatformData(*buffer) : nullptr;
        if (m_fontData)
            m_hasCreatedFontDataWrappingResource = !fontIsWOFF;
        else
            setStatus(DecodeError);
    }
    return m_fontData.get();
}
Exemple #22
0
void CachedImage::allClientsRemoved()
{
    if (m_image && !errorOccurred())
        m_image->resetAnimation();
    if (double interval = cache()->deadDecodedDataDeletionInterval())
        m_decodedDataDeletionTimer.startOneShot(interval);
}
void ImageResource::updateImage(bool allDataReceived)
{
    TRACE_EVENT0("blink", "ImageResource::updateImage");

    if (m_data)
        createImage();

    bool sizeAvailable = false;

    // Have the image update its data from its internal buffer.
    // It will not do anything now, but will delay decoding until
    // queried for info (like size or specific image frames).
    if (m_image)
        sizeAvailable = m_image->setData(m_data, allDataReceived);

    // Go ahead and tell our observers to try to draw if we have either
    // received all the data or the size is known. Each chunk from the
    // network causes observers to repaint, which will force that chunk
    // to decode.
    if (sizeAvailable || allDataReceived) {
        if (!m_image || m_image->isNull()) {
            error(errorOccurred() ? status() : DecodeError);
            if (memoryCache()->contains(this))
                memoryCache()->remove(this);
            return;
        }

        // It would be nice to only redraw the decoded band of the image, but with the current design
        // (decoding delayed until painting) that seems hard.
        notifyObservers();
    }
}
void RenderSVGImage::layout()
{
    ASSERT(needsLayout());

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
    SVGImageElement* image = static_cast<SVGImageElement*>(node());

    if (m_needsTransformUpdate) {
        m_localTransform = image->animatedLocalTransform();
        m_needsTransformUpdate = false;
    }

    // minimum height
    setHeight(errorOccurred() ? intrinsicSize().height() : 0);

    calcWidth();
    calcHeight();

    m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
    m_cachedLocalRepaintRect = FloatRect();

    repainter.repaintAfterLayout();
    
    setNeedsLayout(false);
}
void ImageResource::allClientsRemoved()
{
    m_pendingContainerSizeRequests.clear();
    if (m_image && !errorOccurred())
        m_image->resetAnimation();
    Resource::allClientsRemoved();
}
void SvCreator::addEvents(void)
{
  connect(m_subMenus["NewFile"],SIGNAL(triggered(bool)),this,SLOT(newView()));
  connect(m_subMenus["NewNode"],SIGNAL(triggered(bool)),this,SLOT(newNode()));
  connect(m_subMenus["CopySelected"],SIGNAL(triggered(bool)),this,SLOT(copySelected()));
  connect(m_subMenus["PasteFromSelected"],SIGNAL(triggered(bool)),this,SLOT(pasteFromSelected()));
  connect(m_subMenus["DeleteNode"],SIGNAL(triggered(bool)),this,SLOT(deleteNode()));
  connect(m_subMenus["Open"],SIGNAL(triggered(bool)),this,SLOT(open()));
  connect(m_subMenus["Save"],SIGNAL(triggered(bool)),this,SLOT(save()));
  connect(m_subMenus["SaveAs"], SIGNAL(triggered(bool)), this, SLOT(saveAs()));
  connect(m_subMenus["ImportHostGroupAsBusinessView"],SIGNAL(triggered(bool)),this,SLOT(handleImportHostGroupAsBusinessView()));
  connect(m_subMenus["ImportMonitorItemsAsDataPoints"],SIGNAL(triggered(bool)),this,SLOT(handleImportMonitorItemsAsDataPoints()));
  connect(m_subMenus["ImportNagiosChecks"],SIGNAL(triggered(bool)),this,SLOT(importNagiosChecks()));
  connect(m_subMenus["ImportNagiosBPIConf"],SIGNAL(triggered(bool)),this,SLOT(handleImportNagiosBPIConfigAsBusinessView()));
  connect(m_subMenus["ImportZabbixITServices"],SIGNAL(triggered(bool)),this,SLOT(handleImportZabbixITServicesAsBusinessView()));
  connect(m_subMenus["Quit"],SIGNAL(triggered(bool)),this,SLOT(treatCloseAction()));
  connect(m_subMenus["ShowAbout"],SIGNAL(triggered(bool)),this,SLOT(handleShowAbout()));
  connect(m_subMenus["ShowOnlineResources"],SIGNAL(triggered(bool)),this,SLOT(handleShowOnlineResources()));
  connect(m_editor,SIGNAL(saveClicked()),this,SLOT(save()));
  connect(m_editor,SIGNAL(closeClicked()),this,SLOT(treatCloseAction()));
  connect(m_editor,SIGNAL(returnPressed()),this,SLOT(handleReturnPressed()));
  connect(m_editor,SIGNAL(nodeTypeActivated(qint32)),this,SLOT(handleNodeTypeActivated(qint32)));
  connect(m_editor,SIGNAL(errorOccurred(QString)),this, SLOT(handleErrorOccurred(QString)));
  connect(m_tree,SIGNAL(itemSelectionChanged()),this,SLOT(handleSelectedNodeChanged()));
  connect(m_tree,SIGNAL(treeNodeMoved(QString)),this,SLOT(handleTreeNodeMoved(QString)));
}
QVariant RedisConnection::execute(QString command)
{        
    if (command.isEmpty()) {
        return QVariant();
    }
    
    // Send command
    QByteArray cmd = Command::getByteRepresentation(command);
    socket->write(cmd);
    socket->flush();    

    emit log(QString("%1 > [execute] %2").arg(config.name).arg(command));

    if (!socket->waitForReadyRead(config.executeTimeout)) {

        QAbstractSocket::SocketError error = socket->error();

        if (error == QAbstractSocket::UnknownSocketError && connect()) {
            return execute(command);
        } else {
            emit errorOccurred("Execution timeout exceeded");
        }

        return QVariant();
    }

    /*
     *    Get response
     */    
    Response response; QByteArray res;

    while(!response.isValid()) {    

        if (socket->bytesAvailable() > 0) 
        {
            res = socket->readAll();
            response.appendToSource(res);    

        } else {
            
            // TODO: move config.executeTimeout to config options - user probably want to increase this value for unstable connections            

            if (!socket->waitForReadyRead(config.executeTimeout)) 
            {
                emit log(QString("%1 > [execute] %2 -> response partially received. Execution timeout").arg(config.name).arg(command));
                break;
            }
        }

    }    

    emit log(
        QString("%1 > [execute] %2 -> response received: \n %3")
        .arg(config.name)
        .arg(command)
        .arg(response.toString()));

    return response.getValue();
}
void Resource::setResourceBuffer(PassRefPtr<SharedBuffer> resourceBuffer)
{
    ASSERT(m_revalidatingRequest.isNull());
    ASSERT(!errorOccurred());
    ASSERT(m_options.dataBufferingPolicy == BufferData);
    m_data = resourceBuffer;
    setEncodedSize(m_data->size());
}
Exemple #29
0
void MainWindow::setupTransaction(QApt::Transaction *trans)
{
    // Provide proxy/locale to the transaction
    if (KProtocolManager::proxyType() == KProtocolManager::ManualProxy) {
        trans->setProxy(KProtocolManager::proxyFor("http"));
    }

    trans->setLocale(QLatin1String(setlocale(LC_MESSAGES, 0)));

    trans->setDebconfPipe(m_transWidget->pipe());
    m_transWidget->setTransaction(m_trans);

    connect(m_trans, SIGNAL(statusChanged(QApt::TransactionStatus)),
            this, SLOT(transactionStatusChanged(QApt::TransactionStatus)));
    connect(m_trans, SIGNAL(errorOccurred(QApt::ErrorCode)),
            this, SLOT(errorOccurred(QApt::ErrorCode)));
}
void GeolocationServiceAndroid::timerFired(Timer<GeolocationServiceAndroid>* timer) {
    ASSERT(&m_timer == timer);
    ASSERT(m_lastPosition || m_lastError);
    if (m_lastPosition)
        positionChanged();
    else
        errorOccurred();
}