mmserv/tms/tmscallserver/src/tmscallcsadpt.cpp
changeset 31 8dfd592727cb
parent 22 128eb6a32b84
child 33 5e8b14bae8c3
child 42 1fa3fb47b1e3
--- a/mmserv/tms/tmscallserver/src/tmscallcsadpt.cpp	Thu May 27 13:20:50 2010 +0300
+++ b/mmserv/tms/tmscallserver/src/tmscallcsadpt.cpp	Wed Jun 23 18:47:10 2010 +0300
@@ -33,14 +33,27 @@
 using namespace TMS;
 
 // -----------------------------------------------------------------------------
-// TMSCallCSAdpt::TMSCallCSAdpt
-//
+// TMSCallCSAdpt::NewL
+// Symbian constructor.
 // -----------------------------------------------------------------------------
 //
-TMSCallCSAdpt::TMSCallCSAdpt()
+TMSCallCSAdpt* TMSCallCSAdpt::NewL()
+    {
+    TMSCallCSAdpt* self = new (ELeave) TMSCallCSAdpt();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// TMSCallCSAdpt::ConstructL
+// 2-nd phase constructor.
+// -----------------------------------------------------------------------------
+//
+void TMSCallCSAdpt::ConstructL()
     {
     TRACE_PRN_FN_ENT;
-
     iCSDownlink = NULL;
     iCSUplink = NULL;
     iRouting = NULL;
@@ -48,8 +61,16 @@
     iDTMFDnlinkPlayer = NULL;
     iDTMFUplinkPlayer = NULL;
     iDTMFNotifier = NULL;
+    TRACE_PRN_FN_EXT;
+    }
 
-    TRACE_PRN_FN_EXT;
+// -----------------------------------------------------------------------------
+// TMSCallCSAdpt::TMSCallCSAdpt
+//
+// -----------------------------------------------------------------------------
+//
+TMSCallCSAdpt::TMSCallCSAdpt()
+    {
     }
 
 // -----------------------------------------------------------------------------
@@ -60,19 +81,19 @@
 TMSCallCSAdpt::~TMSCallCSAdpt()
     {
     TRACE_PRN_FN_ENT;
-    delete iCSDownlink;
-    delete iCSUplink;
+
     delete iRouting;
     delete iTarSettings;
+    delete iDTMFUplinkPlayer;
     delete iDTMFDnlinkPlayer;
-    delete iDTMFUplinkPlayer;
     delete iDTMFNotifier;
+    delete iCSUplink;
+    delete iCSDownlink;
 
     if (iMsgQueueUp.Handle() > 0)
         {
         iMsgQueueUp.Close();
         }
-
     if (iMsgQueueDn.Handle() > 0)
         {
         iMsgQueueDn.Close();
@@ -93,7 +114,6 @@
     iNextStreamId = 1;
     iUplinkInitialized = FALSE;
     iDnlinkInitialized = FALSE;
-
     TRACE_PRN_FN_EXT;
     return status;
     }
@@ -103,40 +123,44 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::CreateStream(TMSCallType /*callType*/,
-        TMSStreamType strmType, gint& outStrmId)
+gint TMSCallCSAdpt::CreateStream(const TMSCallType /*callType*/,
+        const TMSStreamType strmType, gint& outStrmId)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_SUCCESS);
     switch (strmType)
         {
         case TMS_STREAM_UPLINK:
+            {
             status = TMS_RESULT_ALREADY_EXIST;
             if (!iUplinkInitialized)
                 {
-                iUplinkInitialized = TRUE;
                 iUplinkStreamId = iNextStreamId;
                 outStrmId = iUplinkStreamId;
                 iNextStreamId++;
-                iUplinkInitialized = TRUE;
+                //iUplinkInitialized = TRUE; //not initialized yet!
                 status = TMS_RESULT_SUCCESS;
                 }
             break;
+            }
         case TMS_STREAM_DOWNLINK:
+            {
             status = TMS_RESULT_ALREADY_EXIST;
             if (!iDnlinkInitialized)
                 {
-                iDnlinkInitialized = TRUE;
                 iDnlinkStreamId = iNextStreamId;
                 outStrmId = iDnlinkStreamId;
                 iNextStreamId++;
-                iDnlinkInitialized = TRUE;
+                //iDnlinkInitialized = TRUE; //not initialized yet!
                 status = TMS_RESULT_SUCCESS;
                 }
             break;
+            }
         default:
+            {
             status = TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED;
             break;
+            }
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -147,8 +171,10 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::InitStream(TMSCallType /*callType*/, TMSStreamType strmType,
-        gint strmId, TMSFormatType /*frmtType*/, const RMessage2& message)
+gint TMSCallCSAdpt::InitStream(const TMSCallType /*callType*/,
+        const TMSStreamType strmType, const gint strmId,
+        const TMSFormatType /*frmtType*/, const gint retrytime,
+        const RMessage2& message)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_SUCCESS);
@@ -157,6 +183,7 @@
         {
         case TMS_STREAM_UPLINK:
             {
+            status = TMS_RESULT_DOES_NOT_EXIST;
             if (strmId == iUplinkStreamId)
                 {
                 // Open message queue handling client-server communication
@@ -167,30 +194,14 @@
                     }
                 if (status == TMS_RESULT_SUCCESS)
                     {
-                    TRAP(status, iCSUplink = TMSCSUplink::NewL(*this));
-
-                    if (status == TMS_RESULT_SUCCESS)
-                        {
-                        TRAP(status, iDTMFUplinkPlayer =
-                                TMSDTMFProvider::NewL());
-                        iDTMFUplinkPlayer->AddObserver(*this);
-                        if (!iDTMFNotifier)
-                            {
-                            TRAP(status, iDTMFNotifier =
-                                    TMSDtmfNotifier::NewL());
-                            }
-                        }
+                    status = InitUplink(retrytime);
                     }
-                iStrmtype = TMS_STREAM_UPLINK;
-                }
-            else
-                {
-                status = TMS_RESULT_DOES_NOT_EXIST;
                 }
             break;
             }
         case TMS_STREAM_DOWNLINK:
             {
+            status = TMS_RESULT_DOES_NOT_EXIST;
             if (strmId == iDnlinkStreamId)
                 {
                 // Open message queue handling client-server communication
@@ -201,35 +212,8 @@
                     }
                 if (status == TMS_RESULT_SUCCESS)
                     {
-                    TRAP(status, iCSDownlink = TMSCSDownlink::NewL(*this));
-                    if (status == TMS_RESULT_SUCCESS)
-                        {
-                        TRAP(status, iRouting =
-                                CTelephonyAudioRouting::NewL(*this));
-                        if (status == TMS_RESULT_SUCCESS)
-                            {
-                            TRAP(status, iTarSettings = TMSTarSettings::NewL());
-                            }
-                        if (status == TMS_RESULT_SUCCESS)
-                            {
-                            TRAP(status, iDTMFDnlinkPlayer =
-                                    TMSAudioDtmfTonePlayer::NewL(*this,
-                                    KAudioDTMFString,
-                                    KAudioPriorityDTMFString));
-
-                            if (!iDTMFNotifier)
-                                {
-                                TRAP(status, iDTMFNotifier =
-                                        TMSDtmfNotifier::NewL());
-                                }
-                            }
-                        }
+                    status = InitDownlink(retrytime);
                     }
-                iStrmtype = TMS_STREAM_DOWNLINK;
-                }
-            else
-                {
-                status = TMS_RESULT_DOES_NOT_EXIST;
                 }
             break;
             }
