Ejemplo n.º 1
0
LucidaServiceClient *TClient::creatLucidaClient(string host, int port) {
	boost::shared_ptr<TTransport> socket(new TSocket(host, port));
	boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
	boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
	LucidaServiceClient *client = new LucidaServiceClient(protocol);
	transport->open();
	return client;
}
Ejemplo n.º 2
0
CommandDef *JabberClient::configWindows()
{
    QString name = i18n(protocol()->description()->text);
    name += " ";
    name += QString::fromUtf8(data.owner.ID);
    cfgJabberWnd[0].text_wrk = strdup(name.utf8());
    return cfgJabberWnd;
}
Ejemplo n.º 3
0
already_AddRefed<nsITransportProvider>
HttpServer::Connection::HandleAcceptWebSocket(const Optional<nsAString>& aProtocol,
                                              ErrorResult& aRv)
{
  MOZ_ASSERT(mPendingWebSocketRequest);

  RefPtr<InternalResponse> response =
    new InternalResponse(101, NS_LITERAL_CSTRING("Switching Protocols"));

  InternalHeaders* headers = response->Headers();
  headers->Set(NS_LITERAL_CSTRING("Upgrade"),
               NS_LITERAL_CSTRING("websocket"),
               aRv);
  headers->Set(NS_LITERAL_CSTRING("Connection"),
               NS_LITERAL_CSTRING("Upgrade"),
               aRv);
  if (aProtocol.WasPassed()) {
    NS_ConvertUTF16toUTF8 protocol(aProtocol.Value());
    nsAutoCString reqProtocols;
    mPendingWebSocketRequest->Headers()->
      GetFirst(NS_LITERAL_CSTRING("Sec-WebSocket-Protocol"), reqProtocols, aRv);
    if (!ContainsToken(reqProtocols, protocol)) {
      // Should throw a better error here
      aRv.Throw(NS_ERROR_FAILURE);
      return nullptr;
    }

    headers->Set(NS_LITERAL_CSTRING("Sec-WebSocket-Protocol"),
                 protocol, aRv);
  }

  nsAutoCString key, hash;
  mPendingWebSocketRequest->Headers()->
    GetFirst(NS_LITERAL_CSTRING("Sec-WebSocket-Key"), key, aRv);
  nsresult rv = mozilla::net::CalculateWebSocketHashedSecret(key, hash);
  if (NS_FAILED(rv)) {
    aRv.Throw(rv);
    return nullptr;
  }
  headers->Set(NS_LITERAL_CSTRING("Sec-WebSocket-Accept"), hash, aRv);

  nsAutoCString extensions, negotiatedExtensions;
  mPendingWebSocketRequest->Headers()->
    GetFirst(NS_LITERAL_CSTRING("Sec-WebSocket-Extensions"), extensions, aRv);
  mozilla::net::ProcessServerWebSocketExtensions(extensions,
                                                 negotiatedExtensions);
  if (!negotiatedExtensions.IsEmpty()) {
    headers->Set(NS_LITERAL_CSTRING("Sec-WebSocket-Extensions"),
                 negotiatedExtensions, aRv);
  }

  RefPtr<TransportProvider> result = new TransportProvider();
  mWebSocketTransportProvider = result;

  QueueResponse(response);

  return result.forget();
}
Ejemplo n.º 4
0
inline void complexThrift_6()
{
	boost::timer::auto_cpu_timer t;

	thriftPerformance::complexThrift_6 input = thriftPerformance::complexThrift_6(), output;
	input.__set_att1(1);
	input.__set_att2(2);
	input.__set_att3(3);
	input.__set_att4(4);
	input.__set_att5(5);
	input.__set_att6(6);
	input.__set_att1(0);
	input.__set_att2(1);
	input.__set_att3(2);
	input.__set_att4(3);
	input.__set_att5(4);
	input.__set_att6(5);
	input.__set_att7(0);
	input.__set_att8(1);
	input.__set_att9(2);
	input.__set_att10(3);
	input.__set_att11(4);
	input.__set_att12(5);
	input.__set_att13("TEST 0");
	input.__set_att14("TEST 1");
	input.__set_att15("TEST 2");
	input.__set_att16("TEST 3");
	input.__set_att17("TEST 4");
	input.__set_att18("TEST 5");
	input.__set_att19(2.0);
	input.__set_att20(3.1);
	input.__set_att21(4.2);
	input.__set_att22(5.3);
	input.__set_att23(6.4);
	input.__set_att24(7.5);
	input.__set_att25(8.5);
	input.__set_att26(9.6);
	input.__set_att27(10.7);
	input.__set_att28(11.8);
	input.__set_att29(12.9);
	input.__set_att30(13.10);
	input.__set_att31(true);
	input.__set_att32(true);
	input.__set_att33(true);
	input.__set_att34(true);
	input.__set_att35(true);
	input.__set_att36(true);

	boost::shared_ptr<TMemoryBuffer> mb(new TMemoryBuffer(500));
	boost::shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(mb));

	for(int i = 0; i < NUMBER_OF_LOOPS; ++i)
	{
		mb->resetBuffer();
		input.write(protocol.get());
		output.read(protocol.get());
	}
}
Ejemplo n.º 5
0
void AIMContact::updateSSIItem()
{
	if ( m_ssiItem.type() != 0xFFFF && m_ssiItem.waitingAuth() == false &&
	     onlineStatus() == Kopete::OnlineStatus::Unknown )
	{
		//make sure they're offline
		setOnlineStatus( static_cast<AIMProtocol*>( protocol() )->statusOffline );
	}
}
Ejemplo n.º 6
0
inline void innercomplexThrift_2()
{
	boost::timer::auto_cpu_timer t;

	thriftPerformance::innercomplexThrift_2 inner1 = thriftPerformance::innercomplexThrift_2();
	inner1.__set_att1(1);
	inner1.__set_att2(2);
	inner1.__set_att3(3);
	inner1.__set_att4(4);
	inner1.__set_att5("TEST 5");
	inner1.__set_att6("TEST 6");
	inner1.__set_att7(2.5);
	inner1.__set_att8(3.6);
	inner1.__set_att9(6.2);
	inner1.__set_att10(7.3);
	inner1.__set_att11(true);
	inner1.__set_att12(true);

	thriftPerformance::innercomplexThrift_2 inner2 = thriftPerformance::innercomplexThrift_2();
	inner2.__set_att1(1);
	inner2.__set_att2(2);
	inner2.__set_att3(3);
	inner2.__set_att4(4);
	inner2.__set_att5("TEST 5");
	inner2.__set_att6("TEST 6");
	inner2.__set_att7(2.5);
	inner2.__set_att8(3.6);
	inner2.__set_att9(6.2);
	inner2.__set_att10(7.3);
	inner2.__set_att11(true);
	inner2.__set_att12(true);

	thriftPerformance::outercomplexThrift_2 input = thriftPerformance::outercomplexThrift_2(), output = thriftPerformance::outercomplexThrift_2();
	input.__set_att1(1);
	input.__set_att2(2);
	input.__set_att3("OUTER TEST 3");
	input.__set_att4(inner1);
	input.__set_att5(3.6);
	input.__set_att6(7.3);
	input.__set_att7(true);
	input.__set_att8(8);
	input.__set_att9("OUTER TEST 9");
	input.__set_att10(inner2);
	input.__set_att11(4.7);
	input.__set_att12(8.4);
	input.__set_att13(true);

	boost::shared_ptr<TMemoryBuffer> mb(new TMemoryBuffer(500));
	boost::shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(mb));

	for(int i = 0; i < NUMBER_OF_LOOPS; ++i)
	{
		mb->resetBuffer();
		input.write(protocol.get());
		output.read(protocol.get());
	}
}
Ejemplo n.º 7
0
Kopete::ChatSession *
    WlmContact::manager (Kopete::Contact::CanCreateFlags canCreate)
{
    Kopete::ContactPtrList chatmembers;
    chatmembers.append (this);

    Kopete::ChatSession * _manager =
        Kopete::ChatSessionManager::self ()->
				findChatSession (account ()->myself (), chatmembers, protocol ());
    WlmChatSession *manager = qobject_cast <WlmChatSession *>(_manager);
    if (!manager && canCreate == Kopete::Contact::CanCreate)
    {
        manager =
            new WlmChatSession (protocol (), account ()->myself (),
                                chatmembers);
    }
    return manager;
}
Ejemplo n.º 8
0
boost::tuple<std::string, std::string, std::string, std::string>
HttpRequest::ParseUrl(const std::string & url)
{
    //for remove regex lib
    size_t pos_protocol = url.find("://");
    std::string protocol("http");
    if (pos_protocol != std::string::npos)
    {
        protocol = url.substr(0, pos_protocol);
    }

    size_t pos_host_beg = (pos_protocol == std::string::npos ? 0 : pos_protocol +3);
    size_t pos_path_beg = -1;
    std::string host_str("");
    std::string port_str("80");
    size_t pos_host = url.find_first_of(':', pos_host_beg);
    size_t pos_slash = url.find_first_of('/', pos_host_beg);
    if (pos_host != std::string::npos && pos_host < pos_slash)
    {
        host_str = url.substr(pos_host_beg, pos_host - pos_host_beg);
        size_t pos_port_beg = pos_host + 1;
        size_t pos_port = url.find_first_of('/', pos_port_beg);
        if (pos_port != std::string ::npos)
        {
            port_str = url.substr(pos_port_beg, pos_port - pos_port_beg);
            pos_path_beg = pos_port;
        }
    }
    else {
        pos_host = url.find_first_of('/', pos_host_beg);
        if (pos_host != std::string::npos)
        {
            host_str = url.substr(pos_host_beg, pos_host - pos_host_beg);
            pos_path_beg = pos_host;
        }
    }

    std::string path_str("");
    if (pos_path_beg > 0)
        path_str = url.substr(pos_path_beg);

    //boost::regex reg("^(([A-Za-z]+)://)?([^:/]+)(:([0-9]+))?(.*)");
    //boost::smatch sm;

    //if (false == boost::regex_match(url, sm, reg))
    //{
    //    return boost::make_tuple("", "", "", "");
    //}

    //std::string protocol(sm[2].matched ? std::string(sm[2].first, sm[2].second) : "http");
    //std::string host_str(sm[3].first, sm[3].second);
    //std::string port_str(sm[5].matched ? std::string(sm[5].first, sm[5].second) : "");
    //std::string path_str(sm[6].matched ? std::string(sm[6].first, sm[6].second) : "/");
    if (path_str.empty()) path_str = "/";

    return boost::make_tuple(protocol, host_str, port_str, path_str);
}
Ejemplo n.º 9
0
CommandDef *JabberClient::infoWindows(Contact*, void *_data)
{
    JabberUserData *data = (JabberUserData*)_data;
    QString name = i18n(protocol()->description()->text);
    name += " ";
    name += QString::fromUtf8(data->ID);
    jabberWnd[0].text_wrk = strdup(name.utf8());
    return jabberWnd;
}
Ejemplo n.º 10
0
SchedulerServiceClient *TClient::creatSchedulerClient(string host, int port) {
    boost::shared_ptr<TSocket> socket(new TSocket(host, port));
    boost::shared_ptr<TTransport> transport(new TFramedTransport(socket));
    boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
    SchedulerServiceClient *client = new SchedulerServiceClient(protocol);
    this->transport = transport;
    transport->open();
    return client;
}
Ejemplo n.º 11
0
QString JabberClient::contactTip(void *_data)
{
    JabberUserData *data = (JabberUserData*)_data;
    QString res;
    QString statusText;
    unsigned long status = STATUS_OFFLINE;
    unsigned style  = 0;
    const char *statusIcon = NULL;
    contactInfo(data, status, style, statusIcon);
    if (statusIcon){
        res += "<img src=\"icon:";
        res += statusIcon;
        res += "\">";
        for (const CommandDef *cmd = protocol()->statusList(); cmd->text; cmd++){
            if (!strcmp(cmd->icon, statusIcon)){
                res += " ";
                statusText += i18n(cmd->text);
                res += statusText;
                break;
            }
        }
        res += "<br>";
    }
    res += "ID: <b>";
    res += QString::fromUtf8(data->ID);
    res += "</b>";
    if (data->Status == STATUS_OFFLINE){
        if (data->StatusTime){
            res += "<br><font size=-1>";
            res += i18n("Last online");
            res += ": </font>";
            res += formatTime(data->StatusTime);
        }
    }else{
        if (data->OnlineTime){
            res += "<br><font size=-1>";
            res += i18n("Online");
            res += ": </font>";
            res += formatTime(data->OnlineTime);
        }
        if (data->StatusTime != data->OnlineTime){
            res += "<br><font size=-1>";
            res += statusText;
            res += ": </font>";
            res += formatTime(data->StatusTime);
        }
    }
    if (data->Resource && *data->Resource){
        res += "<br>";
        res += QString::fromUtf8(data->Resource);
    }
    if (data->AutoReply && *data->AutoReply){
        res += "<br><br>";
        res += QString::fromUtf8(data->AutoReply);
    }
    return res;
}
Ejemplo n.º 12
0
CommandDef *YahooClient::infoWindows(Contact*, void *_data)
{
    YahooUserData *data = (YahooUserData*)_data;
    QString name = i18n(protocol()->description()->text);
    name += " ";
    name += QString::fromUtf8(data->Login.ptr);
    yahooWnd[0].text_wrk = strdup(name.utf8());
    return yahooWnd;
}
Ejemplo n.º 13
0
inline void simpleThrift_40()
{
	thriftPerformance::simpleThrift_40 input = thriftPerformance::simpleThrift_40(), output;
	input.__set_att1(1);
	input.__set_att2(2);
	input.__set_att3(3);
	input.__set_att4(4);
	input.__set_att5(5);
	input.__set_att6(6);
	input.__set_att7(7);
	input.__set_att8(8);
	input.__set_att9(9);
	input.__set_att10(10);
	input.__set_att11(11);
	input.__set_att12(12);
	input.__set_att13(13);
	input.__set_att14(14);
	input.__set_att15(15);
	input.__set_att16(16);
	input.__set_att17(17);
	input.__set_att18(18);
	input.__set_att19(19);
	input.__set_att20(20);
	input.__set_att21(21);
	input.__set_att22(22);
	input.__set_att23(23);
	input.__set_att24(24);
	input.__set_att25(25);
	input.__set_att26(26);
	input.__set_att27(27);
	input.__set_att28(28);
	input.__set_att29(29);
	input.__set_att30(30);
	input.__set_att31(31);
	input.__set_att32(32);
	input.__set_att33(33);
	input.__set_att34(34);
	input.__set_att35(35);
	input.__set_att36(36);
	input.__set_att37(37);
	input.__set_att38(38);
	input.__set_att39(39);
	input.__set_att40(40);

	boost::shared_ptr<TMemoryBuffer> mb(new TMemoryBuffer(500));
	boost::shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(mb));

	boost::timer::auto_cpu_timer t;

	for(int i = 0; i < NUMBER_OF_LOOPS; ++i)
	{
		mb->resetBuffer();
		input.write(protocol.get());
		output.read(protocol.get());
	}
}
Ejemplo n.º 14
0
void ut_cstunbinding::SetupL(  )
    {
    iCallbackCalled = EFalse;
    TUint iapID( 6 );
    TInt retransmitInterval( 10 );
    TBufC8<13> serveraddress( KServerAddress );
    TUint serverport( 2000 );
    TBufC8<4> protocol( KStun );
    TBool obtainsharedsecret( EFalse );
    TBool failifnoSRVrecordfound( EFalse );
    iDeltatimer = CDeltaTimer::NewL( 1 );
    User::LeaveIfError( iSocketServ.Connect() );
    iStreamId = 1;
    iSubstreamId = 1;
    TBool icmpUsed( EFalse );
    
    iMux = CNcmConnectionMultiplexer::NewL( *this );
    
    TCommDbConnPref pref;
    pref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
    pref.SetIapId( iapID );
    
    User::LeaveIfError( iConnection.Open( iSocketServ ) );
    iConnection.Start( pref, iStatus );
    User::WaitForRequest( iStatus );
    User::LeaveIfError( iStatus.Int() );    
    
    iStunclient = CSTUNClient::NewL( retransmitInterval,
                                     serveraddress,
                                     serverport,
                                     protocol,
                                     iSocketServ,
                                     iConnection,
                                     *iDeltatimer,
                                     *this,
                                     obtainsharedsecret,
                                     failifnoSRVrecordfound,
                                     icmpUsed,
                                     iMux );
                                     
    if ( ut_cstunbinding::iActiveSchedulerWait.IsStarted() )
        {
        ut_cstunbinding::iActiveSchedulerWait.AsyncStop();
        }
    ut_cstunbinding::iActiveSchedulerWait.Start(); 
    if ( !iCallbackCalled )
        {
        // Callback not called because of memory running out inside callback execution
        User::Leave( KErrNoMemory );
        }
    
    User::LeaveIfError( iSocket.Open( iSocketServ, KAfInet, KSockDatagram,
                                     KProtocolInetUdp ));

    iBinding = CSTUNBinding::NewL( *iStunclient, iSocket );
    }
