📄 proxyservices.hpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#pragma once
#ifndef __PROXYSERVICES_HPP__
#define __PROXYSERVICES_HPP__
#include "rtccore.h"
#include <atlbase.h> //CComPtr support
#include "Settings.hpp"
#include "Timers.hpp"
#include <VoIPNotify.hpp>
//forward declaration
class VoIPApp_t;
class ProxyServices_t:
public ISettingChangeHandler_t
{
public:
//Ctor
ProxyServices_t();
~ProxyServices_t();
//ISettingHandler_t implementations
HRESULT
OnSettingsChange(
DWORD SettingFlags
);
//handle the rtc event that related with registration and subscription
HRESULT
OnRegistrationStateChangeEvent(
__in IRTCRegistrationStateChangeEvent* piEvent
);
HRESULT
OnSubscriptionStateChangeEvent(
__in IRTCSubscriptionStateChangeEvent* piEvent
);
HRESULT
OnSubscriptionNotificationEvent(
__in IRTCSubscriptionNotificationEvent* piEvent
);
//initialization
void
Initialize(
void
);
// kick off the first registrations and subscriptions
void StartServices();
// stops proxy services
void StopServices();
//accessor method to return the active SIP profile
IRTCProfile*
GetActiveSIPProfile()
{
return m_cpActiveSIPProfile;
}
//get a pointer to the backup profile
IRTCProfile* GetBackupSIPProfile();
//get a default profile
IRTCProfile*
GetDefaultSIPProfile()
{
//return active profile if it is available, otherwise, fall back to main proxy's profile
return (m_cpActiveSIPProfile != NULL) ?
m_cpActiveSIPProfile : m_SIPProxyCollection.m_cpEnabledProfile;
}
//null out all of the RTC smart pointers we are holding
void NullOutRTCPointers();
private:
struct ProfileCollection_t
{
bool m_Unregistering; //Are we in the process of unregistering the enabled profile?
RTC_REGISTRATION_STATE m_RegistrationState; //RTC state for the enabled profile
CComPtr<IRTCProfile> m_cpEnabledProfile; //currently enabled RTCProfile
CComPtr<IRTCProfile> m_cpToBeEnabledProfile; //to be disabled RTCProfile
ProfileCollection_t()
{
m_Unregistering = false;
m_RegistrationState = RTCRS_NOT_REGISTERED;
}
};
struct SubscriptionCollection_t
{
DWORD m_Flags;
CComPtr<IRTCSubscription> m_cpSubscription;
CComPtr<IRTCProfile> m_cpSubscribeProxy;
const static DWORD UNSUBSCRIBING ;
const static DWORD SUBSCRIBE_AFTER_REGISTER ;
const static DWORD SUBSCRIBE_AFTER_UNSUBSCRIBE;
SubscriptionCollection_t()
{
m_Flags = 0;
}
};
HRESULT
OnSIPSettingsChange(
__in ProfileCollection_t* pCollection,
__in Settings_t::SettingType_e SettingType
);
HRESULT OnVoicemailSettingsChange();
HRESULT OnVoicemailNumberChange();
HRESULT
OnRegistrationStateChangeEvent(
__in IRTCProfile* pProfile,
RTC_REGISTRATION_STATE RegistrationState,
__in ProfileCollection_t* pCollection
);
HRESULT
RegisterClientWithSIPProxy(
__in ProfileCollection_t* pCollection
);
HRESULT
UnregisterClientFromSIPProxy(
__in ProfileCollection_t* pCollection
);
HRESULT SubscribeWithVoicemailServer();
HRESULT UnsubscribeFromVoicemailServer();
HRESULT UpdateActiveProfile();
void
UpdateRegistrationStatus(
__in_opt IRTCRegistrationStateChangeEvent* pEvent = NULL
);
void ResetStatusFlags();
void UpdateUserInfoInRegistry(
__in_opt IRTCProfile* pProfile = NULL
);
private:
static const DWORD sc_SettingFlags; //the setting flags we care about
CComPtr<IRTCProfile> m_cpActiveSIPProfile; //active RTCProfile
ProfileCollection_t m_SIPProxyCollection;
ProfileCollection_t m_BackupProxyCollection;
SubscriptionCollection_t m_VoicemailCollection;
UINT m_RegistrationStatusFlags; //flags indicating registration status
UINT m_SubscriptionStatusFlags; //flags indicating subscription status
};
#endif /* __PROXYSERVICES_HPP__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -