コード例 #1
0
ファイル: PsButtonTask.cpp プロジェクト: John-Chan/sipXtapi
// Handle an incoming event message (timer expiration).
// Return TRUE if the message was handled, otherwise FALSE.
UtlBoolean PsButtonTask::handleEventMessage(const OsEventMsg& rMsg)
{
   int           index;
   PsButtonInfo* pButtonInfo;
   PsPhoneTask*  pPhoneTask;
   UtlBoolean     processed;
   OsTimer*      pTimer;
   OsStatus      res;

   OsWriteLock lock(mMutex);        // acquire a write lock

   if (mpButtonInfo == NULL)        // if not yet initialized, just return
      return FALSE;

   processed = TRUE;

   switch(rMsg.getMsgSubType())
   {
   case OsEventMsg::NOTIFY:
      rMsg.getUserData(index);                  // get button index
      rMsg.getEventData((int&) pTimer);         // get timer object
      assert(index > 0 && index <= mMaxBtnIdx);  // check for valid index
      pButtonInfo = &mpButtonInfo[index];        // get ptr to button info

      // In order to send the phone set task a button repeat message, three
      // conditions must be satisfied:
      // 1) The button must currently be down
      // 2) The BUTTON_REPEAT event must be enabled for this button
      // 3) The pointers to the OsTimer object in the mpRepTimers array and
      //    the event message must match (otherwise, we may be processing an
      //    event message for an OsTimer object that has already be released.
      if ((pButtonInfo->getState() == PsButtonInfo::DOWN) &&
          (pButtonInfo->getEventMask() & PsButtonInfo::BUTTON_REPEAT) &&
          (mpRepTimers[index] == pTimer))
      {                             // post msg to the phone set
         pPhoneTask = PsPhoneTask::getPhoneTask();
         res = pPhoneTask->postEvent(PsMsg::BUTTON_REPEAT,  // msg type
                                     this,                  // source
                                     index,                 // button index
                                     pButtonInfo->getId()); // button id
         assert(res == OS_SUCCESS);
      }
      break;
   default:
      processed = FALSE;            // unexpected message subtype
      break;
   }

   return processed;
}
コード例 #2
0
UtlBoolean SipXMessageObserver::handleMessage(OsMsg& rMsg)
{
    UtlBoolean bRet = FALSE ;

    if (rMsg.getMsgType() == OsMsg::OS_EVENT)
    {
        OsEventMsg* pEventMsg = (OsEventMsg*) &rMsg ;
        intptr_t eventType ;
        pEventMsg->getUserData(eventType) ;

        switch (eventType)
        {
            case SIPXMO_NOTIFICATION_STUN:
                handleStunOutcome(pEventMsg) ;
                bRet = TRUE ;
                break ;
            default:
               if (rMsg.getMsgSubType() == OsEventMsg::NOTIFY)
               {
                  // this shouldn't be used at all
                  assert(false);
               }
               break;
        }                
    }
    else
    {
	    SipMessage* pSipMessage = (SipMessage*) ((SipMessageEvent&)rMsg).getMessage() ;
        UtlString method;
    
        pSipMessage->getRequestMethod(&method);
        
        if (pSipMessage && pSipMessage->isResponse())
        {
            int messageType = ((SipMessageEvent&)rMsg).getMessageStatus();

            // ok, the phone has received a response to a sent INFO message.
            bRet = handleIncomingInfoStatus(pSipMessage, messageType);
        }
        else if (pSipMessage && !pSipMessage->isResponse())
        {
            if (method == SIP_INFO_METHOD)
            {
                // ok, the phone has received an INFO message.
                bRet = handleIncomingInfoMessage(pSipMessage);
            }
        }        
    }
    return bRet;
}
コード例 #3
0
UtlBoolean SipXMessageObserver::handleMessage(OsMsg& rMsg)
{
    UtlBoolean bRet = FALSE ;

    switch (rMsg.getMsgType())
    {
       case OsMsg::OS_EVENT:
       {
           OsEventMsg* pEventMsg = (OsEventMsg*) &rMsg ;
           void* eventType ;
           pEventMsg->getUserData(eventType) ;

           switch ((intptr_t)eventType)
           {
               case SIPXMO_NOTIFICATION_STUN:
                   handleStunOutcome(pEventMsg) ;
                   bRet = TRUE ;
                   break ;
           }
           break ;
        }
        case OsMsg::PHONE_APP:
        {
           SipMessage* pSipMessage = (SipMessage*) ((SipMessageEvent&)rMsg).getMessage() ;
           UtlString method;

           pSipMessage->getRequestMethod(&method);

           if (pSipMessage && pSipMessage->isResponse())
           {
               // ok, the phone has received a response to a sent INFO message.
               bRet = handleIncomingInfoStatus(pSipMessage);
           }
           else if (pSipMessage && !pSipMessage->isResponse())
           {
               if (method == SIP_INFO_METHOD)
               {
                   // ok, the phone has received an INFO message.
                   bRet = handleIncomingInfoMessage(pSipMessage);
               }
           }
           break ;
       }
       default:
          break ;
    }
    return bRet;
}
コード例 #4
0
// Handle messages directed to this server task.
UtlBoolean MpStreamPlaylistPlayer::handleMessage(OsMsg& rMsg)
{
   switch (rMsg.getMsgType())
   {
      case OsMsg::OS_EVENT:
         OsEventMsg* pMsg = (OsEventMsg*) &rMsg;
         intptr_t status;
         int index;
	 void* indexVoid;

         pMsg->getUserData(indexVoid);
	 index = (int)(intptr_t)indexVoid;
         if (pMsg->getEventData(status) == OS_SUCCESS)
         {
            PlayListEntry* e = (PlayListEntry*)mPlayListDb->at(index) ;
#ifdef MP_STREAM_DEBUG /* [ */
            osPrintf("MpStreamPlaylistPlayer::handleMessage(%p): Received Feeder event: %s \n",
                     this, getFeederEventString(status));

            OsSysLog::add(FAC_MP, PRI_DEBUG,
               "MpStreamPlaylistPlayer::handleMessage(%p): Received Feeder event: %s index=%d e->index=%d",
                  this, getFeederEventString(status), index, e?e->index:-1);
#endif /* MP_STREAM_DEBUG ] */
            switch (status)
            {
               case FeederRealizedEvent:
                  setEntryState(e, PlayerRealized);
                  break;

               case FeederPrefetchedEvent:
                  setEntryState(e, PlayerPrefetched);
                  break;

               case FeederStoppedEvent:
                  if (mAggregateState != PlayerPlaying)
                  {
                     setEntryState(e, PlayerPrefetched);
                  }
                  break;

               case FeederRenderingEvent:
                  break;

               case FeederFailedEvent:
                  setEntryState(e, PlayerFailed);
                  break;

               case FeederStreamPlayingEvent:
                  setEntryState(e, PlayerPlaying);
                  break;

               case FeederStreamPausedEvent:
                  setEntryState(e, PlayerPaused);
                  break;

               case FeederStreamStoppedEvent:
                  setEntryState(e, PlayerStopped);
                  break;

               case FeederStreamDestroyedEvent:
                  setEntryState(e, PlayerDestroyed);
                  break;

               case FeederStreamAbortedEvent:
                  setEntryState(e, PlayerStopped);
                  break;

            }
         }
         break;
   }

   return TRUE;
}