Ejemplo n.º 15
0
NOEXPORT void client_try(CLI *c) {
    init_local(c);
    if(!c->opt->option.client && c->opt->protocol<0
#ifndef OPENSSL_NO_TLSEXT
            && !c->opt->servername_list_head
#endif
            ) {
        /* server mode and no protocol negotiation needed */
        init_ssl(c);
        init_remote(c);
    } else { /* client mode or protocol negotiation enabled */
        protocol(c, PROTOCOL_PRE_CONNECT);
        init_remote(c);
        protocol(c, PROTOCOL_PRE_SSL);
        init_ssl(c);
        protocol(c, PROTOCOL_POST_SSL);
    }
    transfer(c);
}
Ejemplo n.º 16
0
KURL NetworkAccount::getUrl() const
{
    KURL url;
    url.setProtocol(protocol());
    url.setUser(login());
    url.setPass(passwd());
    url.setHost(host());
    url.setPort(port());
    return url;
}
Ejemplo n.º 17
0
NS_IMETHODIMP
nsGNOMEShellService::SetDefaultClient(bool aForAllUsers,
                                      bool aClaimAllTypes, uint16_t aApps)
{
  nsresult rv;

  nsCOMPtr<nsIGIOMimeApp> app;
  nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  if (giovfs) {
    nsCString brandName;
    rv = GetBrandName(brandName);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = giovfs->CreateAppFromCommand(mAppPath, brandName, getter_AddRefs(app));
    NS_ENSURE_SUCCESS(rv, rv);

    for (unsigned i = 0; i < mozilla::ArrayLength(gMimeTypes); i++) {
      if (aApps & gMimeTypes[i].app) {
        rv = app->SetAsDefaultForMimeType(nsDependentCString(gMimeTypes[i].mimeType));
        NS_ENSURE_SUCCESS(rv, rv);
        rv = app->SetAsDefaultForFileExtensions(nsDependentCString(gMimeTypes[i].extensions));
        NS_ENSURE_SUCCESS(rv, rv);
      }
    }
  }

  nsCString appKeyValue;
  nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
  if (gconf) {
    if (!mAppIsInPath)
      appKeyValue = mAppPath;
    else {
      gchar* basename = g_path_get_basename(mAppPath.get());
      appKeyValue = basename;
      g_free(basename);
    }
    appKeyValue.AppendLiteral(" %s");
  }

  for (unsigned i = 0; i < mozilla::ArrayLength(gProtocols); i++) {
    if (aApps & gProtocols[i].app) {
      nsDependentCString protocol(gProtocols[i].protocol);
      if (app) {
        rv = app->SetAsDefaultForURIScheme(protocol);
        NS_ENSURE_SUCCESS(rv, rv);
      }
      if (gconf) {
        rv = gconf->SetAppForProtocol(protocol, appKeyValue);
        NS_ENSURE_SUCCESS(rv, rv);
      }
    }
  }

  return NS_OK;
}
Ejemplo n.º 18
0
SegmentType IPv6Packet<FrameType>::segmentType() const {
	switch (protocol()) {
	  case IPPROTO_TCP:
		return SEGMENT_TCP;

	  case IPPROTO_UDP:
		return SEGMENT_UDP;
	}

	return SEGMENT_UNKNOWN;
}
Ejemplo n.º 19
0
int main( int ac, char** av )
{
    comma::command_line_options options( ac, av, usage );
    try
    {
        raw=options.exists("--raw");
        timestamp=options.exists("--timestamp");
        if(options.exists("--output-size"))
        {
            std::size_t size=snark::asd::commands::acquire_data::spectrum_data::size;
            if (timestamp) { size += sizeof(boost::posix_time::ptime);}
            std::cout<< size << std::endl;
            return 0;
        }
        if(timestamp && !raw) { COMMA_THROW(comma::exception, "--timestamp option only works with --raw");}
        comma::verbose<<"asd-control"<<std::endl;
        std::vector<std::string> unnamed=options.unnamed("--verbose,-v,--raw,--timestamp,--strict,--acquire,--omit-new-line", "--timeout,--sleep");
        if(unnamed.size() != 1) { COMMA_THROW(comma::exception, "expected address (one unnamed arg); got " << unnamed.size() ); }
        strict=options.exists("--strict");
        acquire=options.exists("--acquire");
        bool omit_new_line=options.exists("--omit-new-line");
        snark::asd::protocol protocol(unnamed[0], options.value("--timeout",0));
        sleep_seconds=options.value("--sleep",0);
        while(std::cin.good())
        {
            //comma::verbose<<"reading stdin..."<<std::endl;
            std::string cmd;
            std::getline( std::cin, cmd );
            if( cmd.empty() ) { continue; }
            if(!omit_new_line) { cmd += '\n'; }
            comma::verbose<<"sending command: "<<cmd<<std::endl;
            bool processed =  process_acquire_data(protocol,cmd)
                || app<snark::asd::commands::version>::process(protocol,cmd)
                || app<snark::asd::commands::abort>::process(protocol,cmd)
                || app<snark::asd::commands::restore>::process(protocol,cmd)
                || app<snark::asd::commands::optimize>::process(protocol,cmd)
                || app<snark::asd::commands::init>::process(protocol,cmd)
                || app<snark::asd::commands::save>::process(protocol,cmd)
                || app<snark::asd::commands::erase>::process(protocol,cmd)
                || app<snark::asd::commands::instrument_gain_control>::process(protocol,cmd);
            if ( !processed ) { COMMA_THROW(comma::exception, "invalid command " << cmd );  }
        }
        return 0;
    }
    catch( std::exception& ex )
    {
        std::cerr << comma::verbose.app_name() << ": " << ex.what() << std::endl;
    }
    catch( ... )
    {
        std::cerr << comma::verbose.app_name() << ": " << "unknown exception" << std::endl;
    }
    return 1;
}
Ejemplo n.º 20
0
    void WirelessNode_Impl::erase()
    {
        //call the node_erase command from the parent BaseStation
        bool success = m_baseStation.node_erase(protocol(), m_address);

        //if the erase command failed
        if(!success)
        {
            throw Error_NodeCommunication(m_address, "Failed to erase the Node.");
        }
    }
