[Windows Mobile Development and Hacking General] Dnomaid:
Hello everyone, it's my first post here.

Please help me with a small problem:

I have a WM6 device (Glofiish X800) with a VoIP enabled (WM6VoIP.cab). Built-in VoIP dialer works perfectly with my sipnet.ru profile.

Now I'm trying to initiate a VoIP call from my application. I use RTC API for this (rtcdll.dll etc.). I've got headers from the RTC Client API v.1.3 SDK for desktop.

Here are the examples I follow: http://msdn.microsoft.com/en-us/library/ms775274(VS.85).aspx

Everything compiles and runs ok, the objects get created, I even receive RTC events through IRTCEventNotification.

But when I try to enable and register my profile (exactly the same to which I provisioned and it worked), I receive RTCRS_ERROR state with the status 0x800703EB (ERROR_CAN_NOT_COMPLETE).

ThrowIfFailed(::CoCreateInstance(CLSID_RTCClient, NULL, CLSCTX_INPROC_SERVER, IID_IRTCClient, OUT (LPVOID*)(&client_))) ;
ThrowIfFailed(client_->Initialize()) ;
ThrowIfFailed(client_->QueryInterface(IID_IRTCClientProvisioning, OUT (LPVOID*) &prov_)) ;

ThrowIfFailed(client_->put_EventFilter(RTCRF_REGISTER_ALL)) ;

{
CComPtr<IConnectionPointContainer> connPtCont ;
ThrowIfFailed(client_->QueryInterface(IID_IConnectionPointContainer, OUT (void**)&connPtCont)) ;
ThrowIfFailed(connPtCont->FindConnectionPoint(IID_IRTCEventNotification, OUT &connPt_)) ;
CComPtr<IUnknown> myUnknown ;
ThrowIfFailed(QueryInterface(IID_IUnknown, OUT (void**)&myUnknown)) ;
ThrowIfFailed(connPt_->Advise(myUnknown, OUT &handlerConnectionCookie_)) ;
}

static const PCTSTR KProfileXml =
L"<provision key='1232ab01' name='SIPNET'>"
L"	<provider name='SIPNET' />"
L"	<user account='sim123456' password='s1i2m3'"
L"	uri='sip:3464167@sipnet.ru'"
L"	allowedauth='digest'/>"
L"	<sipsrv addr='sipnet.ru:5060' protocol='UDP' role='proxy'>"
L"	<session party='first' type='pc2pc' />"
L"	<session party='first' type='pc2ph' />"
L"	</sipsrv>"
L"	<sipsrv addr='sipnet.ru:5060' protocol='UDP' role='registrar'/>"
L"</provision>"
;
CComBSTR profileXmlBstr(KProfileXml) ;
ThrowIfFailed(prov_->CreateProfile(profileXmlBstr, OUT &profile_)) ;
ThrowIfFailed(prov_->EnableProfile(profile_, RTCRF_REGISTER_ALL)) ;

I tried to pass 0 to EnableProfile() (to avoid registration) and then make a call.

I call CreateSession() and then AddParticipant(), then I receive RTCSS_INPROGRESS with status 0 and then RTCSS_DISCONNECTED with status 0x800703EB (ERROR_CAN_NOT_COMPLETE).

ThrowIfFailed(client_->CreateSession(RTCST_PC_TO_PHONE, 0, profile_, RTCCS_FORCE_PROFILE, OUT &session_)) ;
CComBSTR other(L"sip:+79168287599@sipnet.ru") ;
CComPtr<IRTCParticipant> participant ;
ThrowIfFailed(session_->AddParticipant(other, 0, OUT &participant)) ;

Please, anyone, if you've tried this at home, tell me what am I doing wrong?

The device is in flight mode, connected via ActiveSync USB, internet is accessible.

Here is the event handling code:

HRESULT CRtcDialog::Event( RTC_EVENT RTCEvent, IDispatch *pEvent )
{
PRINTF1(_CRtcDialog, "RTCEvent = %d", RTCEvent) ;
if (RTCEvent == RTCE_REGISTRATION_STATE_CHANGE)
return HandleRegistrationStateChange(pEvent) ;
if (RTCEvent == RTCE_SESSION_STATE_CHANGE)
return HandleSessionStateChange(pEvent) ;
return S_OK ;
}

HRESULT CRtcDialog::HandleRegistrationStateChange(IDispatch *pIDispatch)
{
ThrowIfNull(pIDispatch) ;

CComPtr<IRTCRegistrationStateChangeEvent> regChangeEvent ;
ThrowIfFailed(pIDispatch->QueryInterface(IID_IRTCRegistrationStateChangeEvent, OUT (void**)&regChangeEvent)) ;

HRESULT hr ;
RTC_REGISTRATION_STATE regState ;
hr = regChangeEvent->get_State(OUT &regState) ;
CComBSTR statusText ;
hr = regChangeEvent->get_StatusText(OUT &statusText) ;
long statusCode = 0 ;
hr = regChangeEvent->get_StatusCode(OUT &statusCode) ;
PRINTF3(_CRtcDialog, "regState = %d (0x%08X: %s)", regState, statusCode, statusText) ;

return S_OK ;
}

Thanks in advance.