Пример #1
0
bool BenchConnection::OnPoke(const wxString& topic,
                             const wxString& item,
                             const void *data,
                             size_t size,
                             wxIPCFormat format)
{
    if ( !IsSupportedTopicAndItem("OnPoke", topic, item) )
        return false;

    if ( !IsTextFormat(format) )
    {
        wxLogMessage("Unexpected format %d in OnPoke().", format);
        return false;
    }

    m_item = GetTextFromData(data, size, format);

    if ( m_advise )
    {
        if ( !Advise(item, m_item) )
        {
            wxLogMessage("Failed to advise client about the change.");
        }
    }

    return true;
}
Пример #2
0
	AccessProviderImpl::AccessProviderImpl()
		: CommonImpl< IAccessProvider >()
		, accessPoints_()
	{
		// Advise default access point.
		Advise( TypeInfo< ICommon >::GetGuid() );
	}
Пример #3
0
void MyConnection::Notify()
{
    if (!m_sAdvise.empty())
    {
        wxString s = wxDateTime::Now().Format();
        Advise(m_sAdvise, s);
        s = wxDateTime::Now().FormatTime() + " "
                + wxDateTime::Now().FormatDate();
        Advise(m_sAdvise, s.mb_str(), s.length() + 1);

#if wxUSE_DDE_FOR_IPC
        wxLogMessage("DDE Advise type argument cannot be wxIPC_PRIVATE. "
                     "The client will receive it as wxIPC_TEXT, "
                     "and receive the correct no of bytes, "
                     "but not print a correct log entry.");
#endif // DDE

        char bytes[3];
        bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3';
        Advise(m_sAdvise, bytes, 3, wxIPC_PRIVATE);
        // this works, but the log treats it as a string now
//        m_connection->Advise(m_connection->m_sAdvise, bytes, 3, wxIPC_TEXT );
    }
}
Пример #4
0
	ICommonPtr AccessProviderImpl::Advise(RefIid eventsIid)
	{
		// Construct access point.
		IAccessPointPtr accessPoint( Class< AccessPointImpl >::Create( 
			CommonImpl< IAccessProvider >::GetSelf(), eventsIid ) );
		if ( !accessPoint )
			return NULL;
		// Produce corresponding events spreader.
		ICommonPtr eventsSpreader = Object::CreateStub( 
			eventsIid, accessPoint->CreateSpreader(), true );
		if ( !eventsSpreader )
			return NULL;		
		// Register access point.
		if ( Error::IsFailed(Advise(eventsIid, accessPoint)) )
			return NULL;
		return eventsSpreader;
	}
