void CHostIce::postImage( const ::Types::TByteArray & data, const ::Ice::Current & c ) { IceUtil::Mutex::Lock lock( m_mut ); bool sendList = false; for( TClientsIter i = m_clients.begin(); i != m_clients.end(); i++ ) { Client::CClientPrx & client = i->second.client; try { client->cam()->acceptImage( data, c.ctx ); } catch ( Ice::Exception & ) { sendList = true; } } if ( sendList ) { validateClientList( c ); sendClientList( c ); } }
bool CHostIce::queryCtrl( const std::string & id, const ::Ice::Current & c ) { IceUtil::Mutex::Lock lock( m_mut ); QLOG_TRACE() << "queryCtrl( " << QString::fromStdString( id ) << " )"; CClientDesc cd; if ( !client( id, cd ) ) return false; for ( TClientsConstIter i = m_clients.begin(); i != m_clients.end(); i++ ) { const CClientDesc & cd = i->second; if ( cd.access != TView ) { QLOG_TRACE() << "query refused"; return false; } } QLOG_TRACE() << "query granted"; cd.access = TCtrl; updateClient( id, cd ); validateClientList( c ); sendClientList( c ); return true; }
void CHostIce::postMessage( const std::string & id, const ::std::string & stri, const ::Ice::Current & c ) { IceUtil::Mutex::Lock lock( m_mut ); CClientDesc cd; if ( !client( id, cd ) ) return; std::ostringstream msg; msg << cd.nickname << ": \'" << stri << "\'"; QLOG_TRACE() << "postMessage( " << QString::fromUtf8( msg.str().data(), msg.str().size() ) << " )"; bool sendList = false; for ( TClientsIter j = m_clients.begin(); j != m_clients.end(); j++ ) { Client::CClientPrx client = j->second.client; try { client->chat()->acceptMessage( msg.str() ); } catch ( Ice::Exception & ) { sendList = true; } } if ( sendList ) { validateClientList( c ); sendClientList( c ); } }
void CHostIce::releaseCtrl( const std::string & id, const ::Ice::Current & c ) { IceUtil::Mutex::Lock lock( m_mut ); QLOG_TRACE() << "releaseCtrl( " << QString::fromStdString( id ) << " )"; CClientDesc cd; if ( !client( id, cd ) ) return; cd.access = TView; updateClient( id, cd ); validateClientList( c ); sendClientList( c ); }
bool CHostIce::registerClient( const ::Client::CClientPrx & client, const std::string & nickname, std::string & idOrErrMsg, const ::Ice::Current & c ) { IceUtil::Mutex::Lock lock( m_mut ); QLOG_TRACE() << "registerClient( " << QString::fromUtf8( nickname.data(), nickname.size() ) << " )"; try { //client->cam( c.ctx ); //client->ice_id( c.ctx ); if ( !nicknameUnique( nickname ) ) { std::ostringstream msg; msg << "ERROR: \"" << nickname << "\" is aready in use"; QLOG_TRACE() << QString::fromUtf8( msg.str().data(), msg.str().size() ); idOrErrMsg = msg.str(); return false; } std::string id = clientId( nickname, client ); if ( hasClient( id ) ) { std::ostringstream msg; msg << "ERROR: your client id is \"" << id << "\", it is aready in use. Failed to add client."; QLOG_TRACE() << QString::fromUtf8( msg.str().data(), msg.str().size() ); idOrErrMsg = msg.str(); return false; } QLOG_TRACE() << "Assigned id: " << QString::fromStdString( id ); CClientDesc cd( nickname, client ); idOrErrMsg = id; addClient( id, cd ); validateClientList( c ); sendClientList( c ); return true; } catch( const Ice::Exception & ex ) { QLOG_TRACE() << "Exception: " << ex.toString().c_str(); idOrErrMsg = ex.toString().c_str(); fprintf(stderr, "%s\n", ex.toString().c_str()); } return false; }
bool CHostIce::querySuper( const std::string & id, const ::std::string & passwd, const ::Ice::Current & c ) { IceUtil::Mutex::Lock lock( m_mut ); QLOG_TRACE() << "querySuper( " << QString::fromStdString( id ) << " )"; if ( m_owner->m_passwd != passwd ) { QLOG_TRACE() << "wrong password"; return false; } CClientDesc cd; if ( !client( id, cd ) ) return false; bool modified; do { modified = false; for ( TClientsIter i = m_clients.begin(); i != m_clients.end(); i++ ) { if ( id != i->first ) { CClientDesc & cd = i->second; if ( cd.access != TView ) { cd.access = TView; modified = true; } } } } while ( modified ); QLOG_TRACE() << "super privilegies granted"; cd.access = TSuper; updateClient( id, cd ); validateClientList( c ); sendClientList( c ); return true; }
void RfbClientManager::onClientTerminate() { validateClientList(); }