Ejemplo n.º 21
0
QString CEndPoint::toStringWithPort() const
{
	if ( protocol() == QAbstractSocket::IPv4Protocol )
	{
		return toString().append( QString( ":%1" ).arg( m_nPort ) );
	}
	else
	{
		return QString( "[%1]:%2" ).arg( toString() ).arg( m_nPort );
	}
}
Ejemplo n.º 22
0
void JabberClient::packet_ready()
{
    if (m_socket->readBuffer.writePos() == 0)
        return;
    JabberPlugin *plugin = static_cast<JabberPlugin*>(protocol()->plugin());
    log_packet(m_socket->readBuffer, false, plugin->JabberPacket);
    if (XML_Parse(m_parser,
                  m_socket->readBuffer.data(), m_socket->readBuffer.writePos(), false) != XML_STATUS_OK)
        m_socket->error_state("XML parse error");
    m_socket->readBuffer.init(0);
    m_socket->readBuffer.packetStart();
}
LogStream*
LogStreamFactory::create (FiltersFactory* ff, string location,
                          list<string>& filters, u_long cycle)
{
  string protocol (getProtocol (location));
  string path (getPath (location));
  if (protocolCheck (protocol))
    {
      return creators[protocol]->create (ff, path, filters, cycle);
    }
  return 0;
}
Ejemplo n.º 24
0
AIMContact::AIMContact( Kopete::Account* account, const QString& name, Kopete::MetaContact* parent,
                        const QString& icon )
