⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calldisplayitem.cpp

📁 一个WinCE6。0下的IP phone的源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            break;

        case e_csTransferring:
            hr = DrawTransferring(hdc, pRECT, fSelected);
            break;
            
        default:
            hr = DrawCallInfo(hdc, pRECT, fSelected);
            break;
        }
    }

    return hr;
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::GetCall
    
    Returns the current call object associated with this item.
------------------------------------------------------------------------------*/
HRESULT 
CallDisplayItem_t::GetCall(
    Call_t**    ppCall
    )
{
    TRACE(ZONE_PHONEAPP_FUNCTION); 
    
    // Parameter check
    if(ppCall == NULL)
    {
        return E_POINTER;
    }

    // Fail with E_FAIL if we don't have an interface
    if(m_cpCall == NULL)
    {
        *ppCall = NULL;
        return E_FAIL;
    }

    *ppCall = m_cpCall;
    (*ppCall)->AddRef();

    return S_OK;
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::GetCallStatus
    
    Returns the status of the call associated with this item, or "invalid" if
    there is no call associated with this item.
------------------------------------------------------------------------------*/
CallDisplayItemState 
CallDisplayItem_t::GetState(
    void
    )
{
    if (m_State == e_csDialing)
    {
        return m_State;
    }

    RTC_SESSION_STATE CallStatus = RTCSS_IDLE;
    
    if(m_cpCall != NULL)
    {
        CallStatus = m_cpCall->GetCallStatus();        
    }

    if (m_State == e_csTransferring)
    {
        return (CallStatus == e_csDisconnected) ? e_csDisconnected : e_csTransferring;
    }

    return (CallDisplayItemState)CallStatus;
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::GetText
    
    Called to retrieve the current text.
------------------------------------------------------------------------------*/
HRESULT CallDisplayItem_t::GetText(
    WCHAR*  pBuffer,
    INT     BufferSize
    )
{
    if (pBuffer == NULL || BufferSize <= 0)
    {
        return E_INVALIDARG; 
    }
    
    //if we're dialing or transferring the main text is the text in the edit control
    //otherwise its undefined
    if (m_State == e_csDeferToCallStatus)
    {
        return S_FALSE;
    }


    if (!(HWND)m_EditControl || m_RemovingEditControl)
    {
        return S_FALSE;
    }


    return GetWindowText(
                m_EditControl, 
                pBuffer, 
                BufferSize
                );
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::IsAnimated
    
    Returns TRUE if this item is currently animating.
------------------------------------------------------------------------------*/
BOOL 
CallDisplayItem_t::IsAnimated(
    void
    )
{
    // If we are drawing an actual call item (e.g. not dialing/transferring)
    // we need to be updating the timer/glyph as appropriate
    return(m_State == e_csDeferToCallStatus);
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::SetFocus
    
    Sets focus to the embedded edit control when needed
    
    Returns (BOOL): TRUE if focus was set to an edit control, FALSE otherwise
------------------------------------------------------------------------------*/
BOOL 
CallDisplayItem_t::SetFocus(
    void
    )
{
    if (!(HWND)m_EditControl || 
        (m_State != e_csDialing && m_State != e_csTransferring))
    {
        return FALSE;
    }

    ::SetFocus(m_EditControl);
    return TRUE;
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::AssignCall
    
    Assigns a current call to this display item when the item
    was previously in the dialing stage. Forces the item to 
    defer state type to the call
    
    Parameters:
        pCall: The call being assigned
------------------------------------------------------------------------------*/
HRESULT 
CallDisplayItem_t::AssignCall(
    Call_t* pCall
    )
{
    TRACE(ZONE_PHONEAPP_FUNCTION); 
    
    if (pCall == NULL)
    {
       ASSERT(FALSE);
       return E_INVALIDARG;
    }

    m_State = e_csDeferToCallStatus;
    m_cpCall = pCall;
    
    return S_OK;
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::StartTransferring
    
    Moves the item state to internal transferring
------------------------------------------------------------------------------*/
HRESULT 
CallDisplayItem_t::StartTransferring(
    void
    )
{
    ASSERT(m_State == e_csDeferToCallStatus);

    m_State = e_csTransferring;
    
    if (::IsWindow(m_EditControl))
    {
        SetWindowText(
            m_EditControl, 
            L""
            );
    }
    return S_OK;
}

/*------------------------------------------------------------------------------
    CallDisplayItem_t::StopTransferring
    
    Moves the item out of the internal transferring state
------------------------------------------------------------------------------*/
HRESULT 
CallDisplayItem_t::StopTransferring(
    void
    )
{
    if (m_State == e_csTransferring)
    {
        m_State = e_csDeferToCallStatus;
    }
    
    return S_OK;
}
/*------------------------------------------------------------------------------
    CallDisplayItem_t::GetSubItemText
    
    Gets the text for the specified subitem of this IVoIPDisplayItem
------------------------------------------------------------------------------*/
HRESULT 
CallDisplayItem_t::GetSubItemText(
    int     SubItemIndex, 
    WCHAR*  pBuffer, 
    UINT    BufferSize
    )
{
    HRESULT hr = S_OK;

    const WCHAR *c_wszLabel = NULL;
    
    pBuffer[0] = 0;

    switch (GetState())
    {
    case e_csDialing:
        switch (SubItemIndex)
        {
        case DialLabel:
            c_wszLabel = CommonUtilities_t::LoadString(
                                GlobalData_t::s_ModuleInstance, 
                                IDS_LABEL_DIAL
                                ); 

            if (c_wszLabel == NULL)
            {
                return CommonUtilities_t::GetErrorFromWin32();
            }
            StringCchCopy(pBuffer, BufferSize, c_wszLabel);
            break;

#ifdef AUTOMATION
        case DialEdit:
            GetWindowText(
                m_EditControl, 
                pBuffer, 
                BufferSize
                );
            
            break;
#endif
        default:
            hr = S_FALSE;
            break;
        }
        break;

    case e_csTransferring:
        switch (SubItemIndex)
        {
        case TransferText:
            {
                WCHAR CallerId[MAX_PATH] = L"";
                m_cpCall->GetDisplayName(
                            CallerId, 
                            ARRAYSIZE(CallerId)
                            ); 
                
                DWORD rgFmtArgs[] = { (DWORD)CallerId, };
                hr = CommonUtilities_t::ToHR(FormatMessage(
                    FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
                    CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_LABEL_TRANSFER),
                    0,
                    0,
                    pBuffer,
                    BufferSize,
                    reinterpret_cast<va_list*>(rgFmtArgs)
                    ));
            }
            break;

        case TransferLabel:
            c_wszLabel = CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_LABEL_DIAL);
            
            StringCchCopy(pBuffer, BufferSize, c_wszLabel);
            break;

#ifdef AUTOMATION            
        case TransferEdit:
            GetWindowText(
                m_EditControl, 
                pBuffer, 
                BufferSize
                );
            
            break;
#endif

        default:
            hr = S_FALSE;
            break;
        }
        break;

    default:
        switch (SubItemIndex)
        {
        case DisplayName:
            if (m_wstrCallerId[0])
            {
                StringCchCopy(pBuffer, BufferSize, m_wstrCallerId);
            }
            else
            {
                m_cpCall->GetDisplayName(pBuffer, BufferSize);

                if (pBuffer[0])
                {
                    m_wstrCallerId.assign(pBuffer);
                }
            }
            break;

        //For the URI, format the phone number
        case URI:

            m_cpCall->GetDisplayNumber(
                            pBuffer, 
                            BufferSize
                            ); 
            
            break;

        //for duration, format it
        case Duration:
            {
                SYSTEMTIME st = {0};
                if (m_cpCall == NULL)
                {
                    break;
                }
                
                hr = m_cpCall->GetDuration(&st);
            
                if(SUCCEEDED(hr))
                {
                    // Turn the duration into a string
                    hr = FormatDurationString(
                            &st,
                            pBuffer,
                            BufferSize
                            );
                }
            }
            break;

#ifdef AUTOMATION
        case Glyph:
            {
                RTC_SESSION_STATE CallStatus = m_cpCall->GetCallStatus();
                _snwprintf(pBuffer, BufferSize, L"Glyph for call status %d", CallStatus);
            }
            break;
#endif

        default:
            hr = S_FALSE;
            break;
        }
    }
    
    return hr;
}

HRESULT
CallDisplayItem_t::OnBackspace(
    void
    )
{
    if (m_State != e_csDialing && m_State != e_csTransferring)
    {
        return S_FALSE; 
    }

    return SendMessage(
                m_EditControl, 
                WM_CHAR, 
                L'\b',
                0
                );

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -