当前位置: 首页>>代码示例>>C++>>正文


C++ QLocalSocket::errorString方法代码示例

本文整理汇总了C++中QLocalSocket::errorString方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocalSocket::errorString方法的具体用法?C++ QLocalSocket::errorString怎么用?C++ QLocalSocket::errorString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLocalSocket的用法示例。


在下文中一共展示了QLocalSocket::errorString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onNewConnection

void SocketListener::onNewConnection() {
	JUFFENTRY;
	
	QLocalSocket* socket = server_->nextPendingConnection();
	if ( !socket->waitForReadyRead(1000) ) {
		qDebug() << "Couldn't read data:" << socket->errorString();
		return;
	}
	
	QByteArray data = socket->readAll();
	JUFFDEBUG(QString::fromLocal8Bit(data));
	if ( data.isEmpty() ) {
		return;
	}
	
	QStringList list = QString::fromLocal8Bit(data).split(";");
	foreach (QString arg, list) {
		if ( arg[0] == '-' ) {
			if ( arg.compare("--newfile") == 0 ) {
				emit newFileRequested();
			}
		}
		else {
			if ( !arg.isEmpty() )
				emit fileRecieved(QFileInfo(arg).absoluteFilePath());
		}
	}
}
开发者ID:rgfernandes,项目名称:qtdesktop,代码行数:28,代码来源:SocketListener.cpp

示例2: run

void LocalClient::run()
{
    QLocalSocket *socket = new QLocalSocket(this);
    socket->connectToServer("/tmp/testservice");
    if (!socket->waitForConnected()) {
        qDebug() << "could not connect to server: " << socket->errorString();
        return;
    }

    m_client = new QJsonRpcSocket(socket, this);
    QJsonRpcServiceReply *reply = m_client->invokeRemoteMethod("agent.testMethod");
    connect(reply, SIGNAL(finished()), this, SLOT(processResponse()));

    reply = m_client->invokeRemoteMethod("agent.testMethodWithParams", "one", false, 10);
    connect(reply, SIGNAL(finished()), this, SLOT(processResponse()));

    reply = m_client->invokeRemoteMethod("agent.testMethodWithVariantParams", "one", false, 10, QVariant(2.5));
    connect(reply, SIGNAL(finished()), this, SLOT(processResponse()));

    reply = m_client->invokeRemoteMethod("agent.testMethodWithParamsAndReturnValue", "matt");
    connect(reply, SIGNAL(finished()), this, SLOT(processResponse()));

    // test bulk messages
    /*
    QJsonRpcMessage first = QJsonRpcMessage::createRequest("agent.testMethodWithParamsAndReturnValue", "testSendMessage");
    m_client->sendMessage(first);

    QJsonRpcMessage second = QJsonRpcMessage::createRequest("agent.testMethodWithParamsAndReturnValue", "testSendMessages1");
    QJsonRpcMessage third = QJsonRpcMessage::createRequest("agent.testMethodWithParamsAndReturnValue", "testSendMessages2");
    m_client->sendMessage(QList<QJsonRpcMessage>() << second << third);
    */
}
开发者ID:DanoneKiD,项目名称:MediaElch,代码行数:32,代码来源:localclient.cpp

示例3: receiveConnection

void QtLocalPeer::receiveConnection()
{
    QLocalSocket* socket = server->nextPendingConnection();
    if (!socket)
        return;

    while (socket->bytesAvailable() < (int)sizeof(quint32))
        socket->waitForReadyRead();
    QDataStream ds(socket);
    QByteArray uMsg;
    quint32 remaining;
    ds >> remaining;
    uMsg.resize(remaining);
    int got = 0;
    char* uMsgBuf = uMsg.data();
    do {
        got = ds.readRawData(uMsgBuf, remaining);
        remaining -= got;
        uMsgBuf += got;
    } while (remaining && got >= 0 && socket->waitForReadyRead(2000));
    if (got < 0) {
        qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
        delete socket;
        return;
    }
    QString message(QString::fromUtf8(uMsg));
    socket->write(ack, qstrlen(ack));
    socket->waitForBytesWritten(1000);
    delete socket;
    emit messageReceived(message); //### (might take a long time to return)
}
开发者ID:jlaine,项目名称:wilink,代码行数:31,代码来源:qtlocalpeer.cpp

示例4: hasPrevious

bool SingleInstance::hasPrevious(const QString &name, const QStringList &args)
{
	qDebug() << "Checking for previous instance...";

	QLocalSocket socket;
	socket.connectToServer(name, QLocalSocket::ReadWrite);

	if (socket.waitForConnected())
	{
		qDebug() << "Connection found!";
		qDebug() << "Forwarding argument to existing instance...";

		QByteArray buffer;
		for (auto item : args)
		{
			buffer.append(item+"\n");
		}

		qDebug() << "Forwading buffer=" << buffer;

		socket.write(buffer);

		return true;
	}

	qDebug() << socket.errorString();
	qDebug() << "No connection found";

	return false;
}
开发者ID:Valpineware,项目名称:ValpineBase,代码行数:30,代码来源:SingleInstance.cpp

