ptterminal.cpp

来自「基于sipfoundy 公司开发的sipx协议API」· C++ 代码 · 共 1,679 行 · 第 1/5 页

CPP
1,679
字号
                                        pGroup->setTaoClient(mpClient);                                        componentGroup[i] = *pGroup;                                        mpComponentGroups->insert(PHONE_SET, (TaoObjHandle)pGroup);                                }                                else                                {                                        PtComponentGroup *pComponent = (PtComponentGroup *) objValue;                                        componentGroup[i] = *pComponent;                                }                                break;                        case PsTaoComponentGroup::OTHER:                                if (TAO_NOT_FOUND == mpComponentGroups->findValue(OTHER, objValue))                                {                                        PtPhoneMicrophone* pMicrophone = new PtPhoneMicrophone(mpClient);                                        PtPhoneSpeaker* pSpeaker = new PtPhoneSpeaker(mpClient);                                        pMicrophone->setGroupType(PtComponentGroup::OTHER);                                        pSpeaker->setGroupType(PtComponentGroup::OTHER);                                        components[0] = pMicrophone;                                        components[1] = pSpeaker;                                        PtComponentGroup *pGroup = new PtComponentGroup(PtComponentGroup::OTHER,                                                                                                        "OTHER",                                                                                                        components,                                                                                                        2);                                        pGroup->setTaoClient(mpClient);                                        componentGroup[i] = *pGroup;                                        mpComponentGroups->insert(OTHER, (TaoObjHandle)pGroup);                                }                                else                                {                                        PtComponentGroup *pComponent = (PtComponentGroup *) objValue;                                        componentGroup[i] = *pComponent;                                }                                break;                        default:                                break;                        }                }        }        return PT_SUCCESS;}PtStatus PtTerminal::getComponents(PtComponent* components[],                                                                        int size,                                                                        int& nItems){        if (!mpClient)        {                return PT_NOT_FOUND;        }        if (mpComponents)        {                int num = mpComponents->numEntries();                if (num > 0)                {                        TaoObjHandle *objs;                        objs = new TaoObjHandle[num];                        mpComponents->getActiveObjects(objs, num);                        if (num > size)                                num = size;                        nItems = num;                        for (int i = 0; i < num; i++)                        {                                components[i] = (PtComponent *) objs[i];                        }                        delete[] objs;                        return PT_SUCCESS;                }        }    char buff[MAXIMUM_INTEGER_STRING_LENGTH];    sprintf(buff, "%d", size);        UtlString arg(buff);        mpTransactionCnt->add();        unsigned int transactionId = mpTransactionCnt->getRef();        OsProtectedEvent *pe = mpEventMgr->alloc();        TaoMessage      msg(TaoMessage::REQUEST_TERMINAL,                                                                        TaoMessage::GET_COMPONENTS,                                                                        transactionId,                                                                        0, //NULL                                                                        (TaoObjHandle)pe,                                                                        1,                                                                        arg);        mpClient->sendRequest(msg);        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))        {                mpClient->resetConnectionSocket(msg.getMsgID());        // If the event has already been signalled, clean up        if(OS_ALREADY_SIGNALED == pe->signal(0))        {            mpEventMgr->release(pe);        }                return PT_BUSY;        }        pe->getStringData((UtlString &)arg);        pe->getIntData(nItems);#ifdef PTAPI_TEST        int cmd;        pe->getIntData2(cmd);        assert(cmd == TaoMessage::GET_COMPONENTS);#endif        mpEventMgr->release(pe);        TaoString types(arg, TAOMESSAGE_DELIMITER);        if (nItems > 0)        {                PtPhoneButton *pButton;                PtPhoneDisplay *pDisplay;                PtPhoneGraphicDisplay *pGraphicDisplay;                PtPhoneHookswitch *pHookswitch;                PtPhoneLamp *pLamp;                PtPhoneMicrophone* pMicrophone;                PtPhoneRinger *pRinger;                PtPhoneSpeaker *pSpeaker;                int max = (size < nItems) ? size : nItems;                for (int i = 0; i < max; i++)                {                        int type = atoi(types[i]);                        TaoObjHandle objValue;                        switch (type)                        {                        case PsTaoComponent::BUTTON:                                {                                        UtlString name;                                        for (; i < nItems; i++)                                        {                                                name = types[i + 1];                                                pButton = new PtPhoneButton(mpClient, name.data());                                                components[i] = pButton;                                                mpComponents->insert((TaoObjHandle)pButton, (TaoObjHandle)pButton);                                        }                                }                                break;                        case PsTaoComponent::DISPLAY:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)DISPLAY, objValue))                                {                                        osPrintf("PtTerminal:: Creating PsTaoComponent::DISPLAY\n") ;                                        pDisplay = new PtPhoneDisplay(mpClient);                                        components[i] = pDisplay;                                        mpComponents->insert((TaoObjHandle)DISPLAY, (TaoObjHandle)pDisplay);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        case PsTaoComponent::GRAPHIC_DISPLAY:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)GRAPHIC_DISPLAY, objValue))                                {                                        pGraphicDisplay = new PtPhoneGraphicDisplay(mpClient);                                        components[i] = pGraphicDisplay;                                        mpComponents->insert((TaoObjHandle)GRAPHIC_DISPLAY, (TaoObjHandle)pGraphicDisplay);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        case PsTaoComponent::HOOKSWITCH:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)HOOKSWITCH, objValue))                                {                                        pHookswitch = new PtPhoneHookswitch(mpClient);                                        components[i] = pHookswitch;                                        mpComponents->insert((TaoObjHandle)HOOKSWITCH, (TaoObjHandle)pHookswitch);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        case PsTaoComponent::LAMP:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)LAMP, objValue))                                {                                        pLamp = new PtPhoneLamp(mpClient);                                        components[i] = pLamp;                                        mpComponents->insert((TaoObjHandle)LAMP, (TaoObjHandle)pLamp);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        case PsTaoComponent::MICROPHONE:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)MICROPHONE, objValue))                                {                                        pMicrophone = new PtPhoneMicrophone(mpClient);                                        components[i] = pMicrophone;                                        mpComponents->insert((TaoObjHandle)MICROPHONE, (TaoObjHandle)pMicrophone);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        case PsTaoComponent::RINGER:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)RINGER, objValue))                                {                                        pRinger = new PtPhoneRinger(mpClient);                                        components[i] = pRinger;                                        mpComponents->insert((TaoObjHandle)RINGER, (TaoObjHandle)pRinger);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        case PsTaoComponent::SPEAKER:                                if (TAO_NOT_FOUND == mpComponents->findValue((TaoObjHandle)SPEAKER, objValue))                                {                                        pSpeaker = new PtPhoneSpeaker(mpClient);                                        components[i] = pSpeaker;                                        mpComponents->insert((TaoObjHandle)SPEAKER, (TaoObjHandle)pSpeaker);                                }                                else                                {                                        components[i] = (PtComponent *) objValue;                                }                                break;                        default:                                break;                        }                }        }        return PT_SUCCESS;}PtStatus PtTerminal::getConfiguration(PtConfigDb& rpConfigDb){        if (!mpClient)        {                return PT_NOT_FOUND;        }        mpTransactionCnt->add();        unsigned int transactionId = mpTransactionCnt->getRef();        OsProtectedEvent *pe = mpEventMgr->alloc();        TaoMessage      msg(TaoMessage::REQUEST_TERMINAL,                                                                        TaoMessage::GET_CONFIG,                                                                        transactionId,                                                                        0, //NULL                                                                        (TaoObjHandle)pe,                                                                        0,                                                                        "");        mpClient->sendRequest(msg);        int rc;        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))        {                mpClient->resetConnectionSocket(msg.getMsgID());        // If the event has already been signalled, clean up        if(OS_ALREADY_SIGNALED == pe->signal(0))        {            mpEventMgr->release(pe);        }                return PT_BUSY;        }        pe->getEventData((int &)rc);#ifdef PTAPI_TEST        int cmd;        pe->getIntData2(cmd);        assert(cmd == TaoMessage::GET_CONFIG);#endif        mpEventMgr->release(pe);        return PT_SUCCESS;}PtStatus PtTerminal::getDoNotDisturb(PtBoolean& rFlag){        if (!mpClient)        {                return PT_NOT_FOUND;        }        mpTransactionCnt->add();        unsigned int transactionId = mpTransactionCnt->getRef();        OsProtectedEvent *pe = mpEventMgr->alloc();        TaoMessage      msg(TaoMessage::REQUEST_TERMINAL,                                                                        TaoMessage::GET_DONOT_DISTURB,                                                                        transactionId,                                                                        0, //NULL                                                                        (TaoObjHandle)pe,                                                                        0,                                                                        "");        mpClient->sendRequest(msg);        int rc;        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))        {                mpClient->resetConnectionSocket(msg.getMsgID());        // If the event has already been signalled, clean up        if(OS_ALREADY_SIGNALED == pe->signal(0))        {            mpEventMgr->release(pe);        }                return PT_BUSY;        }        pe->getEventData((int &)rc);#ifdef PTAPI_TEST        int cmd;        pe->getIntData2(cmd);        assert(cmd == TaoMessage::GET_DONOT_DISTURB);#endif        mpEventMgr->release(pe);        return PT_SUCCESS;}PtStatus PtTerminal::getTerminalConnections(PtTerminalConnection termConnections[],                                                                                         int size,                                                                                         int& nItems){        if (!mpClient)        {                return PT_NOT_FOUND;        }        UtlString arg(mTerminalName);        mpTransactionCnt->add();        unsigned int transactionId = mpTransactionCnt->getRef();

⌨️ 快捷键说明

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