mmserv/tms/tmsproxy/src/tmsqueuehandler.cpp
changeset 12 5a06f39ad45b
parent 0 71ca22bcf22a
child 14 80975da52420
equal deleted inserted replaced
0:71ca22bcf22a 12:5a06f39ad45b
    25 #include "tmscallproxy.h"
    25 #include "tmscallproxy.h"
    26 
    26 
    27 using namespace TMS;
    27 using namespace TMS;
    28 
    28 
    29 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    30 // CQueueHandler::NewL
    30 // TMSQueueHandler::NewL
    31 // Symbian constructor
    31 // Symbian constructor
    32 // ----------------------------------------------------------------------------
    32 // ----------------------------------------------------------------------------
    33 //
    33 //
    34 CQueueHandler* CQueueHandler::NewL(RMsgQueue<TmsMsgBuf>* aMsgQueue,
    34 TMSQueueHandler* TMSQueueHandler::NewL(RMsgQueue<TmsMsgBuf>* aMsgQueue,
    35         TMSGlobalContext* glblCtx)
    35         TMSGlobalContext* glblCtx)
    36     {
    36     {
    37     CQueueHandler* self = new (ELeave) CQueueHandler(aMsgQueue, glblCtx);
    37     TMSQueueHandler* self = new (ELeave) TMSQueueHandler(aMsgQueue, glblCtx);
    38     CleanupStack::PushL(self);
    38     CleanupStack::PushL(self);
    39     self->ConstructL();
    39     self->ConstructL();
    40     CleanupStack::Pop(self);
    40     CleanupStack::Pop(self);
    41     return self;
    41     return self;
    42     }
    42     }
    43 
    43 
    44 // ----------------------------------------------------------------------------
    44 // ----------------------------------------------------------------------------
    45 // CQueueHandler::ConstructL
    45 // TMSQueueHandler::ConstructL
    46 // Second phase constructor.
    46 // Second phase constructor.
    47 // ----------------------------------------------------------------------------
    47 // ----------------------------------------------------------------------------
    48 //
    48 //
    49 void CQueueHandler::ConstructL()
    49 void TMSQueueHandler::ConstructL()
    50     {
    50     {
    51     iObserver = NULL;
    51     iObserver = NULL;
    52     }
    52     }
    53 
    53 
    54 // ----------------------------------------------------------------------------
    54 // ----------------------------------------------------------------------------
    55 // CQueueHandler::~CQueueHandler
    55 // TMSQueueHandler::~TMSQueueHandler
    56 // Destructor.
    56 // Destructor.
    57 // ----------------------------------------------------------------------------
    57 // ----------------------------------------------------------------------------
    58 //
    58 //
    59 CQueueHandler::~CQueueHandler()
    59 TMSQueueHandler::~TMSQueueHandler()
    60     {
    60     {
    61     Cancel();
    61     Cancel();
    62     if (iMsgQueue->Handle() > 0)
    62     if (iMsgQueue->Handle() > 0)
    63         {
    63         {
    64         iMsgQueue->Close();
    64         iMsgQueue->Close();
    69     delete iBuffer;
    69     delete iBuffer;
    70     iObserver = NULL;
    70     iObserver = NULL;
    71     }
    71     }
    72 
    72 
    73 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
    74 // CQueueHandler::CQueueHandler
    74 // TMSQueueHandler::TMSQueueHandler
    75 // Constructor.
    75 // Constructor.
    76 // ----------------------------------------------------------------------------
    76 // ----------------------------------------------------------------------------
    77 //
    77 //
    78 CQueueHandler::CQueueHandler(RMsgQueue<TmsMsgBuf>* aMsgQueue,
    78 TMSQueueHandler::TMSQueueHandler(RMsgQueue<TmsMsgBuf>* aMsgQueue,
    79         TMSGlobalContext* glblCtx) :
    79         TMSGlobalContext* glblCtx) :
    80     CActive(CActive::EPriorityStandard),
    80     CActive(CActive::EPriorityStandard),
    81     iMsgQueue(aMsgQueue),
    81     iMsgQueue(aMsgQueue),
    82     iChunkDataPtr(0, 0, 0)
    82     iChunkDataPtr(0, 0, 0)
    83     {
    83     {
    84     CActiveScheduler::Add(this);
    84     CActiveScheduler::Add(this);
    85     iTMSGlobalContext = glblCtx;
    85     iTMSGlobalContext = glblCtx;
    86     }
    86     }
    87 
    87 
    88 // ----------------------------------------------------------------------------
    88 // ----------------------------------------------------------------------------
    89 // CQueueHandler::Start
    89 // TMSQueueHandler::Start
    90 // Start listening for events on queue 0.
    90 // Start listening for events on queue 0.
    91 // ----------------------------------------------------------------------------
    91 // ----------------------------------------------------------------------------
    92 //
    92 //
    93 void CQueueHandler::Start()
    93 void TMSQueueHandler::Start()
    94     {
    94     {
    95     if (!IsActive())
    95     if (!IsActive() && iMsgQueue)
    96         {
    96         {
       
    97         iStatus = KRequestPending;
    97         iMsgQueue->NotifyDataAvailable(iStatus);
    98         iMsgQueue->NotifyDataAvailable(iStatus);
    98         SetActive();
    99         SetActive();
    99         }
   100         }
   100     }
   101     }
   101 
   102 
   102 // ----------------------------------------------------------------------------
   103 // ----------------------------------------------------------------------------
   103 // CQueueHandler::AddObserver
   104 // TMSQueueHandler::AddObserver
   104 //
   105 //
   105 // ----------------------------------------------------------------------------
   106 // ----------------------------------------------------------------------------
   106 //
   107 //
   107 TInt CQueueHandler::AddObserver(MQueueHandlerObserver& aObserver,
   108 gint TMSQueueHandler::AddObserver(MQueueHandlerObserver& aObserver,
   108         TInt /*aClientId*/)
   109         gint /*aClientId*/)
   109     {
   110     {
   110     TInt status = KErrNone;
   111     gint status = TMS_RESULT_SUCCESS;
   111 
   112 
   112     if (iObserver == NULL)
   113     if (iObserver == NULL)
   113         {
   114         {
   114         iObserver = &aObserver;
   115         iObserver = &aObserver;
   115         }
   116         }
   116     else
   117     else
   117         {
   118         {
   118         status = KErrAlreadyExists;
   119         status = TMS_RESULT_ALREADY_EXIST;
   119         }
   120         }
   120     return status;
   121     return status;
   121     }
   122     }
   122 
   123 
   123 // ----------------------------------------------------------------------------
   124 // ----------------------------------------------------------------------------
   124 // CQueueHandler::AddObserver
   125 // TMSQueueHandler::RemoveObserver
   125 // Marks observer as inactive in the list
   126 // Marks observer as inactive in the list
   126 // ----------------------------------------------------------------------------
   127 // ----------------------------------------------------------------------------
   127 //
   128 //
   128 TInt CQueueHandler::RemoveObserver(MQueueHandlerObserver& /*aObserver*/)
   129 gint TMSQueueHandler::RemoveObserver(MQueueHandlerObserver& /*aObserver*/)
   129     {
   130     {
   130     iObserver = NULL;
   131     iObserver = NULL;
   131     return KErrNone;
   132     return TMS_RESULT_SUCCESS;
   132     }
   133     }
   133 
   134 
   134 // ----------------------------------------------------------------------------
   135 // ----------------------------------------------------------------------------
   135 // CQueueHandler::DoCancel
   136 // TMSQueueHandler::DoCancel
   136 // Cancel outstanding request
   137 // Cancel outstanding request
   137 // ----------------------------------------------------------------------------
   138 // ----------------------------------------------------------------------------
   138 //
   139 //
   139 void CQueueHandler::DoCancel()
   140 void TMSQueueHandler::DoCancel()
   140     {
   141     {
   141     iMsgQueue->CancelDataAvailable();
   142     if (iMsgQueue)
   142     }
   143         {
   143 
   144         iMsgQueue->CancelDataAvailable();
   144 // ----------------------------------------------------------------------------
   145         }
   145 // CQueueHandler::RunL
   146     }
       
   147 
       
   148 // ----------------------------------------------------------------------------
       
   149 // TMSQueueHandler::RunL
   146 // Process requests.
   150 // Process requests.
   147 // ----------------------------------------------------------------------------
   151 // ----------------------------------------------------------------------------
   148 //
   152 //
   149 void CQueueHandler::RunL()
   153 void TMSQueueHandler::RunL()
   150     {
   154     {
   151     TmsMsgBuf msgBuf;
   155     TmsMsgBuf msgBuf;
   152     TInt err = iMsgQueue->Receive(msgBuf);
   156     gint err = TMS_RESULT_SUCCESS;
       
   157 
       
   158     if (iMsgQueue)
       
   159         {
       
   160         iMsgQueue->Receive(msgBuf);
       
   161         }
       
   162     else
       
   163         {
       
   164         err = TMS_RESULT_INVALID_STATE;
       
   165         }
   153 
   166 
   154     // Start monitoring for more events before calling the observer in case
   167     // Start monitoring for more events before calling the observer in case
   155     // client decides to destroy us before this RunL completes executing.
   168     // client decides to destroy us before this RunL completes executing.
   156     Start();
   169     Start();
   157 
   170 
   158     if (iObserver == NULL)
   171     if (iObserver == NULL)
   159         {
   172         {
   160         return;
   173         return;
   161         }
   174         }
   162 
   175 
   163     if (err == KErrNone)
   176     if (err == TMS_RESULT_SUCCESS)
   164         {
   177         {
   165         switch (msgBuf.iRequest)
   178         switch (msgBuf.iRequest)
   166             {
   179             {
   167             case ECmdGlobalEffectChange:
   180             case ECmdGlobalEffectChange:
   168                 iObserver->QueueEvent(msgBuf.iInt, msgBuf.iStatus, NULL);
   181                 iObserver->QueueEvent(msgBuf.iInt, msgBuf.iStatus, NULL);
   169                 break;
   182                 break;
   170             case ECmdRingToneOpenComplete:
       
   171                 iObserver->QueueEvent(TMS_EVENT_RINGTONE_OPEN_COMPLETE,
       
   172                         msgBuf.iStatus, &msgBuf.iInt64);
       
   173                 break;
       
   174             case ECmdRingTonePlayComplete:
       
   175                 iObserver->QueueEvent(TMS_EVENT_RINGTONE_PLAY_COMPLETE,
       
   176                         msgBuf.iStatus, NULL);
       
   177                 break;
       
   178             case ECmdGlobalRoutingChange:
   183             case ECmdGlobalRoutingChange:
   179                 iObserver->QueueEvent(msgBuf.iInt, msgBuf.iStatus,
   184                 iObserver->QueueEvent(msgBuf.iInt, msgBuf.iStatus,
   180                         &msgBuf.iUint);
   185                         &msgBuf.iUint);
   181                 break;
   186                 break;
       
   187             case ECmdRingToneOpenComplete:
       
   188                 iObserver->QueueEvent(TMS_EVENT_RINGTONE_OPEN_COMPLETE,
       
   189                         msgBuf.iStatus, NULL);
       
   190                 break;
       
   191             case ECmdRingTonePlayComplete:
       
   192                 iObserver->QueueEvent(TMS_EVENT_RINGTONE_PLAY_COMPLETE,
       
   193                         msgBuf.iStatus, NULL);
       
   194                 break;
       
   195             case ECmdRingToneDeinitComplete:
       
   196                 iObserver->QueueEvent(TMS_EVENT_RINGTONE_DEINIT_COMPLETE,
       
   197                         msgBuf.iStatus, NULL);
       
   198                 break;
   182             case ECmdDTMFOpenDnlinkComplete:
   199             case ECmdDTMFOpenDnlinkComplete:
   183             case ECmdDTMFOpenUplinkComplete:
   200             case ECmdDTMFOpenUplinkComplete:
   184                 iObserver->QueueEvent(TMS_EVENT_DTMF_TONE_STARTED,
   201                 iObserver->QueueEvent(TMS_EVENT_DTMF_TONE_STARTED,
   185                         msgBuf.iStatus, NULL);
   202                         msgBuf.iStatus, NULL);
   186                 break;
   203                 break;
   187             case ECmdDTMFTonePlayFinished:
   204             case ECmdDTMFTonePlayFinished:
   188                 iObserver->QueueEvent(TMS_EVENT_DTMF_TONE_STOPPED,
   205                 iObserver->QueueEvent(TMS_EVENT_DTMF_TONE_STOPPED,
   189                         msgBuf.iStatus, NULL);
   206                         msgBuf.iStatus, NULL);
   190                 break;
   207                 break;
       
   208             case ECmdInbandToneStarted:
       
   209                 iObserver->QueueEvent(TMS_EVENT_INBAND_TONE_STARTED,
       
   210                         msgBuf.iStatus, NULL);
       
   211                 break;
       
   212             case ECmdInbandToneStopped:
       
   213                 iObserver->QueueEvent(TMS_EVENT_INBAND_TONE_STOPPED,
       
   214                         msgBuf.iStatus, NULL);
       
   215                 break;
   191             default:
   216             default:
   192                 break;
   217                 break;
   193             }
   218             }
   194         }
   219         }
   195     }
   220     }
   196 
   221 
   197 // ----------------------------------------------------------------------------
   222 // ----------------------------------------------------------------------------
   198 // CQueueHandler::RunError
   223 // TMSQueueHandler::RunError
   199 // Process requests.
   224 // Process requests.
   200 // ----------------------------------------------------------------------------
   225 // ----------------------------------------------------------------------------
   201 //
   226 //
   202 TInt CQueueHandler::RunError(TInt /*aError*/)
   227 TInt TMSQueueHandler::RunError(TInt /*aError*/)
   203     {
   228     {
   204     // Current implementation of RunL does not leave
   229     // Current implementation of RunL does not leave
   205     return 0;
   230     return TMS_RESULT_SUCCESS;
   206     }
   231     }
   207 
   232 
   208 // ----------------------------------------------------------------------------
   233 // ----------------------------------------------------------------------------
   209 // CQueueHandler::Status
   234 // TMSQueueHandler::Status
   210 // Return request status.
   235 // Return request status.
   211 // ----------------------------------------------------------------------------
   236 // ----------------------------------------------------------------------------
   212 //
   237 //
   213 TRequestStatus* CQueueHandler::Status()
   238 TRequestStatus* TMSQueueHandler::Status()
   214     {
   239     {
   215     return &iStatus;
   240     return &iStatus;
   216     }
   241     }
   217 
   242 
   218 // End of File
   243 // End of File