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);
}
Esempio n. 2
0
QSharedPointer<Channel> QueryExecutor::insertNewChannel(const QSharedPointer<Channel>& channel)
{
  bool result;
  QSqlQuery newChannelQuery(m_database);
  qlonglong newId = nextChannelKey();
  syslog(LOG_INFO,"NewId ready, now preparing sql query for adding new channel");
  newChannelQuery.prepare("insert into channel (id,name,description,url) values(:id,:name,:description,:url);");
  newChannelQuery.bindValue(":id",newId);
  newChannelQuery.bindValue(":name",channel->getName());
  newChannelQuery.bindValue(":description",channel->getDescription());
  newChannelQuery.bindValue(":url",channel->getUrl());

  m_database.transaction();

  result=newChannelQuery.exec();
  if(!result)
  {
    syslog(LOG_INFO,"Rollback for NewChannel sql query");
    m_database.rollback();
    return QSharedPointer<Channel>(NULL);
  }else
  syslog(LOG_INFO,"Commit for NewChannel sql query - insert in table channel");

  m_database.commit();

  QSharedPointer<DbChannel> newChannel(new DbChannel(newId,channel->getName(),channel->getDescription(),channel->getUrl()));
  return newChannel;
}
Esempio n. 3
0
HTTPClientChannel::Ptr HTTPClientChannel::newHTTP2Channel(
    apache::thrift::async::TAsyncTransport::UniquePtr transport,
    const std::string& host,
    const std::string& url) {
  return newChannel(std::move(transport),
                    host,
                    url,
                    folly::make_unique<proxygen::HTTP2Codec>(
                        proxygen::TransportDirection::UPSTREAM));
}
Esempio n. 4
0
HTTPClientChannel::Ptr HTTPClientChannel::newHTTP1xChannel(
    apache::thrift::async::TAsyncTransport::UniquePtr transport,
    const std::string& host,
    const std::string& url) {
  auto channel = newChannel(std::move(transport),
                            host,
                            url,
                            folly::make_unique<proxygen::HTTP1xCodec>(
                                proxygen::TransportDirection::UPSTREAM));
  channel->setProtocolId(apache::thrift::protocol::T_BINARY_PROTOCOL);

  return channel;
}
Esempio n. 5
0
void SSH2Channel::channelOpened()
{
    m_in->getUInt8();
    Channel * target = m_channelList.at(m_in->getUInt32());
    target->remoteID = m_in->getUInt32();
    target->remoteWindow = m_in->getUInt32();
    target->remotePacketSize = m_in->getUInt32();
    m_in->atEnd();
    emit newChannel(target->localID);
#ifdef SSH_DEBUG
    qDebug() << "ID: " << target->localID << target->remoteID << "windows size: " << target->localWindow << target->remoteWindow << "packet size: " << target->localPacketSize << target->remotePacketSize;
#endif
    requestPty(target->localID);
}
Esempio n. 6
0
int RpcConnection::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: incomingMessage((*reinterpret_cast< QVariantMap(*)>(_a[1])),(*reinterpret_cast< RpcChannel*(*)>(_a[2]))); break;
        case 1: channelOpened((*reinterpret_cast< RpcChannel*(*)>(_a[1]))); break;
        case 2: channelClosed((*reinterpret_cast< RpcChannel*(*)>(_a[1]))); break;
        case 3: unregisterSender(); break;
        case 4: sendMessage((*reinterpret_cast< QVariantMap(*)>(_a[1])),(*reinterpret_cast< RpcChannel*(*)>(_a[2]))); break;
        case 5: sendMessage((*reinterpret_cast< QVariantMap(*)>(_a[1]))); break;
        case 6: newChannel((*reinterpret_cast< RpcChannel*(*)>(_a[1]))); break;
        case 7: channelIncomingMessage((*reinterpret_cast< QVariantMap(*)>(_a[1]))); break;
        case 8: channelDisconnected((*reinterpret_cast< RpcChannel*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 9;
    }
    return _id;
}
Esempio n. 7
0
bool Channels::addChannel(ValueTree channel_store)
{
DEBUG_TRACE_ADD_CHANNEL_GUI_FAIL

  // ensure GUI for this channel does not already exist
  Identifier channel_id = channel_store.getType() ;
  if (!channel_store.isValid() || getChannel(channel_id)) return false ;

  // hide stereo slave channels
  if (int(channel_store[CONFIG::STEREO_ID]) == CONFIG::STEREO_R) return false ;

  // create channel GUI
  Channel* channel = newChannel(channel_store) ;
  addChildAndSetID(channel , String(channel_id)) ;
  channel->toFront(false) ;

  // resize and shift channel slices
  resized() ;

DEBUG_TRACE_ADD_CHANNEL_GUI

  return true ;
}
void QWSServerSignalBridge::emitNewChannel(const QString& channel){
  emit newChannel(channel);
}
Esempio n. 9
0
ChannelHandle SoundManager::playAudioStream(AudioStream *audStream, SoundType type, bool disposeAfterUse) {
	assert((type >= 0) && (type < kSoundTypeMAX));

	checkReady();

	if (!audStream)
		throw Common::Exception("No audio stream");

	Common::StackLock lock(_mutex);

	ChannelHandle handle = newChannel();

	_channels[handle.channel] = new Channel;
	Channel &channel = *_channels[handle.channel];

	channel.id              = handle.id;
	channel.state           = AL_PAUSED;
	channel.stream          = audStream;
	channel.source          = 0;
	channel.disposeAfterUse = disposeAfterUse;
	channel.type            = type;
	channel.typeIt          = _types[channel.type].list.end();
	channel.gain            = 1.0;

	try {

		if (!channel.stream)
			throw Common::Exception("Could not detect stream type");

		ALenum error = AL_NO_ERROR;

		if (_hasSound) {
			// Create the source
			alGenSources(1, &channel.source);
			if ((error = alGetError()) != AL_NO_ERROR)
				throw Common::Exception("OpenAL error while generating sources: %X", error);

			// Create all needed buffers
			for (int i = 0; i < kOpenALBufferCount; i++) {
				ALuint buffer;

				alGenBuffers(1, &buffer);
				if ((error = alGetError()) != AL_NO_ERROR)
					throw Common::Exception("OpenAL error while generating buffers: %X", error);

				if (fillBuffer(channel.source, buffer, channel.stream)) {
					// If we could fill the buffer with data, queue it

					alSourceQueueBuffers(channel.source, 1, &buffer);
					if ((error = alGetError()) != AL_NO_ERROR)
						throw Common::Exception("OpenAL error while queueing buffers: %X", error);

				} else
					// If not, put it into our free list
					channel.freeBuffers.push_back(buffer);

				channel.buffers.push_back(buffer);
			}

			// Set the gain to the current sound type gain
			alSourcef(channel.source, AL_GAIN, _types[channel.type].gain);
		}

		// Add the channel to the correct type list
		_types[channel.type].list.push_back(&channel);
		channel.typeIt = --_types[channel.type].list.end();

	} catch (...) {
		freeChannel(handle);
		throw;
	}

	return handle;
}