@@ -246,32 +230,98 @@
     }
 
 // -----------------------------------------------------------------------------
+// TMSCallCSAdpt::InitUplink
+//
+// -----------------------------------------------------------------------------
+//
+gint TMSCallCSAdpt::InitUplink(const gint retrytime)
+    {
+    gint status(TMS_RESULT_SUCCESS);
+
+    if (!iCSUplink)
+        {
+        TRAP(status, iCSUplink = TMSCSUplink::NewL(*this, retrytime));
+        }
+    if (!iDTMFUplinkPlayer && status == TMS_RESULT_SUCCESS)
+        {
+        TRAP(status, iDTMFUplinkPlayer = TMSDTMFProvider::NewL());
+        iDTMFUplinkPlayer->AddObserver(*this);
+        }
+    if (!iDTMFNotifier && status == TMS_RESULT_SUCCESS)
+        {
+        TRAP(status, iDTMFNotifier = TMSDtmfNotifier::NewL());
+        }
+    return status;
+    }
+
+// -----------------------------------------------------------------------------
+// TMSCallCSAdpt::InitDownlink
+//
+// -----------------------------------------------------------------------------
+//
+gint TMSCallCSAdpt::InitDownlink(const gint retrytime)
+    {
+    gint status(TMS_RESULT_SUCCESS);
+
+    if (!iCSDownlink)
+        {
+        TRAP(status, iCSDownlink = TMSCSDownlink::NewL(*this, retrytime));
+        }
+    if (!iRouting && status == TMS_RESULT_SUCCESS)
+        {
+        TRAP(status, iRouting = CTelephonyAudioRouting::NewL(*this));
+        }
+    if (!iTarSettings && status == TMS_RESULT_SUCCESS)
+        {
+        TRAP(status, iTarSettings = TMSTarSettings::NewL());
+        }
+    if (!iDTMFDnlinkPlayer && status == TMS_RESULT_SUCCESS)
+        {
+        TRAP(status, iDTMFDnlinkPlayer = TMSAudioDtmfTonePlayer::NewL(*this,
+                KAudioDTMFString, KAudioPriorityDTMFString));
+        }
+    if (!iDTMFNotifier && status == TMS_RESULT_SUCCESS)
+        {
+        TRAP(status, iDTMFNotifier = TMSDtmfNotifier::NewL());
+        }
+    return status;
+    }
+
+// -----------------------------------------------------------------------------
 // TMSCallCSAdpt::StartStream
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::StartStream(TMSCallType /*callType*/,
-        TMSStreamType strmType, gint strmId)
+gint TMSCallCSAdpt::StartStream(const TMSCallType /*callType*/,
+        const TMSStreamType strmType, const gint strmId, const gint retrytime)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
+    gint status(TMS_RESULT_INVALID_STATE);
     switch (strmType)
         {
         case TMS_STREAM_UPLINK:
+            {
             if (iCSUplink && strmId == iUplinkStreamId)
                 {
-                iCSUplink->Activate();
+                iCSUplink->Activate(retrytime);
+                status = TMS_RESULT_SUCCESS;
                 }
             break;
+            }
         case TMS_STREAM_DOWNLINK:
+            {
             if (iCSDownlink && strmId == iDnlinkStreamId)
                 {
-                iCSDownlink->Activate();
+                iCSDownlink->Activate(retrytime);
+                status = TMS_RESULT_SUCCESS;
                 }
             break;
+            }
         default:
+            {
             status = TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED;
             break;
+            }
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -282,11 +332,11 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::PauseStream(TMSCallType /*callType*/,
-        TMSStreamType /*strmType*/, gint /*strmId*/)
+gint TMSCallCSAdpt::PauseStream(const TMSCallType /*callType*/,
+        const TMSStreamType /*strmType*/, const gint /*strmId*/)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
+    gint status(TMS_RESULT_FEATURE_NOT_SUPPORTED);
     TRACE_PRN_FN_EXT;
     return status;
     }
