Esempio n. 1
0
int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam)
{
	CContact::Ref contact;
	MCONTACT hContact = (MCONTACT)wParam;
	SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)));
	if (this->GetContact(sid, contact))
	{
		if (contact->SetBuddyStatus(false))
			this->setByte(hContact, "Grant", 1);
		this->contactList.remove_val(contact);
	}

	return 0;
}
Esempio n. 2
0
void Router::doClose(Connection *conn, RouterMsg *pMsg)
{
	GatewayInfo *pInfo = (GatewayInfo*)conn->getData();
	int pos = 0;
	while(pos + SID_LENGTH <= pMsg->slen){
		std::string sid(pMsg->data + pos, SID_LENGTH);
		
		LOG("close connection, sid=%s", sid.c_str());
		allSessions.erase(sid);
		pInfo->sessions.erase(sid);
		
		pos+= SID_LENGTH;
	}
}
// session 可读
void TcpListener::event_readable(TcpSession::TcpSessionWptr session)
{
	auto sptr = std::move(session.lock());
	if (!sptr)
	{
		return;
	}
	std::uint32_t sid = sptr->sid();

	// 添加到事件列表
	std::unique_lock<std::mutex> ul(m_mtx_ev);
	m_events.push_back(std::bind(&TcpListener::fun_session_readable, this, sid));
	ul.unlock();
}
Esempio n. 4
0
MCONTACT CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary)
{
	ptrW sid(::mir_utf8decodeW(contact->GetSid()));

	CContact::AVAILABILITY availability;
	contact->GetPropAvailability(availability);

	MCONTACT hContact = this->GetContactBySid(sid);
	if ( !hContact)
	{
		hContact = (MCONTACT)::CallService(MS_DB_CONTACT_ADD, 0, 0);
		::CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)this->m_szModuleName);

		ptrW nick(::mir_utf8decodeW(contact->GetNick()));

		switch(availability) {
		case CContact::SKYPEOUT:
			this->setByte(hContact, "IsSkypeOut", 1);
			break;

		case CContact::PENDINGAUTH:
			::db_set_b(hContact, "CList", "NotOnList", 1);
			break;

		case CContact::BLOCKED:
		case CContact::BLOCKED_SKYPEOUT:
			::db_set_b(hContact, "CList", "Hidden", 1);
			break;

		default:
			this->delSetting(hContact, "IsSkypeOut");
			::db_unset(hContact, "CList", "Hidden");
			::db_unset(hContact, "CList", "NotOnList");
		}

		this->setTString(hContact, SKYPE_SETTINGS_SID, sid);
		this->setTString(hContact, "Nick", nick);

		DBVARIANT dbv;
		if ( !this->getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv))
		{
			::db_set_ts(hContact, "CList", "Group", dbv.ptszVal);
			::db_free(&dbv);
		}
	}

	return hContact;
}
Esempio n. 5
0
void PmpPimProtocol::onCreateProfile(PMPFrame * pFrame)
{
    assert(pFrame);
    assert(mEventFactory);

    std::string str = bufferToString(pFrame->data,true);
    unsigned int pos = stringInBufSize(str);
    iviLink::Profile::Uid profileUid(str);
    str = bufferToString(pFrame->data + pos,true);
    pos += stringInBufSize(str);
    iviLink::Profile::IUid piuid(str);
    str = bufferToString(pFrame->data + pos,true);
    iviLink::Service::Uid sid(str);

    mEventFactory->pimProtocolCreateProfile(profileUid, piuid, sid);
}
Esempio n. 6
0
int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam)
{
	CContact::Ref contact;
	MCONTACT hContact = (MCONTACT)wParam;
	SEString sid(_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID)));
	if (this->GetContact(sid, contact))
	{
		if (contact->SetBuddyStatus(true))
		{
			this->delSetting(hContact, "Auth");
			this->delSetting(hContact, "Grant");
		}
	}

	return 0;
}
Esempio n. 7
0
void Worker::doKick(RouterMsg *pMsg)
{
	int pos = 0;
	while(pos + SID_LENGTH <= pMsg->slen)
	{
		std::string sid(pMsg->data + pos, SID_LENGTH);
		LOG("kick user, sid=%s", sid.c_str());
		ClientList::const_iterator it = arrClients.find(sid);
		if(it != arrClients.end()){
			Connection *pClient = it->second;
			pClient->close();
		}
		
		pos+= SID_LENGTH;
	}
}
// session 断开连接
void TcpListener::event_session_disconnect(TcpSession::TcpSessionWptr session)
{
	auto sptr = std::move(session.lock());
	if (!sptr)
	{
		return;
	}

	// 关闭,删除
	std::uint32_t sid = sptr->sid();
	sptr->stop();
	m_conns.erase(sid);

	// 添加到事件列表
	std::unique_lock<std::mutex> ul(m_mtx_ev);
	m_events.push_back(std::bind(&TcpListener::fun_session_kick, this, sid));
	ul.unlock();
}
Esempio n. 9
0
void Router::getSessionGroups(SessionGroup &groups, int slen, char *sptr)
{
	int pos = 0;
	while(pos + SID_LENGTH <= slen)
	{
		std::string sid(sptr + pos, SID_LENGTH);
		pos+= SID_LENGTH;
		
		SessionList::const_iterator it = allSessions.find(sid);
		if(it != allSessions.end()){
			Connection *gate = it->second;
			groups[gate].append(sid);
		}else{
			LOG("gate not found by sid=%s", sid.c_str());
			continue;
		}
	}
}
Esempio n. 10
0
void Worker::doSendMsg(RouterMsg *pMsg)
{
	int pos = 0;
	while(pos + SID_LENGTH <= pMsg->slen)
	{
		std::string sid(pMsg->data + pos, SID_LENGTH);
		ClientList::const_iterator it = arrClients.find(sid);
		if(it != arrClients.end()){
			Connection *pClient = it->second;
			LOG("send msg, sid=%s", sid.c_str());
			sendToClient(pClient, pMsg->data + pMsg->slen, pMsg->len);
		}else{
			LOG("not found client, sid=%s", sid.c_str());
		}
		
		pos+= SID_LENGTH;
	}
}
// Create a new sid emulation.
unsigned int InnovBuilder::create(unsigned int sids)
{
    m_status = true;

    // Check available devices
    unsigned int count = availDevices();
    if (count == 0)
    {
        m_errorBuffer = "Innovation SSI-2001 ERROR: No devices found";
        goto InnovBuilder_create_error;
    }

    if (count < sids)
        sids = count;

    for (count = 0; count < sids; count++)
    {
        try
        {
            std::auto_ptr<Innov> sid(new Innov(this));

            // SID init failed?
            if (!sid->getStatus())
            {
                m_errorBuffer = sid->error();
                goto InnovBuilder_create_error;
            }
            sidobjs.insert(sid.release());
        }
        // Memory alloc failed?
        catch (std::bad_alloc const &)
        {
            m_errorBuffer.assign(name()).append(" ERROR: Unable to create Innov object");
            goto InnovBuilder_create_error;
        }


    }
    return count;

InnovBuilder_create_error:
    m_status = false;
    return count;
}
Esempio n. 12
0
      void CPmpPimClbCtrl::onProfileDied(PMPFrame * pFrame)
      {
         std::string str = bufferToString(pFrame->data,true);
         unsigned int pos = stringInBufSize(str);
         iviLink::Profile::IUid piuid(str);
         str = bufferToString(pFrame->data + pos,true);
         iviLink::Service::Uid sid(str);

         mpPimClb->onProfileDied(piuid,sid);

         PMPFrame pResp;
         pResp.size = sizeof(PMPFrame);
         pResp.frameType = PMP_FRAME_TYPE_RESPONSE;
         pResp.id = pFrame->id;
         pResp.client = pFrame->client;
         pResp.reqType = pFrame->reqType;

         mpProtocol->makeResponse(pResp);
      }