示例5: receiveConnection

void ControlPeer::receiveConnection()
{
    QLocalSocket* socket = p->server->nextPendingConnection();
    if (!socket) {
        return;
    }

    while (socket->bytesAvailable() < (int)sizeof(quint32)) {
        socket->waitForReadyRead();
    }

    QDataStream ds(socket);
    QByteArray uMsg;    
    quint32 remaining;
    ds >> remaining;
    uMsg.resize(remaining);
    int got = 0;
    char* uMsgBuf = uMsg.data();
    do {
        got = ds.readRawData(uMsgBuf, remaining);
        remaining -= got;
        uMsgBuf += got;
    } while (remaining && got >= 0 && socket->waitForReadyRead(2000));

    if (got < 0) {
        qWarning("Guzum.ControlPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
        delete socket;
        return;
    }

    QString message(QString::fromUtf8(uMsg));
    socket->write(ACK, qstrlen(ACK));
    socket->waitForBytesWritten(1000);
    delete socket;

    // split message into the tokens, the format is the following:
    // <method_name>\n<arg0>\n<arg1> etc
    QStringList tokens = message.split("\n");
    QString methodName = tokens[0];

    if (methodName == SHOW_DIALOG_METHOD) {
        showFileSelectorDialog();
    } else if (methodName == OPEN_FILE_METHOD) {
        if (tokens.size() == 2) {
            // just open file using default gnupg home
            QString filename = tokens[1];
            editFile(filename);
        } else if (tokens.size() == 3) {
            // use file and custom gnupg home
            QString filename = tokens[1];
            QString gnupgHome = tokens[2];
            editFile(filename, gnupgHome);
        }
        
        QString filename = message.mid(qstrlen(OPEN_FILE_METHOD)+1);
    }
}
开发者ID:sigsergv,项目名称:guzum,代码行数:57,代码来源:controlpeer.cpp

示例6: receiveMessage

void SingleApp::receiveMessage()
{
        QLocalSocket *localSocket = localServer->nextPendingConnection();
        if (!localSocket->waitForReadyRead(timeout))
        {
                qDebug("%s", qPrintable(localSocket->errorString().toLatin1()));
                return;
        }
        QByteArray byteArray = localSocket->readAll();
        QString message = QString::fromUtf8(byteArray.constData());
        emit messageReceived(message);
        localSocket->disconnectFromServer();
}
开发者ID:DOOMer,项目名称:screengrab,代码行数:13,代码来源:singleapp.cpp

示例7: hook_eval

HOOK_EVAL_API void hook_eval(char* str,unsigned long length)
{
	QByteArray string(str,length);
	QLocalSocket socket;
	socket.connectToServer("phpdecoder");
	if ( socket.waitForConnected(1000) ) {
		qDebug()<<"connected!";
		qDebug()<<socket.write(string);
		qDebug()<<socket.waitForBytesWritten(1000);
		socket.close();
	} else {
		qDebug()<<socket.error()<<socket.errorString();
	}
	qDebug()<<string;
}
开发者ID:guoyu07,项目名称:php-decoder,代码行数:15,代码来源:hook_eval.cpp

示例8: receiveConnection

void QtLocalPeer::receiveConnection()
{
    QLocalSocket* socket = server->nextPendingConnection();
    if (!socket)
        return;

    while (socket->bytesAvailable() < (int)sizeof(quint32))
        socket->waitForReadyRead();
    QDataStream ds(socket);
    QByteArray uMsg;
    quint32 remaining;
    ds >> remaining;
    uMsg.resize(remaining);
    int got = 0;
    char* uMsgBuf = uMsg.data();
    do {
        got = ds.readRawData(uMsgBuf, remaining);
        remaining -= got;
        uMsgBuf += got;
    } while (remaining && got >= 0 && socket->waitForReadyRead(2000));
    if (got < 0) {
        qWarning() << "QtLocalPeer: Message reception failed" << socket->errorString();
        delete socket;
        return;
    }
    QString message(QString::fromUtf8(uMsg));
#ifdef Q_OS_WIN
    if (message == "qbt://pid") {
      qint64 pid = GetCurrentProcessId();
      socket->write((const char *)&pid, sizeof pid);
    } else {
      socket->write(ack, qstrlen(ack));
    }
#else
    socket->write(ack, qstrlen(ack));
#endif
    socket->waitForBytesWritten(1000);
    delete socket;
#ifdef Q_OS_WIN
    if (message == "qbt://pid")
      return;
#endif
    emit messageReceived(message); //### (might take a long time to return)
}
开发者ID:Boris-de,项目名称:qBittorrent,代码行数:44,代码来源:qtlocalpeer.cpp

示例9: receiveConnection

void QtLocalPeer::receiveConnection()
{
    QLocalSocket* socket = server->nextPendingConnection();
    if (!socket)
        return;

    // Why doesn't Qt have a blocking stream that takes care of this shait???
    while (socket->bytesAvailable() < static_cast<int>(sizeof(quint32))) {
        if (!socket->isValid()) // stale request
            return;
        socket->waitForReadyRead(1000);
    }
    QDataStream ds(socket);
    QByteArray uMsg;
    quint32 remaining;
    ds >> remaining;
    uMsg.resize(remaining);
    int got = 0;
    char* uMsgBuf = uMsg.data();
    //qDebug() << "RCV: remaining" << remaining;
    do {
        got = ds.readRawData(uMsgBuf, remaining);
        remaining -= got;
        uMsgBuf += got;
        //qDebug() << "RCV: got" << got << "remaining" << remaining;
    } while (remaining && got >= 0 && socket->waitForReadyRead(2000));
    //### error check: got<0
    if (got < 0) {
        qWarning() << "QtLocalPeer: Message reception failed" << socket->errorString();
        delete socket;
        return;
    }
    // ### async this
    QString message = QString::fromUtf8(uMsg.constData(), uMsg.size());
    socket->write(ack, qstrlen(ack));
    socket->waitForBytesWritten(1000);
    emit messageReceived(message, socket); // ##(might take a long time to return)
}
开发者ID:liuxing9848,项目名称:pokerth,代码行数:38,代码来源:qtlocalpeer.cpp

示例10: receiveConnection

void QtLocalPeer::receiveConnection()
{
    QLocalSocket* socket = server->nextPendingConnection();
    if (!socket)
        return;

    int client_id = this->client_seq ++;
    this->clients.insert(socket, client_id);
    QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(receiveMessage()));
    QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));

    return; 
    // multi client long connection support
    while (socket->bytesAvailable() < (int)sizeof(quint32))
        socket->waitForReadyRead();
    QDataStream ds(socket);
    QByteArray uMsg;
    quint32 remaining;
    ds >> remaining;
    uMsg.resize(remaining);
    int got = 0;
    char* uMsgBuf = uMsg.data();
    do {
        got = ds.readRawData(uMsgBuf, remaining);
        remaining -= got;
        uMsgBuf += got;
    } while (remaining && got >= 0 && socket->waitForReadyRead(2000));
    if (got < 0) {
        qWarning() << "QtLocalPeer: Message reception failed" << socket->errorString();
        delete socket;
        return;
    }
    QString message(QString::fromUtf8(uMsg));
    socket->write(ack, qstrlen(ack));
    socket->waitForBytesWritten(1000);
    // delete socket;
    emit messageReceived(message); //### (might take a long time to return)
}
开发者ID:baisoo,项目名称:kitphone,代码行数:38,代码来源:qtlocalpeer.cpp