@@ -296,32 +346,39 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::StopStream(TMSCallType /*callType*/, TMSStreamType strmType,
-        gint strmId)
+gint TMSCallCSAdpt::StopStream(const TMSCallType /*callType*/,
+        const TMSStreamType strmType, const gint strmId)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
+    gint status(TMS_RESULT_INVALID_STATE);
+
     switch (strmType)
         {
         case TMS_STREAM_UPLINK:
+            {
             if (iCSUplink && strmId == iUplinkStreamId)
                 {
                 iCSUplink->Deactivate();
-                NotifyClient(iUplinkStreamId, ECmdUplinkInitComplete,
-                        status, 0);
+                status = TMS_RESULT_SUCCESS;
+                NotifyClient(iUplinkStreamId, ECmdUplinkInitComplete, status);
                 }
             break;
+            }
         case TMS_STREAM_DOWNLINK:
+            {
             if (iCSDownlink && strmId == iDnlinkStreamId)
                 {
                 iCSDownlink->Deactivate();
-                NotifyClient(iDnlinkStreamId, ECmdDownlinkInitComplete,
-                        status, 0);
+                status = TMS_RESULT_SUCCESS;
+                NotifyClient(iDnlinkStreamId, ECmdDownlinkInitComplete, status);
                 }
             break;
+            }
         default:
+            {
             status = TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED;
             break;
+            }
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -332,20 +389,22 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::DeinitStream(TMSCallType /*callType*/,
-        TMSStreamType strmType, gint strmId)
+gint TMSCallCSAdpt::DeinitStream(const TMSCallType /*callType*/,
+        const TMSStreamType strmType, const gint strmId)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
+    gint status(TMS_RESULT_INVALID_STATE);
+
     switch (strmType)
         {
         case TMS_STREAM_UPLINK:
+            {
             if (iCSUplink && strmId == iUplinkStreamId)
                 {
                 iCSUplink->Deactivate();
                 iUplinkInitialized = FALSE;
-                NotifyClient(iUplinkStreamId, ECmdUplinkDeInitComplete,
-                        status, 0);
+                status = TMS_RESULT_SUCCESS;
+                NotifyClient(iUplinkStreamId, ECmdUplinkDeInitComplete, status);
                 }
             break;
         case TMS_STREAM_DOWNLINK:
@@ -353,13 +412,17 @@
                 {
                 iCSDownlink->Deactivate();
                 iDnlinkInitialized = FALSE;
+                status = TMS_RESULT_SUCCESS;
                 NotifyClient(iDnlinkStreamId, ECmdDownlinkDeInitComplete,
-                        status, 0);
+                        status);
                 }
             break;
+            }
         default:
+            {
             status = TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED;
             break;
+            }
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -370,30 +433,36 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::DeleteStream(TMSCallType /*callType*/,
-        TMSStreamType strmType, gint strmId)
+gint TMSCallCSAdpt::DeleteStream(const TMSCallType /*callType*/,
+        const TMSStreamType strmType, const gint strmId)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_SUCCESS);
     switch (strmType)
         {
         case TMS_STREAM_UPLINK:
+            {
             if (strmId == iUplinkStreamId)
                 {
                 iUplinkStreamId = -1;
                 iUplinkInitialized = FALSE;
                 }
             break;
+            }
         case TMS_STREAM_DOWNLINK:
+            {
             if (strmId == iDnlinkStreamId)
                 {
                 iDnlinkStreamId = -1;
                 iDnlinkInitialized = FALSE;
                 }
             break;
+            }
         default:
+            {
             status = TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED;
             break;
+            }
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -404,8 +473,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::DataXferBufferEmptied(TMSCallType /*callType*/,
-        TMSStreamType /*strmType*/, gint /*strmId*/)
+gint TMSCallCSAdpt::DataXferBufferEmptied(const TMSCallType /*callType*/,
+        const TMSStreamType /*strmType*/, const gint /*strmId*/)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_FEATURE_NOT_SUPPORTED);
@@ -418,8 +487,9 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::DataXferBufferFilled(TMSCallType /*callType*/,
-        TMSStreamType /*strmType*/, gint /*strmId*/, guint /*datasize*/)
+gint TMSCallCSAdpt::DataXferBufferFilled(const TMSCallType /*callType*/,
+        const TMSStreamType /*strmType*/, const gint /*strmId*/,
+        const guint /*datasize*/)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_FEATURE_NOT_SUPPORTED);
@@ -450,11 +520,12 @@
 gint TMSCallCSAdpt::GetMaxVolume(guint& volume)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSDownlink && iDnlinkInitialized)
         {
         volume = iCSDownlink->MaxVolume();
         status = TMS_RESULT_SUCCESS;
+        TRACE_PRN_N1(_L("TMS->TMSCallCSAdpt: GetMaxVolume [%d]"), volume);
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -468,12 +539,12 @@
 gint TMSCallCSAdpt::SetVolume(const guint volume)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSDownlink && iDnlinkInitialized)
         {
         iCSDownlink->SetVolume(volume);
         status = TMS_RESULT_SUCCESS;
-        NotifyClient(iDnlinkStreamId, ECmdSetVolume, status, 0);
+        NotifyClient(iDnlinkStreamId, ECmdSetVolume, status);
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -487,13 +558,12 @@
 gint TMSCallCSAdpt::GetVolume(guint& volume)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSDownlink && iDnlinkInitialized)
         {
         volume = iCSDownlink->Volume();
         status = TMS_RESULT_SUCCESS;
         }