Esempio n. 13
0
pBuffer SourceBase::
        readFixedLength( const Interval& I )
{
    TIME_SOURCEBASE TaskTimer tt("%s.%s %s",
                  vartype(*this).c_str(), __FUNCTION__ ,
                  I.toString().c_str() );

    // Try a simple read
    pBuffer p = readChecked( I );
    if (I == p->getInterval())
        return p;

    // Didn't get exact result, prepare new Buffer
    pBuffer r( new Buffer(I, p->sample_rate(), p->number_of_channels ()) );

    for (int c=0; c<r->number_of_channels (); ++c)
    {
    #ifndef USE_CUDA
        // Allocate cpu memory and prevent calling an unnecessary clear by flagging the store as up-to-date
        CpuMemoryStorage::WriteAll<3>( r->getChannel (c)->waveform_data() );
    #else
        if (p->getChannel (c)->waveform_data()->HasValidContent<CudaGlobalStorage>())
            CudaGlobalStorage::WriteAll<3>( r->getChannel (c)->waveform_data() );
        else
            CpuMemoryStorage::WriteAll<3>( r->getChannel (c)->waveform_data() );
    #endif
    }

    Intervals sid(I);

    while (sid)
    {
        if (!p)
            p = readChecked( sid.fetchFirstInterval() );

        sid -= p->getInterval();
        TIME_SOURCEBASE_LINE((*r) |= *p); // Fill buffer
        p.reset();
    }

    return r;
}
Esempio n. 14
0
bool CHalfLife2::GetServerSteam3Id(char *pszOut, size_t len) const
{
	CSteamID sid(GetServerSteamId64());

	switch (sid.GetEAccountType())
	{
	case k_EAccountTypeAnonGameServer:
		ke::SafeSprintf(pszOut, len, "[A:%u:%u:%u]", sid.GetEUniverse(), sid.GetAccountID(), sid.GetUnAccountInstance());
		break;
	case k_EAccountTypeGameServer:
		ke::SafeSprintf(pszOut, len, "[G:%u:%u]", sid.GetEUniverse(), sid.GetAccountID());
		break;
	case k_EAccountTypeInvalid:
		ke::SafeSprintf(pszOut, len, "[I:%u:%u]", sid.GetEUniverse(), sid.GetAccountID());
		break;
	default:
		return false;
	}

	return true;
}
Esempio n. 15
0
void GroupListModule_Impl::_groupUnreadCntResponse(CImPdu* pdu)
{
	CImPduClientGroupUnreadMsgCntResponse* pduOfflineMsgCnt = (CImPduClientGroupUnreadMsgCntResponse*)pdu;
	client_group_unread_cnt_t* pList = pduOfflineMsgCnt->GetGroupUnreadList();
	for (UInt32 i = 0; i < pduOfflineMsgCnt->GetGroupUnreadCnt(); ++i)
	{
		client_group_unread_cnt_t pInfo = pList[i];
		{
			util::TTAutoLock lock(&m_lock);
			std::string sid(pInfo.group_id_url, pInfo.group_id_len);
			m_vecOfflineMsgGroup.push_back(sid);
			logic::GetLogic()->pushBackOperationWithLambda(
				[=]()
			{
				CImPduClientGroupUnreadMsgRequest pduData(sid.c_str());
				logic::getTcpClientModule()->sendPacket(&pduData);
			}
			);
		}
	}
}
Esempio n. 16
0
const char *ReSIDBuilder::credits ()
{
    m_status = true;

    // Available devices
    if (sidobjs.size ())
    {
        ReSID *sid = (ReSID *) sidobjs[0];
        return sid->credits ();
    }

    {   // Create an emulation to obtain credits
        ReSID sid(this);
        if (!sid)
		{
            m_status = false;
            strcpy (m_errorBuffer, sid.error ());
            return 0;
        }
        return sid.credits ();
    }
}
Esempio n. 17
0
void
vec4_gs_visitor::set_stream_control_data_bits(unsigned stream_id)
{
   /* control_data_bits |= stream_id << ((2 * (vertex_count - 1)) % 32) */

   /* Note: we are calling this *before* increasing vertex_count, so
    * this->vertex_count == vertex_count - 1 in the formula above.
    */

   /* Stream mode uses 2 bits per vertex */
   assert(c->control_data_bits_per_vertex == 2);

   /* Must be a valid stream */
   assert(stream_id >= 0 && stream_id < MAX_VERTEX_STREAMS);

   /* Control data bits are initialized to 0 so we don't have to set any
    * bits when sending vertices to stream 0.
    */
   if (stream_id == 0)
      return;

   /* reg::sid = stream_id */
   src_reg sid(this, glsl_type::uint_type);
   emit(MOV(dst_reg(sid), stream_id));

   /* reg:shift_count = 2 * (vertex_count - 1) */
   src_reg shift_count(this, glsl_type::uint_type);
   emit(SHL(dst_reg(shift_count), this->vertex_count, 1u));

   /* Note: we're relying on the fact that the GEN SHL instruction only pays
    * attention to the lower 5 bits of its second source argument, so on this
    * architecture, stream_id << 2 * (vertex_count - 1) is equivalent to
    * stream_id << ((2 * (vertex_count - 1)) % 32).
    */
   src_reg mask(this, glsl_type::uint_type);
   emit(SHL(dst_reg(mask), sid, shift_count));
   emit(OR(dst_reg(this->control_data_bits), this->control_data_bits, mask));
}
Esempio n. 18
0
  void tester::test<14>()
  {
    BankSelection mixed;
    mixed.MatchOnly(mixed_list);
    ensure_equals("Has 2 wildcards", mixed.fWildCards.size(), 2u);
    ensure_equals("Has 8 exact matches", mixed.fMatches.size(), 8u);
    
    std::string msg;
    msg = "Should not match ";
    SourceID sid(ID::kScVe,ID::kNotApplicable,"general","default");
    ensure(msg + sid.str(), !mixed.Includes(sid));
    
    sid = SourceID(ID::kMuSc,ID::kNotApplicable,"wrong","default");
    ensure(msg + sid.str(), !mixed.Includes(sid));

    
    msg = "Should match ";
    sid = SourceID(ID::kMuSc,ID::kNotApplicable,"general","default");
    ensure(msg + sid.str(), mixed.Includes(sid));

    sid = SourceID(ID::kSiR1_4, ID::kFast, "general", "default");
    ensure(msg + sid.str(), mixed.Includes(sid));
  }