: AIMContactBase(account, name, parent, icon )
{
	mProtocol=static_cast<ICQProtocol *>(protocol());
	setPresenceTarget( Oscar::Presence( Oscar::Presence::Offline, Oscar::Presence::AIM ) );

	QObject::connect( mAccount->engine(), SIGNAL(receivedUserInfo(QString,UserDetails)),
	                  this, SLOT(userInfoUpdated(QString,UserDetails)) );
	QObject::connect( mAccount->engine(), SIGNAL(userIsOffline(QString)),
	                  this, SLOT(userOffline(QString)) );
}
Ejemplo n.º 25
0
    NodeEeprom& WirelessNode_Impl::eeprom() const
    {
        //if the eeprom variable hasn't been set yet
        if(m_eeprom == NULL)
        {
            //create the eeprom variable
            //Note that this requires communicating with the Node via the protocol() function
            m_eeprom.reset(new NodeEeprom(m_address, m_baseStation, protocol(), m_eepromSettings));
        }

        return *(m_eeprom.get());
    }
Ejemplo n.º 26
0
/*!
 * \brief Open connection to Cassandra cluster
 * \param db_id
 */
oac::CassandraClient* dbcassa_open(struct db_id* id)
{
	try {
		boost::shared_ptr<att::TSocket> socket(new att::TSocket(id->host, id->port));
		boost::shared_ptr<att::TTransport> transport(new att::TFramedTransport (socket));
		boost::shared_ptr<atp::TProtocol> protocol(new atp::TBinaryProtocol(transport));

		socket->setConnTimeout(cassa_conn_timeout);
		socket->setSendTimeout(cassa_send_timeout);
		socket->setRecvTimeout(cassa_recv_timeout);

		std::auto_ptr<oac::CassandraClient> cassa_client(new oac::CassandraClient(protocol));

		transport->open();
		if (!transport->isOpen()) {
			LM_ERR("Failed to open transport to Cassandra\n");
			return 0;
		}

		/* database name ->  keyspace */

		cassa_client->set_keyspace(id->database);
		if(id->username && id->password) {
			oac::AuthenticationRequest au_req;
			std::map<std::string, std::string>  cred;
			cred.insert(std::pair<std::string, std::string>("username", id->username));
			cred.insert(std::pair<std::string, std::string>("password", id->password));
			au_req.credentials = cred;
			try {
				cassa_client->login(au_req);
			} catch (const oac::AuthenticationException& autx) {
				LM_ERR("Authentication failure: Credentials not valid, %s\n", autx.why.c_str());
			} catch (const oac::AuthorizationException & auzx) {
				LM_ERR("Authentication failure: Credentials not valid for the selected database, %s\n", auzx.why.c_str());
			}
		}

		LM_DBG("Opened connection to Cassandra cluster  %s:%d\n", id->host, id->port);
		return cassa_client.release();

	} catch (const oac::InvalidRequestException &irx) {
		LM_ERR("Database does not exist %s, %s\n", id->database, irx.why.c_str());
	} catch (const at::TException &tx) {
		LM_ERR("Failed to open connection to Cassandra cluster %s:%d, %s\n",
				id->database, id->port, tx.what());
	} catch (const std::exception &ex) {
		LM_ERR("Failed: %s\n", ex.what());
	} catch (...) {
		LM_ERR("Failed to open connection to Cassandra cluster\n");
	}

	return 0;
}
Ejemplo n.º 27
0
std::auto_ptr<BackupProtocolCallable> connect_to_bbstored(TLSContext& rContext)
{
	// Make a protocol
	std::auto_ptr<BackupProtocolCallable> protocol(new
		BackupProtocolClient(open_conn("localhost", rContext)));
	
	// Check the version
	std::auto_ptr<BackupProtocolVersion> serverVersion(
		protocol->QueryVersion(BACKUP_STORE_SERVER_VERSION));
	TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);

	return protocol;
}
Ejemplo n.º 28
0
QString Cloud::debugInfo() const
{
    QString info;
    info += QLatin1String("### Cloud: ###################\n");
    if (!domain().isNull()) {
        info += QLatin1String("domain: #") + domain() + QLatin1String("#\n");
    }
    if (port() != -1) {
        info += QLatin1String("port: #") + QString::number(port()) + QLatin1String("#\n");
    }
    if (!path().isNull()) {
        info += QLatin1String("path: #") + path() + QLatin1String("#\n");
    }
    if (!registerProcedure().isNull()) {
        info += QLatin1String("registerProcedure: #") + registerProcedure() + QLatin1String("#\n");
    }
    if (!protocol().isNull()) {
        info += QLatin1String("protocol: #") + protocol() + QLatin1String("#\n");
    }
    info += QLatin1String("### Cloud end ################\n");
    return info;
}
Ejemplo n.º 29
0
  uint32_t CConnection::sendProtocol(
      const EMessageType type, const std::shared_ptr<IMessage>& message)
  {

    uint16_t idConcentrator = NEngine::CConfigurationFactory::getInstance()->getIdConcentrator();

    CProtocol protocol(VERSION, 0,
                       idConcentrator,
                       ++idPackageBase, type, message);

    thread.addToSendingQueue(protocol);
    return idPackageBase;
  }
