Ejemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QSizePolicy qsp(QSizePolicy::Preferred, QSizePolicy::Preferred);
    qsp.setHeightForWidth(true);
    this->setSizePolicy(qsp);
    setCentralWidget(ui->widget);
    this->setFixedSize(1152,720);

    playerID = 0;
    socket = new QTcpSocket(this);
    connect(socket,SIGNAL(readyRead()),this,SLOT(infoReceived()));
    connectBox();

    keyUp = keyDown = keyLeft = keyRight = keyE = keyQ = keySpace = false;

    timerInterval = 15;

    timer.setSingleShot(false);
    timer.setInterval(timerInterval);
    connect(&timer,SIGNAL(timeout()),this,SLOT(onTimer()));
    timer.start();
    mt = 0;
    mtON = false;
    roundTimerEnabled = false;
}
bool QXmppDiscoveryManager::handleStanza(const QDomElement &element)
{
    if (element.tagName() == "iq" && QXmppDiscoveryIq::isDiscoveryIq(element))
    {
        QXmppDiscoveryIq receivedIq;
        receivedIq.parse(element);

        if(receivedIq.type() == QXmppIq::Get &&
           receivedIq.queryType() == QXmppDiscoveryIq::InfoQuery &&
           (receivedIq.queryNode().isEmpty() || receivedIq.queryNode().startsWith(d->clientCapabilitiesNode)))
        {
            // respond to query
            QXmppDiscoveryIq qxmppFeatures = capabilities();
            qxmppFeatures.setId(receivedIq.id());
            qxmppFeatures.setTo(receivedIq.from());
            qxmppFeatures.setQueryNode(receivedIq.queryNode());
            client()->sendPacket(qxmppFeatures);
        }
        else if(receivedIq.queryType() == QXmppDiscoveryIq::InfoQuery)
            emit infoReceived(receivedIq);
        else if(receivedIq.queryType() == QXmppDiscoveryIq::ItemsQuery)
            emit itemsReceived(receivedIq);

        return true;
    }
    return false;
}
Ejemplo n.º 3
0
// --------------------------------------------------------------------------
void qMidasAPIPrivate::processReply(QNetworkReply* reply)
{
  Q_Q(qMidasAPI);
  QUuid uuid(reply->property("uuid").toString());
  if (reply->error() != QNetworkReply::NoError)
    {
    q->emit errorReceived(uuid.toString() + ": "  + 
                  reply->error() + ": " +
                  reply->errorString());
    }
  QScriptValue scriptResult =
    this->ScriptEngine.evaluate("(" + QString(reply->readAll()) + ")");
  q->emit infoReceived(QString("Parse results for ") + uuid);
  QList<QVariantMap> result = this->parseResult(scriptResult);
  q->emit infoReceived(QString("Results for ") + uuid.toString()
                       + ": " + q->qVariantMapListToString(result));
  q->emit resultReceived(uuid, result);
  reply->close();
  reply->deleteLater();
}
Ejemplo n.º 4
0
ChatClient::ChatClient(QObject *parent)
    : QXmppClient(parent)
    , d(new ChatClientPrivate)
{
    bool check;
    Q_UNUSED(check);

    check = connect(this, SIGNAL(connected()),
                    this, SLOT(_q_connected()));
    Q_ASSERT(check);

    check = connect(this, SIGNAL(error(QXmppClient::Error)),
            this, SLOT(_q_error(QXmppClient::Error)));
    Q_ASSERT(check);

    check = connect(this, SIGNAL(messageReceived(QXmppMessage)),
            this, SLOT(_q_messageReceived(QXmppMessage)));
    Q_ASSERT(check);

    // DNS lookups
    check = connect(&d->dns, SIGNAL(finished()),
                    this, SLOT(_q_dnsLookupFinished()));
    Q_ASSERT(check);

    // service discovery
    d->discoManager = findExtension<QXmppDiscoveryManager>();
    check = connect(d->discoManager, SIGNAL(infoReceived(QXmppDiscoveryIq)),
                    this, SLOT(_q_discoveryInfoReceived(QXmppDiscoveryIq)));
    Q_ASSERT(check);

    check = connect(d->discoManager, SIGNAL(itemsReceived(QXmppDiscoveryIq)),
                    this, SLOT(_q_discoveryItemsReceived(QXmppDiscoveryIq)));
    Q_ASSERT(check);

    // server time
    d->timeManager = findExtension<QXmppEntityTimeManager>();
    check = connect(d->timeManager, SIGNAL(timeReceived(QXmppEntityTimeIq)),
                    this, SLOT(_q_timeReceived(QXmppEntityTimeIq)));
    Q_ASSERT(check);

    // file transfers
    transferManager()->setSupportedMethods(QXmppTransferJob::SocksMethod);

    // multimedia calls
    callManager();

    // diagnostics
    diagnosticManager();

    qDebug("ChatClient 0x%llx created", reinterpret_cast<qint64>(this));
    chatClients.append(this);
    theClientObserver()->clientCreated(this);
}
Ejemplo n.º 5
0
// --------------------------------------------------------------------------
void qMidasAPIPrivate::init()
{
  Q_Q(qMidasAPI);
  this->NetworkManager = new QNetworkAccessManager(q);
  QObject::connect(this->NetworkManager, SIGNAL(finished(QNetworkReply*)),
                   this, SLOT(processReply(QNetworkReply*)));
#if 0
  QObject::connect(q, SIGNAL(errorReceived(QString)),
                   this, SLOT(print(QString)));
  QObject::connect(q, SIGNAL(infoReceived(QString)),
                   this, SLOT(print(QString)));
#endif
}
Ejemplo n.º 6
0
// --------------------------------------------------------------------------
QUuid qMidasAPIPrivate::postQuery(const QUrl& url)
{
  Q_Q(qMidasAPI);
  QNetworkRequest queryRequest;
  queryRequest.setUrl(url);
  QUuid queryUuid = QUuid::createUuid();
  q->emit infoReceived("Post query: " + url.toString());
  QNetworkReply* queryReply = this->NetworkManager->get(queryRequest);
  queryReply->setProperty("uuid", queryUuid.toString());
  if (this->TimeOut > 0)
    {
    QTimer* timeOut = new QTimer(queryReply);
    timeOut->setSingleShot(true);
    QObject::connect(timeOut, SIGNAL(timeout()),
                     this, SLOT(queryTimeOut()));
    timeOut->start(this->TimeOut);
    QObject::connect(queryReply, SIGNAL(downloadProgress(qint64,qint64)),
                     this, SLOT(queryProgress()));
    }
  return queryUuid;
}
QXmppClient::QXmppClient(QObject *parent)
    : QXmppLoggable(parent),
    d(new QXmppClientPrivate(this))
{
    bool check;
    Q_UNUSED(check);

    d->stream = new QXmppOutgoingClient(this);
    d->addProperCapability(d->clientPresence);

    check = connect(d->stream, SIGNAL(elementReceived(QDomElement,bool&)),
                    this, SLOT(_q_elementReceived(QDomElement,bool&)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(messageReceived(QXmppMessage)),
                    this, SIGNAL(messageReceived(QXmppMessage)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(presenceReceived(QXmppPresence)),
                    this, SIGNAL(presenceReceived(QXmppPresence)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(iqReceived(QXmppIq)),
                    this, SIGNAL(iqReceived(QXmppIq)));
    Q_ASSERT(check);

    check = connect(d->stream->socket(), SIGNAL(stateChanged(QAbstractSocket::SocketState)),
                    this, SLOT(_q_socketStateChanged(QAbstractSocket::SocketState)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(connected()),
                    this, SLOT(_q_streamConnected()));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(disconnected()),
                    this, SLOT(_q_streamDisconnected()));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(error(QXmppClient::Error)),
                    this, SLOT(_q_streamError(QXmppClient::Error)));
    Q_ASSERT(check);

    // reconnection
    d->reconnectionTimer = new QTimer(this);
    d->reconnectionTimer->setSingleShot(true);
    connect(d->reconnectionTimer, SIGNAL(timeout()),
            this, SLOT(_q_reconnect()));
    Q_ASSERT(check);

    // logging
    setLogger(QXmppLogger::getLogger());

    // create managers
    // TODO move manager references to d->extensions
    d->rosterManager = new QXmppRosterManager(this);
    addExtension(d->rosterManager);

    d->vCardManager = new QXmppVCardManager;
    addExtension(d->vCardManager);

    d->versionManager = new QXmppVersionManager;
    addExtension(d->versionManager);

    addExtension(new QXmppEntityTimeManager());

    QXmppDiscoveryManager *discoveryManager = new QXmppDiscoveryManager;
    addExtension(discoveryManager);

    // obsolete signal
    check = connect(discoveryManager, SIGNAL(infoReceived(QXmppDiscoveryIq)),
                    this, SIGNAL(discoveryIqReceived(QXmppDiscoveryIq)));
    Q_ASSERT(check);

    check = connect(discoveryManager, SIGNAL(itemsReceived(QXmppDiscoveryIq)),
                    this, SIGNAL(discoveryIqReceived(QXmppDiscoveryIq)));
    Q_ASSERT(check);
}
Ejemplo n.º 8
0
QXmppClient::QXmppClient(QObject *parent)
    : QXmppLoggable(parent),
    d(new QXmppClientPrivate(this))
{
    d->stream = new QXmppOutgoingClient(this);
    d->addProperCapability(d->clientPresence);

    bool check = connect(d->stream, SIGNAL(elementReceived(const QDomElement&, bool&)),
                         this, SLOT(slotElementReceived(const QDomElement&, bool&)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(messageReceived(const QXmppMessage&)),
                         this, SIGNAL(messageReceived(const QXmppMessage&)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(presenceReceived(const QXmppPresence&)),
                    this, SIGNAL(presenceReceived(const QXmppPresence&)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(iqReceived(const QXmppIq&)), this,
        SIGNAL(iqReceived(const QXmppIq&)));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(disconnected()), this,
        SIGNAL(disconnected()));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(connected()), this,
        SLOT(xmppConnected()));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(connected()), this,
        SIGNAL(connected()));
    Q_ASSERT(check);

    check = connect(d->stream, SIGNAL(error(QXmppClient::Error)), this,
        SIGNAL(error(QXmppClient::Error)));
    Q_ASSERT(check);

    check = setReconnectionManager(new QXmppReconnectionManager(this));
    Q_ASSERT(check);

    // logging
    d->logger = 0;
    setLogger(QXmppLogger::getLogger());

    // create managers
    // TODO move manager references to d->extensions
    d->rosterManager = new QXmppRosterManager(this);
    addExtension(d->rosterManager);

    d->vCardManager = new QXmppVCardManager;
    addExtension(d->vCardManager);

    d->versionManager = new QXmppVersionManager;
    addExtension(d->versionManager);

    addExtension(new QXmppEntityTimeManager());

    QXmppDiscoveryManager *discoveryManager = new QXmppDiscoveryManager;
    addExtension(discoveryManager);

    // obsolete signal
    check = connect(discoveryManager, SIGNAL(infoReceived(QXmppDiscoveryIq)),
                    this, SIGNAL(discoveryIqReceived(QXmppDiscoveryIq)));
    Q_ASSERT(check);

    check = connect(discoveryManager, SIGNAL(itemsReceived(QXmppDiscoveryIq)),
                    this, SIGNAL(discoveryIqReceived(QXmppDiscoveryIq)));
    Q_ASSERT(check);
}