Пример #5
0
void Starter::Receive(Message & message) {
	int tag = message.GetTag();

	if(tag == Actor::BOOT) {

		Boot(message);

	} else if(tag == DIE) {

		PrintAddress();
		cout << "Now I must die..." << endl;

		Die(message);
	} else if(tag == ADVISE) {
		Advise(message);
	}
}
Пример #6
0
int main(int argc, char * argv[])
{
	IKernelLog *		pKernelLog;
	IKernelLogEvents *	psKernelLogEvents;
	IConnectionPoint *	cp;
	DWORD				cookie;
	MSG msg;

	IKernelLogEvents a;

	::CoInitialize(NULL);

	destination = 0;
	tmain_threadid = ::GetCurrentThreadId();

	if(!FAILED(::CoCreateInstance(CLSID_KernelLog, NULL, CLSCTX_ALL, __uuidof(IKernelLog), (void **)&pKernelLog)))
	{
		cp = NULL;
		psKernelLogEvents = new IKernelLogEvents;

		if(Advise(pKernelLog, __uuidof(_IKernelLogEvents), psKernelLogEvents, &cookie, &cp))
		{
			::SetConsoleCtrlHandler(HandlerRoutine, TRUE);
			while(::GetMessage(&msg, NULL, 0, 0) != 0)
			{   ::DispatchMessage(&msg);   }
			::SetConsoleCtrlHandler(HandlerRoutine, FALSE);
			
			cp->Unadvise(cookie);
		}

		delete psKernelLogEvents;

		if(pKernelLog != NULL)
			pKernelLog->Release();
	}

	if(destination != NULL)
	{
		Printf("\n\nSuspended by Ctrl-C event occursion.\n");
		fclose(destination);
	}

	::CoUninitialize();
	return 0;
}
Пример #7
0
STDMETHODIMP CDispEventTransfer::attachEvent( IDispatch* source, BSTR event, VARIANT notify, VARIANT listener, VARIANT_BOOL* pRetVal )
{
	if( pRetVal )
		*pRetVal = VARIANT_FALSE;
	if( NULL == source  || NULL == event || (VT_EMPTY==notify.vt||VT_NULL==notify.vt||VT_ERROR == notify.vt) && (VT_EMPTY==listener.vt||VT_NULL==listener.vt||VT_ERROR==listener.vt) )
		return S_FALSE;

	UINT n = 0;
	HRESULT hr = source->GetTypeInfoCount( &n );
	if( FAILED(hr) || n < 1 )
		return S_FALSE;
	CComPtr<ITypeInfo> spTI;
	hr = source->GetTypeInfo( 0, LOCALE_USER_DEFAULT, &spTI );
	if( FAILED(hr) || !spTI )
		return S_FALSE;
	CComPtr<ITypeLib> spTL;
	UINT index = 0;
	hr = spTI->GetContainingTypeLib( &spTL, &index );
	if( FAILED(hr) || !spTL )
		return S_FALSE;
	hr = AtlGetObjectSourceInterface( source, &m_libid, &m_iid, &m_wMajorVerNum, &m_wMinorVerNum );
	if( FAILED(hr) || IID_NULL == m_iid )
		return S_FALSE;
	CComPtr<ITypeInfo> spTI2;
	hr = spTL->GetTypeInfoOfGuid( m_iid, &spTI2 );
	if( FAILED(hr) || !spTI2 )
		return S_FALSE;
	MEMBERID idMember = DISPID_UNKNOWN;
	hr = spTI2->GetIDsOfNames( &event, 1, &idMember );
	if( FAILED(hr) || DISPID_UNKNOWN == idMember )
		return S_FALSE;
	hr = Advise( source );
	if( FAILED(hr) )
		return S_FALSE;

	m_spSource = source;
	m_bstrEvent = event;
	m_idMember = idMember;
	m_vNotify = notify;
	m_vListener = listener;
	if( pRetVal )
		*pRetVal = VARIANT_TRUE;
	return S_OK;
}
Пример #8
0
status_t BnChatSession::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
	status_t result = 0x80000000;
	_TRACE("ChatSession::onTransact[pid:%d] >>:code 0x%x",GetCallerPID(),code); //data.print();
	
	switch(code) {
		case ICS_getName: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			String16 name = const_cast<BnChatSession*>(this)->GetName();			
			reply->writeString16(name);
			result =  NO_ERROR;
		} break;		
		case ICS_GetStatements: {

			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);
			Vector<String16> list = GetStatements();
			const size_t N = list.size();
			reply->writeInt32(N);
			_TRACE("GetStatements num %u",(unsigned int)N);
			for (size_t i=0; i<N; i++) {
				reply->writeString16(list[i]);
			}
			result = NO_ERROR;
			
		} break;
		case ICS_Say: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			String16 statement = data.readString16();
			status_t err = Say(statement);
			reply->writeInt32(err);
			result = NO_ERROR;
		} break;
		case ICS_AsyncSay: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			String16 statement = data.readString16();
			AsyncSay(statement);
			result = NO_ERROR;
		} break;
		case ICS_Advise: {
			CHECK_INTERFACE(IChatSession, data, reply);
			sp<IChatSessionEvents> eventSink = interface_cast<IChatSessionEvents>(data.readStrongBinder());
			Advise(eventSink);
			result = NO_ERROR;
		} break;
		case ICS_Unadvise: {
			CHECK_INTERFACE(IChatSession, data, reply);
			//CHECKOUT_CALLER(data);

			status_t err = Unadvise();
			reply->writeInt32(err);
			result = NO_ERROR;
		} break;		
		default:
			result = BBinder::onTransact(code, data, reply, flags);
	}
	
	_TRACE("ChatSession::onTransact[pid:%d] <<:result %d",GetCallerPID(),result); //reply.print();
	return result;
}