Ejemplo n.º 30
0
void YahooClient::contactInfo(void *_data, unsigned long &status, unsigned&, const char *&statusIcon, string *icons)
{
    YahooUserData *data = (YahooUserData*)_data;
    unsigned cmp_status = STATUS_OFFLINE;
    switch (data->Status.value) {
    case YAHOO_STATUS_AVAILABLE:
        cmp_status = STATUS_ONLINE;
        break;
    case YAHOO_STATUS_BUSY:
        cmp_status = STATUS_DND;
        break;
    case YAHOO_STATUS_NOTATHOME:
    case YAHOO_STATUS_NOTATDESK:
    case YAHOO_STATUS_NOTINOFFICE:
    case YAHOO_STATUS_ONVACATION:
        cmp_status = STATUS_NA;
        break;
    case YAHOO_STATUS_OFFLINE:
        break;
    case YAHOO_STATUS_CUSTOM:
        cmp_status = data->bAway.bValue ? STATUS_AWAY : STATUS_ONLINE;
        break;
    default:
        cmp_status = STATUS_AWAY;
    }

    const CommandDef *def;
    for (def = protocol()->statusList(); def->text; def++) {
        if (def->id == cmp_status)
            break;
    }
    if (cmp_status > status) {
        status = cmp_status;
        if (statusIcon && icons) {
            string iconSave = *icons;
            *icons = statusIcon;
            if (iconSave.length())
                addIcon(icons, iconSave.c_str(), statusIcon);
        }
        statusIcon = def->icon;
    } else {
        if (statusIcon) {
            addIcon(icons, def->icon, statusIcon);
        } else {
            statusIcon = def->icon;
        }
    }
    if (icons && data->bTyping.bValue)
        addIcon(icons, "typing", statusIcon);
}