-
     TRACE_PRN_FN_EXT;
     return status;
     }
@@ -506,11 +576,12 @@
 gint TMSCallCSAdpt::GetMaxGain(guint& gain)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSUplink && iUplinkInitialized)
         {
         gain = iCSUplink->MaxGain();
         status = TMS_RESULT_SUCCESS;
+        TRACE_PRN_N1(_L("TMS->TMSCallCSAdpt::GetMaxGain [%d]"), gain);
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -524,12 +595,12 @@
 gint TMSCallCSAdpt::SetGain(const guint gain)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
-    if (iUplinkInitialized)
+    gint status(TMS_RESULT_INVALID_STATE);
+    if (iCSUplink && iUplinkInitialized)
         {
         iCSUplink->SetGain(gain);
         status = TMS_RESULT_SUCCESS;
-        NotifyClient(iUplinkInitialized, ECmdSetGain, status, 0);
+        NotifyClient(iUplinkStreamId, ECmdSetGain, status);
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -543,7 +614,7 @@
 gint TMSCallCSAdpt::GetGain(guint& gain)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSUplink && iUplinkInitialized)
         {
         gain = iCSUplink->Gain();
@@ -561,11 +632,12 @@
 gint TMSCallCSAdpt::GetGlobalMaxVolume(guint& volume)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSDownlink && iDnlinkInitialized)
         {
         volume = iCSDownlink->MaxVolume();
         status = TMS_RESULT_SUCCESS;
+        TRACE_PRN_N1(_L("TMS->TMSCallCSAdpt::GetGlobalMaxVolume [%d]"), volume);
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -579,8 +651,7 @@
 gint TMSCallCSAdpt::SetGlobalVolume(const guint volume)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
-
+    gint status(TMS_RESULT_INVALID_STATE);
     iGlobalVol = volume;
     if (iCSDownlink && iDnlinkInitialized)
         {
@@ -599,13 +670,12 @@
 gint TMSCallCSAdpt::GetGlobalVolume(guint& volume)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSDownlink && iDnlinkInitialized)
         {
         volume = iCSDownlink->Volume();
         status = TMS_RESULT_SUCCESS;
         }
-
     TRACE_PRN_FN_EXT;
     return status;
     }
@@ -618,11 +688,12 @@
 gint TMSCallCSAdpt::GetGlobalMaxGain(guint& gain)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSUplink && iUplinkInitialized)
         {
         gain = iCSUplink->MaxGain();
         status = TMS_RESULT_SUCCESS;
+        TRACE_PRN_N1(_L("TMS->TMSCallCSAdpt::GetGlobalMaxGain [%d]"), gain);
         }
     TRACE_PRN_FN_EXT;
     return status;
