Example #1
0
void QCopChannel::detach(const QString& ch, QCopX11Client *cl)
{
    if (!qcopServerMap)
        return;

    QCopServerMap::Iterator it = qcopServerMap->find(ch);
    if (it != qcopServerMap->end()) {
        it.value().removeAll(cl);
        if (it.value().isEmpty()) {
          // If this was the last client in the channel, announce the channel as dead
          emit qcopServer->removedChannel(it.key());
          qcopServerMap->erase(it);
        }
    }
    if (qcopServerRegexpList && containsWildcards(ch)) {
        // Remove references to a wildcarded channel.
        QCopServerRegexpList::Iterator it
            = qcopServerRegexpList->begin();
        while(it != qcopServerRegexpList->end()) {
            if ((*it).client == cl && (*it).channel == ch)
                it = qcopServerRegexpList->erase(it);
            else
                ++it;
        }
    }
}
void QCopChannel::registerChannel(const QString& ch, QWSClient *cl)
{
    if (!qcopServerMap)
        qcopServerMap = new QCopServerMap;

    // do we need a new channel list ?
    QCopServerMap::Iterator it = qcopServerMap->find(ch);
    if (it == qcopServerMap->end())
      it = qcopServerMap->insert(ch, QList<QWSClient*>());

    // If the channel name contains wildcard characters, then we also
    // register it on the server regexp matching list.
    if (containsWildcards( ch )) {
	QCopServerRegexp item(ch, cl);
	if (!qcopServerRegexpList)
	    qcopServerRegexpList = new QCopServerRegexpList;
	qcopServerRegexpList->append( item );
    }

    // If this is the first client in the channel, announce the channel as being created.
    if (it.value().count() == 0) {
      QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
      connect(qwsBridge, SIGNAL(newChannel(QString)), qwsServer, SIGNAL(newChannel(QString)));
      qwsBridge->emitNewChannel(ch);
      delete qwsBridge;
    }

    it.value().append(cl);
}
Example #3
0
void QCopChannel::registerChannel(const QString& ch, QCopX11Client *cl)
{
    if (!qcopServerMap)
        qcopServerMap = new QCopServerMap;

    // do we need a new channel list ?
    QCopServerMap::Iterator it = qcopServerMap->find(ch);
    if (it == qcopServerMap->end())
      it = qcopServerMap->insert(ch, QList<QCopX11Client*>());

    // If the channel name contains wildcard characters, then we also
    // register it on the server regexp matching list.
    if (containsWildcards( ch )) {
	QCopServerRegexp item(ch, cl);
	if (!qcopServerRegexpList)
	    qcopServerRegexpList = new QCopServerRegexpList;
	qcopServerRegexpList->append( item );
    }

    // If this is the first client in the channel, announce the channel as being created.
    if (it.value().count() == 0) {
      emit qcopServer->newChannel(ch);
    }

    it.value().append(cl);
}
Example #4
0
//==============================================================================
bool OSCAddressPattern::matches (const OSCAddress& address) const noexcept
{
    if (! containsWildcards())
        return asString == address.asString;

    if (oscSymbols.size() != address.oscSymbols.size())
        return false;

    for (int i = 0; i < oscSymbols.size(); ++i)
        if (! matchOscPattern (oscSymbols[i], address.oscSymbols[i]))
            return false;

    return true;
}
Example #5
0
void QCopChannel::answer(QCopX11Client */*cl*/, const QString& ch,
                          const QString& msg, const QByteArray &data)
{
    if (qcopServerMap) {
        QList<QCopX11Client*> clist = qcopServerMap->value(ch);
        for (int i=0; i < clist.size(); ++i) {
            QCopX11Client *c = clist.at(i);
	    c->send( ch, msg, data );
        }
    }

    if(qcopServerRegexpList && !containsWildcards(ch)) {
	// Search for wildcard matches and forward the message on.
	QCopServerRegexpList::ConstIterator it = qcopServerRegexpList->constBegin();
	for (; it != qcopServerRegexpList->constEnd(); ++it) {
	    if ((*it).regexp.exactMatch(ch))
		(*it).client->forward(ch, msg, data, (*it).channel);
	}
    }
}