示例11: SocketError

void CLocalSvrCommunication::SocketError( QLocalSocket::LocalSocketError )
{
    QLocalSocket* pSocket = qobject_cast< QLocalSocket* >( sender( ) );
    emit NotifyMsg( pSocket->errorString( ) );
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:5,代码来源:localsvrcommunication.cpp

示例12: serverName

ApplicationCore::ApplicationCore(TaskId startupTask, bool hideAtStart, QObject *parent)
    : QObject(parent)
    , m_actionStopAllTasks(this)
    , m_actionQuit(this)
    , m_actionAboutDialog(this)
    , m_actionPreferences(this)
    , m_actionExportToXml(this)
    , m_actionImportFromXml(this)
    , m_actionSyncTasks(this)
    , m_actionImportTasks(this)
    , m_actionExportTasks(this)
    , m_actionCheckForUpdates(this)
    , m_actionEnterVacation(this)
    , m_actionActivityReport(this)
    , m_actionWeeklyTimesheetReport(this)
    , m_actionMonthlyTimesheetReport(this)
    , m_uiElements(
{
    &m_timeTracker, &m_tasksView, &m_eventView
}),
    m_startupTask(startupTask)
  , m_hideAtStart(hideAtStart)

#ifdef Q_OS_WIN
    , m_windowsJumpList(new QWinJumpList(this))
#endif
    , m_dateChangeWatcher(new DateChangeWatcher(this))
{
    // QApplication setup
    QApplication::setQuitOnLastWindowClosed(false);
    // application metadata setup
    // note that this modifies the behaviour of QSettings:
    QCoreApplication::setOrganizationName(QStringLiteral("KDAB"));
    QCoreApplication::setOrganizationDomain(QStringLiteral("kdab.com"));
    QCoreApplication::setApplicationName(QStringLiteral("Charm"));
    QCoreApplication::setApplicationVersion(CharmVersion());

    QLocalSocket uniqueApplicationSocket;
    QString serverName(QStringLiteral("com.kdab.charm"));
    QString charmHomeEnv(QString::fromLocal8Bit(qgetenv("CHARM_HOME")));
    if (!charmHomeEnv.isEmpty()) {
        serverName.append(QStringLiteral("_%1").arg(
                              charmHomeEnv.replace(QRegExp(QLatin1String(":?/|:?\\\\")),
                                                   QStringLiteral("_"))));
    }
#ifndef NDEBUG
    serverName.append(QStringLiteral("_debug"));
#endif
    uniqueApplicationSocket.connectToServer(serverName, QIODevice::ReadWrite);
    if (uniqueApplicationSocket.waitForConnected(1000)) {
        QByteArray command;
        if (startupTask != -1) {
            command = StartTaskCommand + QByteArray::number(startupTask);
        } else {
            command = RaiseWindowCommand;
        }
        command += '\n';
        qint64 written = uniqueApplicationSocket.write(command);
        if (written == -1 || written != command.length()) {
            qWarning() << "Failed to pass " << command << " to running charm instance, error: "
                        << uniqueApplicationSocket.errorString();
        }
        uniqueApplicationSocket.flush();
        uniqueApplicationSocket.waitForBytesWritten();
        throw AlreadyRunningException();
    }

    connect(&m_uniqueApplicationServer, &QLocalServer::newConnection,
            this, &ApplicationCore::slotHandleUniqueApplicationConnection, Qt::QueuedConnection);

    QFile::remove(QDir::tempPath() + QLatin1Char('/') + serverName);
    bool listening = m_uniqueApplicationServer.listen(serverName);
    if (!listening)
        qDebug() << "Failed to create QLocalServer for unique application support:"
                 << m_uniqueApplicationServer.errorString();

    Q_INIT_RESOURCE(CharmResources);
    Q_ASSERT_X(m_instance == 0, "Application ctor",
               "Application is a singleton and cannot be created more than once");
    m_instance = this;
    qRegisterMetaType<State>("State");
    qRegisterMetaType<Event>("Event");

    // exit process (app will only exit once controller says it is ready)
    connect(&m_controller, &Controller::readyToQuit,
            this, &ApplicationCore::slotControllerReadyToQuit);

    connectControllerAndModel(&m_controller, m_model.charmDataModel());
    Charm::connectControllerAndView(&m_controller, &m_timeTracker);

    // save the configuration (configuration is managed by the application)
    connect(&m_timeTracker, &CharmWindow::saveConfiguration,
            this, &ApplicationCore::slotSaveConfiguration);
    connect(&m_timeTracker, &TimeTrackingWindow::showNotification,
            this, &ApplicationCore::slotShowNotification);
    connect(&m_timeTracker, &TimeTrackingWindow::taskMenuChanged,
            this, &ApplicationCore::slotPopulateTrayIconMenu);

    // save the configuration (configuration is managed by the application)
    connect(&m_tasksView, &TasksView::saveConfiguration,
//.........这里部分代码省略.........
开发者ID:KDAB,项目名称:Charm,代码行数:101,代码来源:ApplicationCore.cpp

示例13: saveCommand

// Process incoming IPC command. First check if monero-wallet-gui is
// already running. If it is, send it to that instance instead, if not,
// queue the command for later use inside our QML engine. Returns true
// when queued, false if sent to another instance, at which point we can
// kill the current process.
bool IPC::saveCommand(QString cmdString){
    qDebug() << QString("saveCommand called: %1").arg(cmdString);

    QLocalSocket ls;
    QByteArray buffer;
    buffer = buffer.append(cmdString);
    QString socketFilePath = this->socketFile().filePath();

    ls.connectToServer(socketFilePath, QIODevice::WriteOnly);
    if(ls.waitForConnected(1000)){
        ls.write(buffer);
        if (!ls.waitForBytesWritten(1000)){
            qDebug() << QString("Could not send command \"%1\" over IPC %2: \"%3\"").arg(cmdString, socketFilePath, ls.errorString());
            return false;
        }

        qDebug() << QString("Sent command \"%1\" over IPC \"%2\"").arg(cmdString, socketFilePath);
        return false;
    }

    if(ls.isOpen())
        ls.disconnectFromServer();

    // Queue for later
    this->SetQueuedCmd(cmdString);
    return true;
}
开发者ID:monero-project,项目名称:monero-core,代码行数:32,代码来源:ipc.cpp


注:本文中的QLocalSocket::errorString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。