@@ -636,8 +707,7 @@
 gint TMSCallCSAdpt::SetGlobalGain(const guint gain)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
-
+    gint status(TMS_RESULT_INVALID_STATE);
     iGlobalGain = gain;
     if (iCSUplink && iUplinkInitialized)
         {
@@ -656,7 +726,7 @@
 gint TMSCallCSAdpt::GetGlobalGain(guint& gain)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_ILLEGAL_OPERATION);
+    gint status(TMS_RESULT_INVALID_STATE);
     if (iCSUplink && iUplinkInitialized)
         {
         gain = iCSUplink->Gain();
@@ -668,7 +738,7 @@
 
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::GetCodecMode
-//
+// No codec format in CS call
 // -----------------------------------------------------------------------------
 //
 gint TMSCallCSAdpt::GetCodecMode(const TMSFormatType /*fmttype*/,
@@ -682,7 +752,7 @@
 
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::SetCodecMode
-//
+// No codec format in CS call
 // -----------------------------------------------------------------------------
 //
 gint TMSCallCSAdpt::SetCodecMode(const TMSFormatType /*fmttype*/,
@@ -696,7 +766,7 @@
 
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::GetSupportedBitRatesCount
-//
+// No codec format in CS call
 // -----------------------------------------------------------------------------
 //
 gint TMSCallCSAdpt::GetSupportedBitRatesCount(guint& /*count*/)
@@ -712,26 +782,15 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::GetSupportedBitRates(CBufFlat*& brbuffer)
+gint TMSCallCSAdpt::GetSupportedBitRates(CBufFlat*& /*brbuffer*/)
     {
     TRACE_PRN_FN_ENT;
-    TRAPD(status, GetSupportedBitRatesL(brbuffer));
+    gint status(TMS_RESULT_FEATURE_NOT_SUPPORTED);
     TRACE_PRN_FN_EXT;
     return status;
     }
 
 // -----------------------------------------------------------------------------
-// TMSCallCSAdpt::GetSupportedBitRatesL
-//
-// GetSupportedBitRates implementation which can leave.
-// -----------------------------------------------------------------------------
-//
-void TMSCallCSAdpt::GetSupportedBitRatesL(CBufFlat*& /*brbuffer*/)
-    {
-    User::Leave(TMS_RESULT_FEATURE_NOT_SUPPORTED);
-    }
-
-// -----------------------------------------------------------------------------
 // TMSCallCSAdpt::GetBitRate
 //
 // -----------------------------------------------------------------------------
@@ -775,7 +834,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::SetVAD(const TMSFormatType /*fmttype*/, const gboolean /*vad*/)
+gint TMSCallCSAdpt::SetVAD(const TMSFormatType /*fmttype*/,
+        const gboolean /*vad*/)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_FEATURE_NOT_SUPPORTED);
@@ -842,7 +902,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::SetOutput(TMSAudioOutput output)
+gint TMSCallCSAdpt::SetOutput(const TMSAudioOutput output)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_UNINITIALIZED_OBJECT);
@@ -913,7 +973,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::GetAvailableOutputsL(gint& count, CBufFlat*& outputsbuffer)
+gint TMSCallCSAdpt::GetAvailableOutputsL(gint& count, CBufFlat*& outputsbuf)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_UNINITIALIZED_OBJECT);
@@ -922,11 +982,11 @@
     if (iRouting)
         {
         RBufWriteStream stream;
-        stream.Open(*outputsbuffer);
+        stream.Open(*outputsbuf);
         CleanupClosePushL(stream);
 
-        TArray<CTelephonyAudioRouting::TAudioOutput> availableOutputs =
-                iRouting->AvailableOutputs();
+        TArray<CTelephonyAudioRouting::TAudioOutput>
+                availableOutputs = iRouting->AvailableOutputs();
 
         guint numOfItems = availableOutputs.Count();
         count = numOfItems;
@@ -949,26 +1009,23 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::StartDTMF(TMSStreamType strmtype, TDes& dtmfstring)
+gint TMSCallCSAdpt::StartDTMF(const TMSStreamType strmtype, TDes& dtmfstring)
     {
     TRACE_PRN_FN_ENT;
-    gint status(TMS_RESULT_SUCCESS);
-
+    gint status(TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED);
     TmsMsgBufPckg dtmfpckg;
+    dtmfpckg().iStatus = status;
+    dtmfpckg().iRequest = ECmdDTMFTonePlayFinished;
 
     if (strmtype == TMS_STREAM_DOWNLINK && iDnlinkInitialized)
         {
         if (iDTMFDnlinkPlayer)
             {
             iDTMFDnlinkPlayer->PlayDtmfTone(dtmfstring);
+            status = TMS_RESULT_SUCCESS;
             }
-
         dtmfpckg().iStatus = TMS_RESULT_SUCCESS;
         dtmfpckg().iRequest = ECmdDTMFToneDnlPlayStarted;
-        if (iDTMFNotifier)
-            {
-            iDTMFNotifier->SetDtmf(dtmfpckg, TRUE);
-            }
         }
     else if (strmtype == TMS_STREAM_UPLINK && iUplinkInitialized)
         {
@@ -976,17 +1033,18 @@
         if (iDTMFUplinkPlayer)
             {
             status = iDTMFUplinkPlayer->SendDtmfToneString(dtmfstring);
+            status = TMS_RESULT_SUCCESS;
             }
-
         dtmfpckg().iStatus = TMSUtility::EtelToTMSResult(status);
         dtmfpckg().iRequest = ECmdDTMFToneUplPlayStarted;
-
-        if (iDTMFNotifier)
-            {
-            iDTMFNotifier->SetDtmf(dtmfpckg, TRUE);
-            }
         }
 
+    if (iDTMFNotifier)
+        {
+        iDTMFNotifier->SetDtmf(dtmfpckg);
+        }
+
+    TRACE_PRN_IF_ERR(status);
     TRACE_PRN_FN_EXT;
     return status;
     }
@@ -996,7 +1054,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::StopDTMF(TMSStreamType streamtype)
+gint TMSCallCSAdpt::StopDTMF(const TMSStreamType streamtype)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_SUCCESS);
@@ -1020,14 +1078,14 @@
 //
 // -----------------------------------------------------------------------------
 //