Esempio n. 19
0
void __cdecl CSkypeProto::SearchBySidAsync(void* arg)
{
	mir_ptr<wchar_t> sid((wchar_t*)arg);

	MCONTACT hContact = this->GetContactBySid(sid);
	if (hContact)
	{
		this->ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
		this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)SKYPE_SEARCH_BYSID, 0);
		return;
	}

	CContactSearch::Ref search;
	this->CreateIdentitySearch(::mir_u2a(sid), search);
	search.fetch();
	search->SetProtoInfo((HANDLE)SKYPE_SEARCH_BYSID);

	bool valid;
	if (!search->IsValid(valid) || !valid || !search->Submit())
		return;

	search->BlockWhileSearch();
	search->Release();
}
void randomizer_base::setupIOMappings( )
{
    int ninput_streams = 0;
    int noutput_streams = 0;
    std::vector<std::string>::iterator pname;
    std::string sid("");
    int inMode=RealMode;

    if ( !validGRBlock() ) return;
    ninput_streams  = gr_sptr->get_max_input_streams();
    gr_io_signature_sptr g_isig = gr_sptr->input_signature();

    noutput_streams = gr_sptr->get_max_output_streams();
    gr_io_signature_sptr g_osig = gr_sptr->output_signature();

    LOG_DEBUG( randomizer_base, "GNUHAWK IO MAPPINGS IN/OUT " << ninput_streams << "/" << noutput_streams );

    //
    // Someone reset the GR Block so we need to clean up old mappings if they exists
    // we need to reset the io signatures and check the vlens
    //
    if ( _istreams.size() > 0 || _ostreams.size() > 0 ) {

        LOG_DEBUG( randomizer_base, "RESET INPUT SIGNATURE SIZE:" << _istreams.size() );
        IStreamList::iterator istream;
        for ( int idx=0 ; istream != _istreams.end(); idx++, istream++ ) {
            // re-add existing stream definitons
            LOG_DEBUG(  randomizer_base, "ADD READ INDEX TO GNU RADIO BLOCK");
            if ( ninput_streams == -1 ) gr_sptr->add_read_index();

            // setup io signature
            istream->associate( gr_sptr );
        }

        LOG_DEBUG( randomizer_base, "RESET OUTPUT SIGNATURE SIZE:" << _ostreams.size() );
        OStreamList::iterator ostream;
        for ( int idx=0 ; ostream != _ostreams.end(); idx++, ostream++ ) {
            // need to evaluate new settings...???
            ostream->associate( gr_sptr );
        }

        return;
    }


   //
   // Setup mapping of RH port to GNU RADIO Block input streams
   // For version 1,  we are ignoring the GNU Radio input stream -1 case that allows multiple data 
   // streams over a single connection.  We are mapping a single RH Port to a single GNU Radio stream.
   // Stream Identifiers will  be pass along as they are received
   //
    LOG_TRACE( randomizer_base, "setupIOMappings INPUT PORTS: " << inPorts.size() );
    pname = inputPortOrder.begin();
    for( int i=0; pname != inputPortOrder.end(); pname++ ) {

        // grab ports based on their order in the scd.xml file
        RH_ProvidesPortMap::iterator p_in = inPorts.find(*pname);
        if ( p_in != inPorts.end() ) {
            bulkio::InOctetPort *port = dynamic_cast< bulkio::InOctetPort * >(p_in->second);
            int mode = inMode;
            sid = "";

            // need to add read index to GNU Radio Block for processing streams when max_input == -1
            if ( ninput_streams == -1 ) gr_sptr->add_read_index();

            // check if we received SRI during setup
            BULKIO::StreamSRISequence_var sris = port->activeSRIs();
            if (  sris->length() > 0 ) {
                BULKIO::StreamSRI sri = sris[sris->length()-1];
                mode = sri.mode;
            }
            std::vector<int> in;
            io_mapping.push_back( in );
            _istreams.push_back( gr_istream< bulkio::InOctetPort > ( port, gr_sptr, i, mode, sid ));
            LOG_DEBUG( randomizer_base, "ADDING INPUT MAP IDX:" << i << " SID:" << sid );
            // increment port counter
            i++;
        }
    } 

    //
    // Setup mapping of RH port to GNU RADIO Block input streams
    // For version 1,  we are ignoring the GNU Radio output stream -1 case that allows multiple data 
    // streams over a single connection.  We are mapping a single RH Port to a single GNU Radio stream.
    //
    LOG_TRACE( randomizer_base, "setupIOMappings OutputPorts: " << outPorts.size() );
    pname = outputPortOrder.begin();
    for( int i=0; pname != outputPortOrder.end(); pname++ ) {

        // grab ports based on their order in the scd.xml file
        RH_UsesPortMap::iterator p_out = outPorts.find(*pname);
        if ( p_out != outPorts.end() ) {
            bulkio::OutOctetPort *port = dynamic_cast< bulkio::OutOctetPort * >(p_out->second);
            int idx = -1;
            BULKIO::StreamSRI sri = createOutputSRI( i, idx );
            if (idx == -1) idx = i;
            if(idx < (int)io_mapping.size()) io_mapping[idx].push_back(i);
            int mode = sri.mode;
            sid = sri.streamID;
            _ostreams.push_back( gr_ostream< bulkio::OutOctetPort > ( port, gr_sptr, i, mode, sid ));
            LOG_DEBUG( randomizer_base, "ADDING OUTPUT MAP IDX:" << i << " SID:" << sid );
            _ostreams[i].setSRI(sri, i );
            // increment port counter
            i++;
        }
    }
}
Esempio n. 21
0
INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	CSkypeProto *proto = (CSkypeProto *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);

	switch (message)
	{
	case WM_INITDIALOG:
		{
			::TranslateDialogDefault(hwnd);

			proto = (CSkypeProto *)lParam;
			::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
			{
				ptrW sid( ::db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_SID));
				SetDlgItemText(hwnd, IDC_SL, sid);
			}
			{
				ptrA pwd( ::db_get_sa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD));
				SetDlgItemTextA(hwnd, IDC_PW, pwd);
			}
			{
				int port = rand() % 10000 + 10000;
				SetDlgItemInt(hwnd, IDC_PORT, ::db_get_w(NULL, proto->m_szModuleName, "Port", port), FALSE);
				SendMessage(GetDlgItem(hwnd, IDC_PORT), EM_SETLIMITTEXT, 5, 0);
			}

			CheckDlgButton(hwnd, IDC_USE_ALT_PORTS, ::db_get_b(NULL, proto->m_szModuleName, "UseAlternativePorts", 1));
			
			if (proto->IsOnline())
			{
				SendMessage(GetDlgItem(hwnd, IDC_SL), EM_SETREADONLY, 1, 0);
				SendMessage(GetDlgItem(hwnd, IDC_PW), EM_SETREADONLY, 1, 0);
				SendMessage(GetDlgItem(hwnd, IDC_PORT), EM_SETREADONLY, 1, 0);
				EnableWindow(GetDlgItem(hwnd, IDC_USE_ALT_PORTS), FALSE);
				EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), FALSE);
				EnableWindow(GetDlgItem(hwnd, IDC_CHANGE_PWD), TRUE);
				EnableWindow(GetDlgItem(hwnd, IDC_GROUP), FALSE);
			}
			else if (::db_get_w(NULL, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) > ID_STATUS_OFFLINE)
			{
				EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), FALSE);
			}

			SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, SKYPE_GROUP_NAME_LIMIT, 0);

			ptrW defgroup( db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP));
			SetDlgItemText(hwnd, IDC_GROUP, defgroup);
		}
		return TRUE;

	case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
			case IDC_SL:
				{
					if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;

					if (!proto->IsOnline() && ::db_get_w(NULL, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) <= ID_STATUS_OFFLINE)
					{
						wchar_t sid[128];
						GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid));
						EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), ::wcslen(sid) != 0);
					}
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_PW:
				{
					if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
					if (proto->IsOnline())
					{
						char pwd[128];
						GetDlgItemTextA(hwnd, IDC_SL, pwd, SIZEOF(pwd));
						EnableWindow(GetDlgItem(hwnd, IDC_CHANGE_PWD), ::strlen(pwd) != 0);
					}
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_GROUP:
				{
					if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
						return 0;
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_PORT:
				{
					if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
						return 0;
					SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_USE_ALT_PORTS:
				SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
				break;

			case IDC_REGISTER:
				{
					char sid[128], pwd[128];
					GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
					GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));

					Skype::VALIDATERESULT reason;
					proto->ValidatePassword(sid, pwd, reason);

					if (reason == Skype::VALIDATED_OK)
					{
						CAccount::Ref account;
						proto->GetAccount(sid, proto->account);
						proto->account->SetStrProperty(CAccount::P_FULLNAME, sid);
						proto->account->Register(pwd, false, false);
					}
					else
					{
						proto->ShowNotification(CSkypeProto::ValidationReasons[reason]);
					}
				}
				return FALSE;

			case IDC_CHANGE_PWD:
				{
					char sid[128], pwd[128];
					GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
					GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));

					PasswordChangeBoxParam param;
					param.password = ::mir_strdup(pwd);

					if (proto->ChangePassword(param))
					{
						proto->account->ChangePassword(param.password, param.password2);
					}
				}
				break;
			}
		}
		break;

	case WM_NOTIFY:
		if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY && !proto->IsOnline())
		{
			wchar_t sid[128];
			GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid));
			::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_SID, sid);
			::mir_free(proto->login);
			proto->login = ::mir_wstrdup(sid);

			char pwd[128];
			GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
			::db_set_s(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, pwd);

			HWND item = GetDlgItem(hwnd, IDC_PORT);
			if (item)
			{
				BOOL error;
				int port = GetDlgItemInt(hwnd, IDC_PORT, &error, FALSE);
				::db_set_w(NULL, proto->m_szModuleName, "Port", port);
				::db_set_b(NULL, proto->m_szModuleName, "UseAlternativePorts", (BYTE)IsDlgButtonChecked(hwnd, IDC_USE_ALT_PORTS));
			}

			wchar_t tstr[128];
			GetDlgItemText(hwnd, IDC_GROUP, tstr, SIZEOF(tstr));
			if (lstrlen(tstr) > 0)
			{
				::db_set_ts(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP, tstr);
				::Clist_CreateGroup(0, tstr);
			}
			else
				::db_unset(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP);

			return TRUE;
		}
		break;
	}

	return FALSE;
}
Esempio n. 22
0
void xRinexEphemerisStore :: BCESaddEphemerisTest (void)
{

	ofstream DumpData;
	DumpData.open ("Logs/addEphemerisTest.txt");

	gpstk::GPSEphemerisStore Blank;
     //cout << " On construction, Blank.getInitialTime: " << Blank.getInitialTime() << endl;
     //cout << " On construction, Blank.getFinalTime:   " << Blank.getFinalTime() << endl;

	gpstk::Rinex3EphemerisStore Store;
	Store.loadFile("TestRinex06.031");

        std::list<gpstk::Rinex3NavData> R3NList;
        gpstk::GPSEphemerisStore GStore;
        std::list<gpstk::Rinex3NavData>::const_iterator it;
        Store.addToList(R3NList);
        for (it = R3NList.begin(); it != R3NList.end(); ++it)
          GStore.addEphemeris(gpstk::EngEphemeris(*it));

	short PRN = 1;
        gpstk::SatID sid(PRN,gpstk::SatID::systemGPS);

	gpstk::CivilTime Time(2006,1,31,11,45,0,2);
	gpstk::CivilTime TimeB(2006,1,31,9,59,44,2);
        gpstk::CivilTime TimeE(2006,1,31,13,59,44,2);

        const gpstk::CommonTime ComTime = (gpstk::CommonTime)Time;
        const gpstk::CommonTime ComTimeB = (gpstk::CommonTime)TimeB;
        const gpstk::CommonTime ComTimeE = (gpstk::CommonTime)TimeE;

	const gpstk::EngEphemeris eph = GStore.findEphemeris(sid,ComTime);

     //cout << " ComTime: " << ComTime << " ComTimeB: " << ComTimeB << " ComTimeE: " << ComTimeE << endl;
     //cout << " eph follows: " << endl;
     //cout << eph << endl;

	try
	{
		CPPUNIT_ASSERT_NO_THROW(Blank.addEphemeris(eph));
     //cout << " After assert_no_throw: " << endl;
     //cout << " Blank.getInitialTime: " << Blank.getInitialTime() << endl;
     //cout << " Blank.getFinalTime:   " << Blank.getFinalTime() << endl;

                Blank.clear();
     //cout << " After clear: " << endl;
     //cout << " Blank.getInitialTime: " << Blank.getInitialTime() << endl;
     //cout << " Blank.getFinalTime:   " << Blank.getFinalTime() << endl;

		Blank.addEphemeris(eph);
     //cout << " After addEphemeris(eph): " << endl;
     //cout << " Blank.getInitialTime: " << Blank.getInitialTime() << endl;
     //cout << " Blank.getFinalTime:   " << Blank.getFinalTime() << endl;

		CPPUNIT_ASSERT_EQUAL(ComTimeB,Blank.getInitialTime());
		CPPUNIT_ASSERT_EQUAL(ComTimeE,Blank.getFinalTime());

		Blank.dump(DumpData,1);
	}
	catch (gpstk::Exception& e)
	{
		cout << e;
	}
	CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/addEphemerisTest.txt",(char*)"Checks/addEphemerisTest.chk"));
}
Esempio n. 23
0
common::ErrnoError IStream::sendFrame(const common::http2::frame_base& frame) {
  CHECK(sid() == frame.stream_id());
  common::buffer_t raw = frame.raw_data();
  return sendData(raw);
}
	//TODO: Test-Me!!
	private: void do_update_service()
	{
		DCS_DEBUG_TRACE_L(3, "(" << this << ") BEGIN Do-Update-Service (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX

		// Check if there is at least one busy server.
		if (num_busy_ > 0)
		{
			typedef typename server_container::const_iterator iterator;

			real_type new_share(this->share());
			real_type new_multiplier(this->capacity_multiplier());

			// Check if we really need to update currently running customers
			if (::dcs::math::float_traits<real_type>::approximately_equal(old_share_, new_share)
				&& ::dcs::math::float_traits<real_type>::approximately_equal(old_multiplier_, new_multiplier))
			{
				// Share is not changed -> avoid to update customers and reschedule their end-of-service events

				DCS_DEBUG_TRACE_L(3, "(" << this << ") Share/Multiplier not changed: " << old_share_ << " vs. " << new_share << " / " << old_multiplier_ << " vs. " << new_multiplier);

				return;
			}

			real_type cur_time(this->node().network().engine().simulated_time());
			iterator end_it(servers_.end());
			for (iterator it = servers_.begin(); it != end_it; ++it)
			{
				uint_type sid(it->first);
				customer_pointer ptr_customer(it->second);

				// paranoid-check: null
				DCS_DEBUG_ASSERT( ptr_customer );

				DCS_DEBUG_TRACE_L(3, "(" << this << ") Running Customer ID: " << ptr_customer->id());

				runtime_info_type& rt_info(this->info(ptr_customer));

				// paranoid-check: paranoid check
				DCS_DEBUG_ASSERT( rt_info.server_id() == sid );

				DCS_DEBUG_TRACE_L(3, "Updating Customer: " << rt_info.get_customer() << " - Service demand: " << rt_info.service_demand() << " - Multiplier: " << this->capacity_multiplier() << " - old share: " << rt_info.share() << " - old runtime: " << rt_info.runtime() << " - old completed work: " << rt_info.completed_work() << " - old residual-work: " << rt_info.residual_work() << " (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX

				// Increment the accumulated work done by this customer to date...
				rt_info.accumulate_work(cur_time);
				// ... Update the capacity multiplier,...
				rt_info.capacity_multiplier(new_multiplier);
				// ... Update the share,...
				rt_info.share(new_share);
				// ... Compute the new residual work
				real_type new_residual_time(rt_info.residual_work()/new_multiplier);
				// ... And reschedule the end-of-service
				this->node().reschedule_service(*ptr_customer, new_residual_time);

				DCS_DEBUG_TRACE_L(3, "Updated Customer: " << rt_info.get_customer() << " - Service demand: " << rt_info.service_demand() << " - Multiplier: " << this->capacity_multiplier() << " - new share: " << rt_info.share() << " - new runtime: " << rt_info.runtime() << " - new completed work: " << rt_info.completed_work() << " - new residual-work: " << rt_info.residual_work() << " (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX
			}

			old_share_ = new_share;
			old_multiplier_ = new_multiplier;
		}

		DCS_DEBUG_TRACE_L(3, "(" << this << ") END Do-Update-Service (Clock: " << this->node().network().engine().simulated_time() << ")");//XXX
	}
Esempio n. 25
0
common::ErrnoError IStream::sendCloseFrame() {
  common::http2::frame_hdr hdr = common::http2::frame_rst::create_frame_header(0, sid());
  uint32_t er = be32toh(common::http2::HTTP2_STREAM_CLOSED);
  common::http2::frame_rst rst(hdr, &er);
  return sendFrame(rst);
}
void copy_octet_base::setupIOMappings()
{
  int ninput_streams = 0;
  int noutput_streams = 0;

  if ( !validGRBlock() ) return;
  
  ninput_streams  = gr_sptr->get_max_input_streams();
  gr_io_signature_sptr g_isig = gr_sptr->input_signature();  
  noutput_streams = gr_sptr->get_max_output_streams();
  gr_io_signature_sptr g_osig = gr_sptr->output_signature();

  //
  // RESOLVE: Still need to resolve the issue with the input port/stream to output port.  We also need to resolve issue
  // with "ganging" ports together as an input to a GNU RADIO Block. transform cplx to real ... r/i -> float
  //
  
  LOG_DEBUG( copy_octet_base, "GNUHAWK IO MAPPINGS IN/OUT " << ninput_streams << "/" << noutput_streams );
  std::string sid("");

  //
  // Someone reset the GR Block so we need to clean up old mappings if they exists
  // we need to reset the io signatures and check the vlens
  //
 
 
   if ( _istreams.size() > 0 || _ostreams.size() > 0 ) {


 
    LOG_DEBUG(  copy_octet_base, "RESET INPUT SIGNATURE SIZE:" << _istreams.size() );
    IStreamList::iterator istream;
    for ( int idx=0 ; istream != _istreams.end(); idx++, istream++ ) {
        // re-add existing stream definitons
      LOG_DEBUG(  copy_octet_base, "ADD READ INDEX TO GNU RADIO BLOCK");
      if ( ninput_streams == -1 ) gr_sptr->add_read_index();

      // setup io signature 
      istream->associate( gr_sptr );
    }
 
    LOG_DEBUG(  copy_octet_base, "RESET OUTPUT SIGNATURE SIZE:" << _ostreams.size() );
    OStreamList::iterator ostream;
    for ( int idx=0 ; ostream != _ostreams.end(); idx++, ostream++ ) {
        // need to evaluated new settings...???
        ostream->associate( gr_sptr );
    }

    return;
  }


     
  // setup mapping of RH Port to GNU RADIO BLOCK input streams as a 1-1 mapping (basically we ignore streamID when pulling data from port)
  // for case ninput == -1 and 1 port we map out streamID to each GNU Radio Block input stream this is done in the notifySRI callback method
  if ( ninput_streams != -1 || ( ninput_streams == -1 && inPorts.size() > 1 ) ) {
  
    int nstreams = inPorts.size();
    if ( ninput_streams != -1 ) nstreams = std::min( nstreams, ninput_streams);
    
    RH_ProvidesPortMap::iterator p_in = inPorts.begin();
    for ( int i=0; i < nstreams && p_in != inPorts.end(); i++, p_in++ ) {
      // need to add read index to GNU Radio Block for processing, 
      if ( ninput_streams == -1 ) gr_sptr->add_read_index();
      _istreams.push_back( gr_istream< BULKIO_dataOctet_In_i > ( dynamic_cast< BULKIO_dataOctet_In_i * >(p_in->second), sid, gr_sptr, i));
    }
  }
  else {   // ninput_stream is variable == -1 and  component ports == 1
    //
    // need to worry about sync between when service function starts and pushSRI happens, 
    //
    for ( RH_ProvidesPortMap::iterator p_in = inPorts.begin(); p_in != inPorts.end(); p_in++ ) {

      BULKIO_dataOctet_In_i *port = dynamic_cast< BULKIO_dataOctet_In_i * >(p_in->second);
      BULKIO::StreamSRISequence_var sris = port->activeSRIs();
      for ( uint32_t i=0 ; i < sris->length(); i++ ) {
         BULKIO::StreamSRI sri = sris[i];
         int mode = sri.mode;
	 sid = sri.streamID;
	 _istreams.push_back( gr_istream< BULKIO_dataOctet_In_i > ( port, sid, gr_sptr, i, mode ));
      }
	  
    }
  }
 

  if ( noutput_streams != -1  || (noutput_streams == -1 && outPorts.size() > 1  ) ) {
    int32_t nstreams = outPorts.size();
    if ( noutput_streams != -1 ) {
      if ( nstreams != noutput_streams ) 
         LOG_WARN( copy_octet_base, "Number of OUTPUT PORTS is different than number of GNU RADIO STREAMS  PORTS/STREAMS " <<  nstreams << "/" << noutput_streams );
      nstreams = std::min( nstreams, noutput_streams);
    }

    // add number of output streams based min ( gr block output streams, or output ports)
    LOG_TRACE( copy_octet_base, "setupIOMappings OutputPorts: " << nstreams );
    RH_UsesPortMap::iterator p_out = outPorts.begin();
    for ( int i=0; i < nstreams && p_out != outPorts.end(); i++, p_out++ ) {
       _ostreams.push_back( gr_ostream < BULKIO_dataOctet_Out_i >( dynamic_cast< BULKIO_dataOctet_Out_i *>(p_out->second), sid, gr_sptr, i ));
    }
  } 
  else if ( (noutput_streams == -1 && outPorts.size() == 1) && ( ninput_streams == 0 ) ) {
    // RESOLVE: should generate maps based on port connections when output streams is variable and no input stream
    RH_UsesPortMap::iterator p_out = outPorts.begin();
    uint32_t idx =0;
    std::string sid("");
    uint32_t nstreams = getNOutputStreams();
    for( ; idx < nstreams; idx++ ) {
       _ostreams.push_back( gr_ostream < BULKIO_dataOctet_Out_i >( dynamic_cast< BULKIO_dataOctet_Out_i *>(p_out->second), sid, gr_sptr, idx ));
    }
  }

  // for each output stream definition, call createOutputSRI to create initial value for the stream 
  OStreamList::iterator ostream = _ostreams.begin();
  for ( int i=0;  ostream != _ostreams.end(); i++, ostream++ ) {
    BULKIO::StreamSRI sri = createOutputSRI( i );
    ostream->setSRI(sri, i );
    ostream->pushSRI();
  }
  
     
}
void copy_octet_base::processStreamIdChanges() {

  boost::mutex::scoped_lock lock(_sriMutex);

  LOG_TRACE( copy_octet_base, "processStreamIDChanges QUEUE: " << _sriQueue.size()  );
  if (  _sriQueue.size() == 0 ) return;
  std::string sid("");

  if ( validGRBlock() ) {
    int max_input =  gr_sptr->get_max_input_streams();
    int n_input = gr_sptr->get_num_input_streams();
    LOG_TRACE( copy_octet_base, " IN_MAX=" << max_input << " N_IN:" << n_input);
    int max_output =  gr_sptr->get_max_output_streams();
    int n_output = gr_sptr->get_num_output_streams(); 
    LOG_TRACE( copy_octet_base, " OUT_MAX=" << max_output << " N_OUT:" << n_output);          

    bool var_istreams = false;
    if ( max_input == -1 && inPorts.size() == 1 ) 
       var_istreams = true;

    bool var_ostreams = false;
    if ( max_output == -1 && outPorts.size() == 1 ) 
       var_ostreams = true;    

    IStreamList::iterator istream;
    int idx=0;
    std::string sid("");
    int mode=0;
    SRIQueue::iterator item = _sriQueue.begin();
    
    for ( ; item != _sriQueue.end(); item++ ) {
       idx = 0;
       sid = "";
       mode= item->second.mode;
       sid = item->second.streamID;
       istream = _istreams.begin();
       for ( ; istream != _istreams.end(); idx++, istream++ ) {
	   if ( !var_istreams && istream->port == item->first ) {
	      break;
	   }
	   else if ( var_istreams && (istream->port == item->first) && (istream->streamID == sid) )  {
	        break;
	  }
       }

       if ( istream == _istreams.end() ) {
          if ( var_istreams )  {
	     if ( gr_sptr ) gr_sptr->add_read_index();
	     _istreams.push_back( gr_istream< BULKIO_dataOctet_In_i >( item->first, sid, gr_sptr, idx, mode ) );
             LOG_TRACE( copy_octet_base, "GR_ISTREAM::ADD  PORT:" << item->first->getName() << " STREAM_ID:" << sid << " NSTREAMS:" << _istreams.size());

	     if ( var_ostreams ) {
	     	RH_UsesPortMap::iterator p_out = outPorts.begin();
		_ostreams.push_back( gr_ostream < BULKIO_dataOctet_Out_i >( dynamic_cast< BULKIO_dataOctet_Out_i *>(p_out->second), sid, gr_sptr, idx ));
	        LOG_TRACE( copy_octet_base, "GR_OSTREAM::ADD  PORT:" << p_out->second->getName() << " STREAM_ID:" << sid << " OSTREAMS:" << _ostreams.size());
             }    
	  }
	  else {
	       LOG_WARN( copy_octet_base, " NEW STREAM ID, MISSING INPUT STREAM DEFINITION"  );
	  }
       }
       else if ( !var_istreams ) {
	    LOG_DEBUG(  copy_octet_base,  "  SETTING GR_OSTREAM ID/STREAM_ID :" << idx << "/" << sid  );
	    istream->sri(true);
	    istream->spe(mode);
       }

       LOG_DEBUG(  copy_octet_base,  "  GR_OSTREAM ID/STREAM_ID :" << idx << "/" << sid  );
       setOutputStreamSRI( idx, item->second );
	        
    }

     _sriQueue.clear();
     
  }
  else {
 	LOG_WARN(  copy_octet_base, " NEW STREAM ID, NO GNU RADIO BLOCK DEFINED, SRI QUEUE SIZE:" << _sriQueue.size() );
  }
      

 LOG_TRACE(  copy_octet_base,  "processStreamID,  GR_ISTREAM MAP SIZE:"  << _istreams.size() );

}
Esempio n. 28
0
void TransferServer::onBroken(ConnectionIdentifier client)
{
    ServiceIdentifier sid(0, 0, client.getId());
    m_dispatcherInterface->postMessage(sid, UTM::create(sid, sid, _EvtClientClosed));
}
Esempio n. 29
0
bool qExtractSecurityPolicyFromString(const QString &string, TSecurityPolicy &policy)
{
    int startPos = string.indexOf(QLatin1Char('='));
    QStringList values;
    bool ret = false;
    
    if (startPos == -1) {
        values = string.split(QLatin1Char(','), QString::SkipEmptyParts);
    } else {
        values = string.mid(startPos + 1).split(QLatin1Char(','), QString::SkipEmptyParts);
    }
    
    if (values.count() > 0) {
        const QString findVid(QLatin1String("vid["));
        const QString findSid(QLatin1String("sid["));
        const int MaxCapCount = 7;
        const int VidMaxCount = 3;
        const int SidMaxCount = 3;

        TCapability capList[MaxCapCount] = { ECapability_None,ECapability_None,ECapability_None,
                                    ECapability_None,ECapability_None,ECapability_None,ECapability_None };
        
        bool isVID = false;
        bool isSID = false;
        
        QString idString(QLatin1String(""));
        int maxAllowed = MaxCapCount;
        
        if (values[0].contains(findVid, Qt::CaseInsensitive)) {
            idString = values[0].remove(findVid, Qt::CaseInsensitive);
            idString = idString.remove(QLatin1Char(']'));
            values.removeAt(0);
            isVID = true;
            maxAllowed = VidMaxCount;
            
        } else if (values[0].contains(findSid, Qt::CaseInsensitive)) {
            idString = values[0].remove(findSid, Qt::CaseInsensitive);
            idString = idString.remove(QLatin1Char(']'));
            values.removeAt(0);
            isSID = true;
            maxAllowed = SidMaxCount;
        }
        
        if (values.count() <= maxAllowed) {
            bool wasSuccesful = true;
            
            for (int i = 0; i < values.count(); i++) {
                capList[i] = qMatchCapStr(values[i]);
                
                if (capList[i] == ECapability_HardLimit) {
                    wasSuccesful = false;
                    break;
                }
            }
            
            if (wasSuccesful) {
                if (isVID || isSID){
                    bool ok = true;
                    quint32 id = idString.toUInt(&ok, 16);
                    
                    if (ok) {
                        if (isVID) {
                            TVendorId vid(id);
                            policy = TSecurityPolicy(vid, capList[0], capList[1], capList[2]);
                        } else {
                            TSecureId sid(id);
                            policy = TSecurityPolicy(sid, capList[0], capList[1], capList[2]);
                        }
                        
                        ret = true; //Everything is fine
                    }   
                } else {
                    policy = TSecurityPolicy(capList[0], capList[1], capList[2], capList[3], 
                                        capList[4], capList[5], capList[6]);
                    
                    ret = true;  //Everything is fine
                }
            }
        }
    } 
    
    return ret;
}