예제 #1
0
파일: client.cpp 프로젝트: tshipa/wilink
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);
}
예제 #2
0
void ModuleManagerPrivate::initLocalPeer(const QString &message, bool *shouldExit)
{
	*shouldExit = false;
	d->localPeer.reset(new QtLocalPeer(managerSelf));
	if (d->localPeer->isClient()) {
		if (d->localPeer->sendMessage(message, 1000)) {
			*shouldExit = true;
			return;
		}
		// Assume we became a server
		Q_ASSERT(!d->localPeer->isClient());
	}
	QObject::connect(d->localPeer.data(), SIGNAL(messageReceived(QString)),
					 managerSelf, SLOT(_q_messageReceived(QString)));
}