-gint TMSCallCSAdpt::ContinueDTMF(gboolean continuesending)
+gint TMSCallCSAdpt::ContinueDTMF(const gboolean sending)
     {
     TRACE_PRN_FN_ENT;
     gint status(TMS_RESULT_UNINITIALIZED_OBJECT);
 
     if (iDTMFUplinkPlayer)
         {
-        status = iDTMFUplinkPlayer->ContinueDtmfStringSending(continuesending);
+        status = iDTMFUplinkPlayer->ContinueDtmfStringSending(sending);
         status = TMSUtility::EtelToTMSResult(status);
         }
 
@@ -1035,13 +1093,13 @@
     return status;
     }
 
-//From DTMFTonePlayerObserver
+//From TMSDTMFTonePlayerObserver
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::DTMFInitCompleted
 //
 // -----------------------------------------------------------------------------
 //
-void TMSCallCSAdpt::DTMFInitCompleted(gint /*error*/)
+void TMSCallCSAdpt::DTMFInitCompleted(gint /*status*/)
     {
     TRACE_PRN_FN_ENT;
     // TODO: process error
@@ -1053,23 +1111,23 @@
 //
 // -----------------------------------------------------------------------------
 //
-void TMSCallCSAdpt::DTMFToneFinished(gint error)
+void TMSCallCSAdpt::DTMFToneFinished(gint status)
     {
     TRACE_PRN_FN_ENT;
+    TRACE_PRN_IF_ERR(status);
     TmsMsgBufPckg dtmfpckg;
 
-    if (error == KErrUnderflow || error == KErrInUse)
+    // KErrUnderflow indicates end of DTMF playback.
+    if (status == KErrUnderflow || status == KErrInUse)
         {
-        error = TMS_RESULT_SUCCESS;
+        status = TMS_RESULT_SUCCESS;
         }
-
-    dtmfpckg().iStatus = TMSUtility::TMSResult(error);
+    dtmfpckg().iStatus = TMSUtility::TMSResult(status);
     dtmfpckg().iRequest = ECmdDTMFTonePlayFinished;
     if (iDTMFNotifier)
         {
-        iDTMFNotifier->SetDtmf(dtmfpckg, TRUE);
+        iDTMFNotifier->SetDtmf(dtmfpckg);
         }
-
     TRACE_PRN_FN_EXT;
     }
 
@@ -1079,19 +1137,18 @@
 // -----------------------------------------------------------------------------
 //
 void TMSCallCSAdpt::HandleDTMFEvent(
-        const TMSDTMFObserver::TCCPDtmfEvent aEvent, const gint aError,
-        const TChar /*aTone*/)
+        const TMSDTMFObserver::TCCPDtmfEvent event, const gint status,
+        const TChar /*tone*/)
     {
     TRACE_PRN_FN_ENT;
     TmsMsgBufPckg dtmfpckg;
 
-    TRACE_PRN_N1(_L("**TMS TMSCallCSAdpt::HandleDTMFEvent error:%d"),aError);
-
-    dtmfpckg().iStatus = TMSUtility::EtelToTMSResult(aError);
+    TRACE_PRN_N1(_L("**TMS TMSCallCSAdpt::HandleDTMFEvent error:%d"), status);
 
-    switch (aEvent)
+    dtmfpckg().iStatus = TMSUtility::EtelToTMSResult(status);
+
+    switch (event)
         {
-
         case ECCPDtmfUnknown:               //Unknown
             break;
         case ECCPDtmfManualStart:           //DTMF sending started manually
@@ -1117,78 +1174,59 @@
     TRACE_PRN_FN_EXT;
     }
 
-// From TMSCSPDevSoundObserver
-
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::DownlinkInitCompleted
-//
+// From TMSCSDevSoundObserver
 // -----------------------------------------------------------------------------
 //
 void TMSCallCSAdpt::DownlinkInitCompleted(gint status)
     {
     TRACE_PRN_FN_ENT;
-    NotifyClient(iDnlinkStreamId, ECmdDownlinkInitComplete, status, 0);
+    if (status == TMS_RESULT_SUCCESS)
+        {
+        iDnlinkInitialized = TRUE;
+        }
+    NotifyClient(iDnlinkStreamId, ECmdDownlinkInitComplete, status);
     TRACE_PRN_FN_EXT;
     }
 
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::UplinkInitCompleted
-//
+// From TMSCSDevSoundObserver
 // -----------------------------------------------------------------------------
 //
 void TMSCallCSAdpt::UplinkInitCompleted(gint status)
     {
     TRACE_PRN_FN_ENT;
-    NotifyClient(iUplinkStreamId, ECmdUplinkInitComplete, status, 0);
-    TRACE_PRN_FN_EXT;
-    }
-
-// -----------------------------------------------------------------------------
-// TMSCallCSAdpt::UplinkActivatedSuccessfully
-//
-// -----------------------------------------------------------------------------
-//
-void TMSCallCSAdpt::UplinkActivatedSuccessfully()
-    {
-    TRACE_PRN_FN_ENT;
-    NotifyClient(iUplinkStreamId, ECmdUplinkStarted, KErrNone, 0);
-    TRACE_PRN_FN_EXT;
-    }
-
-// -----------------------------------------------------------------------------
-// TMSCallCSAdpt::DownlinkActivatedSuccessfully
-//
-// -----------------------------------------------------------------------------
-//
-void TMSCallCSAdpt::DownlinkActivatedSuccessfully()
-    {
-    TRACE_PRN_FN_ENT;
-    NotifyClient(iDnlinkStreamId, ECmdDownlinkStarted, KErrNone, 0);
+    if (status == TMS_RESULT_SUCCESS)
+        {
+        iUplinkInitialized = TRUE;
+        }
+    NotifyClient(iUplinkStreamId, ECmdUplinkInitComplete, status);
     TRACE_PRN_FN_EXT;
     }
 
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::UplinkActivationFailed
-//
+// From TMSCSDevSoundObserver
 // -----------------------------------------------------------------------------
 //
-void TMSCallCSAdpt::UplinkActivationFailed()
+void TMSCallCSAdpt::UplinkActivationCompleted(gint status)
     {
     TRACE_PRN_FN_ENT;
-    NotifyClient(iUplinkStreamId, ECmdUplinkStarted, TMS_RESULT_FATAL_ERROR, 0);
+    NotifyClient(iUplinkStreamId, ECmdUplinkStarted, status);
     TRACE_PRN_FN_EXT;
     }
 
 // -----------------------------------------------------------------------------
 // TMSCallCSAdpt::DownlinkActivationFailed
-//
+// From TMSCSDevSoundObserver
 // -----------------------------------------------------------------------------
 //
-void TMSCallCSAdpt::DownlinkActivationFailed()
+void TMSCallCSAdpt::DownlinkActivationCompleted(gint status)
     {
     TRACE_PRN_FN_ENT;
-    NotifyClient(iDnlinkStreamId, ECmdDownlinkStarted,
-            TMS_RESULT_FATAL_ERROR, 0);
+    NotifyClient(iDnlinkStreamId, ECmdDownlinkStarted, status);
     TRACE_PRN_FN_EXT;
     }
 
@@ -1229,7 +1267,7 @@
 // -----------------------------------------------------------------------------
 //
 void TMSCallCSAdpt::SetOutputComplete(
-        CTelephonyAudioRouting& aTelephonyAudioRouting, gint /*aError*/)
+        CTelephonyAudioRouting& aTelephonyAudioRouting, gint /*status*/)
     {
     TRACE_PRN_FN_ENT;
     TRoutingMsgBufPckg pckg;